Modeling and Simulation
Modeling and Simulation
Objectives:
The objectives of this application are to:
1. Convert the functions from time domain to Laplace domain (s).
2. Obtain the time domain function from the complex variable
domain (s).
3. Solve the linear ordinary differential equations, and obtain the
output response.
4.Derive the mathematical model of mechanical, electrical, and
fluid control systems.
5.Simulate the derived mathematical model using MATLAB
Simulink.
Introduction:
To understand and control complex systems, one must obtain
quantitative mathematical models of these systems. It is
necessary therefore to analyze the relationships between the
system variables and to obtain a mathematical model. Because
the systems under consideration are dynamic in nature, the
descriptive equations are usually differential equations.
Furthermore. If these equations can be linearized, then the
Laplace transform can be used to simplify the method of solution.
Laplace Transform:
Where:
0
1
------
s
>> % 2. To determine the Laplace transform for unit ramp function %
>> syms t
>> ft=t;
>> Fs=laplace(ft);
>> pretty(Fs)
1
------
s2
s
----------
s2 + w2
2. f ( t )=( t +1 )2 +7 u ( t ) .
Solution:
>> % 1. To find the Laplace transform of f(t)= 5 exp(-2t) cos(5t) %
>> syms t
>> ft=5*exp(-2*t)*cos(5*t);
>> Fs=laplace(ft);
>> pretty(Fs)
5 (s + 2)
------------------
(s + 2)2 + 25
2 (4 s2 + s + 1)
----------------------
s3
F ( s )=F1 ( s ) + F 2 ( s ) +…+ F N ( s )
f ( t )=L
−1
[ F 1 ( s ) ] + L−1 [ F2 ( s ) ] +…+ L−1 [ F N ( s ) ]
f ( t )=f 1 ( t ) + f 2 ( t ) +…+ f N ( t )
Solution:
0
k=
[]
>> % To find the inverse Laplace transform …%
>> syms s
>> Ys=1.33/(s+3)-2/(s+2)+0.6667/s;
>> yt=ilaplace(Ys)
yt =
1.33 * exp(-3t) - 2 * exp(-2t) +0.6667
-4.0000
-4.0000
k=
[]
1
1. Y ( s )=
( s+ 1 ) ( s 2+ 4 )
2
s + 6 s+ 8
2. Y ( s )= 2
s + 8 s+ 15
Solution:
>> % To find inverse Laplace transform for: y(s)=1/((s+1)(s^2+4))
directly %
>> syms s
>> Ys=1/((s+1)*(s^2+4));
>> yt=ilaplace(Ys)
yt =
1/5*exp(-t) - cos(2*t)/5 + sin(2*t)/10
>> % To find inverse Laplace transform for…%
>> % y(s)=(s^2+6s+8)/(s^2+8s+15) directly %
>> syms s
>> Ys=(s^2+6*s+8)/(s^2+8*s+15);
>> yt=ilaplace(Ys)
yt =
dirac(t) - 3/2*exp(-5*t) - 1/2*exp(-3*t)
Solution:
>> % 1. To find inverse Laplace transform for: Vo(s)=10/(s(s+10))%
>> syms s;
>> Vs=10/(s*(s+10));
>> vt=ilaplace(Vs)
vt =
1 - exp(-10*t)
0.9
0.8
0.7
Output Vo(Voltage)
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Figure 2.2: Output response of RC Lag network for unit step input.
Time (sec)
(2.1)
v ¿ (t)−v o ( t)
i(t)=
R
(2.2)
1
v o (t)= ∫ i(t)dt
From Equations (2.1) and (2.2), we can obtain the elements of
C
Figure 2.3: (a) Elements of the block diagram of the RC network shown in
Figure 2.1, (b) block diagram of the RC network.
The Simulink diagram of the coupled tank system as shown in
Figure 2.4:
Using MATLAB:
1. Solve the differential equation above to determine x (t ).
2. Plot the output response of the system.
Solution:
>> xt=dsolve('5*D2x+15*Dx+10*x=exp(-3*t)','x(0)=0.5,Dx(0)=3')
xt =
4.1*exp(-t) – 3.7*exp(-2*t) + 0.1*exp(-3*t)
>> plot(t,xt)
>> grid
>> title('The Output Response for f(t)=exp(-3t)')
>> xlabel('Time (sec)')
>> ylabel('Diplacement (Meter)')
1.2
1
Diplacement (Meter)
0.8
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7 8 9 10
Figure 2.6: Output response of spring mass damper system for exponential
Time (sec)
input.
Simulate the system and obtain the output response using MATLAB
Simulink.
Solution:
The simulation of the system using MATLAB Simulink as shown in
Figure 2.8:
1
Diplacement(Meter)
0.5
0
0 1 2 3 4 5 6 7 8 9 10
Time(sec)
Figure 2.9: Step response of the mechanical system for Example 2.7.
From the Figure 2.10, the systems equations at zero initial conditions
are:
m1 x¨1 +b ( x˙1− x˙2 ) +k 1 x 1+ k 2 ( x 1−x 2 ) =u ( t )
m2 x¨2 +b ( x˙2− x˙1 ) +k 3 x 2+ k 2 ( x 2−x1 ) =0
0.01
0.005
Diplacement x1(Meter)
-0.005
-0.01
-0.015
0 5 10 15 20 25 30 35 40 45 50
Time(sec)
(2.3)
h1−h 2
=q1
R1
(2.4)
d h1
C1 =q−q1
dt
(2.5)
h2
=q
R2 2
(2.6)
d h2
C2 =q1−q2
dt
Figure 2.14: (a) Elements of the block diagram of the system shown in
Figure 2.10; (b) block diagram of the system.
1
Outlet flow rate(m3/sec)
0.8
0.6
0.4
0.2
0
0 5 10 15 20 25 30 35 40 45 50
Time(sec)
3. f ( t )=sin 2 t +3 cos2 t
--------------------------------------------------------------------------------------------------
-
Homework 2.2: Use MATLAB to determine the inverse Laplace
transform of the following transfer functions:
−2 s
e
1. Y ( s )= (Directly )
s ( s+ 4 )( s+6 )
4 3 2
2 s +9 s +15 s + s +2
2. Y ( s )= 2 2
(Using ResidueCommand )
s ( s +2 ) ( s+ 1 )
3 2
s + 7 s + 9 s +5
3. Y ( s )= (Using ResidueCommand )
--------------------------------------------------------------------------------------------------
( s +3 ) ( s+ 4)
-
Homework 2.3: A ship has a mass m and resistance c times the
forward velocity u ( t ) . If the thrust from the propeller is k times its
angular velocity ω ( t ) ,where:
d uf
m + c u f (t )=kω(t )
If: m=180 ×10 5 kg , c=150 ×103 N . s /m, k =96 ×10 3 N . s /rad , and ω ( t )=12.5 u ( t ) .
dt
2.5 ( s +2 )
ω ( s )= L (s)
( s+ 5 )( s+1 )2