Simulation of Dynamic Systems with MATLAB and Simulink Harold Klee download
Simulation of Dynamic Systems with MATLAB and Simulink Harold Klee download
https://textbookfull.com/product/simulation-of-dynamic-systems-
with-matlab-and-simulink-harold-klee/
https://textbookfull.com/product/classical-feedback-control-with-
nonlinear-multi-loop-systems-with-matlab-and-simulink-3rd-
edition-boris-j-lurie/
https://textbookfull.com/product/advanced-simulation-of-
alternative-energy-simulation-with-simulink-and-
simpowersystems-1st-edition-viktor-m-perelmuter/
https://textbookfull.com/product/modeling-and-simulation-of-
dynamic-systems-1st-edition-robert-l-woods/
https://textbookfull.com/product/high-performance-control-of-ac-
drives-with-matlab-simulink-second-edition-jaroslaw-guzinski-
haithem-abu-rub-atif-iqbal/
Introduction to Modeling and Simulation with MATLAB and
Python 1st Edition Steven I. Gordon
https://textbookfull.com/product/introduction-to-modeling-and-
simulation-with-matlab-and-python-1st-edition-steven-i-gordon/
https://textbookfull.com/product/design-and-optimization-of-
thermal-systems-with-matlab-applications-yogesh-jaluria/
https://textbookfull.com/product/an-introduction-to-reservoir-
simulation-using-matlab-gnu-octave-user-guide-for-the-matlab-
reservoir-simulation-toolbox-mrst-lie/
https://textbookfull.com/product/dynamic-systems-with-time-
delays-stability-and-control-ju-h-park/
https://textbookfull.com/product/continuous-signals-and-systems-
with-matlab-3rd-edition-taan-s-elali/
Simulation of Dynamic
Systems with
MATLAB® and Simulink®
Third Edition
Simulation of Dynamic
Systems with
MATLAB® and Simulink®
Third Edition
CRC Press
Taylor & Francis Group
6000 Broken Sound Parkway NW, Suite 300
Boca Raton, FL 33487-2742
This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been
made to publish reliable data and information, but the author and publisher cannot assume responsibility for the
validity of all materials or the consequences of their use. The authors and publishers have attempted to trace the
copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to
publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let
us know so we may rectify in any future reprint.
Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or
utilized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including pho-
tocopying, microfilming, and recording, or in any information storage or retrieval system, without written permission
from the publishers.
For permission to photocopy or use material electronically from this work, please access www.copyright.com (http://
www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA
01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users.
For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been
arranged.
Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for
identification and explanation without intent to infringe.
Harold Klee
To my wife, Christine, whose inner beauty radiates with the warmth of a
sunny day at the beach. Thank you for your everlasting love and support.
Randal Allen
Contents
Foreword ........................................................................................................................................ xiii
Preface.............................................................................................................................................. xv
About the Authors............................................................................................................................xix
vii
viii Contents
5.12.5 Summary...........................................................................................468
5.13 Case Study: Cascaded Tanks with Flow Logic Control.................................469
References...................................................................................................................................... 817
Index............................................................................................................................................... 821
Foreword
MATLAB is used for so many applications, it defies attempts at categorization. This book demon-
strates some of that interesting diversity.
As you read and use this book, you will find two kinds of knowledge. You may hope to find
insight to the use of MATLAB and Simulink. That hope will be richly fulfilled, I think. But you
should be mindful of another kind of knowledge; how others have solved problems. The rich col-
lection of examples and methods go far beyond the software toolset. These span different technical
disciplines and industries.
The authors show how modeling, simulation, and analysis gets done across a wide range of appli-
cations and industries, including financial markets. Work within and among various professional
societies further broaden this perspective. Their university work in teaching budding scientists and
engineers has honed the ability to make complexity approachable.
This book gives readers a chance to look outside their own discipline or industry, to collect ideas
from afar.
I hope your imagination will be fired while your modeling and simulation skills are being honed.
Steve Roemerman
Chairman & CEO of Lone Star Analysis
Dallas, TX
Simulation has come a long way since the days analog computers filled entire rooms. Yet, it is more
important than ever that simulations be constructed with care, knowledge, and a little wisdom, lest
the results be gibberish or, worse, reasonable but misleading. Used properly, simulations can give
us extraordinary insights into the processes and states of a physical system. Constructed with care,
simulations can save time and money in today’s competitive marketplace.
One major application of simulation is the simulator, which provides interaction between a model
and a person through some interface. The earliest simulator, Ed Link’s Pilot Maker aircraft trainer,
did not use any of the simulation techniques described in this book. Modern simulators, however,
such as the National Advanced Driving Simulator (NADS), cannot be fully understood without them.
The mission of the NADS is a lofty one: to save lives on U.S. highways through safety research
using realistic human-in-the-loop simulation. This is an example of the importance simulation has
attained in our generation. The pervasiveness of simulation tools in our society will only increase
over time; it will be more important than ever that future scientists and engineers be familiar with
their theory and application.
The content for Simulation of Dynamic Systems with MATLAB® and Simulink® is arranged
to give the student a gradual and natural progression through the important topics in simulation.
Advanced concepts are added only after complete examples have been constructed using funda-
mental methods. The use of MATLAB and Simulink provides experience with tools that are widely
adopted in industry and allow easy construction of simulation models.
May your experience with simulation be enjoyable and fruitful and extend throughout your careers.
xiii
Preface
In the first article of SIMULATION magazine in the Fall of 1963, the editor John McLeod pro-
claimed simulation to mean “the act of representing some aspects of the real world by numbers or
symbols which may be easily manipulated to facilitate their study.” Two years later, it was modified
to “the development and use of models for the study of the dynamics of existing or hypothesized
systems.” More than 40 years later, the simulation community has yet to converge upon a univer-
sally accepted definition. Either of the two cited definitions or others that followed convey a basic
notion, namely, that simulation is intended to reinforce or supplement one’s understanding of a sys-
tem. The definitions vary in their description of tools and methods to accomplish this.
The field of simulation is experiencing explosive growth in importance because of its ability to
improve the way systems and people perform, in a safe and controllable environment, at a reduced
cost. Understanding the behavior of complex systems with the latest technological innovations in
fields such as transportation, communication, medicine, aerospace, meteorology, etc., is a daunting
task. It requires an assimilation of the underlying natural laws and scientific principles that gov-
ern the individual subsystems and components. A multifaceted approach is required, one in which
simulation can play a prominent role, both in validation of a system’s design and in training of per-
sonnel to become proficient in its operation.
Simulation is a subject that cuts across traditional academic disciplines. Airplane crews spend
hours flying simulated missions in aircraft simulators to become proficient in the use of onboard sub-
systems during normal flight and possible emergency conditions. Astronauts spend years training in
shuttle and orbiter simulators to prepare for future missions in space. Power plant and petrochemical
process operators are exposed to simulation to obtain peak system performance. Economists resort
to simulation models to predict economic conditions of municipalities and countries for policymak-
ers. Simulations of natural disasters aid in preparation and planning to mitigate the possibility of
catastrophic events.
While the mathematical models created by aircraft designers, nuclear engineers, and economists
are application specific, many of the equations are analogous in form despite the markedly differ-
ent phenomena described by each model. Simulation offers practitioners from each of these fields
the tools to explore solutions of the models as an alternative to experimenting with the real system.
This book is meant to serve as an introduction to the fundamental concepts of continuous sys-
tem simulation, a branch of simulation applied to dynamic systems whose signals change over a
continuum of points in time or space. Our concern is with mathematical models of continuous-
time systems (electric circuits, thermal processes, population dynamics, vehicle suspension, human
physiology, etc.) and the discrete-time system models created to simulate them. The continuous sys-
tem mathematical models consist of a combination of algebraic and ordinary differential equations.
The discrete-time system models are a mix of algebraic and difference equations.
Systems that transition between states at randomly occurring times are called discrete-event
systems. Discrete-event simulation is a complementary branch of simulation, separate from con-
tinuous system simulation, with a mathematical foundation rooted in probability theory. Examples
of discrete-event systems are facilities such as a bank, a tollbooth, a supermarket, or a hospital
emergency room, where customers arrive and are then serviced in some way. A manufacturing plant
involving multiple production stages of uncertain duration to generate a finished product is another
candidate for discrete-event simulation.
Discrete-event simulation is an important tool for optimizing the performance of systems that
change internally at unpredictable times due to the influence of random events. Industrial engineer-
ing programs typically include a basic course at the undergraduate level in discrete-event simula-
tion. Not surprisingly, a number of excellent textbooks in the area have emerged for use by the
academic community and professionals.
xv
xvi Preface
1. All MATLAB script and function .m files have been renamed and the references to them
in the text have been changed to reflect the new file names. This eliminates the confusion
present in the second edition which retained the MATLAB file names from the first edition
based on the old system for naming chapter sections, figures, tables and exercise problems.
Simulink model .mdl file names remain unchanged since they do not contain chapter or
section references in their names.
2. With very few exceptions, nearly every graph generated in MATLAB has been redone
to improve its appearance in printed form. Specifically, all line plots and markers are
produced with a heavier weight, annotation and titles of most graphs have been changed
to better communicate the significance of each graph. Whilst the graphs are in black and
white in the text, every graph generated in MATLAB appears on screen in vivid colors to
enhance their appearance. Updated MATLAB and Simulink files are accessible from CRC
Press.
3. Simulink diagrams have been updated to be compatible with version R2016a of MATLAB/
Simulink. Diagrams with numerous Simulink blocks have been expanded to reveal the
details of each block and their interconnections.
4. Certain non-graph figures have been eliminated as a result of being unnecessary, while
others have been modified to be more informative.
Simulation is best learned by doing. Accordingly, the material is presented in a way that per-
mits the reader to begin exploring simulation, starting with a mathematical model in Chapter 1.
The notation used to represent discrete-time variables has been simplified in the new edition mak-
ing it easier to comprehend the difference equations developed to approximate the dynamics of
continuous-time systems. The latter part of Section 1.1 and all of Sections 1.2 through 1.5 have been
rewritten to better explain the underlying concepts.
Preface xvii
Chapters 2 and 4 remain basically unchanged. They present a condensed treatment of linear,
continuous-time, and discrete-time dynamic systems, normally covered in an introductory linear
systems course. The instructor can skip some or all of the material in these chapters if the students’
background includes a course in signals and systems or linear control theory.
Numerical integration is at the very core of continuous system simulation. Instead of treating the
subject in one exhaustive chapter, coverage is distributed over three chapters. Elementary numeri-
cal integration in Chapter 3 is an informal introduction to the subject, which includes discussion
of several elementary methods for approximating the solutions of first order differential equations.
Presentation of the topics in Chapter 3 has been completely revised. Much of the material in Chapter
3 from the second edition appears in a reorganized format while some material has been deleted
and new material added.
Simulink, from The MathWorks, is the featured simulation program because of its tight
integration with MATLAB, the de facto standard for scientific and engineering analysis, and data
visualization software. Chapter 5 takes the reader through the basic steps of creating and running
Simulink models. Monte Carlo simulation for estimation of system parameters and probability of
events occurring in dynamic systems is covered. A new case study is introduced in Section 5.13
involving logically-controlled flows between two interconnected tanks.
Chapter 6 delves into intermediate-level topics of numerical integration, including a formal pre-
sentation of One-Step (Runga–Kutta) and multistep methods, adaptive techniques, truncation errors
and a brief mention of stability.
Chapter 7 highlights some advanced features of Simulink useful in more in-depth simulation
studies. Section 7.7 was added to demonstrate rare event modeling and portfolio risk measurement,
thereby exposing potential Black Swans as they may pertain to the financial markets. Section 7.8
was added to introduce SIPmath as a means for efficiently representing uncertainty as probability
distributions, enabling legacy and future simulation models to communicate with each other.
Chapter 8 is for those interested in more advanced topics on continuous simulation. Coverage
includes a discussion of dynamic errors, stability, real-time compatible numerical integration and
multirate integration algorithms for simulation of stiff systems.
The basic minimum requirement for anyone using this text is a first course in Ordinary
Differential Equations. An outline for a one-semester, preferably senior-level course in continuous
system simulation is subject to the individual requirements of the instructor as well as the prior
education of the students. As a starting point, some basic recommendations by the authors for a
one-semester course are:
All remaining sections are appropriate for a second course in a two-semester sequence, either at
the senior, or more appropriately graduate level. The material in Chapters 7 and 8 is well suited as a
reference for practicing engineers and researchers involved in more advanced simulation endeavors.
The first and second editions of this text has been field-tested for nearly a decade. Despite numer-
ous revisions based on the scrutiny and suggestions of students and colleagues, some errors man-
age to go undetected. Further suggestions for improvement and revelations of inaccuracies can be
brought to the attention of the authors at aerospace321@outlook.com and klee.harold@gmail.com.
Numerous individuals deserve our thanks and appreciation for making the third edition pos-
sible. Thanks to Nora Konopka at Taylor & Francis/CRC Press for committing to the third edition
xviii Preface
and Kyra Lindholm, also with Taylor & Francis/CRC Press, for facilitating the transition from the
second to the third edition.
MATLAB® and Simulink® are registered trademarks of The MathWorks, Inc. For product
information, please contact:
Dr. Randal Allen is an aerospace and defense consultant working under contract to provide
6DOF aerodynamic simulation modeling, analysis, and design of navigation, guidance, and con-
trol systems. His previous experience includes launch systems integration and flight operations for
West Coast Titan-IV missions, propulsion modeling for the Iridium satellite constellation, and field
applications engineering for MATRIXx. He also chairs the Central Florida Section of the American
Institute of Aeronautics and Astronautics (AIAA).
Dr. Allen is certified as a modeling and simulation professional (CMSP) by the Modeling and
Simulation Professional Certification Commission (M&SPCC) under the auspices of the National
Training and Simulation Association (NTSA). He is also certified to deliver FranklinCovey’s Focus
and Execution track, which provides training on achieving your highest priorities.
Dr. Allen’s academic background includes a PhD in mechanical engineering from the University
of Central Florida, an engineer’s degree in aeronautical and astronautical engineering from Stanford
University, an MS in applied mathematics, and a BS in engineering physics from the University of
Illinois (Urbana–Champaign). He also serves as an adjunct professor at the University of Central
Florida in Orlando, Florida.
xix
1 Mathematical Modeling
1.1 INTRODUCTION
1.1.1 Importance of Models
Models are an essential component of simulation. Before a new prototype design for an automobile
braking system or a multimillion dollar aircraft is tested in the field, it is commonplace to “test
drive” the separate components and the overall system in a simulated environment based on some
form of model. A meteorologist predicts the expected path of a tropical storm using weather models
that incorporate the relevant climatic variables and their effect on the storm’s trajectory. An econo-
mist issues a quantitative forecast of the U.S. economy predicated based on key economic variables
and their interrelationships with the help of computer models. Before a nuclear power plant operator
is “turned loose” at the controls, extensive training is conducted in a model-based simulator where
the individual becomes familiar with the plant’s dynamics under routine and emergency conditions.
Health care professionals have access to a human patient simulator to receive training in the rec-
ognition and diagnosis of disease. Public safety organizations can plan for emergency evacuations
of civilians from low-lying areas using traffic models to simulate vehicle movements along major
access roads.
The word “model” is a generic term referring to a conceptual or physical entity that resembles,
mimics, describes, predicts, or conveys information about the behavior of some process or system.
The benefit of having a model is to be able to explore the intrinsic behavior of a system in an eco-
nomical and safe manner. The physical system being modeled may be inaccessible or even nonexis-
tent as in the case of a new design for an aircraft or automotive component.
Physical models are often scaled-down versions of a larger system of interconnected compo-
nents as in the case of a model airplane. Aerodynamic properties of airframe and car body designs
for high-performance airplanes and automobiles are evaluated using physical models in wind tun-
nels. In the past, model boards with roads, terrain, miniaturized models of buildings, and land-
scape, along with tiny cameras secured to the frame of ground vehicles or aircraft, were prevalent
for simulator visualization. Current technology relies almost exclusively on computer-generated
imagery.
In principle, the behavior of dynamic systems can be explained by mathematical equations and
formulae, which embody either scientific principles or empirical observations, or both, related to
the system. When the system parameters and variables change continuously over time or space, the
models consist of coupled algebraic and differential equations. In some cases, lookup tables con-
taining empirical data are employed to compute the parameters. Equations may be supplemented by
mathematical inequalities, which constrain the variation of one or more dependent variables. The
aggregation of equations and numerical data employed to describe the dynamic behavior of a system
in quantitative terms is collectively referred to as a mathematical model of the system.
Partial differential equation models appear when a dependent variable is a function of two or
more independent variables. For example, electrical parameters such as resistance and capacitance
are distributed along the length of conductors carrying electrical signals (currents and voltages).
These signals are attenuated over long distances of cabling. The voltage at some location x mea-
sured from an arbitrary reference is written v(x, t) instead of simply v(t), and the circuit is modeled
accordingly.
A mathematical model for the temperature in a room would necessitate equations to predict
T(x, y, z, t) if a temperature probe placed at various points inside the room reveals significant vari-
ations in temperature with respect to x, y, z in addition to temporal variations. Partial differential
1
2 Simulation of Dynamic Systems with MATLAB® and Simulink®
equations describing the cable voltage v(x, t) and room temperature T(x, y, z, t) are referred to as
“distributed parameter” models.
The mathematical models of dynamic systems where the single independent variable is “time”
comprise ordinary differential equations. The same applies to systems with a single spatial indepen-
dent variable; however, these are not commonly referred to as dynamic systems since variations of
the dependent variables are spatial as opposed to temporal in nature. Ordinary differential equation
models of dynamic systems are called “lumped parameter” models because the spatial variation of
the system parameters is negligible or else it is being approximated by lumped sections with con-
stant parameter values. In the room temperature example, if the entire contents of the room can be
represented by a single or lumped thermal capacitance, then a single temperature T(t) is sufficient
to describe the room. We focus exclusively on dynamic systems with lumped parameter models,
hereafter referred to simply as mathematical models.
A system with a lumped parameter model is illustrated in Figure 1.1. The key elements are the
system inputs u1(t), u2(t), …, ur(t), which make up the system input vector u(t), the system outputs
y1(t), y2(t), …, yp(t), which form the output vector y(t), and the parameters p1, p2, …, pm constituting
the parameter vector p. The parameters are shown as constants; however, they may also vary with
time.
Our interest is in mathematical models of systems consisting of coupled algebraic and differ-
ential equations relating the outputs and inputs with coefficients expressed in terms of the system
parameters. For steady-state analyses, transient responses are irrelevant, and the mathematical mod-
els consist of purely algebraic equations relating the system variables.
An example of a mathematical model for a system with two inputs, three outputs, and several
parameters is
d2 d d
p1 y (t ) + p2 p3 y1 (t ) + p4 y1 (t ) + p5 y2 (t ) + p6 y2 (t ) = p7u1 (t )
2 1
(1.1)
dt dt dt
d p d
p8 y2 (t ) + 9 y2 (t ) + p11 y1 (t ) y2 (t ) = p12 u1 (t ) + p13u1 (t ) + p14u2 (t ) (1.2)
dt p10 dt
p16 y1p17 (t )
p15 y3 (t ) = (1.3)
y2 (t )
The order of a model is equal to the sum of the highest derivatives of each of the dependent
variables, in this case y1(t), y2(t), y3(t), and the order is therefore 2 + 1 + 0 = 3. Equation 1.1 is a
linear differential equation. Equation 1.2 is a nonlinear differential equation because of the term
involving the product of y1(t) and y2(t). The mathematical model is nonlinear due to the presence of
the nonlinear differential equation and the nonlinear algebraic equation (Equation 1.3). It is to be
borne in mind that it is the nature of the equations that determines whether a math model is linear
p1 p2 pm
u1(t) y1(t)
······· y2(t)
u2(t)
Input Output
u(t) = SYSTEM y(t) =
ur(t) yp(t)
or nonlinear. An adjective such as linear or nonlinear applies to the mathematical model as opposed
to the actual system.
It is important to distinguish between the system being modeled and the model itself. The former
is unique, even though it may exist only at the design stage, while the mathematical model may
assume different forms. For example, a team of modelers may be convinced that the lead term in
Equation 1.1 is likely to be insignificant under normal operating conditions. Consequently, two
distinct models of the system exist, one third order and the other second order. The third-order
model includes the second derivative term to accurately reflect system behavior under unusual or
nontypical conditions (e.g., an aircraft exceeding its flight envelope or a ground vehicle performing
an extreme maneuver). The simpler second-order model ignores what are commonly referred to as
higher-order effects. Indeed, there may be a multitude of mathematical models to represent the same
system under different sets of restricted operating conditions. Regardless of the detail inherent in a
mathematical model, it nevertheless represents an incomplete and inexact depiction of the system.
A model’s intended use will normally dictate its level of complexity. For example, models for
predicting vehicle handling and responsiveness are different from those intended to predict ride
comfort. In the first case, accurate equations describing lateral and longitudinal tire forces are para-
mount in importance, whereas passenger comfort relies more on vertical tire forces and suspension
system characteristics.
Mathematical modeling is an inexact science, relying on a combination of intuition, experience,
empiricism, and the application of scientific laws of nature. Trade-offs between model complexity
and usefulness are routine. Highly accurate microclimatic weather models that use current atmo-
spheric conditions to predict the following day’s weather are of limited value if they require 48 h
on a massively parallel or supercomputer system to produce results. At the extreme opposite, overly
simplified models can be grossly inaccurate if significant effects are overlooked.
The difference between a mathematical model and a simulation model is open to interpretation.
Some in the simulation community view the two as one and the same. Their belief is that a math-
ematical model embodies the attributes of the actual system and simulation refers to solutions of the
model equations, albeit generally approximate in nature. Exact analytical solutions of mathematical
model equations are nonexistent in all but the simplest cases.
Others maintain a distinction between the two and express the view that simulation model(s)
originate from the mathematical model. According to this line of thinking, simulating the dynam-
ics of a system requires a simulation model that is different in nature from a mathematical model.
A reliable simulation model must be capable of producing numerical solutions in reasonably
close agreement with the actual (unknown) solutions to the math model. Simulation models are
commonly obtained from discrete-time approximations of continuous-time mathematical mod-
els. Much of this book is devoted to the process of obtaining simulation models in this way. More
than one simulation model can be developed from a single mathematical model of a system.
Stochastic models are important when dealing with systems whose inputs and parameters are
best modeled using statistical methods. Discrete event models are used to describe processes that
transit from one state to another at randomly spaced points in time. Probability theory plays a sig-
nificant role in the formulation of discrete event models for describing the movement of products
and service times at different stages in manufacturing processes, queuing systems, and the like. In
fact, the two pillars of simulation are continuous system simulation, the subject of this book, and
discrete event simulation.
There is a great deal more to be said about modeling. Entire books are devoted to properly iden-
tifying model structure and parameter values for deterministic and stochastic systems. Others con-
centrate more on derivation of mathematical models from diverse fields and methods of obtaining
solutions under different circumstances. The reader is encouraged to check the references section at
the end of this book for additional sources of material related to modeling.
Modeling is essential to the field of simulation. Indeed, it is the starting point of any simula-
tion study. The emphasis, however, in this book is on the presentation of simulation fundamentals.
4 Simulation of Dynamic Systems with MATLAB® and Simulink®
Accordingly, derivation of mathematical models is not a prominent component. For the most part,
the math models are taken from documented sources listed in the references section, some of which
include step-by-step derivations of the model equations. The derivation is secondary to a complete
understanding of the model, that is, its variables, parameters, and knowledge of conditions that may
impose restrictions on its suitability for a specific application.
Simulation of complex systems requires a team effort. The modeler is a subject expert responsi-
ble for providing the math model and interpreting the simulation results. The simulationist produces
the simulation model and performs the simulation study. For example, an aerodynamicist applies
principles of boundary layer theory to obtain a mathematical model for the performance of a new
airfoil design. Starting with the math model, simulation skills are required to produce a simulation
model capable of verifying the efficacy of the design based on numerical results. Individuals with
expert knowledge in a particular field are oftentimes well versed in the practice of simulation and
may be responsible for formulation of alternative mathematical models of the system in addition to
developing and running simulations.
A simple physical system is introduced in the next section, and the steps involved in deriving an
idealized math model are presented. In addition to benefiting from seeing the process from start
to finish, the ingredients for creating a simulation model are introduced. Hence, by the end of this
chapter, the reader will be able to perform rudimentary simulation.
F0(t)
F1(t) TANK
H(t)
ΔH
model will be suitable for its intended application. It must be borne in mind that if extremely accu-
rate predictions of the level H(t) are required, it may be necessary to include second-order effects
such as evaporation and hence introduce additional inputs related to ambient conditions, namely,
temperature, humidity, air pressure, wind speed, and so forth.
The derivation is based on conditions of the tank at two discrete points in time, as if snapshots of
the tank were available at times “t” and “t + Δt,” as shown in Figure 1.3.
The following notation is used with representative units given for clarity:
V (t + ∆t ) = V (t ) + ∆V (1.4)
where
V(t) is the volume of liquid in the tank at time t
ΔV is the change in volume from time t to t + Δt
V (t ) = AH (t ) (1.5)
V (t + ∆t ) = AH (t + ∆t ) (1.6)
Equations 1.5 and 1.6 assume constant cross-sectional area of the tank, that is, A is independent
of H.
The change in volume from t to t + Δt is equal to the volume of liquid flowing in during the interval
t to t + Δt minus the volume of liquid flowing out during the same period of time. The liquid volumes
are the areas under the input and output volume flow rates from t to t + Δt as shown in Figure 1.4.
Expressing these areas in terms of integrals,
t +∆t t +∆t
∆V =
∫ F (t )dt − ∫ F (t )dt
t
1
t
0 (1.7)
The integrals in Equation 1.7 can be approximated by assuming F1(t) and F0(t) are constant over the
interval t to t + Δt (see Figure 1.4). Hence,
F1(t)
H(t)
F0(t)
ΔH
t t + Δt t t + Δt t t + Δt
FIGURE 1.4 Volumes of liquid flowing in and out of tank from t to t + Δt.
6 Simulation of Dynamic Systems with MATLAB® and Simulink®
t +∆t
∫ F (t )dt ≈ F (t )∆t
t
1 1 (1.8)
t +∆t
∫ F (t )dt ≈ F (t )∆t
t
0 0 (1.9)
Equations 1.8 and 1.9 are reasonable approximations provided Δt is small. Substituting Equations
1.8 and 1.9 into Equation 1.7 yields
Substituting Equations 1.5, 1.6, and 1.10 into Equation 1.4 gives
AH (t + ∆t ) ≈ AH (t ) + [ F1 (t ) − F0 (t )]∆t (1.11)
∆H
⇒ A ≈ F1 (t ) − F0 (t ) (1.13)
∆
where ΔH is the change in liquid level over the interval (t, t + Δt). Note that ΔH/Δt is the average
rate of change in the level H over the interval (t, t + Δt). It is the slope of the secant line from pt A
to pt B in Figure 1.5.
In the limit as Δt approaches zero, pt B approaches pt A, and the average rate of change in H over
the interval (t, t + Δt) becomes the instantaneous rate of change in H at time t, that is,
∆H dH
lim = (1.14)
∆t → 0 ∆t dt
where dH/dt is the first derivative of H(t). From the graph, it can be seen that dH/dt is equal to the
slope of the tangent line of the function H(t) at t (pt A).
H
B
B′
Pt Coordinates
Tangent
ΔH A [t, H(t)]
A Δt B [t + Δt, H(t + Δt)]
t t + Δt′ t + Δt
F0
1 1
F0 = H
R
R
H
Taking the limit as Δt approaches zero in Equation 1.13 and using the definition of the derivative
in Equation 1.14 give
∆H
lim = lim [ F1 (t ) − F0 (t )] (1.15)
∆t → 0 ∆t
∆t →0
dH
⇒ A = F1 (t ) − F0 (t ) (1.16)
dt
Since there are two dependent variables, a second equation or constraint relating F0 and H is
required in order to solve for either one given the input function F1(t). It is convenient at this point
to assume that F0 is proportional to H, that is, F0 = constant × H (see Figure 1.6). The constant of
proportionality is expressed as 1/R where R is called the fluid resistance of the tank. At a later point,
we will revisit this assumption.
1
F0 = H (1.17)
R
Equations 1.16 and 1.17 constitute the mathematical model of the liquid tank, namely,
dH 1
A + F0 = F1 and F0 = H
dt R
where F1, F0, H, and dH/dt are short for F1(t), F0(t), H(t), and (d/dt)H(t).
In this example, the model is a coupled set of equations. One is a linear differential equation and
the other is an algebraic equation, also linear. The differential equation is first order since only the
first derivative appears in the equation and the tank dynamics are said to be first order.
The outflow F0 can be eliminated from the model equations by substituting Equation 1.17 into
Equation 1.16 resulting in
dH 1
A + H = F1 (1.18)
dt R
Before a particular solution to Equation 1.18 for some F1(t), t ≥ 0 can be obtained, the initial tank
level H(0) must be known.
There are several reasons why an analytical approach to solving Equation 1.18 may not be the
preferred method. Even when the analytical solution is readily obtainable, for example, when the
system model is linear, as in the present example, the solution may be required for a number of dif-
ferent inputs or forcing functions. Recall from studying differential equations what happens when
the right-hand side of the equation changes. A new particular solution is required that can be time-
consuming, especially if the process is repeated for a number of nontrivial forcing functions.
Second, the input F1(t) may not even be available in analytical form. Suppose the input func-
tion F1(t) is unknown except as a sequence of measured values at regularly spaced points in time.
8 Simulation of Dynamic Systems with MATLAB® and Simulink®
An exact solution to the differential equation model is out of the question since the input is not
expressible as an analytic function of time.
EXERCISES
1.1 A system consists of two tanks in series in which the outflow from the first tank is the inflow
to the second tank as shown in the figure below.
a. Find the algebraic and differential equations comprising the mathematical model of the two
tank system. Assume both tanks are linear, i.e. the outflows are proportional to the liquid
levels and R1, R2 are the fluid resistances of the tanks.
b. Eliminate the flows F0(t) and F2(t) from the model to obtain a model in the form of two dif-
ferential equations involving the system input F1(t) and the tank levels H1(t) and H2(t).
c. Obtain the model differential equations when F0(t) and F2(t) are present instead of H1(t) and
H2(t).
d. The initial fluid levels in the tanks are H1(0) and H2(0) Suppose the flow in to the first tank
is constant, F1 (t ) = F1, t ≥ 0. Obtain expressions for H1(∞) and H2(∞), the eventual fluid
levels in Tanks 1 and 2. Do H1(∞) and H2(∞) depend on the initial fluid levels? Explain.
e. Find the ratio of tank resistances R1/R2 if H1(∞) = 2H2(∞).
f. Suppose the flow between the two tanks is reduced to zero by closing the valve in the line.
Show that this is equivalent to R1 = ∞ and determine the values of H1(∞) and H2(∞)
assuming the inflow to the first tank is still constant.
1.2 The two tanks in Exercise 1.1 are said to be non-interacting because the flow rate from the
first tank only depends on the fluid level in the first tank and is independent of the fluid level
in the second tank. Suppose the discharged fluid from the first tank enters the second tank at
the bottom instead of the top as shown in the figure below.
The flow between the tanks is now a function of the fluid levels in both tanks. The driving
force for the inter-tank flow is the difference in fluid levels and for the time being we can
assume the two quantities are proportional. That is,
H (t ) − H 2 (t )
F0 (t ) ∝ H1 (t ) − H 2 (t ) ⇒ F0 (t ) = 1
R12
Other documents randomly have
different content
after a tough struggle up the precipitous and clayey bank
of the stream found a firm footing at the top. He was
obliged to walk till daylight before he found a shelter.
There was enough music, fortunately, in the violin–case for
immediate use; and although the company had lost all their luggage,
only one concert was given up. The second night after the accident
Ole Bull performed in Cincinnati as announced, but was obliged to
appear in his traveling dress.
The exquisite pictures of the artist which appear later in the poem,
breathing the Northern tradition and spirit, follow naturally here:—
Last the Musician, as he stood
Illumined by that fire of wood;
Fair–haired, blue–eyed, his aspect blithe,
His figure tall and straight and lithe,
And every feature of his face
Revealing his Norwegian race;
A radiance, streaming from within,
Around his eyes and forehead beamed;
The angel with the violin,
Painted by Raphael, he seemed.
He lived in that ideal world
Whose language is not speech, but song;
Around him evermore the throng
Of elves and sprites their dances whirled;
The Strömkarl sang, the cataract hurled
Its headlong waters from the height;
And mingled in the wild delight
The scream of sea–birds in their flight,
The rumor of the forest trees,
The plunge of the implacable seas,
The tumult of the wind at night,
Voices of eld, like trumpets blowing,
Old ballads and wild melodies
Through mist and darkness pouring forth,
Like Elivagar’s river flowing
Out of the glaciers of the North.
The instrument on which he played
Was in Cremona’s workshops made,
By a great master of the past,
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com