I'm trying to determine the amplitude vs the excitation frequency of a multi dof dynamic system. I'm very confused from reading different methods, although I understand there's a very general one, which is not giving me the results that I think should be when plotting the response. Considering a system with no damping $\mathbf{M{\ddot x}+{Kx}=F(t)}$, and by assuming the harmonic excitation of the force is a cosine the system becomes $\mathbf{-MX{cos(\omega t)}+{KX}cos(\omega t)=fcos(\omega t)}$. From here the cosines get cancelled out so only $\mathbf{[K-M{\omega^2}]X=f}$ remains. By solving for the $X$ vector in the end I get $X = \frac{F/M}{|\omega_n^2-\omega^2|}$.
So with Matlab I wrote the following code, with parameters I found on an example from brown.edu, in which the explanation is not complete, my system is actually a 24 DoF system, so I need the code a bit automated:
k1 = 2;
k2 = 1;
k3 = 1;
m1 = 1;
m2 = 1;
M=[m1 0; ...
0 m2];
K=[k1+k2 -k2; ...
-k2 k3+k3];
F=[1;...
1];
[V,D] = eig(K,M);
D = diag(sqrtm(D));
frequencies = (D);
[rows,~] = size(V);
f=linspace(0,0.7,100);
omega=2*pi*f;
Mag = M\F;
Xt = zeros(rows, length(omega));
for i = 1:rows
for j = 1:length(omega)
Xt(i,j) = abs((frequencies(i)^2 - omega(j)^2)\Mag(i)) ;
end
end
figure
for m = 1:length(frequencies)
plot(omega, Xt(m,:));
set(gca,'YScale','log')
hold on
axis tight
end
Where the main part is the Xt(i,j) = (abs (frequencies(i)^2 - omega(j)^2)\Mag(i) );
, which follows the determined formula for the displacements of each degree of freedom.
which shows the masses vibrations being at resonance, but from what I understand there should be more peaks and some antiresonance.
What am I missing in the general math?
EDIT_1: I changed the bit of the code to calculate the absolute values of the equation like: $$X(\omega) = \left|\sum_n \frac{F/M}{\omega_n^2 - \omega^2}\right|$$ but I get the same when plotting. I found another solution but I don't understand how its determined or why choose it. From ${M{\ddot x_i}+{Kx_i}=f(t)sin\omega t}$ the steady state solution is $x_{iss} = x_{is} sin \omega t + x_{ic} cos \omega t$ , where $i = 1,2$ , then $$ \begin{bmatrix} \mathbf{-(\omega)^2M+{K}} & \mathbf{0} \\ \mathbf{0} & \mathbf{-(\omega)^2M+{K}} \end{bmatrix} \begin{bmatrix} \mathbf{x_{ic}} \\ \mathbf{x_{is}} \end{bmatrix} = \begin{bmatrix} \mathbf{0} \\ \mathbf{f} \end{bmatrix} $$ which is then solved to get ${X_{i}} = (x_{ic} + x_{is} )^{1/2}$ First, I don´t understand very well if just $x_{iss}$ is substituted in ${M{\ddot x_i}+{Kx_i}=f(t)sin\omega t}$ for $x_i$. And is this just assuming a sum of $cos$ and $sin$ instead of my first approach of only $cos$? Then, do I need to consider adding the transient response also, which I´m actually not sure how it would be.
EDIT_2: I think I figured out what I was doing wrong. I changed the equation from $$X(\omega) = \left|\sum_n \frac{F/M}{\omega_n^2 - \omega^2}\right|$$ to $$ X = [K-M\omega^2]^{-1}F$$ which mathematically I though they were the same??? The code part that changed is as follows:
for j = 1:length(omega)
Xt(:,j) = abs((K-M*omega(j)^2)\F);
end
figure
for m = 1:length(frequencies)
plot(omega,Xt(m,:))
hold on
axis tight
end
For my extended MDoF system I got:
In which I excited all DoF, even when I only excite a single one, it is still very hard to notice what's going on, is there a better way of analysing the response?