Using Simulink to analyze 2 degrees of freedom system Nasser M. Abbasi Spring 29 page compiled on June 29, 25 at 4:2pm Abstract A two degrees of freedom system consisting of two masses connected by springs and subject to 3 different type of input forces is analyzed and simulated using Simulink Contents Introduction and Theory 2 2 Analytical solution 2 2. Finding the homogenous solution.................................... 3 2.2 Finding particular solutions....................................... 5 2.2. Finding the particular solution for unit impulse input.................... 6 2.2.2 Finding the particular solution for unit step input...................... 6 2.2.3 Finding the particular solution for sin ωt............................ 6 3 Simulink simulation and block diagrams 7 3. Unit step simulink diagram and output................................ 8 3.. Verification of result from Simulink by Numerically solving the differential equations... 9 4 Unit impulse simulink diagram and output 4.. Verification of result from Simulink by Numerically solving the differential equations... 4. sin ωt input simulink diagram and output.............................. 2 5 Discussion 4
Introduction and Theory The system that is being analyzed is show in the following diagram Ft m x k m 2 k 2 In the above, F t is to be taken as each of the following. Unit impulse force. 2. Unit step force. 3. sin ωt It is required to find x t and t analytically and then to use Matlab s Simulink software for the analysis. The mathematical model of the system is first developed and the equation of motions obtained using Lagrangian formulation then the analytical solution is found by solving the resulting coupled second order differential equations for m and m 2. Next, a simulink model is developed to implement the differential equations and the output x t and t from Simulink is shown and compared to the output from the analytical solution. 2 Analytical solution The following is the free body diagram of the above system 2
Ft m x K -x K -x m 2 K 2 Assuming positive is downwards and that > x, force-balance equations for m results in And force-balance equations for m 2 results in m ẍ F t k x m 2 ẍ 2 k x k 2 Hence the EQM for the system become m ẍ k k x F t m 2 ẍ 2 k k 2 k x Or in matrix form m m 2 ẍ ẍ 2 k k k k k 2 x F t The above can be written in matrix form as Mẍ Kx F Where ẍ, x, F are 2 by vectors and M and K are the mass and stiffness matrices. The solution to the above is x x h x p 2. Finding the homogenous solution We start by finding x h from the following m m 2 ẍ ẍ 2 k k k k k 2 x 3
Now assume x t A cos ωt φ and t A 2 cos ωt φ, hence ẋ t ωa sin ωt φ and ẋ 2 t ωa 2 sin ωt φ and ẍ t ω 2 A cos ωt φ and ẋ 2 t ω 2 A 2 cos ωt φ. Substituting the above values in the above system results in m ω 2 A cos ωt φ k k A cos ωt φ m 2 ω 2 A 2 cos ωt φ k k k 2 A 2 cos ωt φ Divide by cos ωt φ since not zero else no solution exist we obtain m ω 2 A k k A m 2 ω 2 A 2 k k k 2 A 2 Rewrite the above as ω 2 m A k A k A 2 ω 2 m 2 A 2 k A k k 2 A 2 ω 2 m A k A k A 2 ω 2 m 2 A 2 k A k k 2 A 2 ω 2 m k A k A 2 ω 2 m 2 A 2 k k 2 A 2 k A ω 2 m k k A k ω 2 m 2 k k 2 A 2 2 From the last equation above, we see that to obtain a solution we must have ω 2 m k k k ω 2 m 2 k k 2 since if we had results in A A 2 then no solution will exist. Therefore, taking the determinant and setting it to zero Let ω 4 λ 2, hence the above becomes Solving for λ gives ω 2 m k ω 2 m 2 k k 2 k 2 k 2 k k 2 ω 2 k m ω 2 k m 2 ω 2 k 2 m ω 4 m m 2 k 2 ω 4 m m 2 ω 2 k m k 2 m k m 2 k 2 k k 2 k 2 λ 2 m m 2 λ k m k 2 m k m 2 k 2 k k 2 k 2 λ 2m m 2 k m k m 2 k 2 m k 2m2 k2 m2 2 k2 2 m2 2k k 2 m 2 2k2 m m 2 2k k 2 m m 2 λ 2 2m m 2 k m k m 2 k 2 m k 2m2 k2 m2 2 k2 2 m2 2k k 2 m 2 2k2 m 3 m 2 2k k 2 m m 2 For each of the above solutions, we obtain a different A 4 A 2 from equation 2 as follows
For λ, 2 becomes λ m k k A k λ m 2 k k 2 A 2 λ m k A k A 2 k A λ m 2 A 2 k k 2 A 2 From the first equation above, we have λ m k A k A 2 λ m k k A2 A Similarly for λ 2, Let λ 2 m k k 2 A2 A Hence now x h can be written as x h r λ m k k r 2 λ 2m k k A2 A 2 A2 A A cos ω t φ A 2 cos ω 2 t φ 2 A 2 cos ω t φ A 2 2 cos ω 2 t φ 2 4 But A 2 r A and A 2 2 r 2 A 2 x h, hence the above becomes A cos ω t φ A 2 cos ω 2 t φ 2 r A cos ω t φ r 2 A 2 cos ω 2 t φ 2 5 Now, given numerical values for k, k 2, m, m 2 we can find ω, ω 2 from 3 above, and next find r, r 2 from 4. Hence 5 contains 4 unknowns, A, A2, φ, φ 2 which now can be found from initial conditions after we find the particular solution which we will now proceed to do. 2.2 Finding particular solutions There are 3 different F t which we are asked to consider. Unit impulse force. 2. Unit step force. 3. sin ωt For each of the above, we find x p and then add it to x h found above in 5 to obtain. 5
2.2. Finding the particular solution for unit impulse input Using the standard response for a unit impulse which for a single degree of freedom system is x t mω n sin ω n t, then we write x p as x mω x p sin ω t mω 2 sin ω 2 t Hence, the general solution becomes x A cos ω t φ A 2 cos ω 2 t φ 2 r A cos ω t φ r 2 A 2 cos ω 2 t φ 2 2.2.2 Finding the particular solution for unit step input Since unit step is for t >, then, using convolution we write p p x p t t t t mω n f τ h t τ dτ h t τ dτ sin ω n t τ dτ mω n [ cos ωn t τ ω n mωn 2 [cos ω n t τ] t mωn 2 [ cos ω n t] mω sin ω t Then, since now we have 2 natural frequencies, we can write x p as x x p [ cos ω mω 2 t] [ cos ω mω2 2 2 t] Hence, the general solution becomes x A cos ω t φ A 2 cos ω 2 t φ 2 r A cos ω t φ r 2 A 2 cos ω 2 t φ 2 2.2.3 Finding the particular solution for sin ωt mω 2 ] t [ cos ω t] mω2 2 mω 2 sin ω 2 t [ cos ω 2 t] In this case, we guess that x p c cos ωt c 2 sin ωt, and since there is no forcing function being applied directly on m 2 then p hence x t c cos ωt c 2 sin ωt x p t p Then ẋ p t ωc sin ωt ωc 2 cos ωt and ẍ p t ω 2 c cos ωt ω 2 c 2 sin ωt and now we substitute these into the original ODE for x which is m ẍ k k x F t m ẍ p k p k x p sin ωt 6 6
We obtain the following m ω 2 c cos ωt ω 2 c 2 sin ωt k k c cos ωt c 2 sin ωt sin ωt Hence by comparing coefficients, we obtain or cos ωt ω 2 c m k c sin ωt m ω 2 c 2 k c 2 sin ωt ω 2 c m k c m ω 2 c 2 k c 2 c ω 2 m k c 2 m ω 2 k c must be zero since k ω 2 m only when ω ω n and we assume that this is not the case here. Hence c c 2 m ω 2 k Therefore x p becomes And the general solution becomes x x p x t t p m ω 2 k sin ωt A cos ω t φ A 2 cos ω 2 t φ 2 r A cos ω t φ r 2 A 2 cos ω 2 t φ 2 m ω 2 k sin ωt 8 3 Simulink simulation and block diagrams In simulink, we will directly solve the system from the original formulation or Hence m ẍ k k x F t m 2 ẍ 2 k k 2 k x ẍ k k x F t m m m ẍ 2 k k 2 k x m 2 m 2 ẍ F t m k m k m x ẍ 2 k k 2 m 2 k m 2 x 7
3. Unit step simulink diagram and output The simulink block diagram will be as follows for the unit step input For an initial run with parameters m m 2 k k 2 I get this warning below EDU>> simulink Warning: Using a default value of.2 for maximum step size. The simulation step size will be equal to or less than this value. You can disable this diagnostic by setting 'Automatic solver parameter selection' diagnostic to 'none' in the Diagnostics page of the configuration parameters dialog. And this is the output for x t and t for the unit step response 8
3.. Verification of result from Simulink by Numerically solving the differential equations To verify the above output from Simulink, I solved the same coupled differential equations for zero initial conditions numerically using a numerical differential equation solver and plotted the solution for x t and t and the result matches that shown above by simulink. Here is the code the plot as a result of this verification k ; k 2 ; m ; m 2 ; eq m x ''[t] - k [t] k x [t] f[t] eq2 m 2 ''[t] k k 2 [t] - k x [t] sol NDSolve[{eq, eq2, x [], x '[], [], '[] }, {x [t], [t]}, {t,, 35}]; 9
4 Solutions x t and t 3 x t t xt 2 unit step input 5 5 2 25 3 35 t 4 Unit impulse simulink diagram and output
And the output for x t and t is as follows run with parameters m m 2 k k 2 Mass m Mass m 2 INPUT Mass m 2 Solution to the following coupled second order differential equations when Ft is a unit impulse m x k k x F t m 2 x 2 k k 2 k x 4.. Verification of result from Simulink by Numerically solving the differential equations To verify the above output from Simulink, The same coupled differential equations were solved numerically for zero initial conditions numerically and the solution plotted for x t and t and the result was found to match that shown above by simulink. Here is the code used to do the verification verification
f[x_] : Piecewise[{{, x < }, {, x >.}, {, True}}] k ; k 2 ; m ; m 2 ; eq m x ''[t] - k [t] k x [t] f[t] eq2 m 2 ''[t] k k 2 [t] - k x [t] sol NDSolve[{eq, eq2, x [], x '[], [], '[] }, {x [t], [t]}, {t,, 35}]; sol Chop[sol] sol x [t] /. sol sol2 [t] /. sol Plot[Evaluate[{f[t], sol, sol2}], {t,, 35}, Frame True, FrameLabel {{"xt", None}, {"t", "Solutions x t and t"}}] Solutions x t and t.2.5 x t. xt.5. -.5 t -. 5 5 2 25 3 35 t 4. sin ωt input simulink diagram and output The simulink block diagram will be as follows for the sin ωt input 2
For an initial run with parameters m m 2 k k 2 this is the output for x t and t and showing the input signal at the same time 3
5 Discussion A coupled system of two masses and springs was analyzed using Simulink. The simulation was done for one set of parameters masses and stiffness. Simulink made the simulation of this system under different loading conditions easy to do. The 2 masses response were recorded using simulink scope and the signals captured on the same plot to make it easy to compare the response of the first mass to the second mass. The analytical analysis was more time consuming than actually making the simulation in simulink. The ability to easily change different sources to the system was useful as well as the ability to change the frequency of the input and immediately see the effect on the response. This was my first project using Simulink, and I can see that this tool will be useful to learn more as it allows one to easily analyze engineering problems. 4