Note Modeling Simulation

9
 Lecture Notes of ME 862 Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 1  Modeling and Simulation of Dynamic Systems

Transcript of Note Modeling Simulation

Page 1: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 1/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 1

 

Modeling and Simulation

of Dynamic Systems

Page 2: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 2/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 2

1. Modeling of Dynamic System

A model of a system can be physical or mathematical. The model accuracy needed

(closeness to the actual system) depends on the purpose. Generally, a simplified model is

needed to study the main characteristics of the system. A detailed model is needed for

accurate simulation and prediction studies. In this class, modeling refers to themathematical model of a system. The mathematical model of a dynamic system is

generally in the form of differential equations. Therefore, modeling of dynamic system

refers to the use of the physical laws to set up differential equations for a given dynamic

system. Once we have the model of the system, we are interested in studying its behavior.

The behavior of a dynamic system in time is described by the solution of its differential

equations.

There two different purposes for modeling of a physical system.

•  Develop a mathematical model in order to predict the dynamic behavior of the system

as accurately as possible, using numerical methods. Such a model serves as a tool for

extensive evaluation of system behavior without actually using or building the actualsystem.

•  Develop model to gain insight into the dynamic behavior qualitatively instead of

exact response prediction, i.e., knowledge of stability margin, controllability and

observability of states, and sensitivity of response to parameter changes. Such models

do not contain all the detail of an actual system, but only the most essential features

so as to provide good insight from an engineering standpoint.

Therefore, we may develop simplified linear models for controller design and analysis

 purposes, and use more detailed, possibly nonlinear, models in testing and predicting the

dynamic system response as accurately as possible. For instance, consider the robotic

manipulator schematically shown in Figure 1. The

dynamic model is a set of differential equations

which describe the relationship between the

applied torques at the joints and motion of the

 joint angles in time. The set of nonlinear

differential equations can be used to predict the

 behavior of the robotic manipulator under various

initial conditions and joint torque inputs.

Quite often, the dynamics models of physical

systems are nonlinear. Most control system

design methods and analytical methods are

applicable only to linear systems. Therefore, for

the sake of being able to analyze various

controller alternatives, we need to obtain

approximate linearized modes from the nonlinear

models.

Figure 1: Robotic manipulator model

Page 3: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 3/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 3

2. Differential Equations

2.1 Basics of Differential Equations

Continuous time dynamic systems are described by differential equations. A differential

equation is an equation involving derivatives of dependent variables with respect toindependent variables, for example,

)()()(

t ut aydt 

t dy=+  

where t  is an independent variable, y is a dependent variable (e.g. the system output), and

u is another dependent variable (e.g., the system input). If there is only one independent

variable, then the differential equation is called an ordinary differential equation (ODE).

If there are two or more independent variables, then it is called a partial differential

equation (PDE).

The highest derivative in the equation is the order of the equation. Solution of an nth-

order differential equation contains n-arbitrary constants. These constants are determined

 by n-conditions on dependent variable (i.e., the initial conditions)

2.2 Nonlinearities and Linearization

If the dependent variables or their derivatives appear in nonlinear functions in the

equations, then the differential equation is nonlinear ; otherwise it is linear . For example,

the following equation is nonlinear

)()()()(

2

2

2

t ut aydt 

t dy

dt 

t dy=+⎟

 ⎠

 ⎞⎜⎝ 

⎛ +  

A system is called a linear dynamic system if its dynamics is described by linear

differential equation(s). A linear system possesses two properties: superposition and

Homogeneity. The property of superposition means the output response of a system to

the sum of inputs is the sum of the responses to the individual inputs. Thus, if an input of

r 1(t ) yields an output of c1(t ) and an input of r 2(t ) yields an output of c2(t ), then an input

of r 1(t )+r 2(t ) will yield an output of c1(t )+c2(t ). The property of homogeneity describes

the response of the system to a multiplication of the input by a scalar. Specifically, in a

linear system, the property of homogeneity is demonstrated if for an input of r (t ) that

yields an output of c(t ), an input of Kr (t ) will yield an output of Kc(t ). In other words, the

multiplication of an input by a scalar (i.e., K ) yields a response that is multiplied by the

same scalar.

Quite Often, a designer needs to make a linear approximation to a nonlinear system.

Linear approximations simplify the analysis and design of a system and are used as long

Page 4: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 4/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 4

as the results yield a good approximation to reality. For example, if a system consists of

nonlinear components, we must linearize the system before we can find its transfer

function. Now, let’s see how to linearize a nonlinear system in order to obtain its transfer

function.

The first step is to write the nonlinear differential equation and linearize it. When welinearize a nonlinear differential equation, we linearize it for small changes in the input

about the operating point A, as shown in Figure 2, where the system input and the output

are x0 and f ( x0), respectively. Small changes in the input can be related to changes in the

output about the point by way of the slope of the curve at the point A. Thus, if the slope

of the curve at pint A is ma, then small excursions of the

input about pint A, δ   x, yield small changes in the output,

δ   f ( x), related the slope at point A. Thus,

)()()()( 00   x xm x f  x f  x f  a   −=−=δ    

where

0

)(

 x x

adx

 xdf m

=

=  

Figure 2: Linearization about the operating point A.

Once we have the linearized differential equation, next we take the Laplace transform of

the equation(s), assuming zero initial conditions. Finally, we separate input and output

variables and form the transfer function.

Example 1

(a) Write the differential equation for the simple pendulum shown in the following

figure, where all the mass is concentrated at the endpoint.

(b) Linearize the system about the operating point of θ  =0 and then find its transfer

function.

(c) Use SIMULINK to determine the time response of θ   to a step input T c of 1 N⋅m.

Assume l =1 m, m = 0.5 kg, and g = 9.81 m/s2.

Page 5: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 5/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 5

Example 2

Find the transfer function, V  L(s)/ V (s), for the electrical network shown in the following

figure, which contains a nonlinear resistor whose voltage-current relationship is defined

 by r v

r    ei1.0

2= , where ir  and vr  are the resistor current and voltage, respectively. Also, it is

know that v(t ) is a small-signal source. Use SIMULINK to determine the time responseof v L(t ) to a step input v(t ) of 0.1 V.

Page 6: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 6/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 6

3.  Numerical Simulation of Nonlinear Dynamic

Systems 

The behavior of a dynamic system in the time domain can be predicted by the solution of

its mathematical model, which typically is a set of ordinary differential equations(ODEs). Analytical solution of ODEs is available for only linear ODEs and very simple

nonlinear ODEs. Therefore, time domain response of any dynamic system model with

reasonable complexity must be solved using numerical methods. The primary tool is the

numerical integration of ODEs in the time domain. Numerical integration is performed

 by discretizing ODEs using various approximations to differentiation.

3.1 Basics for Solving a First-Order ODE

Given that a dynamic system is describe by the following first-order ODE

),(   u y f  y =&

 

The task at hand is to solve for  y(t ) given the initial condition 00 )(   yt  y   =  and the input

u(t ). The fundamental idea behind numerical integration is illustrated in Figure 3, in

which

∫  +

+=+

1

)()( 1

i

i

t ii   dt  yt  yt  y   &  

where ∫  +1i

i

t dt  y& can be obtained by using various approximations, such as the Euler’s and

Runge-Kutta methods introduced in the following.

Figure 3: Graphical interpretation of numerical integration for solving a first-order ODE.

∫t 

d  y0

τ &  

&  

&  

&

Page 7: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 7/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 7

3.2 Euler’s Method and Runge-Kutta Methods

Euler’s method is based on the definition of a derivative, i.e.,

t  y

dt dy

t    ΔΔ=

→Δlim

0

 

Let us examine the differential equation for two values of time, t i  and t i+1, where Δt   is

sufficiently close to zero that the above equation is approximated by

),(1ii

ii u y f t 

 y y=

Δ

−+  

which can be rewritten as

) ,(1   iiii   u ytf  y y   Δ+=+  

Repeated evaluation of the above equation leads to the numerical solution. As the initial

 point, 0 y yi  =  and, for subsequent values of the index i+1,  yi+1 takes on the value from

the previous calculation of  yi. Any arbitrary time history of the input ui  can be used:

steps, ramps, sinusoids, random sequences, or stock market indices. As the step size Δt  

decreases, the accuracy of the method improves and the required computation time

increases.

Figure 3 suggests that a more accurate formula is to use the average of the values of the

derivative at t i and t i+1. Because this is essentially a straight line approximation to the  y&  curve between t i and t i+1, it is called the trapezoidal rule. Unfortunately, it is impossible

to implement for numerical integration of nonlinear system because the derivative at t i+1 

depends on y(t i+1), which is not known yet. Many different numerical integration schemes

have been developed to approximate the area under the curve; and they are all iterative

 because the derivative at the endpoint is not initially known.

Runge-Kutta methods  comprise one popular set of integration schemes. The second-

order Runge-Kutta method obtains an approximate value of the endpoint using the Euler

method, estimates the derivative at the endpoint using the approximate  yi+1, and then

arrives at the final value for yi+1 using an average of the two derivatives:

)(2

) t,(

) ,(

211

112

1

k k t 

 y y

uk  y f k 

u y f k 

ii

ii

ii

+=

Δ+=

=

+

+  

Page 8: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 8/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 8

Third- and higher-order Runge-Kutta methods use this same basic idea; they differ from

the second-order formula by using estimates of derivatives at mid-points as well as

endpoints and including them in a weighted average to arrive at the final estimate of yi+1.

Most computer-aided control system design software includes some form of numerical

integration capability such as Runge-Kutta method and most will include some sort ofautomatic step size determination. Any method will be become more accurate as the step

size decrease: however, initially, neither the computer algorithms nor the user knows

what step size is the best compromise between accuracy and speed. A commonly used

scheme is to integrate using two different methods (perhaps a second- and third-order

Rung-Kutta formula), compare the difference, and then cut the step size in half if the

error exceeds a certain tolerance. The step size will continue to be cut in half until the

error tolerance is met.

3.3 Simulation of Nonlinear Dynamic Systems Using SIMULINK

In SIMULINK, we use a block, called  Integrator , for continuous-time integration of its

input signal, i.e., ∫Δ

=t 

inout    dt S S 0

, where Δt  is the step size (specified in the Solver options 

in SIMULINK). The initial condition of integration can be specified via the Function

 Block Parameters window of the block.

Figure 4: Integrator in SIMULINK.

Suppose a dynamic system is describe by the following n-order ODE

),,,,()2()1()(

u y y y f  y  nnn

L−−=  

with initial conditions:

)1(

00

)1( )(   −− =   nn  yt  y ,)2(

00

)2( )(   −− =   nn  yt  y , …, 00 )(   yt  y   = .

The general process to solve the above ODE by means of SIMULINK is discussed in

class.

s

1   S out  S in 

Page 9: Note Modeling Simulation

8/13/2019 Note Modeling Simulation

http://slidepdf.com/reader/full/note-modeling-simulation 9/9

 Lecture Notes of ME 862

Department of Mechanical Engineering, University Of Saskatchewan, 57 Campus Drive, Saskatoon, SK S7N 5A9, Canada 9

Example 3

Use SIMULINK to determine the time response of θ   to a step input of 1 N⋅m of the

 pendulum in Example 1 based on the nonlinear differential equation obtained; and then

compare it to the result from the transfer function after linearization.

Example 4

Consider the liquid level in a tank and its control system shown in the following figure.

The purpose of control is to maintain the liquid height in the tank at a constant level.

Let us consider a computer-controlled version of the system: the mechanism for

manipulating the inflow rate to the tank is controlled by a level sensor, a digital

controller, and a valve. The digital controller is an ON/OFF type one with hysteresis: the

controller either fully turns ON or OFF the value, depending the error signal to the

controller; and the hysteresis is added to the controller in order to make sure the

controller does not switch the valve ON/OFF at high frequency due to small change inthe liquid level. This type of controller is called relay with hysteresis. The inflow rate is

 proportional to the valve opening.

Manipulated by the aforementioned ON/OFF controller, the flow rate has the value of

either zero or maximum. The outflow rate is proportional to the liquid level in the tank by

multiplying a constant of 1/ R. Simulate the system for the following conditions: (1) the

hysteresis band of the controller is [-0.05, 0.05], (2) the maximum inflow rate is 0.02

m3/s, (3) R has a value of 500 m/( m

3/s), and (4) the cross-section area of the tank is 0.01

m2.