Discussion:
Solving SDOF system in freq domain using FFT & IFFT
(too old to reply)
Michael Harte
2010-06-03 09:46:06 UTC
Permalink
Hello,
So I want to use FFT & IFFT to solve a simple SDOF system (so that i can move on and use a freq domain method to solve more complex dynamic models). I've solved a simple SDOF system with a sin wave forcing function in time domain using ode45 and then was looking to get the same results using freq domain approach using a FFT and IFFT method,
Im aware of the method, transform the input time history
p(t)-FFT-P(w)
Calculate the response of the SDOF system in the frequency domain using the transfer (frequency response) function
U(w)=H(w)P(w)
Use the inverse FFT to obtain the response of the SDOF system in the time domain
U(w)-IFFT-u(t)

And my code is as follow

%frequency domain

function freqsdof ()

m = 2;
k = 10;
c = 0.26;

wn = sqrt(k/m); %nat freq
I = c/(2*m*wn);

t = linspace(1,100,10000);
dt = t(1,2) - t(1,1);
% dt = 1;
f = sin(t);

ff = (f/m) ; %load divided by mass

Qi = fft((ff)) ;

N = length(f);
fs = 1/(dt);
Q_hertz = ( 0:(N-1) )*fs/N; %Freq in Herz
Q_w = 2*pi*Q_hertz ; %Cir freq in rads per second


Qf = Qi(1: ceil(N/2));

wQ = Q_w(1: ceil(N/2));


m = length (Qf);


for n = 1:m


X1(n,1) = ( ( (wn^2 - wQ(1,n)^2) + (i*2*I*wn*wQ(1,n)) )^-1 *(Qf(1,n)) );

%Conjugates of above line
X2(n,1) = ( ( (wn^2 - wQ(1,n)^2) - (i*2*I*wn*wQ(1,n)))^-1 * conj(Qf(1,n)));

end



x (1:m,1) = X1(:,1);
x ( ((m+1):(m*2)),1 ) = X2(:,1);


x1 = ifft( x );

tspan = linspace(1,100,(2*m));

figure
plot ( tspan, real(x1) );
title('Freq domain')


end


However im not getting the right results,
I think the problem is where i have to get the complex conjugate of the values.

Can anyone please help!
Thanks in advance!
IJssebrand
2013-10-09 08:40:09 UTC
Permalink
Did you find a solution to this issue? I am struggling with the same problem.
Post by Michael Harte
Hello,
So I want to use FFT & IFFT to solve a simple SDOF system (so that i can move on and use a freq domain method to solve more complex dynamic models). I've solved a simple SDOF system with a sin wave forcing function in time domain using ode45 and then was looking to get the same results using freq domain approach using a FFT and IFFT method,
Im aware of the method, transform the input time history
p(t)-FFT-P(w)
Calculate the response of the SDOF system in the frequency domain using the transfer (frequency response) function
U(w)=H(w)P(w)
Use the inverse FFT to obtain the response of the SDOF system in the time domain
U(w)-IFFT-u(t)
And my code is as follow
%frequency domain
function freqsdof ()
m = 2;
k = 10;
c = 0.26;
wn = sqrt(k/m); %nat freq
I = c/(2*m*wn);
t = linspace(1,100,10000);
dt = t(1,2) - t(1,1);
% dt = 1;
f = sin(t);
ff = (f/m) ; %load divided by mass
Qi = fft((ff)) ;
N = length(f);
fs = 1/(dt);
Q_hertz = ( 0:(N-1) )*fs/N; %Freq in Herz
Q_w = 2*pi*Q_hertz ; %Cir freq in rads per second
Qf = Qi(1: ceil(N/2));
wQ = Q_w(1: ceil(N/2));
m = length (Qf);
for n = 1:m
X1(n,1) = ( ( (wn^2 - wQ(1,n)^2) + (i*2*I*wn*wQ(1,n)) )^-1 *(Qf(1,n)) );
%Conjugates of above line
X2(n,1) = ( ( (wn^2 - wQ(1,n)^2) - (i*2*I*wn*wQ(1,n)))^-1 * conj(Qf(1,n)));
end
x (1:m,1) = X1(:,1);
x ( ((m+1):(m*2)),1 ) = X2(:,1);
x1 = ifft( x );
tspan = linspace(1,100,(2*m));
figure
plot ( tspan, real(x1) );
title('Freq domain')
end
However im not getting the right results,
I think the problem is where i have to get the complex conjugate of the values.
Can anyone please help!
Thanks in advance!
Aditya Kumar
2023-03-02 07:24:48 UTC
Permalink
Post by IJssebrand
Did you find a solution to this issue? I am struggling with the same problem.
Post by Michael Harte
Hello,
So I want to use FFT & IFFT to solve a simple SDOF system (so that i can move on and use a freq domain method to solve more complex dynamic models). I've solved a simple SDOF system with a sin wave forcing function in time domain using ode45 and then was looking to get the same results using freq domain approach using a FFT and IFFT method,
Im aware of the method, transform the input time history
p(t)-FFT-P(w)
Calculate the response of the SDOF system in the frequency domain using the transfer (frequency response) function
U(w)=H(w)P(w)
Use the inverse FFT to obtain the response of the SDOF system in the time domain
U(w)-IFFT-u(t)
And my code is as follow
%frequency domain
function freqsdof ()
m = 2;
k = 10;
c = 0.26;
wn = sqrt(k/m); %nat freq
I = c/(2*m*wn);
t = linspace(1,100,10000);
dt = t(1,2) - t(1,1);
% dt = 1;
f = sin(t);
ff = (f/m) ; %load divided by mass
Qi = fft((ff)) ;
N = length(f);
fs = 1/(dt);
Q_hertz = ( 0:(N-1) )*fs/N; %Freq in Herz
Q_w = 2*pi*Q_hertz ; %Cir freq in rads per second
Qf = Qi(1: ceil(N/2));
wQ = Q_w(1: ceil(N/2));
m = length (Qf);
for n = 1:m
X1(n,1) = ( ( (wn^2 - wQ(1,n)^2) + (i*2*I*wn*wQ(1,n)) )^-1 *(Qf(1,n)) );
%Conjugates of above line
X2(n,1) = ( ( (wn^2 - wQ(1,n)^2) - (i*2*I*wn*wQ(1,n)))^-1 * conj(Qf(1,n)));
end
x (1:m,1) = X1(:,1);
x ( ((m+1):(m*2)),1 ) = X2(:,1);
x1 = ifft( x );
tspan = linspace(1,100,(2*m));
figure
plot ( tspan, real(x1) );
title('Freq domain')
end
However im not getting the right results,
I think the problem is where i have to get the complex conjugate of the values.
Can anyone please help!
Thanks in advance!
I need help with the same problem

Loading...