Activity 2: Mathematical Modeling of Physical System

advertisement
Name:
EE 179.1 Section:
Course and Year:
Laboratory Schedule:
Activity 2: Mathematical Modeling of Physical Systems
Abstract
<100-300 words well-chosen words>
1
Objectives
 To grasp the important role of mathematical models of physical systems in the design
and analysis of control systems.
 To learn how Scilab helps in solving such models.
2
List of equipment/software
 Personal Computer
 Scilab
3
Deliverables
 Scilab scripts and their results for all the assignments and exercises properly discussed
and explained.
 Analytical conclusion for this lab activity.
4
Modeling Physical Systems
4.1
Mass-Spring System Model
Consider the following Mass -Spring system shown in Figure 1 where K is the spring force, fv is
the friction coefficient, x(t) is the displacement and f(t) is the applied force:
Figure 1. Mass-Spring System and its Free-Body Diagram
Name:
EE 179.1 Section:
Course and Year:
Laboratory Schedule:
Referring to the free-body diagram, we get
𝑀
𝑑2 𝑥(𝑡)
𝑑𝑡 2
+ 𝑓𝑣
𝑑𝑥(𝑡)
𝑑𝑡
+ 𝐾𝑥(𝑡) = 𝑓(𝑡) . (1)
The second order linear differential equation (1) describes the relationship between the
displacement and the applied force. The differential equation can then be used to study the
time behavior of x(t) under various changes of the applied force.
The objectives behind modeling the mass-damper system can be many and may include:

Understanding the dynamics of such system.

Studying the effect of each parameter on the system such as mass M, the friction
coefficient B, and the elastic characteristic Kx(t).

Designing a new component such as damper or spring.

Reproducing a problem in order to suggest a solution.
4.2
Using Scilab in Solving Ordinary Differential Equations
Scilab can help solve linear or nonlinear ordinary differential equations (ODE) usging ode tool.
To show how you can solve ODE using Scilab, we will proceed in two ways. We first see how we
can solve a first order ODE and then see how we can solve a second order ODE.
4. 3
First Order ODE: Speed Cruise Control Example
Assume a zero spring force which means that K = 0. Equation (1) becomes
𝑀
𝑑2 𝑥(𝑡)
𝑑𝑡 2
+ 𝑓𝑣
𝑑𝑥(𝑡)
𝑑𝑡
= 𝑓(𝑡)
(2)
or
𝑀
𝑑𝑣(𝑡)
𝑑𝑡
+ 𝑓𝑣 𝑣(𝑡) = 𝑓(𝑡)
since
𝑎(𝑡) =
𝑑𝑣(𝑡)
𝑑𝑡
=
𝑑2 𝑥(𝑡)
𝑑𝑡 2
,
(3)
Name:
EE 179.1 Section:
and
Course and Year:
Laboratory Schedule:
𝑣(𝑡) =
𝑑𝑥(𝑡)
𝑑𝑡
.
Equation (3) is a first order linear ODE and we can use Scilab to solve for this differential
equation.
We can model and solve for equation (3) by writing the following script in Scilab. You can also
input the codes directly into the Scilab Console.
Code:
//declare constant values
M = 750
B = 30
Fa = 300
//the force f(t)
//differential equation definition
function dvdt = f(t,v)
dvdt = (Fa-B*v)/M;
endfunction
//initial conditions @ t=0, v=0
t0 = 0
v0 = 0
t = 0:0.1:5;
v = ode(v0, t0, t, f);
clf;
plot2d(t, v)
//read references for ode tool
Name:
EE 179.1 Section:
4. 4
Course and Year:
Laboratory Schedule:
Second Order ODE: Mass-Spring System Example
In reality, the spring force and/or friction force can have a more complicated expression or
could be represented by a graph or data table. For instance, a nonlinear spring can be designed
such that the elastic characteristic is
𝐾𝑥 𝑟 (𝑡)
where r > 1. Figure 2 is an example of a nonlinear spring.
Figure 2. Nonlinear Spring[1]
In such case, equation (1) becomes
𝑀
𝑑2 𝑥(𝑡)
𝑑𝑡 2
+ 𝑓𝑣
𝑑𝑥(𝑡)
𝑑𝑡
+ 𝐾𝑥 𝑟 (𝑡) = 𝑓(𝑡) (4)
Equation (3) represents another possible model that describes the dynamic behavior of the
mass-damper system under external force. Unlike equation (1), this is said to be a nonlinear
differential equation.
We can also solve equation (3) using Scilab ode tool but this time, the second order differential
equation has to be decomposed in a set of first order differential equations as follows:
Let 𝑥(𝑡) = 𝑋1 ,
so
𝑑𝑋2
𝑑𝑡
so
𝑓
𝐾
𝑑𝑋1
𝑑𝑡
= 𝑋2
= − 𝑀𝑣 𝑋2 − 𝑀 𝑋1 𝑟 +
𝑓(𝑡)
𝑀
.
and
𝑑𝑥(𝑡)
𝑑𝑡
= 𝑋2,
Name:
EE 179.1 Section:
In vector form, let
Course and Year:
Laboratory Schedule:
𝑋
𝑥
𝑋 = [ 1] = [ ′] ;
𝑥
𝑋2
𝑑𝑋1
𝑑𝑋
𝑑𝑡
𝑑𝑡
= [𝑑𝑋
] = [ 𝑥′ ]
2
𝑥′′
𝑑𝑡
so we get
𝑑𝑋
𝑑𝑡
𝑋2
= [ 𝑓𝑣
𝐾
𝑓(𝑡)] .
− 𝑀 𝑋2 − 𝑀 𝑋1 𝑟 + 𝑀
The Scilab ode tool can now be used:
Code:
//declare constant values
M = 750
B = 30
Fa = 300
//the force f(t)
K = 15
r = 1
//differential equation definition
function xprime = f(t,x)
xprime(1) = x(2);
xprime(2) = -(B/M)*x(2)-(K/M)*((x(1))^r)+(Fa/M);
endfunction
t0 = 0
t = 0:0.1:5;
x0 = 0; //set initial position
xprime0 = 0; //set initial velocity
x = ode([x0; xprime0], t0, t, f);
clf;
plot2d(t, x(1,:))
// “x(1,:)” plots the position vs time
// “x(n, :)” to plot a solution in matrix
form
// with dimension n x T
Name:
EE 179.1 Section:
5
5.1
Course and Year:
Laboratory Schedule:
Assessment
Assignment
1. Show and discuss the graphs obtained from the sample simulations.
Name:
EE 179.1 Section:
5.2
Course and Year:
Laboratory Schedule:
Exercise 1
Referring to the mass-spring system example:
1. Plot the position and the speed of the system both with respect to time in separate
graphs.
2. Change the value of r to 2 and 3. Plot the position and speed both with respect to time.
Discuss the results.
3. With r = 1, vary the value of K (multiply by 5 and 10) and discuss the results.
Name:
EE 179.1 Section:
5.3
Course and Year:
Laboratory Schedule:
Exercise 2
Consider the mechanical system depicted in the
figure. The input is given by f(t), and the output is
given by y(t). Determine the differential equation
governing the system and using Scilab, write a
script and plot the system response such that
forcing function f(t) = 1. Let m = 10, k = 1, and b =
0.5.
a. The peak displacement of the block is about ____.
b. At time t = ____, the output reaches peak displacement.
c. If k = 10, the peak value of y is ____.
d. What happens to the system when b is changed?
Name:
EE 179.1 Section:
Course and Year:
Laboratory Schedule:
6 References
CISE 302 Linear Control Systems Laboratory Manual. (2011, October). Systems Engineering
Department, King Fahd University of Petroleum & Minerals.
Scilab Enterprises . (2013). Scilab for very beginners. 78000 Versailles, France.
Sengupta, A. (15, April 2010). Introduction to ODEs in Scilab. Indian Institute of Technology
Bombay.
Download