0% found this document useful (0 votes)
12 views21 pages

Chapter 5

Chapter 5 discusses the simulation of dynamic systems, emphasizing the importance of developing mathematical models and determining system responses through analytical methods or numerical simulations. It introduces MATLAB's Simulink software for creating block diagrams to represent dynamic systems and outlines the basic steps for using it, including selecting input-output blocks and executing simulations. The chapter also covers solvers for dynamic systems, differentiating between fixed-step and variable-step solvers, and continuous versus discrete solvers, providing insights into their applications and effectiveness.

Uploaded by

201230
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)
12 views21 pages

Chapter 5

Chapter 5 discusses the simulation of dynamic systems, emphasizing the importance of developing mathematical models and determining system responses through analytical methods or numerical simulations. It introduces MATLAB's Simulink software for creating block diagrams to represent dynamic systems and outlines the basic steps for using it, including selecting input-output blocks and executing simulations. The chapter also covers solvers for dynamic systems, differentiating between fixed-step and variable-step solvers, and continuous versus discrete solvers, providing insights into their applications and effectiveness.

Uploaded by

201230
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/ 21

Chapter 5

Simulation of Dynamic Systems


This chapter introduces the students with computer simulation of dynamic methods
6.1 Introduction
Developing a mathematical model is always the first step in the analysis and design of
dynamic systems. Determining the system's response to a specific input (i.e., solving
the governing ODEs) is the second step, as the engineer is interested in characteristics
such as response speed, maximum output, and the time to achieve a steady or
constant output.
Once the mathematical model has been developed, the engineer has two options for
determining the system's response: (1) analytical methods or (2) numerical
simulations using a digital computer.
Analytical techniques involve solving the governing ODEs "by hand," which is feasible
for linear, time-invariant (LTI) first- and second-order systems. However, when the
system dynamics involve nonlinear terms, a numerical simulation is likely the only
option for determining the system response. Furthermore, a numerical simulation is
the best option for determining the response of a higher-order, real-world system that
involves the interaction of multiple inputs and outputs.
Simulation is the process of obtaining the system's dynamic response by
numerically solving the governing modeling equations (by using computer); in other
words, numerical integration of the model's differential equations.

In this chapter, we introduce the MATLAB simulation software and present several
examples that illustrate simulating dynamic systems.
6.2 Use of Simulink® in Computer Simulation
Simulink is a numerical simulation tool that is part of the MATLAB software package
developed by MathWorks. It uses a graphical user interface (GUI) to develop a block
diagram representation of dynamic systems.
The user develops the desired block diagram by selecting and connecting various
input-output (I/O) blocks such as transfer functions, integrators, and gains. Simulink
provides the user with a GUI that contains a wide array of I/O blocks.

We can summarize the basic steps for using Simulink in the following:

1. Select the appropriate I/O blocks needed to represent the system dynamics (e.g.,
I/O blocks for transfer functions, state-space representations (SSRs), and
integrators).
2. Select the appropriate blocks to represent the input function(s) (e.g., step, pulse,
sinusoid).
3. Store the desired system output variables for plots or later analysis.
4. Select the numerical simulation parameters (e.g., run time, numerical integration
method, integration step size).
5. Execute the Simulink model to obtain the system response.
Basic Elements
There are two types of elements in Simulink: blocks and lines. Blocks are used to
generate, modify, combine, output, and display signals. Lines are used to transfer
signals from one block to another.
Blocks: The subfolders below the Simulink folder show the general classes of blocks
available for use. They are

▪Continuous: Linear, continuous-


time system elements (integrators,
transfer functions, state-space
models, etc.)
▪Discrete: Linear, discrete-time
system elements (integrators,
transfer functions, state-space
models, etc.)
▪Functions and tables: User-defined
functions and tables for
interpolating function values
▪Math: Mathematical operators
(sum, gain, dot product, etc.)
▪Nonlinear: Nonlinear operators (Coulomb/viscous friction, switches, relays, etc.)
▪Signals and systems: Blocks for controlling/monitoring signals and for creating
subsystems
▪Sinks: For output or display signals (displays, scopes, graphs, etc.)
▪Sources: To generate various types of signals (step, ramp, sinusoidal, etc.)

Lines: A directed line segment transmits signals in the direction indicated by its arrow.
Typically, a line must transmit signals from the output terminal of one block to the
input terminal of another block. A signal can be either a scalar signal (single signal) or
a vector signal (several signals in parallel). The lines used to transmit scalar signals and
vector signals are identical. Whether it is a scalar or vector is determined by the blocks
connected by the line.

Example 6.1
Let us demonstrate the construction of a
simple Simulink model. We wish to simulate
the output response of the system shown in
the figure. The system is governed by the T.F.
Y (s) 4
= 2
U ( s ) 2 s + 6 s + 30
and is given a step input of u(t) = 0.2 unit.
The Continuous library in the Simulink Library Browser will present the standard
model options for dynamic systems: transfer function, SSR, and the integrator block.
Note that the Transfer Fcn block has a single input port and a single output port.
Double clicking the Transfer Fcn block opens a dialog box which allows the user to set
the desired numerator and denominator coefficients of the transfer function.
Example 6.2
Consider a second-order system governed by the following linear ODE

The system's initial conditions are . Simulate the system


response when the input is u(t) = 0.8 sin 12t, and considering the output is

Solution
Because this system has nonzero initial conditions, we can’t use a transfer function for
the system dynamics. So we get the state-space representation as,

The Simulink model is constructed by dragging the State-Space block from the
Continuous library. State-Space block has one input port and one output port these
ports can pass scalar or vector signals. In this case, we have a single input u and a
vector output y. Double clicking the State-Space block opens a dialog box where you
can enter the appropriate numerical values for state-space matrices A, B, C, and D.
Example 6.3
Consider a dynamic system governed by two coupled, nonlinear state space

Simulate the system on simulink if it is given an input of pulse function:


u(t) = 0 for t < 1 ,
u(t) = 20 for 1 < t < 2 s ,
u(t) = 0 for t ≥ 2 s.
Consider the output as y and z and save them to workspace together with the time of
simulation.

Solution
2
Example 6.4
The figure shows a single tank with constant cross-sectional area A. It is being filled
with water with input volumetric-flow rate Qin . The output volumetric flow Qout is
modeled by turbulent flow through the valve to atmospheric pressure Patm· The
nonlinear modeling equation for the hydraulic tank system is

The turbulent flow coefficient KT = 4^10-4 m3.5/kg0.5, atmospheric pressure Patm =


1.033^105 N/m2 and the fluid capacitance is C = 2^10-4 m4s2/kg. Using Simulink,
simulate the system response to an input of Qin= 0.052 m3/s for,
a- the nonlinear model
b- the linearized model around the equilibrium condition when
c- compare the two responses.
Nonlinear system simulation

Note that constant block is used to define atmospheric pressure and in-flow rate.
Therefore, you must define the constants Qin and Patm in the MATLAB workspace
before executing the Simulink model. Also, the output is written in the workspace
instead of displaying it by scope block.
Linear system simulation
We get the linear model by linearizing the nonlinear system about a nominal input
flow rate and the corresponding nominal pressure . Putting and
into the nonlinear equation we get

Defining

Writing the Taylor expansion for we get

Computing the first derivatives and substituting we get the linear model,
6.3 Solvers
A dynamic system is simulated by computing its states at successive time steps over a
specified time span, using information provided by the model. The process of
computing the successive states of a system from its model is known as solving the
model. No single method of solving
a model suffices for all systems.
Accordingly, a set of programs,
known as solvers, are provided that
each embody a particular approach
to solving a model. The chart
provides a broad classification
of solvers in the Simulink
library.
Fixed-Step Solvers Versus Variable-Step Solvers

Fixed-step solvers solve the model at regular time intervals from the beginning to the
end of the simulation. The size of the interval is known as the step size. You can
specify the step size or let the solver choose the step size. Generally, decreasing the
step size increases the accuracy of the results while increasing the time required to
simulate the system.
▪ When you deploy a model as generated code, you can use only a fixed-step
solver.
▪ You can choose Auto to make the solve choose the suitable step size.

Variable-step solvers vary the step size during the simulation, reducing the step size to
increase accuracy when a model's states are changing rapidly and increasing the step
size to avoid taking unnecessary steps when the model's states are changing slowly.
Computing the step size adds to the computational overhead at each step but can
reduce the total number of steps, and hence simulation time, required to maintain a
specified level of accuracy for models with rapidly changing or piecewise continuous
states.
Continuous Versus Discrete Solvers
Continuous solvers use numerical integration to compute a continuous model's states
at the current time step based on the states at previous time steps and the state
derivatives.
Continuous models: are models in which the state variables change in a continuous
way, and not abruptly from one state to another.

x = f ( x(t ), u (t ))
We derive continuous models of a physical system from differential equations of the
system. If the system is linear we can derive its transfer function by Laplace
transformation.
Y (s)
G (s) =
X (s)
Mathematicians have developed a wide variety of numerical integration techniques
for solving the ordinary differential equations (ODEs) that represent the continuous
states of dynamic systems. An extensive set of fixed-step and variable-step continuous
solvers are provided, each of which implements a specific ODE solution method.
Discrete solvers exist primarily to solve purely discrete models.
Discrete models: are models in which the state variables change only at a countable
number of points in time.
x(n + 1) = f ( x(n), u (n))

We derive discrete models of a physical system from difference equations or by


converting continuous models to discrete models (discretization). If the system is
linear we can derive its transfer function by Z-transformation.

Y ( z)
G( z) =
X ( z)

In computer-based applications, signals and operations are digital. Therefore, you can
use discrete models to implement a digital controller or to simulate the behavior of a
physical system at discrete instants.

Note
You must use a continuous solver to solve a model that contains both continuous
and discrete states. You can not use a discrete solver because discrete solvers cannot
handle continuous states.
The Fixed-Step Discrete Solver
The fixed-step discrete solver computes the time of the next simulation step by adding
a fixed step size to the current time. The accuracy and the length of time of the
resulting simulation depends on the size of the steps taken by the simulation: the
smaller the step size, the more accurate the results are but the longer the simulation
takes.
Discrete solvers rely on the discrete model blocks to compute the values of any
discrete states. Blocks that define discrete states are responsible for computing the
values of those states at each time step. However, unlike discrete solvers, continuous
solvers use numerical integration to compute the continuous states that the blocks
define.

Fixed-Step Continuous Solvers

Simulink provides a set of fixed-step continuous solvers. The solvers differ in the
specific numerical integration technique that they use to compute the state
derivatives of the model. The table lists each solver and the integration technique it
uses. The table also lists the solvers in order of the computational complexity of the
integration methods they use, from the least complex (ode1) to the most complex
(ode8)
Solver Integration Technique Order of Accuracy
ode1 Euler's Method First
ode2 Heun's Method Second
ode3 Bogacki-Shampine Formula Third
ode4 Fourth-Order Runge-Kutta (RK4) Formula Fourth
ode5 Dormand-Prince (RK5) Formula Fifth
ode8 Dormand-Prince RK8(7) Formula Eighth
ode14x Newton's method + extrapolation Variable

Note that: Any of the fixed-step continuous solvers in the Simulink product can
simulate a model to any desired level of accuracy, given a small enough step size.
Unfortunately, it is not possible or practical to decide without trial, the combination of
solver and step size that will yield acceptable results for the continuous states in the
shortest time. Determining the best solver for a particular model generally requires
experimentation.

The Variable-Step Discrete Solver


Just like the fixed-step discrete solver except that, variable-step discrete solver varies
the step size dynamically based on the local error to speed up the total simulation
time.
Variable-Step Continuous Solvers
Variable-step solvers dynamically vary the step size during the simulation. Each of
these solvers increases or reduces the step size using its local error control to achieve
the tolerances that you specify. Computing the step size at each time step adds to the
computational overhead. However, it can reduce the total number of steps, and the
simulation time required to maintain a specified level of accuracy.
Simulink provides a number of variable-step continuous solvers such as,

ODE Solver Method


ode45 Runge-Kutta, Dormand-Prince (4,5) pair
ode23 Runge-Kutta (2,3) pair of Bogacki & Shampine
ode113 PECE Implementation of Adams-Bashforth-Moutlon
ode15s Numerical Differentiation Formulas (NDFs)
ode23s Second-order, modified Rosenbrock formula
ode23t Trapezoidal rule using a "free" interpolant
ode23tb TR-BDF2

In general, the ode45 solver is the best to apply as a first try for most problems. For
this reason, ode45 is the default solver for models with continuous states.

You might also like