Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
142 views44 pages

Vibration Lecture 3

The document summarizes the solution methods for homogeneous and non-homogeneous second-order differential equations that govern vibration systems. It presents the general differential equation and defines the terms. It then describes the solution process for homogeneous equations with constant coefficients, identifying three cases: overdamped, critically damped, and underdamped systems. Solution forms are provided for each case. Two examples are worked through to demonstrate solving the equations and plotting the response based on initial conditions.
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)
142 views44 pages

Vibration Lecture 3

The document summarizes the solution methods for homogeneous and non-homogeneous second-order differential equations that govern vibration systems. It presents the general differential equation and defines the terms. It then describes the solution process for homogeneous equations with constant coefficients, identifying three cases: overdamped, critically damped, and underdamped systems. Solution forms are provided for each case. Two examples are worked through to demonstrate solving the equations and plotting the response based on initial conditions.
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/ 44

EME 304– Mechanical Vibrations

Lecture 3
Solution of the Vibration Equation
1. Introduction

The differential equations that govern the vibration system is given by:

𝑚𝑥̈ + 𝑐𝑥̇ + 𝑘𝑥 = 𝑓(𝑡) (1)

where
𝑚: Inertia coefficient
𝑐: Damping coefficient
𝑘 Stiffness coefficient
𝑥 : Displacement
𝑑𝑥
𝑥̇ : Velocity = 𝑑𝑡
𝑑2 𝑥 𝑑𝑥̇
𝑥̈ : Acceleration = 𝑑𝑡 2 = 𝑑𝑡
𝑓(𝑡): Forcing function that might depend on time.

In the linear theory of vibration, 𝑚, 𝑐 and 𝑘 are constant coefficients. If the forcing
function 𝑓(𝑡) is equal to zero, Eq. 1 is described as homogeneous, second order
differential equation. If the forcing function 𝑓(𝑡) is not equals to zero, Eq. 1 is
described as nonhomogeneous, second order differential equation. The
nonhomogeneous differential equation corresponds to the case of forced vibration
and the homogeneous differential equation corresponds to the case of free vibration.
In the following sections we present methods for obtaining solutions for both
homogeneous and nonhomogeneous differential equations.

2. Solution of homogeneous differential Equation with constant coefficients

In this section, techniques for solving linear, homogeneous, second order differential
equations with constant coefficients are discussed. Whenever the right-hand side of
Eq. 1 is identically zero, that is

𝑓(𝑡) = 0 (2)

The equation is called a homogeneous differential equation. In this case Eq. 1


reduces to

𝑚𝑥̈ + 𝑐𝑥̇ + 𝑘𝑥 = 0 (3)

1
By a solution of Eq. 3 we mean a function x(t) which, with its derivatives, satisfies the
differential equation. A solution to Eq. 3 can be obtained by trial and error. A trial
solution is to assume the function 𝑥(𝑡) in the following form

𝑥(𝑡) = 𝐴𝑒 𝑝𝑡 (4)
The general solution of the differential equation, provided that the roots of the
differential equation are not equal, can be written as

𝑥(𝑡) = 𝐴1 𝑒 𝑝1𝑡 + 𝐴2 𝑒 𝑝2𝑡 (5)


where
−𝑐 + √𝑐 2 − 4𝑚𝑘
𝑝1 = (6)
2𝑚
−𝑐 − √𝑐 2 − 4𝑚𝑘
𝑝2 = (7)
2𝑚

That is a complete solution of the second-order ordinary differential equations


contains two arbitrary constants 𝐴1 and 𝐴2 . These arbitrary constants can be
determined from the initial conditions, as discussed in later sections.

Clearly the solution of the differential equation depends on the roots 𝑝1 and 𝑝2 .

There are three different cases for the roots 𝑝1 and 𝑝2 as shown in Table 1.

2
Table 1.1. Different Cases of the solution of the second order homogeneous
differential equation with constant coefficients.

Case 1 Case 2 Case 3


Overdamped System Critically Damped System Underdamped System
Real distinct roots Repeated roots Complex Conjugate Roots
𝑝1 and 𝑝2 are real 𝑝1 and 𝑝2 are real 𝑝1 and 𝑝2 are complex
numbers and 𝑝1 ≠ 𝑝2 numbers and 𝑝1 = 𝑝2 conjugate numbers and
𝑝1 ≠ 𝑝2
𝑐 2 > 4𝑚𝑘 𝑐 2 = 4𝑚𝑘 𝑐 2 < 4𝑚𝑘
High damping Coefficient Small damping Coefficient

The solution will be in the form of

Case 1 Case 2 Case 3


Overdamped System Critically Damped System Underdamped System
𝑥(𝑡) = 𝐴1 𝑒 𝑝1𝑡 + 𝐴2 𝑒 𝑝2𝑡 𝑥(𝑡) = (𝑐1 + 𝑐2 𝑡)𝑒 𝑝1𝑡 𝑥(𝑡) = 𝑋𝑒 𝛼𝑡 sin (𝛽𝑡 + 𝜙)
𝐴1 and 𝐴2 from initial 𝑐1 and 𝑐2 from initial 𝑋 and 𝜙 from initial
conditions conditions conditions
−𝑐 𝑐
−𝑐 + √𝑐2 − 4𝑚𝑘 𝑝 1 = 2𝑚 𝛼=−
𝑝1 = 2𝑚
2𝑚
−𝑐 − √𝑐2 − 4𝑚𝑘 1
𝛽= √4𝑚𝑘 − 𝑐2
𝑝2 = 2𝑚
2𝑚

If the initial Conditions are given as


𝑥𝑜 = 𝑥(𝑡 = 0), 𝑣𝑜 = 𝑥̇ (𝑡 = 0),

the coefficients 𝐴1 , 𝐴2 , 𝑐1, 𝑐2 , 𝑋 and 𝜙 will be calculated as follows

Case 1 Case 2 Case 3


Overdamped System Critically Damped System Underdamped System
𝑥(𝑡) = 𝐴1 𝑒 𝑝1𝑡 + 𝐴2 𝑒 𝑝2𝑡 𝑥(𝑡) = (𝑐1 + 𝑐2 𝑡)𝐴1 𝑒 𝑝1𝑡 𝑥(𝑡) = 𝑋𝑒 𝛼𝑡 sin (𝛽𝑡 + 𝜙)
𝑥𝑜 𝑝2 − 𝑣𝑜 𝑐1 = 𝑥𝑜
𝐴1 = 𝑣𝑜 − 𝛼𝑥𝑜 2
𝑝2 − 𝑝1 𝑋 = √𝑥02 + ( )
𝛽
𝑣𝑜 − 𝑝1 𝑥𝑜 𝑐2 = 𝑣𝑜 − 𝑝1 𝑥𝑜 𝛽𝑥𝑜
𝐴2 = 𝜙 = tan−1
𝑝2 − 𝑝1 𝑣𝑜 − 𝛼𝑥𝑜

3
Example 1.1

a. Find the solution of the following homogeneous second-order ordinary


differential equation

𝑥̈ − 4𝑥̇ + 3𝑥 = 0
b. If the initial conditions are 𝑥𝑜 = 2 and 𝑣𝑜 = 0, plot the response.

Solution.

a. m=1, c=-4, k=3

𝑐2 ? 4𝑚𝑘

16 > 4 × 1 × 3

Since 𝑐 2 > 4𝑚𝑘, the system is over damped.

−𝑐 + √𝑐2 − 4𝑚𝑘
𝑝1 =
2𝑚

−(−4) + √42 − 4 × 1 × 3
𝑝1 =
2×1

𝑝1 = 3

−𝑐 − √𝑐2 − 4𝑚𝑘
𝑝2 =
2𝑚

2
−(−4) − √4 − 4 × 1 × 3
𝑝2 =
2×1

𝑝2 = 1

The solution is

𝑥(𝑡) = 𝐴1 𝑒 𝑝1𝑡 + 𝐴2 𝑒 𝑝2𝑡

𝑥(𝑡) = 𝐴1 𝑒 3𝑡 + 𝐴2 𝑒 𝑡

b. The initial conditions are 𝑥𝑜 = 2 and 𝑣𝑜 = 0

𝑥𝑜 𝑝2 − 𝑣𝑜
𝐴1 =
𝑝2 − 𝑝1

4
2×1−0
𝐴1 =
1−3

𝐴1 = −1

𝑣𝑜 − 𝑝1 𝑥𝑜
𝐴2 =
𝑝2 − 𝑝1

0−3×2
𝐴2 =
1−3

𝐴2 = 3

The solution is

𝑥(𝑡) = 𝐴1 𝑒 3𝑡 + 𝐴2 𝑒 𝑡

𝑥(𝑡) = −𝑒 3𝑡 + 3𝑒 𝑡

The solution is shown in Fig. 1.1.

Fig. 1.1. Time response of example 1.1.

5
Matlab Code of Example 1.1:

Matlab Program 1.1


% Example 1.1
clear all; clf; clc
Tf=1; %Final time, sec
%time Step
dt=1e-3;
no_data_points=Tf/dt; %number of data points to plot
for i=1:no_data_points+1
t(i)=(i-1)*dt;
x(i)=-exp(3*t(i))+3*exp(t(i));
end
%plotting
figure(1);plot(t,x,'linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
axis([0 1.2*Tf 1.2*min(x) 1.2*max(x)])
grid on
title('Example 1.1 ','FontSize',16);
saveas(gcf, 'Example 1_1.tiff');

Example 1.2

a. Find the solution of the following homogeneous second-order ordinary


differential equation

𝑥̈ + 6𝑥̇ + 9𝑥 = 0

b. If the initial conditions are 𝑥𝑜 = 0 and 𝑣𝑜 = 1, plot the response.

Solution.

a. m=1, c=6, k=9

𝑐2 ? 4𝑚𝑘

36 = 4 × 1 × 9

Since 𝑐 2 = 4𝑚𝑘, the system is critically damped.

−𝑐 −6
𝑝1 = = = −3
2𝑚 2 × 1

6
The solution is

𝑥(𝑡) = (𝑐1 + 𝑐2 𝑡)𝑒 𝑝1𝑡

𝑥(𝑡) = (𝑐1 + 𝑐2 𝑡)𝑒 −3𝑡

b. The initial conditions are 𝑥𝑜 = 0 and 𝑣𝑜 = 1

𝑐1 = 𝑥𝑜 = 0

𝑐2 = 𝑣𝑜 − 𝑝1 𝑥𝑜 = 1 − (−3) × 0 = 1

The solution is

𝑥(𝑡) = (𝑐1 + 𝑐2 𝑡)𝑒 −3𝑡

𝑥(𝑡) = (0 + 1 × 𝑡)𝑒 −3𝑡

𝑥(𝑡) = 𝑡𝑒 −3𝑡

The solution is shown in Fig. 1.2.

Fig. 1.2. Time response of example 1.2.

7
Matlab Code of Example 1.2:

Matlab Program 1.2

% Example 1.2
clear all; clf; clc
Tf=4; %Final time, sec
%time Step
dt=1e-3;
no_data_points=Tf/dt; %number of data points to plot
for i=1:no_data_points+1
t(i)=(i-1)*dt;
x(i)=t(i).*exp(-3*t(i));
end
%plotting
figure(1);plot(t,x,'linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
axis([0 Tf+1 .8*min(x) 1.2*max(x)])
grid on
title('Example 1.2 ','FontSize',16);
saveas(gcf, 'Example 1_2.tiff');

Example 1.3

a. Find the solution of the following homogeneous second-order ordinary


differential equation

5𝑥̈ + 2𝑥̇ + 50𝑥 = 0

b. If the initial conditions are 𝑥𝑜 = 0.01 and 𝑣𝑜 = 3, plot the response.

Solution.

a. m=5, c=2, k=50

𝑐2 ? 4𝑚𝑘

4 < 4 × 5 × 50

Since 𝑐 2 < 4𝑚𝑘, the system is underdamped.

𝑐 2
𝛼=− =− = −0.2
2𝑚 2×5

1 1
𝛽= √4𝑚𝑘 − 𝑐2 = √4 × 5 × 50 − 22 = 3.156
2𝑚 2×5

8
The solution is

𝑥(𝑡) = 𝑋𝑒 𝛼𝑡 sin (𝛽𝑡 + 𝜙)

𝑥(𝑡) = 𝑋𝑒 −0.2𝑡 sin (3.156𝑡 + 𝜙)

b. The initial conditions are 𝑥𝑜 = 0.01 and 𝑣𝑜 = 3

𝑣𝑜 − 𝛼𝑥𝑜 2
𝑋 = √𝑥02 + ( )
𝛽

2
3 − (−0.2) × 0.01
𝑋 = √0.012 + ( ) = 0.9512
3.156

𝛽𝑥𝑜
𝜙 = tan−1
𝑣𝑜 − 𝛼𝑥𝑜

3.156 × 0.01
𝜙 = tan−1 = 0.6023°
3 − (−0.2) × 0.01

The compete solution is then given by

𝑥(𝑡) = 𝑋𝑒 −0.2𝑡 sin (3.156𝑡 + 𝜙)

𝑥(𝑡) = 0.9512𝑒 −0.2𝑡 sin (3.156𝑡 + 0.6023)

The solution is shown in Fig. 1.3.

Fig. 1.3. Time response of example 1.3.

9
Matlab Code of Example 1.3:

Matlab Program 1.3

% Example 1.3
clear all; clf; clc
Tf=10; %Final time, sec
%time Step
dt=1e-3;
no_data_points=Tf/dt; %number of data points to plot
for i=1:no_data_points+1
t(i)=(i-1)*dt;
x(i)=0.9512*exp(-0.2*t(i))*sin(3.156*t(i)+.6023*pi/180);
end
%plotting
figure(1);plot(t,x,'linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
axis([0 Tf+1 1.2*min(x) 1.2*max(x)])
grid on
title('Example 1.3 ','FontSize',16);
saveas(gcf, 'Example 1_3.tiff');

General Matlab code for solving solve homogeneous second order differential
equation of single degree of freedom vibratory system

Matlab Program 1.4

% General Program to plot the response of Second Order ODE


of a vibratory system
clear all; clf; clc
%Inputs
m=5; % mass
c=2; %damping
k=50; %stiffness
Tf=10; %Final time, sec
dt=1e-3; %time Step
%initial conditions
xo=0.01; % initial displacement
vo=3; % initial velocity
no_data_points=Tf/dt; %number of data points to plot
C= c^2-4*m*k;
% Overdamped System C^2>4mk
if C>0
p1= (-c+sqrt(c^2-4*m*k))/(2*m);
p2= (-c-sqrt(c^2-4*m*k))/(2*m);
A1=(xo*p2-vo)/(p2-p1);

10
A2=(vo-xo*p1)/(p2-p1);
for i=1:no_data_points+1
t(i)=(i-1)*dt;
x(i)=A1*exp(p1*t(i))+A2*exp(p2*t(i));
end
end
% Critically damped System C^2=4mk
if C==0
p1_1= (-c/(2*m));
c1=xo;
c2=vo-xo*p1_1;
for i=1:no_data_points+1
t(i)=(i-1)*dt;
x(i)=(c1+c2*t(i))*exp(p1_1*t(i));
end
end
% Undrdamped System C^2<4mk
if C<0
alpha= (-c)/(2*m);
beta= (sqrt(4*m*k-c^2))/(2*m);
X=sqrt(xo^2+((vo-alpha*xo)/beta)^2);
phi=atand((beta*xo)/(vo-alpha*xo));
for i=1:no_data_points+1
t(i)=(i-1)*dt;
x(i)=X*exp(alpha*t(i))*sin(beta*t(i)+phi*pi/180);
end
end
%plotting
figure(1);plot(t,x,'linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
axis([0 Tf+0.2 1.2*min(x) 1.2*max(x)])
grid on

Dsolve Command in matlab

Dsolve command in Matlab can be used to find the analytical solution of first and
second order ODE as shown in the following two examples.

Example 1.4

By using Dsolve command in Matlab, solve the following ODE:

𝑥̇ (𝑡) = 2𝑡 − 𝑥, 𝑥(0) = 1

11
Matlab Program 1.5

% Example 1-4
X=dsolve('Dx-2*t+x=0','x(0)=1','t')
X=simple(X);
pretty(X)
ezplot(X,(0:0.05:0.3))

Matlab Output

X =

2*t + 3*exp(-t) - 2

2 t + 3 exp(-t) - 2

Fig. 1.4. Time response of example 1.4.

The exact solution is

𝑥(𝑡) = 3𝑒 −𝑡 + 2𝑡 − 2

Example 1.5

By using Dsolve command in Matlab, solve the following ODE:


3𝑥̈ + 𝑥̇ + 2𝑥 = 0
subject to the initial conditions 𝑥(0) = 0, 𝑥̇ (0) = 0.25 over the time interval 0 ≤ 𝑡 ≤
20 sec by using 4th order Runge-Kutta method.

Matlab Program 1.6

% Example 1-5
clc; clear all; clf;
tf=20;

12
X=dsolve('3*D2x+1*Dx+2*x=0','Dx(0)=0.25','x(0)=0','t');
X=simple(X)
pretty(X)
ezplot(X,(0:0.01:20))
grid on
saveas(gcf, 'Example 1_5.tiff');

Matlab Output

X =

(3*23^(1/2)*exp(-t/6)*sin((23^(1/2)*t)/6))/46

/ 1/2 \
1/2 / t \ | 23 t |
3 23 exp| - - | sin| ------- |
\ 6 / \ 6 /
---------------------------------
46
The exact solution is
𝑡
𝑥(𝑡) = 0.31𝑒 −6 sin (0.79𝑡)

Fig. 1.5. Time response of example 1.5.

13
3. Solution of nonhomogeneous differential Equation with constant
coefficients

The nonhomogeneous differential Equation with constant coefficients of a vibratory


system is written as:

𝑚𝑥̈ + 𝑐𝑥̇ + 𝑘𝑥 = 𝑓(𝑡) (8)

where 𝑓(𝑡) is the forcing function. The solution of the equation consists of two parts.
First the complementary solution 𝑥𝑐 of Eq.8 where the right hand side is equal to zero,
that is, 𝑓(𝑡) = 0. Methods for obtaining the complementary solutions were discussed
in the proceeding sections. The second part of the solution is the particular solution,
𝑥𝑝 . The complete solution of Eq.8 can be written as

𝑥 =complementary solution + particular solution

𝑥 = 𝑥𝑐 + 𝑥𝑝 (9)

where 𝑥𝑐 is the solution of the equation

𝑚𝑥̈ 𝑐 + 𝑐𝑥̇ 𝑐 + 𝑘𝑥𝑐 = 0 (10)

and 𝑥𝑝 is the solution of the equation

𝑚𝑥̈ 𝑝 + 𝑐𝑥̇ 𝑝 + 𝑘𝑥𝑝 = 𝑓(𝑡) (11)

The particular solution 𝑥𝑝 can be found by the method of undetermined coefficients.

The solution of different force functions is given below


1. For a constant Force, the forcing function will be
𝑓(𝑡) = 𝐹0 (12)
and the particular solution, 𝑥𝑝 will be

𝑥𝑝 =
𝐹0
(13)
𝑘

2. For a sinusoidal Force, the forcing function will be

𝑓(𝑡) = 𝐹0 sin(𝜔𝑡) (14)

and the particular solution, 𝑥𝑝 will be

𝐹0 𝑐𝜔
𝑥𝑝 = sin (𝑤𝑡 − (𝑡𝑎𝑛−1 ( ))) (15)
√(𝑘 − 𝑚𝜔 2 )2 + (𝑐𝜔)2 𝑘 − 𝑚𝜔 2

14
4. Numerical Simulation of the time response

The solution of the vibration problems is often plotted versus time in order to
visualize the physical vibration and to obtain an idea of the nature of the response.
For simple vibration problems, there is analytical (closed form solution for the
displacement as a function of time) solution. However for real life problems, the
equations are more complex and sometimes nonlinear that is difficult or impossible
to solve analytically. The use of numerical solution (integration) greatly enhances the
understanding of vibration. Just as a picture is worth a thousand words, a numerical
simulation or plot can enable a completely dynamic understanding of vibration
phenomena. Computer calculations and simulations are presented at the end of each
chapter.
The free response of any system is usually computed by simple numerical means such
as Euler’s method, Heun’s or Runge-Kutta methods. The basis of the numerical
solutions of ordinary differential equations is to essentially undo calculus by
representing each derivative by a small but finite difference. A numerical solution of
an ordinary differential equation is a procedure for constructing approximate values:
x1, x2, …, xn, of the solution x(t) at the discrete values of time: to < t1 … <tn. Effectively,
a numerical procedure produces a list of discrete values xi = x(ti) that approximates
the solution, as shown in Fig.1, rather than a continuous function x(t), which is the
exact solution.

Fig. 1.6. Time discretization of time response.

15
For a single degree of freedom system of the form

𝑚𝑥̈ + 𝑐𝑥̇ + 𝑘𝑥 = 0 𝑥(0) = 𝑥𝑜 𝑣(0) = 𝑣𝑜 (16)

the initial values xo (initial displacement) and vo (initial velocity) form the first two
points of the numerical solution. The equation will be solved for values of time 𝑡
between 𝑡 = 0 and 𝑡 = 𝑇𝑓 , where 𝑇𝑓 is the total length of time over which the solution
is of interest. The time interval 𝑇𝑓 − 0 is then divided into 𝑛 intervals (so that ∆𝑡 =
𝑇𝑓 ⁄𝑛 ). Then Eq.16 is calculated at the values of 𝑡𝑜 = 0, 𝑡1 = ∆𝑡, 𝑡2 = 2∆𝑡, … , 𝑡𝑛 =
𝑛∆𝑡 = 𝑇𝑓 to produce an approximate representation, or simulation, of the solution.
The concept of a numerical solution is easiest to grasp by first examining the
numerical solution of a first order scalar differential equation. To this end consider
the first order differential equation

𝑥̇ (𝑡) = 𝑓(𝑥, 𝑡), 𝑥(0) = 𝑥𝑜 (17)

5. Euler’s Method for first order ODE


The Euler’s method proceeds from the definition of the slope form of the derivative
at 𝑡 = 𝑡𝑖 is

𝑑𝑥(𝑡𝑖 ) 𝑥(𝑡𝑖+1 ) − 𝑥(𝑡𝑖 ) 𝑥𝑖+1 − 𝑥𝑖


𝑥̇ (𝑡𝑖 ) = 𝑥̇ 𝑖 = = lim = = 𝑓(𝑡𝑖 , 𝑥𝑖 )
𝑑𝑡 ∆𝑡=0 ∆𝑡 ∆𝑡

𝑓(𝑡𝑖 , 𝑥𝑖 ) = 𝐴𝑖

where 𝐴𝑖 is the derivative at time 𝑡𝑖 and 𝑥(𝑡𝑖 ) = 𝑥𝑖

𝑥𝑖+1 − 𝑥𝑖
= 𝐴𝑖
∆𝑡
𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡𝐴𝑖

Euler’s Equations
𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡

𝐴𝑖 = 𝑓(𝑡𝑖 , 𝑥𝑖 )
(18)
𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡𝐴𝑖

Example 2.1

By using Euler’s method, solve the following ODE:

𝑥̇ (𝑡) = 5𝑥, 𝑥(0) = 1, ∆𝑡 = 0.1

16
Solution

𝑥𝑜 = 1 , 𝑡𝑜 = 0

𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡 = 𝑡𝑖 + 0.1

𝐴𝑖 = 𝑓(𝑡𝑖 , 𝑥𝑖 ) = 5𝑥𝑖

𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡𝐴𝑖

For i=0:

𝑡1 = 𝑡0 + ∆𝑡 = 0 + 0.1 = 0.1

𝐴0 = 𝑓(𝑡0 , 𝑥0 ) = 5𝑥0 = 5 × 1 = 5

𝑥1 = 𝑥0 + ∆𝑡𝐴0 = 1 + 0.1 × 5 = 1.5

For i=1:

𝑡2 = 𝑡1 + ∆𝑡 = 0.1 + 0.1 = 0.2

𝐴1 = 𝑓(𝑡1 , 𝑥1 ) = 5𝑥1 = 5 × 1.5 = 7.5

𝑥2 = 𝑥1 + ∆𝑡𝐴1 = 1.5 + 0.1 × 7.5 = 2.15

Iteration, 𝑖 𝑡𝑖 𝑥𝑖 𝐴𝑖 ∆𝑡𝐴𝑖
0 0 1 5×1=5 0.1 × 5 = 0.5
1 0.1 1 + 0.5 = 1.5 5 × 1.5 0.1 × 7.5
2 0.2 1.5 + 0.75 = 2.25
= 7.5 = 0.75

Exact solution can be found by using the following Matlab program

Matlab Program 1.7

X=dsolve('Dx-5*x=0','x(0)=1','t')
X=simple(X);
pretty(X)

Te exact solution is:

𝑥(𝑡) = 𝑒 5𝑡

17
A comparison between Euler method numerical solution and the exact solution is
shown in Fig. 1.7.

Fig. 1.7. Time response of example 2.1.

Matlab Code for Example 2.1:

Matlab Program 1.8

% Euler Method Program to plot the response of first Order


ODE
% Example 2_1
clear all; clf; clc
% xdot=ax+bt+c
%Inputs
a=5;
b=0; %damping
c=0; %stiffness
Tf=10; %Final time, sec
dt=1e-1; %time Step
%initial conditions
x(1)=1; % initial displacement
x_exact(1)=x(1);
no_data_points=Tf/dt; %number of data points to plot
% for i=1:no_data_points+1
for i=1:3
t(i)=(i-1)*dt;
A(i)= a*x(i)+b*t(i)+c;
x(i+1)=x(i)+A(i)*dt;

18
x_exact(i+1)=1*exp(a*(t(i)+dt));
end
t(i+1)=(i)*dt;
%plotting
figure(1);plot(t,x,'linewidth', 2);
hold on
plot(t,x_exact,'r:','linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
% axis([0 Tf+0.2 1.2*min(x) 1.2*max(x)])
grid on
legend('Euler', 'Exact','location', 'best')
title('Example 2.1 ','FontSize',16);
saveas(gcf, 'Example 2_1.tiff');

Example 2.2

By using Euler’s method, solve the following ODE:

𝑥̇ (𝑡) = 2𝑡 − 𝑥, 𝑥(0) = 1, ∆𝑡 = 0.1

Solution

𝑥𝑜 = 1 , 𝑡𝑜 = 0

𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡 = 𝑡𝑖 + 0.1

𝐴𝑖 = 𝑓(𝑡𝑖 , 𝑥𝑖 ) = 2𝑡𝑖 − 𝑥𝑖

𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡𝐴𝑖

For i=0:

𝑡1 = 𝑡0 + ∆𝑡 = 0 + 0.1 = 0.1

𝐴0 = 𝑓(𝑡0 , 𝑥0 ) = 2𝑡0 − 𝑥0 = 2 × 0 − 1 = −1

𝑥1 = 𝑥0 + ∆𝑡𝐴0 = 1 + 0.1 × (−1) = 0.9

For i=1

𝑡2 = 𝑡1 + ∆𝑡 = 0.1 + 0.1 = 0.2

𝐴1 = 𝑓(𝑡1 , 𝑥1 ) = 2𝑡1 − 𝑥1 = 2 × 0.1 − 0.9 = −0.7

𝑥2 = 𝑥1 + ∆𝑡𝐴1 = 0.9 + 0.1 × (−0.7) = 0.83

19
𝑡𝑖 𝑥𝑖 𝐴𝑖 ∆𝑡𝐴𝑖
0 0 1 −1 −0.1
1 0.1 0.9 −0.7 −0.07
2 0.2 0.83

It was shown in example 1.4 that the exact solution of this differential equation is

𝑥(𝑡) = 3𝑒 −𝑡 + 2𝑡 − 2
Iteration, 𝑖
A comparison between Heun method numerical solution and the exact solution is
shown in Fig. 1.8.

Fig. 1.8. Time response of example 2.2.

Matlab Code for Example 2.2:

Matlab Program 1.10

% Euler Method Program to plot the response of first Order


ODE
% Example 2_2

20
clear all; clf; clc
% xdot=ax+bt+c
%Inputs
a=-1;
b=2;
c=0;
Tf=0.5; %Final time, sec
dt=1e-1; %time step
%initial conditions
x(1)=1; % initial displacement
x_exact(1)=x(1);
error(1)=abs(x(1)-x_exact(1))/(x_exact(1))*100;
no_data_points=Tf/dt; %number of data points to plot
for i=1:no_data_points
t(i)=(i-1)*dt;
A(i)= a*x(i)+b*t(i)+c;
x(i+1)=x(i)+A(i)*dt;
x_exact(i+1)=3*exp(-(t(i)+dt))+2*(t(i)+dt)-2;
error(i+1)=abs(x_exact(i+1)-x(i+1))/(x_exact(i+1))*100;
end
t(i+1)=(i)*dt;
%plotting
figure(1);plot(t,x,'linewidth', 2);
hold on
figure(1);plot(t,x_exact,'r:','linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
grid on
legend('Euler', 'Exact','location', 'best')
title('Example 2.2 ','FontSize',16);
saveas(gcf, 'Example 2_2.tiff');

Is Euler’s method accurate?

Euler is a first order method that assumes that the slope is constant in the time step
and uses the slope at the beginning. The error in Euler method is first order error and
is related of the time step. That means if you halve the time step the error will halve.
So by decreasing the time step, the error will decrease, but there are better methods
of numerical integration with a higher order error. The better method will find a
better slope.

21
6. Heun’s (Modified Euler’s) Method for first order ODE

This method calculates two slopes, the slope at the beginning and end of the time step.
Then by averaging the two slopes we will get a better slope than Euler method.

Fig. 1.9. Heun numerical integration method.

Modified Euler (Heun) Equations

𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡

𝐵𝑖 = 𝑓(𝑡𝑖 , 𝑥𝑖 )

𝑥̃𝑖+1 = 𝑥𝑖 + ∆𝑡𝐵𝑖

𝐶𝑖 = 𝑓(𝑡𝑖+1 , 𝑥̃𝑖+1 ) (19)

𝐵𝑖 + 𝐶𝑖
𝐴𝑖 =
2

𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡𝐴𝑖

The condensed form of Modified Euler (Heun) Equations is:

𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡

𝑥̃𝑖+1 = 𝑥𝑖 + ∆𝑡𝑓(𝑡𝑖 , 𝑥𝑖 )

𝑓(𝑡𝑖 , 𝑥𝑖 ) + 𝑓(𝑡𝑖+1 , 𝑥̃𝑖+1 )


𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡 ( )
2

Example 2.3

By using Heun’s method solve the following ODE:

𝑥̇ (𝑡) = 2𝑡 − 𝑥, 𝑥(0) = 1, ∆𝑡 = 0.1

22
Solution
𝑥𝑜 = 1 , 𝑡𝑜 = 0

𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡 = 𝑡𝑖 + 0.1

𝐵𝑖 = 𝑓(𝑡𝑖 , 𝑥𝑖 ) = 2𝑡𝑖 − 𝑥𝑖

𝑥̃𝑖+1 = 𝑥𝑖 + ∆𝑡𝐵𝑖

𝐶𝑖 = 𝑓(𝑡𝑖+1 , 𝑥̃𝑖+1 ) = 2𝑡𝑖+1 − 𝑥̃𝑖+1

𝐵𝑖 + 𝐶𝑖
𝐴𝑖 =
2

𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡𝐴𝑖

For i=0:
𝑡1 = 𝑡0 + ∆𝑡 = 0 + 0.1 = 0.1

𝐵0 = 𝑓(𝑡0 , 𝑥0 ) = 2𝑡0 − 𝑥0 = 2 × 0 − 1 = −1

𝑥̃1 = 𝑥0 + ∆𝑡𝐵0 = 1 + 0.1 × (−1) = 0.9

𝐶0 = 𝑓(𝑡1 , 𝑥̃1 ) = 2𝑡1 − 𝑥̃1 = 2 × 0.1 − 0.9 = −0.7

𝐵0 + 𝐶0 −1 + (−0.7)
𝐴0 = = = −0.85
2 2

𝑥1 = 𝑥0 + ∆𝑡𝐴0 = 1 + 0.1 × (−0.85) = 0.915

For i=1
𝑡2 = 𝑡1 + ∆𝑡 = 0.1 + 0.1 = 0.2

𝐵1 = 𝑓(𝑡1 , 𝑥1 ) = 2𝑡1 − 𝑥1 = 2 × 0.1 − 0.915 = −0.715

𝑥̃2 = 𝑥1 + ∆𝑡𝐵1 = 0.915 + 0.1 × (−0.7) = 0.845

𝐶1 = 𝑓(𝑡2 , 𝑥̃2 ) = 2𝑡2 − 𝑥̃2 = 2 × 0.2 − 0.845 = −0.445

𝐵1 + 𝐶1 −0.715 + (−0.445)
𝐴1 = = = −0.58
2 2

𝑥2 = 𝑥1 + ∆𝑡𝐴1 = 0.915 + 0.1 × (−0.58) = 0.857

23
In a tabular form

Iteration, 𝑖 𝑡𝑖 𝑥𝑖 𝐵𝑖 𝑥̃𝑖+1 𝐶𝑖 𝐴𝑖 ∆𝑡𝐴𝑖


0 0 1 -1 0.9 -0.7 -.85 -0.085
1 0.1 0.915 -0.715 0.845 -0.445 -.058 -.0058
2 0.2 0.857

A comparison between 4th order Runge-Kutta method numerical solution and the
exact solution is shown in Fig. 1.10.

Fig. 1.10. Time response of example 2.3.

Matlab Code for Example 2.3:

Matlab Program 1.11

% Heun Method (Modified Euler) Program to plot the response


of first Order ODE
% Example 2_3
clear all; clf; clc
% xdot=ax+bt+c
%Inputs
a=-1;

24
b=2;
c=0;
Tf=0.5; %Final time, sec
dt=1e-1; %time Step
%initial conditions
x(1)=1; % initial displacement
x_exact(1)=x(1);
error(1)=abs(x(1)-x_exact(1))/(x_exact(1))*100;
no_data_points=Tf/dt; %number of data points to plot
for i=1:no_data_points
t(i)=(i-1)*dt;
B(i)= a*x(i)+b*t(i)+c;
x_1=x(i)+B(i)*dt;
C(i)= a*x_1+b*(t(i)+dt)+c;
A(i)= (B(i)+C(i))/2;
x(i+1)=x(i)+A(i)*dt;
x_exact(i+1)=3*exp(-(t(i)+dt))+2*(t(i)+dt)-2;
error(i+1)=abs(x_exact(i+1)-x(i+1))/(x_exact(i+1))*100;
end
t(i+1)=(i)*dt;
%plotting
figure(1);plot(t,x,'linewidth', 2);
hold on
figure(1);plot(t,x_exact,'r:','linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
grid on
legend('Heun', 'Exact','location', 'best')
title('Example 2.3 ','FontSize',16);
saveas(gcf, 'Example 2_3.tiff');

7. 4th order Runge-Kutta Method for first order ODE

Euler's method and the improved Euler's method are the simplest examples of a
whole family of numerical methods to approximate the solutions of differential
equations called Runge-Kutta methods. In this section we will give third and fourth
order Runge-Kutta methods and discuss how Runge-Kutta methods are developed.
Euler's method and the improved Euler's method both try to approximate
Euler's
method approximates the slope of the secant line by the slope of the tangent line at
the left endpoint
The improved Euler's method uses the average of the slopes at the left endpoint and
the approximate right endpoint (that is the right endpoint as computed by Euler's
method) to approximate the slope of the secant line. We don't have to stop there
either. We can keep finding slopes at different points and computing weighted
averages to approximate the slope of the tangent line. Numerical methods to
approximate the solution of differential equations in this fashion are called Runge-
Kutta methods (after the mathematicians Runge and Kutta).

25
This method calculates four slopes, the slope at the beginning, middle and end of the
time step. Then by using the weighted average of the four slopes we will get a better
slope than Euler method.
By considering the following first order ODE:

𝑥̇ (𝑡) = 𝑓(𝑥, 𝑡), 𝑥(0) = 𝑥𝑜 (20)

𝑥𝑖+1 = 𝑥𝑖 +
∆𝑡
(𝑆𝑖,1 + 2𝑆𝑖,2 + 𝑆𝑖,3 + 𝑆𝑖,4 ) (21)
6

where
𝑆𝑖,1 = 𝑓(𝑡𝑖 , 𝑥𝑖 )
∆𝑡 ∆𝑡
𝑆𝑖,2 = 𝑓 (𝑡𝑖 + , 𝑥𝑖 + 𝑆𝑖,1 )
2 2
∆𝑡 ∆𝑡
𝑆𝑖,3 = 𝑓 (𝑡𝑖 + , 𝑥𝑖 + 𝑆𝑖,2 )
2 2
𝑆𝑖,4 = 𝑓(𝑡𝑖 + ∆𝑡, 𝑥𝑖 + ∆𝑡𝑆𝑖,3 )

4th order Runge-Kutta Equations:

𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡

𝑆𝑖,1 = 𝑓(𝑡𝑖 , 𝑥𝑖 )

𝑥̃𝑖+1,1 = 𝑥𝑖 + ∆𝑡⁄2 × 𝑆𝑖,1

𝑆𝑖,2 = 𝑓(𝑡𝑖 + ∆𝑡⁄2 , 𝑥̃𝑖+1,1 )

𝑥̃𝑖+1,2 = 𝑥𝑖 + ∆𝑡⁄2 × 𝑆𝑖,2

𝑆𝑖,3 = 𝑓(𝑡𝑖 + ∆𝑡⁄2 , 𝑥̃𝑖+1,2 ) (22)


𝑥̃𝑖+1,3 = 𝑥𝑖 + ∆𝑡 × 𝑆𝑖,3

𝑆𝑖,4 = 𝑓(𝑡𝑖 + ∆𝑡, 𝑥̃𝑖+1,3 )

𝑆𝑖,1 + 2𝑆𝑖,2 + 2𝑆𝑖,3 + 𝑆𝑖,4


𝑄𝑖 =
6

𝑥𝑖+1 = 𝑥𝑖 + ∆𝑡𝑄𝑖

26
An example of the first calculation is shown below for i=0

𝑡1 = 𝑡0 + ∆𝑡

𝑆0,1 = 𝑓(𝑡0 , 𝑥0 )

𝑥̃1,1 = 𝑥0 + ∆𝑡⁄2 × 𝑆0,1

𝑆0,2 = 𝑓(𝑡0 + ∆𝑡⁄2 , 𝑥̃1,1 )

𝑥̃1,2 = 𝑥0 + ∆𝑡⁄2 × 𝑆0,2

𝑆0,3 = 𝑓(𝑡0 + ∆𝑡⁄2 , 𝑥̃1,2 )

𝑥̃1,3 = 𝑥𝑖 + ∆𝑡 × 𝑆0,3

𝑆0,4 = 𝑓(𝑡𝑖 + ∆𝑡, 𝑥̃1,3 )

𝑆0,1 + 2𝑆0,2 + 2𝑆0,3 + 𝑆0,4


𝑄0 =
6

𝑥1 = 𝑥0 + ∆𝑡𝑄0

The solution was computed by using Matlab software and the response is shown in
Fig. 1.11.

Fig. 1.11. Time response of example 2.4.

27
Matlab Code for Example 2.4:

Matlab Program 1.12

% Runge-Kutta 4th order Program to plot the response of


first Order ODE
% Example 2_4
clear all; clf; clc
% xdot=ax+bt+c
%Inputs
a=-1;
b=2;
c=0;
Tf=0.5; %Final time, sec
dt=1e-1; %time Step
%initial conditions
x(1)=1; % initial displacement
x_exact(1)=x(1);
error(1)=abs(x(1)-x_exact(1))/(x_exact(1))*100;
no_data_points=Tf/dt; %number of data points to plot
for i=1:no_data_points
t(i)=(i-1)*dt;
S1(i)= a*x(i)+b*t(i)+c;
x_1=x(i)+S1(i)*dt/2;
S2(i)= a*x_1+b*(t(i)+dt/2)+c;
x_2=x(i)+S2(i)*dt/2;
S3(i)= a*x_2+b*(t(i)+dt/2)+c;
x_3=x(i)+S3(i)*dt;
S4(i)= a*x_3+b*(t(i)+dt)+c;
Q(i)= (S1(i)+2*S2(i)+2*S3(i)+S4(i))/6;
x(i+1)=x(i)+Q(i)*dt;
x_exact(i+1)=3*exp(-(t(i)+dt))+2*(t(i)+dt)-2;
error(i+1)=abs(x_exact(i+1)-x(i+1))/(x_exact(i+1))*100;
end
t(i+1)=(i)*dt;
%plotting
figure(1);plot(t,x,'linewidth', 2);
hold on
figure(1);plot(t,x_exact,'r:','linewidth', 2);
xlabel('Time (sec)','FontSize',12);
ylabel('Displacement (mm)','FontSize',12);
grid on
legend('RK4', 'Exact','location', 'best')
title('Example 2.4 ','FontSize',16);
saveas(gcf, 'Example 2_4.tiff');

28
Comparison of the numerical integration methods

Iteration Euler Heun RK4 Exact


1 1 1 1 1
2 0.9 0.915 0.914513 0.914512
3 0.83 0.857075 0.856193 0.856192
4 0.787 0.823653 0.822455 0.822455
5 0.7683 0.812406 0.810961 0.81096

The error percentage for each method is show in the following table

Iteration Euler Heun RK4


1 0 0 0
2 1.586885 0.053334 2.69E-05
3 3.059156 0.103101 5.20E-05
4 4.310835 0.145687 7.34E-05
5 5.260448 0.178272 8.98E-05

The time response plot for each method is shown in the Fig. 1.12.

Fig. 1.12. Comparison mf the time response for Euler, Heun’s, 4th order Runge-Kutta
and exact solution.

29
8. Numerical Integration of second order DOE

The Euler's, Heun's, Runge-Kutta methods can be applied to first order systems only.
So that it will be necessary to convert the second order vibration equation into two
first order equations. The non-homogeneous differential equation with constant
coefficients of a vibratory system is written as:

𝑚𝑥̈ + 𝑐𝑥̇ + 𝑘𝑥 = 0 𝑥(0) = 𝑥𝑜 𝑣(0) = 𝑣𝑜 (23)

To achieve this, new variables 𝑦1 and 𝑦2 are defined as follows


𝑦1 = 𝑥(𝑡) 𝑎𝑛𝑑 𝑦2 = 𝑥̇ (𝑡)
Hence

𝑥 = 𝑦1 𝑥̇ = 𝑦2 = 𝑦̇ 1 𝑥̈ = 𝑦̇ 2

Substitute into Eq.23

𝑚𝑦̇ 2 + 𝑐𝑦2 + 𝑘𝑦1 = 𝑓(𝑡)

𝑐 𝑘 𝑓(𝑡)
𝑦̇ 2 = − 𝑦2 − 𝑦1 +
𝑚 𝑚 𝑚

Therefore, we are going to solve the next two first order equations:

𝑦̇ 1 = 𝑦2

𝑐 𝑘 (24)
𝑦̇ 2 = − 𝑦2 − 𝑦1 + 𝑓(𝑡)
𝑚 𝑚

In matrix form:
0 1 𝑦 0
𝑦̇ 1 𝑐 ] [ 1 ] + [𝑓(𝑡)]
[ ]=[ 𝑘 𝑦2
𝑦̇ 2 − −
𝑚 𝑚 𝑚

Equation 24 can be written as

𝑦̇ = 𝐴𝑦 + 𝐵(𝑡) (25)

𝑦1 (0) 𝑥(0) 𝑥𝑜
𝑦(0) = [ ]=[ ] = [𝑣 ]
𝑦2 (0) 𝑥̇ (0) 𝑜

where
0 1 0
𝐴=[ 𝑘 𝑐 ] , 𝐵 = [𝑓(𝑡)]
− −
𝑚 𝑚 𝑚

30
𝑦̇ 𝑥̇ 𝑦1 𝑥
𝑦̇ = [ 1 ] = [ ] 𝑦 = [𝑦 ] = [ ]
𝑦̇ 2 𝑥̈ 2 𝑥̇

The matrix 𝐴 defined in this way is called the state matrix and the vector 𝑦 is called
the state vector. The position 𝑦1 and the velocity 𝑦1 are called the state variables.
Now the Euler and Range-Kutta methods of numerical solution can be applied to
Eq.25 as follows:

Euler Method
𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡

𝑆𝑖 = 𝐴𝑦(𝑖) + 𝐵(𝑡)
(26)
𝑦(𝑖 + 1) = 𝑦(𝑖) + ∆𝑡𝑆𝑖

Runge-Kutta Method
𝑡𝑖+1 = 𝑡𝑖 + ∆𝑡

𝑆𝑖,1 = ∆𝑡 × 𝑓(𝑡𝑖 , 𝑦(𝑖))

𝑓(𝑡𝑖 , 𝑦(𝑖)) = 𝐴𝑦(𝑖) + 𝐵(𝑡𝑖 )

𝑦̃1 (𝑖 + 1) = 𝑦(𝑖) + 𝑆𝑖,1⁄2

𝑆𝑖,2 = 𝑓(𝑡𝑖 + ∆𝑡⁄2 , 𝑦̃1 (𝑖 + 1))

𝑓(𝑡𝑖 + ∆𝑡⁄2 , 𝑦̃1 (𝑖 + 1)) = 𝐴𝑦̃1 (𝑖 + 1) + 𝐵(𝑡𝑖 + ∆𝑡⁄2)

𝑦̃2 (𝑖 + 1) = 𝑦(𝑖) + 𝑆2 ⁄2

𝑆𝑖,3 = 𝑓(𝑡𝑖 + ∆𝑡⁄2 , 𝑦̃2 (𝑖 + 1)) (27)

𝑓(𝑡𝑖 + ∆𝑡⁄2 , 𝑦̃2 (𝑖 + 1)) = 𝐴𝑦̃2 (𝑖 + 1) + 𝐵(𝑡𝑖 + ∆𝑡⁄2)

𝑦̃3 (𝑖 + 1) = 𝑦(𝑖) + 𝑆𝑖,3

𝑆𝑖,4 = 𝑓(𝑡𝑖 + ∆𝑡, 𝑦̃3 (𝑖 + 1))

𝑓(𝑡𝑖 + ∆𝑡, 𝑦̃3 (𝑖 + 1)) = 𝐴𝑦̃3 (𝑖 + 1) + 𝐵(𝑡𝑖 + ∆𝑡)

𝑆𝑖,1 + 2𝑆𝑖,2 + 2𝑆𝑖,3 + 𝑆𝑖,4


𝑄𝑖 =
6

𝑦(𝑖 + 1) = 𝑦(𝑖) + 𝑄𝑖

31
Example 3.1

Plot the response of 3𝑥̈ + 𝑥̇ + 2𝑥 = 0 subject to the initial conditions 𝑥(0) = 0 ,


𝑥̇ (0) = 0.25 over the time interval 0 ≤ 𝑡 ≤ 20 sec by using 4th order Runge-Kutta
method.

Solution

The first step is to write the equation of motion in first-order form:

3𝑥̈ + 𝑥̇ + 2𝑥 = 0

1 2
𝑥̈ = − 𝑥̇ − 𝑥
3 3

Let
𝑦1 = 𝑥(𝑡) 𝑎𝑛𝑑 𝑦2 = 𝑥̇ (𝑡)

Hence
𝑦̇ 1 = 𝑦2 = 𝑥̇

1 2
𝑦̇ 2 = 𝑥̈ = − 𝑥̇ − 𝑥
3 3

𝑦̇ 1 = 𝑦2 = 𝑥̇

1 2 (28)
𝑦̇ 2 = 𝑥̈ = − 𝑥̇ − 𝑥
3 3

𝑦̇ 𝑥̇ 𝑦1 𝑥
𝑦̇ = [ 1 ] = [ ] 𝑦 = [𝑦 ] = [ ]
𝑦̇ 2 𝑥̈ 2 𝑥̇

In matrix form:

0 1 𝑦
𝑦̇ 1 2 1] [ 1 ] + [0]
[ ]=[ 𝑦2
𝑦̇ 2 − − 0
3 3

Eq. 28 can be written as


𝑦̇ = 𝐴𝑦 + 𝐵(𝑡)

𝑦1 (0) 𝑥(0) 𝑥𝑜 0
𝑦(0) = [ ]=[ ] = [𝑣 ] = [ ]
𝑦2 (0) 𝑥̇ (0) 𝑜 0.25

32
where
0 1
𝐴=[ 2 1] , 𝐵 = [0]
− − 0
3 3

Numerical iterations:
Assume ∆𝑡 = 0.01

For 𝑖 = 0:
𝑡1 = 𝑡0 + ∆𝑡 = 0 + 0.01 = 0.01

𝑆𝑖,1 = ∆𝑡 × 𝑓(𝑡0 , 𝑦(0)) = ∆𝑡 × 𝑓(0, 𝑦(0))

𝑓(0, 𝑦(0)) = 𝐴𝑦(0) + 𝐵(0)

0 1
𝑓(0, 𝑦(0)) = [ 2 1] 𝑦(0) + [0]
− − 0
3 3

𝑦 (0) 𝑥𝑜 0
𝑦(0) = [ 1 ] = [𝑣 ] = [ ]
𝑦2 (0) 𝑜 0.25

0 1
𝑓(0, 𝑦(0)) = [ 2 1] [ 0 ] + [0]
− − 0.25 0
3 3

0.25
𝑓(0, 𝑦(0)) = [ ]
−0.083

0.25 0.0025
𝑆𝑖,1 = ∆𝑡 × 𝑓(0, 𝑦(0)) = 0.01 × [ ]=[ ]
−0.083 −0.00083

𝑆𝑖,1 ∆𝑡 × 𝑓(0, 𝑦(0)) 0 1 0.0025


𝑦̃1 (1) = 𝑦(0) + = 𝑦(0) + =[ ]+ ×[ ]
2 2 0.25 2 −0.00083

0.00125
𝑦̃1 (1) = [ ]
0.24958

𝑆𝑖,2 = ∆𝑡 × 𝑓(𝑡𝑜 + ∆𝑡⁄2 , 𝑦̃1 (1)) = ∆𝑡 × 𝑓(0 + 0.01⁄2 , 𝑦̃1 (1))

𝑆𝑖,2 = ∆𝑡 × 𝑓(0.005, 𝑦̃1 (1))

𝑓(0.005, 𝑦̃1 (1)) = 𝐴𝑦̃1 (1) + 𝐵(0.005)

0 1
𝑓(0.005, 𝑦̃1 (1)) = [ 2 1] 𝑦̃1 (1) + + [0]
− − 0
3 3

33
0 1
𝑓(0.005, 𝑦̃1 (1)) = [ 2 1] [0.00125] + [0]
− − 0.24958 0
3 3

0.24958
𝑓(0.005, 𝑦̃1 (1)) = [ ]
−0.084

0.0024958
𝑆𝑖,2 = ∆𝑡 × 𝑓(0.005, 𝑦̃1 (1))=[ ]
−0.00084

𝑆𝑖,2 ∆𝑡 × 𝑓(0.005, 𝑦̃1 (1)) 0 1 0.0024958


𝑦̃2 (1) = 𝑦(0) + = 𝑦(0) + =[ ]+ ×[ ]
2 2 0.25 2 −0.00084

0.001248
𝑦̃2 (1) = [ ]
0.24958

𝑆𝑖,3 = ∆𝑡 × 𝑓(𝑡𝑜 + ∆𝑡⁄2 , 𝑦̃2 (1)) = ∆𝑡 × 𝑓(0 + 0.01⁄2 , 𝑦̃2 (1))

𝑆𝑖,3 = ∆𝑡 × 𝑓(0.005, 𝑦̃2 (1))

𝑓(0.005, 𝑦̃2 (1)) = 𝐴𝑦̃2 (1) + 𝐵(0.005)

0 1
𝑓(0.005, 𝑦̃1 (1)) = [ 2 1] 𝑦̃2 (1) + + [0]
− − 0
3 3

0 1
𝑓(0.005, 𝑦̃1 (1)) = [ 2 1] [0.001248] + [0]
− − 0.24958 0
3 3

0.24958
𝑓(0.005, 𝑦̃1 (1)) = [ ]
−0.084

0.0024958
𝑆𝑖,3 = ∆𝑡 × 𝑓(0.005, 𝑦̃1 (1))=[ ]
−0.00084

0 0.0024958
𝑦̃3 (1) = 𝑦(0) + 𝑆3 = 𝑦(0) + ∆𝑡 × 𝑓(0.005, 𝑦̃1 (1)) = [ ]+[ ]
0.25 −0.00084

0.0025958
𝑦̃3 (1) = [ ]
0.24916

𝑆𝑖,4 = ∆𝑡 × 𝑓(𝑡𝑜 + ∆𝑡, 𝑦̃3 (1)) = ∆𝑡 × 𝑓(0 + 0.01, 𝑦̃3 (1))

𝑆𝑖,4 = ∆𝑡 × 𝑓(0.01, 𝑦̃3 (1))

𝑓(0.01, 𝑦̃3 (1)) = 𝐴𝑦̃3 (1) + 𝐵(0.01)

34
0 1
𝑓(0.01, 𝑦̃3 (1)) = [ 2 1] 𝑦̃3 (1) + + [0]
− − 0
3 3

0 1
𝑓(0.01, 𝑦̃3 (1)) = [ 2 1] [0.0025958] + [0]
− − 0.24916 0
3 3

0.24916
𝑓(0.01, 𝑦̃3 (1)) = [ ]
−0.0847

0.0024916
𝑆𝑖,4 = ∆𝑡 × 𝑓(0.05, 𝑦̃3 (1))=[ ]
−0.000847

𝑆𝑖,1 + 2𝑆𝑖,2 + 2𝑆𝑖,3 + 𝑆𝑖,4


𝑄1 =
6

0.0025 0.0024958 0.0024958 0.0024916


[ ]+2×[ ]+2×[ ]+[ ]
𝑄1 = −0.00083 −0.00084 −0.00084 −0.000847
6

0.0024958
𝑄1 = [ ]
−0.00084

𝑦(𝑖 + 1) = 𝑦(𝑖) + 𝑄𝑖

𝑦(1) = 𝑦(0) + 𝑄1

0 0.0024958
𝑦(1) = [ ]+[ ]
0.25 −0.00084

0.0024958
𝑦(1) = [ ]
0.24916

The Matlab Code for solving Second order, vibration system ODE of Example 3.1:

Matlab Program 1.13

%Matlab Code for Single Degree of freedom vibratory System


by Using RK4
%Example 3_1
function Ex3_1
clear all; clf; clc;
global m k c
global dt t t_rk

%Inputs
m = 3; % mass (Kg)

35
k = 2; % Stiffness (N/mm)
c = 1; % damping coefficient (N.s/mm)
%initial conditions
xo=0; % initial displacement (mm)
vo=0.25; % initial velocity (mm/s)
% time
tf = 20; %(sec)
dt = 0.01; %(sec)
xstate = [xo; vo]; %(mm; mm/sec)
for i=1:tf/dt
t = dt*i;
xstate = RK(xstate);
%results
z(i) = xstate(1); % Displacement(mm)
q(i) = xstate(2); % Velocity(mm/sec)
end
% Calculating Exact Solution
C= c^2-4*m*k;
% Overdamped System C^2>4mk
if C>0
p1= (-c+sqrt(c^2-4*m*k))/(2*m);
p2= (-c-sqrt(c^2-4*m*k))/(2*m);
A1=(xo*p2-vo)/(p2-p1);
A2=(vo-xo*p1)/(p2-p1);
for i=1:tf/dt+1
t1(i)=(i-1)*dt;
x_exact(i)=A1*exp(p1*t1(i))+A2*exp(p2*t1(i));
end
end
% Critically damped System C^2=4mk
if C==0
p1_1= (-c/(2*m));
c1=xo;
c2=vo-xo*p1_1;
for i=1:tf/dt1
t1(i)=(i-1)*dt;
x_exact(i)=(c1+c2*t1(i))*exp(p1_1*t1(i));
end
end
% Undrdamped System C^2<4mk
if C<0
alpha= (-c)/(2*m);
beta= (sqrt(4*m*k-c^2))/(2*m);
X=sqrt(xo^2+((vo-alpha*xo)/beta)^2);
phi=atand((beta*xo)/(vo-alpha*xo));
for i=1:tf/dt+1
t1(i)=(i-1)*dt;
x_exact(i)=X*exp(alpha*t1(i))*sin(beta*t1(i)+phi*pi/180);

36
end
end
%plotting
plot(0:dt:tf,[xo,z],'linewidth', 2);
hold on
plot(t1,x_exact,'r:','linewidth', 2);
xlabel('Time (sec)','FontSize',12); ylabel('Displacement
(mm/sec)','FontSize',12);
title(' Transient Response','FontSize',15)
legend('Numerical', 'Exact','location', 'best')
grid on
saveas(gcf, 'Example 3_1.tiff');
figure(2)
plot(0:dt:tf,[xo,z],'linewidth', 2);
hold on
plot(0:dt:tf,[vo,q],'r:','linewidth', 2); xlabel('Time
(sec)','FontSize',12);
title(' Transient Response','FontSize',15)
legend('Displacement', 'Velocity','location', 'best')
grid on
saveas(gcf, 'Example 3_1_velocity.tiff');
function xstate= RK(xstate)
global dt t t_rk
t_rk=(t-dt);
S1 = dt * x_dot( xstate );
t_rk=(t-dt)+dt/2;
S2 = dt * x_dot( xstate + S1/2);
t_rk=(t-dt)+dt/2;
S3 = dt * x_dot( xstate + S2/2);
t_rk=(t-dt)+dt;
S4 = dt * x_dot( xstate + S3 );
Q=1/6 *(S1 + 2*S2 + 2*S3 + S4);
xstate = xstate + Q;
function xdot=x_dot(X)
global m k c
% forcing function
F_t= force;
A=[0, 1; -k/m, -c/m];
b=[0; F_t/m];
xdot = A*X+b;
function F_of_t =force
global t_rk
F_of_t=0;
% F_of_t=240000*t_rk;

37
The time response is plotted in Fig. 1.13.

Fig. 1.13. Time response of example 3.1.

It was shown in example 1.5 that the exact solution of this differential equation is
𝑡
𝑥(𝑡) = 0.31𝑒 −6 sin (0.79𝑡)

9. Enhancements to Runge-Kutta integration method

Runge-Kutta method can be enhanced by treating the time step ∆𝑡 as a variable, ∆𝑡𝑖 .
At each time 𝑡𝑖 , the value of ∆𝑡𝑖 is adjusted based on how rapidly the solution of 𝑥(𝑡)is
changing. If the solution is not changing very rapidly, a large value of ∆𝑡𝑖 is allowed
without increasing the formula error. On the other hand, if 𝑥(𝑡)is changing rapidly, a
small ∆𝑡𝑖 must be chosen to keep the formula error small. Such step sizes can be
chosen automatically as part of the computer code for implementing the numerical
solution.
Matlab has two different Runge-Kutta based simulations: ode23 and ode45. These
are automatic step-size integration methods (i.e., ∆𝑡 is chosen automatically).

Example 3.1 can be solved by using ode45 function in matlab as follows

Matlab Program 1.14

Create and save the following code as sdof.m

% function Ex_3_1_ODE45
function xdot=sdof(t,x)

38
m = 3; % mass (Kg)
k = 2; % Stiffness (N/mm)
c = 1; % damping coefficient (N.s/mm)
xdot=zeros(2,1);
xdot(1)=x(2);
xdot(2)=(-k/m)*x(1)+(-c/m)*x(2);

In the same directory as sdof.m, create a new m-file as follows:

% Program to solve 1 DOF vibration system by using RK-4


clear all; clf; clc;
to=0;
tf=20;
xo=[0 0.25];
[t,x]=ode45('sdof', [to tf], xo);
plot(t,x(:,1),'linewidth', 2); xlabel('Time
(sec)','FontSize',12);
hold on
plot(t,x(:,2),'r:','linewidth', 2); xlabel('Time
(sec)','FontSize',12);
title(' Transient Response','FontSize',15)
legend('Displacement', 'Velocity','location', 'best')
grid on
saveas(gcf, 'Example 3_1_ODE45.tiff');

The time response by using ODE45 function is shown in Fig. 1.14.

Fig. 1.14. Time response of example 3.1 by using ode45 Matlab function.

39
Stability of the Vibration Equation
1. Introduction

The differential equations that govern the vibration system is given by:

𝑚𝑥̈ + 𝑐𝑥̇ + 𝑘𝑥 = 𝑓(𝑡) (1)

It has been shown in the preceding analysis that the solution of the vibration
equations consists of two parts; the complementary solution and the particular
solution. In the theory of vibration, the particular solution depends on the external
excitation. In the special case of free vibration, one has to determine only the
complementary solution which contains two arbitrary constants that can be
determined from the initial conditions. As was shown in chapter 2, the
complementary solution depends n the roots of the characteristic equations. These
roots depend on the coefficients of the displacement and its time derivatives in the
differential equation. Consequently, these coefficients, which represent inertia,
damping, and stiffness coefficients, affect the form of the complementary function and
the complete solution of the vibration problem. The stability of the system depends
on the roots of the characteristic equations, 𝑝1 and 𝑝2 . In terms of these roots, the
general form of the complementary solution is given by

𝑥(𝑡) = 𝐴𝑒 𝑝𝑡 (2)

If we substitute with Eq. 2 in Eq. 1 we will get the following characteristic equation

𝑚𝑝2 + 𝑐𝑝 + 𝑘 = 0 (3)
By solving Eq. (3) we will get
−𝑐 + √𝑐 2 − 4𝑚𝑘
𝑝1 = (4)
2𝑚
−𝑐 − √𝑐 2 − 4𝑚𝑘
𝑝2 = (5)
2𝑚
The general solution of the differential equation, provided that the roots of the
differential equation are not equal, can be written as

𝑥(𝑡) = 𝐴1 𝑒 𝑝1𝑡 + 𝐴2 𝑒 𝑝2𝑡 (6)

where 𝐴1 and 𝐴2 are arbitrary constants and 𝑝1 and 𝑝2 are the roots of the
characteristic equation. In the following, we examine the effect of the roots on the
stability of the system.

Negative Real Roots

40
If both the roots 𝑝1and 𝑝2 are real and negative, the solution 𝑥(𝑡) approaches zero as
time 𝑡 becomes large. In this case, the solution is bounded and nonoscillatory. The
rate at which the solution decreases as time increases depends on the magnitude of
the roots p𝑝1and 𝑝2 . It is quite usual to use the complex plane to examine the stability
of the system as shown in Fig. 4.1, in the case of the negative real roots, the roots of
the characteristic equations 𝑝1and 𝑝2 lie on the negative portion of the real axis. The
system can be more stable by increasing the magnitude of the negative roots. This, of
course, can be achieved by changing the inertia, damping, and/or stiffness parameter
of the system.

More staple

p1 p2

Fig. 4.1. Time response of a stable system with negative real roots.

Positive Real Roots

If one of the roots or both become positive, the solution is non oscillatory and grows
without bond as time increases; an increase with time depends on the magnitude of
the positive roots. As the root magnitude increases, the solution grows more rapidly.
This behavior happens, because of the exponential form of the solution. Different
combinations that lead to instability are shown in the complex plane shown in Fig.
4.2.

Complex Roots

In this case, the roots 𝑝1and 𝑝2 appear as a complex conjugates which can be written
as
𝑝1 = 𝛼 + 𝑖𝛽 (7)

𝑝2 = 𝛼 − 𝑖𝛽 (8)

41
p1 p2

p1 p2 p2 p1

Fig. 4.2. Time response of a unstable system with one or two positive real roots.

Therefore, the solution in this case is oscillatory and can be expressed as

𝑥(𝑡) = 𝑋𝑒 𝛼𝑡 sin (𝛽𝑡 + 𝜙) (9)

where 𝑋 and 𝜙 are arbitrary constants which can be determined from the initial
conditions. As shown in the examples presented in the preceding sections, there are
3 possibilities which may be encountered. First, the real part of the root 𝛼 is negative.
In this case, the roots 𝑝1and 𝑝2 are located in the left-hand side o the complex plane,
as shown in Fig. 4.3. As shown in Fig. 4.3, the solution of the vibration equation is
oscillatory and bounded, with an amplitude which decreases with time. The
frequency of the oscillation depends on 𝛽 while the rate of the decay depends on the
magnitude of the real part 𝛼. This is the case of stable system.
The second possibility occurs when the real part 𝛼 is identically zero. In this case, the
roots 𝑝1and 𝑝2 consist of only imaginary parts, as shown n Fig. 4.4. In this case, the
solution is a harmonic oscillation which has a frequency equal to 𝛽, as shown in Fig.
4.4. In this case, the system is called critically stable since the solution is bounded, but
the amplitude does not increase or decrease as time 𝑡 increases.

42
p1

p2

Fig. 4.3. Time response of a stable system with complex roots.

p1

p2

Fig. 4.3. Time response of a critically stable system with complex roots.

p1

p2

Fig. 4.4. Time response of an unstable system with complex roots.

43
The third possibility occurs when the real part 𝛼 is positive. In this case, the roots
𝑝1and 𝑝2 are located in the right-hand side of the complex plane, as shown in Fig. 4.5.
The solution, in this case, is a product of an exponential function which grows with
time and a harmonic function which has a constant amplitude. The result is an
oscillatory motion with an amplitude that increases as time increases, as shown in
Fig. 4.5, this is the case of unstable system.
It is clear from the analysis presented in this section, that the stability of motion is
achieved if the roots 𝑝1and 𝑝2 of the characteristic equations lie in the right-hand side
of the complex plane. If any of the roots lie in the right-hand side of the complex plane,
the system becomes unstable. Furthermore, the degree of stability or instability
depends on the magnitude of the roots. The location of the roots of the characteristic
equations can be altered by changing the physical parameters of the system, such as
the inertia, damping, and stiffness coefficients.

44

You might also like