0% found this document useful (0 votes)
104 views50 pages

Capitulo 9 Practical MATLAB Modeling With Simulink Programming and Simulating

Uploaded by

Eduardo Roblero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views50 pages

Capitulo 9 Practical MATLAB Modeling With Simulink Programming and Simulating

Uploaded by

Eduardo Roblero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

CHAPTER 9

Spring-Mass-Damper
Systems
This chapter covers several essential aspects and approaches how to build simulation
models of spring-mass-damper systems in MATLAB and Simulink environments. The
equations of motions of one, two, three degree of freedom spring-mass-damper systems
are derived and MATLAB/Simulink models are built based on the derived mathematical
formulations. Free and forced motions of the spring-mass-damper systems are
studied, and linear and non-linear behaviours of the spring-mass-damper systems are
considered. The developed simulation models of one, two and three degree of freedom
systems can be applied for multipled degree of freedom systems.

 ingle Degree of Freedom System


S
Case 1: Free Vibration (Motion)
Let’s consider a single degree of freedom (DOF) spring-mass-damper (SMD) system
of a nonlinear type formulated by Mu + C u u + Ku = 0 , u ( 0 ) = 0 , and u ( 0 ) = 1 , where
M is a mass, C is damping, and K is stiffness of the system. Note that the formulation of
the system is a second-order homogenous ODE, and there is no external force applied.
The system oscillates with respect to its initial conditions. In other words, its response
depends on its initial displacement and velocity values.
Likewise, when solving the initial value problems of ODEs, the first step to build a
simulation model of the given problem is to rewrite its equation of motion.

C u u + Ku ( t )
u = - (9-1)
M

295
© Sulaymon L. Eshkabilov 2020
S. L. Eshkabilov, Practical MATLAB Modeling with Simulink, https://doi.org/10.1007/978-1-4842-5799-9_9
Chapter 9 Spring-Mass-Damper Systems

The second-order ODE, shown in Equation (9-1), can be represented by the next two
differential equations by introducing a new variable, as explained in Part 1 of the book,
to solve the second-order ODEs numerically.

ìu1 = u2
ï (9-2)
í C u2 u2 + Ku1
ïu 2 = -
î M

The given system model will be of a stiff-type ODE if the magnitude of its mass is much
Ns N
smaller than its stiffness and damping, for instance: M = 1 kg , C = 1001 , K = 1000 .
m m
Let’s write a script in a function file (SMDode.m) with three input arguments (M, C, K)
based on the first ODEs shown in Equation (9-2). We are using the ODE solver ode15s since
the given problem is a stiff ODE type. Note that we also introduce the Jacobian
matrix of the given system in Equation (9-2) as the nested function function dfdu =
Jacobian(t, u). The expression shown in Equation (9-2) is coded within the nested
function function dudt = f(t, u). Having the Jacobian matrix defined speeds up the
simulation process of the MATLAB ODE solvers.

function  SMDode(Mass,Damping, Stiffness)
%{
SMDode.m. Spring-Mass-Damper system behavior analysis
with the given Mass, Damping and Stiffness values.
Note: an order of input argument data is important.
The system's damper has non-linear properties expressed
with D*|u'|*u' e.g., abs(velocity)*velocity
Solver ode15s is employed; yet, other solvers, viz.
ODE15S, ODE23S, ODE23T, ODE23TB, can be used, as well.
%}

if nargin < 1
%  Some default values for parameters: Mass, Damping & Stiffness
%  in case not specified by the user
   Mass = 1;          % [kg]
   Damping=1001;      % [Ns/m]
   Stiffness=1000;    % [N/m]
end

296
Chapter 9 Spring-Mass-Damper Systems

tspan = [0; min(20,5*(Damping/Mass))]; % Several periods


u0 = [0; 1];                           % Initial conditions
% Options for ODESETs can be switched off
options = odeset('Jacobian',@Jacobian);
% [t,u] = ode15s(@f,tspan,u0,[]); % without options
[t,u] = ode15s(@f,tspan,u0,options);

figure;
plot(t,u(:,1),'r-', t, u(:,2), 'b-.', 'MarkerSize', 5,...
    'LineWidth', 1.5);
title(['\it Spring-Mass-Damper System: ',...
'M = ' num2str(Mass), '[kg]' '; D = ' num2str(Damping),...
'[Ns/m]', '; S = ' num2str(Stiffness), '[N/m]']);
xlabel('time t')
grid on
axis tight
axis([tspan(1) tspan(end) -0.1 0.1]); % Axis limits are set
hold on
Acceleration=-(Damping/Mass)*abs(u(:,2)).*u(:,2)-...
(Stiffness/Mass)*u(:,1);
plot(t, Acceleration,'k--', 'MarkerSize', 3, 'LineWidth', 1);
legend('Displacement', 'Velocity', 'Acceleration');
ylabel('Displacement, Velocity, Acceleration')
hold off; xlim([0, 3])
% -----------------------------------------------------------
% Nested functions: Mass, Damping and Stiffness are provided
% by the outer function.
%------------------------------------------------------------
  function dudt = f(t, u)
% Derivative function.  Mass, Damping and Stiffness are provided
% by the outer function or taken default (example values)
  dudt = [            u(2);
        -(Damping/Mass)*abs(u(2))*u(2)-(Stiffness/Mass)*u(1) ];
  end

297
Chapter 9 Spring-Mass-Damper Systems

% -----------------------------------------------------------
  function dfdu = Jacobian(t, u)
% Jacobian function. Mass, Damping and Stiffness are provided by
% the main function or taken default values for no inputs.
    dfdu = [         0,                  1;
             -(Stiffness/Mass),  -(Damping/Mass)*abs(u(2))-...
             (Damping/Mass)*u(2)*sign(u(2)) ];
  end %
% -----------------------------------------------------------
end  % SMDode.m

From the simulation results plotted in Figure 9-1, it is clear that the system is over-­
damped. In studies of spring-mass-damper systems, it is important to study not only the
overall system behavior but also its natural frequency, damping level (lightly damped, under-
damped, and over-damped case scenarios), and influence of the system parameter changes.
All of these studies can be introduced additionally into a simulation model of the system.

Figure 9-1.  Simulation of the spring-mass-damper system


298
Chapter 9 Spring-Mass-Damper Systems

Let’s reconsider the previous problem of the single degree of freedom SMD system to
study its free motion when the system is linear, i.e., u is not present: Mu + Cu + Ku = 0 .
This can be rewritten by dividing it by M (mass), as shown here:

C K
u + u + u = 0 (9-3)
M M

In this new formulation, the following substitutions can be introduced:

K C
= wn2 ; = 2zwn (9-4)
M M

where ωn is the natural frequency of the system and ζ is the damping ratio.
The problem formulation can be rewritten again like this:

u + 2zwn u + wn2u = 0 (9-5)

That equation has a general solution of the following form:

u ( t ) = Ae r1t + Be r2t (9-6)


where the unknown coefficients A and B are computed from the initial conditions
( u ( 0 ) = u0 , u ( 0 ) = u 0 ) using the next general equations:

u0 r2 - u 0
A= (9-7)
r2 - r1

u 0 - u0 r1
B= (9-8)
r2 - r1

By plugging the general solution into the given problem formulation of Equation (9-5),
we obtain the following characteristic equation:

r 2 + 2zwn r + wn2 = 0 (9-9)

299
Chapter 9 Spring-Mass-Damper Systems

The roots (roots r1 and r2) of this quadratic characteristic equation are as follows:


r1, 2 = (-2zwn ± ( 2zwn )
2
)
- 4wn2 / 4wn2
(9-10)

The roots (r1 and r2) depend on the parameters, namely, ωn and ζ. Let’s look at four
case scenarios [1, 2] to compute them.
Case Scenario I. Undamped. ζ = 0.The problem formulation is as follows:

u + wn2 u = 0 , u ( 0 ) = u0 , u ( 0 ) = u 0 (9-11)

The solutions of the differential equation in (9-11) are r1 = i ωn; r2 =  − i ωn, and the
solutions for real system cases are available for: M > 0 and K > 0 .
The solution is as follows:

u 0
u ( t ) = u0 cos (wn t ) + sin (wn t ) (9-12)
wn

Note that this solution is obtained using some substitutions, such as the Euler
formula we’ve used in previous chapters (eiθ =  cos θ + i sin θ) and the general solution
formulation shown earlier in Equation (9-6).
The following is another formulation of the solution:

æ u 2 ö
u ( t ) = ç u02 + 02 ÷ sin (wn t + j ) (9-13)
ç wn ÷
è ø

æw u ö
j = tan -1 ç n 0 ÷ (9-14)
è u 0 ø

where φ is the phase shift angle. Note that both solution formulations, shown in
Equations (9-12) and (9-13), are equivalent and can be derived from one another.
Case Scenarios II. Underdamped. 0 < c2 < 4 MK or 0 < ζ < 1. The roots of the general
solution in Equation (9-6) are as follows:

r1 = é -z + i
ëê
(1 - z ) ùûú w
2
n

(9-15)

r2 = é -z - i
êë (1 - z ) ùúû w
2
n
(9-16)

300
Chapter 9 Spring-Mass-Damper Systems

Damping is present, and the damped natural frequency of the system will be as
follows:


wd = wn (1 - z ) 2
(9-17)

Thus, the solution is as follows:

æ u zw + u 0 ö
u ( t ) = e -zwnt ç uo cos (wd t ) + 0 n sin (wd t ) ÷
è wd ø (9-18)

Case Scenario III. Overdamped. c2 > 4 MK or ζ > 1. The roots of the general solution
equation shown in Equation (9-6) are as follows:

r1 = é -z -
ëê
(z 2
- 1) ù wn
ûú
(9-19)

r2 = é -z +
ëê
(z 2
- 1) ù wn
ûú
(9-20)

The coefficients of the general solution equation shown in Equation (9-6) are as
follows:

é z ù u 0
A = u0 ê ú- (9-21)
êë 2 z - 1 úû 2wn z 2 - 1
2

é z ù u 0
B = u0 ê ú+ (9-22)
êë 2 z 2 - 1 úû 2wn z 2 - 1

Finally, the solution equation is as follows:

é é z ù u 0 ù éê-z - (z 2 -1) ùúwn


u ( t ) = Ae r1t + Be r2t = êu0 ê ú+ úeë û
+
êë êë 2 z 2 - 1 úû 2wn z 2 - 1 úû
(9-23)
é é z ù 
u0 ù ( )
é -z + z 2 -1 ù w
ê -u0 ê ú e ëê ûú
n
ú+
êë êë 2 z - 1 úû 2wn z - 1 úû
2 2

301
Chapter 9 Spring-Mass-Damper Systems

Case Scenario IV. Critically damped. ζ = 1 (critical damping), c2 = 4MK. The roots of


the general solution equation shown in Equation (9-6) are as follows:

r1 = r2 = -wn (9-24)

The coefficients of the general solution equation shown in Equation (9-6) are as
follows:

A = u0 , B = u 0 + wn u0 (9-25)

The solution equation is composed of two linearly independent solutions.

u ( t ) = ( A + Bt ) e -wnt (9-26)

Here we have skipped some of the details of deriving solutions in four case scenarios.
A few essential details of the derived formulations shown in Equations (9-7) to (9-26) can
be found in [3].
A complete simulation model of the previous case scenarios can be programmed
with a nested function. Out=SMDsysSim(M, D, S, ICs, t) embedded within the
m-­file SMDsysSIM_compare.m that simulates all four scenarios based on five input entries,
namely, M, D, S, ICs, t. The input entries are mass (M), damping (D), stiffness (S),
initial conditions (ICs), and time vector (t).

clearvars; close all


% Input Data for Scenarios I - IV.
M1=1; D1=0; S1=25;   % Scenario I. No damping
M2=1; D2=2; S2=25;   % Scenario II. Underdamped
M3=1; D3=13; S3=25;  % Scenario III. Over-damped
M4=1; D4=10; S4=25;  % Scenario IV. Critically damped
ICs=[0.1, 0]; t=0:.05:5;
% Displacement:
ut1=SMDsysSim(M1, D1, S1, ICs, t);
ut2=SMDsysSim(M2, D2, S2, ICs, t);
ut3=SMDsysSim(M3, D3, S3, ICs, t);
ut4=SMDsysSim(M4, D4, S4, ICs, t);
% Velocity:

302
Chapter 9 Spring-Mass-Damper Systems

dut1=diff(ut1);
dut2=diff(ut2);
dut3=diff(ut3);
dut4=diff(ut4);
figure(1)
plot(t, ut1, 'b-',  'linewidth', 1.5), hold on
plot(t, ut2, 'r-.', 'linewidth', 1.5)
plot(t, ut3, 'k:',  'linewidth', 2)
plot(t, ut4, 'g--', 'linewidth', 1.5)
xlabel('time, [s]'); ylabel('System response, [m]'), grid on,
title('1-DOF Spring-Mass-Damper System simulation - 4 Scenarios'),
legend('No damping: \zeta=0',' Underdamped: 0<\zeta<1',...
'Overdamped: \zeta>1','Critically damped: \zeta=1'), hold off
figure(2)
plot(ut1(2:end), dut1, 'b-',  'linewidth', 1.5),
hold on
plot(ut2(2:end), dut2, 'r-.','linewidth', 1.5)
plot(ut3(2:end), dut3, 'k:', 'linewidth', 2)
plot(ut4(2:end), dut4, 'g--',  'linewidth', 1.5)
xlabel('time, [s]');
ylabel('System response, [m]')
grid on, title('Phase plot: Displacement vs. velocity')
legend('No damping: \zeta=0',' Underdamped: 0<\zeta<1',...
    'Overdamped: \zeta>1','Critically damped: \zeta=1')
xlim([-.1 .1]), ylim([-.025 .025]), axis square
hold off; shg

function Out=SMDsysSim(M, D, S, ICs, t)


% HELP. Simulation model of 1-DOF SMD system.
    omegaN = sqrt(S/M);
    ksi = 0.5*(D/M)*(1/omegaN);
    u0=ICs(1);
    du0=ICs(2);
if ksi==0               % Scenario I. Undamped
    Out=u0*cos(omegaN*t)+(du0/omegaN)*sin(omegaN*t);

303
Chapter 9 Spring-Mass-Damper Systems

elseif ksi>0 && ksi<1   % Scenario II. Underdamped


omegaD=omegaN*sqrt(1-ksi^2);
Out=exp(-ksi*omegaN*t).*(u0*cos(omegaD*t)+(u0*ksi*omegaN+du0)...
*sin(omegaD*t)/omegaD);
elseif ksi>1            % Scenario III. Overdamped
r1=(-ksi-sqrt(ksi^2-1))*omegaN;
r2=(-ksi+sqrt(ksi^2-1))*omegaN;
A=(-du0+(-ksi+(sqrt(ksi^2-1)))*u0*omegaN)/(2*omegaN*sqrt(ksi^2-1));
B=(du0+(ksi+(sqrt(ksi^2-1)))*u0*omegaN)/(2*omegaN*sqrt(ksi^2-1));
Out=(A*exp(r1*t)+B*exp(r2*t));
else  %ksi==1          % Scenario IV. Critically damped
  r1=-omegaN;
  A=u0;
  B=du0+omegaN*u0;
  Out=(A+B*t).*exp(r1*t);
end
end

The simulation results of this simulation model demonstrate the influence of the
damping ratio values, ζ (Figure 9-2 and Figure 9-3) on the system behaviours. For
instance, having ζ under a critical damping (under-damped case) value leads to decay
(damping) of the system response, but the decay rate will be exponential depending on
the value of ζ. If there is no damping present, then the system response oscillates at its
natural frequency value of ωn. Conversely, in over-damped and critically damped cases,
the system response does not oscillate.

304
Chapter 9 Spring-Mass-Damper Systems

1-DOF Spring-Mass-Damper System simulation - 4 Scenarios


0.1
No damping: ζ=0
0.08 Underdamped: 0<ζ<1
Overdamped: ζ>1
0.06
Critically damped: ζ=1
0.04
System response, [m]

0.02

-0.02

-0.04

-0.06

-0.08

-0.1
0 1 2 3 4 5
time, [s]

Figure 9-2.  Single-DOF spring-mass-damper system simulation for four different


scenarios

305
Chapter 9 Spring-Mass-Damper Systems

Phase plot: Displacement vs. velocity


0.025
No damping: ζ=0
0.02 Underdamped: 0<ζ<1
Overdamped: ζ>1
0.015
Critically damped: ζ=1
0.01

0.005
du(t), [m/s]

-0.005

-0.01

-0.015

-0.02

-0.025
-0.1 -0.05 0 0.05 0.1
u(t), [m]

Figure 9-3.  Phase plot of four scenarios of single-DOF spring-mass-damper system

Moreover, we can study the influence of initial conditions on the system response
u(t) to see how much time is required for the system to come to a complete stop. Now, by
modifying the previous script, SMDsysSIM_compare.m, we can write another simulation
model, SMDsysSIM_compare_ICs.m, that simulates three case scenarios: under-damped,
critically damped, and over-damped with three different initial conditions.

%%  Study influence of Initial Conditions


clearvars; close all
% Input Data:
M=1; D=5; S=25; t=0:.05:2.5;
% Initial Conditions for three different cases:
ICs1=[0.1, 0];
ICs2=[0.1, 1];
ICs3=[0.1, -1];
% Displacement:

306
Chapter 9 Spring-Mass-Damper Systems

ut1=SMDsysSim(M, D, S, ICs1, t);


ut2=SMDsysSim(M, D, S, ICs2, t);
ut3=SMDsysSim(M, D, S, ICs3, t);
figure, subplot(311)
plot(t, ut1, 'b-', 'linewidth', 1.5), hold on
plot(t, ut2, 'r--', 'linewidth', 2),
plot(t, ut3, 'k:', 'linewidth', 2), grid on
legend('u_0=0.1, du_0=0','u_0=0.1, du_0=1','u_0= 0.1, du_0= -1')
ylabel(' u(t), [m]')
gtext({' \zeta < 1'}, 'fontsize', 13), hold off ,axis tight
% Input Data for Scenarios III. Critically damped
M2=1; D2=10; S2=25; t=0:.05:2.5;
ICs1=[0.1, 0]; ICs2=[0.1, 1]; ICs3=[0.1,-1];
% Displacement:
ut1=SMDsysSim(M2, D2, S2, ICs1, t);
ut2=SMDsysSim(M2, D2, S2, ICs2, t);
ut3=SMDsysSim(M2, D2, S2, ICs3, t);
subplot(312)
plot(t, ut1, 'b-', 'linewidth', 1.5), hold on
plot(t, ut2, 'r--', 'linewidth', 2),
plot(t, ut3, 'k:', 'linewidth', 2), grid on
legend('u_0=0.1, du_0=0','u_0=0.1, du_0=1','u_0=0.1, du_0= -1')
ylabel(' u(t), [m]')
gtext({' \zeta = 1'}, 'fontsize', 13), axis tight; hold off
% Input Data for Scenario IV. Over-damped case
M3=1; D3=13; S3=25; t=0:.05:2.5;
ICs1=[0.1, 0]; ICs2=[0, 0.5]; ICs3=[-0.1, 0];
% Displacement:
ut1=SMDsysSim(M3, D3, S3, ICs1, t);
ut2=SMDsysSim(M3, D3, S3, ICs2, t);
ut3=SMDsysSim(M3, D3, S3, ICs3, t);
subplot(313), plot(t, ut1, 'b-', 'linewidth', 1.5), hold on
plot(t, ut2, 'r--', 'linewidth', 2),
plot(t, ut3, 'k:', 'linewidth', 2), grid on
legend('u_0=0.1, du_0=0','u_0=0, du_0=0.5','u_0= -0.1, du_0=0')

307
Chapter 9 Spring-Mass-Damper Systems

xlabel('t, [s]'); ylabel(' u(t), [m]')


gtext({'\zeta >1'}, 'fontsize', 13), hold off, axis tight
function Out=SMDsysSim(M, D, S, ICs, t)
% HELP. Simulation model of 1-DOF SMD system.
% Out=SMDsysSim(M, D, S, ICs, t)
    omegaN = sqrt(S/M);
    ksi = 0.5*(D/M)*(1/omegaN);
    u0=ICs(1);
    du0=ICs(2);
if ksi==0               % Scenario I. Undamped
    Out=u0*cos(omegaN*t)+(du0/omegaN)*sin(omegaN*t);
elseif ksi>0 && ksi<1   % Scenario II. Underdamped
omegaD=omegaN*sqrt(1-ksi^2);
Out=exp(-ksi*omegaN*t).*(u0*cos(omegaD*t)+(u0*ksi*omegaN+du0)...
*sin(omegaD*t)/omegaD);
elseif ksi>1            % Scenario III. Overdamped
r1=(-ksi-sqrt(ksi^2-1))*omegaN;
r2=(-ksi+sqrt(ksi^2-1))*omegaN;
A=(-du0+(-ksi+(sqrt(ksi^2-1)))*u0*omegaN)/(2*omegaN*sqrt(ksi^2-1));
B=(du0+(ksi+(sqrt(ksi^2-1)))*u0*omegaN)/(2*omegaN*sqrt(ksi^2-1));
Out=(A*exp(r1*t)+B*exp(r2*t));
else  %ksi==1          % Scenario IV. Critically damped
  r1=-omegaN;
  A=u0;
  B=du0+omegaN*u0;
  Out=(A+B*t).*exp(r1*t);
end
end

As demonstrated in Figure 9-4, the simulation results for three different values of ζ


show that if there is considerable damping present in the system, free motion of a system
decays over time. Nevertheless, the whole decay (die) time of free motion depends on
the initial conditions, i.e., initial excitation values (displacement and velocity of the
system). The previously discussed simulation model approaches for free vibration
(motion) of a single DOF system can be also applied with some changes to free vibration
of multidegree of freedom (linear) system simulations.

308
Chapter 9 Spring-Mass-Damper Systems

Figure 9-4.  Study the influence of initial conditions of the system on its responses

Case 2: Forced Vibration (Motion)


Let’s consider the case of the single-DOF SMD system excited with an external force that
is a rectangular type of periodic wave force, as shown in Figure 9-5.

309
Chapter 9 Spring-Mass-Damper Systems

Figure 9-5.  Spring-mass-damper system excited with a periodic wave force

The equation of motion of the system is as follows:

md 2 y Cdy
+ + Ky = F ( t ) (9-27)
dt 2 dt

where external force F(t) is a periodic wave function that can be expressed via the
Fourier series approximation as follows:
¥
400 400 80
F ( t ) = å (1 - cos np ) sin ( np t ) = sin (p t ) - sin ( 3p t ) + sin ( 5p t ) - (9-28)
n =1 p 3p p

Now, the final formulation of the system model in Equation (9-27) will be as follows:

md 2 y Cdy 400 400 80


+ + Ky = sin (p t ) - sin ( 3p t ) + sin ( 5p t ) -  (9-29)
dt 2
dt p 3p p

First simulation model. Using Equation (9-29), we create a simulation model with
MATLAB scripts. The periodic wave function formulation in Equation (9-28) can be
expressed as a function called F=func_pulse(t, n).

310
Chapter 9 Spring-Mass-Damper Systems

function F=func_pulse(t, n)
%HELP. t is time vector. n is number of terms in pulse approximation.
F(1,:)=(200/pi)*(1-cos(pi))*sin(pi*t);
for ii=2:n
    F(:,:)=F(:,:)+(200/(ii*pi))*(1-cos(ii*pi))*sin(ii*pi*t);
end

We express the second-order ODE, which is the left side of Equation (9-29), via the
anonymous function handle DDx and embed the force function F=func_pulse(t, n)
within an m-file called Sim_func_pulse.m with the ode45 solver. This simulates the
system behavior and plots the simulation results. Note that in this simulation model,
zero initial conditions are taken. The simulation results of the model aer shown in
Figure 9-6 and Figure 9-7.

% F = func_pulse(t, n) produces rectangular periodic pulses.


% DDx = @(t, x) anonymous function handle.
clearvars; close all
M = 10; C = 0.5; K = 1000; % System parameters
t=0:pi/1000:13;          % Time
n=113;                   % Terms for Fourier Series
ICs=[0,0];               % Initial Conditions
F=func_pulse(t, n);      % Fourier Series values
% System model equation is expressed by two 1st order ODEs
DDx=@(t,x)([x(2); (1/10)*(func_pulse(t,n)-C*x(2)-K*x(1))]);
opts_ODE=odeset('RelTol', 1e-6, 'AbsTol', 1e-8);
[time, Xt]=ode45(DDx, t, ICs, opts_ODE);
subplot(211)
yyaxis left
plot(t, F, 'k-');
ylabel('Input F(t), [N]')
yyaxis right
plot(t, Xt(:,1), 'r--')
ylabel('Output x(t), [m]')
legend('F(t) Input', 'x(t) Output'), grid on
title(['\it SMD system excited ',...
'by periodic pulse force'])
axis tight
311
Chapter 9 Spring-Mass-Damper Systems

subplot(212)
yyaxis left
plot(t,Xt(:,1),'k-')
ylabel('Displacement x(t), [m]')
yyaxis right
plot(t, Xt(:,2),'b-.','linewidth', 1.5)
legend('x(t)','dx(t)')
ylabel('Velocity dx(t), [m/s]')
xlabel('time [sec]'), grid on, axis tight
figure
plot(Xt(:,1), Xt(:,2)),
xlabel('x(t)'), ylabel('dx(t)')
title('Phase plot; x vs. dx'), grid on
axis square
function F=func_pulse(t,n)
%HELP. t is time vector. n is number of terms in pulse approximation.
F(1,:)=(200/pi)*(1-cos(pi))*sin(pi*t);
for ii=2:n
    F(:,:)=F(:,:)+(200/(ii*pi))*(1-cos(ii*pi))*sin(ii*pi*t);
end
end

312
Chapter 9 Spring-Mass-Damper Systems

Figure 9-6.  Simulation of spring-mass-damper system excited with a periodic


pulse force

313
Chapter 9 Spring-Mass-Damper Systems

Figure 9-7.  Phase plot: displacement versus velocity of the SMD system excited
with a periodic rectangular wave force

Now let’s employ the Simulink modeling approach to simulate the system behavior.
The second simulation model is built in Simulink. In Simulink, there are a few
blocks with which periodic pulse signals can be generated (see [4] for more details
about how to build Simulink models). They are signal generator, pulse generator, series
of step function, signal builder, and repeating sequence. Pulses__Input.mdl (shown
in Figure 9-8) is the final model of the spring-mass-damper system subject to external
force, namely, repeated pulses.

314
Chapter 9 Spring-Mass-Damper Systems

Figure 9-8.  Simulink model (Pulses__Input.mdl) of the spring-mass-system


subject to a pulse external force

The simulation results (input signal versus system response, displacement versus
velocity in the Plots–Scope block, displacement versus velocity in the Phase Plot block)
of the Simulink model (Pulses__Input.mdl) shown in Figure 9-8 are well converged
with the results in Figures 9-6 and 9-7 from the m-file Sim_func_pulse.m. The simulation
results obtained from the Scope block called [Plots] and the XY Scope block called
[Phase Plot] are not shown here. The x-y axis limits of the XY Scope block, shown in
[Phase Plot], are set to [-0.8 0.8 -8 8]. Note that the parameters of the [Signal Generator]
block are as follows:

Output various wave forms: Y(t) = Amp*Waveform(Freq, t)


Wave form: square

Time (t): Use simulation time

Amplitude: -100

Frequency: 0.5

Units: Hertz
The values of the other gain parameters M, C, and K, of the model (Pulses__Input.
mdl), are 10, 0.5, and 1000, respectively.
Let’s consider another case with a sinusoidal periodic forced motion of a single-DOF
SMD system with F(t) = F0 cos (ωt).

315
Chapter 9 Spring-Mass-Damper Systems

md 2 y Cdy
Equation (9-27), which is + + Ky = F ( t ) , has a general solution, shown
dt 2 dt
here:

x ( t ) = Ae -zwnt sin (wd t + j ) + X cos (wt - q ) (9-30)


where ω is the applied force’s frequency and φ is the phase shift. The constants A and X
are computed from the initial conditions [1, 2, 3].

x 0 - X cosq
A= (9-31)
sinj

f0
X= (9-32)

(w 2
n -w ) + ( 2zw w )
2 2
n
2

F0
where f 0 = is normalized force magnitude. The phase θ is computed from the
m
following formulation:

2zwnw
q = tan -1 (9-33)
wn2 - w 2

The previous formulations of magnitude X and phase θ are of great importance


in general practice. The transient response xt ( t ) = Ae -zwnt sin (wd t + j ) part of the
general solution is relatively small in amplitude, and its influence on the response is
considerably smaller than the steady-state response magnitude. Therefore, in practice,
we deal with the steady-state response part of the solution, which is x(t) = X cos (ωt − θ).
F
From the formulations of X and θ, by factoring out ω2, dividing the magnitude by 0
w m
or f0, and substituting r = , the following expressions of the normalized magnitude of
wn
the system response and phase are obtained:

XK X wn2 1
= = (9-34)

F0 f0
(1 - r ) + ( 2z r )
2 2 2

2z r
q = tan -1 (9-35)
1- r2

316
Chapter 9 Spring-Mass-Damper Systems

These formulations are simulated with the following script (zeta_1DOF_SMD.m):

function zeta_1DOF_SMD(M, zeta, S, omega)


% HELP. Study damping ratio (zeta) effects on Amplitude change
% M - Mass of the system
% zeta - Damping ratio
% S - Stiffness of the system
% omega - frequency
if nargin<1
M=2.5; S=25;
omega=0:.2:10;
zeta=0:0.2:1;
end
omegaN=sqrt(S/M);
r=omega./omegaN;
Mag=zeros(length(zeta), length(r));
Theta=ones(length(zeta), length(r));
for ii=1:length(zeta)
    for k=1:length(r)
        Mag(ii,k)=1/sqrt((1-r(k)^2)^2+(2*zeta(ii)*r(k))^2);
        Theta(ii,k)=atan2(2*zeta(ii)*r(k), (1-r(k)^2));
    end
end
Labelit = {};
Colorit = 'bgrmkgbckmbgrygr';
Lineit  = '--:-:--:-:--:----:----:--';
Markit  = 'oxs+*^v<p>.xsh+od+*^v';
for m=1:length(zeta)
    Stylo    = [Colorit(m) Lineit(m) Markit(m)];
    Labelit{m} = ['\zeta= ' num2str(zeta(m))];
    semilogy(r, Mag(m,:), Stylo, 'linewidth', 1.5), hold on
end

317
Chapter 9 Spring-Mass-Damper Systems

legend(Labelit{:}); axis tight; grid on; ylim([0, 5])


title('\zeta influence on Response Amplitude change')
xlabel('r = \omega/\omega_n'), ylabel('\it Normalized Amplitude'),
hold off
figure
for m=1:length(zeta)
    Stylo    = [Colorit(m) Lineit(m) Markit(m)];
    Labelit{m} = ['\zeta= ' num2str(zeta(m))];
    plot(r, Theta(m,:), Stylo, 'linewidth', 1.5)
    hold on
end
legend(Labelit{:}, 'location', 'northwest')
axis tight, grid on;
axis([0, 2 -.2 3.35])
title('\zeta  effects on Phase changes')
xlabel('r = \omega/\omega_n ')
ylabel('Phase, \theta(r)')

Again, in our simulation studies of damping ratio (ζ) with the normalized system
amplitude (Figure 9-9) and the phase shift (Figure 9-10), we can conclude that the
resonance peak occurs when the system’s natural frequency equals the periodic
excitation force’s excitation frequency as expected in theoretical evaluations, and the
system behavior will become uncontrollable. To avoid such circumstances, we need to
apply damping. Note that in the script, the function atan2 is used to evaluate the phase
angle θ(r) values since it computes the values of θ(r) in the range of [0, π], whereas the
é p pù
tan function computes in the range of ê - , ú , which is not appropriate in this case.
ë 2 2û

318
Chapter 9 Spring-Mass-Damper Systems

Figure 9-9.  Influence of the damping ratio (ζ) on the normalized system response
amplitude

319
Chapter 9 Spring-Mass-Damper Systems

Figure 9-10.  Influence of the damping ratio (ζ) on the system phase θ change

Two Degrees of Freedom System


The motions of many mechanical systems are studied by modeling them as SMD
systems. Let’s consider the two-DOF SMD system subject to external force shown in
Figure 9-11. Note that the friction under mass 1 and 2 is taken to be linear.

320
Chapter 9 Spring-Mass-Damper Systems

1
2
1
1
2
1
( )
2

3 2 1

Figure 9-11.  Two mass spring-mass-damper system subject to external impulse


force F(t)

Before we start to derive the system equations, Figure 9-12 shows an alternative


equivalent physical model of the given system by substituting the friction damping
under body mass 1 and 2 with dampers applied to each mass.

1
2

2 1 ( )
1
2 1

a)
3 2 1

2 2 − 1 2 + 1 1 − 1 2 + 1 1 ( )
2 1 b)

Figure 9-12.  a) Alternative physical model of the system; b) free-body diagrams


of mass 1, 2

Using the free-body diagram of the system and applying D’Alembert’s principle for
acting forces on each mass, we can write the equations of motion of the system.
For mass 1:

F ( t ) = m1 x1 + ( c1 + c 2 ) x1 - c 2 x 2 + k1 x1 - k1 x 2 (9-36)


321
Chapter 9 Spring-Mass-Damper Systems

For mass 2:

0 = m2 x2 + ( c 2 + c 3 ) x 2 + ( k1 + k2 ) x 2 - c 2 x1 - k1 x1 (9-37)


Note that m1, m2, c1, c2, c3, k1, k2 are the system parameters of mass, damping, and
stiffness, respectively. x1 and x2 are displacements of mass 1 and 2, respectively, and
x1 , x 2 , x1 , x2 are the velocities and accelerations of mass 1 and mass 2, respectively.
By introducing new state variables, we rewrite Equations (9-36) and (9-37) as a
system of first-order ODEs. To avoid confusion, the variables are renamed as x1 = y1  and
x2 = y2.

ì x1 = y 2
ï 1
ï y 2 = é F ( t ) - ( c1 + c 2 ) y 2 + c 2 y 4 - k1 y1 + k1 y 3 ùû
ï m1 ë
í (9-38)
ï x2 = y4
ï 1
ï y 4 = éc 2 y 2 - ( c 2 + c 3 ) y 4 + k1 y1 - ( k1 + k2 ) y 3 ùû
î m2 ë

Based on the system model defined in Equation (9-38), we write the MATLAB
models, named SMsysSIM.m and two_DOF_sys_sim_ALL.m, and build a Simulink model
named Two_DOF_SMsys.mdl for the case when the external force, F(t) = F0 sin (10t), is
applied.

function SMsysSIM(t, ICs)


% SMsysSIM.m
% t is time; ICs is initial conditions.
if nargin<1
% If no input arguments and Initial conditions are given, then
t=[0,5]; ICs=[1; 1.5; -1; 1];
OPTs=odeset('OutputFcn', @odeplot,'reltol', 1e-4,'abstol',1e-6);
ode45(@SMsys1,t, ICs, OPTs)
else
Opts=odeset('OutputFcn', @odeplot,'reltol', 1e-4,'abstol',1e-6);
ode45(@SMsys1,t, ICs, Opts)
end

322
Chapter 9 Spring-Mass-Damper Systems

function DX=SMsys1(t, y)
k1=90; k2=85; c1=2; c2=1; c3=3; m1=5; m2=3; F0=3.3;
Dx(1)= y(2);
Dx(2)=(1/m1)*(F0*sin(10*t)-(c1+c2)*y(2)+c2*y(4)-k1*y(1)+k1*y(3));
Dx(3)= y(4);
Dx(4)= (1/m2)*(c2*y(2)-(c2+c3)*y(4)+k1*y(1)-(k1+k2)*y(3));
DX=[Dx(1); Dx(2); Dx(3); Dx(4)];
end
end

This function file (SMsysSIM.m) computes the displacement and velocity values of
mass 1 and 2 and plots them in a single plot without figure attributes, such as plot title,
legends, etc.
The next m-file (two_DOF_sys_sim_ALL.m) computes the displacement and velocity
values of mass 1 and 2 with the ODE solvers (ode23, ode23s, ode23tb, and ode113)
and the Simulink model (Two_DOF_SMsys.mdl) and plots them separately with all the plot
attributes, as shown in Figure 9-14, Figure 9-15, and Figure 9-16.

% two_DOF_sys_sim_ALL.m
clearvars; close all
ICs=[1; 1.5; -1; 1];
k1=90; k2=85; c1=2; c2=1; c3=3; m1=5; m2=3; F0=3.3;
F=@(t, y)[y(2);(1/m1)*(F0*sin(10*t)-(c1+c2)*y(2)+c2*y(4)- ...
    k1*y(1)+k1*y(3)); y(4); ...
(1/m2)*(c2*y(2)-(c2+c3)*y(4)+k1*y(1)-(k1+k2)*y(3))];
t=0:.005:5;
Opts=odeset('OutputFcn',@odeplot,'reltol', 1e-4, 'abstol', 1e-6);
ode45(F, t, ICs, Opts)
xlabel('\it time'), ylabel('x_1, dx_1, x_2,  dx_2'), grid on
legend('x_1(t)', 'dx_1(t)', 'x_2(t)', 'dx_2(t)')
title('Simulation of 2-DOF system')
%% Testing different solvers with different ODE settings
% ODE45 with fixed time step of 0.005
ts=0:.005:5; % fixed time step of 0.005
[t1, y1]=ode45(F, ts, ICs, []);
%% ODE23tb with variable time step

323
Chapter 9 Spring-Mass-Damper Systems

t=[0, 5];
[t2, y2]=ode23tb(F, t, ICs, []);
%% ODE23 calls an embedded function SMsys. A fixed time step of 0.005
[t3, y3]=ode23(@SMsys, ts, ICs);
%% ODE113 with the varying step size and function handle
[t4, y4]=ode113(@(t, y)[y(2); (1/m1)*(F0*sin(10*t)- ...
    (c1+c2)*y(2)+c2*y(4)-k1*y(1)+k1*y(3)); y(4);
(1/m2)*(c2*y(2)-(c2+c3)*y(4)+k1*y(1)-(k1+k2)*y(3))],t, ICs);
%% SIMULINK model: Two_DOF_SMsys.slx with ODE23S & rel. error tol. 1e-6
OPTs=simset('reltol', 1e-6, 'solver', 'ode23s');
XOUT=sim('Two_DOF_SMsys', t, OPTs); % Simulates model: Two_DOF_SMsys.slx
figure('name', 'Displacement: x1')
plot(t1,y1(:,1), 'b-o'), hold on
plot(t2,y2(:,1), 'r--s')
plot(t3,y3(:,1), 'm-.x'),
plot(t4,y4(:,1), 'g:+')
plot(XOUT.tout, XOUT.yout{1}.Values.Data, 'k-'), grid on
legend('ode45','ode23tb','ode23',...
    'ode113','Simulink(ode23s ~var)')
title('Displacement of body mass: m_1')
xlabel('time, [sec]'), ylabel('x_1(t)')
figure('name', 'Displacement: x2')
plot(t1,y1(:,3), 'b-o'), hold on
plot(t2,y2(:,3), 'r--s')
plot(t3,y3(:,3), 'm-.x'),
plot(t4,y4(:,3), 'g:+')
plot(XOUT.tout, XOUT.yout{2}.Values.Data, 'k-'), grid on
legend('ode45','ode23tb','ode23',...
    'ode113','Simulink(ode23s ~var)')
title('Displacement of body mass: m_2')
xlabel('time, [sec]'), ylabel('x_2(t)')
% Function called by ODE23TB
function DX=SMsys(t,y)
k1=90; k2=85; c1=2; c2=1; c3=3; m1=5; m2=3; F0=3.3;

324
Chapter 9 Spring-Mass-Damper Systems

Dx(1)= y(2);
Dx(2)=(1/m1)*(F0*sin(10*t)-(c1+c2)*y(2)+c2*y(4)-k1*y(1)+k1*y(3));
Dx(3)= y(4);
Dx(4)= (1/m2)*(c2*y(2)-(c2+c3)*y(4)+k1*y(1)-(k1+k2)*y(3));
DX=[Dx(1); Dx(2); Dx(3); Dx(4)];
end

Note that the Simulink model (Two_DOF_SMsys.mdl) takes all the parameter (m1, m2,
k1, k2, c1, c2, c3, F0) values and initial condition values (defined in the integrator
blocks with these variable names: ICs(1), ICs(2), ICs(3), ICs(4)) from the
simulation m-file called two_DOF_sys_sim_ALL.m. Note that the input plot (the sine
wave in the Simulink model Two_DOF_SMsys.mdl) has Amplitude set to F0 and Frequency
(rad/sec) set to 10.

Figure 9-13.  Simulink model, Two_DOF_SMsys.slx


325
Chapter 9 Spring-Mass-Damper Systems

We run the model two_DOF_sys_sim_ALL.m that automatically calls/simulates the


Simulink model (Two_DOF_SMsys.mdl) and function file. Subsequently, we obtain the next
plot figures (Figure 9-14, Figure 9-15, and Figure 9-16) displaying the simulation results.

Figure 9-14.  Displacement and velocity of mass 1 and mass 2 bodies

326
Chapter 9 Spring-Mass-Damper Systems

Figure 9-15.  Displacement of body mass 1 computed with different ODE solvers of
MATLAB/Simulink

327
Chapter 9 Spring-Mass-Damper Systems

Figure 9-16.  Displacement of body mass 2 computed with different ODE solvers of
MATLAB/Simulink

The simulation results in Figure 9-14 and 9-15 show that all of the employed ODE
solvers (ode23, ode23tb, ode23s, ode45, ode113) have resulted in well-converged
solutions.

Three Degrees of Freedom System


Let’s consider the three-DOF spring-mass-damper system shown in Figure 9-17 that
have three masses interconnected with springs and dampers. It is similar to the previous
two DOF systems. We will derive system equations of motion and build simulation
models.

328
Chapter 9 Spring-Mass-Damper Systems

The equations of motion of the system with respect to its free-body diagrams
(Figure 9-17) can be expressed with the system of second-order differential equations
shown in Equation (9-39):

ì m1 x1 + k1 x1 + k2 ( x1 - x 2 ) + c1 x1 + c 2 ( x1 - x 2 ) = F1 ( t )


ï
ím2 x2 + k2 ( x 2 - x1 ) + k3 ( x 2 - x 3 ) + c 2 ( x 2 - x1 ) + c 3 ( x 2 - x 3 ) = F2 ( t )
ï m3 x3 + k3 ( x 3 - x 2 ) + 2k4 x 3 + c 3 ( x 3 - x 2 ) = F3 ( t ) (9-39)
î

Equation (9-39) can be rewritten as follows:

ì m1 x1 ( t ) + ( k1 + k2 ) x1 ( t ) - k2 x 2 ( t ) + ( c1 + c 2 ) x1 ( t ) - c 2 x 2 ( t ) = F1 ( t )
ï
ïm2 x2 ( t ) - k2 x1 ( t ) + ( k2 + k3 ) x 2 ( t ) - k3 x 3 ( t )
í
ï + ( c 2 + c 3 ) x 2 ( t ) - c 2 x1 ( t ) - c 3 x 3 ( t ) = F2 ( t )
ï m3 x3 ( t ) - k3 x 2 ( t ) + ( k3 + 2k4 ) x 3 ( t ) - c 3 x 2 ( t ) + c 3 x 3 ( t ) = F3 ( t (9-40)
)
î

Note that m1, m2, m3, c1, c2, c3, k1, k2, and k3 are the system parameters of mass, damping
and stiffness, respectively. x1, x2, and x3 are the displacements of mass 1, 2, 3, respectively.
x1 , x 2 , and x 3 are the velocities, and x1 , x2 , and x3 are the accelerations of mass 1, 2, 3,
respectively. F1(t), F2(t), and F3(t) are applied external forces on mass 1, 2, 3, respectively.

1( ) 2( ) 3( )
1 2 3

1 2 3 4
1 2 3

a)
1 2 3 4

b)
1 1 (− 2 1 + 2 2) (− 3 2 + 3 3) 4 3

1 2 3
1 2 3

Figure 9-17.  Three degrees of freedom system: a) a physical model of the system
with three masses rolling on a flat surface without any friction; b) free body
diagram of the system
329
Chapter 9 Spring-Mass-Damper Systems

Note that the system equations in Equation (9-39) and Equation (9-40) are second-­
order ODEs, which are linear and time invariant. They are coupled by the coordinate
systems of x1(t), x2(t), and x3(t). Therefore, these equations must be solved
simultaneously. For numerical simulations, the following values for the system
parameters are taken: m1 = 2.5 [kg]; m2 = 2.0 [kg]; m3 = 3.0 [kg];
éN ù éN ù éN ù é Ns ù é Ns ù é Ns ù
k1 = 25 ê ú ; k2 = 5 ê ú ; k3 = k4 = 30 ê ú ; c1 = 2.5 ê ú ; c 2 = 0.5 ê ú ; c 3 = 3.5 ê ú .
ëm û ëm û ëm û ëm û ëm û ëm û
We simulate this system with forced and free motion.
–– Forced motion (vibration) case with zero initial conditions:
e.g.: F1(t) = 20 sin (120t); F2(t) = 0; F3(t) = 20Φ(t − t0);
Note that F3(t) is a Heaviside step function Φ(t − t0) applied at t0 = 0.
–– Free motion (vibration) case. No external forces are
applied: F1(t) = F2(t) = F3(t) = 0;. There is an initial
(excitation) displacement applied on mass 1 only:
x1 ( 0 ) = 0.5, x 2 ( 0 ) = 0 , x 3 ( 0 ) = 0 ; x1 ( 0 ) = 0 , x 2 ( 0 ) = 0 , x 3 ( 0 ) = 0 ; .
Note that before writing a simulation model, we rewrite the system equations
in Equation (9-39) via first-order ODEs. The system has three second-order
(acceleration) variables, x1 , x2 , and x3 , which will be substituted with new variables,
i.e., x1 = y1 , x1 = y 2 , x1 = y 2 ; x 2 = y 3 , x 2 = y 4 , x2 = y 4 ; x 3 = y 5 , x 3 = y6 ,an
nd x3 = y 6 . Using these
new variables, we can write the next system of first-order coupled ODE equations.

ì x1 = y 2
ï
ï y = æ 1 ö ( F ( t ) - ( k + k ) y + k y - ( c + c ) y + c y )
ï 2 çè m1 ÷ø 1 1 2 1 2 3 1 2 2 2 4

ï
ï x 2 = y 4
í (9-41)
ï y 4 = (1 / m2 ) ( F2 ( t ) + k2 y1 - ( k2 + k3 ) x 3 + k3 y 5 - ( c 2 + c 3 ) y 4 )
ï x = y
ï 3 6

ï æ 1 ö
ï y 6 = ç ÷ ( F3 ( t ) + k3 y 3 - ( k3 + 2k4 ) y 5 + c 3 y 4 - c 3 y6 )
î è m3 ø

Based on the formulations in Equation (9-41), we write a function file called three_
MASS.m with the ode45 solver. Note that the function file contains a nested function called
third_DOF(t, y) that defines the system equations given in Equation (9-41).
The system parameter values and external forces are also defined within this nested
function. The Heaviside step function is expressed via MATLAB’s built-in function step().

330
Chapter 9 Spring-Mass-Damper Systems

% three_MASS.m
% HELP. Simulation of highly coupled three degree of freedom system.
clearvars; clc
t=0:.01:120;  % Simulation time span
IC=[0;0;0;0;0;0];           % Case # 1
% IC=[0.5; 0; 0; 0; 0; 0];  % Case # 2

F1=20*sin(120*t);F2=0; t0=0; F3=20*stepfun(t,t0); % Case # 1


% F1=0; F2=F1; F3=F1;                             % Case # 2
k1=25; k2=5; k3=30; k4=k3; c1=2.5; c2=.5; c3=3.5;
m1=2.5; m2=2; m3=3;
[t, xyz]=ode45(@third_DOF, t, IC, []);
% SIMULINK model: ThreeDOFsys.slx with ODE113 & relative error tol. 1e-6
OPTs=simset('reltol', 1e-6, 'solver', 'ode113');
[tt, YY, X123]=sim('ThreeDOFsys', [0, 20], OPTs);% Run: ThreeDOFsys.slx

figure('name', 'Matlab vs. Simulink')


plot(t(1:2000),xyz(1:2000,1),'bo',t(1:2000),xyz(1:2000,3), ...
    'rx', t(1:2000), xyz(1:2000,5), 'ks', ...
    tt(1:5000),X123(1:5000,1),'r-',tt(1:5000),X123(1:5000,2), ...
    'b--', tt(1:5000), X123(1:5000,3), 'g-.','linewidth',1.5)
legend('Mass 1: x_1(t) (Matlab)','Mass 2: x_2(t) (Matlab)', ...
'Mass 3: x_3(t) (Matlab)', ...
'Mass 1: x_1(t) (Simulink)', 'Mass 2: x_2(t) (Simulink)', ...
'Mass 3: x_3(t) (Simulink)')
title('\it Three DOF SMD (coupled) system')
xlabel('\it time, [sec]')
ylabel('\it Displacement, x_1(t), x_2(t), x_3(t)'), grid on
figure('name', 'Animation')

for k=1:t(end)-20
% Note: Displacement magnitudes of x1, x2, x3 increased
% by the factor of 10 for better visualization
plot(-20,0,'*', 20,0, '*', -10+10*xyz(k+20,1), 0, 'r-o',...
-5+10*xyz(k+20,3),0,'g-o',...
10+10*xyz(k+20,5),0,'b-o','markersize', 35, ...
'markerfacecolor', 'c');
331
Chapter 9 Spring-Mass-Damper Systems

grid on; Motion(k)=getframe;


end
movie(Motion)
function  dx = third_DOF(t, y)
% HELP: three degree of freedom system
k1=25; k2=5; k3=30; k4=k3; c1=2.5; c2=.5; c3=3.5;
m1=2.5; m2=2; m3=3;
F1=20*sin(120*t);F2=0; t0=0; F3=20*stepfun(t,t0);     % Case # 1
% F1=0; F2=0; F3=0;                                   % Case # 2
dx=zeros(6,1);
dx(1)=y(2);
dx(2)=(1/m1)*(F1-(k1+k2)*y(1)+k2*y(3)-(c1+c2)*y(2)+c2*y(4));
dx(3)=y(4);
dx(4)=(1/m2)*(F2+k2*y(1)-(k2+k3)*y(3)+k3*y(5)-...
    (c2+c3)*y(4)+c2*y(2)+c3*y(6));
dx(5)=y(6);
dx(6)=(1/m3)*(F3+k3*y(3)-(k3+2*k4)*y(5)+c3*y(4)-c3*y(6));
end
end

This simulation model includes forced (Case #1) and free (Case #2) motion inputs,
such as input forces and nonzero initial conditions (for mass 1) for forced and free
motion cases, respectively.
Moreover, it incorporates the commands to call and execute the Simulink model of
the system, as shown in Figure 9-18. Note that the Simulink model, ThreeDOFsys.slx,
takes the numerical values of all the parameters, and the initial conditions are set inside
the integrator blocks from the simulation function file, three_MASS.m. The external
force magnitudes of the Simulink model are initiated by selecting Model Properties ➤
Callbacks ➤ InitFcn.

F1 = 30; F2=0; F3=30; % for Case #1

F1 = 0; F2=0; F3=0; % for Case #2

Note that in the Simulink model ThreeDOFsys.slx, the [Sine Wave] block is
used for an input force signal F1(t) applied on mass 1 with the following parameters:
­Amplitude =1, Frequency=120, Phase=0, Bias =0, Sample time=0. It has the following
output formulation: O(t) = Amplitude *  sin (Frequency * t + Phase) + Bias. The input

332
Chapter 9 Spring-Mass-Damper Systems

force signal is F1(t) = O(t) * F1, where F1 is a constant gain value. The force applied on
mass 3 has a constant value equal to F3. The force applied on mass 2 is 0. Thus, F2 = 0,
and it is ignored in the model.

Figure 9-18.  A Simulink model (ThreeDOFsys.slx) of the three-DOF system

333
Chapter 9 Spring-Mass-Damper Systems

Forced motion case. In this case, we take all zero initial conditions and two nonzero
applied external forces:

IC=[0;0;0;0;0;0];                                 % Case # 1
F1=20*sin(120*t);F2=0; t0=0; F3=20*stepfun(t,t0); % Case # 1

By simulating the model (three_MASS.m) that recalls and executes the Simulink
model (threeDOFsys.slx), we obtain the simulation results shown in Figure 9-19 and
an animation plot (not shown here) demonstrating the motion of the three masses with
respect to each other.

Figure 9-19.  Simulation of the three degree of freedom coupled system with forced
vibration

The simulation results in Figure 9-19 show that the MATLAB model results match
with the ones from the Simulink model.

334
Chapter 9 Spring-Mass-Damper Systems

Free motion case. In this case, we take all zero initial conditions and two nonzero
applied external forces.

IC=[0.5;0;0;0;0;0];    % Case # 2
F1=0; F2=0; F3=0;      % Case # 2

The simulation results of Case #2 (free motion, shown in Figure 9-20) show that the
small initial displacement (nonzero) on mass 1 result in displacements in the other two
masses as well. The computed results by the MATLAB and Simulink models converge
perfectly even though different solvers and step sizes are used.

Figure 9-20.  Simulation results of free motion of the three-DOF SMD system

335
Chapter 9 Spring-Mass-Damper Systems

Matrix Approach for n-Degree of Freedom System


When a given n-DOF system is linear, then there is another more efficient way, which is a
matrix approach, to build a simulation model of such systems. Let’s consider the forced
response of a damped linear n-degree of freedom spring-mass-damper system. The
most general formulation of such systems can be expressed in the following way:

[ M ] x + [C ] x + [ K ] x = [ B ] F (t ) (9-42)

with the initial conditions x ( 0 ) = x 0 and x ( 0 ) = x 0 , where [M], [C], [K] are mass, damper,
and spring matrices, and [B] is a column force matrix of F(t) applied force. By dividing
both sides of Equation (9-1) by [M] or multiplying by [M−1] and introducing new
variables, second-order ODEs are converted into first-order ODEs. The introduction of
new variables, for instance, for a second-order system will be x = y1 , x = y 2 , and x = y 2 .
With these substitutions, the next system of two differential equations is obtained.

ìï y1 = y 2
í (9-43)
îï y 2 = ë M û [ B ] F ( t ) - ë M û [ K ] y1 - ë M û [C ] y 2
é -1 ù é -1 ù é -1 ù

with initial conditions y1 ( 0 ) = x 0 , y 2 ( 0 ) = y1 ( 0 ) = x 0 . The formulation in Equation (9-43)


can be written in a more explicit form with the following:

é y1 ù é [0] y1 + [ I ] y2 ù
y = ê ú = ê ú=
ë y 2 û êë éë M ùû [ B ] F ( t ) - éë M ùû [ K ] y1 - éë M ùû [C ] y 2 úû
-1 -1 -1

é [0] ù é [0] y1 + [ I ] y2 ù
ê ú+ê ú (9-44)
êë éë M ùû [ B ] F ( t ) úû êë - éë M ùû [ K ] y1 - éë M ùû [C ] y 2 úû
-1 -1 -1

This is in a more general form:

y ( t ) = f ( t ) + [ A ] y ( t ) (9-45)

336
Chapter 9 Spring-Mass-Damper Systems

where A is the state matrix defined by the following equation:

é 0 I ù
A=ê ú (9-46)
êë - éë M ùû [ K ] - éë M ùû [C ]úû
-1 -1

Moreover, we can write the following:

é y1 ( t ) ù é 0 ù é y1 ( 0 ) ù é x 0 ù
y (t ) = ê ú , f ( t ) = ê M -1 BF t ú , y 0 = ê ú=ê ú (9-47)
ë y2 (t )û ë ( )û ë y 2 ( 0 ) û ë x 0 û

To summarize, after evaluating matrix [A] and a force vector f(t), if the given system is
subject to external force, we can solve the equation y ( t ) = f ( t ) + [ A ] y ( t ) numerically.
Example. Let’s consider previously studied three-DOF SMD system.

é2.5 0 0 ù éc1 + c 2 -c 2 0 ù é 3 -0.5 0 ù


[ M ] = ê 0 2 0 ú , [C ] = êê -c2
ê ú c2 + c3 ú ê
-c 3 ú = ê -0.5 4 -3.5 úú ,
êë 0 0 3 úû êë 0 -c 3 c 3 úû êë 0 -3.5 3.5 úû
ék1 + k2 - k2 0 ù é 30 -5 0 ù
[ K ] = êê -k2 k2 + k 3 ú ê
-k3 ú = ê -5 35 -30 úú
êë 0 - k3 k3 + 2k4 úû êë 0 -30 90 úû

Again, we consider two cases: forced and free motions.


Forced motion (vibration) case. This case, with zero initial conditions and external
forces applied on mass 2 and mass 1 and 3 are set free:

F1 ( t ) = 0 ; F2 ( t ) = 20 F ( t - t 0 ) ; F3 ( t ) = 0 ;

Note that F2(t) is the Heaviside step function Φ(t − t0) of maginutude 20 applied at
t0 = 0.
We write the simulation model script of the problem, MASS3.m, with a nested
function, DOF3(t, x).

function MASS3
% HELP. Simulation of three-degree-of-freedom system.
t=0:.01:120;          % Simulation time span
IC=[0;0;0;0;0;0];    % Case # 1. Forced Motion

337
Chapter 9 Spring-Mass-Damper Systems

% IC=[0.5;0;0;0;0;0]; % Initial conditions


[t, x123]=ode45(@DOF3, t, IC, []);
figure('name', 'Matrix Approach')
H=plot(t, x123(:,1), t, x123(:,3), t, x123(:,5));
H(1).Color = [1 0 0];
H(2).Color = [0 1 0];
H(3).Color = [0 0 1];
H(1).LineStyle = '-';
H(2).LineStyle = '-.';
H(3).LineStyle = '--';
H(1).LineWidth = 1.5;
H(2).LineWidth = 2.0;
H(3).LineWidth = 2.0;
legend('Mass 1: x_1(t)', 'Mass 2: x_2(t)', 'Mass 3: x_3(t)')
ylabel('\it x_1(t), x_2(t), x_3(t)')
xlabel('\it time')
title('\it Forced Motion: Displacement'), grid on
% title('\it Free Motion: Displacement'), grid on
xlim([0, 20])
figure(2)
G=plot(t, x123(:,2), t, x123(:,4), t, x123(:,6));
G(1).Color = [1 0 0];
G(2).Color = [0 1 0];
G(3).Color = [0 0 1];
G(1).LineStyle = '-';
G(2).LineStyle = '-.';
G(3).LineStyle = '--';
G(1).LineWidth = 1.5;
G(2).LineWidth = 2.0;
G(3).LineWidth = 2.0;
legend('Mass 1: dx_1(t)', 'Mass 2: dx_2(t)', 'Mass 3: dx_3(t)')
title('\it Forced Motion: Velocity'), grid on
% title('\it Free Motion: Velocity'), grid on
xlabel('\it time'), ylabel('\it dx_1, dx_2, dx_3')
xlim([0, 20])

338
Chapter 9 Spring-Mass-Damper Systems

    function  dx = DOF3(t, x)
        % HELP: three-degree-of-freedom system simulation
        k1=25; k2=5; k3=30; k4=k3; c1=2.5; c2=.5; c3=3.5;
        m1=2.5; m2=2; m3=3; M=[m1 0 0; 0 m2 0; 0 0 m3];
        K=[k1+k2, -k2, 0; -k2, k2+k3, -k3; 0, -k3, k3+2*k4];
        C=[c1+c2, -c2, 0; -c2, c2+c3, -c3; 0, -c3, c3];
        % Case 1: External forces applied
         F1= 0; t0=0; F2=20*stepfun(t,t0); F3=0;
        % Case 2: Free vibration (No force applied)
        % F1=0;F2=0;F3=0;
        B=[F1;F2;F3]; A=[zeros(3) eye(3); -inv(M)*K, -inv(M)*C];
        f=(M\eye(3))*B; dx=A*x+[0;0;0;f];
    end
end

Note that an inverse matrix computing function is computationally costly for


large systems. Thus, a backslash (\) operator is employed instead of inv() because it
is computationally more efficient and accurate than an inverse matrix computation
approach. For example, M\eye(3) is equivalent to inv(M) but more accurate and efficient
than inv(M).
By executing the model MASS3.m, we obtain the simulation results of the forced
motion, as shown in Figure 9-21 and Figure 9-22.

339
Chapter 9 Spring-Mass-Damper Systems

Figure 9-21.  Simulation results of forced motion of the three-DOF SMD system

340
Chapter 9 Spring-Mass-Damper Systems

Figure 9-22.  Simulation results of forced motion of the three-DOF SMD


system

Free motion (vibration) case. Initially, a small displacement is applied


on mass 2 alone, and zero initial conditions are given to other two masses:
x1 ( 0 ) = 0.5, x 2 ( 0 ) = 0 , x 3 ( 0 ) = 0 ; x1 ( 0 ) = 0 , x 2 ( 0 ) = 0 , x 3 ( 0 ) = 0 , F1(t) = F2(t) = F3(t) = 0. The
simulation results are shown in Figure 9-23 and Figure 9-24.

341
Chapter 9 Spring-Mass-Damper Systems

Figure 9-23.  Free motion: displacement

342
Chapter 9 Spring-Mass-Damper Systems

Figure 9-24.  Free motion: velocity

The developed simulation models of the three-DOF SMD system with free and
forced motion can be applied for n-DOF systems with minor adjustments to the system
parameters. The matrix approach is relatively simple and computationally efficient.

References
[1] Inman, D. J., 2008, Engineering Vibration (3rd ed.), Pearson Prentice Hall, pp. 15–28,
282–288.

[2] Dimarogonas, A., 1996, Vibration for Engineers (2nd ed.), Prentice Hall, pp. 84–89.

343
Chapter 9 Spring-Mass-Damper Systems

[3] Weisstein, Eric W. “Critically Damped Simple Harmonic Motion.” From


MathWorld: A Wolfram Web Resource. http://mathworld.wolfram.com/
CriticallyDampedSimpleHarmonicMotion.html, viewed on September 20, 2019.

[4] Sulaymon Eshkabilov, Beginning MATLAB and Simulink, Apress, New York: ISBN
(pbk) 978-1-4842-5060-0, ISBN (electronic) 978-1-4842-5061-7 (2019). DOI:
­https://doi.org/10.1007/978-1-4842-5061-7.

344

You might also like