0% found this document useful (0 votes)
5 views258 pages

Continuous System Simulation

The document is a comprehensive guide on continuous system simulation, authored by D.J. Murray-Smith and published in 1995. It covers principles of modeling, simulation methods, numerical modeling, and various applications, including case studies on liquid level control systems and aircraft landing systems. The text also discusses real-time simulation, current trends, and provides appendices on related mathematical concepts.

Uploaded by

CESAR Lc
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)
5 views258 pages

Continuous System Simulation

The document is a comprehensive guide on continuous system simulation, authored by D.J. Murray-Smith and published in 1995. It covers principles of modeling, simulation methods, numerical modeling, and various applications, including case studies on liquid level control systems and aircraft landing systems. The text also discusses real-time simulation, current trends, and provides appendices on related mathematical concepts.

Uploaded by

CESAR Lc
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

CONTINUOUS SYSTEM

SIMULATION
Continuous System
Simulation

D.J. Murray-Smith
Department of Electronics and Electrical Engineering
University of Glasgow
Glasgow
UK

SPRINGER-SCIENCE+BUSINESS MEDIA, B.V.


First edition 1995

© 1995 D.J. M u r r a y - S m i t h
O r i g i n a l l y published b y C h a p m a n & H a l l i n 1995
Typeset by E X P O H o l d i n g s , M a l a y s i a

ISBN 978-1-4613-6066-7 I S B N 978-1-4615-2504-2 (eBook)


D O I 10.1007/978-1-4615-2504-2
A p a r t f r o m any fair dealing for the purposes of research or private study,
or criticism or review, as permitted under the U K C o p y r i g h t Designs and
Patents A c t , 1988, this publication m a y not be reproduced, stored, or
transmitted, i n any f o r m or by any means, without the prior permission
i n w r i t i n g of the publishers, or i n the case of reprographic reproduction
only i n accordance w i t h the terms of the licences issued by the C o p y r i g h t
Licensing A g e n c y i n the U K , or i n accordance w i t h the terms of licences
issued by the appropriate Reproduction Rights Organization outside the
U K . Enquiries concerning reproduction outside the terms stated here
should be sent to the publishers at the L o n d o n address printed on this
page.
The publisher makes no representation, express or i m p l i e d , w i t h regard
to the accuracy of the information contained i n this book and cannot
accept any legal responsibility or liability for any errors or omissions that
may be made.

A catalogue record for this book is available from the British L i b r a r y

L i b r a r y of Congress Catalog C a r d N u m b e r : 94-72017

(bb) Printed on permanent acid-free text paper, manufactured i n

accordance w i t h A N S I / N I S O Z39.48-1992 and A N S I / N I S O Z39.48-1984


CONTENTS

Preface xi

1 The principles of modeling 1


1.1 Objectives in the modeling of systems 1
1.2 Continuous-variable and discrete-event models 2
1.3 Types of continuous-variable model 3
1.4 Modeling and simulation procedures for continuous-variable models 4
References 11

2 An introduction to simulation methods 13


2.1 The need for simulation 13
2.2 Methods of simulation 14
2.2.1 Techniques based on special-purpose simulation hardware 14
2.2.2 Techniques based on general-purpose computer hardware 16
2.3 A review of simulation applications 18
References 21

3 Problem organization for continuous system simulation 23


3.1 Introduction 23
3.2 Descriptions for continuous-variable models: reduced and state-variable forms 24
3.3 Conversion from reduced form to state-variable form 25
3.4 Transfer function descriptions 26
3.5 Bond graph representations 27
3.5.1 One-port components 27
3.5.2 Causality in bond graph representations 27
3.5.3 Junctions in bond graphs 28
3.5.4 Coupling between physical domains 29
3.5.5 Signals in bond graphs 30
3.5.6 Simulation program development from bond graph models 30
3.6 Block diagram and signal flow graph representations 31
3.7 Block diagram and signal flow graph methods for transfer function simulation 32
3.7.1 The direct construction approach 33
3.7.2 The parallel construction approach 35
3.7.3 The iterative construction approach 36
3.7.4 An example of block diagram construction from a transfer function 37
vi Contents
3.8 Modeling of distributed parameter elements 39
3.8.1 Introduction 40
3.8.2 Pure time delay 41
3.8.3 Distributed time delay 41
3.8.4 Simulation models involving pure and distributed delay elements 41
3.9 Parameter sensitivity analysis methods in system modeling and simulation 42
3.9.1 Methods for sensitivity co-system simulation 43
3.10 Mathematical models of systems having both discrete and continuous
elements 47
References 49

4 The principles of numerical modeling 51


4.1 An introduction to numerical integration methods 51
4.2 Fixed-step integration algorithms: one-step methods 52
4.2.1 Introduction 53
4.2.2 Taylor series descriptions 53
4.2.3 Errors in fixed-step integration methods 56
4.2.4 Explicit Runge-Kutta methods 57
4.2.5 Trapezoidal integration 60
4.3 Fixed-step integration algorithms: multistep methods 60
4.4 Problems of integration step-size selection and numerical instability 61
4.5 Variable-step integration algorithms 62
4.6 Problems of 'stiff' models 62
4.7 Discontinuities and their effects 63
4.7.1 Numerical methods for discontinuous problems 64
4.8 Problems of implicit loop structures 66
References 66

5 Sampled-data models and operator methods 67


5.1 Introduction 67
5.2 Approximations based on sampled-data theory 67
5.3 Modeling of linear systems using sampled-data approximations 69
5.3.1 Cascaded elements 69
5.3.2 Closed-loop systems 70
5.4 Modeling of nonlinear systems using sampled-data approximations 70
5.4.1 Cascaded elements 70
5.4.2 Closed-loop models 73
5.5 Sampled-data description for a continuous state-space model 74
5.5.1 Linear time-invariant models 74
5.6 Operational methods for difference equation models 75
5.6.1 Integration operators 75
5.7 Simulation using operational methods 76
5.7.1 Simulation of a single transfer function 76
5.7.2 Simulation of cascaded transfer functions 77
5.7.3 Simulation of linear closed-loop systems 80
5.7.4 Simulation of time-varying and nonlinear models by operator methods 81
5.8 Assessment of simulation performance by frequency response methods 83
Contents vii
5.8.1 Frequency response of discrete integrators 83
References 84

6 The principles of equation-oriented simulation software 85


6.1 Introduction 85
6.2 Simulation programming using general-purpose high-level languages 85
6.3 Simulation programming using matrix packages 86
6.4 Simulation packages 87
6.5 Simulation programming using simulation languages 87
6.5.1 Introduction 87
6.5.2 The Simulation Councils' 1967 recommendations (CSSL'67) 87
6.5.3 The general structure of simulation programs using CSSL'67-type
languages 88
6.6 SLIM - a simple continuous system simulation language 91
6.6.1 The main features of the language 91
6.6.2 The syntax of the SLIM language 92
6.6.3 Output facilities and graphics 97
6.6.4 An example of a simulation program in the SLIM language 97
6.7 Examples of other simulation languages 101
6.7.1 CSSL IV 101
6.7.2 ACSL 103
6.7.3 DESIRE 104
6.8 Comparisons of SLIM with widely used simulation languages 105
References 107

7 The principles of block diagram-oriented simulation tools 109


7.1 Graphical man-machine interfaces for simulation 109
7.2 The block-based approach to the description of dynamic systems 110
7.3 Examples of block-oriented simulation environments with a graphical user
interface 111
7.4 A simple simulation example using graphical block-oriented tools 113
References 115

8 Simple examples using common simulation tools 117


8.1 Introduction 117
8.2 A coupled-tuned electrical circuit simulation 117
8.3 A control system simulation: speed control of a water turbine 121
8.4 Simulation of a neural encoder model 125
8.5 A constrained pendulum simulation 129
8.6 Simulation of a simple digital control system 131
References 138

9 Internal verification and external validation 141


9.1 The need for testing 141
9.2 Terminology and definitions 142
9.3 Internal verification 142
viii Contents
9.3.1 Static checks 143
9.3.2 Dynamic checks 143
9.4 External validation 144
9.4.1 Theoretical validity 144
9.4.2 Empirical validity 145
9.4.3 Measured response information for empirical validation 147
9.4.4 System identification and parameter estimation methods in the empirical
validation process 148
9.5 Robustness issues in external validation 149
9.6 Possible outcomes of the external validation process 150
9.7 Documentation of the validation process 150
References 151

10 Case study I - a two-tank liquid level control system 153


10.1 Introduction 153
10.2 Modeling of a pair of interconnected tanks 154
10.2.1 A nonlinear mathematical model 155
10.2.2 Linearization of the model 156
10.3 Programs for simulation of the nonlinear coupled-tank system 157
10.3.1 Internal verification of the simulation program 158
10.3.2 External validation of the simulation model 160
10.4 Discussion 162
Reference 162

11 Case study II - an aircraft automatic landing system 163


11.1 Introduction 163
11.2 Modeling and simulation of an aircraft directional-control system 165
11.3 Modeling and simulation of a lateral beam guidance system 169
11.4 Discussion 173
References 173

12 Case study III - respiratory gas-exchange process simulation 175


12.1 Introduction and background physiology 175
12.2 Modeling of pulmonary gas-exchange processes 176
12.3 The computer simulation 179
12.4 Discussion 182
References 184

13 Case study IV - a simulation model of active skeletal muscle 187


13.1 Introduction 187
13.2 Models of active muscle 189
13.2.1 Simulation of active muscle for constant length conditions 192
13.2.2 Models of active muscle for constant tension conditions and simulation
of the after-loaded isotonic twitch 193
13.3 Parameter sensitivity analysis 196
Contents ix
13.4 Simulation of the complete twitch response and repetitive stimulation 203
13.5 Discussion 204
References 205

14 Real-time simulation 207


14.1 An introduction to real-time applications 207
14.2 Hardware and software aspects of real-time simulation 208
14.3 Analog simulation techniques 209
14.3.1 The operational amplifier 210
14.3.2 The summing unit 211
14.3.3 The integrator unit 211
14.3.4 The coefficient unit 212
14.3.5 Multipliers and other nonlinear units 213
14.3.6 Scaling of variables 213
14.3.7 Operating modes 217
14.4 Digital techniques 217
14.4.1 Real-time integration algorithms 217
14.4.2 Choice of communication interval 219
14.4.3 Error analysis in real-time simulation 220
14.4.4 Multirate methods 220
14.5 Special-purpose hardware for real-time digital simulation 221
14.5.1 Introduction 221
14.5.2 Array processors and multiprocessor systems 221
14.5.3 Transputer-based parallel systems 222
14.6 Hardware-in-the-Ioop simulation and partial-system testing 222
14.7 Applications in training and education 223
14.7.1 Introduction 223
14.7.2 Simulators for operator training 224
14.7.3 Real-time simulation in teaching 225
References 226

15 Current trends in continuous system simulation 227


15.1 Developments in simulation languages 227
15.2 Improvements in the man-machine interface 228
15.3 Developments involving parallel processor systems 229
15.3.1 Hardware developments in parallel processing for simulation 229
15.3.2 Simulation software for parallel processor systems 230
15.4 Artificial intelligence and simulation 230
15.4.1 Knowledge-based systems in modeling and simulation 231
15.4.2 Knowledge representation using frames and inheritance 231
15.4.3 Qualitative modeling and qualitative simulation 232
References 233

Appendix A The Laplace transform 235


A.l Introduction 235
A.2 Linearity theorem 235
x Contents
A3 Differentiation theorem 235
A4 Final value theorem 236
A5 Example 236
Reference 236

Appendix B The transfer function 237


Reference 237

Appendix C Block diagrams and signal flow graphs 239


C1 Introduction 239
C2 Block diagrams 239
C3 Signal flow graphs 241
Reference 242

Appendix D Discrete-time models and sampled-data theory 243


D.1 Introduction 243
D.2 Discrete-time models 243
D.3 Discretization of a continuous-time model 243
D.4 The sampling process 244
References 246

Appendix E SLIM software instructions 247


E.1 Introduction 247
E.2 Hardware requirements 247
E.3 Software installation 247
E.4 Starting and exiting SLIM 248
E.5 Useful hints for using SLIM 248
E.6 Starting and exiting SLIMPLOT 249
E.7 Useful hints for using SLIMPLOT 249

Index 251
PREFACE

Computer simulation of dynamic systems is a obtained by simulation more quickly, effec-


topic which is growing steadily in importance tively and cheaply than by experimentation
in the physical sciences, engineering, biology and testing of the real system. System perfor-
and medicine. The reasons for this trend mance can also be investigated using simula-
relate not only to the steadily increasing tion for a much wider range of conditions
power of computers and the rapidly falling than can be contemplated for the real system
costs of hardware, but also to the availability because of operating constraints or safety
of appropriate software tools in the form of requirements. Similar factors can apply in
simulation languages. Problem-oriented lan- other fields, such as biomedical systems
guages of this kind assist those who are not engineering.
specialists in computational methods to trans- System simulation, using digital computers,
late a mathematical description into a simula- can relate either to models based on continu-
tion program in a simple and straightforward ous variables or to discrete-event descriptions.
fashion. They can also provide useful diag- Continuous system simulation techniques are
nostic information when difficulties are applied to systems described by sets of differ-
encountered. Therefore, a simulation lan- ential equations and algebraic equations. Such
guage provides, in comparison with lan- descriptions of dynamic properties are applic-
guages such as Fortran, Basic, Pascal or C, the able to many types of engineering system, to a
same type of advantages for simulation wide range of problems in the physical sci-
which those standard high-level languages ences and to certain types of biological system.
provide over an assembly language for other Discrete-event simulation is also concerned
computer applications. with systems which are dynamic in nature, but
Simulation involves experimentation with in this case events and the times at which they
models of real systems. The reasons for using occur are of primary importance. Examples of
a simulation approach to problem solving applications for which discrete-event simula-
depend, to some extent, on the field of appli- tion is important are in air and road traffic
cation. In engineering, simulation techniques control, in manufacturing systems and in the
can often allow valuable insight to be gained optimization of computer systems or commu-
at an early stage in a design, when it would nications networks. This book is concerned
otherwise be unobtainable until a prototype primarily with continuous system simulation
system or scale model was constructed. In and includes discussion of di~cret-vn tech-
some engineering applications, such as the niques only in the context of mixed models
development of aircraft flight-control sys- which include some discrete elements together
tems, simulation may be the only feasible and with continuous system descriptions.
safe approach for initial investigations. Even The proper use of simulation techniques
at much later stages of system development, a cannot be separated from the intelligent use
simulation-based approach may still be of mathematical models. The concept of
useful, since the required results may often be 'garbage in, garbage out' is true of simulation
xii Preface
as much as it is of any other computer appli- computer. This language, which is fully
cation area. Recognizing the fact that informa- described in Chapter 6, provides a basis for
tion inherent in the underlying model is at some preliminary work on equation-oriented
fault can present serious problems even for methods and can be used by the reader to
experienced users of simulation techniques. gain practical experience before considering
Careful consideration must be given to more complex examples involving use of
methods of testing and validation. Without more comprehensive simulation languages,
this the potential advantages of a simulation such as ACSL. Although the software pro-
approach are nullified. The first chapter of the vided on the diskette is limited in terms of the
book sets the scene in this respect with a size of problems that can be tackled and in
review of the objectives of modeling and the range of facilities provided, it is hoped
simulation and an account of systematic pro- that it may enhance the text considerably for
cedures which help to ensure that these objec- those having access to a personal computer.
tives are satisfied. More detailed discussion of The limitations of the language are fully
the verification and validation of simulation described and comparisons are made, in
models is presented in later sections, espe- terms of its facilities and performance, with
cially in Chapter 9 and in the case study of commercially supported languages. How-
Chapter 10. ever, it must be emphasized that this software
The book is intended mainly for readers is intended only as an aid to understanding
with little or no previous experience of com- simulation methods and is not a substitute for
puter simulation methods but having a established and supported modem simula-
reasonably numerate background. An tion languages which have many features not
elementary understanding of ordinary differ- included within SLIM.
ential equations and some knowledge con- The case studies in Chapters 10, 11, 12 and
cerning their use in the mathematical modeling 13 have been chosen to be of interest to
of physical systems is necessary. Large sec- readers with a background principally in en-
tions of the book should also be of value to gineering, physics or applied mathematics.
those already working in the field of computer However, both here and in other sections of
simulation and modeling. The objective has the book, some use is also made of bioengin-
been to cover the general principles of continu- eering examples to emphasize the importance
ous system simulation methods in a thorough of simulation in biomedical fields and to high-
fashion and, through appropriate examples light some of the problems that can arise in
and case studies, to illustrate the application of the modeling and simulation of such systems.
these principles using modem simulation In every example background information is
packages. Both equation-oriented languages provided which is intended to provide
and block diagram-based packages are consid- readers not active in the field with sufficient
ered. Separate chapters are included which information to allow them to understand the
cover the questions of problem description problem, the associated mathematical model
and organization at a mathematical level and and the particular simulation issues raised.
the principles of numerical modeling before Care has been taken to ensure that objectives
any attempt is made to discuss specific for the simulation work are stated clearly in
problem-oriented languages. the case studies presented.
A simple continuous system simulation Other topics covered in later chapters
language called SLIM (Simulation Language include real-time simulation techniques,
for Introductory Modeling) is provided with which are of great importance for many types
the book on a diskette which can be used on of engineering and laboratory applications,
any DOS-based IBM-compatible personal and a brief review of current trends in simula-
Preface xiii
tion. Topics covered under this latter heading Sales Department
include the effects of new developments in NAG Ltd
conventional computer hardware and soft- Wilkinson House
ware, the influence of parallel architectures Jordan Hill Road
on simulation methods, and links which are Oxford OX2 9BX
being established between the fields of artifi- United Kingdom
cial intelligence and simulation. Many people have contributed to the
In preparing a book intended for engineers preparation of this text and the accompany-
and scientists in a number of different disci- ing software. First of all, I wish to thank many
plines it has been recognized that readers students in the Department of Electronics and
may not all be fully familiar with the relevant Electrical Engineering at the University of
mathematical techniques. A number of Glasgow who have assisted in the develop-
appendices have therefore been included to ment of some of the material through their
cover relevant topics such as the Laplace project work, by pointing out errors in sec-
transform, transfer function descriptions and tions which have been used to support
block diagram notation. courses at undergraduate and post-graduate
The graphical routines included in the level, and by helping with the development
accompanying software are part of the NAG and testing of the SLIM software. In particu-
Graphics Library. This product contains a col- lar, I wish to mention the contribution made
lection of over 100 carefully designed routines by Fran<;ois Gaudaire, who developed many
which provides Fortran and C programmers of the XANALOG simulation diagrams used
with a convenient and versatile means of pro- in the examples and case studies of Chapters
ducing a graphical representation of numeri- 8, 10, 11, 12 and 13. I also wish to thank
cal and statistical results. It is used worldwide Mingrui Gong for her assistance with some of
in commerce, financial modeling, industry, the model validation results included in
academic research and many other areas, and Chapter 10. I have also had very helpful feed-
is available for a wide spectrum of machines. back from experienced engineers on post-
Interfaces are also supplied to the most com- graduate short courses, most recently at one
monly used plotting packages. organized by PROPESA at the Centro Tecnico
NAG also provide a wide range of other Aeroespacial, Sao Jose dos Campos, Brazil. To
products such as mathematical and statistical all the many individuals who have provided
routines in Fortran, C, Pascal and Ada; assistance, of one kind or another, I wish to
Fortran 90 compilers and tools; symbolic express my sincere appreciation. Finally, I
solvers; data visualization software; linear must acknowledge the support, encourage-
programming software and a gateway gener- ment and patience of my wife, Effie, who has
ator which automatically generates MATLAB helped to make this book possible.
gateway. For further information, a quotation
or details of your local distributor please David Murray-Smith
contact: Glasgow 1994
THE PRINCIPLES OF MODELING 1

1.1 OBJECTIVES IN THE MODELING OF able information and can expose gaps and
SYSTEMS inconsistencies in the existing knowledge
base. Problems of this kind can only be
Much scientific and engineering work resolved by the design of new experiments. It
involves the formalization of knowledge and is clear, therefore, that mathematical model-
the building of models. From experiments ing should not be regarded simply as an alter-
and observations one can form abstract repre- native to experimentation and a solid base of
sentations and laws which can then provide a experimental data is needed in order to
basis for analysis or engineering design. develop a quantitative model. Further experi-
Mathematical models are one particular type mental data are needed in order to carry out
of abstract representation which has been the processes of model validation to establish
found to provide a very effective means of the range of conditions over which the model
encoding information about a real system. may be applied with confidence.
Such representations can also serve to com- The acceptability of mathematical model-
press large amounts of observational data ing, and the extent to which modeling tech-
and allow quantitative relationships to be niques are used, varies considerably from one
established which may not be directly evident field to another. Mathematical models are
from experimental data. used so extensively in the physical sciences
A mathematical model which embraces the and engineering, and are so central to the
essential features of a real-world system per- introductory teaching of many topics within
mits useful analysis to be carried out for the those fields, that, for some at least, there is a
range of conditions for which the model is danger that models can become more import-
believed to be accurate and useful. In this ant than the systems which they represent.
respect a model may be likened to a map: the Often it is only when students are exposed to
scale of the map determines both the accuracy more advanced experimental work in these
and the range of applications that are appro- fields that they begin to appreciate some of
priate. As with a map, some cautious extra- the limitations of the models which they are
polation may be possible with a model. In this using. However, in the biological sciences
case such extrapolation may allow investi- mathematical modeling is still viewed with
gation of situations which cannot be studied some suspicion, although there are many
experimentally because of safety constraints examples in which models have been used
or measurement problems, or because the very effectively to help to solve important
system in question has not yet been biological problems.
constructed. Objectives in the development and applica-
The development of a formal mathematical tion of mathematical Q10dels are very de-
description for a given system normally pendent upon the subject area. Generally,
involves a critical examination of all the avail- within pure science, mathematical models are
2 The principles of modeling
developed for one or more of the following tors, capacitors and inductors, equations
reasons: may be written down from Ohm's law and
Kirchhoff's laws describing currents and volt-
1. hypothesis testing;
ages within a given electrical network as
2. the development of new or improved
continuous functions of time. They are con-
experiments;
tinuous-variable models and involve mathe-
3. the provision of a concise quantitative
matical descriptions based on differential
description which extends the capabilities
equations. This is the general class of model
of the human brain to handle the com-
which is of primary importance in this book.
plexities of the real system under consid-
A second class of mathematical description,
eration.
known as discrete-event models, is also im-
Within engineering, mathematical modeling portant in certain types of computer simula-
is used as a tool for decision making and as a tion application. Changes in discrete systems
basis for design calculations. In this field of take place either periodically or in a random
application, questions concerning model fashion. Between the events which mark these
accuracy and credibility are of central import- changes all the variables of the system remain
ance, since decisions may be made on the constant. One example of a discrete system in
basis of mathematical model predictions which changes take place periodically arises
which have a direct bearing on the safety, in the modeling of a digital computer used
reliability, efficiency or effectiveness of some for real-time signal processing or direct digi-
new product or system. tal control. In this case a continuous variable
In general, whatever the field of appli- is sampled periodically using some form of
cation, mathematical modeling should be analog to digital converter, and calculations
seen as just one aspect of a systems approach are performed on the discrete numbers which
to problem solving. In most cases the steps have been input to the computer from the
involved in the modeling of a process are converter. The system cannot be modeled
linked closely to questions of measurement entirely using differential equations owing to
and experimentation. The integration of mod- the discrete nature of the processing actions
eling, experimentation and data analysis can within the computer and a difference equa-
often provide new insight and allow progress tion type of formulation is necessary for the
to be made which might not be achieved so model of the computer and the associated
readily using one of these three elements in analog to digital converters. In section 3.10
isolation. further consideration is given to the treatment
of discrete models of this kind, in which
changes take place on a regular periodic
1.2 CONTINUOUS-VARIABLE AND
basis. Problems of discrete systems in which
DISCRETE-EVENT MODELS
events occur randomly have led to the devel-
Models commonly used in the physical sci- opment of a separate form of simulation
ences, engineering and biology often involve methodology which is generally known as
variables which are continuous functions of discrete-event simulation. Examples of areas
time. One example is in applied mechanics, of application for discrete-event simulation
where equations of motion may be derived include traffic flow analysis of all kinds. For
from the application of Newton's laws of example, the times of arrival of vehicles at a
motion and involve quantities such as posi- set of road traffic signals and requests for con-
tion, velocity and acceleration which may be nections in a telephone communication
defined as continuous functions. Similarly, in system are both cases of discrete events
modeling electrical circuits involving resis- which can be regarded as occurring ran-
Types of continuous-variable model 3
domly. Event-oriented simulation of this kind variable (the 'output') and another (the
is outside the scope of this book. Further 'input'), there are also internal variables
details of such simulation methods may be which have counterparts in the real system.
found in any of the many available texts Unlike data models, which are based simply
dealing with this specialized area (e.g. refs 1 on observations, system models should incor-
and 2). porate all relevant available knowledge con-
cerning the structure and parameters of the
real system.
1.3 TYPES OF CONTINUOUS-VARIABLE
This book is concerned mainly with models
MODEL
of systems. Models of data may, in some
Mathematical descriptions involving continu- cases, provide a basis for submodels within a
ous variables may be divided, in general larger system description, but for most pur-
terms, into two broad classes. These are poses simulation models of the type being
models of data and models of systems. considered here belong to the class defined
The first of these classes involves math- above as system models. Many subgroups of
ematical descriptions which have been fitted such models can be defined. Some of these
to measured response data. The resulting categories relate to mathematical aspects of
models consist of mathematical functions, the description, while others are concerned
such as polynomials or exponentials, and the more with the field of application.
coefficients or constants appearing in these One of the most fundamental divisions, in
descriptions often have no direct link to rec- terms of mathematics, is between linear and
ognizable elements of the real system. nonlinear system models. In a linear system
Statistical models and other forms of 'black model responses are additive in their effects
box' description come within this class. Such and satisfy the principle of superposition. In
models simply express an observed relation- other words, the output is directly propor-
ship between two or more variables of the tional to the input, and doubling of the input
real system. They have an important role in leads to doubling of the output. In a non-
fields such as control systems engineering linear model the principle of superposition
where input-output descriptions, for example is not satisfied. It is important that questions
transfer functions, can be derived from meas- of linearity should be considered carefully in
urements and can provide a starting point for the initial stages of model development and
design calculations. They tend, however, to that assumptions of linearity should not be
be of less value for the study of problems at made without justification. The range of
the research level since they provide little linear operation of the system, if any such
information about the internal processes of range exists, has to be established by careful
the system. evaluation of what is known about the real
Models of systems, the second of the system or by carrying out additional tests on
classes being considered, are usually devel- the system.
oped by applying established laws and prin- Time invariance is a second important
ciples together with simplifying assumptions property which can provide a basis for classi-
and hypotheses about the structure and func- fication of models of systems. A time-invari-
tion of the system being considered. Such ant system is one in which the observed
models are essentially explanatory in nature performance of the system is independent of
and reflect complex causal relationships. the times at which the observations are made.
Although models of. systems may involve As with linearity, time invariance must be
descriptions in which particular attention is verified in some way before being adopted as
given to relationships between one measured a basis for model formulation.
4 The principles of modeling
Models which are both linear and time careful comparisons with the real system's
invariant are particularly important and behavior, can be of enormous value when
receive considerable attention in most intro- used appropriately.
ductory textbooks in fields such as applied A great deal has been written about mathe-
mathematics, systems engineering, automatic matical modeling methods and principles.
control, electrical circuit analysis and applied Useful texts concerned with general aspects
mechanics. Many practical systems do have of modeling dynamic systems include those
properties which may be approximated in a by Jacoby and Kowalik [3], Jeffers [4] and
satisfactory way by linear time-invariant Spriet and Vansteenkiste [5]. Since this text is
descriptions, even if only for specified and concerned with simulation techniques, rather
restricted sets of conditions. Linear time- than with the fundamentals of modeling, the
invariant models are also very attractive treatment of the model development process
because they can be analyzed using standard is approached in terms of practical issues
mathematical techniques. Nonlinear and which can arise when simulation tools are
time-varying dynamic models present used for developing and evaluating mathe-
far greater difficulty in terms of classical matical models.
mathematical solutions based on paper and The development of a mathematical model
pencil methods. It is for this reason, and for may be described conveniently using the ter-
this very important class of problems, that minology adopted in structured program-
computer simulation techniques have become ming methods in computing science. On one
so important. Computer simulation methods hand, a 'bottom-up' modeling approach
and numerical modeling can provide insight involves starting with a highly detailed
into and solutions to problems for which no description of the system under considera-
analytical solutions are currently available, tion. This incorporates all of the information
except possibly in very special and restricted available about the elements of the system
cases. and allows one to build up a comprehensive
set of equations. On the other hand, a 'top-
down' type of modeling method involves
1.4 MODELING AND SIMULATION
working from a statement of the modeling
PROCEDURES FOR CONTINUOUS-
objectives and leads to the formulation of a
VARIABLE MODELS
model which may involve a significantly
A critical assessment of well-established smaller set of equations. The resulting model
models, which have become accepted and has to be judged in the context of the in-
widely used, shows that they were usually tended application. Although the form of a
developed for specific applications. Such top-down model may be relatively simple at
models have clear boundaries and the under- the initial stages of development, additional
lying simplifying assumptions are well docu- features may be added if the first assessment
mented and fully understood by those using suggests that the model is deficient in some
the models. On one hand, if there are no state- significant way. Modifications are made, in
ments available about the modeling assump- an iterative fashion, until the model is
tions and about the model boundaries, any deemed adequate for the intended applica-
results obtained from a model are of limited tion and can be used with some confidence.
practical value and may possibly be very As already pointed out, useful analogies
misleading. On the other hand, a well- can be drawn between models and maps. A
documented model, which has been devel- political map which shows cities and national
oped for a particular type of application, boundaries may be very useful for many pur-
using an interactive approach involving poses but is of no value if one is interested in
Procedures for continuous-variable models 5
the physical geography of the same area. In unlikely to be adequate for AC studies in the
the latter case one needs a map which shows radio-frequency range. Eventually a point is
all the physical features of the region in terms reached in the modeling of a system of this
of mountain ranges, rivers and lakes. Political kind at which the whole concept of a lumped
boundaries are of secondary importance in parameter model becomes inappropriate and
this case. A combined map which includes it becomes necessary to use a distributed
both physical features and all the information parameter model based on partial differential
on the political map may well be compre- equations. One could then ensure that the
hensive but may not always be the most satis- description of the circuit is sufficiently
factory representation for a given application. general to cover the complete range of fre-
Similarly, the intended application of a model quencies that could possibly be of interest.
has a major bearing on the form which the However, the effort involved in this process
model should take and the aspects of the of developing a truly general model can be
system which are to be included in the mathe- considerable, and a compromise is often pre-
matical description. A fully comprehensive ferred in which the model has a well-defined
bottom-up type of model is not always best. range of validity and applicability. Models
In engineering, models are often developed used outside their valid range give inaccurate
using bottom-up design principles since and sometimes highly misleading predictions
detailed information is available about the of system performance.
characteristics of each element of the system One obvious problem with the develop-
and well-established physical laws and prin- ment of models using the bottom-up approach
ciples can be applied to the formulation of the is that it is difficult sometimes to obtain reli-
model equations. A good example of this is able information about the elements or sub-
the development of a mathematical model for systems. Major simplifying assumptions may
an electrical circuit involving lumped passive have to be made to obtain any kind of quanti-
elements such as resistors and capacitors. tative description, and this is particularly true
Well-known principles of circuit analysis in fields such as biology. In such cases there
(such as Kirchhoff's laws and Ohm's law) may also be problems in assessing the range
provide a simple means of establishing a set of applicability of the model and in carrying
of ordinary differential equations for a given out detailed comparisons with the real system,
network of circuit elements. The resulting since the number of variables in a typical
model may be regarded as valid provided it model may be much greater than the number
is used within the range of frequency and of quantities directly measurable. The physio-
applied voltage for which the description for logical mechanisms of oxygen and carbon
each circuit element is valid. In this respect it dioxide exchange in the human body provide
is important that the person developing the an interesting application which is discussed
model should be aware that the use of Ohm's in Chapter 12. In models of this highly
law in describing a lumped circuit element, in complex system the lungs and the body
terms of the single property known as resis- tissues are conventionally represented by
tance, involves implicit assumptions of linear- uniform compartments. Variables such as the
ity and frequency independence. The modeler concentration of each gas in the lung compart-
must remember that a simple circuit element ments or the blood gas concentrations within
such as a wirewound resistor has other the tissue compartments may not be directly
important properties as well as resistance; the measurable in the real system, and one may
effect of inductance will become significant as therefore have only limited scope for compar-
the frequency is increased and a model devel- ing these aspects of the model with the real
oped for use in DC operating conditions is system. Top-down modeling may, however,
6 The principles of modeling
be quite appropriate for dealing with situa- could be regarded simply as an isolated elec-
tions such as this, with simple models being trical load. Similarly, for a thermal system,
postulated initially and additional features boundaries may be defined at which tempera-
being added as new experimental evidence is tures are constant or independent of heat
accumulated. flow. Such a representation clearly requires
The 'principle of parsimony' is often careful consideration to be given to inputs
quoted in texts on mathematical modeling. that originate outside these predefined
This states, essentially, that models should be boundaries and may have significant effects
kept as simple as possible. The concepts of upon the system within. This may even
top-down modeling are generally consistent require the use of measured quantities from
with this principle. Certainly the inclusion of the real system being converted to digital
unnecessary detail in models is undesirable form and used as variables within the simu-
and leads to an excessive number of para- lation model. This is a topic of particular sig-
meters. Such overparameterization can cause nificance in real-time simulation applications
difficulties in the validation stages of model involving a combination of real-system hard-
development. ware and a simulation model. Examples of
Whatever the approach adopted, it is the use of auxiliary inputs of this kind can be
important to distinguish between simplifi- found in aerospace engineering.
cations involving the elimination of elements Validation is an important and integral part
which have a negligible effect on the overall of the modeling process. In some respects
behavior of the system and those introduced 'model calibration' is a better description of
for mathematical convenience or computa- this aspect of model development. No model
tional speed and efficiency. Although the can ever be completely validated and shown to
choice between complex comprehensive be a perfect representation of the system under
models and simpler models developed for a investigation. However, the performance of a
specific application is often controversial, it is simulation model can be evaluated in terms of
now generally accepted that both the top- equilibrium conditions, stability limits, tran-
down and bottom-up approaches are valu- sient response or frequency response. Findings
able. They complement each other and a of this kind may then be compared with infor-
useful combination of the two approaches can mation from the real system and any differ-
sometimes be achieved by splitting a complex ences assessed in the context of the intended
model into submodels which can be studied, application of the model. Limitations of the
developed and validated independently model can thus be established in terms of that
before being combined. application and, once a model has been 'cali-
Careful consideration of the purpose of a brated' in this sense, it can be used within its
model together with a full and detailed known limitations until new evidence from the
understanding of the real system are essential real system shows that the model is in some
in defining model boundaries. For example, way inadequate for the intended use and
in modeling an electrical generator considera- should be modified. Figure 1.1 is a flow chart
tion has to be given to the representation of which illustrates some aspects of the iterative
the network to which the generator is con- process of model development, testing and
nected. If the details of the current distri- modification.
bution in different parts of the network are of In considering the use of measured system
interest, or if the network incorporates other response data for the testing and calibration of
generators, it may be necessary to include a simulation model it should be noted that the
much more within the boundaries of the model development process may sometimes
model than would be the case if the network involve inverse modeling techniques in which
EXPERIMENTATION MODELING AND SIMULATION

Specify the objectives Specify the modeling


of the experiment.. objectives

t
Define the measurements
necessary to characterize
the system behavior and
Define the model
boundaries r-
~
define the available inputs Define the assumptions and
approximations to be used

rl Design appropriate
experiments
I
Apply physical laws and
principles to formulate
the model equations
Carry out experiments and Estimate values of any poorly-
r+ make measurements defined parameters for the l+-
I chosen model structure
Create a database of Formulate the simulation model
measured responses
I
Implement the simulation
model on a computer
~
Carry out simulation experiments
equivalent to the experiments
on the real system

J
results inconsistent l r~lts incQllsistenl
Compare model and real system
for chosen data sets

resylts satisfactoOl
results inconsistent r~lts mk!lWlistent
Test predictive capabilities
of the model using additional
data sets

results satisfadQot
Apply the model in this form
until new evidence suggests
need for changes

Fig. 1.1 Block diagram of the modeling process showing the links between experimentation and the
stages of model development and checking. In situations in which active experimentation is impossible,
current observations and historical data from the system under investigation may be useful for model-
testing purposes.
8 The principles of modeling
estimates of the structure and parameters of a dinated use of experimental techniques and
model are obtained from measured data. This computer simulation can often provide
involves the use of system identification tech- insight which would be difficult, or impos-
niques, as outlined in Chapter 9 in the special sible, to obtain by conventional experiments
context of model validation. Although details alone. Examples of the use of simulation in
of system identification methods fall beyond this way for the testing of scientific hypo-
the scope of this text, it is appropriate that theses can be found in many different fields.
those using simulation techniques should be Problems in biomedical engineering, espe-
aware that such methods exist and that they cially the application of control engineering
should have some understanding of their concepts to the investigation of physiological
potential. In addition to providing a basis for control systems, provide interesting examples
one approach to model testing, they provide of this. The respiratory control system, which
an approach to the problem of establishing involves the pulmonary gas exchange pro-
values for model parameters which are not cesses already mentioned, is one complex
known from theory. Examples of fields in physiological system which has been studied
which system identification techniques are extensively using simulation techniques to
recognized as established tools for model test hypotheses. Respiratory control was in
development and calibration include the fact one of the first biomedical engineering
development of ground-based aircraft flight problems to which continuous system simu-
simulators and the development of simula- lation methods were applied. Although this is
tions for biomedical applications such as a biological problem, the main features of this
anesthesia. application are typical of those encountered
In the modeling of engineering systems it is in the modeling of physical and chemical
often possible, and usually desirable, to estab- processes in other application areas.
lish a close link between elements of a model The respiratory control system can be
and the corresponding components of the real divided conveniently into a 'plant', which
system under investigation. However, even in comprises the gas transport and gas exchang-
some engineering applications, this cannot be ing processes of the lungs, circulation and
done initially because of uncertainties in the tissues, and a separate 'controller', which
quantitative information available about the involves various chemoreceptors and other
system. One objective in applying system sense organs which provide the neural 'drive'
identification techniques in such cases may be to the muscles responsible for breathing.
to help select one representation from a Figure 1.2 shows a much simplified block
number of candidate models. This is closely diagram of the system as it is understood at
linked to the idea of model calibration and present.
emphasizes yet again the fact that the devel- Many early simulations of the respiratory
opment process involves a sequence of steps control processes could provide reasonably
and may require several iterations as the accurate predictions of some aspects of the
model is tested and refined. system's performance but some difficulties
The type of application for which a model remained. One area which presents particular
is being developed always has a considerable problems is the respiratory center, which
influence on the form of the model itself. For combines and processes signals from the
example, in a research environment, mathe- various sensory receptors within the system.
matical models may be studied using simu- Indeed, most studies have avoided many of
lation, together with experimental results, as the complications of the respiratory center
part of a process of testing hypotheses about because detailed quantitative data about
a real system. Results obtained from the coor- some aspects of this part of the system are
Procedures for continuous-variable models 9

BRAIN
COMPARTMENT

I_ feedback pathways
I from
I chemoreceptors

~-PT:V --: 1
CONTROLLER r4- - -
I
I
-f - - - - - - - 1-I
I I
feedback pathways
I I drive signals to
muscles of chest,
from I diaphragm etc.
mechanoreceptors
in chest etc. I
I
I
LUNGS

circulation
---

COMPARTMENT
REPRESENTING OTHER
BODY TISSUES

Fig. 1.2 Highly simplified block diagram of the respiratory control system, which is responsible for the
regulation of breathing. Two types of feedback pathway are shown in this diagram: (1) feedback to the
respiratory centre from chemoreceptors which sense concentration levels of oxygen and carbon dioxide
in the blood and tissues and (2) feedback from other receptors associated with the lungs and chest, such
as the mechanoreceptors responsible for sensing the extension and velocity of the muscles which are
active during breathing.
10 The principles of modeling
still lacking. However, a number of models trast to a more detailed representation in
have been developed which have provided a which the neuromuscular elements are
means of assessing competing hypotheses included. In making decisions about model
concerning interactions between the neural boundaries such as these it is essential to keep
and chemical components of respiratory in mind the intended application of the model
control. Many problems are still unresolved, and the measurements likely to be available
especially in terms of the response of the for model testing and validation. One impor-
system to exercise, and simulation techniques tant factor is that some system variables, such
continue to have an important role in this as gas concentrations at the mouth and gas
field of bioengineering research. flow rates, are accessible for direct measure-
The respiratory system provides other ment on a continuous basis. Other variables,
useful illustrations of some of the modeling such as blood gas concentrations, are less
and simulation problems which have already readily measured.
been touched on in this introductory chapter. While some fundamental physiological
The first of these concerns model boundaries. problems concerning respiratory control
Physiological systems are highly interactive, remain unsolved, respiratory system models
and it is seldom possible to consider one are now beginning to receive attention in the
element in isolation. The study of the respira- context of clinical research and in the design
tory system requires understanding of the gas of medical hardware to provide breathing
transfer and exchanging processes in the functions artificially. Even quite simple simu-
airways, lungs, blood and tissues. The ques- lation models of the respiratory control
tion of boundaries is therefore a complex one system can exhibit maintained oscillations
which must be reviewed constantly through- which appear as periodic patterns of breath-
out the model development process. What ing similar to well-known clinical conditions.
level of complexity is appropriate for repre- Although the above example, which has
sentation of the airways and gas exchanging provided a convenient preliminary illustra-
regions of the lungs? How many lung com- tion of some of the processes of development
partments should there be? Are these lung of a simulation model, relates to a biological
compartments in series or in parallel? What system, the principles are quite general.
level of complexity is needed to represent the Decisions also have to be made about bound-
circulation and body tissues? How many aries in approaching the modeling of physical
lumped tissue compartments should be systems. The model structure is often no more
included in a model intended for respiratory obvious in complex engineering systems than
control system studies? How should breath- it is in this biomedical example. Similarly, the
ing be represented? Do we include the action availability of measurable output quantities
of the respiratory muscles or do we draw the for the purposes of model testing and valida-
model boundaries so that ventilation (the tion may often present problems in engineer-
flow of gas into and out of the upper airways) ing applications which are just as difficult to
is a model input? In the last case the neuro- solve as in the biological case. One vitally
muscular drive may be represented in an important point is that, whatever the field of
implicit fashion by a quantity which alters the interest, the development of a simulation
amplitude and frequency of a periodic wave- model must be undertaken in the context of a
form representing ventilation, and a consider- particular application and must be an itera-
able simplification results in terms of the tive process involving a rigorous testing and
structure and complexity of the model in con- evaluation stage.
References 11
REFERENCES Mathematical Modelling with Computers,
Prentice- Hall, Englewood Cliffs, NJ.
1. Neelamkavil, F. (1987) Computer Simulation 4. Jeffers, J.N.R. (1982) Modelling, Chapman &
and Modelling, John Wiley, Chichester. Hall, London.
2. Pritsker, A.A.B. (1984) Introduction to Simulation 5. Spriet, J.A. and Vansteenkiste, C.c. (1982)
and SLAM II, 2nd edn, John Wiley, New York. Computer-aided Modelling and Simulation,
3. Jacoby, S.L.S. and Kowalik, J.S. (1982) Academic Press, London.
AN INTRODUCTION TO SIMULATION
METHODS 2

2.1 THE NEED FOR SIMULATION Analog principles have been very widely
used for a very long time for the investigation
Simple mathematical solutions can be found of complex nonlinear phenomena. For
for linear ordinary differential equations example, active electrical networks which are
having constant coefficients. Such equations analogs, or models, of some other equivalent
form the basis of many well-known and very physical system can be established readily.
useful lumped parameter models. Intro- Conclusions reached on the basis of simula-
ductory courses in dynamics and in electrical tion experiments on the electrical network
circuit theory provide many illustrations of should then apply to the original system of
models of this type. For example, transients in interest. The use of an analog of this kind
simple electrical circuits involving linear ele- makes it relatively easy to set up the modet
ments such as ideal resistors, capacitors and and to carry out experiments which might be
inductors can be studied very easily using impossible, or at least difficult and time-con-
standard analytical tools for the solution of suming, on the real system. Wind tunnel
ordinary differential equations. Concepts such models and models used in ship testing tanks
as the complementary function, particular provide two other examples of this kind of
integrat D-operator and Laplace transform approach based on the study of analogous
are of considerable importance for problems systems.
of this type, but such analytical tools are of no With conventional digital computers,
use in the case of many practical problems advantage may be taken of the many
involving nonlinear models. For example, general-purpose computer-based numerical
analytical methods are of little assistance if an tools which are now available for continuous
inductive element in an electrical circuit has a system simulation. Although, in principle, any
core of magnetic material and displays general scientific programming language may
significant hysteresis. Similarly, in dynamics, be used for the numerical solution of differen-
linear mechanical systems involving elements tial equations, the use of special-purpose
with mass, spring stiffness and viscous resist- simulation software tools can be very helpful
ance provide a basis for much elegant mathe- in many practical situations and can eliminate
matical analysis which can provide valuable many of the computational difficulties associ-
understanding. Replacement of a viscous ated with writing a simulation program.
damping element by an element with static These special-purpose tools are particularly
friction immediately makes the problem non- appropriate when used in an interactive mode
linear and eliminates the possibility of apply- and allow the user to concentrate attention on
ing standard mathematical techniques. In the model instead of having to struggle with
cases where analytical methods are impracti- computational methods and the technical
cal the only possible approach is through problems of getting meaningful numerical
numerical techniques of some kind or by the results. Simulation is essentially a process of
use of an analog method. experimentation with mathematical models
14 An introduction to simulation methods
and in any experimental situation good inter- train performance with different loads and
action between the experimenter and the gradient profiles.
experiment itself is of vital importance. Good The development of the electronic analog
simulation tools provide good facilities for computer during the period from about 1945
user interaction. to 1955 provided a vitally important stimulus
Simulation software tools for distributed to the field of simulation and introduced tools
parameter models, involving partial differen- that could be translated into hardware which
tial equations, are less well developed than was sufficient reliable and accurate for use in
those for lumped parameter descriptions, large-scale engineering studies. Examples of
involving ordinary differential equations. the use of electronic analog simulation
Although some ,simulation tools do exist for methods can be found in many accounts of
problems involving some special classes of aerospace projects in the 1960s, in the nuclear
partial differential equations, this book deals industry at that time, in the field of chemical
mainly with simulation applications involv- process control and in many other areas of
ing lumped parameter models. engineering. The essential idea in the elec-
tronic analog computer is that electrical volt-
ages or currents can be used to represent
2.2 METHODS OF SIMULAnON
other physical variables in the system under
Simulation may be performed using special- study. The electronic operational amplifier
purpose hardware, or using a general-purpose can form a computational block, which can
computer. Both of these approaches are impor- either take the algebraic sum of these electri-
tant, and the simulation methodology adopted cal quantities or act as an integrator, again
depends very much upon the application area. operating on the electrical analogs of the real
physical variables of the original problem.
Other electronic elements can act as units to
2.2.1 TECHNIQUES BASED ON
multiply variables by constants or to form the
SPECIAL-PURPOSE SIMULA nON
product of two variables. Similarly, there are
HARDWARE
active electronic analog elements which can
The earliest developments in continuous- carry out tasks such as division of one vari-
system simulation were based mainly upon able by another, the determination of a square
special-purpose simulation equipment such root, the representation of some arbitrary
as a mechanical differential analyzer. This function of a given variable or simple logical
type of mechanical computer system involved operations such as comparing the magnitude
operations which were based entirely on of one quantity with another. The intercon-
mechanical principles. For example, the oper- nections between the operational elements are
ation of integration could be based on the fact established by the user, and it is these inter-
that angular position is the integral of angular connections that determine the set of equa-
velocity. Although the mechanical type of dif- tions represented on the analog computer.
ferential analyzer was cumbersome and Considerable ingenuity was shown in the
difficult to use, it was applied to the success- design of commercially available analog com-
ful solution of some very important problems puters to ensure that the user interface was
both prior to and during the Second World suitable and convenient. Much emphasis was
War. Early published accounts of practical also placed on the presentation of results in
uses of this type of simulation computer graphical form. One very important point
include descriptions of applications involving about the analog computer is that such a
the prediction of target position in gun- system is inherently parallel in terms of its
aiming mechanisms and the calculation of internal organization. Since every operation,
Methods of simulation 15
such as integration, multiplication or sum- pure delays and other operations which were
mation, is carried out using independent difficult to implement using analog hardware
hardware elements, the individual processes alone. The principles of hybrid computation
required to form a solution are performed led to the development of some very power-
simultaneously. This gives the electronic ful systems, many of which were-used in
analog computer important benefits in terms dedicated applications within the defense
of speed of operation since the overall speed industries in the 1960s and 1970s.
of the simulation is independent of the size of Although analog and hybrid computers
the problem. The main practical limitation in have ceased to be important as general-
terms of speed of operation of an analog com- purpose simulation tools, small analog
puter is imposed by the finite bandwidth of systems can still be very useful in the solution
the active electronic components, such as of real-time simulation problems. This is
operational amplifiers. In principle, when especially true of simulation studies which
designed with high-bandwidth components, involve real hardware and a simulation
an analog computer can provide performance, model working together in an integrated
in terms of speed, which is still hard to match fashion. Such situations arise frequently in
in simulation applications by even the most the testing of engineering systems. One very
powerful digital computers available today. good example is the evaluation of a control
Problems with analog simulation tech- system which incorporates digital processors
niques, as implemented using 1960s tech- within a feedback structure. The control hard-
nology, lay in the high cost of the hardware ware and software might be tested initially in
and the fact that such computers had no the laboratory using a simulation of the plant
applications other than simulation. Other prior to being installed on site. In this type of
difficulties, which were significant in some situation, interfacing the control system to an
applications areas, included the fact that the analog computer simulation can allow checks
programming of analog simulation problems to be made in a realistic way and may help to
was time-consuming, relatively complicated [Link] errors in the system prior to com-
and required specialist skills. In addition, the missioning on site. Similarly, in laboratory
relatively low accuracy of analog computers work of various kinds, small analog comput-
was an important factor which counted ers (or equivalent special-purpose electronic
against this technology for some types of hardware based on operational amplifiers)
application. The low reliability of early can provide a flexible and low-cost way of
analog computer hardware also raised impor- applying control or carrying out signal pro-
tant issues in terms of maintenance and oper- cessing operations such as multiplication of
ating costs. signals or filtering. Analog methods are
In order to try to overcome the acknow- discussed in more detail in Chapter 14.
ledged limitations of analog computers, the Some developments in the 1970s, such as
manufacturers of simulation computers those at the Technical University of Vienna,
decided to try to combine the best features of where a very powerful multiuser hybrid sim-
conventional serial digital computers with the ulation facility was developed [2], demon-
best features of analog systems [1]. This led to strated the potential of hybrid principles.
what became known as the hybrid computer. However, by that time, major developments
The digital part of a hybrid system was gener- were taking place in the fields of digital hard-
ally used to control the operation of the simu- ware and software. Conventional digital
lation on the analog part of the system, to set computers were becoming ever cheaper and
up and check the analog elements and to more powerful and new concepts were
provide capabilities for function generation, leading to specialized digital systems which
16 An introduction to simulation methods
had architectures designed more specifically Project Whirlwind computer at MIT was
for simulation. This allowed digital machines developed for real-time simulation of flight
to be used in real-time simulation problems, vehicles. Calculations in these machines were
such as flight simulation of aircraft or missile all based on fixed-point arithmetic but, by
systems, in place of analog or hybrid comput- modern standards, were extremely slow. It
ers. Such specialized digital systems could be is worth noting that, although the first gener-
significantly less costly than a large conven- ation of electronic analog computers could
tional digital computer of power sufficient to simulate aircraft and missiles in real time,
deal with the specialized demands of this digital computers could not approach this
type of application and also easier to use and level of performance until about 10 years
less expensive to maintain than most hybrid later. Subsequent developments in digital
systems. computer technology led to very significant
Dedicated special-purpose digital systems increases in speed and the introduction of
continue to be used for some simulation high-level programming languages, such
applications. Considerable efforts have been as Fortran, made digital computers more
made in recent years to produce software accessible to many potential simulation users.
which is appropriate and allows users to For lumped parameter models, traditional
exploit fully the potential of such specialized continuous system simulations are essentially
systems. For example, Applied Dynamics numerical solutions of sets of ordinary differ-
International have produced a series of ential equations. The programming task can
special-purpose digital systems for real-time be approached in a number of ways, includ-
applications and other numerically intens- ing coding from first principles in a general-
ive simulation tasks. Such special-purpose purpose high-level language such as Fortran,
hardware systems require special-purpose Pascal or C. An alternative is to write the
high-level software to allow full advantage program in a general-purpose language but to
to be taken of the speed capabilities which make as much use as possible of an appropri-
are available [3]. Many highly specialized ate library of standard numerical methods
and fully dedicated real-time simulation subprograms such as the NAG [4], IMSL [5] or
applications have been based on computer 'Numerical Recipes' [6]. One important
systems such as these. Other real-time tasks, benefit from using a well-established sub-
such as those involved in piloted flight simu- routine library is that the numerical methods
lation, have also been approached using routines are generally well documented and
multiprocessor architectures based upon much experience has been accumulated in
more conventional computer hardware. their use for many types of application.
These and other aspects of this specialized Provided that the available routines are used
area of simulation are discussed in more with care, and within their published limita-
detail in Chapters 14 and 15. tions, they offer a reasonably efficient and
effective means of generating simulation pro-
grams using a general-purpose high-level pro-
2.2.2 TECHNIQUES BASED ON
gramming language. This approach has been
GENERAL-PURPOSE COMPUTER HARDWARE
used in some special-purpose simulation soft-
Some of the earliest developments in digital ware packages. These consist of a library of
computer technology were associated with routines commonly required for simulations
problems which would now be regarded as applications, and the user must supply a main
simulation applications. The US Army program which defines the model and experi-
EN lAC computer was used in the late 1940s ment, with appropriate calls to the numerical
to solve ballistic trajectory problems, and the subprograms as and when required.
Methods of simulation 17
Simulation languages differ from the simu- provided for interaction with the simulation
lation packages described above in that they problem while the computer was running.
involve coding at a higher level. A simulation The presentation of results was, at best, in the
language should allow the user to write a form of simple graphs, the particulars of
simulation program using a natural form of which had usually to be defined prior to the
application-oriented language and provide a start of a simulation run.
more user-friendly form of environment than Developments in the power of personal
is possible for the nonspecialist programmer computers and workstations has changed the
using general-purpose programming lan- situation considerably in terms of the user-
guages and associated numerical libraries. computer interface and has made truly inter-
The development of specialized simulation active digital simulation possible for many
software for general-purpose digital com- application areas. The availability of the
puters began as a conscious attempt to windows type of environment and of mouse-
represent, on a digital machine, the basic driven software has led to a revitalization of
operations which were possible on an analog block-oriented methods as an alternative to
computer. Examples of early attempts to the equation-oriented approach. The use of
produce software capable of carrying out modern post-processing techniques also
such digital simulations include the DAS offers far more flexibility for the presentation
program, which was followed by MIDAS. of graphical results on a personal computer
Brennan and Linebarger [7] have provided than was available in any of the early simula-
an interesting review of these very early tion languages running on large mainframe
developments in simulation software. These computers. The move from mainframe
tools were generally block oriented and the systems and multiuser minicomputers to
user built up a program to represent, on single-user personal systems has thus
the digital machine, the function of the equiv- brought major benefits in terms of the possi-
alent analog computer diagram showing the bilities for efficient interaction between the
interconnections between the operational user and the simulation problem.
units. It is now generally accepted that a good
MIMIC was an early language which simulation environment should allow models
departed from the block-oriented tradition to be set up and modified quickly and easily
and adopted an equation-oriented format and should permit efficient interactive experi-
which was followed, with variations, by mentation. It should be capable of releasing
many other languages. This approach simulation model developers and users from
involved defining the simulation model much of the detailed coding, and thus allow
directly in terms of the differential equations them to use their time effectively by concen-
of the underlying mathematical model. In trating attention on the model and its behav-
1967 the Society for Computer Simulation, ior. While incorporating many powerful
which at that time was known as Simulation facilities, user-friendly software should gen-
Councils Inc., published a proposed standard erally keep advanced features hidden from
for continuous simulation languages [8], the user until they are actually needed. A
which has formed a basis for many subse- good software system should thus be seen as
quent developments. This standard, which is an appropriate tool by users at many differ-
based upon equation-oriented principles, is ent levels of experience and expertise.
discussed in more detail in Chapter 6. The effectiveness of an interactive simula-
Much of the early software was batch ori- tion depends critically upon whether or not it
ented and relatively inconvenient to use in a is compatible with the typical timescale of
simulation environment. Few facilities were human activities. User-friendly simulation
18 An introduction to simulation methods
software should provide fast keyboard in testing hypotheses or as a means of
responses, fast program translation and fast expressing all of the available knowledge
solution of the model equations. Any exces- about the properties of a complex dynamic
sive delays at the translation stage or at system in a concise and consistent fashion.
runtime can greatly reduce the productivity of The process of building up a simulation
the computer system and of its user and have model can also highlight gaps in existing
an adverse effect on his or her creativity. For knowledge and lead to a search for additional
this reason modern stand-alone workstations information.
and personal computers (especially when It is useful to distinguish between a simula-
equipped with a numeric co-processor) often tion run, which is a term used to describe a
provide a much more effective environment single solution of the model equations, and a
for interactive simulation than multiuser time- simulation study, in which several simula-
sharing computer systems. tion runs are performed and further analysis
In addition to general-purpose simulation is carried out on the basis of the multiple run
languages and packages, a significant number results. Modern commercial simulation soft-
of special-purpose software tools have been ware systems are increasingly being designed
developed for particular applications areas. to provide facilities for simulation studies and
These include software for simulation of elec- have powerful post-processing and graphics
trical and electronic circuits, software for presentation options available or can be
chemical process simulation, software for linked to appropriate computer-aided analy-
simulation of electrical power systems and sis and design packages. Simulation studies
software for simulation of hydraulic and may, for example, be concerned with model
fluid-power control systems. None of these optimization, with sensitivity investigations
specialized aspects of simulation software is to establish the effects of a change in a para-
considered in detail in this book. Further meter, or perhaps with an investigation of
information about these applications can be conditions under which the model becomes
found in more specialized texts (e.g. refs 9 unstable. Although such studies are often
and 10). numerically intensive in nature, and require
high speeds of solution for any interactive
investigation, results obtained by manipulat-
2.3 A REVIEW OF SIMULA nON
ing a simulation model can often provide evi-
APPLICA nONS
dence which would be difficult to obtain by
It has already been pointed out that simula- conventional experimentation alone.
tion may be viewed as a process of experi- Figures 2.1 and 2.2 show flow charts illus-
mentation with mathematical models. This is trating two ways in which models can be
true in the context of both scientific and en- used in the testing of hypotheses [11]. In
gineering applications. In both these fields, Fig. 2.1 a new finding from an experiment on
simulation techniques are especially useful the real system leads to the formulation of a
when the models are nonlinear in form or are hypothesis. Investigations based on a simula-
to be used in real time. In such cases there is tion model and the experimental results,
seldom any alternative to the use of a numeri- taken together, may provide support for the
calor analog type of solution. hypothesis or lead to its modification or rejec-
Simulation applications are very varied, tion. Rejection of the hypothesis may lead to
and the precise approach adopted depends modification of the model or to a new
on the objectives and purpose of the investi- hypothesis which is, in turn, investigated in
gation. For example, models used in scientific the same way. In Fig. 2.2 the hypothesis is
investigations are often developed as an aid based on findings from experiments on the
A review of simulation applications 19

Experiment

t
Examination of experimental
results in terms of
qualitative model

~
Formulation of hypothesis

~
Development of quantitative
mathematical model

+
Correlation of experimental findings
and hypothesis
using mathematical model

I I
+ t
~ Hypothesis supported I Hypothesis rejected I
Fig. 2.1 Flow chart illustrating processes involved in the formulation of a hypothesis from new experi-
mental or observational findings.

simulation model. The model is, in this case, even using a desk-top personal computer of
being used predictively, and new experi- relatively modest power. Further enhance-
ments are needed to provide supporting evi- ment of the interactive capabilities of simula-
dence from the real system. Again, the tion systems is still desirable in order to
process may lead to modification of the create an environment in which complex
model or to a new hypothesis. Practical inves- models can be developed and optimized in a
'tigations can often involve a combination of more natural and user-friendly way. This also
the approaches outlined in these two flow implies careful integration of a number of dif-
charts. In an iterative process of this kind ferent systems, such as databases for experi-
there is a need for a man-machine interface mental records and simulation results,
which allows a close and natural form of graphics packages for the presentation of
interaction to be established between the sim- results, analysis software for any associated
ulation model and the user. Modern simula- numerical operations, as well as the simula-
tion software and hardware can provide an tion software itself. Developments in expert
environment in which many problems can be systems and other areas of artificial intelli-
handled efficiently in an interactive fashion, gence may also be of importance in providing
20 An introduction to simulation methods

Simulation experiment
on mathematical model

Assessment of model
behavior

Formulation of hypothesis

Use of simulation model


for design of
new experiment on
the real system

New experiment

Correlation of experimental findings


and hypothesis

I I
t t
I Hypothesis supported ~ Hypothesis rejected I
Fig. 2.2 Flow chart illustrating processes involved in the formulation of a hypothesis from examination
of model behavior.

a basis for intelligent help systems and deci- extract new information which may be incor-
sion aids to guide the less experienced user. porated into an improved model and thus
Simulation may also be required to provide simulation results which are in closer
compare possible experimental strategies or accord with reality. In this type of application
to help with the design of experiments on the simulation again forms an element which is
real system to maximize the information central to the overall scientific method.
content of extracted data. From optimized In engineering design applications simula-
experiments of this kind it may be possible to tion has a role which is often predictive.
References 21
Simulation may be used because no possibili- assessed in this way is by means of a nonlin-
ties exist for experimentation on the real ear simulation model. In the case of the heli-
system. This may be because the system is still copter application this nonlinear simulation
at the design stage or because experiments study would normally include assessments
may not be permissible because of operating carried out using real-time methods in a
requirements or safety constraints. ground-based piloted flight simulator facility.
The field of automatic control systems pro- Simulation models have another type of
vides many good examples of engineering application that is important in engineering
applications in which simulation has a central and in many other fields. This concerns edu-
role within the design process. Control cation and training. Many systems are both
systems are normally designed on the basis of dynamic and complex, and it is often difficult
a linearized description which is valid only to gain an understanding of them from a
at a single given operating condition. written description or from an experimental
Assessment of performance, on the other investigation. A well-planned simulation
hand, frequently requires investigation of the exercise carried out in parallel with experi-
performance of the complete control system mental studies can provide detailed under-
over a range of operating conditions. This is standing where the other methods, used
necessary in order to assess the overall alone, may be more limited in potential. For
robustness of the control system design and example, physiological systems are both
to be able to make predictions regarding per- complex and dynamic. A simulation model of
formance limits. a physiological system, which has been tested
The design of flight control systems for a adequately and is accepted as a credible rep-
helicopter is an interesting example in which resentation, can therefore be used as an edu-
the dynamics of the vehicle changes consider- cational tool. Students can alter the model,
ably with the flight condition. A control often in ways which would be impossible
system designed on the basis of a linearized using conventional experimental methods,
vehicle model to meet particular performance and immediately observe what happens.
requirements in terms of lateral and longitu- Many examples of simulation are now to be
dinal dynamic response at hover could have a found in medical education. The MACPUF
very different performance for fast forward simulation is one of the best known [121.
flight. To be able to undertake an investigation
of system performance in such cases it is not
usually enough to test the control system with REFERENCES
a series of linearized models of the system
1. Bekey, G.A. and Karplus, W.J. (1968) Hybrid
being controlled. Clearly, a new linearized Computation, John Wiley, New York.
description could be used for each flight con- 2. Kleinert, W., Solar, D. and Berger, F. (1983)
dition and the designer could obtain some Status report on TV Vienna's hybrid time
information about the robustness of the com- sharing system, in Proceedings of the 1st European
plete system from linear analysis applied at Simulation Congress, September 1983, Aachen
each point. However, the results would Onformatik-Fachberichte 71), (ed. W. Ameling),
provide information only about the dynamics Springer, Berlin, pp. 193-200.
3. Van Schieveen, H.M. (1986) The System 100-
of the complete system for small perturbations an efficient hardware/software architecture
about each nominal flight condition. Often for real-time and time-critical simulation, in
one is also interested in the response for large Proceedings of the 2nd European Simulation
disturbances or large command signals, and Congress, September 1986, Antwerp, Simula-
the only way in which a design can be tion Councils, Ghent, pp. 413-19.
22 An introduction to simulation methods
4. NAG (1987) Fortran Library Manual, Mark 12, 9. Bowers, J.e. and Sedore, S.R. (1971)
NAG, Oxford. SCEPTRE. A Computer Program for Circuit and
5. IMSL (1987) Library Reference Manual, Version Systems Analysis, Prentice-Hall, Englewood
1.0, IMSL, Sugar Land, TX. Cliffs, NJ.
6. Press, W.H., Flannery, B.P., Teukolsky, S.A. 10. Spriet, JA and Vansteenkiste, G.e. (1982)
and Vetterling, W.T. (1986) Numerical Recipes, Computer-aided Modelling and Simulation,
Cambridge University Press, Cambridge. Academic Press, London, Chapter 6.
7. Brennan, R.D. and Linebarger, R.N. (1964) A 11. Pack, A.I. and Murray-Smith, D.J. (1972)
survey of digital simulation: digital analogue Mathematical models and their applications in
simulator programs. Simulation, 3 (6),22-36. medicine, Scottish Medical Journal, 17, 401-409.
8. The Simulation Software Committee of 12. Dickinson, e.J. (1977) A Computer Model of
Simulation Councils Inc. (1967) The SCi con- Human Respiration, MTP Press, Lancaster.
tinuous system simulation language (CSSL).
Simulation,9 (6), 182-203.
PROBLEM ORGANIZATION FOR
CONTINUOUS SYSTEM SIMULATION 3

3.1 INTRODUCTION include block diagrams, signal flow graphs


and bond graphs. All of these show, in dia-
Careful organization of the information avail- grammatic form, the mathematical operations
able regarding a system and any associated to be performed and the order in which infor-
mathematical models is of great importance mation must be processed. Transfer functions
as a first step in the development of a simula- may provide a more natural form of descrip-
tion. This information must include a state- tion than an equivalent set of ordinary differ-
ment concerning the intended application of ential equations in the case of linear models
the simulation and the reasons for undertak- or submodels. The form of description chosen
ing the investigation. The data to be used in depends considerably upon the field of appli-
establishing values of constants in the simula- cation for the simulation and upon the con-
tion model must be thoroughly assessed since ventions commonly adopted in that area.
the value of the simulation will be highly Several commonly used types of description
dependent on the error bounds and other are introduced in this chapter.
uncertainties associated with the numerical Once the general and specific objectives of
values of these quantities. There is little point the study have been established and decisions
in obtaining simulation results to a very high have been made concerning the necessary
degree of accuracy if the parameters of the accuracy of the simulation results, the process
underlying model are known only to within of simulation program development can start.
20% or 30%. Careful assessment of the source This normally begins with a statement of the
data in this way also ensures that any omis- equations or the preparation of equivalent
sions or inconsistencies are spotted at an early diagrammatic descriptions. The equations or
stage, thus allowing steps to be taken to diagrams must be written down initially with
obtain further data if necessary, without as much detail included as possible. Depend-
delaying the development of the computer ing on the type of application being consid-
implementation. ered it may well be possible and appropriate
Many methods exist for recording the to make significant simplifying assumptions
details of a model on paper. Sets of ordinary at a later stage in the development of the sim-
differential equations and algebraic equations ulation. However, it must always be remem-
are clearly of central importance in lumped bered that terms which are left out of the
parameter dynamic models. However, there mathematical model deliberately at any stage
are a number of other forms of description of the simulation development process may
which are very commonly used, and these have to be reinserted later on if problems
must be understood in order to allow most arise in the model checking and validation
effective use to be made of the available stages. Careful assessment and documenta-
mathematical and simulation tools. These tion of simplifications made in the early
24 Problem organization for continuous system simulation
stages of model development may therefore f
be of considerable importance later.
It is important to realize that there are
always many ways of solving a given simula-
tion problem. It is also important to select a
good approach. For example, when working M
with a given mathematical model it may be
useful to alter the form of the model equa-
tions to make them more suitable for
computer solution. Some forms of model
description are known to be likely to intro-
duce problems because solutions are over-
sensitive to small changes in certain para-
meters within the equations. Transformation
of the model to another, mathematically Fig. 3.1 A schematic diagram of a mechanical
system involving mass, spring and viscous resis-
equivalent, form may well reduce such sensi- tance elements.
tivity problems. Developing an ability to spot
problems such as this in advance is part of the
art of simulation. Such skills are best learned tional motion are of considerable importance
through practical experience, but a few of the to the investigation of vibration problems in
difficulties that can be encountered in tack- engineering, such as the design of vehicle sus-
ling practical simulation problems are high- pension systems, turbine-generator shaft
lighted in later sections of this book. unbalance problems or drive systems for
robot arms. The corresponding description in
state-variable form involves two first-order
3.2 DESCRIPTIONS FOR CONTINUOUS-
equations in place of the single second-order
VARIABLE MODELS: REDUCED AND
equation. It takes the form
STATE-VARIABLE FORMS
Many different forms of mathematical (3.2)
description are possible for the representation
of a given dynamic system. Two of the most
(3.3)
widely used are the so-called reduced form
and the state-variable form. An example of a
simple model expressed in reduced form is where the new variable Xl is the displacement,
the equation y(t), and the new variable X z is the velocity,
dy / dt. These new variables are known as the
My + Ry + Ky = [(t) (3.1) state variables of the system. An nth order
description in reduced form is equivalent to
which is the differential equation commonly a set of n first-order ordinary differential
used to represent the mechanical system of equations in state-variable form.
Fig. 3.1 involving the displacement, y(t), of a In general, the state-variable form of model
mass M suspended by means of a linear description is found to be very convenient for
spring of stiffness K and damping element simulation, while the reduced-form descrip-
having viscous resistance R. The mass is sub- tion is more appropriate when the model is
jected to an external force [(t)o being studied analytically. There is no unique
Models of mechanical systems of this kind set of state variables for a given model in
and of equivalent systems involving rota- red uced form.
Conversion from reduced form to state-variable form 25
Physical reasoning can often provide a simply by a process of integration. In other
basis for making a sensible choice of quanti- words, the right-hand side of each state
ties to be defined as state variables. In the equation is the derivative of one of the state
case of the mechanical system of Fig. 3.1 it is variables. A second-order system, with two
fairly clear that the selection of displacement state variables, thus requires two integration
and velocity has advantages over other pos- operations in the corresponding simulation
sible sets of state variables. Displacement is a program; an eighth-order model, with
variable of particular interest in the model eight state variables, would require eight
and is also likely to be a measured quantity integrations.
in the real system. Velocity is also likely to In the more general case of a nonlinear
be a measurable quantity. Information con- model the state-space model would have the
cerning the position and velocity at any form
instant of time is in fact sufficient in this
problem to allow the subsequent behavior of x= nt, x(t), u(t)] (3.6)
the system to be predicted exactly, given where f now denotes the vector of derivative
information about the input forcing f(t) functions and u(t) is the input.
which is to be applied. This is consistent
with the fact that in the analytical solution of
a second-order linear differential equation, 3.3 CONVERSION FROM REDUCED FORM
such as equation (3.1), initial conditions TO STATE-VARIABLE FORM
must be defined for two of the terms on the
There are many ways of changing a model
left-hand side of the equation (y and dy / dt,
in this case). which is derived, or given, in reduced form to
The two-dimensional vector having com- state-variable form. If, for example, the model
ponents Xl and X 2 is known as the state vector. is initially in the form
The importance of the state vector is that, if d"y [ dy dn-ly ]
the initial state is defined and the system - = f t, y'-""'--l ,u(t) (3.7)
dt" dt dt-
inputs are known, all future states are
defined. The two equations defining the state- where u(t) represents an input forcing func-
space model above can be rewritten as a tion and f is a given linear or nonlinear func-
single-vector matrix equation tion, it is always possible to convert the
model to state-space form by selecting the fol-
lowing as the state variables

or, more concisely, as


x= Ax+bu (3.5)

where x is the state vector, A is a 2 x 2 square


matrix and b is a two-element column
vector. This equation relates the rate of
d n- 2
dt"-~
change of the state to the present state and
the input. It is a form which is particularly X"-l =
convenient for simulation purposes since the
d n- l
numerical solution can then be obtained for X =--y (3.8)
each equation within the state-space model n dt
n l -
26 Problem organization for continuous system simulation
In physical terms, in the case of a mechanical model allows a given differential equation to
system, this might involve selecting position, be transformed into the Laplace domain
velocity, acceleration, etc., as the set of state simply by replacing d/ dt by 5, d 2 / de by 52
variables. The state-space description resulting and so on for higher derivatives. This process
from this choice of state variables has the form converts the differential equation into an
algebraic equation in the Laplace variable s.
Subsequent analysis is all carried out in terms
of algebraic relationships, which both simpli-
fies the mathematical operations which have
to be performed and can also provide oppor-
tunities for additional physical insight. For
example, the mass-spring-damper system
defined in equation (3.1) transforms to
(3.9) MS2(S) + RsY(s) + KY(s) = F(s) (3.10)

It has already been emphasized that the where yes) is the Laplace transform of yet),
choice of state variables is never unique. F(s) is the Laplace transform of f(t) and all
Hence the state variables in this approach initial conditions on yet) and its derivatives
may be numbered in any order. are zero. The quantity yes) can then be manip-
ulated algebraically to give
3.4 TRANSFER FUNCTION DESCRIPTIONS (Ms 2 + Rs + K)Y(s) = F(s) (3.11)
Linear models, expressed in terms of ordinary and thus
differential equations, can also be written
very conveniently as transfer functions, yes) 1
= (3.12)
defined as the ratio of the Laplace transform F(s) MS2 +Rs+K
of the model output variable to the Laplace
transform of the input when all initial condi- In general a transfer function G(s) may be
tions are zero. This type of description is par- written in the form
ticularly widely used in the analysis and
design of engineering control systems. An
yes) = G(s) = A(s) (3.13)
U(s) B(s)
understanding of Laplace transform methods
is an essential prerequisite to the use of trans- where yes) is the Laplace transform of the
fer functions, and a summary of some of the output variable, U(s) is the Laplace transform
relevant aspects of Laplace transforms may be of the input and where A(s) and B(s) are poly-
found in Appendix A. Most introductory nomials in s. In all cases the output transform
texts dealing with control systems engineer- is the transform of the input times the transfer
ing (e.g. refs 1 and 2) provide a detailed function.
account of transfer function models and their Many important properties of a transfer
derivation. An outline of the relevant theory function, and of the system which it repre-
is provided in Appendix B. It is assumed, in sents, depend upon the denominator B(s). The
the remainder of this chapter and in other sec- roots of the characteristic equation B(s) = 0
tions of this book, that the reader is familiar largely determine the form of the output
with Laplace transforms and with the funda- when the transfer function is subjected to a
mentals of transfer function descriptions. given input. These roots are the poles of the
The assumption that all initial conditions transfer function. The number of poles is, of
are zero using a transfer function type of course, equal to the 'order of the system as
Bond graph representations 27
discussed above in the context of state- the loss within the resistor. Equivalent com-
variable descriptions. ponents in mechanical and hydraulic systems
are translational or rotational dampers and
flow resistance respectively.
3.5 BOND GRAPH REPRESENTATIONS

The bond graph form of model representa-


(b) Inertia or effort store (I)
tion was developed by Paynter [3] and is
now routinely used in a number of different An inertia or effort store is a component for
disciplines. Movement of materials or energy which the flow output is related to the integ-
is central to bond graph representations, and ral of the incoming effort. A pure inductance
most of the early applications of this in electrical circuit theory is a simple example
approach involved engineering systems. of such a component since the current
They can be particularly useful in the devel- through the element (flow variable) is directly
opment of mathematical models of complex related to the integral of the voltage across
engineering systems involving a number of the element (effort variable).
different forms of energy. More recently,
applications have been reported in entirely
(c) Capacitor or flow store (C)
different areas, such as biology and econom-
ics. This section provides a concise review of A capacitor or flow store produces an effort
bond graph modeling principles. A fuller output which is related to the integral of the
account of the subject may be found in a incoming flow. A simple example of this type
number of texts concerned specifically with of component is a simple hydraulic tank in
bond graph techniques and their application which the depth of liquid, and thus the pres-
(e.g. refs 4-6). sure at the base, is related to the integral of
A bond graph consists of a set of compo- the input fluid flow rate. In mechanical
nents and a set of bonds which connect the systems the equivalent component is a trans-
components together. Bond graphs involve lational or rotational compliance.
two classes of variables, known as effort vari-
ables and flow variables. Two examples of
(d) Source (S)
effort variables are mechanical force and elec-
trical voltage. The corresponding flow vari- In addition to the three components dis-
ables are velocity and electrical current cussed above, one must also be able to repre-
respectively. sent an ideal source involving either flow or
effort, and there is thus a need for
a fourth type of generic element which is
3.5.1 ONE-PORT COMPONENTS
known as an'S component'. Figure 3.2 shows
Possible components for a bond graph are as the four generic components in graphical
follows: form. Each type of bond appears in the graph
as a straight line with a half-arrow indicating
the direction for the flow-effort product.
(a) Resistor (R)
This component represents a generalization
3.5.2 CAUSALITY IN BOND GRAPH
of the corresponding electrical circuit
REPRESENTATIONS
element. Components of this type can be used
when the effort and flow are directly related. It is important to take note of the fact that at
The product of the effort and flow for the the component level a bond graph repre-
bond to which the resistor is connected gives sentation does not distinguish between a
28 Problem organization for continuous system simulation

'R

Fig. 3.3 The representation of causality in a bond


graph.

Fig. 3.2 Four generic one-port compne~s for a but it is not always possible to assign this pre-
bond graph: resistor (R), inertia (I), capacItor (C)
and source (S) components. ferred causality in practical applications.

component input and a component output. In 3.5.3 JUNCTIONS IN BOND GRAPHS


other words no assumptions need be made
A bond or signal is always connected to a
initially, for example about whether the junction at one end or, possibly, at both ends.
voltage across a resistor depends on the Bond graph junctions conserve the net
current through it or vice versa. This contrasts product of effort and flow variables and are
quite strongly with signal flow graph and of two types, which are known as common
block diagram construction principles, effort junctions and common flow junctions.
described in section 3.6, where causality is A common effort junction has the effort vari-
established prior to construction of the
ables equal on all of the bonds which are con-
diagram. Causality in a bond graph ~s nected to that junction, whereas a common
assigned after construction of the basIc flow junction has the flow variables equal on
diagram. Bond graphs make the study of the connecting bonds. Common effort junc-
causality an explicit step in the development tions are known as zero junctions and are
of a model, and in this sense they are unique. indicated by a zero on the graph beside the
Causality studies can indicate the most junction. Common flow junctions are distin-
appropriate input-output organization for guished by a 1, and are thus known as one
submodels and, through the use of bond junctions. In general, junctions may have one
graphs, a modeler can establish if proposed or more incoming bonds or signals and one or
changes in a model will introduce any more outgoing bonds or signals. Figures 3.4
changes in the causality of submodels. and 3.5 show two examples of bond graph
Causality may be indicated in a bond graph junctions.
by the inclusion of a short stroke per~­
dicular to one end of each bond, as shown m
Fig. 3.3. In general, effort and flow stores are R

--
R
assigned causality in order to indicate that the
variable which they store is taken from the
junction to which they are bonded. Causality at
Vr

~i C s~
i
·l
1
also shows the order in which equations are
to be solved. In the case of an effort or flow vel
source, causality is clearly implicit. Energy C
storage elements (C and I) have a preferred
causality involving effort output for C com- Fig. 3.4 An example of a common flow junction in
ponents and flow output for I components, a bond graph.
Bond graph representations 29
R

ir ic

e
-}
el R C S \. 0

el' C

Fig. 3.5 An example of a common effort junction in a bond graph.

Clearly a zero junction imposes the same A gyrator, on the other hand, couples domains
effort on each connected component, while a a and b according to an equation of the form
one junction imposes the same flow on each
(3.15)
component. Both types of junction conserve
power, and in a zero junction the flow vari- This use of coupling components may
ables must sum to zero algebraically. Con- be clarified by considering two specific exam-
versely, at a one junction, the effort variables ples. Take first the hydraulic cylinder and
must sum to zero algebraically. This means piston shown in Fig. 3.6. Here the piston force
that in electrical circuit applications, for F and velocity V can be related to the pres-
example, the one junction is a statement of sure P and volumetric flow rate f through the
Kirchhoff's voltage law, while a zero junc- equations
tion is a statement of Kirchhoff's current
law. F=PA (3.16)
f=VA (3.17)

3.5.4 COUPLING BETWEEN PHYSICAL where A is the cross-sectional area of the


DOMAINS piston. In this case the system may be
modeled using a transformer equation
Bond graphs are particularly useful in the where eb= P; eo = F; fa = V; fb =f; k = 1/ A.
modeling of dynamic systems which involve Similarly, for a DC electric motor where the
a combination of mechanical, electrical or torque T is related to the current I by the
other components involving energy exchange equation
between different physical domains. Bond
graphs allow for two types of energy- (3.18)
conserving components to assist in the mod-
and the motor armature back e.m.f., V, is
eling of systems with elements which involve
related to the motor shaft angular velocity, il,
such coupling. These two-port bond graph
by the equation
components are known as the transformer
and the gyrator. A transformer couples V = kmQ (3.19)
domains a and b according to an equation of
the form it is clear that a gyrator is the appropriate
form of coupling component with eb = T; fo = I;
(3.14) ea = V; fb = il.
30 Problem organization for continuous system simulation

F,v
a
~I F
V
' TF
p
~

: I
a

V )T,.o V
'GY
T ~
I .n

Fig. 3.6 Examples of bond graph coupling components: (a) a hydraulic cylinder and piston (a
transformer) and (b) a DC electric motor (a gyrator).

3.5.5 SIGNALS IN BOND GRAPHS in Fig. 3.8, the pressure in the second tank
would not influence the flow from the first
A signal is somewhat similar to a bond but
carries a variable, in one direction, from one tank to the second. Since the flow from the
first tank depends only on the pressure at the
point to another and can be amplified. The
output of the first tank a bond is not used and
difference between a bond and a signal may
a signal is employed instead.
be understood best by means of examples.
Consider a system involving two coupled
tanks, as shown in Fig. 3.7. In this system the
3.5.6 SIMULA nON PROGRAM
flow out of the left-hand tank depends on the
DEVELOPMENT FROM BOND GRAPH
pressure difference between the two tanks.
MODELS
The bond graph in this case involves bonds
but no signals. However, if the two tanks In principle it is possible to translate a bond
were connected in a different way, as shown graph model into a simulation program either

0
P1
l
\. 1
P2

f
~o

P1 ~-+L
f

Fig. 3.7 An example of a system involving two coupled tanks.


Block diagram and signal flow graph representations 31

P1 0 ~
l
" 1 ) 0
P
2

1f

Fig. 3.8 A second example involving two connected tanks.

manually or using software [7]. There are In the block diagram approach to the
continuous system simulation programs for description of a system each element is
which the dynamic model may be described described by a single block. The arrow enter-
in bond graph form. Examples include ing the block represents the input variable
CAMP-G [8] and ENPORT [9]. For example, and the arrow leaving the block represents
in applying the CAMP-G program the user the output variable. The block contains a
creates a bond graph on the screen and the mathematical expression, usually in transfer
software allows a complete causal analysis to function form, which relates the output to the
be carried out. A CAMP-G output file may input. Signal flow diagrams incorporate
then be created which can be used as an input exactly the same information as the block
file for ACSL, which is a widely used simula- diagram. In this case input and output vari-
tion tool discussed in later chapters. ables are represented by nodes and the line
connecting two nodes is the equivalent of the
block in the block diagram approach. A given
3.6 BLOCK DIAGRAM AND SIGNAL system can be represented at many different
FLOW GRAPH REPRESENT AnONS levels using a block diagram or signal flow
graph. For example Fig. 3.9 shows valid block
Complex systems can be described very conve- diagram and signal flow graph representa-
niently by means of block diagrams or signal tions for the mass-spring-damper system of
flow graphs. Both these forms of graphical rep- equation (3.1). In these diagrams the input
resentation are described in Appendix C. The variable is F(s), the Laplace transform of the
importance of block diagrams and signal flow force f(t), and the output is Y(s), the Laplace
graphs is very considerable for simulation transform of the displacement y(t). No other
since these provide a simple means of express- variables appear in the diagram, which
ing the structure of a complex model. Many describes only the relationship between the
modern simulation packages are block chosen input variable and the chosen output
diagram oriented and a thorough understand- variable. Figure 3.10 shows another possible
ing of such diagrams is therefore essential. level of representation for the same model. In
32 Problem organization for continuous system simulation
course, be noted that the diagrams of Figs 3.9
and 3.10 are exactly equivalent and Fig. 3.9
Frs) 1 Y!s)
1----+ may be derived from Fig. 3.10 using standard
rules for block diagram or signal flow graph
manipulation and reduction, as outlined in
Appendix C.

3.7 BLOCK DIAGRAM AND SIGNAL


FLOW GRAPH METHODS FOR TRANSFER
~,.:(s) _ _ _ _+)_ _ _ _ _):Isl FUNCTION SIMULATION

1 Several methods are available for obtaining a


set of equations in state variable form from
a given transfer function. The methods consid-
ered here are all based on block diagrams or
Fig. 3.9 Transfer function based block diagram
and signal flow graph representations of the mass, signal flow graphs and provide information
spring and damper system of Fig. 3.1. which is of value for the implementation of
simulation programs using either equation-
oriented methods or block diagram-oriented
this case the diagrams involve a number of packages. Several different approaches are
blocks or signal flow graph elements in com- presented because some methods, which can
bination, and the structure of the diagrams be entirely satisfactory with low-order models,
may provide additional information about can present problems of numerical robustness
the system being considered. It should, of when applied to higher order problems.

Frsl + 1 1 VIs)
M S

Fig. 3.10 Detailed block diagram and signal flow graph representations of the mass, spring and damper
system of Fig. 3.1.
Methods for transfer function simulation 33
3.7.1 THE DIRECT CONSTRUCTION the system which is being modeled and is
APPROACH defined from the following equation
Most transfer functions of practical im-
yes) = yes) . E(s) (3.22)
portance can be manipulated into a general U(s) E(s) U(s)
form involving a ratio of two polynomials in
s and a gain factor. Consider the transfer The transfer function of equation (3.21) may
function now be split into two parts as follows

yes) K(sm + am_ls m-1 + ... + a2s2 + als + ao)


=
U(s) sn + bn_ls n-1 + ... + b2 s2 + bls + bo
(3.23)
(3.20)
and
where n > m and K is a simple gain factor.
This is in the required form, and the restric- E(s) 1
tion that the order of the denominator should U(s) 1 + bn-I s-I + ... + b2 s2- n + bls l- n + bos-n
be greater than that of the numerator is con-
nected with conditions for physical realizabil- (3.24)
ity. In the simulation of real physical systems
this condition should be expected to apply to Equation (3.24) may then be rearranged to
all valid models. give
The only types of transfer function which
are likely to be of practical importance but E(s) = U(S) - (bn_IS- 1 + ... + b2 s2-"
which cannot be manipulated into the form +bls l- n + bos-n )E(s) (3.25)
shown in equation (3.20) involve pure delay
elements involving factors exp(-sT) or dis- which corresponds to a signal flow graph of
tributed delay elements involving factors the form shown in Fig. 3.11. Here the new
exp (-M). However, such cases can be variable E(s) provides the input to a cascaded
handled without difficulty if the delay ele- sequence of integrator elements, the output of
ments are simple multiplicative factors each of which is fed back to the input through
which can be treated as a separate block in coefficient elements. The outputs of each of
cascade with a block described by a transfer the integrators, taken in order from the left,
function involving a ratio of polynomials are thus s-IE(s), s-2E(s), s-3E(s), ... , s-"E(s).
in s. However, from equation (3.23), it may be seen
Dividing all terms in the numerator and that the output yes) is a weighted sum of
denominator of the right-hand side by s" m + 1 quantities such as these, and this gives a
gives complete signal flow graph of the form
shown in Fig. 3.12.
yes) K(sm-" + am ,sm-'-" + ... + a,s2-" + a,s'-" + aos-") Output variables from each of the integra-
U(s) l+b,,_,s-' +... +b,S2" +b,s' "+bos " tor blocks in Fig. 3.12 may be assigned as
(3.21) state variables and a set of equations in state-
variable form may be written down from the
It is now possible to rewrite the relationship signal flow graph or block diagram by a
between the transfer function output yes) and process of inspection. If the output of the final
the input U(s) to involve an intermediate vari- integrator is chosen as the state variable XI'
able E(s). This new variable need not have with the other state variables taken as the
any obvious physical significance in terms of outputs of each of the remaining integrator
34 Problem organization for continuous system simulation
1 1 1 1
U(s} 1 E(s) i T T S

Fig. 3.11 A direct construction form of signal flow graph for denominator terms in a linear nth-order
single-input single-output transfer function description.

U(s) 1 E(s) l 1
S K Yes)

,,

Fig. 3.12 The complete signal flow graph, obtained by the direct construction method, for a linear nth-
order single-input single-output transfer function model.

elements, in order from the right, the com- added to make this set of equations into a
plete set of state equations is as follows: complete state variable representation of the
given transfer function is to add a single alge-
braic equation relating the output y to the
state variables. From the block diagram it is
clear that this equation is
y = K(aox 1+ a1x2 + ... + am-1X n- m + x n- m+l ) (3.27)
Equations (3.26) and (3.27) together form a
(3.26) complete state-space description for the given
transfer function and therefore provide a very
This set of equations is similar in structure to simple basis for implementation of the given
equations (3.9) above. All that has to be transfer function within a simulation. The
Methods for transfer function simulation 35
only disadvantage of this direct construction Using partial fractions it is then possible to
approach is that the properties of the result- express the right-hand side of this equation as
ing state-space model can be highly sensitive a sum of terms each of which involves a
to small numerical inaccuracies in coefficient single pole. The resulting equation is
values, especially in the case of high-order
models. yes) al az a"
- = - - + - - + ... + - - (3.29)
U(s) S+/3l S+/32 s+/3"
Each of the terms on the right-hand side of the
3.7.2 THE PARALLEL CONSTRUCTION equation has the same form, and the corre-
APPROACH sponding signal flow graph involves a parallel
structure as shown in Fig. 3.13. Once again the
The parallel programming approach for the state variables are taken to be the outputs of
derivation of a set of state equations from a each integrator. The state equations describing
given transfer function, and thus for simula- the signal flow graph are then of the form
tion of that transfer function, is appropriate
when the given transfer function has a Xl = -/31X l + u(t)
denominator in factored form as shown
below

(3.28) (3.30)

U(s) 1 Y(s)

Fig. 3.13 A signal flow graph, obtained by the parallel construction method, for an nth-order single-
input single-output transfer function model.
36 Problem organization for continuous system simulation
An additional algebraic equation is then 1
needed to relate the output y to the n state
variables. This has the form
1

It is important to note that a model with


a parallel structure having first-order (or
second-order) blocks is generally more robust
in terms of numerical sensitivity to coefficient Fig. 3.14 A signal flow graph for a single pole-zero
inaccuracies than the equivalent model in pair for use in the iterative construction method.
direct construction form. The higher the order
of the original transfer function description denominators of the form (s + 13k)' which
the greater are the benefits of the parallel cannot be combined with any numerator
approach. factors. In such cases the additional factors
can be accommodated by means of the sub-
model signal flow graph element in Fig. 3.15.
3.7.3 THE ITERATIVE CONSTRUCTION The form of the diagram for the complete
APPROACH transfer function for the special case where
the orders of the numerator and denominator
If a transfer function has only real poles and
are the same is shown in Fig. 3.16. The state
zeros, the numerator and denominator may variables are chosen to be the output
both be factorized into products of first-order
variables of the integrator blocks and the
factors to give a description of the following resulting state equations are obtained as
form: follows:
K(s + a I)(S + a 2) ... (s +a m) (3.34)
(3.32)
(s + 13 1)(S + 13 2) ... (S + 13 n)

where K, a; and f3j are all real constants.


(3.35)
Grouping the factors into products of terms of
the form

(3.33)
X n_, = -13 n_jX,,_j + (a n-j+1 - 13 n-j+1 )x"_j+1
it is possible to construct a submodel block
diagram or signal flow graph which repre-
sents a single factor of the complete transfer
function. This submodel diagram has the
form shown in Fig. 3.14. Since the order of the
denominator is always equal to or greater
X, =-/3,x, +(a 2 -/32)X 2 + ... +(a" -/3 ")x" +u (3.37)
than the order of the numerator of the trans-
fer function for physically realizable systems, As with the parallel construction approach
the number of denominator factors is always the iterative method has properties which are
equal to, or greater than, the number of superior to the direct construction method in
numerator factors. Therefore, at the end of the terms of coefficient sensitivity. A cascaded
process of grouping these factors in pairs, arrangement of first- or second-order transfer
there may be some additional terms involving functions tends to be more robust to coeffi-
Methods for transfer function simulation 37
and

E(s) 1
= (3.41)

That is

Fig. 3.15 A signal flow graph for a single pole for E(s) =U(s) - [6s- 1E(s) + l1s- 2E(s) + 6s-3E(s)]
use in the iterative construction method.
(3.42)
cient errors than the equivalent structure and
involving multiple feedback loops.
Y(s) = S-1 E(s) + 9s-2 E(s) + 20s-3 E(s) (3.43)
3.7.4 AN EXAMPLE OF BLOCK DIAGRAM Equations (3.42) and (3.43) may be expressed
CONSTRUCTION FROM A TRANSFER in block diagram form by a model involv-
FUNCTION ing three integrators connected in cascade
Consider the following transfer function: as shown in Fig. 3.17. Taking the outputs
of integrator blocks as state variables
G(s) = Y(s) = S2 + 9s + 20 (3.38) allows the following set of simultaneous
u(s) S3 +6s 2 + l1s+6 first-order differential equations to be
established:

(a) Direct construction method


First of all, the numerator and denominator
polynomials on the right-hand side of the
equation should be divided by the highest
power of s to give or, in matrix notation

G(s) = y(s) =

r::1 r ~ ~ ~1r;: r~1u


S-1 + 9s-2 + 20s-3 (3.39)
U(s) 1 + 6s-1 + 11s-2 + 6s-3
= + (3.44)
X3 -6 -11 -6 X3 1
Introducing a dummy variable E(s) gives
The output equation is
(3.40)
y = 20x 1 + 9x 2 + X3

U(s) 1 yes)

Fig. 3.16 A signal flow graph, obtained by the iterative construction method, for the special case of a
single-input single-output transfer function model with an nth-order numerator and nth-order
denominator.
38 Problem organization for continuous system simulation

Fig. 3.17 A block diagram for the example of section 3.7.4 by the direct construction method.

or to give the following set of first-order differ-


ential equations:

and an algebraic equation relating the output,


y(t), to the three state variables x1(t), x2(t) and
x3(t) which has the form
(b) Parallel construction method
y = 6x 1 - 6X2 + X3
In this case the first step involves factorizing
the denominator of the given transfer func- In matrix form the state and output equations
tion to give are thus

G(5) = Y(5) = 52 +9s+20


U(5) 53 + 6s 2 + 115 + 6 (3.48)
S2 +95+20
=------ (3.46)
(s + 1)(5 + 2)(s + 3)
and
Expressing the right-hand side of this equa-
tion in partial fraction form gives:
(3.49)
Y(s) 6 6 1
-=---+- (3.47)
U(s) 5+1 s+2 s+3
and this may be represented as a block
diagram with the parallel structure shown in (c) Iterative construction method
Fig. 3.18. Once again the outputs of the inte- It can be seen that there are two zeros and
grator blocks are taken as the state variables three poles in the given transfer function.
Modeling of distributed parameter elements 39
+ ,
s 6

+
, x2
-6
Y(s)
s

,
S
x3

Fig. 3.18 A block diagram for the example of section 3.7.4 by the parallel construction method.

Hence the two zeros can be associated with (3.52)


two of the poles in the standard way for the
iterative approach and one pole must be (3.53)
treated separately, as shown in the transfer
and an algebraic output equation
function below
y =Xj (3.54)
y(s) S2 + 9s + 20
u(s) S3 +6s 2 + l1s+6

3.8 MODELING OF DISTRIBUTED


( S+5)(S+4)( 1 ) (3.50) PARAMETER ELEMENTS
= s+1 s+2 s+3

The resulting block diagram thus has two 3.8.1 INTRODUCTION


stages involving elements of the type shown in
The use of time-domain and frequency-
Fig. 3.14 and one stage of the type shown in
domain analysis methods in the study of
Fig. 3.15. Figure 3.19 shows the complete block
feedback control systems is not limited to
diagram. It should be noted that because one
lumped parameter systems, but may be
of the zeros is at the origin there is no direct
extended readily to systems which include
link between the first-stage integrator output
distributed parameters. Such parameters arise
and the second stage. Taking outputs of inte-
in the modeling of systems in which quanti-
grator blocks in Fig. 3.19 as state variables
ties are transmitted from one point to
gives a set of first-order differential equations
another, as in the case of electrical signals in a
transmission line, flow of fluid in a pipe, phe-
nomena associated with the conduction of
= -3xj + 2X2 + 4X3 + u (3.51) heat, or in situations involving transmission
x2 = -2X2 + 5X3 + X3 of sound in a fluid. The 'signals' in such
40 Problem organization for continuous system simulation

U(s) + 1 1 1
S S 4 S

2 3

Fig. 3.19 A block diagram for the example of section 3.7.4 by the iterative construction method.

systems are distributed in space as well as where z(x, t) is the state of a point at position
time and the mathematical models are de- x and time t. The parameter v is the velocity
scribed by partial differential equations. of transmission.
In situations in which the system reduces Applying the unilateral Laplace transfor-
essentially to a single input variable and a mation to this equation gives, assuming zero
single output variable of interest at one point initial conditions, a new equation of the fol-
in space, as often applies in control systems lowing form
applications, it is possible to derive a transfer
function type of description which involves aZ(x, s)
sZ( x,s ) = v-----'-- (3.56)
a distributed parameter. Such distributed para- ax
meter transfer function models may then be
where
used in the same way as conventional transfer
functions for lumped parameter models. The
two types of distributed parameter element Z(x, s) = f o
exp(-st)z(x, t)dt (3.57)
considered in this section are the pure time
delay and the distributed time delay. The solution of this equation is

3.8.2 PURE TIME DELAY z(x, s) = Aexp( -s;) (3.58)


A pure time delay (known also as a trans-
portation lag, 'dead time' or 'velocity-dis- where A is an arbitrary constant.
tance' lag) arises in systems in which If U(s) is the Laplace transform of the input
quantities are transmitted at finite velocity of the system at point Xl and yes) is the trans-
from one point to another. In the case of form of the output of the element at point X2
a pure delay this transmission involves then it follows that
no frequency-dependent change of signal
amplitude. U(s) =Z(x lt s) =Aexp( -s ~ ) (3.59)
A system involving a pure time delay
(perhaps owing to physical phenomena such and
as heat flow but where losses can be
neglected) may be described approximately
by a partial differential equation of the form yes) = Z(x 2 , s) = Aexp( -s ~ ) (3.60)

az
-=v-
az (3.55)
Thus the transfer function relating the output
at ax transform yes) to the input transform U(s) is
Modeling of distributed parameter elements 41
This allows one of the terms in the above
Y(s)
--=exp (X2
-s-- XI-) (3.61) equation to be eliminated, giving
u(s) v
That is

-
Y(s)
= exp( -sT) (3.62)
Z(X, s) = A exp[ - [xl (3.67)

u(s) for x;:, O.


If U(s) is the Laplace transform of the input
where T is the transmission time from point Xl
to the system being modeled (at point Xl) and
to point X2 • The parameter T is thus the dura-
Y(s) is the Laplace transform of the output of
tion of the pure time delay.
the system (at point x2 ) then it follows that

3.8.3 DISTRIBUTED TIME DELAY

A distributed time delay arises in systems in


U(s) = Z(XI! s) = Aex p[ -~XI 1 (3.68)

which quantities are transmitted from one Similarly


point to another with a finite velocity and

-~X2l
with an attenuation which varies with fre-
quency. Examples include the conduction of Y(s) = Z(x 2I s) = Aex p[ (3.69)
heat and the transmission of electrical signals
in a medium which is not loss free. The Hence, the transfer function relating Y(s) to
partial differential equation describing this U(s) has the form
situation has the form
(3.70)
(3.63)

where z(x, t) represents the value of the quan- Thus


tity concerned at point X and time t. The para-
meter a is a constant and could represent, for Y(s) = ex p (- s (x 2 - XI )2] = exp(-{Sf)
example, thermal conductivity. Applying the U(s) a
unilateral Laplace transform for zero initial
conditions gives (3.71)

where the parameter T is an equivalent time.


sZ(X, s) = a (p~' s) (3.64) It should be noted that elimination of the
term involving the positive exponent in this
where derivation has physical significance. It is equiv-
~
alent to rejecting the possibility of reflected
Z(X, s) = f exp( -st)z(x, t)dt (3.65) waves in the system under consideration. The
o use of the transfer function resulting from this
analysis is therefore restricted to cases in which
The solution of this equation has the form reflected waves are not expected.

Z(X,S)=Aexp[ -[xl [xl + Bexp[ (3.66) 3.8.4 SIMULATION MODELS INVOLVING


PURE AND DISTRIBUTED DELAY ELEMENTS
It is now assumed that at infinite distance the Most simulation languages incorporate facili-
value of the variable z(x, t) is always zero. ties for the representation of pure delays.
42 Problem organization for continuous system simulation
Pure delays also present few difficulties in a a model's response alters with changes in its
simulation which is developed using a parameters and may be used in simulation
general-purpose high-level language, pro- studies for a number of different reasons,
vided the delay does not itself vary with time. depending on the overall objectives of the
Cases involving variable delays present addi- investigation. One application of sensitivity
tional problems [10]. An alternative approach, analysis in the model development process
and a more approximate representation for a is for the tuning of model parameters by first
pure delay, is based upon the properties of establishing the parameters which have
Pade approximations. These approximations, the greatest influence. Similarly, sensitivity
based upon truncated series for the exponen- analysis allows assessments to be made of
tial function, were widely used for the repre- the effect of component tolerances on the
sentation of pure delays in analog simu- overall system performance which is likely
lations, and it is equally possible to use this to be achieved. The approach can also be
approach in a digital simulation. very helpful in investigating the significance
Although pure time delays can be handled of assumptions which are inherent in a
easily within simulation models, more model, establishing the accuracy with which
complex problems involving distributed para- parameters must be defined and in model
meter elements can be approached in a very validation [14]. Structural information, com-
general way using finite differences or finite- bined with parameter sensitivity measures,
element methods or other numerical tech- can also greatly assist in the iterative
niques for the solution of partial differential development and refinement of a complex
equations. Detailed treatments of the mathe- system model. When changes in system
matical and numerical aspects of these spe- parameters cause discontinuous changes in
cialized topics can be found in appropriate the overall system behavior the sensitivity
textbooks, and a review of some of the simu- analysis may be termed 'singular perturba-
lation problems associated with distributed tion' analysis.
parameter models is included in the book by An obvious approach to the numerical
Spriet and Vansteenkiste [11]. Simulations evaluation of parameter sensitivity is that of
involving distributed parameter elements can repeated solution or simulation for each set of
be numerically intensive, and for time-critical parameters, but this process can be tedious
applications distributed parameter problems and time-consuming in the case of most
are often reduced to quite simple lumped models of practical importance, and some-
parameter approximations. One example of times is limited in terms of the insight which
this type can be found in the work of Bryce et it provides. More formal methods of para-
al. [12], which is concerned with the real-time meter sensitivity analysis provide an alterna-
simulation of a water pipeline as part of an tive approach to this problem that is more
investigation of water-turbine governing elegant and computationally efficient, and in
systems. Another example, involving an elec- some cases can provide the user with a better
trical transmission line application, may be understanding of potential problems and crit-
found in the work of Nelms et al. [13]. ical conditions.
Modern sensitivity analysis is based on the
use of the sensitivity coefficient, or sensitivity
3.9 PARAMETER SENSITIVITY ANALYSIS
function, which may be defined from a Taylor
METHODS IN SYSTEM MODELING AND
series expansion for a system variable in
SIMULATION
terms of the parameter which is changing. If
Parameter sensitivity analysis techniques y(t, qo) is a model response to a given input
provide information about the way in which and this response is a function of a parameter
Parameter sensitivity analysis methods 43
q as well as of time, the difference between If solved in conjunction with the equations
y(t, qo) and the response y(t, qo + ilq), where defining the system model, these co-system
the parameter q has taken a new value qo + ilq, equations provide solutions for the state-
is given by variable and output sensitivity coefficients
Jx,/Jqo and Jy/Jqo as functions of time.
y(t,qo+&j) = y(t,qo)+Jy t:.q Continuous system simulation techniques
Jq thus provide a basis for parameter sensitivity
1 J2 y 2
analysis in dynamic models defined by ordi-
+--2 (t:.q) +... (3.72) nary differential equations. Early work by
2! Jq Tomovic [15] and his colleagues at the Pupin
If ilq is sufficiently small Institute in Belgrade provided methods which
still form the foundation for sensitivity analy-
y(t, qo + t:.q) ~ y(t, qo) + Jy &j (3.73) sis of continuous system simulation models.
Jq
The quantity Jy/Jq is the sensitivity coeffi- 3.9.1 METHODS FOR SENSITIVITY
cient or sensitivity function. The effective CO-SYSTEM SIMULATION
linearization introduced by truncating the The co-system equations are, in the most
expansion after the second term allows the general case, linear ordinary differential
application of the superposition principle to equations with time-varying coefficients. For
find the effect of simultaneous changes in a
a linear lumped parameter system model the
number of parameters.
coefficients of the sensitivity equations are
Many types of system can be described by a time invariant and the structure of the sensi-
set of ordinary differential equations which tivity co-system is identical to that of the
are, in the general case, nonlinear. The
system model, except for the independent
general form of these equations is as follows:
terms in each equation.
The sensitivity equation may be solved by
analytic, transform or computer simulation
methods. The model equations and the sensi-
tivity equations which form the co-system
where Xlf X2f ... , x" are state variables, Ulf U 2, ••• , may be solved simultaneously, with the
U, are inputs and Yl' Y2f ... , y", are output vari-
instantaneous values of any time-varying
ables. The sensitivity of the dynamic system coefficients and the independent forcing terms
to variation of the parameter q may be being obtained continuously from the system
obtained by means of the sensitivity or 'co- model. Figure 3.20 is a schematic diagram
system' equations. These equations are illustrating this process. The determination of
obtained by differentiating equations (3.74) sensitivity coefficients by this method is, for
and (3.75) with respect to q. This gives most systems, a simple application of simula-
tion principles, and many examples have been
published. In the case of a linear model
having constant coefficients the system model
(3.76) and the co-system are identical in structure.

(a) Parameter sensitivity of linear models


The sensitivity analysis of systems which can
(3.77) be described by lumped parameter linear
44 Problem organization for continuous system simulation

----- SYSTEM - - --
INPUTS - -- -- MODEl - - --
OUTPUTS

I I
I I
I
I I
I I

L..,..
-+
------- -----
- - - - - -- CO-SYSTEM
- - --

SENSITIVI TY
FUNCTIONS

Fig. 3.20 A schematic diagram illustrating the generation of sensitivity coefficients using the co-system
approach.

equations with constant coefficients is facili- proved by Kokotovic [16] for multiloop struc-
tated by the application of a technique, devel- tures, such as those arising in the direct con-
oped first by Kokotovic [16], which is known struction method for the simulation of transfer
as the 'sensitivity points' method. functions (section 3.7.1), that the co-system not
A single-input single-output linear system only has the same structural form as the
may be described by the equation model itself but the sensitivity coefficients are
signals appearing at certain predetermined
yes) = G(s) (3.78) points in the co-system block diagram.
U(s) A general direct construction method block
where yes) is the Laplace transform of the diagram is shown in Fig. 3.21 for an nth-order
system output variable y(t) and U(s) is the system. Let this system be described by a
transform of the input u(t). The sensitivity of transfer function
the output to changes of any parameter q of
the model is then given by

dY(s) = dG(s) U(s) (3.79)


dq dq
that is where ao = bo = 1. Hence, by dividing the
numerator and denominator by s" it follows
dY(s) = _1_ dG(s) yes) (3.80) that
dq G(s) dq
The sensitivity coefficient dy(t)/dq may there-
fore be found if the model output yet) is (3.82)
applied as input to a co-system which has the
transfer function G(s)'ldG(s)/dq. It has been
Parameter sensitivity analysis methods 45

1 1
U(s) K 5 S VIs)

,
I

Fig. 3.21 A signal flow graph for an nth-order transfer function (direct construction).

Differentiating partially with respect to the The representation of a system in terms of a


parameter b, gives block diagram in the direct construction form
gives a system state matrix in what is known
as companion-canonic form if the output of
each integrator is taken as a state variable.
(3.83)
Wilkie and Perkins [17] showed that the sen-
sitivity of each state variable to each para-
meter is directly available from a single
sensitivity model for a system matrix in this
and thus it follows that particular form. In the case of multi-input
ayes) -s-'Y(s) linear systems they also showed that for m
= (3.84)
ab, inputs there are at most 2m - 1 dynamic nth-
order sensitivity models needed to generate
all of the sensitivity coefficients.
Similarly, differentiating with respect to para-
meter a, gives
(b) Parameter sensitivity analysis in
ayes) models containing nonlinear elements
(3.85)
aa r
One of the convenient features of the co-
system approach to the sensitivity analysis of
Therefore, the system state variables are linear models is the obvious structural simi-
themselves the sensitivity functions for the larity of the original model and the sensitivity
numerator coefficients, as shown in Fig. 3.22. model. It is interesting to examine the sensi-
If a different model structure is used and the tivity equations for nonlinear models and to
state variables are not available another investigate structural links between the non-
approach must be used for evaluation of the linear model and its co-system [18]. For this it
numerator sensitivities. is convenient if the model equations can be
46 Problem organization for continuous system simulation
y/s) 1 1
S S
o-+"'r~.:p!;_ - - - - - - --p----:l---o

U(s) K
1 1
5 5 Yes)

Fig. 3.22 Sensitivity co-system structures for denominator and numerator coefficients of the nth-order
linear system of Fig. 3.21. Note that the sensitivity functions are the variables at the nodes of the
co-system.

separated into a set of linear equations for the


linear components and a set of nonlinear rela- (3.88)
tionships for the other elements. The linear
part of the model is represented in the co- Hence, any nonlinear element with r inputs
system by an identical set of linear elements. may be replaced, within the sensitivity co-
Let a typical nonlinear element be repre- system, by a set of r multiplication operations
sented by an equation of the form and r additional elements which may be
y(t) = f[vj(t),vz(t), ... , vr(t)] (3.86) linear or nonlinear, as shown in Fig. 3.23.
One additional point which must be men-
where Vlf Vlf ... , Vr are all inputs to the tioned is that a single structure can be used to
element. Diffenmtiating with respect to a determine the sensitivity functions for all of the
system parameter q gives system parameters. There is a unique set of co-
dy =
dq ~jk
! fl..- dVk + df
dVk dq dq
(3.87)
system forcing functions for each parameter,
but the sensitivity functions can be found using
one basic co-system with appropriate switch-
If the parameter q is not a parameter of the ing to transmit the forcing functions from the
nonlinear element itself then system model to the co-systell}.
Systems having both discrete and continuous elements 47

",---ti
"2---tI
1---- V

V1
Vii! Of
dV1

l~1
aq
Y1
Vii! Clf
bVe
Vr h
iii
~ve •
~

~Vr _ _ _ _ _ _--.l
aq

Fig. 3.23 A block diagram illustrating the generation of parameter sensitivity functions for a general non-
linear element.

3.10 MATHEMATICAL MODELS OF discrete elements as well as the parts of the


SYSTEMS HAVING BOTH DISCRETE AND system involving continuous variables. A
CONTINUOUS ELEMENTS particularly important case involves the mod-
eling of a digital computer used for control
The mathematical modeling of systems purposes within a closed loop, as shown in
involving both discrete and continuous ele- block diagram form in Fig. 3.24. The discrete
ments is of particular importance in the field element involves the processor and the soft-
of automatic control. Increasingly, control ware used to implement the digital control
systems incorporate digital processors and algorithm being used. The interface between
other discrete elements. In most cases this the continuous and discrete parts of the
involves the form of discrete system in which system involves analog to digital and digital
events occur periodically. to analog converters.
Any model of the complete system has to The development of a mathematical model
incorporate an adequate description of the in this case requires that the analog interface
48 Problem organization for continuous system simulii1ion
REF.
INPUT
+ ..,. ADC ~
DIGITAL
-.. DAC PLANT
OUTP UT
PROCESSOR
-

Fig. 3.24 A schematic diagram of a closed-loop control system involving a digital processor together with
analog to digital and digital to analog converters (ADC and DAC respectively) within the feedback loop.

units be replaced by appropriate idealized digital control systems can be found in any
elements. The process of analog to digital con- text on sampled-data theory and digital
version is a process which involves sampling control (e.g. refs 19 and 20). It should be noted
of the continuous variable which is input to that the analog to digital and digital to analog
the converter. This sampling process is con- converters are normally assumed to operate
ventionally represented by an ideal switch in a synchronous fashion with input and
which closes for a short period of time at output operations at the control computer
regular intervals. The time between samples taking place at the same time. This, and other,
is the sampling period of the analog to digital simplifying assumptions, which are widely
converter and the sampled value is assumed used in analytical treatments of digital control
to provide the discrete input to the control system modelling, may be avoided if thought
algorithm, which is implemented on the necessary in a simulation-based approach.
processor in terms of a software program. The The control algorithm within the digital
digital to analog converter converts the dis- processor is normally represented by a differ-
crete numerical result obtained from the ence equation. This provides a means of
control algorithm into an equivalent analog expressing the output of the digital controller
variable. It is conventionally represented in an at some time t = kT in terms of the input as
idealized model by a zero-order hold, which provided by the analog to digital converter at
gives an output which changes periodically that time, and by the output and input at pre-
but maintains a constant output level between vious time instants t = (k - l)T, t =(k - 2)T, ... ,
each output event. Figure 3.25 shows the etc. Here T is the sampling period and k is an
block diagram of an idealized model of this index defining the sample number being con-
kind. Further details of the modeling of sidered. For example, a very simple algorithm

+ I(al CONTROL a(e)


ALGORITHM
f---+ HOLD PLANT

- IDEAL
SAMPLER

Fig. 3.25 An idealized block diagram model of the digital control system of Fig. 3.24 using standard
sampled-data conventions and symbols.
References 49
which provides proportional control in which 8. Granda, J. (1990) CAMP-G Users Manual,
the error signal l(s) sampled by the analog to Mitchell & Gauthier Associates, Concord, MA.
digital converter and simply multiplied by a 9. Rosenberg, RC. (1990) ENPORT Reference
Manual, Rosencode Associates, Lancing, MI.
gain factor G to produce the output that pro- 10. Doebelin, E.O. (1980) System Modelling and
vides the continuous signal O(s) from the Response, John Wiley, New York, pp. 193-201.
digital to analog converter would involve a 11. Spriet, J.A. and Vansteenkiste, G.c. (1982)
difference equation of the form Computer-aided Modelling and Simulation,
Academic Press, London.
O(kD =G1(kD 12. Bryce, G.w., Foord, T.R, Murray-Smith, D.J.
If the control algorithm was now modified to and Agnew, P.w. (1976) Hybrid simulation of
water-turbine governors. Simulation Councils
involve integral contrbl, in which the error Proceedings, 6 (Part 1), 35-44.
signal is integrated numerically before being 13. Nelms, RM., Sheble, G.B., Newton, S.R and
returned in analog form through the digital to Grigsby, L.L. (1990) Simulation of trans-
analog converter, the algorithm would have a mission line transients with a distributed-
more complex form and would involve previ- parameter model using a personal computer.
ous values of the discrete variables 0 and I as Simulation, 55 (2), 103-107.
well as current values. Further consideration 14. Karnavas, W.J., Sanchez, P.J. and Bahill, A.T.
(1993) Sensitivity analyses of continuous and
is given to sampled-data system models in
discrete systems in the time and frequency
Chapter 5. domains. IEEE Transactions Systems, Man and
Cybernetics, 23 (2),488-501.
REFERENCES 15. Tomovic, R (1963) Sensitivity Analysis of
Dynamic Systems, McGraw-Hill, New York.
1. Palm, W.J. (1986) Control Systems Engineering, 16. Kokotovic, P.V. (1964) Method of sensitivity
John Wiley, New York. points in the investigation and optimisation of
2. Golten, J. and Verwer, A. (1991) Control System linear control systems. Automation and Remote
Design and Simulation, McGraw-Hill, London. Control, 25 (12), 1512-18.
3. Paynter, H.M. (1961) Analysis and Design of 17. Wilkie, D.F. and Perkins, W.R (1969)
Engineering Systems, MIT Press, Cambridge, Generation of sensitivity functions for linear
MA. systems using low order models. Transactions
4. Karnopp, D.C., Margolis, D.L. and Rosenberg, oftheIEEE, AC-14 (2), 123-30.
RC. (1990) System Dynamics: A Unified 18. Vuskovic, M. and c':iric, V. (1966) Structural
Approach, 2nd edn, John Wiley, New York. rules for the determination of sensitivity
5. Rosenberg, RC. and Karnopp, D.C. (1983) functions on nonlinear non stationary
Introduction to Physical System Dynamics, systems, Sensitivity Methods in Control Theory
McGraw-Hill, New York. (ed. L. Radanovic), Pergamon, Oxford,
6. Thoma, J.U. (1990) Simulation by Bond Graphs, pp.154-65.
Springer, Berlin. 19. Isermann, R. (1989) Digital Control Systems,
7. Karnopp, D. (1984) Direct programming of 2nd edn, Springer, Berlin.
continuous system simulation languages 20. Franklin, G. and Powell, J.D. (1980) Digital
using bond graph causality, Transactions of the Control of Dynamic Systems, Addison-Wesley,
Society for Computer Simulation, 1 (1),49--60. Reading, MA.
THE PRINCIPLES OF NUMERICAL
MODELING 4

4.1 AN INTRODUCTION TO NUMERICAL


INTEGRATION METHODS (4.2)

The solution of a differential equation can be This equation suggests that evaluation of the
obtained by mathematical operations which
term involving the integral is only possible if
involve integration. In order to obtain a
x(to) and x(to + h) are both known. Numerical
solution using a digital computer the analytic integration techniques provide approx-
processes of integration must be replaced by a imations which allow this difficulty to be
numerical method which can yield an overcome and permit the next value of the
approximation to the true solution. A con- variable x[x(to + h)] to be determined using
tinuous variable x which is a function of the
only the current value of that variable [x(to)]:
independent variable t (i.e. time) is rep~­ Many different integration methods eXIst
sen ted within a digital simulation by a senes which are suitable for use in the solution of
of numbers, or samples, Xo' Xli XU ... , X". These ordinary differential equations and thus for
samples define the variable X in terms both of
continuous system simulation. Some of these
magnitude and sign at the times to, tl , t2 ,···, tn· are very simple in terms of the numerical
For many purposes it may be assumed that methods used and involve relatively crude
these samples are equally spaced in time and
and simple approximations. Other methods
it is clear that if the sampling rate is high the
are potentially much more accurate in ter~s
information loss owing to sampling can be of the numerical methods used but thIS
small. However, the step size, h, does affect
additional numerical accuracy is achieved at
the size of the error in the numerical some additional cost.
approximation and the choice of h must
One of the penalties associated with some
depend upon the dynamic characteristics of of the more complex integration methods is
the system under consideration. an increased tendency to display numerical
The solution of a differential equation instability. This means that the numerical
involves integration of a variable which can algorithm itself tends to become unstable for
involve a function of that same variable.
a chosen integration step size although the
Consider the first-order differential equation
underlying mathematical model is completely
stable. Even if a technique is stable for a
dx (t) = ax(t) + bu(t) (4.1) chosen integration step size there may well be
dt
problems in terms of the transient behavior of
Here the quantity on the left-hand side of the the numerical algorithm which outweigh the
equation, which on integration gives x(t), ~s advantages of high steady-state accuracy. A
itself a function of x(t). If the value of X IS second, and perhaps more obvious, penalty
known at time to then the value at time to + h is incurred in using complicated integration
given by algorithms is concerned with computation
52 The principles of numerical modeling
time. Complicated algorithms, on a conven- this approach it is assumed that the quantity
tional serial computer architecture, require to be integrated, the derivative function,
more processor time for each integration step. remains constant over the integration inter-
A simple algorithm, although less accurate, val. In other words, the value of the
may well be necessary in applications which derivative throughout the interval h in
are time critical and involve relatively fast equation (4.1) is the value of the derivative at
dynamics. time to. In terms of equation (4.2) this gives
A number of different factors must be taken
into account in the selection of an integration x(t + h) = x(t) + h( ~) (4.3)
method for the solution of a given problem.
One obvious question to be considered is and this shows clearly that the new value of x
whether the integration steplength should at time (t + h) is calculated from the value of x
be constant or variable. Some integration at time t and the derivative at time t. For the
algorithms select their own integration step case of equation (4.1) this means that for a
size since a value of h which is satisfactory in given input variable u(t) the solution of the
one part of the time interval may not be good differential equation starting from an initial
elsewhere. For other types of application, value x(to) follows the sequence shown below:
such as real-time simulation, there may be
good reasons for avoiding such methods.
One broad classification for integration
techniques used in simulation involves the x(to + 2h) = x(to + h)
timing of the sampling operation which is +h[ax(to + h) + bu(to + h)]
inherent in the integration process. On the one
hand, an algorithm which requires only x(to) x(to + 3h) = x(to + 2h)
and u(to) to calculate the right-hand side of +h[ax(to + 2h) + bu(to + 2h)]
equation (4.2) and thus provide an estimate of
x(to + h) is known as an 'explicit' method. On etc.
the other hand, a technique in which x(to + h) The processes involved can be illustrated by
itself appears on the right-hand side of the taking a particular example and following
expression to be evaluated inevitably presents through the calculations. Consider the case
more difficulties and is termed an 'implicit' where a =-2 and b =2 and the input is a unit
approach. Implicit algorithms are not nor- step function, u(t) = 1, with an initial value
mally used in continuous system simulation. x(to) = o. The corresponding transfer function is
One example of an implicit method is the
backward Euler integration algorithm in X(s) 2 1
--=--=--- (4.4)
which the quantity x(t + h) is approximated U(s) s+2 1+0.5s
using values of x(t) and dx(t + h) / dt, where h
For the unit step function input it may be
is the integration interval.
shown, by means of the final value theorem,
that the theoretical steady-state response of
this system is 1.0. It is also evident from the
4.2 FIXED-STEP INTEGRA nON
form of the transfer function, as shown in
ALGORITHMS: ONE-STEP METHODS
equation (4.4), that the system has a time
constant of 0.5 s and represents a system with
4.2.1 INTRODUCTION
simple first-order lag characteristics. An
One simple integration algorithm which example of such a system is the simple
provides a useful introduction to fixed-step resistor-capacitor network of Fig. 4.1 with the
integration methods is the Euler method. In state variable x(t) chosen to represent the
Fixed-step integration algorithms: one-step methods 53

R x(t) = 1- e-2t (4.7)

uro~-I I c l It should be noted that at t = 0.5 s, which is


equal to the value of the time constant, the
true analytical result is 0.632 and that the
numerical result for this value of integration
step is significantly different from this.
Similar differences also exist at the other
Fig. 4.1 A resistor-capacitor network of the form points in the sequence. Figure 4.2 shows the
represented by the transfer function of equation
(4.4). analytical solution and numerical results for
this case and for the case of h = 0.05 s.
Reduction of the integration step clearly
voltage across the capacitor and the input u(t) improves the accuracy for this example.
the voltage applied at the input terminals. Figure 4.3 shows numerical results for cases
Typical values of the components Rand C in which h is chosen to be 0.8 and 1.01. The
to give the model specified in equation (4.4) response found for an interval of 1.01 is
are 1 Mil and 0.5 JLF, although any other divergent and shows clear signs of numerical
combination of values giving a product RC of instability. The results are clearly erroneous
value 0.5 would be equally appropriate. and display an oscillation which is not
Applying the Euler method for an inte- characteristic of the real system. This
gration step size of h = 0.1 s gives an output at illustrates very clearly the dangers of using an
x(to + 0.1) as follows inappropriate steplength, a topic to which we
return in section 4.4.
x(to + 0.1) = x(to) + 0.1 [2 - 2x(to)] (4.5) Although the Euler method provides a
that is convenient way of introducing fixed-step
integration methods and the general principles
x(to + 0.1) = 0.8x(to) + 0.2 (4.6) of numerical integration algorithms for
simulation applications, the technique is of
For an initial value of x at t = to of zero the limited practical importance because it uses a
sequence of values generated by the repeated poor estimate of the mean value of the
application of the algorithm is as follows derivative over the integration interval. It is
x(O) = 0.0 possible to achieve much higher levels of
accuracy, for the same integration steplength,
x(O.l) = 0.8(0.0) + 0.2 = 0.2
by using other integration algorithms. The
x(O.2) == 0.8(0.2) + 0.2 = 0.36 next section provides a general framework that
is the basis of a number of important methods.
x(0.3) = 0.8(0.36) + 0.2 = 0.488

x(O.4) = 0.8(0.488) + 0.2 = 0.5904


4.2.2 TAYLOR SERIES DESCRIPTIONS
x(O.5) = 0.8(0.5904) + 0.2 = 0.67232
If x(t) is a smooth function, and thus has
x(0.6) = 0.8(0.67232) + 0.2 = 0.737856 enough continuous derivatives, it is possible to
write x(t + h) by means of the Taylor series as
etc.
1
x(t + h) = x(t)+ hx'(t) +-h 2 x"(t)
These values can be compared with the true 2!
analytical solution, which can be found very 1 1
+-h 3 x"'(t) + ... + - hnx(n)(t) + ...
easily by means of Laplace transform 3! n!
methods as (4.8)
1.0 ........ a

0.9

,...
~o.s

0.7

0.6

0.5

0.4

0.3

0.2

0.1

0.0

Fig. 4.2 Results from a simulation run involving a unit step input voltage change for the model defined
by equation (4.4) using Euler integration method. (a) Results obtained using an integration steplength of
0.1 s over a period of 5 s. (b) Results for an integration steplength of 0.05 s over a period of 2.5 s. The exact
responses, obtained analytically using Laplace transform methods, are shown by continuous curves in
both cases, whereas the simulated results are shown by means of dashed lines.
1.6 a

1.4

-.e
)(
,
1.2
I
:, .•
, ,"
I
,,"
,, \ ,:'
1.0
, ,, ",
",
0.8

0.6

0.4

0.2

0.0

0 4 6 10 12 14 16
time t

2.6
b
2.4 ,
i •
) ••
~
2.2
fi " I:"
ii
~ ~\ "
I, "
"""
j ,I
.e
)(
2.0
I
:"~
"
"
",I""'I iI,"' "
I:
:\" i"\ :1I1\: ,n, !!
1.8
:\ ,I
I,
"
',
' I
:\ , : 'I
:, I
I\,
I,
,I ', I I,
'' !\ ,, ,, ,," ,I II , ,I
I,
1.6 ,' II
,, ' I
, \ ,I I

:, 1 ,
I ' I
I,
,, , ,i , ,,, ,,, , :,,
' I
; , I
I
I I

,, ,
I
1.4 , I I !, ,I
:, , :
I
, I

,
,i i ,,,
I
: \ ,i I

,,:
I
I
I I
, I

, ! ,,, ,, :, ,:
I I
1.2 , \ I I
,1 :, I :,,
I , :
I I
I :I

1.0 ,I , I I
, I

, I ,,
I I I I
,I : ,, I ,
, :
1,, :, i:
I
0.8
,,i ,, I I

, 1 ,, I

,, I
,
,,
0.6
,I '' ,, :I ,, ,,
! I I

,'
I'
.::, .., . ,,, .''
, I I
I
,, ,, I
\ ,, I , ,
I
I

i
0.4 I
I'
""
,,
, , ,, ,,' , ' ,, I I, I'
I' ,,
" "
I'
" " ,, ',
, I
I,
I'
,: I

H
,
0.2 I'
I' ' I

" . "'
I

""•
" " ,I

"" "" "II,, :; I,


, I
\
~
"I'
0.0

'().2
: I
"I'
~
I
~,
I
".,
"
.", "
"" ":i
""
"
"
I,

"I,
I,
I,
,
I

,
I

~
I
I "
~
I
I
,,
'().4
I
,
'().6
0 2 4 6 8 10 12 14 16 18 20
time t

Fig. 4.3 Results similar to those of Fig. 4.2 obtained using the Euler integration method with integration
steplengths of 0.8 s (a) and 1.01 s (b). Dashed lines show the simulated responses in both cases, while
exact solutions (calculated using Laplace transform methods) at the time instants corresponding to the
start of each integration interval are shown by the continuous lines.
56 The principles of numerical modeling
If h is small and if x(t) and its derivatives are value is not known. The only known quan-
all known, the truncated series involving tities are the approximate value and an
(n + 1) terms can be used to calculate x(t + h). estimate of the error or a bound on the
When only terms up to and including maximum size of the error. In the case of
h"xi"l(t)/n! are present in the series the numbers dose to unity the absolute and
representation is said to be a Taylor series of relative error values are very similar. For
order n. numbers which are not close to I, the absolute
Examination of the Taylor series in and relative errors can be very different. For
equation (4.8) shows that Euler's method example, for a true value of 345 678 and an
involves a Taylor series of order 1. Clearly the approximate value of 345 123 the absolute
inclusion of additional terms in the Taylor error is 555 but the relative error is only
series is one way of improving the accuracy 0.0016 (0.16%). Similarly, if the true value is
of the numerical integration process. This is, 0.00003 and the approximate value is 0.00002
however, of limited practical value for the absolute error is 0.00001. However, the
general simulation use since we need to relative error in this case is 0.5 (50%).
obtain the derivatives associated with the Errors in numerical calculations are of three
terms in h, h2, h3 , ••• , etc. It is clearly not types, which are known as inherent errors,
appropriate to carry out this differentiation truncation errors and round-off errors.
analytically in the general case, and esti- Inherent errors are errors in the data upon
mation of the higher derivatives can present which the program depends. In the context of
major difficulties. simulation these might be errors in the values
Although Taylor series solutions are not of constants describing elements within
themselves of great practical value in the mathematical model upon which the
providing algorithms which are of use for simulation program is based. Errors of this
simulation, they do provide a basis for the kind may arise because of simple mistakes in
evaluation and comparison of other methods recording values to be used, because of errors
that are of practical importance. In this in the measurement of some physical quan-
respect the Taylor series provides a tity within the system represented by the
convenient yardstick: some integration model or because a number, such as TT, has
methods will agree with the Taylor series not been represented with sufficient accuracy.
solution only as far as terms in h, others Errors also arise in part because of the fact
through terms involving h2 or beyond. that the integration process involves an
approximation which can be regarded as
equivalent to truncation of a Taylor series
4.2.3 ERRORS IN FIXED-STEP INTEGRAnON
after some finite number of terms. In general,
METHODS
the truncation error at each step is of the
An error is defined here to be the true value order of the first term dropped. For example,
minus the approximate value and may be in the Euler method the truncation error can
expressed either as an absolute error or as a be shown to be of the order of h2 • In more
relative error. The absolute error is defined to complex methods, such as the fourth-order
be the difference between the true value and Runge-Kutta approach discussed in the next
the approximation. The relative error is the section, the truncation error is of the order of
absolute error divided by the approximate h5 or better. For small values of the integration
value. It might appear at first to be better to steplength, there are clearly very large
define the relative error as the absolute error benefits in terms of accuracy in using these
divided by the true value, but it must be more complex techniques, in comparison
remembered that in most situations the true with the Euler method.
Fixed-step integration algorithms: one-step methods 57
The third type of error, round-off error, Euler's method can be extended in a
arises because quantities are represented number of ways. One approach of this kind is
within the computer using a finite number of known as the 'improved Euler method'. This
binary digits. Different compilers handle the is a two-stage method in which an estimate of
rounding of numbers in different ways, and the next point is first made using the Euler
detailed discussion of this topic is beyond the method. The derivative is calculated for
scope of this text. Many books on numerical this estimated point. The average of this
methods provide further information on derivative value and the derivative at the
round-off problems and truncation errors beginning of the step is then used to
(e.g. ref. 1). recalculate the next point. The process can be
illustrated using the example previously
discussed in the context of Euler's method
4.2.4 EXPLICIT RUNGE-KUTTA METHODS
involving the differential equation
Explicit Runge-Kutta methods are closely
dx
related to the Taylor series approach and - = -2x(t) + 2u(t) (4.10)
provide a convenient solution to the problem dt
of determining the necessary derivatives For a unit step input [u(t) = 1 for t > 0)] and an
without using any form of analytic integration interval of 0.1 s the first estimate
differentiation. These methods have three of x(t + 0.1) is given by
main properties which may be summarized
xe(t + 0.1) = x(t) + 0.1[2 - 2x(t)] (4.11)
as follows:
that is
1. Explicit Runge-Kutta methods are one-
step methods and require information to xe (t + 0.1) = 0.8x(t) + 0.2 (4.12)
be available from one preceding point
Using this value for the estimate of x at time
only.
t + 0.1 and substituting in equation (4.10) gives
2. Runge-Kutta methods do not require the
an estimate of the derivative value at this time
evaluation of any derivatives of the
function I in the differential equation
( dX)
dt
= 2 - 2[0.8x(t) + 0.2]
dx e
- = I(x,u,t) (4.9) =1.6-1.6x(t) (4.13)
dt
All that is needed is the value of the The average derivative value is then given by
function I(x, u, t) itself.
3. Runge-Kutta methods include a number
of different algorithms which are dis-
o.s[(~) + (~)J = 1.8 -1.8x(t) (4.14)

tinguished by their 'order'. The order is


This expression can then be used to obtain a
defined by comparison with the Taylor
final estimate of x(t + 0.1) as
series. If a Runge-Kutta method agrees
with the Taylor series through terms in hP, x(t + 0.1) = x(t) + 0.1[1.8 -1.8x(t)]
the index p is the order. = 0.82x(t) + 0.18 (4.15)
Clearly the Euler method satisfies the three Figure 4.4 shows a comparison of the
conditions given above. It is an explicit response computed in this case with the
Runge-Kutta method and it is a method of analytic solution. It can be seen that there is a
order 1 since it agrees with the Taylor series significant improvement in accuracy when
through terms in h, as already noted in the compared with the results of the simpler
previous section. Euler method in Fig. 4.2.
58 The principles of numerical modeling

1.0

0.9

0.8

-
~
)( 0.7

0.6

0.5

0.4

0.3

0.2

0.1

0.0

M ~ M 0.6 M W U U U U w
time t

Fig. 4.4 Results similar to those of Figs 4.2 and 4.3 using the 'improved Euler' integration method with an
integration step of 0.1 s. The corresponding analytic solution is shown for comparison. The dashed line
shows the simulated response while the continuous line is the analytical result.

It should be noted that the calculations second-order case. Let the subscript k denote
shown here for the Euler method and the evaluation at time t k• Then tk+! denotes time
improved Euler method are particularly (t k + h) where h is the integration st~plengh.
straightforward because the input u(t) has Truncating the Taylor series after the second
been chosen to be a constant. In the more term gives
general case where the input is time varying,
the equations to be solved repeatedly at each Xk+l = Xk +hXk +0.5h2xk (4.16)
integration step are slightly more complicated. Thus, in terms of the notation of equation
However, the example chosen does illustrate (4.9), that is
the two methods very effectively.
Xk+l = Xk + h/k + 0.5h 2 (df )
The improved Euler method can be shown (4.17)
to involve an algorithm which agrees with the dt k

Taylor series solution through terms in h2• It is


thus a second-order Runge-Kutta method. However
More complex Runge-Kutta methods involve
estimates of three or more derivative values. df = at + at dx = at + at f (4.18)
The basis for the derivation of a Runge-
dt at ax dt at ax
Kutta algorithm of any order may be Simplifying the notation by using fx and ft to
understood readily by considering the denote the partial derivatives of f with respect
Fixed-step integration algorithms: one-step methods 59
to x and t respectively. Equation (4.18) then Although second-order Runge-Kutta algo-
becomes rithms have been of interest for some parti-
cular types of application where processor
df
dt -- f +fx f
}t
(4.19) time is critical and there is need to minimize
the number of separate calculations for each
and equation (4.17) takes the following form integration step, the most commonly used
Runge-Kutta methods for general simulation
Xk+1 = Xk +hfk +0.5h 2 (t + fxj)k (4.20) purposes involve a fourth-order algorithm.
In second-order Runge-Kutta methods Xk + I is The derivation of the relevant expressions is
expressed as essentially the same as in the second-order
(4.21) case except that all terms up to h4 are retained
[3]. The resulting expression is
where WI and W2 are constant weighting
factors and gl and g2 are as follows Xk+1 = Xk + wlgl + W2g2+ W'lg3 + W4 g4 (4.24)
gl = hf(tk,Xk)
gl = hf(tkt Xk)
g2 = hf(t k + alh, Xk + algI)
g2 = hf(t k + ah, Yk + f3hfk)
g3 = hf[t k +a 2h,xk + f32g2 +(a2 - f32)gl]
The quantities a and f3 are constants.
Comparison of equation (4.21) with equation g4 = hf[tk +a3h,xk + f33g2 + Y3g3
(4.16) provides a basis for determining WI' W2, +(a 3 -f33-Y3)gl]
a and f3. First of all, the function f in the
expression defining g2 must be expanded as a The comparison with the Taylor series gives
Taylor series in two variables to give eight equations. Since there are 10 para-
g2 =h[A+(fthah+(fx)kf3hf+ .. ·] (4.22) meters, two of these may be chosen inde-
pendently. Many possible solutions are
where the omitted terms are of the order h2 • available, and one of the most widely used is
This expression for g2' together with the the so-called 'classical' method in which
expression already found for g]f may now be
substituted into equation (4.21) to give wl =w 4 =1/6
Xk+1 = Xk + h(wl f + w2j)k + h2 (WI aft + w2f3ff, h W2 = W3 = 1/3
(4.23) a l =a 2 =1/2
Comparing the right-hand side of this
equation with the right-hand side of equation
(4.20) for like powers of h gives

Another important method is known as


W2f3 = 0.5 Ralston's method, which minimizes a bound
on the truncation error [1]. For this the
Here we have three equations in four coefficients are
unknowns. One of the quantities w]f W 2, a and
f3 may therefore be chosen independently. WI = 0.17476028
The most common choice is to take a = 2/3 w 2 = -0.55148066
since this can be shown to minimize the
truncation error [2]. W3 = 1.20553560
60 The principles of numerical modeling
W4 = 0.17118478 ult\
a! = 0.4
a 2 = 0.45573725

/32 = 0.15875964
/33 =-3.05096516
Y3 = 3.83286476

4.2.5 TRAPEZOIDAL INTEGRATION


Trapezoidal integration is a form of numer-
ical integration which is more accurate than
the Euler method but is also very simple and a
can be of value in specialized applications,
such as real-time problems in which con- ult\
straints on processor time make the use of
more complex algorithms inappropriate. It
will be recalled from section 4.2.1 that the
Euler integration method uses a constant
value for the derivative over the integration
interval and the integral is approximated by a
rectangular area as shown in Fig. 4.5a. The
corresponding area used in the trapezoidal
method is shown in Fig. 4.5b. The trapezoidal
method takes into account an additional area
below the curve which is approximated by a
triangular shape. For example, for a differ-
ential equation

dx b
-=U (4.25)
dt Fig. 4.5 The difference between the Euler (a) and
trapezoidal (b) integration algorithms.
the trapezoidal integration method gives, for
the single step from tk to tk+!
4.3 FIXED-STEP INTEGRAnON
ALGORITHMS: MULnSTEP METHODS
f
tk+l

u(t)dt = hu(tk)+O.5h[u(tk+!)-u(t k)]


The improved Euler method, which was
tk
described in outline in section 4.2.4, involves
a two-step process in which an estimate is
made of the next point, and this estimate is
where h = tk+! - t k. This then gives the tra-
subsequently corrected. Other types of
pezoidal integration algorithm
multistep integration technique also exist,
Xk+! = Xk + O.5h[Uk+! + Uk] (4.26) and these are given the general name of
Step-size selection and numerical instability problems 61
predictor-corrector methods. In all these interval. The integration step size should then
cases we first 'predict' a value of x at the next be reduced by a factor of about 2 and a second
time point and then use a different expression set of test results should be generated.
to 'correct' this estimate. The correction Comparisons of the two sets of simulated
process may be applied more than once to responses should then be made and, if they
further refine the corrected value. agree to some specified level of accuracy, the
There are many different multistep second of the two intervals used in the tests is
formulae [1]. A k-step method uses values of normally adopted as a basis for further work
the dependent variable and its derivative at k with the simulation. If the two initial
different time instants and thus requires simulated responses do not agree to within
information from points prior to the current the required accuracy level, the integration
one. This means that they are incapable of interval should be reduced again and the
starting the integration process and some process repeated until convergence occurs.
other technique must be applied at the start to One might expect that as the integration
get the calculation under way. A Runge-Kutta interval tends to zero the numerical solution
method is often used as a means of starting a should approach the true solution of the
predictor-corrector algorithm. underlying differential equations. However,
There are several multistep methods which this is not entirely correct because numerical
have proved to be of particular value for real- errors associated with round-off become more
time continuous system simulation applica- and more significant as the integration step
tions. These include the Adams-Bashforth becomes smaller and the number of iterations
and Adams-Moulton methods. The Adams- required for a simulation run becomes larger.
Bashforth approach is an explicit multistep In general, truncation errors are dominant
method for which it can be shown [4] that when large values of integration step size
only one evaluation of the function f in are used, while round-off errors are more
equation (4.9) is needed for each time step, important for small integration steps, as
regardless of the value of k. The Adams- shown in Fig. 4.6. The procedure outlined
Moulton method is an implicit multistep above for selecting a satisfactory integration
approach but can give greater accuracy than
the equivalent Adams-Bashforth algorithm in
terms of both truncation errors and round-off
ERROR
errors. It is also a more stable algorithm. I
I

I
\ I
\ I
\ I TRUNCATION
4.4 PROBLEMS OF INTEGRATION \ I
" TOTAL / /
STEP-SIZE SELECTION AND NUMERICAL
" //
INSTABILITY
' ........... _----""'//
The process of choosing an appropriate
integration step size should begin by careful
consideration of the dynamics of the
mathematical model being simulated. A trial
ROUND-OFF
value, which is small in comparison with time
constants in the model or the period of any STEP SIZE
oscillatory components expected in the model
response, must be selected. A test solution can
then be generated from the simulation Fig. 4.6 An illustration of the dependence of round-
program using this initial choice of integration off and truncation errors on integration step size.
62 The principles of numerical modeling
step size usually involves an initial choice 4.5 VARIABLE-STEP INTEGRATION
which is larger than ideal. Successive ALGORITHMS
iterations involving smaller integration steps
In conventional fixed-step methods there is
generally move one towards the optimum.
always a need to estimate the precision of the
The use of double-precision quantities
integration calculations. A tolerance is
can often be helpful in reducing the effects
usually defined and the integration step size
of round-off errors within simulation
must be chosen to ensure that the errors do
programs.
not exceed the level specified by that figure.
In addition to the problems associated with
The determination of a suitable integration
numerical errors, which have been outlined
step size can present considerable difficulties
above, it is found that limits exist in terms of
in some cases. In particular, in nonlinear
the integration intervals for which a given
problems it may be appropriate to use a small
integration algorithm will be stable. Numer-
step size for one part of the operating range
ical instability can occur quite independently
while a much larger step may be sufficient
from questions of inaccuracy because of
elsewhere. Methods have therefore been
truncation or round-off and depends on the
developed for the automatic adjustment of
form of algorithm chosen and the step size
integration step size.
adopted. In simple fixed-step methods there
One widely used algorithm for variable
are a number of simple 'rules of thumb'
step integration is the Fehlberg algorithm.
which are quite widely used to assess the
The Fehlberg method of order 4 involves an
upper limit of the integration interval. For
algorithm of the Runge-Kutta type. The
example, if instability occurs at a particular
variable-step feature is incorporated by
value of integration step size, he' the critical
determining the difference between the
sampling frequency for the simulation, fe' is values of x(t k + h) calculated by fourth-order
given by the relationship
and fifth-order procedures. This difference is
taken as an estimate of the truncation error,
(4.27) and if this exceeds a given tolerance the step
size is halved. If the difference is much less
than the tolerance the step size is doubled.
The ratio of this critical sampling frequency
Many variable-steplength algorithms are to
to the highest frequency of interest in the
be found in the literature, and a number have
model, fmax, is of special interest. The ratio
been incorporated within widely used simu-
must always be greater than 2 and would
lation packages. A useful review of variable-
generally be chosen to be less than 10. In the
step integration techniques is provided in a
case of complex integration algorithms the
paper by Crosbie and Hay [5].
value chosen is likely to be in the upper half
of the range. One obvious question is how
the value fmax is found and this can clearly
4.6 PROBLEMS OF 'STIFF' MODELS
be difficult in practical problems. One
approach, which is useful in dealing with Systems in which responses contain some
models which are linear or can be linearized components which are very fast compared
for particular operating conditions, is to use with others are called 'stiff' systems. In the
transfer function methods and assess the case of linear models this corresponds to a
natural frequencies of the model and the situation where the characteristic equation
frequencies associated with each simple has roots which cover a very wide range of
pole. The highest of these frequencies is then values. A range of 1000 to 1 for these roots
taken as fmax' certainly constitutes a stiff system.
Discontinuities and their effects 63
The difficulties encountered in the both the very fast dynamics and the very
simulation of stiff systems arise because of the slow dynamics in a single simulation
nature of the transient response of a system of experiment is essential. One can usually make
this kind. Since the response contains some appropriate simplifying assumptions, which
components which are very much faster than can allow the stiffness of the model to be
others, the integration step size must be small reduced significantly, without adversely
enough to suit the most rapidly changing affecting the accuracy of the results. Bond
component. However, this small step size may graphs have been found to provide a basis on
be unacceptable in terms of the computing which to consider alternative models, and
time needed to obtain the complete solution these techniques can therefore sometimes be
which shows the full-time history of the slow of value in the elimination of irrelevant parts
components of the response. Even some of a model [6].
variable-step algorithms may not be capable Situations in which the complications of
of reducing the computing time to an stiffness cannot be avoided include certain
acceptable value in such cases. types of nonlinear problem and models
One obvious solution to the problem of involving time-varying coefficients. In such
stiffness is to redefine the model since this cases use can be made of special integration
type of numerical problem is often avoidable algorithms which have been developed for
by the use of appropriate approximations. stiff systems. A number of such algorithms
Physical insight and practical engineering are available, including one by Gear which is
knowledge can often be used at the initial widely used and is included as an option
model development stage to eliminate in many continuous system simulation
unnecessary features which can lead to languages [7].
problems of stiffness. For example, in the
simulation of a chemical process the
dominant time constants may well be of the 4.7 DISCONTINUITIES AND THEIR
order of many minutes. If a particular EFFECTS
instrument acting as a sensor for some
As has been seen in earlier sections of this
variable within this system has dynamic
book it is conventional to describe a con-
characteristics which can be described by a
tinuous system model by an equation of the
transfer function having a time constant of
form
0.1 s, it may be appropriate to consider
modeling the sensor simply as a gain constant dx(t)
and eliminating the sensor time constant, cit = f[t,x(t),u(t)] (4.28)
which is negligible in comparison with the
other process time constants. Such a course of where x(t) denotes the system state vector (of
action would be particularly appropriate if dimension n), f is the vector of derivative
interest is focused on the long-term behavior functions and u(t) is the input. Discontinuities
of the system. On the other hand, if one was can arise in two ways. The first of these
interested in examining the short-term behav- involves situations in which there is more
ior of the sensor following a sudden change than one set of derivative functions for the
in the variable being sensed, it would be more system model. Switching can occur from one
appropriate to regard the time constants of derivative function to another when a
the process as infinite and consider only the particular state variable in the model reaches
instrument dynamics in the simulation study. a predefined threshold value. Such transitions
There are relatively few situations with a may cause considerable problems for numer-
model of this kind where the inclusion of ical integration routines. The second way in
64 The principles of numerical modeling
which a discontinuity can occur is when there The zeros of the switch functions cPJt, x(t)]
is an instantaneous change in one or more of define events which involve discontinuous
the problem state variables. behavior.
The distinction between these two types of The same type of approach, based on the
situation may perhaps be understood more location of the zeros of a switch function, may
completely by considering some examples of be used also for the case of an instantaneous
simple cases in which discontinuities can change in a state variable. The first problem
occur. An example of the first type, in which is essentially one of establishing whether or
the derivative suddenly changes value, can not an event has occurred within the most
arise when simulating a system in which the recent integration step. If an event has
input u(t) is discontinuous, such as a square occurred the second stage is to determine the
waveform. A small change in the independent exact time of that event. This two-stage
variable (which we are assuming to be time) process can be described as a 'detection
can cause a very large change in the value of problem' and a 'location problem'.
the derivative owing to the sudden change in The detection problem can be approached
u(t) in going from one level to another. The by making use of information about the switch
resulting response in terms of time history of function cP; and its derivatives evaluated at the
x(t) can be highly sensitive to small errors in start and end of the integration step. If the start
timing of such sudden transitions in the of the current integration step is at time t1 and
derivatives. The second type of discontinuity the end of the same step is at time t21 it is
is typified by the problem of simulating an possible to define two auxiliary quantities 51
electrical circuit that involves diodes. These and 521 the signs of which can be used to
devices can conduct when operated with a establish the presence or absence of an event
positive voltage bias, but become non- in most common situations. The technique,
conducting when the voltage across the which has been used by Carver [8], and others,
device is negative. Since currents and voltages involves the following two equations:
are inevitably state variables in the
51 = cPi (t 1 )cPi (t 2 ) (4.30)
mathematical description for an electrical
system such as this, the discontinuities
5 = dcPi (t ) dcPi (t ) (4.31)
involve sudden cl}anges in quantities which 2 dt I dt 2
are state variables of the model. Similar
situations arise in mechanical systems which It can be shown that three main conditions
involve hydraulic elements such as valves. arise. These are as follows:
The simulation of the impact of snooker balls
1. If 51 > 0 and 52> 0 it may be assumed that
provides a further good example of a system
no critical points lie in the integration step
involving discontinuous behavior in terms of
under consideration and the integration
the state variables.
routine may be allowed to continue.
2. If 51 < 0 and S2 > 0 it should be assumed
4.7.1 NUMERICAL METHODS FOR that a single event lies within the interval.
DISCONTINUOUS PROBLEMS 3. If S1 > 0 and S2 < 0 it should be assumed
that there are two events within the inte-
The condition governing the switch from one
gration step in question and the step size
set of derivative functions to another may
should be reduced in order to modify the
often be described in terms of the solution of
situation and get a single event within the
a set of algebraic equations
interval. These three cases are repre-
eMt, x(t)] = a i = l,2,,,.,m (4.29) sented graphically in Fig. 4.7.
Discontinuities and their effects 65
One situation which is not adequately ~i
covered by the conditions given above is
shown in Fig. 4.8. Two zeros occur in the
integration interval, but these are not
detected because the values of <Pi and its first
derivatives at ends of the interval satisfy
condition 1. It should also be noted that in
some cases, such as that shown in Fig. 4.9, a
condition 51 < a and 52 < a could also define an
event within the interval.

Fig. 4.8 The discontinuity detection problem:


example of a situation not covered by the three
given conditions involving 5, and 52 [9].

Having established that an event occurs


within the integration step, the precise
location of the event must be determined.
This is a simple root-finding problem, and a
variety of methods can be applied. Details of
particular algorithms for detecting and
handling discontinuities are beyond the level
appropriate for a general text of this kind. A
paper by Birta, Oren and Kettenis [9]

til

tz

Fig. 4.7 The discontinuity detection problem:


possible graphical interpretations of the conditions Fig. 4.9 The discontinuity detection problem: an
on functions 51 and 52 (equations 4.30 and 4.31) example of a situation for which the conditions
which can indicate the existence of critical points 5, < 0 and 52 < 0 define an event within the
within the integration interval [9]. integration interval [9].
66 The principles of numerical modeling
provides a useful review of the main issues An alternative approach is to attempt to
and presents a detailed specification for a eliminate algebraic loops by careful model-
robust procedure for discontinuity processing ing. Those who advocate the use of bond
based on switch functions. Although the graph modeling techniques claim that the
switch function approach is the most widely understanding of causality which comes with
used, it should be noted that other methods the adoption of that approach allows the
exist that are based on examination of the modeler to become aware of algebraic loop
local truncation error in the vicinity of the problems at an early stage in the modeling
discontinuity. Although the switch function process [6].
approach leads to procedures which are
independent of the integration algorithm
REFERENCES
used, methods based on truncation errors
may be specific to a particular type of 1. Dorn, W.5. and McCracken, D.O. (1972)
integration process used. Numerical Methods with Fortran IV Case Studies,
John Wiley, New York.
2. Ralston, A. (1965) A First Course in Numerical
Analysis, McGraw-Hill, New York.
4.8 PROBLEMS OF IMPLICIT LOOP 3. Hornbeck, R.W. (1975) Numerical Methods,
STRUCTURES Quantum Publishers, New York.
4. Gear, C.W. (1971) Numerical Initial Value
If a simulation model has a block diagram Problems in Ordinary Differential Equations,
that includes any closed pathways, which do Prentice-Hall, Englewood Cliffs, NJ.
not include any integrators or delay elements, 5. Crosbie, R.E. and Hay, J.L. (1971) Variable
there are inevitable additional problems in step-length integration routines. Simulation,
obtaining a numerical solution. Such features, 17 (5), 206-12 (including discussion).
known as 'implicit' or 'algebraic' loops, 6. Karnopp, D. (1981) Using bond graphs in
nonlinear simulation problems. Simulation,
also present difficulties in analog methods
36 (6), 183-92.
of simulation. One simple approach to 7. Gear, C.W. (1984) Efficient step size control for
overcoming an implicit loop problem is to output and discontinuities. Transactions of the
convert the closed path in question into an Society for Computer Simulation, 1, 27-3l.
equivalent explicit loop. This may be done by 8. Carver, M.B. (1978) Efficient integration over
adding a very small time delay or a first-order discontinuities in ordinary differential equa-
transfer function with a small time constant. tion simulations. Mathematics and Computers in
The numerical values must be chosen so that Simulation, XX, 190-96.
9. Birta, L.G., Oren, T.1. and Kettenis, D.L. (1985)
the added delay or time constant is very small A robust procedure for discontinuity handling
compared with the magnitude of any time in continuous system simulation. Transactions
delays or time constants in the remainder of of the Society for Computer Simulation, 2 (3),
the simulation model. 189-205.
SAMPLED-DATA MODELS AND
OPERATOR METHODS 5

5.1 INTRODUCTION ous model were sampled and allows a differ-


ence equation approximation to be derived.
Difference equations are easy to program in
Figure 5.1a shows the block diagram of a
comparison with differential equations.
linear continuous system, while Fig. 5.1 b
Although they are normally associated with
shows the equivalent sampled-data represen-
models of entirely discrete systems, with
tation. Here the block labeled G},(s) is the
sampled-data systems or with digital control
transfer function of the data reconstructor.
systems which are partly continuous and
This is usually chosen to be a zero-order hold,
partly discrete, difference equations can also be
or possibly a triangular hold. The zero-order
used in the simulation of continuous systems.
hold is simple in terms of its properties and is
The mathematical treatment of discrete
particularly appropriate for use in applica-
systems and of sampled data is a major area
tions in which the input has a discontinuous
of study in its own right. Most textbooks on
form (e.g. involving step functions). The tri-
digital control provide a review of some of
angular hold may be preferred where the
the aspects of the theory of sampled-data
input is more regular in form.
systems. The texts by Rosko [1] and by Smith
Applying z-transform analysis to the sys-
[2] present the relevant theory in the context
tem of Fig. 5.1b it follows that
of the modeling of dynamic systems. Such
texts provide an introduction to the z-
Y(z) = G"G(z)U(z) (5.1)
transform, which is a mathematical tool of
fundamental importance in this field. The
where
notation of z-transforms is used extensively
throughout this chapter. G"G(z) = Z[G,,(s)G(s)] (5.2)

5.2 APPROXIMATIONS BASED ON For the case of a zero-order hold


SAMPLED-DATA THEORY
1- e-,r
It must be emphasized, first of all, that the G,,(s)=--- (5.3)
s
sampled response of a system is not obtained
simply by inserting samplers at the input and
where T is the period of sampling.
output of each block within a block diagram
Hence
description. However, if the input is sampled
and a data reconstructor is placed after the
sampler, the sampled response should be Y(z) = (1- Z-1 )z[ G~S) ]U(Z)
similar to that of the system with a conti-
nuous input. This allows one to proceed as if
both the input and the output of the continu-
= z: 1Z[ G~S) ]U(Z) (5.4)
68 Sampled-data models and operator methods
U(s)

·1
G(s) PS)
a

U(s) U(z) Y(z)

-/.-j G,,(s)
H G(s)
~-
b

Fig. 5.1 A linear continuous transfer function model and the equivalent sampled-data approximation.
(a) The block diagram representation of a linear single-input single-output system having transfer function
G(s). (b) The conventional block diagram representation of the corresponding sampled-data approximation
involving a sampler and hold block Gj,(s). This provides the basis for a digital simulation of G(s).

For the case of a triangular hold, which is That is


another form of data reconstructor
Y(z) = (z - 1) [ (1- e- IOT )z ] (5.9)
U(z) z (z-1)(z-e- 10T )
(5.5)

and when T = 0.02 s


and thus for this choice
Y(z) 0.1813
(5.10)
Y(z) = (z _1)2 z[G(S)]U(Z) U(z) z - 0.8187
(5.6)
Tz S
Rearranging this equation gives
The use of such data reconstruction
elements, together with the transfer function Y(z) =0.8187z-l y(z) + 0.1813z-I U(z) (5.11)
in z-transform form, to generate a discrete
representation of the output variable is best which is equivalent to a difference equation
illustrated through a specific simple example.
Consider a first-order transfer function y(kT) =0.8187y[ (k -1)T] + 0.1813u[ (k -1)T]

(5.12)
G(S)=~ (5.7)
s+ 10 The response for a unit step function input
applied at time zero can be calculated very
For the case in which a zero-order hold is easily by hand, assuming zero initial condi-
used, the overall transfer function is tions. At the first evaluation (t = 0.0) the
quantities y[(k-1)T] and u[(k-l)T] are zero
Y(z) _ z -1
u(z) z
z[ 10]
s(s + 10)
(5.8) so that y(kD found from the difference equa-
tion is also zero. At the second evaluation
Linear systems modeling using sampled data 69
u[(k-l)T] is unity while y[(k-l)T] is the calculated response from the discrete approx-
value of y(kT) found at the first evaluation imation would not be exact and the error
(i.e. zero). This gives a new value of y(kT) of would be dependent upon the sampling
0.1813, and this is therefore the response at period.
t = 0.02 s. This value is then assigned to the The programming of a difference equation
quantity y[(k -l)T] for evaluation of the model using a general-purpose high-level
response at 0.04 s, and so on. Table 5.1 shows programming language, such as Fortran,
the step response of the approximate model Pascal or C is very straightforward. The solu-
calculated in this way, together with the tion time can be made very short and this
exact response of the continuous model type of approach has proved valuable for
found by means of Laplace transforms. It can real-time applications.
be seen that in this case the agreement is
almost exact, the only differences being asso-
ciated with round-off effects in the fourth
decimal place. For other forms of input the 5.3 MODELING OF LINEAR SYSTEMS
USING SAMPLED-DATA APPROXIMATIONS

Table 5.1 Results for the simulation of the first- 5.3.1 CASCADED ELEMENTS
order transfer function of equation (5.7) for a unit
step function input. The table shows the numerical The modeling of cascaded linear systems by
results y(kT), for T = 0.02 s, together with the means of sampled-data approximations
response of the continuous model, y(t), found involves a straightforward extension of the
using Laplace transform methods approach described in section 5.2 for a single
transfer function. For example, the discrete
k kT y(kT) y(t)
model of a system involving several blocks in
1 0.02 0.1813 0.1813 cascade (as shown in Fig. 5.2a) can be
2 0.04 0.3297 0.3297 obtained by attaching a sampler and data
3 0.06 0.4513 0.4512 reconstructor to the input and a sampler at
4 0.08 0.5507 0.5507 the output of each element. The equation
5 0.10 0.6322 0.6321
defining the output of the first element Gj(s)
6 0.12 0.6989 0.6988
7 0.14 0.7535 0.7534
then becomes, in the discrete model
8 0.16 0.7982 0.7981
9 0.18 0.8348 0.8347
10 0.20 0.8647 0.8647
11 0.22 0.8892 0.8892
12 0.24 0.9093 0.9093
Similarly, for the outputs of the other ele-
13 0.26 0.9258 0.9257
14 0.28 0.9392 0.9392 ments we have
15 0.30 0.9502 0.9502
16 0.32 0.9593 0.9592
17 0.34 0.9666 0.9666
18 0.36 0.9727 0.9727
19 0.38 0.9776 0.9776
20 0.40 0.9817 0.9817
21 0.42 0.9850 0.9850
22 0.44 0.9877 0.9877
23 0.46 0.9900 0.9899
24 0.48 0.9918 0.9918
25 0.50 0.9933 0.9933
(5.14)
70 Sampled-data models and operator methods

-1 GII(S)

Uls)
T
~

Fig. 5.2 Block diagrams of a linear system involving n single-input single-output cascaded blocks. (a) The
continuous model. (b) The sampled-data equivalent.

and a separate difference equation may be


found for the output of each of the cascaded (S.16)
elements in response to the input u(kT).
The steps involved in generating the differ-
5.3.2 CLOSED-LOOP SYSTEMS ence equations from these transfer functions
Many physical systems can be represented by are exactly the same as those already outlined
block diagrams which incorporate feedback for the simpler models considered previously.
pathways, even in cases where no obvious The transfer functions are first expanded and
feedback mechanisms eXIst and where no the coefficients of like powers of Z-1 are col-
feedback has been introduced for control pur- lected. This allows the difference equations to
poses. The treatment of such systems is a be formulated for each discrete output vari-
simple extension of the methods outlined in able in turn.
the previous sections for single transfer func-
tions and for cascaded elements.
For the systems in Fig. S.3a and b it is clear
that in the discrete model (Fig. S.3b) the rela- 5.4 MODELING OF NONLINEAR SYSTEMS
tionship between the discrete signal U(z) and USING SAMPLED-DATA APPROXIMA nONS
the discrete signal R(z) is given by the transfer
function 5.4.1 CASCADED ELEMENTS

In the simple case of a linear transfer function


cascaded with a nonlinear block, two arrange-
ments are possible. Either the nonlinear ele-
ment comes in front of the linear block or it
Similarly, the transfer function relating the follows it. Consider first the case of a linear
discrete model output Y(z) to the signal R(z) element which precedes a nonlinear block, as
is given by shown in Fig. S.4a and b.
Nonlinear systems modeling using sampled data 71

R(s) Yes)

G(s)

R(s) R(z)
T

- U(z)

-
Y(z)

T
V(z)
b

Fig. 5.3 Block diagrams of a linear system involving feedback. (a) The continuous model. (b) The corre-
sponding sampled-data representation.

The discrete transfer function for the linear y(kT) = f[Yl (kT)] (5.19)
portion of the system is in this case given by
the equation If, on the other hand, the nonlinearity pre-
cedes the linear element, as shown in Fig. 5.5a
Y1(Z) = Z[Gh(s)G(s)] (5.17) and b, the discrete output of the nonlinear
U(z) element is given by

and thus the difference equation description Yl (kT) = f[ u(kT)] (5.20)


for this element will take the form
To obtain the difference equation in terms of
Yl(kT) = a1Yl[(k-1)T]+a 2Yl[(k-2)T] the output of the linear element, y(kT), it is
necessary to regard the nonlinearity as an
+... + bou(kT) + b1u[(k -l)T] + ...
ideal amplifier having a gain n(kT) which
(5.18) changes at each sampling instant. This gain is
defined by the equation
The output of the nonlinear element can
b represented by an expression of the n(kT) = Yl (kT) = f[ u(kT)] (5.21)
form u(kT) u(kT)
72 Sampled-data models and operator methods

___
U__ ~.I_ __S_)__~I " ·I~_:nei __~-Y
a

Yl(11)

u(l1)
....-. y(J:1)
u
~.- GII(s) G(s)
nonlinear
...-.
element

Fig. 5.4 Block diagrams of a single-input single-output system with a linear element followed by a static
nonlinearity. (a) The continuous model. (b) The equivalent sampled-data representation.

'1
~
y
nonlinear
element -I G(s) ~

a
,)(k1)
.--.-
u(l1) y(l1)
U T
--/ GII(s) nonlinear
element
G(s) • •

Fig. 5.5 Block diagrams of a single-input single-output system with a static nonlinearity followed by a
linear element. (a) The continuous model. (b) The equivalent sampled-data representation.

Hence, the overall transfer function may be and thus the difference equation takes the form
written as
y(kT) = a1y[ (k -l)T] + a2Y[ (k - 2)T]
Y(Z) = Z[Gh(s)n(kT)G(s)] (5.22) + ... + bou(kT) + b1u[(k -l)T] + ...
U(z)
That is (5.24)

Y(Z) = n(kT)Z[Gh(s)G(s)]
In this case the a and b coefficients depend
(5.23)
U(z) both upon the linear elements and on n(kD.
Nonlinear systems modeling using sampled data 73
Thus, unlike the previous cases where The complete closed-loop transfer function is
the coefficients are constant, these quan-
tities must be evaluated at each sampling Y(z) _
R(z)
z[ + n(kT)G1 (s)
1 n(kT)G1(s)G 2 (s)
] (5.26)
instant.
and the transfer function relating the feed-
5.4.2 CLOSED-LOOP MODELS back variable V(z) to the input R(z) is given
by
The treatment of a closed-loop model which
incorporates a single nonlinear element is
essentially the same as that adopted for non-
V(z) _
R(z)
z[ +n(kT)G1(s)G 2 (S)]
1 n(kT)G1 (s)G 2 (s)
(5.27)

linear cascaded elements. Consider the block


However, the quantity e(kT) is given by the
diagrams of Fig. 5.6a and b. The nonlinear
equation
element is replaced by an element having a
gain factor which changes at each sampling e(kT) = r(kT) - v(kT) (5.28)
instant in the following way:
and since v(kD depends upon n(kT), which
n(kT) = u(kT) = f[ e(kT)] (5.25) itself is a function of e(kT), it is clear that this
e(kT) e(kT) set of equations has no solution. In order to

-
y(kTJ

~z) -- T
b

Fig. 5.6 Block diagrams of a feedback system with a static nonlinearity in the forward path. (a) The con-
tinuous model. (b) The equivalent block diagram for the sampled-data representation.
74 Sampled-data models and operator methods
avoid this problem it is conventional to insert x(to) the exact solution of the state equation
a delay of one sample period in the feedback can be shown to be
loop. This does introduce an error, but this I

may be minimized by an appropriate choice f


x(t) = eAU-lo)x(to) + e AU -T1 Bu(T )dT (5.36)
of the sampling interval T. With this delay 10
included
If the state and output variables are sampled
e(kT) = r(kT) - v[ (k - l)T] (5.29)
periodically at times t =kT we obtain a solution
and the variable gain element representing KT
the nonlinearity is described by the equation f
x(kT) = eAtkT-IO)x(to) + eAtkT-T1Bu(T )dT (5.37)

n(kT) = f[ e(kT)] = f{r(kT) - v[ (k - l)Tn


10

e(kT) r(kT) - v[ (k - l)T] Hence at time t = (k - l)T we have


(5.30)
This gives three equations in difference equa- tk-l)T
tion form. They are as follows: + f eA[tk-lJT- lo]Bu(T )dT (5.38)
10
u(kT) = f{r(kT) - v[(k -1)Tn (5.31)
Multiplying equation (5.38) by eAT and sub-
n(kT) = u(kT) (5.32) tracting it from equation (5.37) gives
r(kT) - v[ (k - 1)T]
kT
y(kT) = a1y[ (k - l)T] + a2Y[ (k - 2)T] x(kT) = eAT x(kT - T) + fe AlkT -7 I BU(T )d T
(k-1)T

+... + bor(kT) + b1r[ (k - l)T] + ...


(5.39)
(5.33)
Here eAT is a constant matrix which need only
where the a and b coefficients again depend be calculated once. However, the integral
upon the linear transfer function elements must be calculated at each sampling instant.
and on n(kD. If the given continuous model is repre-
sented, as before, by a discrete model which
includes a zero-order hold in cascade (as
5.5 SAMPLED-DATA DESCRIPTION FOR A
shown in Fig. 5.7) the excitation u(t) will be
CONTINUOUS STATE-SPACE MODEL
represented in the discrete model by a
quantity which remains constant within each
5.5.1 LINEAR TIME-INVARIANT MODELS
sampling interval. Thus the difference equa-
Linear time-invariant systems are often tion reduces to
described by state-space models of the form kT

x=Ax+Bu (5.34)
x[kT] = eAT x[ (k -1)T] + u(kT) f eA1kT -7 Id T
tk-1)T

y=Cx (5.35)
(5.40)
where x(t) is a vector of n state variables, y(t)
However, it is clear that
is a vector of p output variables and u(t) is a
vector of m input variables. A, Band Care
constant matrices of dimension n x n, n x m f
kT
eAlkT-7ldr = f
T
eAIT-TldT (5.41)
and p x n respectively. For an initial condition (k-l)T 0
Operational methods for difference equation models 75

Gis) H G(sJ
y

Fig. 5.7 Block diagram, equivalent to that of Fig. [Link], for a sampled-data representation of a linear multi-
input multi-output system. Double lines have been used to indicate that inputs and outputs to the ele-
ments of the model involve a number of variables. The block G,,(s) represents an array of zero-order hold
elements. The block G(s) is a matrix of transfer functions. It should be noted that the matrix G in the
state-space representation of equations (5.42) and (5.45) is not the same as G(s) in this diagram.

and the differeHce equations representing the equation would have advantages. At each
given continuous model are as follows: time step the responses of all the cascaded
blocks could then be generated sequentially
x(kT) = Fx[ (k -l)T] + Gu(kT) (5.42)
since the output of one element is the input
y(kT) = Cx[(k -l)T] (5.43) to the element which follows it. An
important class of methods has been devel-
where the matrices F and G are given by oped which have origins in operational
calculus and which allow such sequential
(5.44) calculations [1,3]. These operational
and methods are quite widely used for real-time
applications.
G= f
T

eA(T-r)dT (5.45)
o 5.6.1 INTEGRATION OPERATORS

respectively. These two difference equations The process of integration may be repre-
are easily programmed to provide digitally sented by a transfer function
simulated responses for the continuous
model. The matrices need be calculated only (5.46)
once at tpe start of the simulation.
This state-space approach may be extended For the case of the trapezoidal integration
without difficulty to the case of nonlinear algorithm the difference equation represent-
equations. ing the integrator transfer function may be
written as
5.6 OPERATIONAL METHODS FOR
T
DIFFERENCE EQUATION MODELS y(kT) = y[ (k - l)T] + - { u(kT) + u[ (k - l)Tl)
2
It should be noted that in the methods so far
(5.47)
discussed in this section, calculation of the
outputs of a number of different block Taking z-transforms gives
diagram elements involves a separate differ-
T
ence equation for every block considered. Y(z) = z- l y(z) + 2{ U(z) + z- l U(z)} (5.48)
Each of these difference equations relates the
chosen output variable to the excitation and rearranging this gives the transfer
applied to the system input. function
This is not very efficient in terms of com-
puter time, and a method in which each GA (z) = y(z) = T z + 1 (5.49)
element is described by a separate difference U(z) 2 z-l
76 Sampled-data models and operator methods
The same approach may be used for many 5.7 SIMULATION USING OPERATIONAL
other integration methods. However, tech- METHODS
niques such as Runge-Kutta methods or pre-
dictor-corrector methods do not yield a 5.7.1 SIMULATION OF A SINGLE
discrete transfer function so readily since TRANSFER FUNCTION
more than one evaluation is needed of the
A digital simulation model of a given transfer
input and output variables at each sampling function element may be obtained from inte-
interval. Discrete transfer function models
gration operators by carrying out a well-
can also be found for continuous integrators
defined sequence of simple steps. Consider
of order 2 or higher. Rosko [1] provides
the case of a simple second-order linear
derivations for integrators of various orders
system shown in block diagram form in Fig.
for a number of the most widely used opera-
5.S. This has a transfer function
tor methods. Table 5.2 shows operators for a
number of cases for integrators of order 2
G(s) = a2 s + a]s + ao
1-4 inclusive. In some of these it may be (5.50)
b2s2 + b]s + bo
seen that the discrete transfer functions
for the integrals of order 2 and higher The steps involved are as follows:
follow directly from the first order case,
but in others the relationship is not so 1. Divide the numerator and denominator
straightforward. by the highest power of s in the denom-

Table 5.2 Commonly used integration operators for integrators of order 1-4 [1]

Operator

Method l/s 1/s2 1/s3 1/s4

z-transform Tz T'z, T' z' +z T4 Z3 +4z' +z


method (z _1)'
- --
2 (z _1)3
z-1 6 (z -1)'
First-difference Tz T'z' T 3z 3 T'z'
method z-1 (z _1)' (z _1)3 (z -1)'
Halijak's Tz T'z T3 Z' + Z T4 Z3 +2z' +z
---
method z-1 (z _1)' 2 (z-1)' 4 (z _1)4
Tustin's T z+1 T' (z+ 1)' T3 (z+ 1)3 T' (z+ 1)4
method
--- --- --- ---
2 z-1 4 (z -1)' 8 (Z-1)3 16 (z-1)'
Boxer-Thaler T z+ 1 T' z' + lOz+ 1 T3 Z' +z T' Z3 +4z' +z T4
--- ---
method 2 z-1 12 (z -1)' 2 (Z-1)3 6 (z _1)4 720
Madwed's T z+1 T'z'+4z+1 T3 Z3 + lIz' + lIz + 1 3
T' z' + 26z + 66z' + 26z + 1
method
--- (z _1)3
2 z-1 6 (z -1)' 24 120 (z -1)'

U(s) 2 Y(s)
a 2 s +ats+ao

b2 s 2 +b 1s+bo

Fig. 5.8 Block diagram of a continuous linear second-order system.


Simulation using operational methods 77
ina tor of the given continuous transfer Y(z) = [A 2U(z) + A 1z-1U(Z) + Aoz-2U(z)
function description, that is
-B1z-1y(Z) - BOZ-2Y()]~ (5.56)
B2

or, in difference equation terms,


A A
y(kT) = _2 u(kT) + _1 u[(k -1)T]
2. Select an appropriate set of discrete inte- B2 B2
gration operators and substitute for
(1/ S)i i =I, 2, 3, ... , n to obtain the equi- + Ao u[(k - 2)T] - ~ y[(k -l)T]
B2 B2
valent discrete transfer function. For
example, using the 'first difference' oper- -~y[(k - 2)T] (5.57)
ator (see Table 5.2 for details) the dis- B2
crete form is
5.7.2 SIMULATION OF CASCADED
TRANSFER FUNCTIONS

The procedure for digital simulation of a set


of cascaded transfer functions is a simple
extension of the approach for a single transfer
function. Consider, for example, the cascaded
system in Fig. 5.l0a. The corresponding simu-
lation model is derived by attaching a
A2 + A1z-1+ AOZ-2 sampler to/the input and output of each block
= (5.54)
B2 + B1z-1 + Boz-2 and discretizing each continuous transfer
function by the procedure outlined in the pre-
where A2=a2+a1T+aoT2, A 1=-(a IT+2a),
vious section. This gives the block diagram of
Ao = a21 B2 = b2+ bIT + boT2, BI = -(b1T + 2b2), bo= b2•
Fig. 5.10b and the following equations:
But
Y1 (z) = G1A (z)U(z) (5.58)
G (z) = Y(z) (5.55)
A U(z)
(5.59)
and therefore an appropriate block diagram Y3 (z) = G3A (z)Y2 (z) (5.60)
representation for this digital simulation
model is as shown in Fig. 5.9. The sampler at Difference equations may then be obtained
the output is included to emphasize the dis- representing the output of each of these
crete nature of the response. From equations elements. The simulated response of each
(5.54) and (5.55) it follows that element is thus obtained from a difference

U(s) U(z) , . - - - - - - - - - - - - - ,
Y(z)
T
---!/'.- A2 + Alz -1 + AoZ -2

B2 + B1Z -1 + B_7- 2
IT""

Fig. 5.9 Block diagram of the digital simulation model equivalent to that of Fig. 5.8.
78 Sampled-data models and operator methods
U(s) Y(s)
G1(s) Gis) G3(s)
·1 ·1 ·1
a

U(s) U(z) Y1(z) Viz)

p.-
Y(z)

-/-1 GlA(z)
P-1 G2/a(z)
P-1 G3,.{z)

Fig. 5.10 Block diagrams for a linear system involving three cascaded transfer functions. (a) The continu-
ous case. (b) The diagram for the equivalent digital simulation model.

equation in which the input variable is the That is


output variable of the preceding element.
Consider now an example illustrating the
(5.64)
procedure to be followed in the simulation of
a simple cascaded system. The block diagram
of the system in question is shown in Fig. 5.11. and in difference equation form we have
For the first block the transfer function is
(kT) = Yl [(k - l)T] + IOTU(kT)
(5.65)
10 YI l+T
G1(s)=- (5.61)
s+l
For the second block
Dividing the numerator and denominator by
the highest power of s in the denominator
gives (5.66)

IOnJ (5.62)
so that, by the first difference substitution

GI(S)=-(lJ
1+ - G2A () z -_~ -
Y(z)
(5.67)
s z -1 1'; (z)

and selecting the first difference method gives


an equivalent discrete transfer function
G1(s) G2(s)

GAl(Z) =
1+(~
1O(~
Z- 1) =
1
10Tz
z(1+T)-l
U(S)·I S 1~ 1 HL..-_;-J~(S)
z-l)
Fig. 5.11 Block diagram of the continuous linear
(5.63) cascaded system used as an example.
Simulation using operational methods 79
That is can be seen that there is reasonably close
agreement between the simulation results
Y(z) T and the corresponding analytical values. For
--=-- (5.68)
~(z) 1-z-1 a smaller value of T, such as 0.001 s, the
agreement would be very close indeed.
and this gives a difference equation It should be noted that the procedure used
here, involving a direct substitution for the
y(kT) = y[ (k -1)T] + TYI (kT) (5.69) integration operator, differs significantly from
the direct z-transformation method described
Results of a simulation based on the differ- in section 5.3 since insertion of a data-
ence equations (5.65) and (5.69) are shown in reconstruction element is no longer needed.
Table 5.3 for a unit step input with a value of One advantage of the operator method is
T of 0.2 s, together with the response calcu- therefore the fact that it avoids any need to
lated analytically using Laplace transforms. It find the z-transform of the combined data-hold

Table 5.3 Results for the simulation of the cascaded system of Fig. 5.11
for a unit step function input. The table shows the numerical results for
the variables y(kT) and y,(kT), for T = 0.2 s, together with the response
of the continuous model, y(t), found by means of Laplace transform
methods

k kT y,(kT) y(kT) y(t)

0 0.00 0.0000 0.0000 0.0000


1 0.20 1.6667 0.3333 0.1873
2 0.40 3.0556 0.9444 0.7032
3 0.60 4.2130 1.7870 1.4881
4 0.80 5.1775 2.8225 2.4933
5 1.00 5.9812 4.0188 3.6788
6 1.20 6.6510 5.3490 5.0119
7 1.40 7.2092 6.7908 6.4660
8 1.60 7.6743 8.3257 8.0190
9 1.80 8.0619 9.9381 9.6530
10 2.00 8.3849 11.6151 11.3534
11 2.20 8.6541 13.3459 13.1080
12 2.40 8.8784 15.1216 14.9072
13 2.60 9.0654 16.9346 16.7427
14 2.80 9.2211 18.7789 18.6081
15 3.00 9.3509 20.6491 20.4979
16 3.20 9.4591 22.5409 22.4076
17 3.40 9.5493 24.4507 24.3337
18 3.60 9.6244 26.3756 26.2732
19 3.80 9.6870 28.3130 28.2237
20 4.00 9.7392 30.2608 30.1832
21 4.20 9.7826 32.2174 32.1500
22 4.40 9.8189 34.1811 34.1228
23 4.60 9.8491 36.1510 36.1005
24 4.80 9.8742 38.1258 38.0823
25 5.00 9.8952 40.1048 40.0674
80 Sampled-data models and operator methods
and system transfer function, which can be a 5.7.3 SIMULA nON OF LINEAR
tedious process. Also, if intermediate variables CLOSED-LOOP SYSTEMS
in a cascaded set of transfer functions are
The approach, outlined in sections 5.7.1 and
needed, the z-transformation method either
5.7.2, for the application of operator methods
gives a separate difference equation relating
to linear systems described by transfer func-
each variable to the system input or requires a
tions can be extended to closed-loop systems
number of samplers and data reconstructors.
such as that shown in Fig. 5.12. The substitu-
The introduction of samplers and data recon-
tion method can be used to find a discrete
structors in cascade in this way may alter the
transfer function for each transfer function of
system characteristics quite significantly and
the closed-loop system. The equivalent digital
may reduce the numerical stability of the
simulation model may then be constructed by
overall simulation model.
placing samplers between the continuous
Some interesting new developments have
system block diagram elements and replacing
been reported recently in the control systems
the continuous transfer functions by the
and digital filtering fields which suggest that
equivalent discrete models. It should be noted
the operational approach could be further
that the feedback signal needed to form the
extended and generalized. Mukhopadhyay,
error signal is inevitably one sample period
Patra and Rao [4] have proposed a new class
behind the input.
of discrete-time model, known as a 'gamma'
The difference equations corresponding to
operator model. This originates from the z-
Fig. 5.12 are as follows
transfer function but is close to continuous
time models in structure and parameters. The e(kT) = r(kT) - y[(k -l)T] (5.70)
earlier 'delta' operator model [5] is a member
of the gamma operator model class. Com-
monly used operators, such as the Tustin (kT) = 10Te(kT) + Yl [(k -l)T] (5.71)
operator, may be shown to be special cases of Yl l+T
the more general gamma operator. Advan-
tages claimed for the gamma operator y(kT) = TYl (kT) + y[ (k -l)T] (5.72)
approach over z-transfer function methods
are reduced sensitivity of the resulting Figure 5.13 presents the results for y(kT)
models to numerical round-off in coefficient together for the case of a unit step change of
values and the close link between the struc- reference input r(t) using an increment T of
ture of the discrete model and the equivalent 0.01 s. The numerical error in the simulated
continuous model. response y(kT), calculated from the true

R(s) yes)
+ 10 1
• s+1 s

Fig. 5.12 Block diagram of the closed-loop system used as an example.


Simulation using operational methods 81

1.6
~
~
..... 1.4

1.2

1.0

0.8 -

0.6

0.4

0.2

0.0
0 2 4 6 8 10 12 14 16 18 20
time
Fig. 5.13 Simulated response y(kT) in response to unit step change of reference for the feedback system
of Fig. 5.12. A time increment, T, of 0.01 s was used in this case.

values determined using Laplace transforms, Figure 5.15 shows the error in the calculated
is shown in Fig. 5.14. response variable for the same case as that in
A modification suggested by Tagawa [6] Fig. 5.14. It can be seen from Figs 5.14 and
attempts to overcome the effect of the delay 5.15 that Tagawa's modification leads to a
in feedback by introducing a predictive term simulation result which is closer to the theor-
in the difference equation representing the etical response for the initial part of the time
summing element in the block diagram. For history but that errors are larger elsewhere.
the case of an input signal u(t) and a feedback The overall benefits could possibly be greater
signal y(t), with negative feedback, this gives for other values of T or in other types of
a discrete model for the summer which has application.
the form
5.7.4 SIMULATION OF TIME-VARYING AND
e(kT) = u(kT) - {2y[ (k - I)T] - y[ (k - 2)T])
NONLINEAR MODELS BY OPERATOR
(5.73) METHODS
Although the concept of a transfer function,
As an example of this procedure, consider upon which the operator approach depends,
the closed-loop system of Fig. 5.12. Applying cannot be applied strictly to time-varying and
the procedure outlined above leads to the fol- nonlinear system descriptions, it is possible to
lowing three difference equations: approximate the system dynamics in these
cases by what is known as a 'frozen-system'
e(kT) = r(kT) - {2y[(k -1)T] - y[(k - 2)T]} transfer function. This approach is described
in detail by Rosko [1].
(5.74) An alternative approach to dealing with
time-varying and nonlinear systems by
YI (k T ) _ 10Te(kT)+ YI[(k -1)T]
_____ ;::........0_ _---"-
(5.75) means of operator substitutions is to derive a
l+T detailed block diagram of the given model in
which integrators appear individually. Each
y(kT) = TYI (kT) + y[ (k - 1)T] (5.76) integrator may then be replaced by the
0.010

...0 0.009

t:
V 0.008 .

0.007

0.006

0.005

0.004

0.003

0.002

0.001

0.000

·0.001

{).002

0 4 10 12 14 16 18 20

time

Fig. 5.14 Plot of the error in the simulated response shown in Fig. 5.13. This was calculated from the dif-
ference between y(kT) and the exact response y(t), determined analytically using Laplace transforms, at
each time instant t =0, kT, 2kT, ... , etc.

0.035

g oms
V
0.030

0.020

oms
0.010

0.005

0.000

-().005

-().01O

·M15

-().020

-().025

-(),O3O

0 4 6 10 12 14 16 18 20
time
Fig. 5.15 Plot of error in the simulated response for the feedback system of Fig. 5.12 determined using
Tagawa's modification for a value of T of 0.01 s.
Assessment of performance by frequency response methods 83
chosen operator and the difference equations integration, has an amplitude (1/ wYand
derived for all the linear and nonlinear ele- phase (-7T/2)p.
ments in combination. One advantage of this The accuracy of an integration method may
approach is that Tagawa's modification can be assessed by investigating the deviation of
be incorporated wherever there is a feedback the frequency response of a single integrator,
pathway in the model and this may enhance or a multiple integrator, from the theoretical
the overall accuracy [6]. The speed advan- response. This comparison is carried out most
tages of operator methods, in comparison conveniently by determining the ratio of the
with more complex integration methods, are transfer function I'(jw) of the numerical inte-
retained. Care must be taken, however, in grator to the corresponding transfer function
using an approximate approach of this kind, I(jw) of the ideal integrator. That is, by con-
and verification of the simulation is essential. sidering the quantity
This can be carried out by comparing results
obtained using this approach with selected
A (J'w ) = 1'(jw ) (5.77)
results from use of an established, but slower, I(iw)
simulation package.
The larger the range of frequencies over
which A(jw) has a magnitude close to unity
5.8 ASSESSMENT OF SIMULAnON and a phase of zero the more accurate is the
PERFORMANCE BY FREQUENCY integrator.
RESPONSE METHODS Consider the case of the Tustin integration
operator given by the transfer function
The performance of linear continuous system
simulations can be assessed very conve-
1'(z) = T z + 1 (5.78)
niently using frequency response methods.
2 z-l
The accuracy of the simulation may be deter-
mined by investigating the extent to which
Since z = exp(sT) and s = jw for frequency
the frequency response of the simulation
response evaluation this gives
model deviates from the frequency response
of the linear model from which it was T jwT 1
derived. This approach is most widely used I'('w)= e + (5.79)
J 2 e}wT -1
with transfer function descriptions and is par-
ticularly popular in control system applica- = T cos wT + j sin wT + 1
tions, reflecting the widespread use of (5.80)
2 cos wT + j sin wT - 1
frequency-domain methods in control engi-
neering [7-9].
After simplification the resulting expressions
for magnitude and phase are
5.8.1 FREQUENCY RESPONSE OF DISCRETE
n
INTEGRATORS l1'(jw )1 = T cot wT Phase=-- (5.81)
2 2 2
The transfer function of an integrator (1/ s)
has a frequency response l/jw. The ideal inte- Similar processes can be carried out for
gration operator (1/ s) thus has a frequency other types of integration operator. Figure
response characteristic that has an amplitude 5.16 shows relationships between IA(jw) I
which is inversely proportional to frequency and wT for a number of different integration
and a phase lag of n/2. In general, an integra- operators and Fig. 5.17 shows the correspond-
tion operator (1/ sY, where p is the order of ing phase plots.
84 Sampled-data models and operator methods
1.4
/
/
/ 600
I/A
II -.l. /
/ Ve /
~
VB
3' // L 40
0
;::>
< ...--V >-- 1-1- /
- 1.0
-- r-
....... 1' C V
/
V

""
0
20 v
\ /
V
1\ L

~ l.--"
A,C
00
0.2 0.5 1.0 3.0
0.6 ColT
0.2 0.5 1.0 3·0

Fig. 5.17 Plots of phase of A(jw) versus wT for a


Fig. 5.16 Plots of magnitude of A(jw) versus wT for number of different integration methods. A, Band
a number of different integration methods. Curve C define the methods, as in Fig. 5.16.
A shows results for Adams-Bashforth integration,
B for Euler integration and C for the trapezoidal
method.

REFERENCES 6. Tagawa, R. (1965) Automatic design of auto-


matic control systems with the help of a
1. Rosko, J.s. (1972) Digital Simulation of Physical digital computer, in Proceedings Of the. IFAC
Systems, Addison-Wesley, Reading, MA. Tokyo Symposium on Systems Engzneerzng for
2. Smith, J.M. (1977) Mathematical Modelling and Control Systems Design, IFAC, pp. 31-39.
Digital Simulation for Engineers and Scientists, 7. Bekey, G.A. and Karplus, W.G. (1968) Hybrid
John Wiley, New York. Computation, John Wiley, New York, pp. 90-112.
3. Hartley, T.T. (1988) Operational transforms via 8. Gilbert, E.G. (1966) Dynamic error analysis of
time domain optimization, Transactions of the digital and combined digital-analog systems,
Society for Computer Simulation, 5 (3), 221-27. Simulation,6 (4), 241-57.
4. Mukhopadhyay, S., Patra, A. and Rao, G.P. 9. Howe, R. M. (1988) Simulation of linear
(1992) New class of discrete-time models for systems using modified Euler int~grao
continuous-time systems. International Journal methods, Transactions of the SOCIety for
of Control, 55 (5), 1161-87. Computer Simulation, 5 (2), 153-58.
5. Gupta S.c. (1966) Transform and State Variable
Analysis in Linear Systems, John Wiley, New
York.
THE PRINCIPLES OF EQUATION-
ORIENTED SIMULATION SOFTWARE
6

6.1 INTRODUCTION analog simulation. Early programs, such


as IBM 1130 CSMP, were block diagram ori-
The programming of mathematical expres-
sions and the implementation of numerical ented. The simulation programs developed
by the user were based on combinations of
methods, such as those reviewed in Chapters
units such as 'summing blocks', 'integrator
4 and 5, can be facilitated by the use of
blocks' and 'multiplier blocks', which could
general-purpose scientific programming lan-
be interconnected to mimic the complete
guages, such as Fortran. Libraries of special-
block diagram of the system being studied.
ized subprograms can be called by the
Although such block-oriented methods repre-
programmer when required. Such program-
sented a natural progression from analog
ming aids can save considerable amounts of
computer techniques, they were quickly over-
program development time and, when cor-
taken by the development of equation-
rectly used, can avoid the introduction of
oriented programs such as CSMP /360, in
many programming errors. In some cases
v:hich the system was represented by sets of
routines for the solution of ordinary differen-
fIrst-order ordinary differential equations and
tial equations have been brought together as a
by al~ebric equations. Modern develop-
'package' which allows the programmer to
ments In the user-computer interface, such as
use a general-purpose high-level language to
the use of a mouse as an input device and the
create a special-purpose simulation program.
availability of high-resolution color displays,
This is similar in principle to the use of a
have resulted in a move once again toward
more general library of numerical routines,
block diagram methods. It is now clear that a
but the package may incorporate specialized
features of special relevance to simulation k~owledg of the principles of both equation-
onented and block-oriented simulation tools
[Link]. A further type of programming
aId has also been developed which can allow is essential for all those engaged in system
the programmer to formulate the problem in modeling activities. This chapter provides an
a more direct form than is possible using a int~oduc to equation-oriented techniques,
whIle Chapter 7 introduces the use of modern
general-purpose high-level language. This
block diagram-oriented techniques.
takes the form of a problem-oriented lan-
guage, or support language, which contains
specialized features of value only for the spe-
6.2 SIMULATION PROGRAMMING USING
cialized computational tasks involved in a
GENERAL-PURPOSE HIGH-LEVEL
particular type of application. Continuous
LANGUAGES
system simulation languages form one impor-
tant class of problem-oriented language. The core of any continuous system simulation
. The ~irst software developed for digital program is the integration routine since, as
sImulatIon of continuous systems, as outlined ~escribd in Chapters 3, 4 and 5, integration
in Chapter 2, was based on the concepts of IS a fundamental operation in the modeling of
86 The principles of equation-oriented simulation software
continuous dynamic systems. The integration can be optimized for speed, if necessary, and
routine integrates the state variables of the this makes the approach particularly appro-
model over the range of the independent priate for real-time applications. On the other
variable, which is often time. The integration hand, this approach is inevitably time-
routine is accompanied by other routines consuming and requires significant program-
needed to calculate derivatives and other ming and numerical methods expertise if it is
quantities upon which they depend at each to be used effectively for simulation applica-
increment of the independent variable. tions involving complex models.
A simulation program, however it is
written, often involves some calculations
6.3 SIMULAnON PROGRAMMING USING
which need only be carried out once at the
MATRIX PACKAGES
start or finish of a run. In contrast, many
quantities associated with the integration In recent years there has been a rapid growth
operations may have to be computed many of interest in the use of matrix packages for the
thousands or millions of times because of the analysis and design of engineering systems,
iterative nature of the calculations. Simulation especially in a control systems engineering
programs can therefore be divided conveni- context. Several commercial packages are
ently into three parts. These are an initial available such as MATLAB [1] and MATRIXx
section dealing with operations which have to [2]. These packages provide user-friendly inter-
be performed before integration operations faces to a wide variety of routines for matrix
can be started, a simulation section which operations and incorporate useful graphics
contains a description of the model and a ter- facilities. These packages generally include
minal or post-processing section for handling some facilities for simulation and additional
the output of results. features can be added readily by the user [3].
In approaching the writing of a simulation Matrix-based packages provide an inter-
program using a general-purpose high-level esting alternative to the use of more standard
programming language, such as Fortran, high-level programming languages or of sim-
Pascal or C, it is appropriate to adopt the ulation languages, particularly for applica-
principles of structured programming and to tions in which there is a need to combine
create a program description on paper as a simulation with analysis of a linearized
first step. This should incorporate the three model. This frequently arises in control engin-
distinct parts described above as separate eering applications where linear techniques
elements, and for each of these elements a provide a basis for design calculations but
complete description should be derived, where there is a need to evaluate the perfor-
including details of any existing subprograms mance of a proposed controller design by
to be used. As was pointed out in Chapter 2, testing it over a wide range of operating con-
much benefit can often be gained from the ditions using a nonlinear model.
use of standard numerical subprograms In some cases a matrix analysis package has
where these exist. been coupled to modeling and simulation soft-
On one hand, one advantage of writing a ware to provide an integrated environment.
complete simulation program in a standard One example of this is SIMULINK, which is
high-level language is that the resulting simu- associated with MATLAB. SIMULINK is dis-
lation is highly portable and can be installed cussed in Chapter 7 as an example of a block
on any computer equipped with an appropri- diagram-oriented simulation tool.
ate compiler. Also, there is complete freedom Matrix packages work with one kind of
of choice in terms of the numerical methods object only. This is a rectangular numerical
to be used, and every aspect of the simulation matrix. For simulation purposes the system
is known to the program designer. The code equations are represented in state-space form
Programming using simulation languages 87
as a set of first-order ordinary differential 2, simulation languages allow the user to
equations. If these are linear in form they may approach the writing of a simulation program
be simulated using linear analysis methods. In in a natural application-oriented way. Gen-
MATLAB, for example, this is accomplished erally, this provides a more user-friendly and
using a function 'lsim'. If the equations are interactive environment than is normally
nonlinear the lsim function cannot be used achieved using a general-purpose language
and MATLAB provides two other functions and associated subprogram libraries. Many
'ode23' and 'ode45' which are appropriate for different equation-oriented simulation lan-
this type of simulation task. These are guages exist and new ones are appearing
Runge-Kutta routines. The results obtained regularly.
from the application of these MATLAB rou- Selection of an appropriate language for a
tines are in the form of a matrix in which each given application is not trivial as different
column represents the solution at one time languages tend to provide different features.
point. Standard plotting facilities can then be It is useful to have more than one simulation
used to present the results graphically. tool available and to give careful thought at
an early stage in the development of a simula-
tion model about the approach which is likely
6.4 SIMULATION PACKAGES
to be most appropriate. There is no real stan-
As explained in section 6.1, a simulation dard for continuous system simulation lan-
package consists of a set of special-purpose guages, other than the broad set of recom-
subprograms which are suitable for simula- mendations published in 1967 by Simulation
tion applications. The user has to provide a Councils Inc. Attempts since that time to
main program in the relevant high-level pro- establish a new standard specification have
gramming language. This main program has not been fruitful.
to be structured to suit the application in
hand and to use the subprogram calls of the
6.5.2 THE SIMULATION COUNCILS' 1967
package. One well-known example of a
RECOMMENDATIONS (CSSL '67)
general-purpose simulation package is
ODEPACK (Ordinary Differential Equation Many, but by no means all, simulation lan-
PACKage) [4], which is a set of Fortran pro- guages in common use today conform
grams for the solution of ordinary differential to the CSSL specification of 1967. This histori-
equations. ODEPACK allows for systems in cally important specification resulted from
linearly implicit form as well as in explicit the formation, in the early 1960s, of
form. It also provides routines specifically a simulation software committee within
designed for stiff problems. DASSL (a Simulation Councils Inc. (now the Society for
Differential! Algebraic System Solver) [5] is a Computer Simulation). One of the remits of
package which is suitable for the numerical this committee was to provide guidelines for
solution of implicit systems of differential! future language development in the con-
algebraic equations. tinuous system simulation field and thus to
try to reduce the chaos that was beginning to
be experienced through the profusion of dif-
6.5 SIMULATION PROGRAMMING USING
ferent types of simulation software available
SIMULATION LANGUAGES
at that time. The work of that committee led
to the publication of the paper entitled 'The
6.5.1 INTRODUCTION
SCi Continuous System Simulation Language
Simulation languages provide a very power- (CSSL)' [6]. This was the first formal attempt
ful and flexible approach to many types of to define a set of desirable features for a con-
simulation problem. As explained in Chapter tinuous system simulation language.
88 The principles of equation-oriented simulation software
The committee based its recommendations 5. The execution stage of a simulation pro-
on desirable features for a simulation lan- gram should be controlled by a runtime
guage by making reference to an existing lan- command language or by a program.
guage, called MIMIC, which was relatively
Functional elements specified in the recom-
widely used at the time [7]. The resulting
mendations included the following:
CSSL language description was intended to
provide a clear, obvious and unambiguous 1. Operators should be provided for inte-
means of describing continuous dynamic gration and derivative functions.
systems. CSSL contained all of the specialized 2. There should be a delay operator.
operators needed for the solution of differen- 3. Function generators should be provided.
tial and algebraic equations, such as built-in 4. There should be operators for standard
procedures for integration. While providing a signals and for common nonlinearities.
simple programming tool for unskilled users, 5. Solvers should be provided for implicit
the language must give skilled users appro- algebraic loops.
priate facilities for handling large problems. It
was stressed that the language should be In many cases the simulation software
functionally open-ended and that users takes the form of a translator which converts
should be free to add new operators. The the source code of the user's program into a
emphasis on an open standard of this kind general-purpose high-level language such as
has certainly prolonged the life of the Fortran. Another possible approach involves
CSSL'67 recommendations but has, of course, implementation using interpreter techniques.
resulted in the development of many differ- Many different simulation languages have
ent versions all with slightly different features been developed which are based on the
even if they all have similar structural and CSSL standard. CSSL-Ill [8], which was orig-
functional elements. The structural elements inally developed by Programming Sciences
specified as being important in the 1967 Inc., is generally believed to be the first
recommendations were as follows: attempt to develop a language based entirely
upon the CSSL report specification. CSSL-III
1. Programs should be divided into three was subsequently extended and further
parts with INITIAL, DYNAMIC and developed to form CSSL-IV [9]. ACSL [10] is
TERMINAL segments. another widely used language that has a
2. Within the DYNAMIC segment, in which basic structure which follows the CSSL rec-
the differential equations are solved, it ommendations. Other simulation languages
should be possible to incorporate DERIV- which became available about that time,
ATIvE sections that can contain different such as CSMP /360 [11] and CSMP-III [12],
integration algorithms. met or exceeded the CSSL recommendations.
3. There should be provision for automatic
sorting of program statements to avoid
the need for the user to ensure that every 6.5.3 THE GENERAL STRUCTURE OF
variable is defined before it is used on the SIMULA nON PROGRAMS USING
right-hand side of a program statement in CSSL'67-TYPE LANGUAGES
the DYNAMIC segment.
4. As in other high-level languages, macro In comparison with general-purpose high-
facilities should be available to avoid level languages, such as Pascal, C or Fortran,
repeated use of the same code in different relatively few statements in an equation-
parts of a simulation program. oriented simulation language are required to
Programming using simulation languages 89
describe a complex system. To provide a con- of particular variables or may set up condi-
venient separation of these different types of tions for a rerun of the simulation with a
operation, the general form of a CSSL simula- changed parameter set or altered initial
tion program involves three distinct seg- conditions.
ments. These are known as the initial, Figure 6.1 illustrates two ways in which a
dynamic and terminal sections. simulation program may be divided into seg-
The initial segment of a program includes ments. The end of a segment is defined either
only the calculations which must be carried by the start of the next segment or by an
out once at the starting value of the indepen- appropriate END statement. In Fig. 6.1a the
dent variable. This could, for example, be the start of a segment is defined explicitly by one
calculation of an initial condition or some of the control statements INITIAL, DYNAMIC
constant quantity involving a combination of and TERMINAL. The end of a segment is
constants supplied by the user through defined by the start of the next segment,
appropriate input commands. A simple except in the case of the terminal segment
example of this could be the calculation of a where the end is denoted by the END state-
time constant by multiplying given values for ment for the complete program. In Fig. 6.1b
a resistor and a capacitor. One reason for there are no explicit initial and terminal state-
deciding to use a single parameter instead of ments and the only separation is provided by
the two separate quantities is that it is obvi- the control statement DYNAMIC, signifying the
ously more efficient to use a single time con- start of the dynamic section, and the control
stant parameter within the statements in the statement DYNAMIC END, signifying the end
dynamic segment rather than to include an of that section. The initial and terminal sec-
additional multiplication operation in that tions are thus defined implicitly. Both ver-
part of the program. sions are found in practical simulation
The dynamic segment of the simulation is languages.
usually the most important and is also In many simulation languages it is not nec-
usually the longest section. It includes all of essary to incorporate the individual language
the structure statements which correspond to statements within the simulation program in
the differential equations and block diagram the exact order in which they should be com-
of the system being studied. The outputs of puted. The translation phase may incorporate
these statements are evaluated at every incre- a feature which sorts statements so that
ment of the independent variable. In some inputs needed for a given statement are either
cases the dynamic segment may be sub- known or have been computed previously
divided to form a derivative section, the start within the iterative cycle.
of which is denoted by a DERIVATIVE state- One important consequence of sorting is
ment and the end by a DERIVATIVE END that care must be taken to ensure that a given
statement. In such cases all of the integration variable is not defined more than once within
statements must be included within the deriv- the dynamic segment. If this is not done the
ative section. In some simulation languages sorting process fails because the sorter cannot
more than one derivative section may be establish which definition to use. In sections
defined, and each may have its own integra- of a program in which statements are sorted
tion algorithm and integration step size. the equals sign must be taken to imply equal-
Th~ terminal segment of the simulation ity, rather than assignment, and statements in
program includes the calculations needed which the same variable name occurs on both
only at the end of a simulation run. It may the left- and right-hand sides of a statement
include calculations based on the final value are inadmissible.
90 The principles of equation-oriented simulation software
C If the simulation language does not have a
C Start of INITIAL segment
C
sorting facility a small phase lag may be
INITIAL introduced unless the user is careful to place
statements in the correct order when the
simulation program is written. Simulation
languages which include a sort facility also
C
C End of INITIAL segment and start of DYNAMIC segment provide a means of overriding the sort
C process. In general, the start of a sorted
DYNAMIC
section of a program is denoted by the
control statement SORT. The start of an
unsorted section is denoted by the control
C statement NOSORT. It should be noted that
C End of DYNAMIC segment and start of TERMINAL segment sorting is not possible if an algebraic or
C
TERMINAL implicit loop of the type discussed in section
4.10 is included in the simulation program.
While the addition of a small delay or
dynamic lag is one very effective way to
END
eliminate such a loop, some simulation lan-
Fig. 6.1a Explicit structure for continuous system guages, such as CSMP-III, provide a special
simulation program with INITIAL, DYNAMIC and facility for overcoming algebraic loop prob-
TERMINAL control statements. lems through an implicit function (e.g. IMPL
in the case of CSMP-III).
Simulation programs written in some sim-
C
C Start of INITIAL segment ulati,on languages may involve both a model
C definition and a separate set of runtime com-
mands. ACSL is a well-known example of a
simulation language which incorporates
C
extensive runtime command facilities. In this
C End of INITIAL segment and start of DYNAMIC segment case, the simulation model is established
C using ACSL language statements in the
DYNAMIC
model definition section and simulation
operations are controlled from the com-
mands interpreted in the runtime command
DYNAMIC END section. The benefit of this approach is that
C
C End of DYNAMIC segment and start of TERMINAL segment
once the model has been defined it may be
C saved in a file and subsequently analyzed
using any set of runtime commands, which
may either be specified interactively or from
a batch file.
END
Although it has been implied here that any
Fig. 6.1h Structure for continuous system simula- program written in a CSSL type of simula-
tion program with implicit definition of INITIAL tion language has a well-defined structure
and TERMINAL segments, but explicit definition of involving initial, dynamic and terminal seg-
the DYNAMIC segment. ments, it is possible, in some cases, to use an
Fig. 6.1 Segments within a continuous system implicit structure which avoids this formal
simulation program. segmentation. An implicit program is
SLIM - a simple continuous system simulation language 91
considered to be a single derivative section. 6.6 SLIM - A SIMPLE CONTINUOUS
While this is not a desirable structure for a SYSTEM SIMULATION LANGUAGE
simulation program of any complexity, the
implicit structure is described in the docu- 6.6.1 THE MAIN FEATURES OF THE
mentation for a number of simulation
LANGUAGE
languages currently available. Although
sometimes recommended to novice pro- The name SLIM stands for Simulation
grammers as providing a simple introduc- Language for Introductory Modeling. It
tion to simulation language programming, involves a subset of the CSSL standard estab-
such an approach is generally to be avoided. lished by the SCi Technical Committee in
It produces programs which are difficult to 1967. SLIM has been developed specifically as
read and understand and can produce ineffi- a language through which those new to con-
cient code. tinuous system simulation can be introduced
The CSSL standard specification was to the principles of the subject. Although the
established some considerable time ago. It version of SLIM provided with this book and
is natural therefore that the evolution of sim- described in this section does not incorporate
ulation languages should have produced all the features to be found in commercially
some significant variations on the CSSL supported simulation tools, it is sufficiently
specifications in response to pressure from versatile to be capable of handling a wide
software developers and users. Although range of practical problems. It has the advan-
many papers have been produced which tage of being relatively simple to learn, and of
stress the importance of updating the 1967 being reasonably fast for small problems (in
specification, no real progress appears to that programs do not require compilation).
have been made toward having any new Detailed information on the preparation and
specifications accepted. The development of running of SLIM programs is to be found in
simulation software has not, of course, the text files that are provided on the SLIM
ceased for a lack of an updated set of specifi- diskette. This information is specific to the
cations. Rapid and significant changes in version of SLIM included on the diskette.
computer hardware, software and operating Other versions of SLIM have been developed
systems have had major effects on what can which incorporate additional facilities such as
be achieved in terms of continuous system pure time delays, function tables and addi-
simulation, and many features have been tional specialized facilities of value in specific
included in simulation languages and soft- application areas such as neurophysiology.
ware systems which go far beyond those The SLIM software consists of a language
described in the original specifications. processor which has been written in Fortran
However, the lack of a revised specification 77, which is capable of translating and inter-
means that a variety of approaches have preting programs written using the special
appeared in important areas such as the han- SLIM instruction set. This instruction set
dling of submodels, incorporating features involves a small subset of Fortran together
to facilitate interactive simulation and the with a number of the special CSSL instruc-
problems of real-time simulation. However, tions needed for simulation applications.
it is clear that the existing CSSL specification SLIM, as with many other examples of appli-
has had a vitally important influence on the cation-specific software systems, is based
development of simulation software and will upon the use of a syntax-driven parser with a
continue to be of importance for some separate executor routine. The language
considerable time. processor first parses the user's program and
92 The principles of equation-oriented simulation software
detects any statements which are invalid. case characters must be used throughout,
Once the validity of the complete program except for comments, which may involve
has been established, the software produces upper- or lower-case characters as desired.
intermediate code which is not seen by the Blank lines should not be included in a SLIM
user but which can be interpreted by the program, and tab facilities should not be used
executor routine. This approach is a well- to insert spaces.
established one in the field of continuous An additional link with Fortran is the fact
system simulation, having been adopted for that the two types of variable defined within
some earlier packages, including MIMESIS, SLIM, integer variables and real variables, are
which was developed at the University of distinguished according to the letter of the
Dundee by Ricketts [13] and Ricketts and alphabet with which the variable name starts.
Dickie [14]. However, SLIM has been written All integer variable names must begin with
with the needs of the modern user in mind the letters I, J, K, L, M and N, whereas real
and is intended principally for interactive use variable names must start with any other
on a personal computer. The standard version letter of the alphabet. Real variables and con-
has been developed within the DOS environ- stants may have magnitudes in the range
ment, although SLIM may also be imple- 1.18E-38 to 3.40E+38, while integer variables
mented without difficulty on computer and constants must have magnitudes in the
systems based on other operating systems, range 0 to 32 768.
provided they are equipped with a Fortran 77 Variable names may involve any combin-
compiler. ation of letters and numerals (after the first
character, which must of course be a letter)
but can only have six characters in total.
6.6.2 THE SYNTAX OF THE SLIM
Examples of valid real variables are
LANGUAGE

SLIM follows the principles of the 1967 CSSL VALUE


standard and the syntax has much in common VALUE1
with ACSL and other widely used languages.
The structure of a SLIM program follows the GAIN
general form of Fig. 6.1 b. There are no explicit ACC2A
INITIAL and TERMINAL statements, and the
structure of the program is defined through Examples of valid integer variables are
DYNAMIC, DERIVATIVE, DERIVATIVE END
and DYNAMIC END statements. INVAL5
It should be noted that SLIM follows some
of the conventions of Fortran and, in accor- MPOINT
dance with the standard for that language, all NFLAG
program statements in SLIM must begin at, or
to the right of, the seventh column of a KP
program line. The first five columns are used
only for comments or labels. Comments are Real constants are exemplified by
indicated by the character C in the first
1.0
column of the line and are ignored com-
pletely in the translation process. Labels must 3.142
be numeric symbols and may be entered in
4.8E-7
any or all of the first five columns. The sixth
column must always contain a space. Upper- 6E4
SLIM - a simple continuous system simulation language 93
and integer constants by Note that mixed expressions involving com-
binations of integers with real variables or
1 constants are not permitted and if detected
-567 will be rejected as a syntax error.
Real functions available within SLIM which
22l4l may be included within real assignment state-
ments are as follows:
Statements in SLIM may be divided con-
veniently into general-purpose statements ABS,ALOG,ATAN,COS,EXP,SIN,SQRT
which provide the normal facilities for and RND.
numerical programming and which have
counterparts in most high-level programming These functions are quite standard except for
languages, and those statements which are of RND and follow normal conventions in
special significance for simulation. Fortran and other high-level languages.
It should be noted that in the SLIM Details of the function RND may be found in
language expressions are evaluated accord- the User's Guide which is included as a text
ing to the normal operator precedence rules. file on the diskette.
The order of evaluation is therefore as
follows:
Input statement
* * raising to a power Input of data in SLIM is from a file named by
* , / multiplication, division the user. The form of the input statement is as
follows:
+ , - addition, subtraction
ACCEPT variable list
It should be noted that SLIM statements must
not extend beyond one line of code since The variable list contains variable names
there is no facility in the language for which can be of either real or integer type. An
any form of continuation line. Complex example of this type of SLIM assignment is
expressions may therefore have to be split ini-
tially into a number of smaller expressions ACCEPT VALUE,CONST,GAIN
and combined at a later stage in the program.
Output statement
(a) General-purpose statements
Output is always written to a named file on
disk, but may also appear in tabular form on
Integer and real assignments
screen if desired. The form of the output
This type of statement takes the general form statement is

Real variable = real expression TYPE variable list


or and examples are
Integer variable = integer expression
TYPE VALUE,CONST,GAIN
Examples of this type of assignment are TYPE J,IVAL
VELOCY=(7.5-DISTCE)/4.982
The variable list within an output statement
IVALUE=8+7*K must only involve variables of one type. A
94 The principles of equation-oriented simulation software
mixture of integer and real variables in a IF (arith. exp.) lab.l, lab. 2,lab. 3
single variable list is not permitted in an
When this type of statement is executed the
output statement. The first few items in the
arithmetic expression is evaluated and
output file provide information about the con-
control passes to Labell if the result is nega-
ditions selected within the simulation run and
tive, to Label 2 if the result is zero
are written to the file automatically. These
and to Label 3 if the result is positive.
include three integers providing system pro-
Examples of such a statement are as
gramming information, which are not of direct
follows:
interest to the user, followed by the values of
the communication interval, the minimum
IF (VELOCY-THRESH) 175, 90, 90
interval and the absolute and relative error
parameters used in the program. The next IF(IVAL-K)10,20,30
items have to be included in the output file
but require the inclusion of TYPE statements In the first case the expression (VELOCY-
in the SLIM source program for the simula- THRESH) is evaluated and control is passed
tion. They involve. in order, the number of to the statements in lines labeled 175 or 90
channels in the output, the number of samples depending on sign of the result. In the second
and the communication interval. Every SLIM case the integer result from the evaluation of
program must therefore include, at the end of the expression (IVAL-K) determines whether
the initial segment, three lines such as control passes to the statements with labels
10, 20 or 30. It should be noted that, in the
TYPE NCH case of real expressions, the condition corre-
sponding to the result being zero is not of
TYPE NSA
practical value because of problems of round-
TYPE SAM off and other inaccuracies in real arithmetic.

where NCH is the integer constant representing


GOTO statement
the number of output variables (including the
independent variable where appropriate), NSA This statement causes the normal sequential
is the integer constant representing the number process of program statement execution to be
of samples over the complete time history of interrupted. Control is passed uncondi-
each variable and SAM is the real constant rep- tionally to the line which has the label con-
resenting the communication interval. It is, of tained in the GOTO statement. For example,
course, important that these three quantities be the following section of program:
written to the output file in this particular
order and that they should be the first items X=l.O
output from the simulation program. Imme-
40 TYPE X
diately after this it is normal to output the
initial values of the independent variable and x=(X+lO.0)/2.0
of the system variables of interest. Therefore,
GOTO 40
four TYPE statements normally appear within
the initial segment of any SLIM simulation
would produce an endless loop which, if exe-
program for which an output file is required.
cuted, would produce an output sequence as
follows:
Arithmetic IF statement
5.50
The syntax of an arithmetic I F statement is as
follows: 7.75
SLIM - a simple continuous system simulation language 95
8.875 tions which define the dynamic simulation
model are normally contained within this
9.4375
section.
etc.
DERIVATIVE END statement
CONTINUE statement
The DERIVATIVE END statement defines the
A CONTINUE statement is a dummy execution end of the derivative section. It indicates that
statement and simply causes control to be all the integral assignments have been evalu-
passed to the next statement in the program. ated and the numerical integration routine is
called. On returning from the integration
routine the problem variables are all
STOP statement
updated. Once control has been passed into
A STOP statement causes execution to cease. the derivative section it will not be passed
This is usually the last executable statement beyond the DERIVATIVE END statement until
in a SLIM program. As with all other exe- a new communication interval is about to
cutable statements it can be given a label. start. If the start of a new communication
interval has not been reached control is
passed back to the start of the derivative
END statement
section and the integration process is
The purpose of an END statement is to indicate repeated with the updated variables. This
the end of the program. It must therefore continues until, at the appropriate time deter-
always be the last statement and since it is not mined by the communication interval,
executable it cannot be given a label. control is transferred from the derivative
section to the second part of the dynamic
segment but without reassignment of initial
values.
(b) Special-purpose simulation statements

DYNAMIC statement DYNAMIC END statement


The DYNAMIC statement is used to indicate The DYNAMIC END statement signifies the end
the start of the dynamic segment of the simu- of the dynamic segment. In order to enter the
lation program. In SLIM only one dynamic region of the SLIM program lying beyond the
segment is allowed within a program. On DYNAMIC END statement control must be
entering the dynamic segment the processor transferred explicitly by means of a GOTO or
assigns initial values to the integration vari- Arithmetic IF statement.
ables which are evaluated within the deriva-
tive section. The dynamic segment contains
INTEGral assignment statement
the derivative section and the segment is
therefore in two parts, one above the deriva- Each first-order differential equation gives
tive section and the other below it. rise to an integral assignment statement. This
type of statement has the form
DERIVATIVE statement
Real var . =INTEG (real exp., ini t. val.)
The DERIVATIVE statement indicates the
beginning of the derivative section which where
lies entirely within the dynamic segment.
The differential equations and other equa- ini t val. =real val. or real cons t .
96 The principles of equation-oriented simulation software
An example of a statement of this kind could MINTERVAL statement
have the following form
This statement defines the smallest step size
allowed for a variable-steplength method. If
X1=INTEG(V*W,X1INIT)
this lower limit is reached an error message
is displayed on the screen and control of
This indicates that the real expression V*W is the program is returned to the user. The
to be evaluated and from this the real variable MINTERVAL statement has the general form
Xl is to be calculated by integration with
respect to the independent variable (normally MINTERVAL(unsigned real constant
time). The initial condition for this integration or real variable)
operation is provided by the real variable
XlINIT which must have been defined at an for example
earlier stage in the program (usually in the
initial segment). MINTERVAL(1.0E-5)

The default is MINTERVAL (1. OE-4).


CINTERVAL statement
The CINTERVAL statement sets the commu- XERROR statement
nication interval, which defines the increment
of the independent variable at which control The XERROR statement is used to set the
is passed from the derivative section to the maximum absolute error that can be
dynamic segment. The format of this state- accepted in the results of the variable-
ment is as follows: steplength numerical integration. The value
is defined on a basis of the error for each
CINTERVAL(unsigned real constant integration step. The variable-steplength
or real variable) routine used within SLIM either satisfies the
requirement defined in the XERROR state-
ment or indicates to the user that the
For example, the statement
steplength has reached the minimum. The
form of the statement is:
CINTERVAL(O.2)
XERROR (unsigned real constant or
will cause control to be passed from the real variable)
derivative section to the dynamic segment
every 0.2 units of the independent variable. A typical example is
The default communication interval is 1.0,
and this value is used in any program in XERROR(1.0E-5)
which no CINTERVAL is defined explicitly. It
should be noted, incidentally, that the The default value corresponds to
default initial value of the independent vari-
able in a SLIM simulation is zero. Other XERROR(1.0E-4)
initial values are possible but must be set
by the user using an assignment statement
such as MERROR statement
This statement is similar to XERROR but sets
T=1.6 the maximum relative error (for each integra-
SLIM - a simple continuous system simulation language 97
tion step). Again the requirement is satisfied This second-order equation may be expressed
automatically unless the user is otherwise as two first-order equations
informed through an error message. The
format of the MERROR statement is similar to (6.2)
CINTERVAL, MINTERVAL and XERROR and a
typical example is (6.3)

MERROR([Link]-4) where the state variables Xl and X 2 are


defined as the variable y and its first deriva-
which would set the value to the default. tive dy / dt. Initial conditions must be
defined for both of these state variables. The
coefficient J.L is normally positive and lies in
6.6.3 OUTPUT FACILITIES AND GRAPHICS the range between 0 and 2. Van der Pol's
Graphical output may be obtained from the equation may be used to describe an elec-
SLIM program by means of a post-processing tronic feedback oscillator in which the non-
program which uses the results file from linear damping term can give rise to
self-excited oscillations.
SLIM as input. This program, called SLIM-
PLOT, requests the name of the results file, The program VDPOLS. SLI used to simu-
together with information about the channels late this very simple nonlinear system is given
of the output to be plotted. Both time history in Fig. 6.2 for the special case where the para-
meter J.L has a value of 1.0 and the initial con-
plots and x-y plots can be produced by
ditions for Xl and X 2 are 0.5 and -0.5
SLIMPLOT.
The first few items in the output files pro- respectively. The program includes comments
duced by the SLIM program provide informa- which provide much detailed information
tion about the simulation run and about the about the simulation. The initial, dynamic and
internal organization of the output file, as terminal segments are indicated clearly, as is
specified above. This information, which the derivative section, which is central to the
must appear in a standard format, provides program. Examination of this program shows
the post-processing program with essential that the right-hand side of equations (6.2) and
information, which allows it to interpret the (6.3) have been defined in the program by
simulation data which follows. means of additional variables DERIVl and
DERIV2 respectively. The computation of the
two state variables then involves integration
6.6.4 AN EXAMPLE OF A SIMULATION
of these two quantities starting from initial
PROGRAM IN THE SLIM LANGUAGE
conditions defined in the initial segment of
the program. All constants required in the
The example which follows has been chosen solution of the two differential equations are
to illustrate many of the features of the SLIM also defined in the initial segment, along with
language. It involves a simulation of a system quantities needed to control the integration
which is described by a well-known second- process and the communication interval. The
order nonlinear model known as Van der initial segment also includes statements that
Pol's equation. The differential equation of are concerned with the definition of quantities
this model is as follows: which have to be inserted as header informa-
tion in the results file and provide informa-
tion needed by the post-processing program
(6.1)
which produces graphical output. Figure 6.3
98 The principles of equation-oriented simulation software
C simulation of system described by Van der Pol's
C equation.
C
C ******************** Initial Segment*******************
C
C First section of program establishes number of output
C channels, number of samples and time interval for outputs
NCH=3
NSA=400
SAM=0.04
C
C Set parameter value for coefficient in the system equations
AMU=1.0
C
C Set initial conditions for xl and x2.
XlO=0.5
X20=-0.5
C
C Define the maximum value of the independent variable (time t)
TMAX=l6.0
C
C Set communication interval and integration parameters
CINTERVAL(SAM)
MINTERVAL([Link]-6)
MERROR([Link]-4)
XERROR([Link]-4)
C
C Information about file organisation written to results file
TYPE NCH
TYPE NSA
TYPE SAM
C
C Initial values of variables written to the output file
TYPE T,XlO,X20
C
C *******************Start of Dynamic Segment***************
DYNAMIC
C
C *****************Start of Derivative section**************
DERIVATIVE
DERIVl=X2
DERIV2=-X2*AMU*«Xl*Xl)-l.0)-Xl
Xl=INTEG(DERIVl,XlO)
X2=INTEG(DERIV2,X20)
DERIVATIVE END
C
C*******************End of Derivative Section*****************
C
C output t, xl and x2 for current communication interval
TYPE T,Xl,X2
C
C Test for end of simUlation run
IF(T-TMAX)10,10,l2
10 DYNAMIC END
C
C **********************Terminal Segment*********************
12 STOP
END

Fig. 6.2 Listing of the SLIM program VDPOLS. SLI for simulation of a Van der Pol oscillator.

shows the information which appears on the the simulation run illustrated in Fig. 6.3.
computer screen during the running of this Figures 6.5 and 6.6 show typical graphical
simulation. No input file is needed so no file results produced using the post-processing
name is provided. This table also includes the program SLIMPLOT. In Fig. 6.5 the results
first few values of the output as it appears on correspond to selection of channel 3 of the
the screen. results file as the y variable and channel 2 as
Figure 6.4 shows a subset of the results the x variable in an x-y plot. In Fig. 6.6 the
as they appear within the output file same results are shown as two separate time
VDPOLS . OUT which is created as a result of histories.
(a) SLIM
ENTER NAME OF SIMULATION FILE
[Link]
FILENAME FOR INPUT DATA? (HIT RETURN IF NONE)

OUTPUT FILENAME?
[Link]
RESULTS TO BE OUTPUT TO TERMINAL? (YIN)
:t..
3
400
.400000E-OI
.OOOOOOE+OO .500000E+00 -.500000E+00
.400000E-Ol • 479296E+00 -.535330E+00
.800000E-OI • 457164E+00 -.571343E+00
.120000E+00 .433579E+00 -.608069E+00
.160000E+00 .40B509E+00 -.645539E+00
• 200000E+00 etc. etc .
etc.

Fig.6.3a The screen display during the simulation run.

Data file name? [Link]


(b)

Select type of plot required


1. Y versus time
2. X-Y plot
Enter selection (lor 2) :- ~

Number of variables to be plotted? (1 to 2) 2


Enter column numbers of variables to be plotted against time:- 1Ll

Top title? (Up to 40 chars.)


VAN DER POL OSCILLATOR SIM!!!.ATIPN
Second title? (Up to 40 chars.)
Program; YDPOJ,S, SLI

Third title? (Up to 40 chars.)


Data file; Done

NAG PC GRAPHICS LIBRARY


WHICH GRAPHICAL DEVICE DO YOU WANT TO USE:
1. PC SCREEN
2. PC SCREEN (PART)
3. ROLAND D-XY 980 PLOTTER (A3)
4. ROLAND D-XY 980 PLOTTER (A4 UPRIGHT)
5. ROLAND D-XY 980 PLOTTER (A4 OBLONG)
6. GRAPHTEC MP 1000 PLOTTER (A3)
7. GRAPHTEC MP 1000 PLOTTER (A4 UPRIGHT)
8. GRAPHTEC MP 1000 PLOTTER (A4 OBLONG)
9. HP 7475 A PLOTTER (A3)
10. HP 7475 A PLOTTER (A4)
11. HP 7585 B PLOTTER (AO)
12. HP 7585 B PLOTTER (AI)
13. HP 7585 B PLOTTER (A2)
14. HP 7585 B PLOTTER (A3)
15. HP 7585 B PLOTTER (A.)
16. SEIKOSHA BP 5420 AI PRINTER
17. EPSON FX 85 PRINTER
18. EPSON FX 105 PRINTER
CHOICE?.l.

Fig. 6.3b The screen display at the post-processing stage using the SLIMPLOT program.
Fig. 6.3 Copy of screen display for the Van der Pol oscillator simulation run. Prompts from the computer
appear, together with responses from the user (which are shown here underlined).
100 The principles of equation-oriented simulation software
3 0 -1
.400000E-01 .100000E-05 .100000E-03 .lOOOOOE-03
3
400
.400000E-Ol
.OOOOOOE+OO .500000E+OO -.500000E+00
.400000E-Ol .479296E+00 -.535330E+00
.800000E-Ol .457164E+OO -.571343E+OO
.120000E+OO .433579E+OO -.608069E+00
. 160000E+OO .408509E+OO -.645539E+OO
.200000E+00 .381925E+00 -.683783E+00
.240000E+00 .353796E+00 -.722824E+00
• 280000E+00 • 324088E+00 -.762679E+00
• 320000E+00 .292771E+00 -.803358E+00
. 360000E+OO . 259809E+OO
.400000E+OO • 225171E+OO
.440000E+OO • 188826E+00
.480000E+OO .150743E+00
.520000E+00 • 110897E+00
.560000E+00
.600000E+OO
.640000E+00 .598834E+00
.680000E+00 .618052E+00
.720000E+00 .636853E+00
.655397E+00
-.167311E+Ol .673833E+00
-.164579E+Ol .692295E+00
-.161773E+Ol • 710907E+00
• -.158891E+Ol . 729785E+00
• 158800E+02 -.155934E+Ol .749043E+00
.159200E+02 -.152898E+Ol .768785E+00
.159600E+02 -.149783E+Ol • 789118E+00
.160000E+02 -.146585E+Ol .810145E+OO
.160400E+02 -.143301E+01 .831971E+00

Fig. 6.4 Part of file VDPOLS. OUT created during the Van der Pol oscillator simulation run of Fig. 6.3. The
first three values in the file are all integers and convey diagnostic information of little interest to the user.
The next four items provide the communication interval, the absolute and relative error values specified
in the simulation program and the minimum interval value. All this information is provided automati-
cally at the start of each print file but is not used by the SLIMPLOT program to produce graphical output.
The subsequent items in the file all correspond to TYPE statements in the simulation program and all are
used by SLIMPLOT. The first three of these represent the number of channels being output (three in this
case, corresponding to the variables T, Xl and X2 in the program), the number of samples in the simula-
tion run (400 in this case) and the communication interval (0.04 in this case). The values which follow all
represent the response information for the simulation run, with the three columns corresponding to
values of T, Xl and X2 at each communication interval. Note that the value of the communication interval
appears twice in the header data.

Figure 6.7 shows a slightly modified version Although Van der Pol's equation is rela-
of part of the initial segment of the simulation tively simple in form, it shows some very
program in which the parameter value for the interesting features in terms of its properties.
coefficient, IL, and initial conditions in the It can be seen from the results of Figs 6.5 and
system equations are read from a data file. 6.6 that, for the parameter values and initial
Figure 6.8 represents this input data file, and it conditions chosen, the system response is
may be seen from this that the data are identi- oscillatory and shows a maintained oscillation
cal to that incorporated within the program of of constant amplitude, after an initial tran-
Fig. 6.2. In running the modified program the sient. This is because for small values of y (y
procedure is exactly as described above except less than unity) the damping in this second-
that the input file name, VDPOLS . IN, is given order system is negative. As y increases, the
in response to the prompt from the SLIM value of the factor (if - 1) eventually becomes
program. Results in this case are identical to zero and then positive. One would therefore
those found previously. expect intuitively that the oscillation should
Examples of other simulation languages 101
VRN DER POL OSCILLRTOR SIMULATION
r-~l

--1

P~ogam; [Link]
oot.a f -c L!:? : non!:?
Fig.6.S Simulation results for the Van der Pol oscillator simulation in the form of an x-y plot. Here X, is
the x-axis variable and x, is the y-axis variable.

build up in amplitude until a point is reached values of the parameter IL, including nega-
at which the nonlinearity starts to limit the tive values. A further useful exercise is to
amplitude because the damping has changed modify the simulation program slightly to
in sign. The response thus shows typical 'limit allow study of a system described by the
cycle' behavior. equation
The limit cycle feature of the response
shows up very clearly in the phase plane ----t
d
dt
2
+ IL (y2 - 0.1 y4 -1) + y = 0 (6.4)
type of plot involving X2 plotted against Xl'
On the one hand, if separate simulation runs It is left to the reader to modify the program
are performed for a number of different sets VDPOLS . SLI to investigate the nature of the
of initial conditions it is found that a closed model behavior in this second case.
path is defined in the phase plane to which
all the trajectories tend regardless of the
6.7 EXAMPLES OF OTHER SIMULATION
starting point. This is typical of systems
LANGUAGES
which have stable limit cycle behavior.
Unstable limit cycle behavior, on the other
6.7.1 CSSLIV
hand, would give rise to a locus in the phase
plane from which all the trajectories would CSSL IV [9] is a simulation language which
tend to diverge. Therefore, it is interesting has a form which is very strongly linked to
to investigate the way in which the response the 1967 recommendations for continuous
of the system varies with different sets system simulation languages. CSSL IV is
of initial conditions and with different translator based and converts the source
102 The principles of equation-oriented simulation software
VAN DER POL OSCILLATOR SIMULATION
l
I

l "

o ."

-1

-2
\ ..
'" I

P~ogam: [Link]
Data f{.Lel none

KEY

-- COLUMN 2
-- -' COLUMN 9

Fig. 6.6 The results of Fig. 6.5 displayed as separate plots of Xl and X, versus time. Here the continuous
line represents Xl (column 2 of the output file and the second variable in the TYPE statement in the
DYNAMIC segment of the program) while the dashed line represents X, (column 3 of the output file and the
third variable of the TYPE statement).

C Simulation of system described by Van der Pol's


C equation. Input data from file.
C
C ******************** Initial Segment*******************
C
C First section of program establishes number of output
C channels, number of samples and time interval for outputs
NCH=3
NSA=400
SAM=O.04
C
C Input parameter value for coefficient in the system
C equations (from data file)
ACCEPT AMU
C
C Input initial conditions for xl and x2 from data file.
ACCEPT X10, X20
etc.
etc.

Fig. 6.7 Listing showing a modification to part of the initial segment of the SLIM program VDPOLS. SLI
to allow data for the initial conditions (XIO and X20) and the program variable AMU (the parameter J.L of
the mathematical model) to be input from a data file.

program written in the CSSL IV language into generates the equivalent of about 50-250 lines
a set of Fortran 77 programs which are subse- of Fortran. CSSL IV has powerful macro
quently compiled. Each line of CSSL IV code facilities.
Examples of other simulation languages 103
1.0 tinuous system simulation. This is achieved
0.5 by the provision of a DISCRETE section in
-0.5
which difference equations can be coded to
Fig. 6.8 Listing of the data file to be used with the represent discrete elements within a mixed
modified program of Fig. 6.7 for the Van der Pol continuous and discrete model. The DIS-
oscillator simulation. CRETE section is equivalent to a DERIVATIVE
section in a purely continuous simulation
CSSL IV provides for a clear separation of program.
the model definition from the experiments to Simulation programs written using ACSL
be carried out using that model. A powerful have two parts which are quite separate. The
runtime monitor is provided which allows first of these is the model definition, while
the user to control the simulation and carry the second is the set of commands required
out all the necessary interactive processes to control the simulation at runtime. The
such as changing parameters, collecting data benefit which this type of approach gives is
and presenting results. Experiments may be that the model may be defined once
interrupted using a 'break key', which allows and analyzed repeatedly using runtime com-
a simulation to be stopped while remaining mands which are specified either interac-
within the CSSL IV environment. tively or in a batch mode of operation.
In addition to the standard facilities Figure 6.9 is a listing of an ACSL program
expected in simulation languages which for the simulation of the system described
adhere to the 1967 recommendations, CSSL by Van der Pol's equation. Many similar-
IV incorporates a number of useful addi- ities may be found when this program
tional features. As well as special-purpose is compared with the SLIM version in
facilities associated with the simulation of Fig. 6.2.
continuous and mixed continuous-discrete As with CSSL IV, the model definition in an
systems, CSSL IV incorporates analysis tools ACSL program is translated into Fortran. The
such as a steady-state finder, FFT (fast translated model is then loaded with the
Fourier transform) processing and lineariza- runtime library which reads and interprets
tion routines. the set of runtime commands. A variety of
CSSL IV is available on all major computer forms of output may be produced, in both
systems. CSSL IV simulation models are tabular and graphical form.
highly portable and the accuracy is claimed to ACSL allows the user considerable scope in
be machine independent. terms of interactive usage. Simulation com-
mands may be issued individually and data
may be modified at the time of the simulation
6.7.2 ACSL
experiment. Unlike many other simulation
ACSL (Advanced Continuous Simulation languages, ACSL imposes no limits for inter-
Language) [10] is an equation-oriented simu- nal tables used by the translator and thus has
lation language that has a form which corre- no arbitrary limits on the number of state
sponds closely to the CSSL specification [6] in variables, the number of symbols or the
many respects. It has a number of features number of labels in the simulation program.
which exceed the requirements of the 1967 As with most other modern simulation lan-
specification very considerably and it is guages, ACSL has a macro capability which
undergoing a continuous process of upgrad- allows the set of special ACSL statements to be
ing and improvement. ACSL, as with most extended. Macros are similar to a subroutine
other commercial packages currently avail- or function in conventional high-level pro-
able, has facilities for mixed discrete and con- gramming languages. Once defined the macro
104 The principles of equation-oriented simulation software
PROGRAM Van der Pol Oscillator simulation
INITIAL
CONSTANT mU=1.O,yic=O.5,ydic=O.O,tend=15.0
CINTERVAL CINT=O.04
END $ "of INITIAL"
DYNAMIC
DERIVATIVE
ydd=-mu*(y*y-l)*yd-y
yd=INTEG(ydd,ydic)
y=INTEG(yd,yic)
END $ "of DERIVATIVE"
TERMT ([Link])
END $ "of DYNAMIC"
TERMINAL
END $ "of TERMINAL"
END $ "of PROGRAM"

Fig. 6.9 Listing of an ACSL simulation program for the Van der Pol oscillator. Note the explicit definition
of the INITIAL, DYNAMIC and TERMINAL segments and form of syntax used. Comments are denoted in
this listing by means of a $ symbol.

may be invoked as many times as it is needed. formerly of the University of Arizona. It is a


Macro facilities in ACSL provide a basis for simulation language which is based on a
special applications-related submodels and technique known as direct program execu-
are an important feature of the language. tion and differs from many other equation-
Facilities are provided in ACSL for program oriented simulation languages in a number
sorting, and the code which defines the model of important respects. Examples of more
is sorted so that every variable is calculated general direct-executing languages include
before it is used. Any problem without alge- interpreted Basic and FORTH. A number of
braic loops can be completely sorted without different versions of DESIRE have been
difficulty, both for purely continuous and developed, and it is available for a number
mixed continuous and discrete simulations. of different types of computer. Versions for
ACSL is available for a wide range of IBM-compatible personal computers are
multiuser computer systems, workstations available which run on 80286, 80386 and
and personal computers. It has been available 80486 machines. DESIRE combines an inter-
for many years and is one of the most widely preter with a runtime compiler and is
used simulation languages. An important capable of providing a speed of solution in
new feature of ACSL is a graphical interface simulation applications which would be well
to allow model definition from a block beyond the capabilities of a conventional
diagram created on the graphics screen under interpreter. In interpreted Basic, for example,
mouse control. every statement is translated each time it is
encountered in the program. A typical simu-
lation program in Basic would inevitably
6.7.3 DESIRE
involve a loop, or a number of nested loops.
DESIRE (Direct Executing Simulation In REal Every statement in every loop would be
time) [15-17] has been developed by Kom, translated each time the loop is traversed.
Comparisons of SLIM with widely used simulation languages 105
This is avoided in DESIRE by using an inter- unless they are declared to be integer,
preted initial section of the program, in complex or array variables. DESIRE has no
which the experiment is defined, and a com- equation sorter so the user must ensure that
piled model definition. The interpreter reads the equations are organized in an executable
and executes all the lines which precede the sequence. Sub model facilities are provided
DYNAMIC statement. Immediately before the through the use of macro definitions.
DYNAMIC statement there must be a state- DESIRE has an OUT block facility that is
ment 'drun' and when this is executed a somewhat similar to the portion of the
compiler translates the following dynamic DYNAMIC segment in SLIM or ACSL which
segment of the program into machine code. lies outside the DERIVATIVE section.
This compilation process is generally very Statements within the OUT block in DESIRE
fast since it only involves simple expressions programs are executed once during each
and output requests. The user is therefore communication interval rather than at each
unaware in most cases of any delay during integration step. DESIRE includes facilities for
this runtime compilation process. graphics displays at runtime so that the simu-
The combination of the interpreted initial lation user can readily observe results as they
section and the compiled model definition are being generated. Figure 6.10 provides an
section in DESIRE programs provides a fast example of a DESIRE program listing for the
and user-friendly interactive simulation envir- Van der Pol problem previously considered.
onment for IBM-compatible personal comput-
ers. Other versions of DESIRE, such as
6.8 COMPARISONS OF SLIM WITH
DESIRE/X, are available for a workstation
WIDELY USED SIMULATION LANGUAGES
type of environment. Predecessors of the
current versions of DESIRE include other soft- SLIM is intended to provide an introduction
ware products originating at the University of to some of the principles of continuous
Arizona, such as MICRODARE, EARLY system simulation and has been designed
DESIRE, DESIRE P and DESCTOP [15]. as an inexpensive teaching tool. It is
Extremely fast operation with DESIRE is not intended to compete directly with com-
possible on personal computers based upon mercially supported languages. SLIM is most
an 80486 processor, or on an 80386 processor suitable for relatively small simulation prob-
equipped with a numeric co-processor (on lems. It does, however, conform to many of
which much of the simulation code is ex- the conventions of the CSSL specification and
ecuted). DESIRE is a fully equipped simula- provides a convenient, efficient and easily
tion system with screen editing and line used tool for the beginner. Having gained
editing facilities. The interpreter facilities of some initial experience with SLIM the user
the language are similar in many ways to should be able to move on without difficulty
Basic but include extra features concerned to make use of other more powerful lan-
specifically with simulation. The dynamic guages, such as ACSL.
segment of a DESIRE program involves an A maximum of 40 state variables can be
equation-oriented model definition based on accommodated within a SLIM simulation
conventional mathematical notation for ordi- program using the version of the SLIM soft-
nary differential equations. Up to 1000 linear ware which accompanies this text. This is not
or nonlinear first-order equations can be seen as imposing any serious restriction on
handled using fixed-step and variable-step the average beginner. All of the examples and
Runge-Kutta integration methods. All vari- case studies considered in later chapters
ables and constants in DESIRE are repre- involve fewer than 10 state variables. A max-
sented by 32-bit floating-point quantities imum of 250 statements is allowed within a
106 The principles of equation-oriented simulation software
Van der Pol Oscillator simulation
-------- Timing
NN=500
TMAX=l5
DT=0.01
-------- Display scale
scale=3
-------- Initial conditions
y=0.5
ydot=-O.O
-------- Loop involving multiple runs
for mu=O.5 to 1.5 step 0.2
drunr
next
DYNAMIC
-------- Model equations
d/dt y=ydot
d/dt ydot=-y-mu*(y*y-1)*ydot
dispxy y,ydot

Fig. 6.10 DESIRE program listing for the Van der Pol oscillator. In this case the program has been written
in such a way that multiple runs are being performed for a range of values of the parameter 'mu'.
DESIRE has a command-mode interpreter statement 'drun' which calls for a simulation run. In this
example, use has been made of the similar statement 'drunr', which is an extension of the 'drun' type of
statement for use in repetitive simulation experiments in which initial conditions must be reset before the
start of each separate run.

SLIM program. Once again, typical applica- The absence of facilities to model a pure
tions involve much smaller programs. As has time delay (transport delay) is one important
been explained in section 6.7, some simula- example of a feature available in many simu-
tion languages, such as ACSL, do not impose lation packages which has not been included
limitations of this kind. within the version of SLIM provided with this
While the restrictions in terms of program book. The lack of any facility to represent a
size are not thought to represent limits which function in tabular form is another example
are likely to be approached by the beginner, it of a potentially useful feature which has not
is important to understand that languages been included. Problems which require the
such as CSSL IV, ACSL and DESIRE provide use of such facilities cannot be tackled using
many features which are not available within SLIM unless the problem can be reformulated
SLIM. Some of these restrict the type of in some way to allow it to be solved within
system which can be modeled using SLIM the limitations of the language. Other lan-
and others limit the options available to the guages provide a much more extensive set of
user at runtime. The subset of facilities incor- facilities and therefore provide much more
porated in SLIM has been chosen to allow the flexibility at the model definition stage.
beginner to gain experience rapidly, without In comparison with ACSL and other similar
having to deal with the complexities associ- languages SLIM has limited capabilities in
ated with certain types of feature which are terms of runtime options. There is no real sep-
included in more comprehensive languages. aration of the model definition and the exper-
A careful examination of the user manual for iment in SLIM. Changes of parameters
each specific language allows the potential require editing of the simulation program
user to establish the precise differences in itself or changes of an associated data file.
every case. However, flexibility is available, in terms of
References 107
output display facilities, in SLIM because of 7. Control Data (1970) MIMIC - A Digital
the fact that the graphical output options Simulation Language Reference Manual, revision
involve a separate post-processing program. D, Publication No. 44610400, Control Data,
Minneapolis, Ml.
The reader can gain some appreciation of 8. Control Data (1971) Continuous System Simu-
the facilities of languages other than SLIM in lation Language, Version 3, User's Guide, Control
the applications chapter which include some Data, Sunnyvale, CA.
comparisons of SLIM with other implemen- 9. Simulation Services (1984) CSSL-IVReference
tations of the same simulation problems. Manual, Simulation Services, Chatsworth,
SLIM can be extremely effective when learn- CA.
ing about the principles of simulation and 10. Mitchell, E.E.L. and Gauthier, J.S. (1976)
Advanced continuous simulation language
when used for the solution of problems for
(ACSL). Simulation, 25, 72-78.
which its facilities are appropriate. It is 11. IBM (1968) System/360 Continuous System
important, however, to understand its limita- Modeling Program (360A-Cx-16X) Application
tions and to have an appreciation of the addi- Description, IBM Publication GH20-0240-2.
tional facilities of the software products 12. Speckhart, F.H. and Green, W.L. (1976) A
which are available commercially. Guide to Using CSMP, Prentice-Hall, Engle-
wood Cliffs, NJ.
13. Ricketts, l.W. (1977) MIMESIS - a continuous
REFERENCES system simulation language. University of
Dundee. PhD thesis.
1. MathWorks (1993) MATLAB User's Guide, 14. Ricketts, l.W. and Dickie, A.A. (1978)
MathWorks, Natick, MA. MIMESIS - a machine independent CSSL for
2. Billmann, L., Mirab, H. and Winkler, U. (1992) minicomputer systems, in Proceedings of
CACSD - CASE tools. Measurement and the UKSC Conference on Computer
Control, 25, 137-43. Simulation, 1978, Chester. IPC, Guildford,
3. Cellier, F.E. and Rimvall, CM. (1989) Matrix pp. 193-203.
environments for continuous system model- 15. Kom, G.A. (1989) Interactive Dynamic System
ling and simulation. Simulation, 52 (4), 141-49. Simulation, McGraw-Hill, New York.
4. Hindmarsh, A.C (1983) ODEPACK, a system- 16. Kom, G.A. and Kom, T.M. (1993) Simulating
atized collection of ODE solvers. IMACS dynamics and neural networks under DOS,
Transactions on Scientific Computing, I, 55-64. OS/2 and UNIX, in Proceedings of the 1992
5. Petzold, L.R. (1982) DASSL: A Differential/ EUROSIM Conference, EUROSIM'92, 28
Algebraic System Solver, Report No. SAND82- September-4 October, 1992, Capri (eds
8637, Applied Maths Division, Sandia F. Maceri and G. Iazolla), North-Holland,
National Laboratories, Livermore, USA. Amsterdam, pp. 103-15.
6. SCi Software Committee (1967) The SCi 17. Kom, G.A. (1991) Neural Network Experiments
Continuous-System Simulation Language. on Personal Computers and Workstations. MIT
Simulation, 9 (6), 281-303. Press, Cambridge, MA.
THE PRINCIPLES OF BLOCK DIAGRAM-
ORIENTED SIMULATION TOOLS
7

7.1 GRAPHICAL MAN-MACHINE mouse on the desk-top produce equivalent


INTERFACES FOR SIMULATION movements of the pointer on the screen.
Selection of an object on the screen is per-
The only form of interactive man-machine formed by moving the pointer until it is
interface which was generally available until above the icon of interest and then pressing
the 1970s involved the user entering com- one or more of the mouse buttons. A WIMP
mands via a keyboard. These commands environment also includes 'windows', which
were then interpreted and acted upon by the can provide a number of separate work
operating system or program. Such an inter- spaces or tasks which are active simultane-
face makes it necessary for the user to learn a ously. Windows may often be overlaid on top
command language, and it is claimed that this of each other.
may introduce a significant psychological Windows-based products are now com-
barrier for some people. Since the command monplace, especially in the personal computer
language is different for different operating and workstation types of environment, and
systems, in terms of both syntax and the facil- the general assumption in most new commer-
ities available, it can certainly be time-con- cial software is that a high degree of user-
suming and frustrating to have to make a friendliness must be provided, usually
change from one system to another. through a WIMP interface. Although the
Since the 1970s developments in the user market for continuous systems simulation soft-
interface for operating systems and for many ware is relatively small and highly specialized,
applications software packages have led to a this general trend has influenced the nature of
very different form of environment. This is simulation software products introduced in
the so-called WIMP interface. The acronym recent years. Many products are now available
WIMP stands for Windows, Icons, Mouse and which exploit this form of interface for contin-
Pop-up menus. Such an interface allows the uous system simulation. Such an interface
user to manipulate objects and perform allows the user to construct, on-screen, a block
actions on a graphical screen through 'icons' diagram of the system using predefined icons.
and 'menus'. Icons are special graphical The model structure can then be altered graph-
symbols which appear on the screen and ically, parameters changed, input types re-
which represent pictorially objects or actions defined and so on, through selection of the
which are of importance to the user. The need appropriate icon or menus. Block diagrams
to learn a command language disappears can also be rearranged graphically as they
with an interface of this kind because actions evolve to provide a clear and unambiguous
can be performed simply by selecting the description. Output can be displayed using
appropriate icon or menu item, usually by appropriate windows or can be stored for sub-
means of a pointer which is controlled by sequent post-processing. Through such an
hand using a mouse. Movements of the interface the digital simulation of continuous
110 Principles of block diagram-oriented simulation tools
systems can become a highly user-interactive upon the block diagram type of system
process based upon a form of model descrip- description outlined in Chapter 3. The
tion which is a natural one for many types of approach depends upon the ability of the user
engineering investigation. The structure of the to construct a simulation model from basic
model and the flow of information within the elements such as gain factors, integrators,
model often appears most clearly using this multipliers and summers. In general, each
type of approach. Further, block diagram- element may have a number of inputs but has
based methods provide a natural form of only one output. Many different tools have
'top-down' model development. The most been developed for block diagram-based
important information, concerning the pur- modeling and simulation, and much of the
pose of a given element and the connections to earliest development in the digital simulation
other elements, inevitably appears first in the field involved block diagram-oriented soft-
diagram and the details of the internal repre- ware tools. One of the most important early
sentation of that block can be inserted later [1]. examples based on this approach was the
Although developments of this kind are of IBM CSMP 1130 software.
considerable interest and importance it must In block-oriented software products the
be remembered that a graphical interface may structure and parameters of each block are
not always be an advantage for all types of stored in tables. The name of a block usually
user. A tool of this kind should always be an also represents the value of the output of that
aid and not a burden. It must be of value to block. Many products of this kind have been
experienced simulation users as well as to interpretive in nature so that they could be
beginners and must be sufficiently flexible in highly interactive, allowing modification of
terms of the options available to ensure that the structure of the model or the parameter
the inevitable computational overheads do values without any need for recompilation or
not become unacceptable to those with linking. Disadvantages of this interpretive
numerically intensive simulation problems. approach, of course, include the fact that
The graphically based environments currently program execution is relatively slow and the
available certainly do not all suit every type of user lacks facilities to introduce additional
application, and it should be recognized that block types or commands.
equation-based software products and those One relatively recent block diagram-ori-
involving graphical forms of model descrip- ented language which attempts to overcome
tion are likely to coexist for many years. In some of the problems associated with some
this context graphical preprocessors, such as previous products of this type is PSI
that described by Barker, Huynh-Quoc and (Interactive Simulation Program), which has
Townsend [2], are of particular interest since been developed at the Laboratory for Control
they can provide interfaces to widely used Engineering at the Delft University of
continuous system simulation packages, such Technology [3,4]. A similar and closely
as ACSL or SIMNON. A preprocessor allows related block-oriented language (BIOPSI) has
a user to choose whether to describe the also been developed at Delft specifically for
model in graphical form or to use a more con- biomedical applications [5]. A PSI or BIOPSI
ventional equation-based description. program consists of a table which defines the
structure of the model, the model parameters
and the simulation run control parameters.
7.2 THE BLOCK-BASED APPROACH TO
Each block has one output, a maximum of
THE DESCRIPTION OF DYNAMIC SYSTEMS
three inputs and three parameters defining the
Block diagram-oriented simulation programs relations between them. Examples of standard
are, as the name suggests, directly based PSI blocks are INT (integrator), MUL (multi-
Examples of block-oriented simulation environments 111
plier), SUM (summer), TDE (delay time) and Examples of the first type of software,
HYS (hysteresis). Altogether about 60 different which acts as a graphical interface to an
block types are provided, and features are established simulation package, are to be
included which provide the user with con- found in the work of Barker, Huynh-Quoc
siderably more flexibility than was possible and Townsend [2], which has involved the
with many earlier block-oriented languages. development of standard graphical software
Although available as an interpreter, the user that has been designed to provide a general
can also save the model and translate it into interface to a range of different equation-ori-
Fortran code by means of a special compiler. ented simulation tools. A more specialized
model editing and simulation interface of this
kind is the ACSL/Graphic Modeller, which
7.3 EXAMPLES OF BLOCK-ORIENTED
has been developed by Mitchell and Gauthier
SIMULATION ENVIRONMENTS WITH A
Associates [6] as an enhancement to their
GRAPHICAL USER INTERFACE
existing equation-oriented ACSL product.
Block diagram-oriented simulation software The ACSL/Graphic Modeller provides facili-
which is equipped with a modern graphical ties to handle diagrams at a number of differ-
user interface comes in a number of different ent levels, the lowest of these containing the
forms. Firstly, there are products which actual basic ACSL components. Diagrams at
provide a graphical interface to an established higher levels contain blocks created by the
simulation package such as ACSL or user as sub models and combined together to
SIMNON. A second form of simulation envi- provide a top-level diagram which is clear in
ronment has been created by developing terms of its structure and free from unneces-
block diagram software packages which can sary detail. The diagrams of all the tiers are
be used in conjunction with matrix-oriented accessible through simple mouse-click
analysis software such as MA TLAB and actions. The ACSL code behind the blocks is
MATRIX,. A third type of environment is pro- also accessible without difficulty, and existing
vided by stand-alone general-purpose simu- ACSL, Fortran or C code may be incorporated
lation packages, such as XANALOG, which within a block.
have a graphical user interface but have not Products which are based upon matrix-
been developed as enhancements to earlier oriented analysis packages include the
software products. In all three cases the SIMULINK package [7, 8], which is associated
essential feature of the software is that it with the MATLAB software products from
ensures that the simulation program for a The MathWorks Inc., and SYSTEM_BUILD
given model and the block diagram of the [9], which is part of the MATRIX, product
model are one and the same. This can be family from Integrated Systems Inc. The
helpful in describing and discussing a simula- MATLAB and MATRIX, products, which are
tion since the structure of the model is much available for a wide range of computers and
more obvious in this case than it would be operating systems, provide comprehensive
from an equivalent program listing in an interactive linear systems analysis tools for a
equation-oriented simulation language. wide range of scientific and engineering
Hierarchical structures and the ability to applications. These packages are based upon
create user-defined submodel icons which are well-established numerical analysis tools
possible with these block-oriented methods and provide convenient interfaces and
also assist greatly in terms of simulation expandable function library facilities. Both of
model presentation and documentation. A these analysis products are widely used for
library of standard sub models can be built up control systems applications studies, and the
and shared between the members of a group. provision of facilities for nonlinear simulation
112 Principles of block diagram-oriented simulation tools
is a valuable extension. Simulation facilities Powerful user-interaction facilities at
are also provided in connection with other runtime provide the SIMULINK user with
analysis and computer-aided design pack- opportunities to change parameters and other
ages, such as EASY5 [10]. features of a simulation model during a simu-
SIMULINK is fairly typical of the simula- lation run. Immediate feedback at runtime is
tion products which have developed as exten- provided by the use of the very flexible
sions of existing packages for linear analysis output graphs display facilities. Similar levels
and design of dynamic systems. The other of interaction at runtime are also possible in
products of this type, mentioned above, some other modern products.
provide broadly similar facilities. SIMULINK SIMULINK uses standard windowing envi-
and SYSTEM_BUILD both provide facilities ronments, such as Microsoft Windows, X-
for simulating nonlinear or linear dynamic Windows and the Macintosh windowing
systems and allow a block-oriented approach system. Use of a standard of this kind can be
for model definition. Defining a model on the of considerable assistance to users already
screen involves copying blocks from a stan- familiar with the chosen environment and
dard block library or from a more specialized may reduce the time required to become skill-
block library created by the user. Connections ful in the use of the simulation tool.
are then made on the screen to provide the Being closely associated with the MATLAB
necessary block diagram linkages. Experi- software products SIMULINK has special
ments on a SIMULINK model created in this potential for control systems investigations,
way may be carried out either using the as well as being a general-purpose simulation
SIMULINK menu options or through a tool. Two facilities which are of special signif-
MATLAB command window. The more direct icance in this respect are the trim routine,
approach involves controlling the simulation which allows calculation of equilibrium
from the menu and viewing the response on points, and the linmod routine, which derives
the screen using special-purpose 'scope' linearized descriptions from a nonlinear sim-
blocks. Integration techniques and integration ulation model for a given set of operating
parameters may be selected easily and basic conditions. Similar facilities are available in
control operations such as starting a simula- other commercial products of this type.
tion run, stopping and changing parameters SIMULINK and the other packages men-
can be performed interactively. Use of a tioned also provide facilities for handling dis-
command line approach is less interactive but crete models and mixed continuous-discrete
can be more convenient in some situations. situations of the kind that arise in the study
With the SIMULINK extension MATLAB is of digital control systems. A SIMULINK simu-
provided with an additional type of function, lation model may incorporate a number of
known as an S-function. When a SIMULINK discrete submodels, and these may all involve
model is created an S-function is formed different sampling rates.
which defines the dynamics of the model. An example of the stand-alone type of
One useful feature of SIMULINK is that it is graphically based simulation product is pro-
possible to create models directly without the vided by the XANALOG XA-lOOO simulation
use of the block diagram editor by replicating environment [11], which was introduced both
the behavior of the S-function within a stan- as a special-purpose high-performance
dard MATLAB program file. Once a working simulation workstation and as software to be
model has been established, either on screen run on conventional personal computers.
by means of the block diagram editor or In the personal computer-based version
directly using a more conventional editor, it XANALOG provides a wide range of stan-
is possible to save the model on disk for sub- dard facilities for model building, editing,
sequent re-use. running a simulation, post-processing and
Simulation example using graphical block-oriented tools 113
analysis. XANALOG is compiler-based, with compare the features of the various packages
the graphical 'source code' being operated on mentioned above or to make any judgments
by compilers in two stages. The first stage regarding their relative merits. Anyone inter-
of compilation involves production of an ested in using commercial tools of this kind
intermediate 'tree' language, and this is sub- should, of course, always undertake a careful
sequently compiled into object code. Special review of their requirements and of the facili-
simulation error-detection and verification ties available within competing products.
routines are provided, which allow errors
and potential problem areas, such as alge-
7.4 A SIMPLE SIMULAnON EXAMPLE
braic loops, to be found at an early stage in
USING GRAPHICAL BLOCK-ORIENTED
the simulation process. The interactive
TOOLS
runtime environment allows the user to view
the simulation on the computer display as it The example involving Van der Pol's equa-
executes. The user may, for example, stop the tion, which was discussed in Chapter 6, is a
simulation and change parameters, then simple nonlinear model which provides a
restart to observe the effect of the changes. convenient illustration of the use of graphical
Additional options in XANALOG allow a block-oriented tdols. Figure 7.1 shows a block
checked model to be converted to trans- diagram of the system involving integrator
portable Fortran source code and extra blocks, and blocks for summation of vari-
input-output boards can provide limited ables, multiplication of a variable by a con-
real-time analog and digital input-output stant and multiplication of two variables.
facilities. The special-purpose XANALOG Figure 7.2 is a description of Van der Pol's
Model 1050 and 1051 workstations use equation using the BIOPSI interactive simula-
floating-point array processor technology, tion program [5]. This shows how block
and the compiler generates code which names are used and how the structure and
allows the array processor to execute the parameters of each block are stored in tables.
simulation in a highly efficient fashion. Calculation of the variables is achieved by an
Equipped with additional input-output interpretive process and communication with
boards the workstation can provide powerful the BIOPSI user is by means of a command
real-time facilities for a range of applications language. Each command is executed imme-
involving relatively fast dynamics. diately and this provides a high degree of
Product developments are very rapid in this user interaction. A change in the parameters
field, and no attempt has been made here to or structure of the simulation program does

f J x

Fig. 7.1 Block diagram of the Van der Pol oscillator system.
114 Principles of block diagram-oriented simulation tools

iC2 iC1

lIlT lilT MUL GAl


x2 X1 MUL
v1 vg1
sq

COli
unity 1 - - - - '

Block Type Inputl Input2 Input3 ParI Par2 Par3

diff SUM vgl xl -1 -1


x2 INT diff -.5 1
xl INT x2 .5 1
sq MUL xl xl
unity CON 1
el SUB sq unity
vI MUL x2 el
vgl GAl vI 1.0

b
Fig. 7.2 Description of the Van der Pol oscillator using the BIOPSl interactive simulation program.
(a) The BlOPSl structure diagram for the simulation. (b) The corresponding table defining the program. In
the structure diagram, block types are indicated in the upper right corner of each block, and in
this example involve INT (integrator), MUL (multiplier), GAl (gain factor) and CON (constant). The block
name is shown in the middle of each block. Circles indicate a SUM (summer) or SUB (subtractor) block, and
in these cases the names are shown next to the symbol. Note that the numerical values (0.5 and -0.5) for
the initial conditions of the two integrator blocks appear only in the Parl column of the program listing.

not require any compilation or linking difference equations. Model descriptions


processes. One disadvantage of an interpre- entered in equation format are written as
tive approach of this kind is the relatively MATLAB S-functions (already described).
slow execution speed, but programs such as These have a predefined calling syntax.
BIOPSI can be very useful for small simula- Models created using the block diagram
tion problems. approach are also stored as S-functions, and
Figure 7.3 is a SIMULINK diagram for solu- these functions provide a simple means of
tion of the Van der Pol problem. This shows incorporating SIMULINK models into the
the SIMULINK icons, which are equivalent to MATLAB command set.
the standard block diagram symbols of Fig. Figure 7.4 shows an XANALOG block
7.1. As mentioned in section 7.3, it should be diagram for the solution of Van der Pol's
noted that, although SIMULINK enables equation. When this is compared with the
models to be described in block diagram standard block diagram of Fig. 7.1, the
form, there are also facilities which allow meaning of each of the icons used in
models to be defined as sets of differential or the XANALOG diagram becomes obvious.
References 115
x2

x1

Fig. 7.3 A SIMULINK diagram for solution of the Van der Pol oscillator problem. The meaning of each of
the SIMULINK icons becomes obvious when this diagram is compared with Fig. 7.1. Note the use of the
'scope' icons to indicate that the variables xl and x2 are to be displayed.

r ... . ,
0 INT2
1 0 INTl
L4~l . ..
MU

.[D ...
1 ... 00e--+-oo

·,
··
1__ ... __ ... ____ ................. _ ....... _____ ...... __ ... __ ~

1_00e--+-Oo

Fig. 7.4 An XANALOG block diagram for the Van der Pol oscillator problem. Note that in this diagram
the dotted lines indicate quantities which have been inverted (multiplied by -1).

Investigations of different integration para- broadly equivalent graphical editing facilities


meters and methods, or of the response to dif- and runtime features.
ferent initial conditions, are easily carried out
interactively using either the SIMULINK or
XANALOG products. Further examples of REFERENCES
applications of the SIMULINK and XANALOG
1. Humphreys, K. and Foss, A. (1989) A block-
simulation tools are included in the case
based graphical approach for the description
studies presented in some of the later chap- and analysis of dynamic systems, in ESC89:
ters of this book. Similar results could, of Proceedings of the 3rd European Simulation
course, have been obtained for all these exam- Congress (eds D. Murray-Smith, J. Stephenson
ples using other block diagram-oriented and R.N. Zobel), SCS Europe, University of
simulation products, many of which have Ghent, pp. 369-73.
116 Principles of block diagram-oriented simulation tools
2. Barker, H.A., Huynh-Quoc, T. and Townsend, 6. Mitchell and Gauthier Associates (1992)
P. (1989) A graphical pre-processor for contin- Announcing ACSLlGraphic Modeller, in State
uous simulators, in ESC89: Proceedings of the Events, Mitchell and Gauthier Associates,
3rd European Simulation Congress (eds Concord, MA.
D. Murray-Smith, }. Stephenson and R.N. 7. The MathWorks (1992) SIMULINK User's
Zobel), SCS Europe, University of Ghent, Guide for Microsoft Windows, The MathWorks,
pp. 349-55. Natick, MA.
3. Bosch, P.P.}. van den (1987) Simulation 8. Grace, A.C.W. (1993) SIMULINK, an integrated
Program PSI (manual), Delft University of environment for simulation and control, in
Technology, The Netherlands. MATLAB Toolboxes and Applications for Control
4. Bosch, P.P.}. van den (1993) Simu- (eds A.}. Chipperfield and P.}. Fleming), Peter
lation: a general design tool, in Biomedical Peregrinus, Stevenage, pp. 47-60.
Modeling and Simulation on a PC (eds 9. Billmann, L., Mirab, H. and Winkler, U. (1992)
R.P. van Wijk van Brievingh and CACSD - CASE tools. Measurement and
D.P.F. Moller), Springer, New York, Control, 25, 137-43.
pp.74-83. 10. Boeing (1992) EASY5x Engineering Analysis
5. Bosch, P.P.}. van den (1993) Interactive simu- Software, Technical Overview, Boeing
lation program BIOPSI, in Biomedical Modeling Computer Services, Seattle, WA.
on a PC (eds R.P. van Wijk van Brievingh 11. XANALOG (1990) XANALOG Simulation and
and D.P.F. Moller), Springer, New York, Control Design Software User's Guide, revision
pp.471-502. 8, XANALOG, Woburn, MA.
SIMPLE EXAMPLES USING COMMON
SIMULATION TOOLS
8

8.1 INTRODUCTION differential equation. Although a linear


problem, and therefore suitable in principle
This chapter provides examples of a number
for analytical methods of solution, this is a
of different types of simulation problem. The
relatively complicated case to handle analyti-
models upon which the simulations are based
cally and represents a situation where simula-
are relatively simple, and have been chosen to
tion can provide valuable insight. This
illustrate features of some typical simulation
problem is of particular interest because it
tools which are currently available and the
involves two tuned circuits coupled through
application of the principles introduced in
the mutual inductance M. This produces
Chapters 3, 4, 5 and 6. Particular techniques
~uit co~plex dynamic behavior, especially
have been selected, but this choice is not
m SItuatIons where the two circuits have
intended to suggest that other tools could not
parameter values which produce lightly
have provided an equally appropriate solu-
tion. Strengths and weaknesses of some damped transients. Similar properties can be
methods of approach are discussed. In each found in mechanical systems involving
case suggestions of further investigations coupled motion of masses, springs and
which could be made with these simple damping elements.
models are outlined. A pair of differential equations describing
the circuit can be derived by applying
Kirchhoff's voltage law to the left-hand loop
8.2 A COUPLED-TUNED ELECTRICAL and to the right-hand loop in turn. For the
CIRCUIT SIMULATION path involving the source voltage e(t) and the
current ij(t) we have the following equation:
Figure 8.1 shows a circuit diagram of a
coupled-tuned electrical circuit. This is an
example of a lumped parameter model e(t) = l.j Rj + Lj di
j

dt dt C j
f
- + Mdi2- +1- ij dt (8.1)
described by a linear fourth-order ordinary
Similarly, for the closed path involving the
R 11 current i2(t), application of Kirchhoff's voltage
M
law gives an equation of the following form:

O=l2. R2 + L2-+M-+-
di2 di 1 l2 dt
j J. (8.2)
-1O>-~ 1 - - -.....
dt dt C2

These equations can be rearranged as follows:


C1

Fig. 8.1 Circuit diagram of the coupled-tuned elec- (8.3)


trical circuit.
118 Simple examples using common simulation tools

di2
dt =-
1.
T2 12 -
2
W 2
f'
12
d di1
t - K2 dt (8.4)

where

(8.6)

(8.7)

Selecting state variables as follows:

w~ 1
- X3 - X4
1- K j K 2 T2 (1- K j K 2 )
K 2e(t)
+-----==---.:....:...- (8.8)
Lj (1-K j K 2 )

gives the four state equations The four state equations above may be
incorporated into any equation-oriented sim-
(8.5) ulation language program or may be simu-

Fig. 8.2 Block diagram for the coupled-tuned electrical circuit.


A coupled-tuned electrical circuit simulation 119
C
C Initial segment calculations based on coefficient values
C read from data file.
C1=OM1SQ/(1.0-AK1*AK2)
C2=1.0/(T1*(1.0-AK1*AK2))
C3=OM2SQ/(1.0-AK1*AK2)
C4=1.0/(T2*(1.0-AK1*AK2))
C5=T1*C2/AL1
C
C *************Start of Dynamic Segment*********
DYNAMIC
C
C *************Start of Derivative section*******
DERIVATIVE
DERIV1=X2
DERIV2=-Cl*X1-C2*X2+AKl*C3*X3+AK1*C4*X4+E*C5
DERIV3=X4
DERIV4=AK2*(C1*X1+C2*X2)-C3*X3-C4*X4+E*AK2*C5
X1=INTEG(DERIVl,XlO)
X2=INTEG(DERIV2,X20)
X3=INTEG(DERIV3,X30)
X4=INTEG(DERIV4,X40)
DERIVATIVE END
C
C Values of t, x2 and x4 for current communication interval
C output to the results file
TYPE T,X2,X4
C
C Test for end of simulation run
IF(T-TMAX)10,10,12
10 DYNAMIC END
C
C ******************Terminal Segment****************
12 STOP
END

Fig. 8.3 Listing of part of a SLIM program (COUPLE. SLI) for simulation of the coupled-tuned electrical
circuit.

lated easily by writing a program using a three examples of appropriate parameter sets
general-purpose high-level programming lan- with the corresponding data file names. Any
guage. Figure 8.2 is a block diagram which other situation may be investigated easily by
corresponds to this set of state equations. creating a similar data file containing the nec-
Figure 8.3 shows the listing of the DYNAMIC essary parameter values. Results from this
segment of a SLIM program (COUPLE. SLI) SLIM program are shown in Fig. 8.4 as plots
for this system model for a case where the of the currents i,(t) and i2 (t) versus time for
input, e(t), is a step change of voltage, and the two different sets of conditions. These results
response of interest involves the primary and show very clearly the coupled nature of the
secondary currents. The complete program is dynamics and the periodic exchange of
included on diskette. The initial segment of energy between the primary and secondary
this program involves a set of parameters circuits and the dependence of the behavior
which are read in from a file. Table 8.1 shows of the system on the time constants T, and T2 •

Table 8.1 Parameter values and SLIM data file names for coupled-tuned circuit
example

K, K2 liT, IlT2 w,2 w22 Data file


0.27 0.10 1.00 1.00 0.60 0.62 [Link]
0.00 0.00 0.05 0.05 0.60 0.62 [Link]
0.27 0.10 0.05 0.05 0.60 0.62 [Link]
120 Simple examples using common simulation tools

6 ~

7\\,
'
o '-7~
o 20 40 60 80 t
a (s)

10

5
.-
\
0 )

-5

-10
0 20 40 60 80 t
b (s)

Fig. 8.4 Simulated responses of the coupled-tuned electrical circuit for a step input of applied voltage.
The responses shown are the currents (measured in amperes) in the primary circuit (continuous line)
and secondary circuit (dashed line) for parameter values corresponding to the data file COUP1. IN (a) and
COUP3. IN (b). Note the much lower level of damping in the responses of (b) compared with those
shown in (a). This difference is because of the choice of parameters T, and T2 in the two cases considered,
as indicated by the figures in Table 8.1.

Block diagram-oriented simulation pro- Ideas for further things to tryout on your
grams based on XANALOG and SIMULINK own using this model include investigations
may be derived from Fig. 8.2 and can have an of other parameter combinations involving
identical structure. Results obtained using variation of Wj and W 2 and K and K2 • Those
j

these tools are exactly the same as those with an appropriate understanding of electri-
shown above. The powerful runtime cal circuits may also want to use the simula-
command facilities of XANALOG and tion model to look at the effect of changing
SIMULINK provide a more user-friendly the sign of the mutual inductance coupling
interface for interactive experimentation than the left- and right-hand circuits. This would
is possible with SLIM. Similar runtime involve changing the structure of the equa-
command facilities and high levels of interac- tions which form the simulation model and
tion could, of course, be achieved with other would thus require modification of the source
equation-based languages such as ACSL and program. Since this is a linear model, compar-
with other block diagram-based tools. isons may be made of the simulation methods
A control system simulation 121
with analytic approaches based, for example, useful illustration of continuous simulation
on Laplace transforms. techniques being used to approach an import-
ant class of practical engineering problem.
A number of controller transfer functions
8.3 A CONTROL SYSTEM SIMULATION:
can be considered for this type of application.
SPEED CONTROL OF A WATER TURBINE
Detailed consideration of possible forms of
Control systems investigations form one of controller are not of primary interest in the
the most common application areas for con- present context, but any readers interested in
tinuous system simulation tools. This this aspect, or in the underlying model, may
example is concerned with a simulation of a find further details elsewhere (e.g. refs 1 and
speed-control system for a water turbine used 2). For the present purposes, the controller
for the generation of electricity. Figure 8.5 is a considered is of the 'temporary droop' type
block diagram of a highly simplified descrip- implemented in continuous form. This type
tion of a system of this kind. The turbine, of controller has a transfer function of the
which is of the impulse type, is represented form:
by a linear transfer function, which also incor-
porates dynamics of the pipeline system.
Control of the turbine is accomplished
through feedback of a signal proportional to
turbine shaft speed and comparison with
the desired (reference) speed signal. Any dif- In this controller transfer function only the
ference between the desired and actual speed parameters (J" and JL may be regarded as
provides an error signal, which is processed adjustable quantities. The other parameters Tx
by the controller block to provide the signal and Ty) are fixed quantities and are not avail-
applied to the turbine actuator input, to able for controller tuning.
change the water flow in such a way that the Appropriate parameter values for the plant
error is continuously minimized. The con- and controller are as follows:
troller may be implemented either in analog
(continuous) or digital form. The model is Ta = 7.0 s (inertial time constant)
linear throughout, apart from backlash in the Tw = 1.1 s (water time constant)
mechanical linkages associated with the Ts = 0.2 s (actuator servo time constant)
turbine inlet actuator. The purpose is to allow
the performance of the model of the closed- All model variables, such as turbine speed,
loop system to be investigated. This is a are expressed as normalized (unit) quantities.

TL

+
N ref + V 1 v 1 N.
CIs) N.L.E.
1 + sT. sT.

ACTUA TOR SERVO AID LOAD

Fig. 8.5 Block diagram of closed-loop system for automatic control of the speed of a water turbine.
122 Simple examples using common simulation tools
Figure 8.6 shows the DYNAMIC segment of a program listing. The simulation experiment,
SLIM program (TURB. SLI) for the simulation in this case, involves investigation of the
model and the full source code may be found response of the control system to a step change
on the diskette. Parameter values for the of the reference speed. It can be seen from Fig.
nominal set of conditions are provided in the 8.7 that the response is stable but oscillatory in

C
C ******************Start of Dynamic Segment*************
DYNAMIC
C
C ******************Start of Derivative Segment************
DERIVATIVE
DT1= (V-T1) *( 2.0 ITW)
T1=INTEG(DT1,T10)
TO=T1-TW*DT1
TA=TO-TL
DNS=TA/TIA
ANS=INTEG(DNS,ANSO)
E1=REF-ANS
DDY1=(E1-SIG*Y1-( (SIG+AMU)*TX+TY) *DY1) I (TX*TY)
DY1 =INTEG (DDY1,DDY10)
Y1=INTEG(DY1,Y10)
Y=Y1+TX*DY1
DV= (Y-V) ITS
V=INTEG(DV,VO)
DERIVATIVE END
C
C Values of t, ref, tl and ans for current communication
C interval output to results fil
TYPE T,REF,TL,ANS
C
C Test for end of simulation run
IF (T-TMAX) 10,10,12
10 DYNAMIC END
C
C *************************Terminal Segment*******************
12 STOP
END

Fig. 8.6 Part of a SLIM program (TURB. SLI) for the simulation of the water-turbine speed-control system
with a 'temporary droop' type of controller transfer function. No backlash is included in the simulation
model in this case.

<II
Z 0.2

0.1

o 20 40 60 t
(5)

Fig. 8.7 A typical simulated response of the water-turbine speed-control system to a step change in the ref-
erence speed. The choice of controller parameters used in this case gives a transient response which is oscil-
latory in nature. The adjustable parameters of the controller (a and fL) could be altered, through further
simulation experiments, to try to establish conditions giving a more satisfactory transient performance.
A control system simulation 123
.... One interesting extension to this simulation
=
IL.
.... program involves the inclusion of mechanical
=
= backlash between the servomotor and the
turbine inlet. This is an important feature of
real mechanical systems of this kind and is
known to have a destabilizing effect on the
INPUT overall control system. Backlash is a double-
valued form of nonlinearity which has a
steady-state input-output characteristic of the
form shown in Fig. 8.8. It generally arises
because of 'slack' in mechanical linkages and
gears. With backlash present, movement of the
input in one direction produces a proportional
movement of the output, but any reversal of
Fig. 8.8 Typical input-output characteristics of a the direction of the input will cause the output
backlash element. to stop before following the input again.
The representation of backlash and other
nature for the controller parameter values similar double-valued nonlinearities which
used. A program TURBl . SLI, which allows involve a form of 'memory', such as hyster-
input from a data file, is also included on the esis, can be difficult. One approach is to use
diskette supplied with this book. This version principles first established for the modeling of
of the simulation program, together with the backlash elements using analog computers
appropriate data files in the same format as the [3]. This involves the use of an integrator with
test file TURB1. IN, provides a convenient feedback to provide the memory element.
means of experimenting with controller para- Figure 8.9 shows a block diagram for a repre-
meter values. sentation of backlash by this type of method.

--,
: OR

'--D
.-..
,
I
: ,
,
_J
,,
,

:..... -_ .. -
,
I

Fig. 8.9 Block diagram illustrating one possible technique for representation of backlash within a simula-
tion model. Variables shown on this diagram are consistent with the variables of Fig. 8.5 and with vari-
able names used in the SLIM program listing of Fig. 8.10.
124 Simple examples using common simulation tools
Essentially, the system works by comparing the integrator output to remain fixed in value
the integrator output, which is the output for a period of time, and this corresponds to
variable for the backlash element, with the the flat top and bottom sections on the
input. The integrator input is controlled diagram showing the input-output character-
through comparator elements and logic istics for the backlash. Although presented
blocks, and when the input reverses direction here in block diagram form, the implementa-
(at the extremes of travel) the integrator input tion of a backlash model of this kind is quite
becomes zero. The integrator input remains simple using the equation-oriented methods.
zero until the input variable has changed by Figure 8.10 shows the DYNAMIC segment of a
an amount equal to the width of the backlash SLIM program TURB2. SLI, which is a
element. It is then switched back to the version of the turbine speed-control system
output of the summing element. This causes model with backlash incorporated. This

C
C ******************start of Dynamic Segment**************
DYNAMIC
C
C ******************Start of Derivative Section***********
DERIVATIVE
C
C Section for representation of backlash element
IF(AB-0.00l)40,45,45
45 DB=V-YB
IF(DB+AB)60,50,50
60 FB=DB
GOTO 100
50 IF(DB-AB)80,70,70
70 FB=DB
GOTO 100
80 FB=O.O
100 YB=INTEG(10.0*FB,YBO)
GOTO 110
40 YB=V
C
C End of section for backlash
110 DT1=(YB-T1)*(2.0/TW)
Tl=INTEG(DTl,TlO)
TO=TI-TW*DTI
TA=TO-TL
DNS=TA/TIA
ANS=INTEG(DNS,ANSO)
El=REF-ANS
DDYl=(El-SIG*Yl-«SIG+AMU)*TX+TY)*DYl)/(TX*TY)
DY1=INTEG(DDYl,DDYI0)
Y1=INTEG(DYl,YlO)
Y=Yl+TX*DYl
DV=(Y-V)/TS
V=INTEG(DV,VO)
DERIVATIVE END
C
C ********************End of Derivative section**************
C
C Values of t, ref, tl, ans and yb for current communication
C interval output to results file
TYPE T,REF,TL,ANS,YB
C
C Test for end of simulation run
IF(T-TMAX)10,10,12
10 DYNAMIC END
C
C *************************Terminal Segment******************
12 STOP
END

Fig. 8.10 Part of a SLIM program (TURB2 . SLI) for the water-turbine speed-control system with mechani-
cal backlash included between the servomotor and the turbine inlet valve.
Simulation of a neural encoder model 125
program and the corresponding data file tice. For those with an appropriate level of
TURB2 . IN are available on the diskette. understanding of control systems analysis
The oscillation observed on the response techniques, the simulation result for the criti-
shown in Fig. 8.7 is influenced by the backlash cal value of the backlash parameter may be
parameter ab as well as by the parameters of compared with predictions from theory,
the controller. A well-damped step response based upon describing function analysis. It is
in the absence of backlash (a b = 0.0) can interesting to consider the reasons for any dif-
become a maintained oscillation if the back- ferences between the simulation result and
lash is increased sufficiently (Fig. 8.11). the value predicted by theory. It should be
Figure 8.12 is an ACSL program listing for remembered that the describing function
this example. Note that a special statement approach involves some important simplify-
BCKLSH is available in ACSL to represent ing assumptions and approximations. The
backlash effects and use has been made of significance of some of these can be investi-
this facility. Figure 8.13 shows results gated easily using the simulation.
obtained from this ACSL program. In modern
block-oriented tools such as XANALOG and
8.4 SIMULATION OF A NEURAL
SIMULINK special facilities are also available
ENCODER MODEL
for the simulation of nonlinear elements such
as backlash. Figure 8.14 shows an XANALOG Sensory receptors of the peripheral nervous
block diagram for this problem. system have an important role in the control
Further investigations which could be systems which are used in the maintenance of
carried out using this model and the SLIM posture and in the control of movement. One
simulation programs include determination very important receptor in the neuromuscu-
of the minimum value of the backlash para- lar control system is the muscle spindle.
meter ab which gives rise to a maintained Muscle spindles are embedded in skeletal
oscillation in terms of turbine speed. This muscles and provide neural signals that are
'limit cycling' type of behavior is clearly an sensitive to muscle stretch and to the rate of
undesirable situation in a speed-control sys- change of stretch. The precise role of the
tem and one that should be avoided in prac- muscle spindle as an active element in the

0.2 ",
t \
\

..
.1 \
\ ,
.<"
"
, I
l \

0 .. I
-'
-0.2

o 20 40 60 80 t
(s)

Fig. 8.11 Simulated step response of the water-turbine speed-control system with backlash which is
almost sufficient to produce a continuous oscillation. The dashed line shows the response in terms of the
output speed (N,), while the continuous line is the output Yb from the backlash element. This is typical of
the response of a nonlinear closed-loop system when operating in the vicinity of a stable limit cycle.
126 Simple examples using common simulation tools
PROGRAM [Link]
"Simulation of governed hydro-turbine system with"
"a temporary-droop governor and with backlash between"
"servo-motor and turbine inlet actuator"
INITIAL
"Data for plant and governor transfer functions"
CONSTANT tw=l.l, ts=O.2, tia=7.0
CONSTANT ab=O.06 $ "backlash parameter"
CONSTANT tx=16.0, ty=O.3, sig=O.03, mu=O.25
"Data for reference input and disturbance input"
CONSTANT ref=O.l, tl=O.O
"Data for experiment duration"
CONSTANT tend=99.9
ALGORITHM IALG=4 $ "Runge-Kutta second order"
CINTERVAL CINT=l.O
"Initial conditions"
tl=O.O
v~o.
yl=O.O
dyl=O.O
ybO=O.O
END $ "of INITIAL"
DYNAMIC
DERIVATIVE
"Turbine"
dtl={yb-tl)*{2.0/tw)
tl=INTEG{dtl,O.O)
to=tl-tw*dtl
"Load"
ta=tO+tl
dns=ta/tia
ns=INTEG{dns,O.O)
"Governor"
el=ref-ns
ddyl={el-sig*yl-{{sig+mu)*tx+ty)*dyl)/{tx*ty)
dyl=INTEG{ddyl,O.O)
yl=INTEG{dyl,O.O)
y=yl+tx*dyl
"Servo motor ll
dv={y-v)/ts
v=INTEG{dv,O.O)
yb=BCKLSH{ybO,ab,v)
END $ "of DERIVATIVE"
TERMT ([Link])
END $ "of DYNAMIC"
TERMINAL
END $ "of TERMINAL"
END $ "of PROGRAM"

Fig. 8.12 ACSL program listing for the water-turbine speed-control example.

overall control system is not yet fully under- modeled in an approximate way by the
stood but much experimental work has been charging and periodic resetting of a leaky
carried out on the properties of the muscle integrator when its output reaches a thresh-
spindle and many modeling investigations old level. This is an interesting example of a
have been undertaken (e.g. refs 4 and 5). The discontinuous problem and provides a simu-
'encoder', which is the element responsible lation model which has some very interesting
for the conversion of stretch within the nonlinear properties when subjected to peri-
central section of the muscle spindle to a odic inputs representing mechanical stimuli
neural signal in pulse frequency modulated applied to the muscle. Further information
form, provides an interesting simulation about the use of leaky integrator and thresh-
example involving a highly nonlinear old models for neural encoders may be found
problem. The generation of action potentials in the biomedical engineering literature (e.g.
in the nerve leading from the receptor arises refs 6-9). It is also of interest to note that these
through membrane properties which can be 'integrate and fire' models are now creating
Simulation of a neural encoder model 127

i
c
TURBTD2 AB=O . 0 ~ TURBTD2 AB=O.02

[;;
· d;~-+r

(\
[I~
· 1\
~d:+-r4

J' VV'
(f)

~ ~
Z
(f)

~
· d:~-+4
ru

-
c

?[Link] 0.25 [Link] 0.75 1.00


-
o

C?[Link] 0.25 0.50


T *102 TIME
0.75 1.00
a T *102 TIME b

Fig. 8.13 Responses obtained using the ACSL simulation (a) with backlash (a b =0.02) and (b) without
(a b = 0.0). Note, once again, the destabilizing effect of the backlash.

LTD

K -------""'
[Link]+oo

Nr b
[Link]. SERVO
1
MOTOR TURBINE I-~a.
C:(S) :s'I'a.

GOV_TEMP.MDL
~- SERVO. MOL
5.00e-02

~-
[Link] TNER~rA _ MDLI
.

Fig. 8.14 An XANALOG block diagram for the water-turbine speed-control system simulation. In this
case, the diagram consists entirely of blocks representing submodels. Each of these submodels involves a
further more detailed block diagram based upon combinations of the standard XANALOG block
diagram elements.

some interest in the context of artificial neural sive description of the muscle spindle recep-
networks (e.g. ref. 9). tor or of any other physiological sense organ.
The model which forms the basis of this However, it does embody some elements of
example is extremely simple in form and is widely used physiological models of recep-
not intended to be in any way a comprehen- tors and has properties which are similar in
128 Simple examples using common simulation tools
many respects to those of more detailed phys- of an encoder of this form, including non-
iologically based descriptions. The basic linear effects associated with the response to
equation forming the model is the first-order periodic inputs.
equation Figure 8.15 shows a listing of the DYNAMIC
segment of a SLIM program (ENCODE. SLI)
. vp K (8.10) for this example. This program is included
v =--+-e
P T T on the diskette and provides a further illus-
tration of ways in which the facilities of the
Here the variable v/t) represents the mem- DERIVATIVE section and the DYNAMIC
brane potential, e(t) is the input representing segment can be used to provide quite
mechanical extension of the receptor region complex simulation functions. Figure 8.16
and K and T are constants. When the variable shows some typical results for a constant
vp(t) reaches a threshold level VT the integra- input e(t) and illustrates the 'integrate and
tor is reset to some initial state. When this fire' action of the model very clearly. The
occurs an output pulse is generated, repre- detection of the threshold level and the reset-
senting an action potential in the nerve ting of the integrator is achieved by means of
leading from the receptor to the spinal cord. an IF statement within the DERIVATIVE
The purpose of the model is to allow investi- section and a further IF statement between
gation of some of the fundamental properties the end of the DERIVATIVE section and the

VG=AR*E
C
C ***************Start of Dynamic Segment**************
DYNAMIC
C
C *************Start of Derivative Section*************
DERIVATIVE
VP=INTEG((VG-VP)/TA,VR)
C
C Test whether VP has reached threshold level VT
C
IF(VP-VT)10,20,20
C
C Generate output spike if threshold has been reached.
C If not continue integration process.
C a
20 SP=1.0
10 DERIVATIVE END
C
C *************End of Derivative Section*****************
C
C Values of t, vg, vp and sp for current communication interval
C output to results file
C
TYPE T,VG,VP,SP
C
C Test for end of simulation run
C
IF(T-TMAX)25,50,50
C
C Test for spike. If a spike has been generated the integrator is
C effectively reset by by-passing the DYNAMIC END statement.
C In this case control is passed to line having label 5,
C if end-time not yet reached.
C
25 IF(SP-0.5)30,5,5
30 DYNAMIC END
C
C **************Terminal segment**************************
50 STOP
END

Fig. 8.15 A listing of part of the SLIM program (ENCODE. SLI) for the neural encoder model.
A constrained pendulum simulation 129
......
)0. )

-Ll

/
B t
I

!
~ i!
4~ i

i
~
0'
0 2 4 6 B x1cF t:
a (a)

)a.{ .::,/

b
Fig. 8.16 Membrane potential time histories for two levels of input in the neural encoder simulation
model. These show the 'integrate and fire' characteristics of the system very clearly. Each time the mem-
brane potential (v p) reaches the threshold (10 mV) the integrator is reset (to zero in this case) and an
action potential 'spike' is generated. For the results shown in (b) the input applied was four times the
level used in case of (a). The frequency of the resulting spike train thus depends directly upon the level of
the input applied.

end of the DYNAMIC section. If the integrator facilities for the handling of discontinuities,
output has reached the threshold level an and for the control of integrator operation,
output spike is generated and the integrator which are not available in SLIM. Use of the
is reset by a path which involves bypassing facilities of the DYNAMI C segment to repro-
the DYNAMIC END statement and re-entering duce the operation of the ENCODE. SLI
the DYNAMIC segment. The model can program in other equation-oriented languages
produce interesting and rather complex in exactly the same way may not always be
phase-locking effects when subjected to peri- appropriate. Care should be taken to ensure
odic inputs. Both these situations may be that all of the available features of the lan-
accommodated in the ENCODE. SLI program guage are being used to the best advantage.
with minor editing to allow the sinusoidal
excitation to be used instead of the constant
8.S A CONSTRAINED PENDULUM
input. Figure 8.17 shows an XANALOG block
SIMULATION
diagram for the encoder simulation. Results
in this case are essentially identical to the This example has been proposed by
SLIM results. Breitenecker [11] as an interesting simu-
It should be noted that many equation- lation which can be used for the evaluation
oriented simulation languages have special and comparison of simulation tools. It is
130 Simple examples using common simulation tools

SPIKE

0.0019-+-00

VG
COMPARE

VT

1.00e+0 1

Fig. 8.17 An XANALOG block diagram for the neural encoder model. Note that this diagram includes a
'compare' block which has been implemented as a special-purpose submodel. This XANALOG diagram
is itself a submodel having input variable VG and output variable SPIKE. The block elements associated
with VG and SPIKE are special 'import' and 'export' blocks for use with submodels. Note also the use of
the 'peep' icon, which resembles an eye looking through a circular hole: this provides a means of display-
ing variables within an XANALOG submodel at runtime.

one of a number of problems which have


provided the basis for a continuing series
of published comparisons of simulation soft-
ware [11-13], This particular problem is of
special interest because it involves a
discontinuity. pin
The system under investigation is shown in
Fig. 8.18. A pendulum of length I has an angle
({I(t) measured in radians counterclockwise
from the vertical position. The mass of the m
pendulum bob is m, and the string which
forms the arm of the pendulum is assumed to
have negligible mass. The pendulum may hit a
pin positioned at angle ({Ip and at a distance Ip
from the point of suspension. When this
happens the pendulum continues to swing but
now has a length Is = I-Ip, and a new angular
velocity defined with respect to the new point
about which rotation is taking place.
The equation of motion of the pendulum
for angles ({I which are smaller than ({Ip is as
follows: m

d 2 ({1 g. d d({l
- - = - - SIn ({I - - - (8.11) Fig. 8.18 Diagrams illustrating the constrained
de I m dt pendulum' simulation example.
Simulation of a simple digital control system 131
where d is a damping factor. When the pen- Figure 8.20 shows results from the simula-
dulum reaches an angle 'P = 'Pp its point of tion for both sets of parameters and initial
rotation is at the pin. The length of the pen- conditions given above.
dulum is changed to Is and the angular veloc-
ity d'Pl dt is changed at 'P = 'Pp by a factor Ills'
The form of the equation of motion remains
8.6 SIMULATION OF A SIMPLE DIGITAL
as shown in equation (8.11). When the pen-
CONTROL SYSTEM
dulum swings back so that it again has
length 1the angular velocity is again changed Figure 8.21 is a block diagram of a simple
at 'P = 'Pp' this time by a factor ljI. closed-loop digital control system of the type
Parameters suggested by Breitenecker [11] introduced in section 3.10. The difference
to provide a common basis for software com- between the reference signal and the plant
parisons are as follows: output forms an error, which is sampled by
the analog to digital converter. The digital
m = 1.02 kg 1= 1 m lp= 0.7m processor carries out some form of numerical
g = 9.81 m S-2 operation on the error samples and provides
an actuating signal to the plant input through
Simulation of the motion of the pendulum the digital to analog converter. Figure 8.22
may be considered for a variety of different shows part of the corresponding SLIM
initial conditions, different damping factors program listing for the simplest possible
and for different pin angles 'Pp' Assuming situation in which the control computer
zero initial angular velocity, two sets of con- samples the error signal and outputs the
ditions suggested by Breitenecker are as sampled error values periodically as input to
follows: the plant. The complete program file, named
DIGCON. SLI, and the necessary input data
1. 'Po = 1T16, d = 0.2, 'Pp = -1T112
file DIGCON. IN, can be found on the diskette.
2. 'Po = -1T16, d =0.1, 'Pp = -1T112
Examination of the DIGCON . SLI shows that,
In both cases the response may be considered because SLIM does not have special facilities
over a time period of 10 s. for mixed continuous and discrete system
Figure 8.19 shows part of a program listing simulation, the sampling period is defined as
of a SLIM program (CONS PEND . SLI) on the a multiple of the communication interval
diskette for simulation of this problem. Since parameter, and the facilities of the DYNAMIC
this example involves a discontinuity the segment and DERIVATIVE section are used to
SLIM program makes use of the facilities emulate the discrete action of the controller.
of the DYNAMIC segment to reset the integra- The sampled variable is held constant in a
tion operations at appropriate points. zero-order hold type of action by a loop
The program is therefore similar to the within the DYNAMIC segment. Any discrete
ENCODE. SLI program in some respects. calculations representing the action of a
When the pendulum has reached the critical control algorithm within the control com-
angle and is about to lengthen, or shorten, a puter must also be performed within the
jump occurs out of the DYNAMIC segment. If DYNAMIC segment. Values of variables of
the critical angle has not been reached, opera- interest in the simulation may be written to
tion continues in the normal way within the the output file in the usual way, at times set
DYNAMIC segment and the DERIVATIVE by the communication interval.
section. Comments included within the Figure 8.23 shows results obtained for three
program listing should help to clarify the different sampling periods. It can be seen that
details of this operation. the system shows an increasing tendency to
132 Simple examples using common simulation tools
C Setting flags to indicate phase of motion
IF(XIO-PHIP)4,4,2
2 MARK=-l
MARKl=-l
AL=ALI
GOTO 5
4 MARK=2
MARKl=2
AL=ALI
7 T=Tl
DYNAMIC
DERIVATIVE
DERIVl=X2
DERIV2=-(G/AL)*SIN(Xl)-(D/AM)*X2
Xl=INTEG(DERIV1,XIO)
X2=INTEG(DERIV2,X20)
C Check whether angle of string has reached critical angle PHIP
C If it has not simulation continues without any change of
C parameter AL and without any change of X2 (angular velocity).
C If critical angle has been reached the parameter AL is changed
C (pendulum length) and also variable X2 (angular velocity). The
C changes to be made depend upon the values of PHI immediately
C before the critical angle is reached.
IF(XI-PHIP)20,20,30
C This case applies where the length is ALS (short).
20 MARK=2
GOTO 32
C This case applies where the length is ALI (long).
30 MARK=-l
32 DERIVATIVE END
C output values of variables Xl and X2 to file (and screen)
TYPE T,Xl,X2
IF(T-TMAX)33,33,l2
C Test whether MARK and MARKl flags show that the pendulum
C has reached the critical angle PHIP from either direction
33 IF(MARK-MARKl) 40, 37, 35
C This case applies if pendulum shortens at critical angle.
35 Tl=T
X20=X2*ALI/ALS
MARKl=2
MARK=2
X10=PHIP
AL=ALS
GOTO 45
C This case applies if pendulum lengthens at critical angle.
40 T1=T
X20=X2*ALS/ALI
MARK1=-1
MARK=-1
X10=PHIP
AL=ALI
GO TO 45
37 DYNAMIC END
45 GOTO 7
12 STOP
END

Fig. 8.19 Listing of part of a SLIM program (CONSPEND. SLI) for simulation of the constrained pendulum.

oscillate as the sampling period is increased, The DIGCON. SLI program can be modi-
and eventually it becomes unstable. Sampled fied easily to allow for more complex con-
data theory (e.g. ref. 14) predicts that for this troller action. For example, if one wanted to
system instability occurs when the sampling simulate the system with a controller which
period is greater than 0.549 s. This is consis- implemented a difference equation of the
tent with the results presented in Fig. 8.23, form
and detailed investigations using the simula-
O(kT) = O[(k - l)T] + I(kT) - O.5I[(k - l)T]
tion program can confirm the theoretical
result more precisely. (8.12)
o 2 4 8 t
a (5)

2
1

o
-1
-2
-3

o 2 4 6 8 t
b (5)

o 2 4 6 8 t
c (5)

Fig. 8.20 Responses obtained from CONS PEND. SLI for two sets of initial conditions and different
damping factors. In (a) and (b) the responses shown are the pendulum angular displacement and angular
velocity respectively, for the given set of conditions involving a damping factor of 0.2. Note the discon-
tinuity associated with the string reaching the critical angle and the fact that this is eliminated when the
amplitude of the oscillation becomes sufficiently small. Part (c) is for the second set of conditions, and in
this case the continuous line shows angular displacement of the pendulum while the dashed line is the
angular velocity.
134 Simple examples using common simulation tools
REF.
INPUT
R(s) + I(s) • DIGITAL O(si 4 - OUTP UT
ADC ~ f-+ OAC --
-
PROCESSOR S + 2 YIs)

Fig. 8.21 Block diagram of a simple closed-loop digital control system.

c
c *******************Start of Dynamic Segment***************
DYNAMIC
1=1+1
C
C *****Test time count for sample instant. Sampling instants
C *****occur at times given by t=MULT*SAM.
C
IF(I)15,25,15
15 IF(I-MULT)20,25,25
C
C *****Take sample of error variable, generate DAC output
C *****and reset sampling timer count to zero.
C
25 AIN=R-Y
OUT=AIN
1=0
C
C *****Write results for current communication interval to
C *****output file (and to screen if required).
C
20 TYPE T,R,AIN,Y
C
C *****************Start of Derivative section**************
DERIVATIVE
DERIV=-(Y-AK*OUT)/TAW
Y=INTEG(DERIV,O.O)
DERIVATIVE END
C
C*******************End of Derivative section*****************
C
C Test for end of simUlation run
C
IF(T-TMAX)10,10,12
10 DYNAMIC END
C
C *********************Terminal Segment**********************
C
12 STOP
END

Fig. 8.22 Listing of part of a SLIM program (DIGCON. SLI) for simulation of the digital control system of
Fig. 8.21. In this case the control computer samples the error signal and outputs the sampled error as the
control input to the plant.

the changes to the simulation program would included on the diskette as the file
all be made in the initial part of the DYNAMIC DIGCONl . [Link] how the discrete input
segment. Figure 8.24 shows the relevant part and output variables are stored for one
of the listing and the complete program is sample period and updated. The transfer
Simulation of a simple digital control system 135
I
I
I
0.8 ~
I
I
L
I
I

I
0.4 , I
\.
----------------------------------------

OL-~
o 2 4 6
______ ~
t
a (s)

~
0.8

0.4
!
-.,I
I -~

2 4 6 t
b (s)

1•

.5

o
I
5 t.. _ _ ...t I
-. t -____________~-L
o 2 4 6 t
c (s)

Fig. 8.23 Responses of the digital control system simulation for three different values of the controller
sampling period. (a) The system output (continuous line) and the error value after sampling by the
analog to digital converter (dashed line) for a sampling period of 0.1 s. (b and c) Equivalent results for
sampling periods of 0.28 sand 0.56 s. Note the instability displayed in the case of (c).
136 Simple examples using common simulation tools
C
C *******************Start of Dynamic Segment***************
DYNAMIC
I=I+I
C
C *****Test time count for sample instant. Sampling instants
C *****occur at times given by t=MULT*SAM.
C
IF(I)15,25,15
15 IF(I-MULT)20,25,25
C
C *****Take sample of error variable and generate DAC output
C *****from present value of controller input AIN and the
C *****values of controller input and output at sampling instant
C *****immediately before the current one (AINI and OUTl).
C
25 AIN=R-Y
OUT=OUTl+AIN-0.5*AINI
c
C *****Re-define previous values AINI and OUTI for use at the
C *****next sampling instant (i.e. the next time around the loop)
C
OUTI=OUT
AINl=AIN
C
C *****Reset the sampling time count variable
C
I=O
C
C *****Write results for current communication interval to
C *****output file (and to screen if required).
C
20 TYPE T,R,AIN,Y
C
C *****************Start of Derivative Section**************
DERIVATIVE
DERIV=-(Y-AK*OUT)/TAW
Y=INTEG(DERIV,O.O)
DERIVATIVE END
C
C*******************End of Derivative Section*****************
C
C Test for end of simulation run
C
IF(T-TMAX)10,10,12
10 DYNAMIC END
C
C *********************Terminal Segment**********************
C
12 STOP
END

Fig. 8.24 Part of the listing of the SLIM program DIGCON1. SLI for simulation of the digital control
system involving the controller transfer function of equation (8.13). With a sample period of 0.347 s this
gives dead beat control characteristics for a step change of reference.

function of the controller of equation (8.12), [14]. In such a situation, the plant output
expressed in terms of z-transforms, is as should exhibit zero steady-state error and
follows: should rise to its final value, in response to a
step change of system reference input, in one
z - 0.5
O(z)
= 1-1-0.5z- sampling period. Figure 8.25 shows results
1
=--- (8.13)
1(z) Z-1 z -1 from the simulation program which are con-
sistent with theory for this special case.
In the special case when the sample period is Some other equation-oriented simulation
0.347 s, the controller should, from sampled languages, such as ACSL, include special facil-
data theory, act as a 'dead beat' compensator ities which can be very useful for the simula-
Simulation of a simple digital control system 137
>-
12

1.

.8
.6
.4
.2
0
0 2 4 6 t
a (5)

...0
......
CD
1. -
.8
.6
.4
.2

°0 2 4 6
t
(5)
b
Fig. 8.25 Responses obtained from the dead beat control system simulation. (a) The output, y, in response
to a unit step change of reference while (b) shows the corresponding sampled error. Note the fact that
this form of controller gives zero steady-state error and that the final value of output is reached after one
sample period.

tion of digital control systems. In ACSL, for This example offers any reader interested
example, DISCRETE sections representing the in automatic control systems many opportu-
difference equations or z-transfer function of a nities for experimentation. It is clear from the
digital controller may be inserted within the listing of the SLIM program DIGCON1. SLI
DYNAMIC segment. Such DISCRETE sections that, with some minor changes to the
are thus similar to DERIVATIVE sections, but DYNAMIC segment, it would be very easy to
communicate with the continuous parts of the replace the dead beat compensator by some
simulation at regular predetermined times. other form of controller. Similarly, any other
Figures 8.26 and 8.27 show XANALOG and form of plant transfer function could be
SIMULINK block diagrams for this digital used in place of the one given in Fig. 8.21,
control problem and illustrate some more of with only some simple changes to the
the specialized blocks and icons available with DERIVATIVE section of the program being
these simulation tools. necessary.
138 Simple examples using common simulation tools

1.00e+OO

REF -[Link]-Ol 4.00e+OO

1.000+OO -2.00e+OO

1------------1 K ...- - - - - - - - - - - - - - '


-[Link]+OO

Fig. 8.26 XANALOG diagram for simulation of the digital control system.

+ Z-O.5 4 0
Z- 1 S + 2
unit step digital con. plant y

1__-~

Fig. 8.27 SIMULINK diagram for simulation of the digital control system. Note that a discrete transfer
function block in SIMULINK incorporates a built-in sampler at its input and a zero-order hold at its
output. Hence, when discrete blocks are mixed with continuous blocks, as in this example, the outputs of
the discrete blocks are held constant between sampling times.

REFERENCES 4. Murray-Smith, D.J. and Rosenberg, J.R (1983)


Models of the muscle spindle: a case study in
1. Bryce, G.W., Foord, T.R, Murray-Smith, D.J.
physiological system simulation, Proceedings of
and Agnew, P. (1976) Hybrid simulation of
the 1st European Simulation Congress: ESC83,
water turbine governors. Simulation Council
1983, Aachen (ed. W. Ameling), Springer,
Proceedings, 6 Part 1, 35-44. Berlin, pp. 519-23.
2. Murray-Smith, D.J. (1984) Use of a hydro-elec-
5. Jones, RW., Li, c.c., Meyer, A.U. and Pinter,
tric generator system simulation in the teach-
RB. (1961) Pulse modulation in physiological
ing of control engineering, in Proceedings of the
systems, phenomenological aspects. IRE
1984 UKSC Conference on Computer Simulation, Transactions on Bio-medical Electronics, BME-8,
September 1984, Bath (ed. D.J. Murray-Smith),
59-67.
Butterworth, London, pp. 451-57. 6. Michaelis, B. and Chaplain, RA. (1973) The
3. Ricci, F.J. (1972) Analog-Logic Computer
encoder mechanism of receptor neurons.
Programming and Simulation, Spartan Books, Kybernetik, 13, 6-23.
New York.
References 139
7. Pavlidis, T. and Jury, E.1. (1965) Analysis of 11. Breitenecker, F. (1993) Comparison 7-ACS1.
a new class of pulse-frequency modulated EUROSIM Simulation News Europe, 8, 30.
feedback systems. IEEE Transactions on 12. Kom, G.A. and Kom, T.M. (1993) Comparison
Automatic Control, AC-IO, 35-43. 7 - DESIRE/X. EUROSIM Simulation News
8. Bugmann, G. (1991) Summation and multipli- Europe, 8, 28.
cation: two distinct operation domains of 13. Husinsky, 1. and Breitenecker, F. (1993)
leaky integrate-and-fire neurons. Network, 2, Comparisons of simulation software - the
489-509. EUROSIM comparisons, in Proceedings of the
9. Murray, A. and Tarresenko, L. (1993). 1992 EUROSIM Conference, EUROSIM'92, 28
Analogue Neural VLSI: A Pulse Stream Approach, September-4 October 1992, Capri (eds F.
Chapman & Hall, London. Maceri and G. Iazeolla), North-Holland,
10. Breitenecker, F. (1993) Comparison 7: con- Amsterdam, pp. 181-86.
strained pendulum. EUROSIM Simulation 14. Leigh, J.R. (1984) Applied Digital Control,
News Europe, 7,29. Prentice-Hall, Englewood Cliffs, NJ.
INTERNAL VERIFICATION AND
EXTERNAL VALIDATION 9

9.1 THE NEED FOR TESTING The processes of external validation present
many more problems than those of internal
The capabilities and user-friendliness of verification. Although the importance of both
simulation packages have clearly contributed these aspects of testing has been recognized
greatly to the growth of computer-based in some previous texts on modeling (e.g. refs
simulation methods in a very wide range of 1 and 2), it is disturbing to find that most
activities and application areas. This growth applications papers in journals and confer-
means, of course, that simulation techniques ence proceedings pass over questions of
are being used increasingly by nonspecialists external validation in a superficial fashion or
and the risk of misuse is therefore becoming make no mention of it at all. Those appli-
more and more significant. cations studies in which some mention of
Many simulation models are developed to external validation is made seldom provide
provide insight about the dynamic behavior enough detail of the methods used. Ideally
of a complex system, to allow design the processes of internal verification and
decisions to be made, or to provide a basis for external validation should be integral parts of
predictions of future behavior. Simulation the iterative process of model development
results are being used to take important discussed in Chapter 1 and shown in
decisions which may have a bearing on safety diagrammatic form in Fig. 1.1. Therefore, tests
or investment in terms of human and other of validity should be applied many times
resources. It is thus vitally important to be during the development of a model. The
able to test a simulation and to have some documentation associated with the model
objective measures of performance, which can finally adopted for application to the problem
then be incorporated within the documen- in hand need not include every test carried
tation describing the development and out at every stage of development but must
providing information for the user. This include enough detail to allow tests of
involves testing the computer program to external validity to be repeated in full.
establish that it is an accurate implementation Although validation appears to be a
which incorporates the equations of the somewhat neglected topic in most appli-
chosen mathematical model. It also involves cation areas, there are a few safety-critical
testing the mathematical model to ensure applications in which the importance of
that, in the context of the intended model validation is fully accepted. The
application, the mathematical description is aerospace industry provides many good
itself appropriate. These two aspects of illustrations of this since accurate externally
testing involve separate and quite different validated models are needed for the design
activities: the first may be referred to as of aircraft flight-control systems, and for the
'internal verification' and the second as design of simulators for pilot training and
'external validation'. other activities such as investigations of
142 Internal verification and external validation
aircraft handling qualities. The nuclear 'verification' and 'external' with 'validation'
power industry provides other examples in [4]. Internal verification is thus defined as the
which safety requirements make it essential process of proving that a computer simula-
to have a high level of confidence in tion is consistent with the underlying model
simulations. to a specified degree of accuracy, while
The acceptance of model validation external validation involves demonstrating
methods in safety-critical fields means that that the mathematical or conceptual model
there are techniques currently available has an acceptable accuracy over the range of
which can be adopted with benefit in other conditions relevant for the application. These
application areas. Properly validated simu- definitions emphasize clearly that the
lation models, used in an appropriate way, processes which lead to internal verification
can lead to major cost benefits in the design of should provide proof of the internal con-
engineering systems and in other fields of sistency and accuracy of the simulation
application. Inaccurate models, or models program, whereas the assessment of external
applied beyond their range of validity, are of validity of the model involves questions of
little value and can lead to major problems of judgment to a greater extent.
interpretation or understanding and to
engineering design errors, which may prove
9.3 INTERNAL VERIFICATION
difficult and expensive to correct.
Criteria for internal verification involve the
following two aspects:
9.2 TERMINOLOGY AND DEFINITIONS
1. Internal consistency of the simulation
Many different words are commonly used to
program with the mathematical model on
describe aspects of the complete validation
which it is based. The program and the
process. Terms such as assessment, calibra-
model must be shown to involve no
tion, certification, evaluation, qualification,
contradictions in terms of mathematics,
testing, validation and verification are all
logic or concepts.
found. Similarly, words such as accuracy,
2. Algorithmic validity of the simulation
confidence, credibility, fidelity and perform-
program so that all the numerical algo-
ance are used widely in describing the
rithms and associated software routines
qualities of a model. In certain cases these
are shown to be appropriate and provide
words have been given specialized meanings
solutions having a specified numerical
in specific fields of application.
accuracy.
Guidelines on terminology were published
in 1979 by the Technical Committee on Model Internal verification is important at every
Credibility of the Society for Computer stage of model development. All changes
Simulation [3]. Although these have not been within a model must be considered carefully
adopted as a standard by everyone using in terms of internal verification, however
simulation and modeling techniques, the minor they may be. This must involve very
committee has provided very useful careful line-by-line checks of code which
definitions which allow possible ambiguities form the simulation program. In addition,
to be eliminated. One very important there are a number of additional checks and
recommendation was that there should be a comparisons that can be helpful. Checks of
strong distinction made between the words well-understood special cases, which can
'verification' and 'validation'. As indicated in sometimes even be derived using pencil-and-
section 9.1 this has since been extended paper calculations, are particularly appro-
slightly to associate the word 'internal' with priate and these can be divided conveniently
Internal verification 143
into checks of static, or equilibrium, states obtained from the equations suggest that a
and dynamic checks. mistake may have been made in coding the
simulation program. Static checks do not
provide any basis for algorithmic verification
9.3.1 STATIC CHECKS
and are concerned only with questions of
One important example of a check carried out internal consistency.
under static conditions involves a comparison
of equilibrium states in the mathematical
9.3.2 DYNAMIC CHECKS
model and in the simulation. Equilibrium
states are steady-state solutions which can be Dynamic checking, as the term suggests, is a
found by setting all the derivatives on the procedure that goes beyond testing only
left-hand side of the state equations to zero or under static conditions. In general, it involves
by using one of the 'steady state' finders comparing results from the simulation with
which are available in many modern known analytical solutions of the same
simulation software products. Although equations for special cases. Since analytical
algebraic problems may arise in some cases dynamic solutions for nonlinear problems are
with calculations of this kind, the approach is usually not available, this may sometimes
a useful one which can highlight problems require consideration of a slightly modified
that could be much more difficult to identify problem in which nonlinearities have been
under non-steady-state conditions. An temporarily removed for the purposes of
alternative approach to finding steady-state testing. Comparisons of results from a
conditions is to allow the simulation to run simulation program modified in this way
until a steady state is achieved. Whichever with solutions obtained by standard
method of approach is used, comparisons of techniques of linear mathematics, such as the
equilibrium states in the simulation and in Laplace transform, can certainly be of
the real system can also provide a useful basis assistance in locating possible problems both
for external validation. in the structure of the program and in the
It is possible to carry out a partial numerical techniques being used. Dynamic
verification of consistency between the checks therefore address questions of
program code and the mathematical algorithmic accuracy as well as consistency of
formulation by carrying out a static check the simulation code with the underlying
under conditions which do not correspond to mathematical model.
an equilibrium state. This technique was Algorithmic accuracy can be assessed most
introduced first for verification of analog easily in relatively small and simple models.
simulations, but it is equally valid for use Therefore, it is very beneficial to apply
with modern digital simulation tools and is verification of this kind at the submodellevel
especially useful in carrying out checks on and to build up a library of well-tested and
block diagram-oriented simulations. In a documented submodels. These submodels
static check calculation appropriate nonzero can then be incorporated with some
initial conditions are imposed on the confidence in other larger models, provided
integrators, and values of all the other they are appropriate for the intended
variables in the simulation are found. These application.
values are then compared with values In using a well-established simulation
calculated directly from the differential package most of the emphasis in terms of
equations for the same imposed initial state. internal verification is placed on questions of
Any differences in values found from the internal consistency and on the suitability
simulation and the corresponding quantities of options chosen by the user of the package.
144 Internal verification and external validation
The latter may include, for example, 1. Theoretical validity in the sense that the
the integration method, the integration model shows overall consistency with
step length and the communication interval accepted theories or is based upon a
for plotting of output variables. An satisfactory theoretical foundation.
inappropriate choice of anyone of these 2. Empirical validity, with adequate
quantities may cause major problems in agreement shown between the behavior
terms of the eventual interpretation of the of the model and that of the real system
behavior of the simulation. For example, the represented by the model.
choice of an inappropriate integration 3. Pragmatic validity in the sense that the
steplength in a fixed-step integration algo- model satisfies the requirements of the
rithm could cause numerical instability in application.
the simulation program, which could be 4. Heuristic validity in terms of the potential
misinterpreted as a system instability by the of the model for hypothesis testing and
user. In this particular situation, which is a explanation.
common one, simple tests based on changing
the integration steplength, or integration The most important of these criteria, in the
method, can help to establish the true nature context of most practical modeling and simu-
of the instability. If small changes of lation applications, are the ones concerned
integration steplength cause significant with empirical and theoretical validity. These
changes in the model response, the insta- need to be considered at every stage of
bility may well be numerical in nature and development of a model.
be unrelated to any properties of the real
system. Observations of the frequency of the
9.4.1 THEORETICAL VALIDITY
oscillations can also be revealing and a
frequency which is higher than the expected Assessment of theoretical validity involves
bandwidth of the system being modeled checking that the chosen mathematical
may also be indicative of a numerical description does not in any way violate
problem. However, more fundamental important physical laws or principles. It
checks of algorithmic accuracy should not is, for example, very easy to define a
be forgotten, even when using a well- mathematical model in transfer function form
established commercially supported pack- which would incorporate a pure time delay.
age. A responsible user should always give Such a description would be very appropriate
careful consideration to the need for some as part of a model of an engineering process
checks of accuracy, especially when a involving loss-less transport of material in a
particular feature of the package is being pipeline. What comes out of the far end of the
used for the first time by that user or is being pipe is the same as the input but delayed in
employed in an unconventional way. Such time by an amount which depends on the
algorithmic checks normally are of the transport velocity. It would be equally easy to
dynamiC kind. define a mathematical model in which the
delay parameter had a negative value but this
would, of course, be impossible in terms of
9.4 EXTERNAL VALIDATION
the physical system since it would imply that
Criteria for external validation involve the output was available before the input was
assessment of the accuracy and suitability of a applied.
model with respect to the intended Many other situations can arise in which
application. They may include the following mathematical statements have no physical
aspects [5]: relevance, or have restricted validity in terms,
External validation 145
say, of the frequency range in which they are in the real system because of safety
applicable. Situations of this kind must be constraints, but any information available
recognized at the model development stage. about such limits may provide useful insight.
If they involve modeling errors appropriate Comparisons could also be made of the
changes must be made to the structure or frequencies of oscillation of unstable modes
parameters of the model. If they only impose in the real system response and in the model
restrictions in terms of the range of conditions response. Criteria for model acceptability
for which the model will be valid, it may not might then involve agreement to within some
be necessary to make a change in the model given percentage of the relevant system
but decisions must be made about the eigenvalue.
conditions under which the approximation is The third approach involves consideration
acceptable and this must influence the of the response of the system to an
eventual use of the model. Documentation for appropriate input and can be treated in at
the model must then include some statement least two ways:
about the theoretical validity of the model
1. analysis of small perturbation responses
and the range of conditions over which its use
about a selected operating point or about
is permissible.
a series of operating points; and
2. analysis of large-amplitude responses.
9.4.2 EMPIRICAL VALIDITY
Small-perturbation response data may be
Empirical validity is concerned, in the expressed either in the time domain, as a
broadest sense, with comparisons between simple time history, or in the frequency
the behavior of the model and the behavior of domain in the form of separate plots of
the real system. This can include comparison magnitude versus frequency and phase
of chosen system and model variables under versus frequency. Frequency-domain results
equilibrium conditions, comparison of may be obtained from sinusoidal testing or
stability limits and comparisons in terms of from response data generated using other
the dynamic response of selected variables to forms of broadband test input appropriately
chosen input perturbations. transformed using digital signal processing
Evaluation of system and model behavior software. Large-amplitude responses are
under equilibrium conditions can provide normally expressed as time histories as they
much useful insight in the assessment of often involve nonlinear responses for which
external validity, as in the case of internal the frequency domain has no advantage.
verification. Differences in the equilibrium or Responses predicted for a given test input
'trimmed' states of the system and model should, ideally, match the corresponding
may well give indications of problems which system responses to within a given per-
would be much more difficult to identify centage of the full response range in the real
from dynamic responses. Criteria for system. Difficulties can arise with this type of
acceptability of the model could be expressed approach in some cases if the system and
in terms of the percentage difference between model responses are very sensitive to small
appropriate variables of the model and differences of initial condition or of input
system at each equilibrium point considered. amplitude. Such small initial differences may
Stability boundaries for the simulation become exaggerated as time increases because
model should correspond to the stability of integration effects within the system, and
limits for the real physical system. Evaluation direct comparisons of time histories over an
of these limits by actual testing and extended period following the application of
experimentation may not always be possible a test disturbance can therefore sometimes be
146 Internal verification and external validation
of limited value. In the case of a single output can be very helpful as a first step towards
variable, criteria based upon the integral of external validation. For example, the absence
the error squared or the integral of the of an oscillatory response in a model for a
absolute error between the system response system which exhibits strongly oscillatory
and the model response can be of value. A behavior provides an immediate clue which
more general criterion function, which can be can be useful in reconsidering the structure
useful for the assessment of models using and parameter values previously chosen.
direct time history comparisons in the case of Models are not unique, and in most
a model with a number of output variables, situations of practical importance there will
has the form be a number of candidate models which give
an adequate match for a given set of
f
J = eT (t)W(t)e(t)dt (9.1) experimental responses. Models should
therefore be assessed for a variety of
experimental data sets and, before being
where e(t) is the vector representing the time accepted for the intended application, should
response error function and W(t) is a matrix be shown to be capable of matching the
which provides appropriate weighting. experimental results to an acceptable level of
Optimization of criterion functions such as accuracy for all of the test conditions.
those discussed above provides one approach Methods of parameter sensitivity analysis
to the refinement of models in which can help the modeler considerably in gaining
discrepancies have been found. However, an understanding of the potential of a chosen
care must be taken to consider the possibility mathematical description to describe fully the
of errors in model structure as well as errors behavior of a system under both steady-state
in model parameters when carrying out this and dynamic conditions. However, detailed
type of optimization. Unrealistic parameter sensitivity analysis for a complex model is a
values in a model are often indicative of a computationally intensive task and can also
deficiency in the model structure, but it must provide problems in terms of presentation
be recognized that such structural deficiencies and efficient interpretation of results. The
may be difficult to correct. Once corrected, use of parallel-processing techniques and
however, the model structure should be improvements to the user interface tradi-
capable of providing a good fit to system tionally used in simulation work could well
response data over an expanded range of produce benefits in this respect in the future.
conditions. Sometimes, lack of appropriate experi-
Models can also be assessed using particu- mental response data from the real system
lar features of a time history or a small part of may make it impossible to compare model
the total frequency range rather than the responses with measured data. This can arise,
complete record. For example, quantitative for example, in engineering design appli-
comparisons may be made of particular cations when a simulation model may be
features of a time history, such as the shape developed at an early stage in a new project
of a response overshoot for a step input test, before any real hardware or prototype system
or of a frequency response in the vicinity of a exists. Very often, in such circumstances, it
resonant peak. Comparisons may also be may be possible to use previous modeling
useful in terms of individual features of a experience from the appropriate application
response, such as the actual frequency of an area and validated submodels to minimize
oscillatory response or the magnitude or time risks and uncertainties inherent in the new
of occurrence of an overshoot. Even quali- model. It may also be possible to assess the
tative comparisons involving such features overall model results by making comparisons
External validation 147
with data from other validated simulations, validation. Such submodels may be available
even if these other representations are not from previous design studies involving
appropriate for the intended application. similar systems. Complete external validation
Good examples of this kind are often to be of a model, initially validated only at
found in the development of real-time subsystem level, is clearly desirable as soon
simulation models where a simplified as data becomes available from the full
description, capable of running in a fast system.
timescale on a given computer, may be One important, but often neglected, aspect
assessed by making detailed comparisons of the processes of external validation is.
with a much slower but more detailed model concerned with the specification of tests for
which has previously been subjected to a full the generation of time history data for
validation process. This is, of course, a validation purposes. Often experiments have
weaker form of external model validation to be designed specially for model testing and
than is possible by the direct approach, and it may involve monitOring of quantities which
must be used with care. Careful study must are not normally accessible for measurement.
be made of the model which is being used as In engineering applications this may involve
reference, especially in terms of the intended significant augmentation of the standard
area of application, the inherent assumptions instrumentation for the system. There is, in
and the recorded limitations. most cases, an inverse relationship between
the initial level of understanding of a given
system and the complexity of the instrumen-
9.4.3 MEASURED RESPONSE INFORMATION
tation needed for a comprehensive empirical
FOR EMPIRICAL VALIDATION
validation of a model for that system.
Empirical validation requires the availability The information content of the experi-
of data describing the behavior of the real mental response data used for model
system which is being modeled. Such data validation must be maximized, subject to
may involve one or more of the following: constraints imposed by safety. Careful con-
sideration must be given to system band-
1. measured time histories from tests
width, the frequency content of test signals,
carried out on isolated subsystems;
sampling rates, signal amplitudes and signal
2. measured time histories from tests
to noise ratios. Factors such as these are also
carried out on the complete system; and
important in system identification methods as
3. the opinion of an independent person
discussed in section 9.4.4.
who has expert knowledge and practical
One important source of validation
experience of the system in question.
information which should never be neglected
The use of measured response data from is the independent expert. Much useful
tests carried out on isolated subsystems is insight can be provided by someone who is
especially valuable for engineering appli- familiar with the real system, and simple tests
cations involving the evaluation of competing which can be very revealing are often
design options through the use of simulation suggested by such experts. Those responsible
models. As pointed out in the previous for the development of simulator systems for
section, measured response information for training purposes have found that valuable
the complete system under investigation information can be gained very quickly and
clearly cannot exist at the design stage, but effectively in this way, although there may
use may be made of subsystem models which well be differences in the way such infor-
have already been subjected to rigorous mation is used in correcting deficiencies in a
processes of internal verification and external training simulator and in a mathematical
148 Internal verification and external validation
model being validated for other purposes. In are mostly concerned with the estimation of
the case of a training simulator it may well be parameters for small perturbation models for
acceptable to make empirical adjustments particular operating conditions. From meas-
until the experienced operator is satisfied that ured system response data, identification and
the simulation is realistic. In a model being parameter estimation tools can provide para-
developed for other purposes a more thor- meter estimates, together with associated
ough understanding may be needed of all the estimates of variance for the parameter values.
factors underlying the alleged deficiency. Potential problems in the use of system
identification methods for model validation
can be assessed, for a given model structure
9.4.4 SYSTEM IDENTIFICATION AND
and available set of measured variables, by
PARAMETER ESTIMATION METHODS IN
carrying out a preliminary analysis of
THE EMPIRICAL VALIDATION PROCESS
identifiability. In models which are theor-
The factors which are important in the design etically identifiable all of the parameters may
of experiments for empirical validation are be estimated uniquely given ideal test data. In
essentially the same as the factors which models which are theoretically unidentifiable
influence experiment design for system some parameters may be estimated uniquely,
identification. System identification may be whereas others could have a range of possible
defined as a process of determining, on the values consistent with the test data. Many
basis of measured input and response data, a different techniques are available for the
model to which the system under test is assessment of identifiability [7], and some of
equivalent. these are applied in the case studies in later
Some system identification techniques, chapters.
which have been developed largely in the System identification and parameter
context of engineering applications involving estimation methods provide a particularly
automatic control, are often closely linked to important form of external validation in fields
the development of models of data and may of application in which linearized dynamic
not involve models which have any models provide a natural form of system
underlying theoretical structure. In this respect description. One important example comes
system identification methods are very similar from the aerospace industry, in which
to the time-series modeling techniques used by linearized state-space models of aircraft
statisticians and operations researchers, and provide the mathematical descriptions
indeed the underlying theoretical foundations needed for some aspects of flight control
are very closely related. These techniques are system design and handling qualities studies.
now being considered increasingly important In this particular type of application, system
for the development and testing of dynamic identification techniques have also been
models used in continuous system simulation found to be of value in the assessment of
[6]. Frequently, insufficient information is nonlinear models. At each chosen operating
available to allow a mathematical model to be condition the parameters of a linearized
developed entirely from theory, and infor- model obtained by system identification can
mation must be extracted about parameter be compared with the corresponding
values or possible model structures from theoretical parameters found by linearizing
observations on the real system. This process the underlying nonlinear model derived
of inverse modeling from measurements is the using physical principles. Comparison of the
essence of system identification. values of the theoretical and estimated
Aspects of system identification which are parameters for a number of different oper-
of particular relevance for model validation ating points can be revealing. The tendency of
Robustness issues in external validation 149
an estimated parameter to increase or further consideration of it goes beyond the
decrease in value over a range of conditions scope of this book.
involving a series of equilibrium points can
provide considerable insight since a similar
9.5ROBUSTNESS ISSUES IN EXTERNAL
trend in the estimated and theoretical
VALIDATION
parameters tends to support the validity of
the theoretical nonlinear model over the Empirical validity is, of course, one of the
operating range involved [8]. In the case of most important aspects of the external
the aircraft model this might involve validation process, and the robustness of a
comparing theoretical and estimated para- model which has been subjected to the
meters for a [Link] of small perturbation tests processes of empirical validation must be
for a series of trimmed flight conditions at demonstrated if the model is to be credible. In
different forward velocities. general, robustness of a model which has
The importance of system identification been subjected to external validation may be
methods for model validation in aircraft checked further by carrying out tests using
applications has been given further emphasis data sets not employed at any stage in the
recently in a report concerned with the development and refinement of the model. If
application of identification techniques to the differences between the model predictions
helicopters and other forms of rotorcraft [9]. and the corresponding measured variables
This report stresses the need for accurate are all sufficiently small the model may be
mathematical models for the development of accepted as a candidate for the intended
high-performance flight-control systems and application. If the model does not satisfy this
suggests that system identification techniques requirement it must be reconsidered and all
may become mandatory in the future for theory and data used at any stage of model
model validation in ground-based flight development must be reassessed. However, it
simulators. should be noted that even if the model gives a
Although system identification is not good prediction for all the additional tests
carried out exclusively for model validation considered it will not be a unique repre-
purposes, the factors which are important for sentation and other models could give similar
obtaining reliable and robust estimates of results.
parameters in an identified model have The data sets to be used for assessment of
an important bearing on the successful model robustness should be similar in
validation of a given model. As has already character to data sets used at the model
been pointed out, the success of the empirical development or refinement stages in terms of
validation process is closely linked to the the amplitude and frequency distribution of
design of experiments used to test the model. inputs and responses. However, results
Similarly, in system identification and obtained using a number of forms of test input
parameter estimation, the reliability of may give differences which are under-
estimates is critically dependent upon standable in terms of physical reasoning and
experimental design. In both cases the may provide useful insight, which can lead to
information content of the experimental further model improvements. Additional tests
response data must be maximized subject to or new experiments or observations may also
practical constraints. Much has been written be needed in order to resolve difficulties
about system identification techniques and identified at this stage.
about methods of experiment design for Robustness issues are also of considerable
system identification (e.g. refs 6, 7 and 10). importance for the parameter estimates which
This is a specialist topic in its own right and are incorporated into a model at the initial
150 Internal verification and external validation
development stage. This is really inseparable model leads to three possible outcomes.
from the question of robustness, in terms of These are as follows:
model validation, since they both form part of
1. The data sets used for model testing
a larger iterative process. However, it should
cannot be explained by any combination
be noted that the variance of each parameter
of model parameter values and model
estimate provides a useful measure of
structures considered. The candidate
the relative reliability. Whenever system
models have therefore all been falsified. It
identification methods are used as part of the
is necessary to reconsider the model
initial development stage, careful checks
structure and assumptions once again
should be made of the variance values
from first prinCiples.
provided by the chosen parameter estimation
2. One or more models produce a satis-
method, and residuals (the differences at each
factory match to the available system data
point in time between [Link] system
but the uncertainty level is excessive for
quantities and the correspondmg model
certain parameters. Such models may not
variables) should be examined to assess the
be of much predictive value and re-
possible presence of systematic erro:s caused
formulation of the model may again be
by an incorrect model structure .whIch co~ld
necessary.
show up as parametric dIscrepanCIes.
3. A model gives satisfactory agreement
Repetitions of the estimation process. for a
with experimental test results from the
variety of different record lengths or, m the
real system and involves parameter values
case of frequency-domain identification
which are considered plaUSible. In this
methods, for a number of different frequency
case the model is of acceptable validity in
ranges can be useful. Estimated parameters
terms of the particular tests performed.
should show low sensitivity to record length
The model may be used for the intended
and frequency range used.
application until such time as evidence is
In general it is important that identification
found which falsifies the model.
tools which are being used for the
development and validation of con~ius
dynamic models for simulation app!Icattons 9.7 DOCUMENTAnON OF THE
should incorporate a comprehenSIve and VALIDA nON PROCESS
well-engineered user interface which .exploits
When carrying out the complex and time-
the maximum use of simple graphICS. The
consuming tasks of internal verification and
tools available should provide information on
external validation it is essential that the
goodness of fit, confidence intervals f?r
complete process is documented in detail and
estimated quantities, sensitivity to changes ~n
is thus repeatable. The SCS Technical
model structure and sensitivity to changes m
Committee on Model Credibility recom-
test condition [11]. Good facilities are also
mends [3] that the documentation associated
needed for management of the very large
with the assessment of credibility and
amounts of data required for identification,
applicability of a model should include at
and for comprehensive documentation of the
least four basic elements as follows:
results.
1. a clear statement of the purpose of the
model;
9.6 POSSIBLE OUTCOMES OF THE
2. descriptions of the model in both con-
EXTERNAL VALIDA nON PROCESS
ceptual and mathematical terms;
Application of the methods outlined above 3. a statement concerning the range of
for assessing external validity for a given conditions for which the model has been
References 151
tested and the range for which there is 4. Murray-Smith, D.J. (1990) A review of
overall agreement with the real system methods for the validation of continuous
behavior; and system simulation models, in Proceedings of
the 1990 UKSC Conference on Computer
4. a description of all tests used for internal
Simulation (ed. K.G. Nock), United Kingdom
verification and external validation, Simulation Council, Burgess Hill, pp. 108-11.
together with relevant results and a 5. Murray-Smith, D.J. and Carson, E.R (1988)
justification of the tests chosen. The modelling process in respiratory
medicine, in The Respiratory System (eds D.G.
Model documentation of this kind provides Cramp and E.R. Carson), Croom Helm,
a basis for formal certification of a model in London, pp. 296-333.
application areas where this is required. A 6. Unbehauen, H. and Rao, G.P. (1987)
potential user of a model documented in this Identification of Continuous Systems, North-
way can review the evidence provided, Holland, Amsterdam.
consider the context in which it was 7. Beck, J.V. and Arnold, K.J. (1977) Parameter
Estimation in Engineering and Science, John
developed, assess its suitability for the
Wiley, New York.
intended application and take note of stated 8. Bradley, R, Padfield, G.D., Murray-Smith, D.J.
limitations. and Thomson, D.G. (1990) Validation of
helicopter mathematical models. Transactions
of the Institute of Measurement and Control, 12,
186-96.
9. AGARD (1991) Rotorcraft System Identification,
REFERENCES
Advisory Report No. 280, AGARD, Neuilly
1. Shannon, RE. (1975) System Simulation. The sur Seine.
Art and the Science, Prentice-Hall, Englewood 10. Sinha, N.K. and Kuszta, B. (1983) Modeling
Cliffs, NJ. and Identification of Dynamic Systems, Van
2. Spriet, J.A. and Vansteenkiste, G.c. (1982) Nostrand Reinhold, New York.
Computer-aided Modelling and Simulation, 11. Murray-Smith, D.J. (1991) Modelling and
Academic Press, London. Robustness Issues in Rotorcraft System
3. SCS Technical Committee on Model Identification, AGARD Lecture Series No. 178,
Credibility (1979) Terminology for model Rotorcraft System Identification, AGARD,
credibility. Simulation, 32, 103-104. Neuilly sur Seine.
CASE STUDY I - A TWO-TANK LIQUID
LEVEL CONTROL SYSTEM
10

10.1 INTRODUCTION Figure 10.1 shows a typical vessel of rectan-


Systems involving tanks containing liquid gular cross-section. If A is the surface area of
are found in many industrial situations. the tank, it is possible to relate the mass of
Examples include blending and reaction liquid, M, to the liquid height, H, through an
equation
vessels in chemical processes and boiler
systems in electrical power stations. The
design of automatic control systems for the M=pAH (10.4)

regulation of liquid level is thus of consider-


able practical importance and requires an The hydrostatic pressure at the base of the
appropriate mathematical model of the plant vessel is then
(the system to be controlled) as a starting
point. This chapter is concerned with the P=pgH (10.5)

modeling of hydraulic systems of this kind


and with discussion of methods for the verifi- where g is the gravitational constant. For the
system of Fig. 10.1, if the pressure at the
cation and validation of a simulation model
of a laboratory-scale system involving two
interconnected vessels.
The primary variables for hydraulic
systems are pressure, mass and mass flow
rate. For any vessel holding a mass of fluid M,
the rate of change of mass in the container
must equal the total mass inflow rate (Q)
minus the total mass outflow rate (Q). That is

(10.1)
H

The mass of fluid, M, is related to the volume


of fluid in the vessel, V, by the equation

M=pV (10.2)

where p is the fluid density. For an incom-


pressible fluid p is constant and thus Fig. 10.1 A tank of rectangular cross-section con-
taining liquid and having an inflow rate Qi and an
M=pV (10.3) outflow rate Qo for liquid depth H.
154 Case study I
surface of the liquid and at the outlet are be shown (by using the principle of conserva-
the same and equal to Pa (say, atmospheric tion of energy) that the mass flow rate
pressure) the pressure difference between through the orifice is given by
the tank base and the outlet is given by
(Pa + P) - Pa , which is simply P. The output
flow rate Qo is dependent on P and, for the
case of laminar flow, is conventionally
described by an equation of the form
where ao is the orifice area and Cd is the dis-
charge coefficient. If, on the other hand, the
(10.6) outlet is through a pipe with turbulent flow,
the appropriate relationship is
where R is the fluid resistance.
Assume now that Qi is known (as a func- (10.11)
tion of time) and that we want to be able to
predict the system behavior in terms of the
liquid height H. From equations (10.1), (10.4), where RT is a constant. Practical hydraulic
(10.5) and (10.6) one may write components, such as valves, can be described
by equation (10.6) for small pressure drops
A dh = Q. _ pgH (10.7) but have to be described by equation (10.11)
p dt 1 R in many cases owing to turbulence at typical
operating conditions.
so that
10.2 MODELING OF A PAIR OF
A dH = Qi _ gH (10.8) INTERCONNECTED TANKS
dt p R
When a hydraulic system incorporates more
than one liquid storage vessel the principle of
It should be noted here that Qi is the mass conservation of mass, equation (10.1), may be
flow rate and thus Q/ p is the volume flow applied to each element in turn. However,
rate. Let Qvi denote this quantity, so that there is coupling between the vessels, and the
nature of this coupling depends upon the
A dH =Q. _ gH (10.9) precise configuration of the vessels and upon
dt VI R the operating conditions. The interconnected
tanks being modeled in this chapter are
It is important to note that the relationship bench-top systems intended for use in teach-
describing the flow at the outlet of the vessel ing the principles of automatic control engin-
is not always that shown in equation (10.6) eering [1].
and the form of expression which is appropri- Figure 10.2 is a schematic diagram of the
ate depends upon the nature of the outlet. For system being considered. It consists of a con-
example, if the outlet is simply a hole in the tainer of volume 6 I having a center partition
side wall of the tank, a condition known as which divides the container into two sepa-
orifice flow occurs. In this case, if the size of rate tanks. Coupling between the tanks is
the orifice is small, and the pressure variation provided by a number of holes of various
over the orifice area is thus negligible com- diameters near the base of the partition, and
pared with the average orifice pressure, it can the extent of the coupling may be adjusted
Modeling of a pair of interconnected tanks 155

pump

H2

1 av1 avo
H -!.~ _._ .... -. '_. __ .-... -.-.-.-.-.-.- ._- ~

Fig. 10.2 A pair of interconnected tanks.

through the insertion of plugs into one or is the cross-sectional area. Similarly for tank 2
more of these holes. The system is equipped we can write
with a drain tap, under manual control, and
the flow rate from one of the tanks can be A 2 dH 2 -Q -Q
dt - v1 vo
00.13)
adjusted through this. The other tank has an
inflow provided by a variable-speed pump,
which is electrically driven. Both tanks are where H2 is the height of liquid in tank 2 and
equipped with sensors which measure the Qvo is the flow rate of liquid out of tank 2.

pressure at the base of each tank and thus Considering the holes connecting the two
provide an electrical output voltage propor- tanks and the drain tap all as simple orifices
tional to the liquid level. allows the flow rates to be related to the
liquid heights by the following two equations
10.2.1 A NONLINEAR MATHEMATICAL
00.14)
MODEL
Following the approach used in section 10.1 and
the equation describing tank 1 in Fig. 10.2 has
the form Qvo = Cd ,a2 (2g(H 2 - H 3 )t 2
00.15)

A dH 1 -Q -Q 00.12) where a1 is the cross-sectional area of the


1 dt - vi v1
orifice between the two tanks, az is the cross-
sectional area of the orifice representing the
where H1 is the height of liquid in tank 1, Qvi drain tap, H3 is the height of the drain tap
is the input volume flow rate and QVl is the above the base of the tank and g is the gravi-
volume flow rate from tank 1 to tank 2 and Al tational constant.
156 Case study I
10.2.2 LINEARIZATION OF THE MODEL
(10.23)
For control system design studies it is appro-
priate to consider a linearized model in
which the model variables represent small where
variations about steady-state values. Thus,
the input flow variable is qv;' representing (10.24)
small variations about a steady flow rate Qv;.
Similarly, the other variables represent small
variations about steady values qv1 in QV1' qvo and
in Qvo' h1 in H1 and h2 in H 2. In the steady
state (10.25)

(10.16)
Reorganization of equations (10.22) and
(10.23) gives a second-order state-space
(10.17) model as follows

(10.18)

From equation (10.14) it is clear that Qv1 is a


function of both H1 and H 2• Hence, in deriv-
(10.26)
ing a linearized representation, the small
variation in flow, qv]l must depend on the
Taking Laplace transforms it is possible, in a
steady levels H1 and H2 about which the
few steps, to obtain the transfer function
system is operating. In general, one may
descriptions relating the depth h1 and the
therefore write
depth h2 to the input flow rate qv;. These are as
follows:
(10.19)
1
Differentiating equation (10.14) partially with
respect to H1 and H2 in turn gives

(10.27)
(10.20)

and
Similarly

_ aQvo h _ Cd2 a2(2g)1/2 h


(10.21)
qvo - aH 2 2 - 2(H 2 _ HS12 2

Substituting for qv1 and qvo in equations (10.17)


and (10.18) gives (10.28)

(10.22) These transfer functions both involve a


pair of simple real poles and the charac-
Simulation of the nonlinear coupled-tank system 157
teristic equation may be written in both source program is included as a . SL1 file
cases as (TANKS. SL1) on the diskette. Nominal para-
meter values corresponding to a real labora-
tory-scale coupled-tank system are as shown
in Table 10.1. A data file is provided on the
(10.29) diskette for this nominal set of parameters.
Figure 10.4 shows an XANALOG block
diagram for this simulation model.
or Some preliminary results based on the sim-
ulation program of Fig. 10.3 and the given
(10.30)
DYNAMIC
where DERIVATIVE
IF(H1-H3)4,2,2
4 IF(H2-H3)3,5,5
3 Q1=0.0
(10.31) GOTO 7
5 Q1=-CD1*A1*SQRT(2.0*G*(H2-H1))
GOTO 10
and 2 IF(H1-H2)5,6,6
6 Q1=CD1*A1*SQRT(2.0*G*(H1-H2))
GOTO 10
10 IF(H2-H3)7,7,8
(10.32) 7 QO=O.O
GOTO 20
8 QO=CD2*A2*SQRT(2.0*G*(H2-H3))
GOTO 20
20 CONTINUE
DH1=(1.0/A)*(QI-Q1)
10.3 PROGRAMS FOR SIMULA nON OF DH2=(1.0/A)*(Q1-QO)
H1=INTEG(DH1,H10)
THE NONLINEAR COUPLED-TANK H2=INTEG(DH2,H20)
DERIVATIVE END
SYSTEM TYPE T, H1SS,H2SS, H1,H2
IF(T-TMAX)50,50,60
Figure 10.3 shows part of a simulation 50 DYNAMIC END
60 STOP
program for the nonlinear model of the
coupled-tank system based on equations Fig. 10.3 Listing of part of a SLIM program
(10.12) to (10.15). This program is written (TANKS. SLI) for simulation of the two-tank system
using the SLIM language and the complete described by equations (10.12) to (10.15).

Table 10.1 Parameter values for the coupled-tank system

Parameter Symbol Value

Cross-sectional area, tank no. 1 AI 0.0097 m'


Cross-sectional area, tank no. 2 A, 0.0097 m'
Orifice area, between tanks al 0.00003956 m'
Orifice area, outlet from tank no. 2 a, 0.0000385 m'
Coefficient of discharge, Cdl 0.75
intertank orifice
Coefficient of discharge, Cd' 0.5
outlet orifice from tank no. 2
Gravitational constant g 9.81 m s-'
Pump calibration constant Cp 0.0000072 m 3S-I V-I
Depth sensor calibration constant Cd 33.33 Vm- I
Height of outlet above H3 O.03m
base of tank
158 Case study I
,•.....•.•...•..•.............••..•.••....••..•••••••.••.••..••••••..........•...
I
I
I
I

3_5009-05 1_03 09-+-02 INT1


H1
H2
j-. Ga1
H3

·
W ... -.
o

TANKS _ ALG
'.'
.'

"'iI]Ga~1.
H3

3_0009-02

H2 L.......... Gao
~ .....-_H3~ GaD

1_0309-+-02 INT2
~

W
.' :"

TANKS_ALG
.. •
I

.......•••••..•.••.....•••••••.••••...••..•..................••.......•.......... I

Fig. 10.4 XANALOG block diagram for simulation of the two tank system. Note the use of submodels
and their associated icons.

parameter set are shown in Fig. 10.5. These internal verification is concerned with check-
show the changes of depth h1 and h2 versus ing that the structure of the simulation
time for a number of different initial condi- program is consistent with the mathematical
tions. Are these results meaningful? Is the model. This involves working backward from
mathematical model adequate and does the the statements in the program, especially
simulation program represent the model to a those within the derivative section, to ensure
sufficient degree of accuracy? In order to that when translated back to the form of dif-
answer these questions in a satisfactory way ferential equations they are the same as those
one must first consider carefully how this of the original model. Checks should also be
simulation can be verified and how the model made of the parameter values used in the
can be validated. program or in the parameter input file to
ensure that they correspond exactly to the
parameter set of the model itself.
10.3.1 INTERNAL VERIFICATION OF THE
The second stage of internal verification is
SIMULATION PROGRAM
concerned with numerical accuracy. In the
The simulation program for the coupled-tank case of fixed-step integration methods, com-
system is a very simple one. The first stage of parisons can be made of results obtained with
Simulation of the nonlinear coupled-tank system 159

0.06

100 200 300 400 t


(s)

~I r-~_,
0.18 ~

0.14 f.
~
0.1 0 ~ ,- - , - - "__
L/ . . -- . . - . . - . . __
-------------..,
-~ -____________________________________
0.06 L
------- ~

o 100 200 300 400 t


(sl

~
0.18

0.06 "--___________________________ ~ ______---=:I


o 100 200 300 400 t
(s)

Fig. 10.5 Simulation results (from SLIM) for the two-tank system model for three sets of initial condi-
tions. The input flow rate was the same in all the cases, with a value of 16.67E-06 m 3 S-I (1000 cm3 min-I).
The continuous line represents the depth HI and the dashed line denotes H 2 • Note particularly the case
where the two tanks are both initially empty. Can you explain the behavior of the system, on physical
grounds, during the first part of the response?

a number of different sizes of integration ent settings of the relative and absolute error
step length and with different integration limits and with different values of the
techniques. This provides the user with some minimum integration step to be allowed. In
understanding of the sensitivity of results to both cases, some comparisons can be made
the step length and of the overall suitability of using a number of different values of the
the numerical methods chosen. In the case of communication interval to ensure that inter-
variable-step integration algorithms, tests can esting events in the simulation model are not
be carried out to compare results with differ- being hidden from the user simply because of
160 Case study I
an inappropriate choice of this parameter to checking a mathematical model which can
which determines the interval between provide a basis for any definitive statement
output samples. about the overall validity of that model.
Statements about model validity must be
made in the context of an intended applica-
10.3.2 EXTERNAL VALIDATION OF THE
tion. In the case of the coupled-tank system,
SIMULATION MODEL
the computer simulation is to be used as a
The discussion of validation in Chapter 9 basis for the design of an automatic control
shows clearly that there is no single approach system which will ensure that a given level is

Table 10.2 Comparisons between system and simulation model


variables under steady-state conditions for a number of operating
points

Q, H, H, H, H,
measured model measured model
(em 3min-') (em) (em) (em) (em)

1000 5.0 8.4 3.4 6.8


1500 13.1 15.2 9.7 11.6
2000 25.0 24.7 18.9 18.3

C\j-
IE
£.
21

18

15

12

o~-+
o 100 200 300 400 500
__
600
t
(s)
Fig. 10.6 Simulation results for H, (dashed line) and the corresponding measured response of the real
system for an experiment involving doubling of the input flow rate from Qvi =1000 cm3 min-' to QVi =2000
cm3 min-' at time t = 50 s. Note the initial steady-state difference between the measured and simulated
responses.
Simulation of the nonlinear coupled-tank system 161
maintained in one of the tanks. There is par- change in operating conditions. Figure 10.7
ticular interest therefore in the accuracy of the shows measured response data for small-
model in predicting steady-state conditions perturbation step tests carried out about one
and in predicting the form of small transients chosen operating point. Time constants esti-
about any given steady operating point. Such mated from measured step responses such as
comparisons are very easily made in the case these, from which the error plots of Fig. 10.7
of small-scale laboratory equipment of this were derived, can also be compared with
kind, and agreement between steady-state values determined from the linearized model
measurements and steady-state model predic- in the form of equations (10.27) and (10.28).
tions is generally quite good for upper parts The discrepancies in the model exposed by
of the operating range. Table 10.2 shows some the steady-state tests, and the large perturba-
typical results obtained from measurements tion responses, are believed to arise mainly
on the real system and corresponding tests on because of the limitations of equations (10.14)
the simulation model. Differences between and (10.15) in describing the relationships
the steady-state liquid levels in the simulation between output flow and the liquid level in
model and in the real system, for smaller each tank. These equations apply to an ideal
values of input flow rate, are significant and simple orifice and the actual physical effects
vary slightly with operating point. Figures at the tank outlets do not agree exactly with
10.6 and 10.7 show some comparisons in this simplified model.
terms of dynamic tests. In Fig. 10.6 discrepan- With closed-loop control added to the real
cies between the model and system results system, and to the simulation model, the
are shown for a test involving quite a large agreement can be shown to be significantly

~NE
<J I,)

4
3

0 500 1000
sec

~ E
I,)

3
2

o 500 1000 t
sec

Fig. 10.7 Plots showing differences between model predictions and measured values for HI and H, for
small perturbation step tests carried out at one chosen operating point. The step input was applied at time
t =250 s. Note the initial steady-state errors between the simulation model variables and the corresponding
measurements and the increased steady-state error value for H, after the transient has died away.
162 Case study I
closer. This is important since the equipment tively simple nature of the system, and the
is intended to be used for investigations of variables which are accessible for measure-
closed-loop control. In simulation studies ment in the real hardware, make this
involving control system design applications an interesting but straightforward system
there is always particular interest in the for the application of external validation
overall robustness of the control system and methods.
the effect which modeling errors and uncer- Possibilities for using the simulation
tainties may have on the performance of the program TANKS. SLI as a basis for further
closed-loop system. Although control systems investigations on your own fall into two main
are normally designed using linearized areas. One obvious topic to consider would
models, simula,tion studies carried out on a involve investigation of the effect of changing
proposed closed-loop system using a non- the form of relationship used to describe the
linear model of the plant can often be highly discharge nonlinearities. A second area for
illuminating. Such an investigation may independent study would involve adding
reveal problems with the proposed design feedback control. Control system design
which would otherwise only come to light studies could be carried out using the linear-
during the commissioning and testing of the ized form of the mathematical model and dif-
real system. ferent controllers could then be compared in
terms of their sensitivity to changes in operat-
ing points or to changes in plant parameters,
10.4 DISCUSSION
such as the coefficients of discharge.
This case study provides an illustration of a
relatively simple nonlinear system which can
be modeled in a classical way using physical REFERENCE
laws and principles. The simulation model is 1. Wellstead, P.E. (1981) Coupled Tanks Apparatus:
easily implemented using either equation- Manual, TecQuipment International, Long
oriented or block-oriented tools. The rela- Eaton, Nottingham.
CASE STUDY II - AN AIRCRAFT
AUTOMATIC LANDING SYSTEM 11

11.1 INTRODUCTION system is known as the instrument landing


system (ILS). Basically this is a short-range
A fully automatic aircraft landing system pro- navigational aid which provides azimuth (i.e.
vides an interesting example of an engineer- horizontal) position information and vertical
ing system for which simulation techniques position data relative to a defined glide-slope
offer important advantages at the design path. The parts of the ILS system which are
stage. Although system evaluation through on the ground are the 'localizer' transmitter,
flight trials is very important in the develop- which provides azimuth approach data, the
ment of a complex control system of this kind, 'glide-slope' transmitter, which provides ver-
much useful work can be carried out through tical approach information, and 'marker'
simulation. Safety considerations are always beacons, which provide information on the
of paramount importance in aircraft systems, distance to the runway. The aircraft carries
and simulation experiments are both safer and the receiving antennae for the three signals
less costly than flight trials, especially in the transmitted from the ground and the asso-
initial stages of system testing and evaluation. ciated ILS receiver unit. There is also an indi-
Simulation techniques can also provide the cator display· device on the aircraft to show
engineer with valuable insight which is diffi- the pilot whether or not the aircraft is on the
cult to obtain by other methods. correct approach path.
Maneuvers of a conventional fixed-wing The localizer transmitter is positioned at
aircraft are normally achieved using control the far end of the runway relative to the
surfaces, such as the elevator, ailerons and approaching aircraft. It transmits a radio-
rudder, which apply forces and moments to frequency signal in a band from 108 MHz to
the vehicle and thus generate angular acceler- 112 MHz. Two signals are transmitted, one to
ations about the pitch, yaw and roll axes. the left and one to the right of the runway
Figure 11.1 shows these control surfaces and center-line, as shown in Fig. 11.2. The signal
defines the axes. Direct control of transla- transmitted to the left is modulated by a 90-Hz
tional velocity can be achieved only through signal, while that on the right is modulated
variation of engine thrust. Hence, in attempt- by a signal at ISO Hz. The transmission pat-
ing to follow a chosen trajectory in the sky, as terns for the two radio-frequency signals
in a landing system, control is achieved in- overlap along the runway center-line. When
directly through changes of pitch attitude, an aircraft is approaching the runway in line
roll attitude and heading. Attitude-control with the central axis, the ILS receiver picks up
systems are therefore of fundamental impor- the 90-Hz and ISO-Hz signals with equal
tance for flight-path control and thus for all strength. If the aircraft deviates to the left, the
forms of automatic landing system. strength of the 90-Hz signal will be greater
One form of radio system capable of than that of the ISO-Hz signal and, con-
feeding signals to the aircraft flight-control versely, if there is a deviation to the right, the
164 Case study II
normal
axis

longitudinal

lateral
axis

rudder
/
______-"7 elevators

Fig. 11.1 The longitudinal (roll), lateral (pitch) and normal (yaw) axes of a conventional fixed-wing air-
craft, together with the control surfaces which are used to apply control forces and moments to the
vehicle.

I
,~ .... ----- -
l' ------ . runway

centre
line __ ,7-~90_HZ=:JIiT<::::':' ______ ~ ••.transmitter
( 150 Hz ___

" ------
Fig. 11.2 Radio transmission patterns associated with the localizer transmitter within an instrument
landing system (ILS).
Simulation of an aircraft directional-control system 16S
ISO-Hz signal will be greater. The received tion to investigate a nonlinear closed-loop
signals provide the input for the indicator system model which could not be studied
display device and can also provide a refer- using analytical methods alone. No consider-
ence for the directional control system. The ation has been given to the question of model
linking of the ILS receiver output and the validation in this particular study. In an
autopilot reference input is carried out using application such as this, in which a simplified
a 'coupler' unit. model is used for the analysis and design of a
The glide-path transmitter is located near flight-control system, validation might well
the point of touchdown on the runway and be carried out by comparing the performance
transmits on a given frequency in the band of the reduced model with a more versatile
329.3 MHz and 33S.0 MHz. The radiated and complex model, which had been the
signal pattern is similar to that of the localizer subject of separate investigations in terms of
transmitter. When on the correct descent path model validity. An incremental approach has
the aircraft receives the 90-Hz and ISO-Hz been adopted in which the simulation model
signals with equal strengths and the hori- of the lateral beam guidance system is built
zontal pointer takes up a central position on up from a simpler linear model of a direc-
the ILS display device. In this case the ILS tional-control system. This allows verification
receiver can be linked to the longitudinal atti- to be carried out through comparisons with
tude-control system of the aircraft and pro- results from linear systems theory.
vides information which ensures that the
aircraft follows the glide path.
11.2 MODELING AND SIMULATION OF
This chapter is concerned with a case study
AN AIRCRAFT DIRECTIONAL-CONTROL
which involves the lateral beam guidance
SYSTEM
system, which uses the localizer signal to
align the aircraft with the runway. The In general, an uncontrolled aircraft has no
second major component of the landing inherent tendency to return to its initial
system, which ensures that the aircraft heading and roll attitude after some distur-
descends on the correct glide slope, is not bance from equilibrium. Thus, in the absence
considered in this simulation study. The two of any kind of flight-control system, the pilot
systems are very similar in terms of their must make corrections continually in order to
block diagram structures and, since they are maintain a required heading and attitude.
essentially independent in their operation, Directional-control systems can provide a
they can be investigated separately. In devel- means of ensuring that a reference heading is
oping a mathematical model for the lateral maintained without pilot intervention.
guidance system it is necessary first to One particular form of directional-control
describe the aircraft's directional control system will be examined in detail. In this
system. Preliminary investigation of this sub- case the system being controlled is the coor-
system, which is of central importance for dinated aircraft, which incorporates coup-
lateral guidance, provides an interesting ilJus- ling between the aileron and rudder. Such
tration of simulation methods for control coupling allows coordinated maneuvers to
system studies. be made, and only the overall transfer func-
Aircraft models are well understood and tion between the aileron input and the roll
well documented. Therefore, in this particu- angle need be considered. A block diagram
lar study, emphasis has been placed on the for the control of heading is shown in Fig.
process of building up a simulation program 11.3. It may be seen from this that the system
to represent a system provided in block involves three feedback loops. The outer-
diagram form and on the use of the simula- most loop involves the feedback of the
166 Case study II

Fig. 11.3 Block diagram of an aircraft directional-control system.

variable of primary concern, which is the where KA is a gain factor and TA is a time con-
heading angle. This feedback is provided stant associated with this highly simplified
through the action of a directional gyro- description of aircraft lateral dynamics.
scope. The other two loops provide sec- Similarly, in terms of the roll angle, ~, for
ondary feedback signals which are needed to an aileron deflection angle, oa' we have a rela-
ensure that the overall system has an accept- tionship of the form
able dynamic response. The block diagram
shows that the second pathway involves roll KA
(11.2)
angle feedback, via the vertical gyroscope, s(1+sTA )
while the innermost loop has roll rate feed-
The control-surface actuation system can be
back. It should be noted that the aircraft
described approximately by a transfer function
description adopted here is a highly simpli-
fied one, and that a detailed description of a 1
(11.3)
practical flight-control system would involve 1+57
a significantly more complex block diagram.
Further details of aircraft flight mechanics where 7 is a time constant.
modeling and of flight-control systems may The three transfer functions given above,
be found, for example, in the texts by and which appear in the block diagram, may
Blakelock [1] and McLean [2]. The reference be converted readily to a state-space form of
quantity is the heading angle commanded model using the methods discussed in Chapter
by the pilot or provided as an electronic 3. This state-space description has the form
signal from some other system within the shown in equations (11.4), (11.5) and (11.6).
aircraft. The various gain constants associ-
dp 1 KA
ated with the feedback pathways in this -=--p+-o (11.4)
system (K d , Kv and K) are chosen at the
dt TA TA a

d~sign stage to ensure that steady-state


d~
and dynamic performance specifications Tt=P (11.5)
are met.
The transfer function of the coordinated
aircraft, relating the roll rate, p, to the aileron
dOa =-1.0 +[Link] (11.6)
dt 7 a 7
deflection angle, oa' has the form
An additional relationship is needed to
(11.1) allow the heading angle to be related to the
roll attitude. For small angles of roll, ~, it may
Simulation of an aircraft directional-control system 167
DYNAMIC while the additional gain constants involved
DERIVATIVE
PSID=PHI*G/UO in the feedback loops are read in by means of
PSI=INTEG(PSID,PSIO) an ACCEPT statement. The program has been
PHIC=(PSIC-PSI)*AKD
EV=PHIC-PHI written in this way because interest is focused
ES=EV*AKV-PHID*AKR
DAD=(ES-DA)/TAW particularly on the flight-control system and
DA=INTEG(DAD,O.O) the effect of the gain in each of the three feed-
Q=(AKA*DA-PHID)/TA
PHID=INTEG(Q,PHIDO) back loops on the overall performance. Using
PHI=INTEG(PHID,PHIO)
DERIVATIVE END an ACCEPT statement for the parameters of
TYPE T,PSIC,PHID,PHI,PSI particular interest simplifies experimentation.
IF(T-15.0)10,10,12
10 DYNAMIC END Initial conditions are also established from
12 STOP
END data provided by the user through ACCEPT
statements, as is information concerning the
Fig. 11.4 Listing of the DYNAMIC and TERMINAL magnitude of the reference heading. The
segments of the SLIM program ALASH. SLI for SLIM source program would need to be
simulation of an aircraft directional-control
system. Variable names in the program are, in
edited to perform other simulation experi-
most cases, very similar to the corresponding vari- ments for different values of the aircraft para-
ables of the mathematical model. The complete meters such as KA or T. The choice of
source program may be found on the diskette. communication interval, CINTERVAL, of 0.1
allows graphical output to be provided
having sufficient resolution in terms of the
be shown (e.g. ref. 2) that the angular velocity time axis to show all transient events of inter-
of the aircraft in terms of heading, d!f;j dt, can est. It should be noted that, although the
be related to the forward velocity, Uo, and the program includes MINTERVAL, MERROR and
roll angle, cjJ, by the equation XERROR statements, the values used are all
default values and the program would give
(11.7) identical results if these lines of code were
omitted. An experiment duration time of 15 s
where g is the gravitational constant has been defined in the program. This could
Three additional algebraic equations are easily be made a variable and could be
necessary to define the structure of the feed- defined by the user at runtime through an
back system. These are as follows: additional ACCEPT statement in the initial
region of the program.
(11.8) Sample results, in terms of time histories of
heading angle (!f;) and roll angle (cjJ) follow-
(11.9)
ing a step change of heading reference (!f;e), of
(11.10) magnitude 0.15 rad, are shown for three
values of the directional gyroscope gain (K d )
Typical parameter values for this system in Figs 11.5, 11.6 and 11.7. The results in
are as follows: Fig. 11.5 show that, for the nominal value of
TA = 2.0 s; KA = 1.0; T = 0.1 s; g = 9.81 m S-2; directional gyroscope gain factor (K d = 2.0),
UO= 60 m S-1; K, = 2.5, Kv =2.5; and Kd = 2.0. the response of the system to the step input is
Figure 11.4 shows part of a simple SLIM stable, rapid and shows no tendency to oscil-
program for simulation of this system. The late in terms of the heading variable. As
complete source program (ALAS-. SLI) may could be expected, there is a marked tran-
be found on the diskette. The parameter sient in roll angle but this variable returns to
values describing the aircraft itself are zero as the aircraft attains the desired
assigned in the initial region of the program, heading. A reduced value of the directional
168 Case study II
~
-s:
X1& r-~
2

-------------------------

, /

o~ ____~ ____~ __~=


o 2 4 6 8 10 12 14
t
Is)

Fig. 11.5 Results from a simulation experiment on the aircraft directional-control system showing time
histories of the heading angle (dashed line) and the roll angle (continuous line) in response to a
demanded step change of heading of 0.15 rad. The value of the directional gyroscope gain factor (Kd ) in
this case was 2.0, while the parameters K/ and Kv were both 2.5.

~
-s: x10~r-
6

o~-
o 2 4 6 8 10 12 14
t
Is)

Fig. 11.6 Results obtained from simulation of step test on directional-control system for a directional
gyro gain factor of 0.5. Values of the other parameters read in from the input data file were the same as
for the case given in Fig. 11.5.

gyroscope gain factor (0.5) produces a very in Fig. 11.7, where a value of Kd of 8.0 gives a
sluggish response (Fig. 11.6) in which the highly oscillatory response, which is again
required heading is not attained within the unsatisfactory for a system of this kind.
15-s duration of the simulation experiment. Although the mathematical tools of linear
The performance, in this case, is clearly in- systems analysis could be applied very
ferior to that of the system with the higher readily to a linear system such as this, the use
value of gain. However, increasing the gain of a simulation can provide opportunities for
factor can produce other problems, as shown additional understanding, particularly in
Simulation of a lateral beam guidance system 169
~
-s..
X101
6
4
2
0
-2
-4
-6
0 2 4 6 8 10 12 14
t
(8)

Fig. 11.7 Results similar to those of Figs 11.5 and 11.6 for a directional gyro gain factor of 8.0.

terms of parameter sensitivity analysis of the Figure 11.8 is a block diagram of the lateral
kind illustrated by these results. Linear beam guidance system which must be inter-
theory also provides opportunities to verify preted in conjunction with Fig. 11.9. This
the simulation program. In this case, for shows the geometry of the situation and
example, the simulation could be used very defines some of the variables used in the
readily to establish stability limits in the block diagram.
directional-control system and selected sets The variable «/Ifefl which represents the
of results from the simulation could be com- heading to be followed, would be set by the
pared with results obtained by applying pilot and, for simplicity, this reference value
standard stability tests from control theory, is taken to be zero in the equations which
such as Nyquist's criterion. follow. An error angle, A, is related to the
lateral displacement, y, and the range, R, by
11.3 MODELING AND SIMULA nON OF A the equation
LATERAL BEAM GUIDANCE SYSTEM
(11.11)
The lateral beam guidance system is based
upon the directional-control system described Hence, for small angles
in section 11.2. In the lateral guidance
application the directional reference input, (11.12)
«/Ie' is derived from the ILS receiver output.

aircraft
&
lateral
auto ilot

Fig. 11.8 Block diagram of the lateral beam guidance system.


170 Case study II

,,
,"
R -~ ",,"
L.. "'aircraft
r'-"=_:~7.;?tC1 ___-,.~ ___ centre
line

Fig. 11.9 Geometry of lateral beam guidance.

Also, it follows from the geometry of Fig. 11.9 where Gc is the gain of the coupler.
that the rate of change of displacement, Combining the block diagram of Fig. 11.8
dy / dt, is related to the aircraft velocity, Uo' by with the block diagram of the directional
the equation flight-control system gives the complete
structure of the lateral beam guidance system,
dy =Uo sin(1/I - I/Iref ) (11.13) as shown in Fig. 11.10.
dt The parameter set for the lateral beam gUid-
Thus, for a small angle 1/1 and for a zero value ance system includes all of the parameters of
of reference heading (I/Ir)' it follows that the directional flight-control system of section
11.2 and, in addition, the coupler gain para-
dy 0:: U ./, (11.14) meter values for the outer loop of Gc = 8.0. In
dt 0."
some cases the coupler involves a transfer
The signal from the localizer course correc- function of a more complex form, incorporat-
tion receiver is approximately proportional in ing proportional plus integral control in a
magnitude to the angle A and, for the case transfer function of the form
where Are! is zero (see Fig. 11.8), the output of
the coupler is given by Gc(s) = G{1 + ~I ) (11.16)

G JL (11.15) This coupler transfer function provides a con-


"'c
./, 0::
C R troller that has a form which is very common

COUPLER
+

Fig. 11.10 Block diagram showing the detailed structure of the lateral beam guidance system.
Simulation of a lateral beam guidance system 171
in many other control system applications. 1t' DYNAMIC
DERIVATIVE
is known as a proportional plus integral con- YD=UO*PSI
troller and can ensure zero steady-state errors Y=INTEG(-YD,YO)
R=INTEG(-UO,RO)
in the presence of a steady external distur- ALAMB=Y/R
PSIC=GC*ALAMB
bance, such as a cross-wind in this instance. PSID=PHI*G/UO
The parameter K] is taken as zero in the exam- PSI=INTEG(PSID,PSIO)
PHIC=(PSIC-PSI)*AKD
ples considered here. EV=PHIC-PHI
Figure 11.11 shows the DYNAMI C segment ES=EV*AKV-PHID*AKR
DAD=(ES-DA)/TAW
of a SLIM program for simulation of the DA=INTEG(DAD,O.O)
Q=(AKA*DA-PHID)/TA
lateral beam guidance system. The complete PHID=INTEG(Q,PHIDO)
program (AILS. SLI) is provided on the PHI=INTEG(PHID,PHIO)
DERIVATIVE END
diskette. The parameter values for the aircraft RP=R/I000.0
TYPE T,PHI,PSI,Y,RP
and directional-control system are assigned in IF(T-90.0)10,10,12
the initial region together with the coupler 10 DYNAMIC END
12 STOP
gain parameter which is input through an END
ACCEPT statement along with the aircraft
Fig. 11.11 Listing of the DYNAMIC and TERMINAL
velocity. Once again, initial conditions, in segments of a SLIM program (AILS. SLI) for sim-
terms of the initial range, initial deviation ulation of the lateral beam guidance system.
from the runway center-line, initial heading Variable names in the program are, in most cases,
and aircraft velocity, are also input through similar to the corresponding variables of the math-
ACCEPT statements in the initial region. Initial ematical model. The complete program may be
conditions for other variables of the direc- found on the diskette.
tional flight-control system are all set to zero.
The range is scaled to provide values in kilo- program with additional statements to allow
meters instead of meters. This is done mainly for the presence of the outer feedback loop
to make the labeling of the range axis more involving the coupler.
convenient. The structure of the derivative Figures 11.12, 11.13 and 11.14 show the
region is essentially the same as that for the response of the system in terms of plots of the
directional flight-control system simulation lateral deviation, y, versus time for three

10

-5 \~
o 20 40 60 80
t
Is.)

Fig. 11.12 Simulation results from AILS. SLI showing response of the lateral beam guidance system in
terms of the deviation, y, versus time for a coupler gain factor G, of 8.
172 Case study II
different values of the coupler gain (Gc = 8.0, characteristic of a truly unstable system. This
Gc = 16.0 and Gc = 32.0). In each case the behavior is a result of the nonlinear nature of
initial position of the aircraft is 6000 m from the lateral beam guidance system. Examin-
the point of touchdown on the runway and ation of Fig. 11.9 suggests that the system
15 m from the center-line in terms of lateral becomes steadily more sensitive as the air-
error. For the two lower values of coupler craft approaches the transmitter because the
gain the trajectory is clearly of a satisfactory angle A increases for a given lateral error, y,
form and the final lateral error is zero or has as the range, R, becomes smaller. This is
a very small value. With the largest of the reflected in Fig. 11.8 by the presence of a
three gain factors the results show a trajec- block involving a gain factor inversely pro-
tory which is clearly unstable. More detailed portional to R. The loop gain in the outer
examination of this case (Fig. 11.14) shows loop of the feedback system therefore in-
that the initial part of the trajectory involves a creases as the range becomes smaller, and
damped oscillation and only the later part of this explains the type of behavior shown in
the response shows a diverging oscillations Fig. 11.14. Although stable for large values

10

o
-5

o 20 40 60 80
t
Is)

Fig. 11.13 Simulation results for the lateral beam guidance system model for G, = 16.

>-S
30

20

10

-10

0 20 40 60 80
t
Is)

Fig. 11.14 Simulation results for the lateral beam guidance system model for G, = 32.
References 173
of R, the system becomes unstable as R the performance of the model when subjected
decreases. In this case, linear theory would to external heading disturbances. The modifi-
provide relatively little information about the cations to the SLIM program provided are
complex nature of the system and could not relatively minor for both these cases [3].
be used to predict the form of the response
for the situation considered in this investiga-
11.4 DISCUSSION
tion, which involves a large change in R.
Another fact of considerable importance is This case study involves the modeling and
that the performance of both the directional simulation of a relatively complicated non-
flight-control system and the lateral beam linear multiloop feedback control system.
guidance system depend upon the approach Mathematical models of fixed-wing aircraft
velocity Uo• The performance is influenced are well established and their limitations are
considerably by this quantity and also by the well understood and documented. Little con-
initial conditions. Unlike a linear system in sideration is therefore given in this example
which the nature of the system response is the to questions of model validity. Emphasis is
same for different initial states, the lateral given instead to the control systems aspects
beam guidance system model has a behavior of the simulation model and to the use of sim-
which depends to a considerable extent on ulation experiments to reveal the complex
the initial lateral deviation, aircraft velocity and highly nonlinear nature of the system
and initial range. Investigation of the model behavior. Similar insight could not be
behavior for different sets of initial conditions obtained from analytical studies based on
is left to the reader as an exercise using the linearized models. As with the system in
lateral beam guidance model file provided on Chapter 10, a nonlinear computer simulation
the accompanying diskette. model provides a basis for very valuable
In a practical system of this kind extensive testing of the control system prior to any
use is made of gain-scheduling techniques, practical implementation in terms of real
with the coupler gain factor being adjusted hardware. This is particularly important in a
according to range information. This gain- safety-critical application such as aircraft
scheduling feature of the real system over- flight control.
comes the major variations of performance
with range. This has not, of course, been
included in the simple model being consid- REFERENCES
ered here. However, the simulation does 1. Blakelock, J. (1991) Automatic Control of Aircraft
provide opportunities to investigate the very and Missiles, 2nd edn, John Wiley, New York.
interesting nonlinear dynamics of the system 2. McLean, D. (1990) Automatic Flight Control
with constant coupler gain and could easily be Systems, Prentice-Hall, Hemel Hempstead.
3. Murray-Smith, D.J. (1983) Use of an aircraft
extended by the reader to include some form lateral beam guidance system simulation in
of scheduled coupler gain. Similarly, the intro- the teaching of control engineering, in
duction of integral control in the coupler is an Proceedings of the 1st European Simulation
exercise which could be carried out without Congress: ESC83, 1983, Aachen (ed.
difficulty by any reader interested in assessing W. Ameling), Springer, Berlin, pp. 337-42.
CASE STUDY III - RESPIRATORY
GAS-EXCHANGE PROCESS SIMULATION 12

12.1 INTRODUCTION AND BACKGROUND membrane known as the alveolar mem-


PHYSIOLOGY brane), and processes of internal respiration,
which involve exchange between blood and
Mathematical modeling and computer simu- body tissue.
lation techniques are being used increasingly Oxygen transport between the lungs and
in the field of respiratory physiology and the tissues involves the hemoglobin protein of
medicine. Aspects of the respiratory system the red blood cells, while carbon dioxide is
to which simulation methods have been transported both in chemically combined and
applied include, for example, the study of dissolved forms in the plasma. Passive dif-
lung mechanics and gas flow in the airways, fusion phenomena are responsible for move-
the investigation of gas-exchange phenomena ment of the gas molecules across the alveolar,
and the highly complex physiological pro- capillary and cell membranes.
cesses involved in the control of breathing. The cyclic process of ventilation is respons-
The objectives, as in many other areas of ible both for the inspiration of fresh air and
physiology, may include advancing physio- the expiration of gases accumulating in the
logical and clinical knowledge through the lungs. The partial pressure of oxygen is
development of validated quantitative descrip- higher in the gas spaces of the lungs than in
tions, or the development of methods for the venous blood, but for carbon dioxide the
indirect estimation of physiological quantities converse is true with a pressure gradient in
such as airway resistance, or the development the opposite direction. The processes of
of aids for training and education. external respiration depend upon these
Human body cells obtain energy through partial pressure differences. The pattern of
chemical reactions involving oxygen and ventilation is controlled through the dia-
produce carbon dioxide as an end product. phragm and intercostal muscles. Specialized
The respiratory system is made up of the neurons within the medulla give outputs
lungs, the airways leading from the mouth to which determine the level of nervous activ-
the lungs and the chest structure involved in ity associated with these muscles. The
the movement of gases into and out of the number of active motor units in the muscles
lungs. It maintains an appropriate level of influences the depth of ventilation, while the
acidity in the extracellular fluid by removing time intervals between bursts of motor activ-
excess carbon dioxide and providing an ad- ity determine the breathing rate. Control of
equate oxygen supply. These gas-exchange the complete system appears to be based
processes are categorized as processes of upon a number of feedback loops, some
external respiration, concerned with exchange of which involve chemoreceptors, which
between blood and air at the lungs (via a thin monitor levels of oxygen and carbon dioxide
176 Case study III
at a number of different sites within the atory processes difficult to grasp because of
body. Further background information about the large number of interacting variables,
the physiology of the respiratory system such as ventilation, perfusion and the gas
may be found in many textbooks (e.g. ref. 1) concentrations in air, blood and tissues. The
and additional details about pulmonary model described in this section has been
gas-exchange phenomena in an excellent developed for teaching some of the elemen-
and easily understandable monograph by tary concepts of respiratory gas-exchange
West [2]. processes. It is a model which neglects the
longer term dynamics of the tissues and cir-
culation and must therefore be applied with
12.2 MODELING OF PULMONARY
caution. Models of similar structure have
GAS-EXCHANGE PROCESSES
been used for other pulmonary applications
The use of dynamic models based upon dif- in which longer term dynamic effects can
ference or differential equations is well estab- also be neglected and have been subjected to
lished in respiratory physiology. Many extensive validation studies using system
clinical tests of lung function are based on identification methods. One particular form
simple mathematical models in which sim- of model of this kind, involving carbon
plifying assumptions may have been applied dioxide exchange, has provided a basis for
in order to provide analytical solutions. The a noninvasive method for estimation of
use of dynamic system simulation techniques cardiopulmonary quantities.
reduces the need for obtaining closed-form A simple model of carbon dioxide trans-
solutions in some circumstances. This has led port, developed by Pack and others [3-6],
to a re-examination of established models and has been used in the development of a teach-
associated measurement techniques in recent ing simulation to illustrate simple concepts
years [3]. of pulmonary gas exchange [6]. Abnormal or
Variables such as gas flow rate and concen- diseased conditions can be represented
tration levels at the mouth are accessible for within the simulation, which is based upon a
continuous and direct measurement in model structure of the type suggested by
human subjects. Testing and validation of Murphy [7] involving three lung compart-
pulmonary gas-exchange simulations can ments. These are the dead space (volume V)
therefore be approached in a relatively and two alveolar compartments (volumes
straightforward fashion by making direct V A1 and V AZ with blood flows <21 and <2z
comparisons between chosen variables of the respectively) in which gas exchange takes
simulation model and the corresponding place. The model also incorporates a tissue
quantities measured in the real system. compartment (volume V TC ) which, if appro-
As in all applications of modeling and priate for the circumstances under consider-
computer simulation methods, the way in ation, may be omitted from the model. If no
which the simulation is to be used and the tissue compartment is required, the model
reasons for developing the simulation structure is modified to represent a situation
strongly influence the form of the math- in which mixed venous blood flows to the
ematical model and the boundaries for the lung compartment with a constant and pre-
system description for that model. One inter- determined carbon dioxide partial pressure.
esting application of gas-exchange simu- Figure 12.1 shows the structure, variables
lations is in the teaching of respiratory and main parameters of this simple model.
physiology and associated clinical subjects Inclusion of the tissue compartment intro-
such as anesthesia. Students often find con- duces a metabolic carbon dioxide production
cepts associated with the dynamics of respir- parameter eM.).
Modeling of pulmonary gas-exchange processes 177

COMMON
DEAD SPACE

ALVEOLAR

-
BY - PASS

TISSUE COMPARTMENT

-- --
Fig. 12.1 A simplified model of the pulmonary gas-exchange processes for carbon dioxide.

For this model structure the respiratory 02.1)


cycle can be regarded as consisting of three
stages:
and
1. Stage 1: inspiration of dead space gas to I

the alveolar compartments, occurring f V(t)dt < V D 02.2)


when the conditions 11
178 Case study III
are satisfied simultaneously. Here tl de- are the slope and intercept, respectively, of
fines the time of the start of the inspiration. the physiological dissociation curve for carbon
2. Stage 2: inspiration of atmospheric air to dioxide (see, for example, refs. 2 and 7 for
the alveolar compartments, for which the further details).
conditions are The quantities 51 and 52 allow for changes
in the gas transfer occurring in the three dis-
(12.3) tinct stages of the breath cycle and introduces
corresponding changes in the model. In terms
and of the three stages defined above
51 = 1 for stage 1
(12.4)
51 = 0 for stage 2 and stage 3
52 =1 for stage 2
52 = 0 for stage 1 and stage 3.
3. Stage 3: expiration, for which the relevant
condition is simply given by The second alveolar compartment receives
a fraction (1 - k) of the ventilation and is
V(t) < 0 (12.5) described by the following equation, which is
similar in structure to equation (12.6):
The differential equation for alveolar com-
partment I, which has proportion k of the VA2 dPA2 = (1-k)Sl V (P -P )
ventilation, is as follows: B - W dt B- W D A2

~ dPAI = kS 2V (P. -P ) + (1-k)S2


V (P.1 - P)
A2
B- W dt B _ W D Al B-W

+ kS2V (P. _ P ) +Q2[b(PTC -PA2 )+a d ] (12.7)


B-W I Al

Here the variable PA2(t) represents the partial


+CMb(PTC -PA1 )+ad] (12.6)
pressure of carbon dioxide in alveolar
compartment 2.
The left-hand side of this differential equation
The third differential equation represents
represents the rate of change of mass of
the mass balance condition for the tissue com-
carbon dioxide in this alveolar compartment.
partment. It has the form
The variable P A1 (t) is the partial pressure of
carbon dioxide in alveolar compartment 1. dPTc • •
The terms on the right-hand side represent bVrc - - =M -QI[b(Prc -PAI)+ad]
dt
the mass transfer rate of that gas from the
dead space compartment and from the tissue - Q2 [b(PTC - PA2 ) + ad] (12.8)
compartment. The variables PD(t), PTC(t) and
p[(t) are the partial pressures of carbon This indicates that the rate of change of mass
dioxide in the dead space compartment, in of carbon dioxide in the tissue compartment
the tissue compartment and in the inspired is equal to the difference between the
gas mixture respectively. The factor (B - W) is metabolic production of carbon dioxide and
a constant for any given experimental situa- the transfer of that gas to the alveolar
tion since B is the barometric pressure and W compartments.
is the partial pressure of water vapor at a The partial pressure of carbon dioxide in
temperature of 37°C. The constants b and ad the dead space, PD(t), is related to the partial
The computer simulation 179
pressures in the two alveolar compartments For example, for VD =0.11, T =4.0 s and VI =
by the equation 0.5 1, it is easy to show that

V(t)~
(12.9)
0.4 Sin(; )
Provision can also be made within the model
equations for a bypass pathway through and that the time required to fill the dead
which a proportion of the blood leaving the space (7") is 0.6 s. The three stages of the
tissue compartment avoids both of the alveo- breath cycle are therefore as shown in
lar compartments. Such a bypass is mainly of Fig. 12.2 for this particular case.
interest for the simulation of abnormalities
and has not been included in the set of equa-
tions presented here.
12.3 THE COMPUTER SIMULAnON
The ventilation, which appears in the equa-
tions describing the alveolar compartments Let us now start considering the task of
and in the relationships defining the three implementing this simulation model using an
stages of the breath cycle, is assumed to be equation-oriented continuous system simu-
sinusoidal in form and is given by the lation package such as SLIM or ACSL. The
equation model equations are already in a convenient
form for simulation and involve a set of three
V(t) =Vrnax sin(2rrft) first-order ordinary differential equations and
additional algebraic relationships. However,
where V max is the amplitude of the sinusoid there is a complication in that the equations
and f is the frequency of breathing. The ven- involve products of variables (e.g. the
tilation level may be defined in terms product of the ventilation and [PD(t) - PA1 (t}]}.
of the tidal volume, Vp This is the volume In addition, there are some rapidly varying
of gas inspired and expired during each terms in the equations owing to the presence
breath cycle, and it is a simple process to of the quantities 51 and 52' which switch
relate this to the amplitude of the sinusoid between values of unity and zero according
above, since to the stages of the breathing cycle. The

f
2 IU
~
VT =tidal volume = V(t)dt (12.10) .... -
::;)-:=

o
o > 0.4 --

where T is the period of one breath. It is pos-


sible to calculate the time required for each of
the first two stages of the breath cycle by TIME
(s)
determining the time taken to fill the dead
space with inspired gas from the start of
inhalation. If this time is 7" it follows that 1 2 3
STAGES

f
T
Fig. 12.2 The three stages of the breath cycle for
V(t)dt =VD (12.11) the case of a 4-s breath cycle period, tidal volume
of 0.5 I and a dead space volume of 0.1 1.
180 Case study III
generation of the switching quantities ward, apart from the additional lines of code
requires an extra integration function in addi- needed to generate the switching quantities.
tion to those needed to represent the actual One unusual feature, which could be of value
compartments. Stiffness is not a problem in in demonstrating the effect of changes in
this model, and no difficulties arise over the quantities such as ventilation or blood flow
choice of an integration method. A number rate, is the inclusion of facilities for applying
off standard integration techniques have been step changes of parameters during a simula-
found to give satisfactory results. tion run, and this requires additional state-
The INITIAL section of the simulation ments within the DERIVATIVE segment.
program can be used to establish parameter In simulation languages such as ACSL a
values and other quantities such as the initial simulation user can readily alter constants
conditions for the partial pressures in the which appear in the program using runtime
lung and tissue compartments. The commu- commands without having to edit the simu-
nication interval must be chosen to provide lation program or change data files. As
an adequate number of samples within the explained in Chapter 6, this is a very useful
minimum expected breath cycle period. In facility and is ideal for a teaching environ-
this connection it must be remembered that ment since it provides a means of separating
the objective of this simulation model is to the model itself from the experiments to be
demonstrate gas-exchange phenomena for a carried out on it. Students can use the simu-
wide range of normal and abnormal condi- lation very effectively by employing such
tions. Parameters of the model will be set to a commands to carry out a variety of tests on
variety of different values, and Table 12.1 the model for as many parameter sets and
gives appropriate ranges for the parameters initial conditions as is necessary.
most likely to be adjusted by the user. Figure 12.3 shows relevant sections of a
The structure of the DYNAMIC and DERIV- SLIM listing of a program implementing the
ATIVE sections of the program is straightfor- gas-exchange model described above. The

Table 12.1 Parameter values for the gas-exchange model

Physiological quantity Model quantity Suggested range of values

Volumes of alveolar VAi (l) 0.5-6.0


compartments
Effective tissue volume V TC (l) 1-11
Dead space volume V D 0) 0.05-0.20
Tidal volume VT0) 0-1.5
Blood flow to alveolar
compartments QiO min-I) 0-10
Metabolic production MO min-I) 0.1-0.5
Slope of dissociation curve
for carbon dioxide in blood b 0.00425
Inspired gas partial pressure P,(mmHg) 0-40
Barometric pressure B (mmHg) 760
Proportional ventilation k 0.0-0.5
Initial value of alveolar
compartment partial pressure P Ai(O) (mmHg) 25-45
Initial value of tissue
compartment partial pressure PT(O) (mmHg) 40-50
The computer simulation 181
DYNAMIC
DERIVATIVE
PP=(B-47.0)*BM*QDOT1*(PT-PA1)
PPP=(B-47.0)*BM*QDOT2*(PT-PA2)
DV=A*SIN(W*T)
PD=AK*PA1+BK*PA2
C
C The three stages of the respiratory cycle
C
IF(DV-0.0)1,2,2
C stage 3
1 Sl=O.O
S2=0.0
GOTO 100
2 IF(V-VD)3,3,4
C stage 1
3 Sl=1.0
S2=0.0
GOTO 100
C stage 2
4 Sl=O.O
S2=1.0
100 DPA1=(1./VA1)*(Sl*AK*DV*(PD-PA1)+S2*AK*DV*(PI-PA1)+PP)
DPA2=(1./VA2)*(Sl*BK*DV*(PD-PA2)+S2*BK*DV*(PI-PA2)+PPP)
DPT=(1./(BM*VTC»*(AMDOT-QDOT1*BM*(PT-PA1)-QDOT2*BM*(PT-PA2»
PA1=INTEG(DPA1,PA10)
PA2=INTEG(DPA2,PA20)
PT=INTEG(DPT,PTO)
V=INTEG(DV,VO)
DERIVATIVE END
TYPE T,DV,PA1,PA2,PT
IF(T-TMAX)10,10,12
10 DYNAMIC END
12 STOP

Fig. 12.3 DYNAMIC segment of a SLIM program for simulation of the gas-exchange model. Variable
names in the program have been chosen to match the corresponding variables of the mathematical model
as closely as possible.

source of the SLIM program may be found on overall results credible? What is the range of
the diskette (LUNGS. SLI). The set of parame- conditions, if any, for which the simulation
ters used (LUNGS. IN) may be regarded as can be used to make useful predictions?
typical of a 'normal' adult human subject. External validation studies have been
Some selected results obtained using this carried out involving comparisons of simula-
SLIM program are shown in Figs 12.4, 12.5, tion results for a particular case of the model
12.6 and 12.7. Similar results may, of course, described above, with experimental records
be obtained from XANALOG and SIMULINK from a human subject. The essential differ-
simulation models, and Fig. 12.8 shows the ence between the simulation used in this case
XANALOG block diagram which is equiva- and the model equations given above is that,
lent to the equation-oriented program listings. in order to allow direct comparisons to be
Questions should always be asked about made with the experimentally measured
the validity or otherwise of any simulation record, the simulation cannot be driven using
model. Clearly a model structure of the kind a sinusoidal ventilation pattern. Instead, ven-
shown in Fig. 12.1 is a highly simplified rep- tilation data logged by computer during an
resentation of a very complicated biological experiment on a human subject must be used
system. Are the simplifying assumptions as an input to the simulation. The model has
used in deriving the model equations justi- been successfully validated in this way for
fied? Does the simulation program accurately normal human subjects and has provided a
represent the model equations? Are the basis for the successful development of a
182 Case study III

- -_. _---- . ----z


50~ ,
! -~ ... --
-_..---"'-
~L _______ --.. - _-J----
45 ~
~
40~

35
~
o 50 100 150 200
t
(5)
Fig. 12.4 Response of the simulation model to a step change of carbon dioxide level in the inspired gas
mixture from 0 to 20 mmHg. The continuous curve shows the partial pressure of carbon dioxide in each
of the alveolar compartments, while the dashed line shows the corresponding partial pressure within the
tissue compartment. The carbon dioxide input is applied after 30 s. Note the cyclic nature of the alveolar
partial pressure record, which is caused by the periodic breathing pattern.

-l
a,.. E 38
- E
34

o 50 100 150
t
(5)
Fig. 12.5 The alveolar compartment partial pressure in response to simulated breath holding for a period
of 45 s (from t = 30 s to t = 75 s).

noninvasive method for estimating cardio- piratory 'plant' in simulation studies of the
pulmonary quantities such as the effective control systems responsible for the regulation
lung volume and the total blood flow and control of breathing [11].
through the lungs [8, 9]. The model has been
found to be of more limited value for abnor-
12.4 DISCUSSION
mal subjects, but can nevertheless provide
valuable qualitative insight [10] and has pro- This case study is of particular interest as an
vided a basis for the representation of the res- example of the use of simulation techniques in
Discussion 183

o 50 100 150 200


t
(5)
Fig. 12.6 Simulation results in response to changes in the ventilation pattern (parameter k). Both alveolar
compartments initially have identical parameters but at t = 30 s the ventilation distribution is suddenly
changed so that one compartment has a high ventilation level relative to the blood flow (hyperventila-
tion) while the other receives no ventilation (a condition similar to breath holding). The level of carbon
dioxide rises in the unventilated compartment and falls rapidly in the compartment which is being
hyperventilated. Restoration of the balanced ventilation pattern at t = 75 s causes the carbon dioxide
partial pressure levels to return to their original values.

o 50 100 150 200


t
(5)
Fig. 12.7 Simulation results showing the effect of a change in the blood flow distribution to the alveolar
compartments. At time t =30 s the flow to one compartment is halved while that to the other is increased
by 50%. Restoration of the original balanced blood flow condition causes carbon dioxide levels to return
to an equilibrium condition.

biomedical engineering. Biological experimen- gation of complex problems in this field.


tation often presents great practical problems Simulation does not, of course, eliminate the
or may involve serious ethical issues. need for experimentation but can ensure that
Simulation tools, properly used, provide a experiments are designed to extract the
powerful additional approach for the investi- maximum information. In some cases, this
184 Case study III

QDOT1

PA2 PT

QDOT2

LUNGPA2_MDL

Fig. 12.8 XANALOG simulation model diagram for the gas-exchange model. Note the use of submodels
for the three compartments, for the ventilation (DV) and for the calculations associated with the switch-
ing quantities (51 and 52).

may reduce significantly the number of experi- in terms of amplitude and frequency, on the
ments required to obtain meaningful results. carbon dioxide concentration within the
Application areas in which simulation-based various compartments. It can also be used to
investigations involving lung gas-exchange investigate the sensitivity of the model vari-
models are of potential value include the ables to the parameter k which determines
development of automatic control systems for how the ventilation is distributed between the
the administration of anesthetic gases, the two alveolar compartments (e.g. Fig. 12.6).
development of improved tests of lung func- Similarly, the blood flow rate parameters Ql
tion and the noninvasive monitoring of car- and Q2 can be varied to simulate abnormalities
diopulmonary quantities. The model described in the pattern of lung perfusion (e.g. Fig. 12.7).
in this study is compartmental in nature and The effects of other parameters such as the
only some of the compartments involve quan- tissue compartment volume V TC and the
tities which can be measured directly in the volumes of the alveolar compartments, VAl
human subject. Issues of external validation and V AU are also of interest.
are therefore of special interest.
The SLIM program LUNGS. SLI can be used
to investigate the behavior of this gas- REFERENCES
exchange model for a wide range of different 1. Vander, P.J., Sherman, J.H. and Luciano,
conditions. It can be used, for example, to D. (1970) Human Physiology, McGraw-Hill,
establish the effect of the ventilation pattern, New York.
References 185
2. West, J.B. (1965) VentilationfBloodFlow and 7. Murphy, T.W. (1969) Modelling of lung gas
Gas Exchange, Oxford University Press, exchange - mathematical models of the lung:
Oxford. the Bohr model, static and dynamic ap-
3. Emery, B. and Pack, A.1. (1971) An experi- proaches. Mathematical Biosciences, 5,427.
mentally verified model of the gas exchange 8. Ferguson, D.R, Mills, RJ., Moran, F., et al.
properties of the lung, in Computers for (1973) Estimation of the parameters of a
Analysis and Control in Medical and Biological lung model with clinical applications, in
Research, IEE Conference Publication No. 79, Identification and System Parameter Estimation
Institution of Electrical Engineers, London, (ed. P. Eykhoff), North-Holland, Amsterdam,
pp.130-34. pp.213-19.
4. Pack, A.I., Emery, B., Moran, F. and Murray- 9. Bache, RA., Gray, W.M. and Murray-Smith,
Smith, D.J. (1974) Computer models of gas OJ (1981) Time-domain system identification
exchange processes in ventilation, in applied to non-invasive estimation of cardio-
Ventilatory and Phonatory Control Systems (ed. pulmonary quantities. lEE Proceedings, Part 0,
B. Wyke), Oxford University Press, Oxford, 128,56-64.
pp.227-47. 10. Bache, RA. and Murray-Smith, D.J. (1983)
5. Murray-Smith, D.J. and Pack, A.1. (1977) Structural and parameter identification of two
Techniques of computer simulation applied to lung gas-exchange models, in Modelling and
respiratory gas exchange, in Non-invasive Data Analysis in Biotechnology and Medical
Clinical Measurement (eds D.E.M. Taylor and Engineering (eds G.c. Vansteenkiste and P.c.
J.5. Whamond), Pitman Medical, Tunbridge Young), North-Holland, Amsterdam, pp.
Wells, pp. 186-202. 175-83.
6. Mills, RJ., Middleton, S., Moran, F., et al. 11. Greer, W., Jordan, M.M. and Murray-Smith,
(1974) Simulation in the teaching of concepts OJ (1982) A structural approach to the respir-
of respiratory gas exchange. International atory control simulation, in Computers in
Journal of Mathematics in Education, Science and Medicine (ed J.P. Paul), Macmillan, London,
Technology, 5, 381-87. pp.339-46.
CASE STUDY IV - A SIMULATION
MODEL OF ACTIVE SKELETAL MUSCLE
13

13.1 INTRODUCTION during which mechanical energy is produced.


Around each muscle fiber is an electrically
Skeletal muscles are highly complex active polarized membrane and, if this membrane is
nonlinear systems in which chemical energy temporarily depolarized, the muscle fiber
is converted into mechanical energy. These contracts. An impulse traveling down a
muscles, which are associated with body motor nerve leading to the muscle is trans-
movement, can exert active force by contrac- mitted to the muscle membrane at a special
tion and they are normally organized in func- junction region known as an end-plate and a
tional pairs or groups to allow bidirectional wave of depolarization travels the length of
motion about a joint. the fiber, causing a single impulsive response
Two states can be distinguished clearly for known as a twitch. If the stimulus is repeated
all skeletal muscles. These are the noncon- before the response to the first impulse
tracting or resting state and the active state, has completely died away, summation of

r I
I
J
Surface
of cell Transmitter I I
I I
I
I
Surface
of cell
Muscle I I
I Mechanical I Mechanical
cell properties properties
-
-
-
-
- -

- - - - -
-1- I
- membrane
I
I
of muscle

I
of load

- Surface
of cell
I
I
I
I
I I

2 3 4

Fig. 13.1 A schematic diagram illustrating the control sequence which links electrical events in the
motoneuron to the mechanical response observed in skeletal muscle.
188 Case study IV
mechanical responses will occur. If the stimu- directly to length. Viscous elements are simi-
lus is repeated in a periodic fashion, at a suffi- larly defined as those in which the tension is
ciently high frequency, the twitches will related directly to velocity. Hill has summar-
merge to produce a contraction which fluctu- ized [2] the results of experiments made to
ates about a mean level which depends upon determine the relationships between length
the applied frequency. The condition in and tension changes. The experiments show
which the decay between individual twitch the following:
responses disappears and a steady contrac-
1. active muscle contains an undamped
tion is maintained is known as tetanus. When
elastic element;
tetanic conditions have been achieved any
2. active muscle contains an apparently
further increase in the frequency of the stimu-
damped element in series with the
lus can produce no further change in output.
undamped elastic one; and
It is possible to investigate the sequence of
3. resting muscle contains the elastic
events which follows the arrival of a pulse
element, but only to a minor degree the
and leads to mechanical activity in the
apparently damped element.
muscle. The complicated system must be
broken down into smaller units which can be The undamped element is termed the series
identified structurally and then isolated for elastic element and the damped element is
independent study. Figure 13.1 shows the the contractile component. Investigations of
control sequence which is commonly sup- the properties of muscle over a wide range of
posed to exist between the input motor nerve lengths indicate that models of resting or
impulses and the mechanical responses of the active muscle must contain a second elastic
muscle. The arrival of a nerve impulse causes element in parallel with the first two. This
the release of a chemical transmitter. The third element is the parallel elastic element.
muscle cell membrane is acted on by the These three elements have been incorporated
chemical transmitter to produce changes in
the mechanical properties of the muscle. The
conceptual boundary between the block rep-
resenting the muscle cell membrane and the
block representing the mechanical properties
of muscle remains somewhat indistinct.
Many models describing the detailed mech-
anisms of muscle contraction have been pro-
posed and, although of great value to Parallel Series elastic
elastic element
physiologists, they do not describe the inter- element
action of a given muscle within a multicom- Contractile
element
ponent system such as the neuromuscular
control system. In this case, the model may be
more empirical in form and can be based on
data obtained from simple measurements.
The concept of muscle as a system of ele-
ments whose mechanical properties could be
described in terms of elasticity and viscosity
was first given clear formulation by Hill in
1922 [1]. In the lumped parameter analogies Fig. 13.2 A diagram showing the three elements of
developed by Hill elastic elements are a simple mechanical analog of active skeletal
defined as those in which tension is related muscle.
Models of active muscle 189
in a conceptual model widely used for many element, and the parallel elastic element can
years to describe the properties of skeletal therefore usually be neglected under these
muscle. This model is shown diagram- conditions. The resulting two-element models
matically in Fig. 13.2. and the associated characteristic curves have
In order to characterize a muscle in terms been the subject of many investigations.
of the three-element model structure dis-
cussed above, at least five curves must be
13.2 MODELS OF ACTIVE MUSCLE
obtained experimentally [3]. These comprise
the force-velocity and force-length curve of As outlined above, the overall mechanical
the complete active muscle; the force- properties of active skeletal muscle can be
extension curve of the series elastic element; described by a set of five characteristic curves.
the force-length curve of the parallel elastic Of these the force-velocity curve is generally
element; and a curve describing the temporal believed to have special significance and has
properties of the muscle activity following the been studied in considerable detail by a
arrival of a motor nerve impulse (the 'active number of different investigators. Each point
state' curve). For values of muscle length on the curve is normally obtained from a
much less than the normal rest length, the measurement of the initial gradient of the
stiffness of the parallel elastic element is very length-time curve of the muscle when con-
much less than the stiffness of the contractile tracting actively in response to a maximal

0_06 1\

,..
\
"I

\J
m
a 0.04 \ ~

~
>t 1\
.ro!
U
0
\
roI 0 . 0 2

>
~ "'" ~
~ I--
I----

0.00
0.0

Force eN)

Fig. 13.3 The force-velocity characteristics of an active frog muscle (based on data of Ritchie and Wilkie
[3]). The circles show experimental points and the continuous curve shows the fit obtained using a
rectangular hyperbola of the form of equation (13.1) with parameters a = 0.143 and b = 0.0175.
190 Case study IV
nervous stimulus applied under conditions of and measuring the tension developed for a
constant tension. Hill's equation [2] give's a number of different values of the overall
good fit to the force-velocity curve for most length. The curve can be approximated quite
skeletal muscles during active contraction. closely by a parabola having the general form
This equation, which has the form of a rectan-
gular hyperbola, may be written in the (13.2)
following way:
In this equation p is the muscle tension, 1 is
(p + a)(v + b) =(po + a)b (13.1) the overall length of the muscle, 10 is the
normal body length of the muscle and Pc is
In this equation P is the force developed by the tension at body length 10 • Figure 13.4
the muscle, v is the speed of shortening, Po is shows the tension-length equation fitted to
the muscle tension at zero velocity for each experimental points found by Ritchie and
value of length and time and a and b are con- Wilkie [3]. The values of k, 10 and Pc are 2060,
stants. Figure 13.3 shows a set of experimen- 0.032 and 0.481 respectively. It should be
tal points for frog muscle obtained by Ritchie noted that, although the theoretical curve
and Wilkie [3] and the corresponding force- defined by equation (13.2) is symmetrical
velocity curve with a = 0.143 and b = 0.0175. about length 10, only the part for 1 less than 10
The tension-length curve of the complete is shown owing to the absence of published
active skeletal muscle can be determined experimental data for 1greater than 10-
experimentally by imposing tetanus on the The length of the series elastic element
whole muscle under isometric conditions cannot be measured directly, but by means of

,...

""
z
0.5

0.4
V
/ --
~
V
0
~ 0.3 I
V
0
~

~ 0.2
/
/
~
0
~
~ 0.1
/
/
~

0.0
J
0.016 0.024 0.032

M~sc1e Le~gth (~)

Fig. 13.4 The tension-length characteristics of an active frog muscle (based on data of Ritchie and Wilkie
[3]). The circles show experimental points and the continuous curve is the parabolic relationship of equa-
tion (13.2) with parameters k = 2060, 10 = 0.032 and Pc = 0.481.
Models of active muscle 191
a series of indirect measurements a curve can the rising phase of the active state curve is
be obtained to relate the extension of this not readily determined with precision, but it
element to the applied tension. This tension- is clear that the contractile element becomes
extension curve gives enough information to an active source of tension a very short time
permit the calculation of corrections to the after the arrival of a nerve impulse at the
tension-length curve of the contractile ele- end-plate. The tension developed in the con-
ment itself. The tension-extension curve of tractile element remains constant for a
the series elastic element (Fig. 13.5) may not period after the application of the stimulus
be expressed in a simple mathematical form and then falls slowly towards zero. Figure
as readily as the other curves, and a table 13.6 shows the active state curve and the cor-
look-up form of function generation is re- responding experimental points found by
quired for the representation of this element Ritchie and Wilkie [3]. It has been assumed
of the model. that the int~al rise in the active state is
The active state curve shows how the instantaneous.
degree of activity of the contractile element The experimental data of Ritchie and Wilkie
changes with time following the application [3] includes results of a series of isoton\: (con-
of a nervous stimulus. The precise form of stant tension) after-loaded twitch experilnents.

0.30

,.. 1
0.20
..,~
D
0
J.f
I
IJ
0
fit

0.10

0.0

0.000 0.001
-- V--
Extensic:>n
V
0.002

<:Ill>
0.003

Fig. 13.5 The force-extension curve describing the series elastic element for the frog muscle used in the
experiments by Ritchie and Wilkie [3]. The circles show experimental points, while the continuous curve
is the corresponding function to be fitted for the simulation model.
192 Case study IV

1.0

~
W
+l
!Ij
+l
m 0.8 ~
W
>
.,.j
0.6
\ \
+l

\
0
<
0.4

0.2
\ 1\

0.0
~ "-...
0.0 0.2 0.4 0.6

'I'i:me (8)

Fig. 13.6 The active-state curve for the frog muscle, with experimental points found by Ritchie and
Wilkie [3] indicated by circles.

To produce an isotonic after-loaded twitch, effect of the parallel elastic element may be
the muscle is held initially under isometric neglected for values of I less than 10, the
(constant length) conditions by a mechanical tension in the contractile element must be
stop which prevents excessive extension of the equal to the tension in the series elastic
inactive muscle arising from the applied force. element. Equation (13.2) may be used to
When the muscle is subjected to a nervous determine the tension at zero velocity for the
stimulus tension is developed, and when the chosen length, assuming the muscle to be in a
active tension developed by the muscle is state of maximum activity. If, on the active
equal to the applied tension contraction starts. state curve, the intensity of the activity at any
The after-loaded twitch therefore involves instant of time is expressed as a fraction of the
both isotonic and isometric conditions at dif- maximum activity, the tension Po at zero
ferent stages in the response. velocity for a given length I must be described
by the equation
13.2.1 SIMULATION OF ACTIVE MUSCLE
(13.3)
FOR CONSTANT LENGTH CONDITIONS
Under isometric conditions the overall length From equation (13.1) the velocity of contrac-
of the muscle is rigidly constrained. Since the tion of the active muscle is given by
Models of active muscle 193
b(po - p) the contractile and series elastic elements
v = ----'----=--- (13.4) must at all times be equal to the applied
p+a
tension. An increase of activity causes the
Under isometric conditions, any change of contractile element to shorten and, since the
length of the contractile element 111c must tension in the series elastic element is con-
cause an equal and opposite change of length stant, the change of length of the complete
111, in the series elastic element. The nonlinear muscle must be equal to the change of length
force-extension curve of the series elastic of the contractile element. Figure 13.10 is a
element gives the tension change appropriate block diagram of the model for isotonic
to the length change 111, and this must be the conditions.
overall tension p developed by the muscle. Figure 13.11 shows the block diagram for
Figure 13.7 is a block diagram of this simple the simulation of an after-loaded isotonic
model. Figure 13.8 shows an XANALOG sim- twitch. Here the muscle is allowed to develop
ulation diagram for this model, and the tension isometrically until the tension reaches
results of a simulation of the isometric twitch the required isotonic value, after which time
response obtained using the XANALOG soft- isotonic conditions are applied. It should be
ware are shown in Fig. 13.9. noted that some intermediate variables have
been introduced on this diagram. These vari-
ables are used in subsequent sensitivity
13.2.2 MODELS OF ACTIVE MUSCLE FOR
analysis studies. Therefore, the system being
CONSTANT TENSION CONDITIONS AND
simulated is initially described by the block
SIMULATION OF THE AFfER-LOADED
diagram of Fig. 13.7 with a change to the
ISOTONIC TWITCH
structure of Fig. 13.10 when the tension
Under isotonic conditions the overall tension reaches the required level.
of the muscle is controlled by external Figure 13.12 shows the XANALOG simula-
means, and the tension developed in both tion diagram for the after-loaded isotonic case,
ActiV"e
[Link]
h

Series a
Musc1e [Link]
e1entent
1ength
1

Fig. 13.7 A block diagram for the nonlinear model for active skeletal muscle for conditions under which
the muscle length is held constant (isometric conditions). Note the use of multiplier, divider and non-
linear function blocks in addition to the standard elements representing integration, summation and
multiplication by a constant. In this diagram the active state (a function of time) is represented by an
external function generator.
b
ACTSTATE_T
TABLE

'----I K
.1..43e-01

4.8119-01 P_DELTAL
TABLE

SERIES
~-ELASTIC"rJ
ELEMENT

"'0 "...... ->p

[D...... [Link]

3.20e-0 2

Fig. 13.8 XANALOG simulation diagram for the muscle model under isometric conditions. This is equiv-
alent to the block diagram of Fig. 13.7. Note the presence of the INVERSE block which has been created by
the user to provide a form of divide operation when used in conjunction with a multiplier block. Note
also the use of TABLE look-up functions for the active-state function and series elastic element. The
active-state block has time as its input, as shown by the 'clock' icon. The principal output variable is the
muscle tension, p, as shown by the 'eye' icon.

·... ·_· ..._·_·l-·... ·... ·...·_-.-_·__·__·j· ...·...·...·... ·__·j·... ·...·... ·...·-· ...·i· ... ·...·... ·... ·...·...·_,_· ... ·..·... _· ... ·_j_·...· ... ·... ·... ·... ·_j
i i i i i . i .
i i i i i i i I

0.5 .-!i~j·
I , I I I I I I
! ! -! ~ ~ i ! !
1 ! ! I
.-+~
!
I
....-.-.-.-+.-.-.---.-+--.-.-.-.-.+.-.--....
I f I
-.~
!
I
..... !I .. _......... _!.I~
~-

i i i i . i i
. i i i I ; i
0.4 ....-~. .....-.+.-.--.--.-...;.-.-.-.....-.-.•-............._.....--
i i i i i
. i j i
I i i I i i
_. __ ._-+-_............._. .-..... -+.;~ ..;.-.-.-.-........ _j.
i i ji i i j
i i j. i i j

0.3 i--·-·-·-·--:-·---·--r-·- ·-·-·--:-·-·-·-·-·--:--·-·-·-·-l--·-·-_·-·t -·--·-·-·-·-!


I i j i i i i i

j i i i i ;
i i i i i i I I
-_.- .-.j--.-.-.--;--.-.-.-.--r-. ·-T-·-·-·-·-·-·r-·-·-·-·--j-·-·-·--·-·j--·-·-·-·-·-i
i i i i i i j i
! ~
._..J...•.__.__.-L_. __.__.L.. __.__
! !I ._.•.
!
_._._.!.•.___•.
! _~.J
. ..._._._._._!!
0.2 I I I I I I I
i i j i i j i
i i j I i i i j
.-i~ _.~-i
I I I I I I I I
i
I
!
I
!
I
!I !
I
!
I
!
I
'
I

0.1 ---t--·-----!----·-+-·--···-4-
I I I I
.-~+_!
I I I I
! ! ! ! ! ! i !
--.L.-----i---l---._-!..._..___... -___.L.__.__.--!______.J
!
I
!
I
!I iI iI . i !
I
! ! ! i! !
0.0
0.0 0.2 0.4 0.6 0.8
[Link] (8)

Fig. 13.9 Response of the muscle model to a single nerve impulse under isometric conditions, obtained
using the XANALOG simulation model of Fig. 13.8.
Models of active muscle 195
[Link]
state

h
Applied.
tension p
-~+{

[Link].l
length Ii

Fig. 13.10 A block diagram for the muscle model under conditions of constant tension (isotonic conditions).

Active
[Link]
h

Applied. 0
tension P PA
P. .-J "'-1r----....:.P- - - - + -.. .
A,-__....L.._ _- - ,
Series
e l ...... t i c S e r i e ...
ele_ent [Link]
e.1..[Link]
Initia.l
length Ii

Fig. 13.11 A block diagram for the muscle model under 'after-loaded' isotonic conditions.

and the results of XANALOG simulation conditions also increases. Experimental results
experiments based on this are shown in by Ritchie and Wilkie [3] are also shown, and
Fig. 13.13. These show length changes versus it may be seen that the agreement between the
time for various different values of applied experimental responses and the simulation
tension. It can be seen that as the tension is results is least satisfactory near the peak of the
increased the time taken to establish isotonic twitch for the smaller values of load.
196 Case study W

b
ACTSTATE_T
TABLE

.1. .. 4 : 3 8 - 0 1
[Link]

TABLE

SERIES SERIES
,....--_......:ELASTIC ..._ _ _ _~-=[Link] . .---------1
ELEMEH LEII'JENT
[Link] 6L-t ~p

MUSCLE .. ALG [Link]

po

.
.:
: 2 .. 06e+03 4 .. 818-01.

t..................•
LO L-LI

[!]. [Link]
3 .. 2 0 e - 0 2

Fig. 13.12 XANALOG simulation diagram for the after·loaded isotonic case of Fig. 13.11. Note the use of
the switching blocks to provide the change of structure in the model at the transition from isometric to
isotonic conditions.

13.3 PARAMETER SENSITIVITY ANALYSIS r- p-a = Fz(r,p) = 0 (13.6)


A complete parameter sensitivity analysis of
the isotonic after-loaded muscle model can (13.7)
provide useful information about the effects
of possible errors in the parameters used in z - pe + d =F4 (z, d) =0 (13.8)
the simulation. The sensitivity analysis
requires the establishment of a co-system The equations of the nonlinear elements are
model, as described in Chapter 3, in series
with the main model. For this it is convenient (13.9)
po - zh = Fs(Po,z,h) = 0
to separate the set of equations into a linear
subset and a nonlinear subset.
Using the additional variables defined in mb
v--=F6 (v,m,r)=0 (13.10)
the block diagram of Fig. 13.11, the linear r
equations may be written as follows: d-kF =F7 (d,l)=O
where f = 1-10 - Ale + Als (13.11)
m - po + P =1) (m, po, p) =0 (13.5)
Parameter sensitivity analysis 197
0.010

014~3 IN
L

0.008
'(
0 V
V

..
0/ ~+0436 N

,...
S
\01

~
0.006
VI V
~
C
m
j +/
1+ V
.c:
t)

.c: 0.004
:x.-
v
I
~ x
~
C
m .I x k1515
x/,
N

l fl xL V
~

0.002

I~ ;/v • •
.....-••
j., I~ ~ N

V
0.2j80

0.000 J
0.00 0.10 0.20 0.30 0.40

Ti:rne (8)

Fig. 13.13 Simulated responses (continuous lines) and experimental results (circles and crosses) for the
first phase of the after-loaded isotonic twitch response, during which the muscle is contracting. Four sets
of results are given for different values of applied tension, ranging from 0.0143 N to 0.298 N. The experi-
mental results are by Ritchie and Wilkie [3].

(13.12) ar ap (13.15)
---+YI =0
aq aq
(13.13)

Differentiation of each of these equations


with respect to a parameter q gives a set of (13.16)
sensitivity equations as follows:

(13.14)
az ad
-+-+Yz =0 (13.17)
aq aq
198 Case study IV
Table 13.1 Functions appearing in the sensitivity
Jpo _ h Jz = 0 (13.18) co-system equations
Jq Jq
Parameter 1'1 1'2 1'3 1'4
(13.19) a -1 0 0 0
b 0 0 -m/r 0
k 0 0 0 -['
(13.20) p, 0 -1 0 0
10 0 0 0 2kf

(13.21)
tension-length diagram of the series elastic
element [4].
Figure 13.14 shows the block diagram of
(13.22)
the general co-system. Figure 13.15 shows the
relative sensitivity coefficients for a number
The functions 1'1' 1'2' 1'3 and 1'4 which appear in of different parameters for a single value of
the co-system equations above are given for applied tension. Figures 13.16 to 13.20 show
each model parameter in Table 13.1. The the sensitivity coefficients for each of the
functions 1'5 and 1'6 are gradient functions parameters of Table 13.1 for a series of values
of a piecewise-linear approximation to the of applied tension.

Ac:ti"e [Link]
h

o
r Ie---Ys

Fig. 13.14 Block diagram of the sensitivity co-system for the muscle model under after-loaded isotonic
conditions.
Parameter sensitivity analysis 199
0.010
P 01
cOp? ~ ---
v::: V
~ - b01
-
Ob
l
/
V

~
~

~
~
'\

'\
- I---
-- t---
ko1-
ok

~
...........

\:--
\ a01
-
oa

\ al0
10 01
-0.010
0.0 0.1 0.2 0.3

T.i:me (s)

Fig. 13.15 Relative sensitivity functions for four parameters of the muscle model for an after-loaded iso-
tonic simulation with an applied tension of 0.2980 N.

The sensitivity coefficients provide an accu- give a better approximation to the experimen-
rate means of estimating the effect of small tal response curves in the vicinity of the peak
changes of parameters on any of the variables of the twitch for the two smaller values of
of the model. The sensitivity functions of Fig. applied tension. However, the same change
13.15 show very clearly the relative impor- does not improve the model response for the
tance of the parameters la, Pc, a and b in the two larger values of tension. Therefore, it is
simulation, and show that near the peak of likely that the errors in the model response
the twitch, where the error in the model are because of a number of factors which
response is greatest, the response is par- include structural features as well as para-
ticularly influenced by the parameter 10 , metric uncertainties. It is of interest to note
Examination of the response curves of Fig. that, in almost all cases, the parametric sensi-
13.13 and their sensitivity functions shows tivity falls as the applied isotonic tension is
that an increase of 10 of the order of 0.3% can increased.
0.06

~I

+l
-.l
),

0.04
v -I--- ~Ot43
I
IN
---;
V-
-.l
+l
-.l
>
V '/ 0.0436 N

~
~
rn

/ V
--
0.02
Ul [Link]

/V
N

-- -
~
l.---
l~ 0.2980 N

0.00
- -1
0.0 0.1. 0.2 0.3

Ti:rne (a)

Fig. 13.16 Parameter sensitivity functions for parameter a in the muscle model under after·loaded iso-
tonic conditions for a number of levels of applied tension.

~Ii@ 0.5

),
+l
.,.j
0.4
>
.,.j
+l N
.,.j
rn 0.3
~ [Link] N
~
Ul

0.2

o . 0 L..-_ _--I_ _ _--L_ _ _....L.._ _ _-L.._ _- - l

0.0 0.1. 0.2 0.3 0.4 0.5

Time (a)

Fig. 13.17 Parameter sensitivity functions for parameter b in the muscle model for the after-loaded iso-
tonic case.
~I
.1.2
/
V
./
--
0.0.143 N

>t
+l
/
.~

>
V
.~
+l O.B /
Y
0.0436 N
oM
00 V---
C ~
m
Ul

0.4 / /
/
V
/ ,/

0.0
---V- V ./

- ---
0 • .15.15

0~29BO
N

0.0 0 • .1 0.2 0.3 0.4

Ti:me (5)

Fig. 13.18 Parameter sensitivity functions for parameter k in the muscle model for the after-loaded iso-
tonic case.

~I
>t 0.0436 N
~ O . 02 r---+---j---+-::=--===+--=;;;;;j
0.0.143
> N
.~
0
I I
• .15.15 N
+l
.~
00
C
m
Ul 0_29BO N
o . 01 t----flf+----iC-.----+--::",........::::::=f-----/

0_00
0.0 0.1 0.2 0.3 0.4 0.5

Ti:me (5)

Fig. 13.19 Parameter sensitivity functions for parameter p, in the muscle model for the after-loaded iso-
tonic case.
t)~( ~\ 0

0.6
I \
0.0.143 N
r-
), ~
.,.,+J
I"
/'
.>
."+J
."In
0.4 / V
0.0436

----
~
N

~
rn
C
/ /
/
V
0.2
V
/ V
/

---
0 . .15.15 N

/ / ~

--- ---
~

0.0 ~ / ~ 0.2980

1
N

0.0 0 . .1 0.2 0.3 0.4

Time (a)

Fig. 13.20 Parameter sensitivity functions for parameter 10 in the muscle model for the after-loaded iso-
tonic case.

0.0.10

,...
S 0.008
rI ~
"'"
~
~ P .. = 0.0436 N

'"
tl'
C 0.006

~
~
.d
t)

.d
+J

~
tl'
C
~
0.004

0.002
I( \
I{
......

'\
= 0 • .15.15

'"~
~

0.000
0.0
\ .1.0 2.0
~
" 3.0 4.0

Time (a)

Fig. 13.21 Simulation results for the muscle model: twitch responses under after-loaded isotonic condi-
tions for two levels of applied tension.
Simulation of the complete twitch response and repetitive stimulation 203
13.4 SIMULATION OF THE COMPLETE of the simulation model may be understood
TWITCH RESPONSE AND REPETITIVE from an examination of the block diagram of
STIMULATION Fig. 13.11, which shows that when the active
state is zero the variable Po must be zero.
Although results in Ritchie and Wilkie's Hence, the velocity must take on a constant
experiments [3] were available only for the value which depends upon the applied
rising phase of the isotonic twitch, it is of tension. These results show general qualita-
some interest to examine the response of the tive agreement with experimental records of
model over the complete period following Jewell and Wilkie [5] which show an approx-
excitation, including both contraction and imately linear phase in the relaxing response.
relaxation. Figure 13.21 shows simulation It should be noted that there is evidence
results for this case and indicates that there is which suggests that Hill's equation for the
a linear relationship between length change force-velocity characteristics of the contractile
and time during the relaxing phase after the element is not strictly valid during the relax-
active state has decayed to zero. This behavior ing phase. Hill's equation has been used in

0.016
I I
f > 11 p/s
.-

0.012
V /"
~
r/
'" r ~
,..
~
I I /f = 1 p/s

'oJ

Gl
~ 0.008
V0..... I
~
~
! "'"
""""""
.c
u
.c
~
01
0.004
I
C ~

'"
~
1-1

~
0.000

0.0 1.0

Ti:me
2.0

(s)
"'" 3.0

Fig. 13.22 Simulation results for the muscle model: the response to repetitive neural stimulation under
isotonic conditions. The response to a single nerve impulse is shown, together with responses to stimula-
tion at 1 pulse per second and at over 11 pulses per second. The applied tension in this simulation experi-
ment was 0.0436 N.
204 Case study IV

I
f :> 11 p /5

0.48
/
~
(
.........

,...
Z t~ i ~ ~

1\ \
\
'oJ

k
..,0
\
~ f = :3

\
00
k
W 0.24
8

r-l
W
1\
~
U
00
~ \
0.00
) 0--
0.00 0.25 0.50 1.00
Ti:rne (5)

Fig. 13.23 Simulation results for the muscle model: the response to repetitive neural stimulation under
isometric conditions. The response to a single nerve impulse is shown, together with responses to stimu-
lation at 3 pulses per second and at over 11 pulses per second. The value of muscle length used for this
simulation experiment was 0.032 m.

this simulation model because of lack of must be regarded as acting as a single motor
experimental data for negative values of unit. A typical muscle has hundreds of motor
velocity. The simulation program can be units which, under normal conditions, are
modified easily to accommodate other stimulated in an asynchronous fashion. A
force-velocity curves. closer approximation to a representation of
Figure 13.22 shows the results of simulat- muscle operating under normal conditions
ing the application of repetitive neural stimu- could perhaps be obtained by a parallel
lation at various frequencies under isotonic arrangement of a number of models, but with
conditions. Figure 13.23 shows similar a random or prescribed statistical pattern of
results for the isometric case. The results stimulation.
show very clearly the summation of
twitches, which is a well-known feature of
13.5 DISCUSSION
muscle responses and the limiting condition,
known as tetanus, in which the individual This case study is of particular interest in
twitch responses fuse together to produce a terms of modeling and simulation methods
smooth contraction. for a number of reasons. Firstly, it provides
It should be noted that because of the an example of a nonlinear model which has
method of stimulation used in the experi- been developed on an empirical basis from
ments by Ritchie and Wilkie [3], the muscle measured response data. Secondly, it pro-
References 205
vides an illustration of function generation their most economical speed. Journal of
through curve fitting (the overall tension- Physiology, 56, 19-41.
length curve and the force-velocity curve) 2. Hill, A.V. (1938) The heat of shortening and
dynamic constants of muscle. Proceedings of
and through use of a table look-up approach the Royal Society, B126, 136-95.
(the series elastic element). It also provides a 3. Ritchie, J.M. and Wilkie, D.R. (1958) Dynamics
useful illustration of the generation and use of muscular contraction. Journal of Physiology,
of parameter sensitivity functions in model 143,104-13.
development. 4. Murray-Smith, D.J. (1970) A Model of Active
Muscle, Control Systems Group Report No.
CSG/70/002, Department of Electronics and
Electrical Engineering, University of Glasgow.
REFERENCES
5. Jewell, B.R. and Wilkie, D.R. (1960) The
1. Hill, A.V. (1922) The maximum work and mechanical properties of relaxing muscle.
mechanical efficiency of human muscles and Journal of Physiology, 152, 30-47.
REAL-TIME SIMULATION 14

14.1 AN INTRODUCTION TO REAL-TIME time simulation of the process. The benefit of


APPLICATIONS this approach, involving 'hardware-in-the-
loop' or 'partial system' testing, is that the
The design, development and testing of many performance of the controller, or other engin-
engineering systems, such as aircraft and eering equipment, can be evaluated in safety
their flight-control systems, missiles, ship- for a wide variety of normal and fault condi-
propulsion systems, road vehicle suspension tions, and the design can be fully checked and
systems and certain kinds of chemical plant, proven prior to installation on site.
can benefit, at certain stages of the process, There is an interesting and important
from the use of computer simulation models distinction which has to be made between
which operate in the same timescale as the real-time applications which are concerned
real system so that the execution time of the with the development of simulators for train-
model is matched to the real system time. ing and real-time applications which arise as
This is generally known as 'real-time' simula- part of the engineering design and develop-
tion. It is particularly important in applica- ment process. In a simulator developed for
tions in which the simulation may have to training, such as an aircraft flight simulator
run with a human operator as part of a intended for airline use, the emphasis may be
closed-loop system or in conjunction with real said to be on emulation, since the objective is
engineering hardware. Simulation may then to model only those aspects of the real system
be used to check interactions between indi- which are needed to achieve an overall
vidual items of equipment and to investigate behavior which matches that of the real
the total system operation. system at the operator interface. In this case,
One very well-known example of real-time some of the simulation submodels may very
simulation arises in training applications, well be input-output descriptions which rep-
such as an aircraft flight simulator, where resent reduced-order models fitted in some
there is a 'man-in-the-Ioop' situation in which appropriate mathematical sense to a more
a human operator, such as a pilot, interacts complex non-real-time simulation model.
directly with the simulation model as part of Although such input-output models may
a larger closed-loop system. Other real-time have no physical basis, they may be com-
simulation applications may involve partial pletely appropriate for this emulation role,
testing of a complex engineering system provided they are used within the range of
where the performance of real engineering conditions for which they are known to be of
hardware is assessed by coupling it to a simu- acceptable validity. Unlike some of the
lation of other subsystems. Thus, for example, processes of model development outlined in
a digital controller for a chemical process earlier chapters, the development of an emu-
plant could be subjected to extensive testing lation model is a top-down process in which
by coupling the controller hardware to a real- details are added until the numerical solution
208 Real-time simulation
is indistinguishable, to a specified level of software methods. The simulation of com-
accuracy, from that of the more complex non- plex continuous systems in a real-time envir-
real-time simulation model. This reference onment has had an important influence on
model is likely to have been developed using the development of special-purpose com-
a bottom-up approach. While emulation is puter systems capable of achieving high
very useful as a means of simplifying models, performance levels in terms of speed. Two
and thus of assisting in the task of develop- developments have been particularly import-
ing a real-time simulation, it must be noted ant in overcoming the limitations imposed by
that when the purpose of the real-time simu- the traditional von Neumann computer
lation tool is to test a proposed system to its architecture. These are parallelism and
limits of performance, or even beyond the pipelining, and they have led to the develop-
expected normal limits, this type of simplifi- ment of some innovative types of digital
cation may be inappropriate. In such cases, it computer, peripheral array processors and
may be essential that as much of the simula- multiprocessors.
tion model as possible has a physical basis so Early developments involving a move
that variables of the model have counterparts away from the inherent restrictions of the von
in the real system and so that the simulation Neumann architecture led to supercomputers
model can be assessed in terms of all the based on arrays of processing elements. The
relevant variables. first example of an operational supercom-
In every application involving partial puter was the ILLIAC-IV, which involved an
system testing there is a well-defined inter- array of 64 processors, each of which con-
face between the external hard ware and the tained an arithmetic-logic unit and local
computer simulation. This is important since memory. By the mid-1970s, interest had
the values of variables in the real system and shifted more towards the development of
in the simulation depend on the accuracy systems involving pipelining, and the first
with which quantities are converted at the type of supercomputer of this kind to be
interface. The external hardware usually widely used was the CRAY-1, which was
involves continuous variables, such as dis- available in 1976. The success of this machine
placements, velocities, pressures, mass flow set the scene for a number of other supercom-
rates or other measured physical quantities. puters based on a similar approach to the
Such quantities are often available at the provision of high computational speeds.
interface in the form of equivalent voltages. While supercomputers, such as the prod-
These voltage values must be transferred to ucts from Cray Research Inc. and Control
and from the simulation with the accuracy Data Corporation, were important for simula-
necessary to ensure that errors introduced by tion in terms of their technology, they were of
the interface are negligible compared with little direct use for real-time simulation appli-
other sources of uncertainty in the model. cations. However, in the late 1970s a new
form of pipeline system became available that
was potentially very useful for the signal-
14.2 HARDWARE AND SOFTWARE
processing and simulation areas. These
ASPECTS OF REAL-TIME SIMULATION
devices were small vector processors, termed
Real-time operation introduces considerable 'peripheral array processors' or 'attached
additional difficulties for the simulation soft- array processors', and operated as peripheral
ware developer because of the constraints devices for conventional digital computers.
which real-time requirements impose. The High speed can now be achieved at relatively
ability to handle more complex problems low cost and many applications have been
depends on the introduction of faster com- reported which involve real-time problems
puters and the development of improved (e.g. ref. 1).
Analog simulation techniques 209
Some machines have been developed with analog simulation should be understood by all
the simulation market specifically in mind. engaged in continuous system simulation.
One example of a family of specialized One reason for this is the fact that many
computers which achieve a high speed of per- digital simulation products currently available
formance by means of pipelining and paral- have been developed specifically as analog
lelism is the Applied Dynamics AD-10 and computer replacements and therefore have
AD-lOa. These were developed specifically features which relate directly to analog simu-
for continuous system simulation applica- lation methods. Another very important
tions, and appropriate software tools are reason is that analog methods can still provide
available for these systems which allow the highly cost-effective solutions to some special-
user to make full use of their capabilities. ized small-scale simulation problems, espe-
Such systems are the subject of further discus- cially in a real-time context.
sion in section 14.5. An analog computer comprises a number
Although much emphasis is placed on the of building blocks which have well-defined
importance of modern developments in functions and which can be interconnected in
digital computer technology for real-time appropriate ways for solving continuous
simulation applications, it should not be for- system simulation problems. Model variables
gotten that analog simulation techniques are represented by other physical quantities
were used successfully for many years in real- such as electrical voltages or currents.
time applications. Although few new devel- Mathematical operations, such as addition,
opments are taking place now in the analog integration or multiplication, are performed
computing field, the principles of analog on these analogous variables using the basic
simulation should not be forgotten entirely. building blocks provided. In many respects
Analog techniques can still be used to an analog simulation can be viewed as an
provide very cost-effective solutions in par- electronic hardware implementation of a
ticular application areas involving small real- block diagram-oriented simulation, intercon-
time simulation problems. This is discussed nected in a way which corresponds exactly to
in more detail in section 14.3. the equations of the system being investi-
Standard simulation languages currently gated. The behavior of the analog model
available are generally not usable in real-time should match that of the mathematical model
problems. The techniques used to overcome in all respects.
the difficulties of real-time simulation are The most widely used type of analog simu-
often somewhat informal, but increasing use lation hardware is electronic in form and
is now being made of techniques of software involves the use of DC electrical voltages to
design intended for other application areas represent dependent variables of the model
such as digital signal processing and digital and time to represent the independent vari-
communications [1]. Also used are software able. The hardware-based functional building
development tools specifically designed for blocks involve electronic operational ampli-
real-time applications. These can be of consid- fiers and can perform a number of operations
erable assistance, especially in the context of such as:
multiprocessor implementations (e.g. ref. 2).
1. summation of a number of variables;
2. integration of a single variable with
14.3 ANALOG SIMULAnON TECHNIQUES
respect to an independent variable
Although digital computer hardware and soft- (usually time) or combined summation
ware have now developed to a point where and integration of a number of variables;
digital methods can now be used in most real- 3. nonlinear operations such as multiplica-
time simulation applications, the principles of tion of two variables, division or the
210 Real-time simulation
generation of a piecewise-linear function solutions for certain types of problem, espe-
of a given variable; and cially involving real-time applications. When
4. multiplication of a variable by a constant. no analog computer is available the possibil-
ity of building up a special-purpose analog
This list shows that the hardware units in simulation using general-purpose electronic
analog simulation correspond to some of the analog integrated circuit elements is well
basic elements of block diagram-based simu- worth considering for applications which are
lation packages, such as XANALOG and especially demanding in terms of speed and
SIMULINK, which were discussed in Chapter for which high absolute accuracy is not vitally
7. Analog hardware elements can also be important.
coupled to digital hardware such as electronic
logic gates, counters and shift registers
14.3.1 THE OPERATIONAL AMPLIFIER
through special-purpose analog to digital
interface units known as comparators. The The operational amplifier is the basis of both
results of logical operations may, in turn, be the summing unit and the integrator unit in
used to actuate analog switches which can electronic analog simulation. Figure 14.1
make or break connections between analog shows a circuit diagram of a simple invert-
hardware units and thus provide capabilities ing operational amplifier involving external
for quite complex operations. resistive elements R; and Rf • Let the DC
It is important to note that all the elements voltage gain of the amplifier without exter-
of an analog simulation operate in parallel. nal elements (open loop) be -A, and assume
Performance therefore is limited in terms of that the input impedance of the amplifier is
speed only by the finite bandwidth of the very high in comparison with the values of
electronic elements used to create an analog the two resistors. If the gain A is large (say
simulation. Accuracy is, on the other hand, of the order of 107 or greater) the voltage Vc
limited by the tolerances on the perform- at the amplifier input must be very small for
ance of the individual building blocks, and any finite level of output vo. The input to the
this tends to be significantly lower than the amplifier element is then termed a 'virtual
accuracy of digital computing hardware. earth' since it remains at zero voltage effec-
Therefore, analog simulation techniques are tively but draws no current. Under these
appropriate for applications in which very conditions it follows, from elementary
high levels of accuracy are not of interest but circuit theory, that the currents in the input
where the speed of solution has to be high. and feedback resistors (i;np and if respect-
. Analog simulation may be carried out ively) are equal in value but opposite in
either using special-purpose electronic hard- sign.
ware, developed for a specific application, or
by means of a general-purpose analog com-
puter. An analog computer normally com-
prises a set of summing units, integrators,
coefficient units and other components which
may be connected together according to the
user's wishes using a simple patch panel and
patch cords (interconnecting wires). Although
large analog computers are no longer widely
used, small systems involving up to about a
dozen integrators are still being manufac- Fig. 14.1 Circuit diagram of a basic inverting oper-
tured and can provide highly cost-effective ational amplifier.
Analog simulation techniques 211
Thus

il

and for Ve = a it follows that

,.\ ('1"
o~-
r~
Fig. 14.2 Circuit diagram of an inverting opera-
Hence tional amplifier acting as a summing unit.

Thus

and thus

04.1) or, in terms of gain factors

The complete operational amplifier unit,


with the two external resistors, thus has The voltages V]f V 2 , ••• , v" can thus be com-
an inverting gain which is determined by bined in a weighted sum through the gain
the two resistance values and is inde- factors gl, g2' ... , g". Typically, Rf = 1 Mil and
pendent of the gain of the active part of the input resistors RI , R2f ... , R" are 0.1 Mil or
the unit, provided this remains high. 1 Mil, giving path gains of -lor -10.
By selecting resistors of equal value the A summing unit is represented in most
unit has a gain of -1, and by choosing analog simulation diagrams by a schematic of
other values any required gain may be the form shown in Fig. 14.3. In this case the
established. diagram shows a five-input unit with three
gains of unity and two of 10.
14.3.2 THE SUMMING UNIT
14.3.3 THE INTEGRATOR UNIT
Because of the virtual earth effect described
above a number of input resistors may be If, in the basic operational amplifier of
connected to the inverting input of the ampli- Fig. 14.1, a capacitor is used in place of the
fier element without risk of interaction. feedback resistor Rf the voltage Vc across that
Figure 14.2 shows a typical configuration.
Here

and so

Fig. 14.3 Conventional analog simulation symbol


for a summing unit.
212 Real-time simulation
capacitor will be related to the charge q on it
and will be given by the equation
9

However, the charge is the integral of the


instantaneous current if which flows in th~ Fig. 14.5 Conventional analog simulation symbol
for an integrator unit.
capacitor and hence it follows that

and, in terms of gain factors


Hence, since ve is a virtual earth, voltage Vo =- f (gjv j + g2 V 2+ ... + gnv)dt (14.4)
and
Vo= Vc

This unit then performs the operation of inte-


vo = ~fi C dt = ~f-i C lOp
dt = -l-fv
CR; dt
I gration on a weighted sum of the inputs.
With C = 1 J1.F and resistances of 0.1 Mil or
In the case of several inputs, as shown in 1 Mil the gains gi have values of 10 or
Fig. 14.4, 1 respectively. The conventional symbol for a
single input integrator is as shown in
Fig. 14.5, where the quantity g may typically
(14.3) have values of 1, 10, 100 or 1000.

C 14.3.4 THE COEFFICIENT UNIT

if
A coefficient unit provides a means of multi-
i, plying an analog variable by a constant value.
Such units provide a means of setting coeffi-
v, cients which arise in the model equations. In
vo terms of hardware, the simplest form of
coefficient unit is a simple electrical poten-
0
1-1 0
tiometer, as shown diagrammatically and
symbolically in Fig. 14.6. In general, the
Fig. 14.4 Circuit diagram of an inverting opera- coefficient setting, k, is restricted to a range of
tional amplifier acting as an integrator unit. zero to one.

Fig. 14.6 Circuit diagram and equivalent symbol for a coefficient unit.
Analog simulation techniques 213
14.3.5 MULTIPLIERS AND OTHER The interpretation of results from a scaled
NONLINEAR UNITS simulation is very straightforward. For
example, for a problem variable, y, represent-
Although summing units, integrators and
ing a displacement with a range of -50 m to
coefficient units meet all the needs for simula-
+50 m the scaled value of y would be
tions involving linear models, there is often a
need for other operations in the case of non-
ysc = Y/ 50. If at some instant during a simula-
tion run the value of the variable Ysc is 0.2 MU,
linear models. Electronic analog multipliers
the corresponding value of the physical vari-
provide a means of multiplying two variables
able y must be
together, and there are ways of using multi-
pliers in conjunction with high-gain ampli-
y=50ysc =0.2x50=10m
fiers to produce 'units which can divide one
variable by another or carry out square-root
The processes involved in amplitude
operations. Details of such elements, as well
scaling are best illustrated by an example.
as others which are available for more
Consider the unforced mass-spring-damper
specialized tasks, may be found in texts
system shown in Fig. 14.7, where a typical set
dealing specifically with analog simulation
of parameters are M = 20 kg, R = 2000 N m- I s
methods (e.g. refs 3 and 4).
and K = 12000 N m-I . Appropriate maxima for
the displacement y and velocity dy / dt are
14.3.6 SCALING OF VARIABLES 0.05 m and 0.5 m S-I respectively. The second-
order ordinary differential equation defining
Variables within an analog simulation are
a linearized mathematical model for this
restricted in their range by the physicallimi-
system is
tations of the active elements forming the
operational units. Summers, integrators and
d2 d
multipliers, for example, all have a maximum M --.JL + R J.- + Ky = 0 (14.5)
output level at which saturation occurs and at df dt
which they cease to behave as ideal elements
with well-defined characteristics. This second-order equation may be rewritten
Amplitude scaling of variables is a normal- as two first-order equations
ization process which is essential in analog
simulation. In an amplitude-scaled simulation (14.6)
all variables are converted to scaled quantities
which lie between +1 and -1. These scaled, or (14.7)
'per-unit' quantities, are normally expressed in
machine units (MU). In an analog computer,
or in a special-purpose electronic analog simu- where XI = Y and X 2 = dy / dt.
lation developed from electronic hardware In order to scale these two equations in
elements, a scaled value of +1 MU or -1 MU terms of amplitude we must have available
corresponds to the maximum permissible pos- the maximum value of the rate of change of X2
itive or negative output level of the electronic as well as the information given above.
units. Using modern integrated circuit hard- Estimation of this maximum acceleration is
ware this normally corresponds to a range of quite simple in this case since, from equation
+10 V to -10 V. For highest accuracy, the com- (3.5), it is clear that
puter variables should always have values
which are as close as possible to the permis-
sible maximum (1 MU positive or negative).
214 Real-time simulation

K
L-.;M~1

Fig. 14.7 Unsealed analog simulation diagram for mass-spring-damper model.

The condition for the maximum acceleration for the full range of conditions over which the
could logically be taken as the situation corre- simulation is to be used. To some extent
sponding to y and dy / dt both taking their scaling always involves some guesswork, but
maximum values. This would give the process may be made much more reliable
if estimates are based upon some preliminary
results obtained from a non-real-time digital
simulation.
For the maxima discussed above we now
This value of 80 m S-2 is, in fact, likely to be a have scaled variables which are as follows
generous estimate of the maximum accelera-
tion since, for physical reasons, it is unlikely X
XI
---
that the displacement and velocity will have Ise - 0.05
their maxima in this system at the same time
instant. It might well be more appropriate to The procedure normally adopted in scaling
examine the two contributions from the terms calculations involves first of all setting up an
involving y and dy / dt separately to give a unsealed analog simulation diagram. This is
maximum acceleration value of 50 m S-2. based upon the state equations, and is very
Possibly, a value between 50 and 80 m S-2 easily constructed in this case, as shown in
might be the most appropriate choice, say, Fig. 14.7. To incorporate scaling the state
60 m S-2. The precise values of maxima used equations must be rewritten in normalized
are not critical but should be chosen to allow form without altering the balance of the terms
Analog simulation techniques 215
on the left- and right-hand sides. This gives and
the following equations:

That is
and
. X d
-.-lrnax
xlsc - - -dtx lsc (14.10)
X 1max

That is . X d
-.-2max
x2sc - - -dtx2sc (14.11)
X 2max
. x2max
X lsc = X2sc -.- (14.8)
x1max Since the input to each of the integrators must
be the time derivative of the output of that
and integrator, it is necessary to introduce addi-
tional coefficients immediately before each
. R X K Xl max
integrator unit in the simulation diagram.
X 2sc = - M X 2sc -.X 2max
- - M X lsc -.- (14.9)
2max X 2max Indeed, one of the important rules of thumb
of analog computer programming is that a
In addition, it is necessary to relate the two coefficient unit must appear between all inte-
derivatives through appropriately scaled grators in a scaled patch diagram. The part of
equations. It is known that the scaled diagram corresponding to equa-
tions (14.10) and (14.11) is shown in Fig. 14.8.
Since coefficients can only be set to values
smaller than 1, it may be necessary to use a
and combination of a coefficient setting with a
summer or integrator gain factor if the
. dX 2 required values are to be obtained. For
X2 = -
dt example, a coefficient unit cannot be set to a
value of 2.5, but such a coefficient could be
and hence it follows that established in a simulation by using a coeffi-
cient unit set to a value of 0.25, along with a
summer or integrator input with a xl0 gain
factor. In the mass-spring-damper problem

Fig. 14.8 Scaling of variables at the inputs and outputs of the integrator units in Fig. 14.7.
In this case the coefficient units C1 and C, must be set to values equal to x1m,j X1m" and x2m ,j X'm"
respectively, in accordance with equations (14.10) and (14.11).
216 Real-time simulation
the substitution of values gives the patch One further important aspect of analog
diagram shown in Fig. 14.9, and it may be computer scaling concerns timescaling. Analog
seen that coefficient units and gain factors simulations may be made to run in a variety
have been used together in this way at the of different timescales simply by altering the
two integrator inputs. It should also be noted gains associated with all of the integrator
that there are two additional coefficient units units by the same factor. For example, increas-
in this diagram which did not appear in ing all of the integrator gains by 10 in a given
Fig. 14.7. These provide a means of setting simulation problem speeds up the simulation
initial conditions on the two integrators. by 10 times. The technique usually employed
Note that, if integrator units can accommo- for timescaling is to define a constant {3 such
date more than one input, the scaling calcula- that
tion may be considerably simplified, unless
dx 2 / dt is needed as an output variable. This
{3 = computer time = ~
simplification arises from the fact that there is
problem time t
no need to use the maximum value of the
acceleration in the scaling calculations if the
integrator involving X2 as output can carry out If this timescale factor is greater than I, the
summation as well as integration. computer is running slower than the real

Fig. 14.9 Complete scaled analog simulation diagram for the mass-spring-damper problem of Fig. 14.7.
It follows, from equations (14.8) to (14.11) with the parameter values given and for the estimated maxima,
that the coefficient unit settings are C] = 1.0000, C2 = 0.1200, C3 = 0.S333 and C4 = 0.5000. Note the use of
gain factors of 10 and 1000 at the integrator inputs to provide coefficient setting which are not greater
than 1.0000. Settings for the initial condition coefficients (Cs and Co) are the initial values of the scaled
state variables and will depend upon the experimental condition to be simulated.
Digital techniques 217
process, while if f3 is smaller than 1 the simu- mode. Modes are normally controlled manu-
lation is faster than real time. From the equa- ally by the user.
tion above it follows that

1 14.4 DIGITAL TECHNIQUES


t=-T (14.12)
f3 What is important in tackling a real-time
problem by digital techniques is to have some
and thus
understanding of the type of trade-off which
may be necessary between hardware capabili-
dx dx dt 1 dx ties, software requirements and model accu-
-=--=-- (14.13)
dT dt dT {3 dt racy. Real-time operations impose constraints
on numerical integration processes since the
Hence if dx / dt can be multiplied by 1/ f3 the computational resource available for each
variable dx/ d T will result. Thus, as stated time step is fixed. There is no point in using
above, to speed up or slow down a simula- variable time step methods, and the concepts
tion by a factor f3 every integrator input must of error control are therefore inappropriate in
be divided by f3. Further details of this and this type of application. A fixed-step method
other aspects of amplitude and time scaling must be chosen which is adequate, and
calculations may be found in more special- ideally this should be the method which min-
ized textbooks on analog simulation methods imizes the numerical errors subject to the
(e.g. refs 3 and 4) and general texts on model- overriding requirement of achieving real-time
ing and simulation which include a more performance.
extensive treatment of analog simulation
methods (e.g. ref. 5).
14.4.1 REAL-TIME INTEGRATION
ALGORITHMS
14.3.7 OPERATING MODES
One of the most widely used integra-
In using an analog simulation on a general- tion methods for real-time applications is
purpose analog computer one normally has the second-order Adams-Bashforth (AB-2)
facilities for using a number of different oper- algorithm. This is a single-pass predictor-
ating modes. Typically, these would include corrector type of algorithm. For a first-order
the following: equation in the standard state-space form
1. coefficient set mode (CS);
dx
2. initial condition mode (IC); - = f(x,u(t)) (14.14)
3. operate mode (OP); and dt
4. hold mode (HD).
the AB-2 algorithm is given by the equation
The names of these modes show how they
may be used. For example, the CS mode is
(14.15)
used when the problem is being set up on the
analog computer. The IC mode is used to
establish initial conditions at the start of a where Xk= x(kh), Uk = u(kh), fk = f(x k, Uk) and h is
simulation experiment, while the OP mode the integration interval.
has to be used when the simulation is actually The AB-2 algorithm is based upon calcula-
operating. The progress of the simulation can tion of the area under a linear extrapolation
be halted at any time by switching to the HD of the derivative f from time t = kh to time
218 Real-time simulation
t = (k + l)h based on fk and fk-l' It has errors method. Since dynamic errors for the real-
proportional to h and is thus a second-order
2 time RK-2 method vary as h2 , a doubling of
method. AB-3 and AB-4 algorithms, which the step size will lead to an increase in error
are based on second- and third-order extrapo- of the order of four times, and this clearly
lation respectively, are also used as real-time negates any benefit over the AB-2 method.
integration methods. They give errors propor- Even very simple integration methods,
tional to h3 and h4 respectively. such as rectangular integration or trapezoidal
Real-time simulations can also make use of integration, can be of considerable value in
multiple-pass integration methods such as the many real-time simulation applications.
Runge-Kutta methods. However, the stand- However, care must be taken to carry out a
ard Runge-Kutta algorithms described in careful preliminary analysis of the mathe-
Chapter 4 are not appropriate. For example, matical model to establish the range of its
the standard second-order Runge-Kutta eigenvalues (time constants and natural fre-
method uses rectangular (Euler) integration quencies of the modes) prior to selecting an
with step size h in the first step to provide an integration step for one of these fixed-step
estimate of Xk+l' which is then used with U k+1 to methods. Decisions can then be taken regard-
compute an improved estimate of Xk+l in the ing any simplifications which may be appro-
second step. In the real-time case U k+1 is not priate in the real-time version of the
available when the second pass takes place simulation. For example, it may be possible
and a modified RK-2 algorithm must be used. to neglect some time constants which are
This involves a first pass based on the very small in comparison with others, and to
equation regard the dynamics of the elements of the
model associated with these time constants
as being instantaneous. The operator
(14.16) methods described in Chapter 5 are also of
very great importance for real-time applica-
tions, especially in cases involving linear
and a second pass using transfer function descriptions. As has been
pointed out by Rosko [7], the computational
(14.17) savings associated with operational methods
may be such that real-time simulation can be
This algorithm also involves rectangular inte- achieved while meeting accuracy specifica-
gration for the first pass but uses step size h/2 tions which could not be approached using
to give an estimated value for the state at the more conventional numerical methods.
mid-point of the interval h. In the second Conversely, for comparable overall accuracy,
pass, this estimated mid-point value is used, frame time reductions have been reported of
together with the mid-point value of the the order of 90% compared with Runge-
input, to compute Xk+l' This modified algor- Kutta methods.
ithm is compatible with real-time applications In Chapter 4 there is a brief introduction to
because the input U is only required at times methods which can be used to handle discon-
at which it is already available. tinuities. For obvious reasons, methods which
Although the real-time RK-2 algorithm out- are suited to variable-steplength integration
lined above gives dynamic errors of about techniques are generally not appropriate for
40% of those of the AB-2 method for a given use in real-time applications. Howe, Ye and
step size [6], it should be noted that the RK-2 Li [8] have presented some other methods
approach will require about twice the proces- which are more appropriate in this applica-
sor time for each step since it is a two-pass tion area.
Digital techniques 219
14.4.2 CHOICE OF COMMUNICATION feedback to the pilot's controls, and thus give
INTERVAL important tactile cues about the response of
the simulated aircraft to the pilot's com-
In general, synchronization is needed at fixed mands, require a very much higher commu-
time intervals and, provided the simulation nication rate than most of the other output
program is capable of executing faster than channels from the simulator's computer
real time, all that is required for a real-time system.
implementation is a delay until a clock inter- In most real-time applications it is import-
rupt occurs. However, it is important to dis- ant to make the integration step size as small
tinguish between the basic integration as possible, since the discrete nature of the
steplength and the intervals at which the simu- numerical integration process introduces
lation communicates externally. Real-time an effective time delay which can have an
applications almost always involve the com- important destabilizing effect overall.
munication of variables between some exter- However, the processes of selecting an inte-
nal hardware and the simulation program gration step size and integration method are
itself. The concept of a communication inter- very closely linked and two effects have to be
val which was discussed in Chapter 6 in the considered. Firstly, if a high-order integration
context of simulation languages, and which method is used, it may not be possible to
may be significantly larger than the integra- complete the necessary calculations in the
tion steplength, applies also to the real-time time available. Secondly, if the integration
case. For the simulation model, the communi- step is short because the communication
cation interval represents the update interval interval must be short, a high-order method
for external data, which may include external may not be necessary for the required accu-
quantities supplied to the computer through racy: single-stage integration algorithms may
analog to digital converters. Such external be adequate. The effectiveness of multistage
data can change value only at the communi- methods is also often reduced in real-time
cation times. Similarly, the times at which the applications because the values of variables
computer supplies values of continuous supplied from outside the simulation remain
output variables, through digital to analog constant throughout the communication
converters, to external hardware are also interval [9, 10]. Another important factor in
determined by the communication interval. some real-time applications is that integration
The choice of communication interval for a operations may be less time-consuming
real-time simulation usually depends upon overall than certain other types of numerical
the dynamic characteristics of the part of the process such as multivariable function gener-
system which is external to the simulation ation. In such cases, effort expended on fine
computer. It is not dependent upon the inte- tuning of integration methods to improve
gration steplength used in the digital simula- integration efficiency is of little value.
tion itself, although in many cases the Floating-point operations are generally
integration steplength and the communica- time-consuming and, in some areas, use has
tion interval are the same. In some complex been made of fixed-point arithmetic in order
applications, such as a real-time flight simula- to speed up a simulation and thus allow real-
tor, there may be a number of different, but time operation. Since there are restrictions on
related, communication intervals since differ- the largest positive and negative fixed-point
ent parts of the external hardware involve numbers which can be represented in a
variables which have different rates of digital computer, scaling then becomes
change. For example, the outputs from the necessary, just as it is in the analog case.
simulation which are used to provide force Although scaling is an additional complication,
220 Real-time simulation
automated procedures for scaling do exist dated, and therefore more acceptable to the
which can be implemented in a digital simula- user, in an application such as a flight simula-
tion. Unfortunately, most of the available tor than any form of oscillatory error.
scaling algorithms tend to produce conserva- Complete analysis of a real-time simulation
tive scaling factors which lead to an undesir- can only be carried out if there is information
able loss of accuracy. A simple alternative is, available about all the elements included in
first of all, to use a floating-point version of the simulation. Dynamic analysis of real-time
the simulation to compute a solution in a simulations can be very similar to the
timescale which is slower than real time. This dynamic analysis of closed-loop control
preliminary run is then used in the same way systems involving a continuous plant and a
as described in the discussion of analog digital control computer. This requires the use
scaling. From the results from the floating- of sampled-data theory as outlined in Chapter
point simulation the maximum values of all 5 and Appendix D. The analytical tools avail-
the model variables are found, and these able for the analysis of linear digital control
values are then used as the basis for the systems can often be of direct value, especially
scaling calculations, making some appropriate for the estimation of stability limits. Since real-
allowance for safety margins. A fixed-point time applications often involve nonlinear
simulation program is then prepared which external hardware or a human operator
may be used for simulation in real time. within a closed loop, such analysis may some-
times be very difficult, or indeed impossible.
Apart from the general desire to minimize
14.4.3 ERROR ANALYSIS IN REAL-TIME
delay because of its importance in terms of
SIMULATION
overall system stability, the really important
Traditional convergence conditions and criteria in terms of accuracy in real-time
asymptotic error estimates for numerical inte- applications are concerned with the location
gration are not meaningful for real-time of dominant eigenvalues. It is important to
applications because it is not possible to ensure that, for small perturbations about
reduce the step size below the real-time limit. any given operating condition, the eigen-
Error measures which are based on some values closest to the imaginary axis in the
form of quantitative comparison with a fully complex plane are accurately represented. As
verified and validated non-rea I-time simula- already mentioned, it is also vital to check
tion model are of more practical value. If the that there are no extraneous high-frequency
real-time results can be shown to lie within oscillations.
the upper and lower bounds of performance
of the non-rea I-time model, for the known tol-
14.4.4 MULTIRATE METHODS
erances of model parameters in that reference
model, the real-time version may be consid- Multirate methods are quite widely used in
ered credible. However, it should be noted real-time simulation problems as a way of
that even if there is zero mean difference reducing the computation time. This applies
between the real-time results and the results where a system can be split into a number of
obtained from a reference non-real-time simu- subsystems partitioned in terms of their
lation, the presence of any small oscillating known dynamic characteristics. Consider the
error of constant peak-to-peak amplitude may case of a system partitioned into two sub-
be very undesirable and could lead to false systems as follows
conclusions. Indeed, a small constant error or
bias may be much more easily accommo- if = fCy,z,t)
Special-purpose hardware for real-time digital simulation 221
i =g(y,z,t) A further form of parallelism is termed
'pipelining', which is a procedure through
so that the variable z(t) changes slowly while which sequential operations are split into
y(t) changes relatively rapidly. Clearly, a smaller tasks with separate hardware pro-
smaller time step is needed for y(t) than for vided for each of these subtasks. The hard-
z(t), and if this is implemented with two inte- ware performing the subtasks can operate
gration step sizes there will be a saving in the concurrently so that a number of operations
number of evaluations of the function g. This of the same kind can be at different stages
is clearly a complex operation in terms of the simultaneously. In general, each unit in the
software implementation since the evaluation pipeline is processing different data, and on
of g must be spread over several time steps completing its task the results are passed to
for y and is best achieved using an operating the next unit. This approach is widely applied
system which allows one task to interrupt within supercomputers, array processors and
another on a real-time basis. multiprocessor systems.
Chapter 15 includes further discussion of
the significance for simulation of some
14.5 SPECIAL-PURPOSE HARDWARE FOR
current hardware and software develop-
REAL-TIME DIGITAL SIMULATION
ments involving parallelism. However, rapid
improvements in the capabilities of more con-
14.5.1 INTRODUCTION
ventional hardware are tending to delay the
In a conventional digital computer with a von widespread adoption of parallel-processing
Neumann architecture there is a single methods in the simulation field. Major invest-
command register and, through this, at any ment in parallel-processing techniques will
one time, one arithmetic or logical operation probably not be seen as being worthwhile in
can be carried out on a single data word con- most fields of application until software
tained in the accumulator. This corresponds developments have taken place which allow
to a single instruction-single data (SISD) type an improved level of portability of applica-
of organization. Computer systems which tions programs.
have a number of processing elements, each
of which has an arithmetic unit and a memory
14.5.2 ARRAY PROCESSORS AND
unit, correspond to a single instruction multi-
MULTIPROCESSOR SYSTEMS
ple data (SIMD) type of organization, since
one control unit can activate all of the arith- Array processors are special-purpose devices
metic units and each arithmetic unit acts on which are intended to act as peripherals for a
different data. This SIMD type of organiza- conventional digital computer which acts as a
tion is implemented in vector processing host system. Array processors have had many
computers and in peripheral array processors. reported applications in real-time simulation
Multiple instruction-multiple data (MIMD) and results show major benefits in terms
organization takes these concepts a stage of performance when compared with that of
further, with each hardware element within the host machine on its own. The enhanced
the system including a control unit as well as computational efficiency is achieved through
an arithmetic and memory unit. The compu- parallelism and pipelining techniques.
tational efficiency of MIMD systems depends One highly specialized attached proces-
both on the efficiency of individual proces- sor of this kind which has been developed
sors and on the speed of the communication specifically for continuous system simu-
channels between the processors (e.g. ref. 11). lation applications is the AD-IOO processor
222 Real-time simulation
developed by Applied Dynamics Interna- simulation application, requires that careful
tional. This high-speed multiprocessor system attention be given to exploitation of the hard-
is normally used in conjunction with a Digital ware features as well as to the programming
VAX/VMS computer as host. The special- aspects. Automatic parallelizing compile~s
purpose architecture is based on pipelined are available, but are unlikely to produce the
parallel processing and a high-speed synchro- optimum performance unless used with care
nous bus. All the processors have their own and after careful consideration of the nature
memory, and a special-purpose I/O proces- of the simulation problem being considered.
sor is available to enable the AD-lOO to com- In general, tasks must be split between
municate efficiently with external hardware processors in such a way that interprocessor
in real time through analog to digital and communication is kept to a minimum [5, 11].
digital to analog converters. The host com-
puter is used for simulation program devel-
14.6 HARDWARE-IN-THE-LOOP
opment, for interactive control of simulation
SIMULATION AND PARTIAL-SYSTEM
experiments and for post-processing of
TESTING
results. The AD-lOO is programmed using a
special CSSL-like simulation language The most common applications of real-time
(ADSIM), with the simulation model being simulation involve situations in which a com-
defined and compiled entirely on the host puter simulation model is operated in con-
computer. The ADSIM compiler is capable of junction with external hardware or with a
searching for operations which can be per- human operator to form a closed-loop system.
formed simultaneously and optimizes the One important type of hardware-in-the-Ioop
code accordingly. Following the compilation situation arises quite commonly in the final
stage, an interactive command language stages of development of cOVlplex automatic
(INTERACT) is used to initialize the AD-100 control systems. Control equipment often has
and control the simulation experiment. to be tested extensively prior to installation on
Complete simulation systems of this kind, site to ensure that it will function in the
involving both hardware and software ele- required fashion in all conceivable operating
ments, have been marketed by Applied conditions. This testing must be carried out in
Dynamics International as products called circumstances which are as close as possible to
SYSTEM 100 and SIMsystem [12]. the real-life situation, and real-time simulation
provides a very convenient and satisfactory
approach to this problem. The controller hard-
14.5.3 TRANSPUTER-BASED PARALLEL
ware can be coupled to a computer which
SYSTEMS
simulates the equipment being controlled (the
A transputer is a VLSI computer on a single 'plant'). The interface between the real control
chip which can be used to produce a parallel hardware and the computer simulation must
computer. The T-800 transputer from the reproduce all the continuous and logical
INMOS Corporation is widely used in many signals which would be encountered in the
commercial systems which have considerable real plant interface on site.
relevance for simulation applications. Parallel Although automatic control applications
computers based on transputer technology are among the commonest examples of hard-
usually involve a large number of separate ware-in-the-loop simulation, this form of
transputers and should be capable of produc- partial-system investigation can also arise in
ing a considerable degree of parallelism. other fields. The benefits, whatever the nature
Good performance of a MIMD system, such of the application, are generally the con-
as a transputer-based parallel machine in a venience offered by the real-time approach in
Applications in training and education 223
allowing the performance of the combined mathematical model. This is normally
system to be investigated at relatively low checked by comparing the performance of the
cost, and in safety, for a wide range of normal real-time simulation with that of an offline
and abnormal operating situations. For fault non-real-time simulation program for as wide
conditions, testing by means of a simulation a range of conditions as possible. In addition
may well be the only practical way of fully to quantitative measurements, which can
evaluating the system design since deliberate indicate control system performance quality,
initiation of faults for testing purposes in the it may sometimes be useful in control applica-
real system may not be acceptable for operat- tions, such as that outlined above, to be able
ing reasons or because of safety constraints. to evaluate the performance of a real-time
The hydro-turbine speed-control system plant model under manual control. An experi-
discussed in Chapter 8 provides an interest- enced operator may well be able to detect
ing example of an investigation carried out at aspects of a real-time simulation model which
the University of Glasgow in which electronic are not typical of the real plant but which
control hardware was subjected to extensive may not be obvious from an examination of
testing in conjunction with a real-time simula- responses over a short period of time during
tion of the hydraulic and mechanical compo- a single test. The 'feel' of the real-time simula-
nents of the system prior to site tests. The first tion may, in some important way, differ from
real-time simulation work for this application that of the real system. Subjective assessments
involved hybrid simulation techniques [13], of this kind can be very revealing and may
but a real-time digital simulation facility was point to important deficiencies in a model.
subsequently developed and used for work Once the full system has been installed on
on- more advanced forms of turbine speed- site, commissioning checks may provide a
governing system involving microprocessor basis for further validation. If good agree-
control [14]. The controller hardware, corre- ment is obtained at this stage, for the com-
sponding to the block labeled 'governor' in plete range of test conditions considered,
Fig. 8.14, was connected to a nonlinear plant there is a reasonably high probability that
simulation model. This real-time simulation other results from the real-time simulation
model was considerably more complex than study for similar parts of the operating enve-
the highly simplified linear plant transfer lope can also be trusted.
function discussed in section 8.3, and in-
corporated water pipeline dynamics and
14.7 APPLICATIONS IN TRAINING AND
involved much nonlinear function generation
EDUCATION
in the modeling of the turbine characteristics.
Facilities were included within the simulation
14.7.1 INTRODUCTION
to allow a number of different situations to
be investigated, including system start-up, One of the most common applications of real-
normal operation at various levels of electri- time simulation is in the training of human
cal load, transient conditions following operators. The ground-based aircraft flight
sudden load changes and system shut-down. simulator is probably the most widely known
Effects of sensor noise, one of the common form of training simulator, but there are
problem areas in control system implementa- many other applications which are routinely
tions, can be investigated very easily and in a used in areas as diverse as space exploration
systematic fashion using this simulation- and exploitation, the maritime field, in the
based approach. chemical process industries, in the nuclear
The credibility of a real-time investigation industry and in railroad operation. Some
depends upon the validity of the underlying aspects of training simulators have been
224 Real-time simulation
mentioned, in passing, in previous sections of As well as safety and cost, the simulator
this chapter, but there are a number of more provides significant benefits in terms of
general issues which are relevant both to real- increased opportunities for training. For
time simulation for specialist training and to example, training flights in a real aircraft are
the broader issues of the role of real-time sim- highly dependent upon the weather condi-
ulation techniques in education, especially tions being acceptable, and such factors do
within science and engineering. not have to be considered in the case of train-
ing on a simulator. Other points in favor of
simulators for flight training include the ben-
14.7.2 SIMULATORS FOR OPERATOR
efits of reduced noise for those living near air-
TRAINING
ports, reduced atmospheric pollution and
The operation of modern engineering plant general energy saving.
and processes demands high levels of skill Although not all of the factors which are
and understanding. This is perhaps most significant for aircrew training on simulators
obvious in the case of aircraft, where the role apply in every other training situation, there
of simulators in training of pilots and other are many examples where there are import-
aircrew is well known and well understood. ant similarities. Simulators are being used
Real-time simulation has been used for many increasingly in training railroad drivers and
years in the aircraft industry for training pur- in navigational training using ship simulators
poses, and the flight simulator in particular [17], in both cases for reasons which are very
has proved its worth not only for the devel- similar to those which apply to pilot training.
opment of piloting skills but also for the The use of ship simulators not only provides
maintenance of those skills and for aircrew opportunities to monitor individual skills in
assessment. Many of the reasons for the wide- trainees but also their interactions with other
spread use of training simulators in civil and crew members. This is an important aspect of
military aviation are becoming increasingly training, and the monitoring of interactions
relevant in other areas, especially in context within a group is easily carried out using a
of the steadily increasing sophistication and simulator. This can be done both for normal
capital cost of equipment now under the and emergency situations with opportunities
control of one operator. for the generation of repeat situations for re-
The advantages of using simulators for evaluation purposes. Clearly, many of the sit-
aircrew training instead of the real aircraft uations which can arise on the bridge of a
are well documented (e.g. refs 15 and 16). large ship have counterparts in other fields
One of the most important benefits arises where monitoring the performance of a group
because the costs of aircraft are high, not of operators is as important as the develop-
~ i~ terms of ~apitl valu~ but also for ment of special skills in the individual.
operation and mamtenance. SImulator costs Training simulators are designed primarily
are a fraction of those of the aircraft itself for training applications, but some situations
under all of these categories. In addition, it may arise in which a training simulator can
should be noted that many training tasks, be used for engineering development work,
such as emergency procedures, tend to especially for evaluating new operating pro-
increase the cost of maintenance of aircraft cedures prior to implementing them on the
and may even reduce its fatigue life. real system. In such situations it is essential
Situations which could be potentially haz- that the simulator should be used only within
ardous in the air can be investigated repeat- the range of operating conditions for which
edly in a training simulator without risk to its performance is known to be acceptable.
personnel or to equipment. The fact that the underlying models within a
Applications in training and education 225
training simulator may involve an element of time may allow a better match to the average
emulation, as pointed out in section 14.1, human attention span and allow behavior to
clearly imposes limitations in this respect. be seen clearly, which would otherwise be too
slow or too rapid to be observed with ease.
For example, simulations which can be run
14.7.3 REAL-TIME SIMULATION IN
faster than real time are helpful in dealing
TEACHING
with topics in medicine or in chemical process
One limiting factor in the education of engin- engineering where time constants may be of
eers and scientists is the small scale of the the order of many minutes or hours. The
systems which can be investigated experi- MACPUF medical simulation [18], referred to
mentally in the laboratory. Simulation tech- in Chapter 2, provides an interesting example
niques provide opportunities for students to of this kind where clinical situations can be
gain experience of industrial-scale processes set up to run, where appropriate, in a
and of other systems, such as aircraft and timescale which is faster than real time and
ships which cannot be accommodated in the thus allow students to gain much valuable
laboratory except possibly in the form of scale experience in a relatively short period of time.
models. Simulation exercises must not, of Conversely, in the study of fast electro-
course, replace other forms of practical work. mechanical systems there may be important
They complement conventional experimenta- educational benefits in being able to take a
tion and are especially useful when the topic real-time simulation of a system and then sys-
being studied is inherently complicated and tematically slow it down until the sequence of
students may have problems in seeing the operations becomes completely clear. Analog
patterns of the relationships involved. simulation techniques, being truly parallel
Simulation allows students to experiment in and inherently fast, provide a very simple
ways that are often impossible using a more and flexible way of changing timescales and
conventional approach and ensures that they are, in many ways, highly appropriate for
have an active role which enhances the educational demonstrations. Analog comput-
opportunities for insight and discovery. ing facilities are, unfortunately, not always
Simulation-based investigations are not a available, but special-purpose hardware can
new development in education. However, the sometimes be built up to simulate a particular
special value of real-time techniques has not system using analog methods. Provided care
received as much attention as it should. In is taken with the analog electronics, the main
some areas of engineering real-time simula- advantages of analog computer methods,
tion can provide significant advantages over such as speed, can be retained and additional
non-real-time studies in that the real-time features incorporated, such as an easily used
approach makes students more immediately interface and display system.
aware of the dynamics of the system under It should always be remembered that a
investigation. Thus the student using a real- good educational simulation does not have to
time simulation interactively is able to gain a mimic the corresponding real system in
feel for the behavior of the system which is every respect. Carefully planned simplifica-
being represented, and this can add signifi- tions can help to focus the attention of the
cantly to the level of understanding. student on the essential features of the
In some cases there may be potential edu- system. A reduced model may therefore
cational benefits in providing facilities to provide more insight than a highly complex
allow a simulation of this kind to be run in a and more general representation, provided of
number of different timescales. Running a course the simplified model is used in an
simulation faster or more slowly than real appropriate way. As with other applications
226 Real-time simulation
of interactive computing, future develop- Simulation (ed. F.E. Cellier), Academic Press,
ments in this area will depend to a con- London, pp. 393-406.
siderable extent on the results of more 10. Gear, C.W. (1977) Simulation: conflicts
between real-time and software, in
fundamental studies concerning the way in Mathematical Software III, Proceedings of the
which humans and computers can be made to Symposium at the University of Wisconsin,
work together to the fullest advantage [19]. March 28-30, 1977 (ed. J.R Rice), Academic
Press, New York, pp. 121-38.
11. Rietman, E. (1990) Exploring Parallel Processing,
REFERENCES
Wind crest Books, Blue Ridge Summit, PA
1. Allworth, S.T. and Zobel, RN. (1987) 12. Fadden, E.J. (1991) The SIMsystem: a distrib-
Introduction to Real-time Software Design, 2nd uted system approach to high fidelity, hard-
edn, Macmillan, London. ware-in-the-Ioop simulation, report, Applied
2. Lewis, P.J. and Lord, E. (1984) An interactive Dynamics, Ann Arbor, MI (reprinted from the
modeling program for real-time applications, Proceedings of SimTec'91, October 21-23,1991).
in Proceedings of the 1984 UKSC Conference on 13. Bryce, G.W., Foord, T.R, Murray-Smith,
Computer Simulation, Bath (ed. D.J. Murray- D.J. and Agnew, P.w. (1976) Hybrid simula-
Smith), Butterworth, London, pp. 497-504. tion of water turbine governors. Simulation
3. Charlesworth AS. and Fletcher, J.R (1974) Councils Proceedings, 6 Part 1, 35-44.
Systematic Analogue Computer Programming, 14. Findlay, D.G.E., Davie, H., Foord, T.R et al.
Pitman, London. (1980) Microprocessor-based adaptive water
4. Ricci, F.J. (1972) Analog-Logic Computer turbine governor. Proceedings of the lEE, Part
Programming and Simulation, Spartan Books, C, 127,360-69.
New York. 15. Rolfe, J.M. and Staples, K.J. (1986) Flight
5. Matko, D., Karba, R and ZupanCic, B. (1992) Simulation, Cambridge University Press,
Simulation and Modelling of Continuous Systems, Cambridge, UK.
Prentice-Hall, London. 16. Baarspul, M. (1990) A review of flight simula-
6. Howe, RM. (1985) Transfer function and char- tion techniques, Progress in Aerospace Science,
acteristic root errors for fixed-step integration 27,1-120.
algorithms. Transactions of the Society for 17. Swift, AJ. (1987) Maritime training and teach-
Computer Simulation, 2 (4), 293-320. ing using real time simulation, in UKSC87,
7. Rosko, JS. (1972) Digital Simulation of Physical Proceedings of the 1987 UKSC Conference on
Systems, Addison-Wesley, Reading, MA Computer Simulation, Bangor (ed. RN. Zobel),
8. Howe, RM., Ye, X.A. and Li, B.H. (1984) An SCS Europe, University of Ghent, pp. 209-14.
improved method for simulation of dynamic 18. Dickinson, c.J. (1977) A Computer Model of
systems with discontinuous nonlinearities, Human Respiration, MTP Press, Lancaster.
Transactions of the Society for Computer 19. MacFarlane, AG.J. (1990) Interactive comput-
Simulation, 1 (1), 33-47. ing: a revolutionary medium for teaching and
9. Crosbie, RE. (1982) Interactive and real-time design, Computing. and Control Engineering
simulation, in Progress in Modeling and Journal, 1 (4), 149-58.
CURRENT TRENDS IN CONTINUOUS
SYSTEM SIMULATION 15

15.1 DEVELOPMENTS IN SIMULAnON by the Technical Committee TC3 of the


LANGUAGES International Association for Mathematics
and Computers in Simulation (IMACS), no
In discussing continuous system simulation formal specification emerged. Many of the
languages in Chapter 6 it was pointed out developments in simulation software which
that the only widely accepted 'standard' have taken place since 1981 are consistent
which exists for continuous system simula- with the ideas which were put forward in
tion software is the CSSL specification pub- that outline specification.
lished in 1967. Many important developments Central to the 1981 proposals was the desire
since that time have been based on the 1967 to retain many features of the 1967 specification
specification, but it is now recognized that which were considered to be of value while
software engineering principles, and other introducing some radical changes. Examples of
developments in hardware and software, new developments which were seen to be of
provide opportunities for some entirely new value included flexible program and data
concepts in simulation languages. New lan- structures, enhanced modularity in terms of
guages are already in use, such as ESL [1], the model definition, improved man-machine
COSMOS [2] and SYSMOD [3], which are in interaction through a user-friendly interface,
some respects fundamentally different from more efficient and convenient means of speci-
previous generations of simulation software fying simulation experiments, capabilities for
and were developed using software engineer- combined continuous and discrete-event simu-
ing principles. The ESL simulation language, lation and robustness in terms of numerical
which was developed at the University of algorithms, especially with respect to dis-
Salford in the UK with support from the continuity handling.
European Space Agency (ESA), is of particu- Modularity can provide major benefits in
lar interest. It was based upon outline propos- the simulation model development process. A
als produced at Salford in 1981 for a new large and complex model is much more easily
CSSL specification [4]. The ideas contained in subdivided using software tools which
that software specification did not define a encourage modular thinking. Hierarchical
complete simulation language and were decomposition of this kind allows the task of
intended to provoke discussion within the model development to be split more readily
simulation community. The proposals by the between a number of people working in par-
Salford group were an outline and allowed allel and helps to ensure that modules are of
flexibility and potential for contributions by a manageable size. Submodels greatly facili-
others by leaving many points of detail tate model testing because each com-
unspecified. Although discussed at consider- ponent section of a complex simulation can
able length by the CSSL Committee of the be internally verified, and in some cases
Society for Computer Simulation (SCS), and externally validated, in isolation. Fully tested
228 Current trends in continuous system simulation
submodels can then provide a basis for a frame. Breitenecker and Solar [7] have taken
library of simulation model components for a these concepts a stage further with their defin-
particular application area. If necessary, dif- itions of models, methods and experiments.
ferent integration algorithms can be used In Breitenecker's terminology a model is a
within different sections of a model and in the system description, a method is an operation
case of parallel processor applications differ- or algorithm which defines actions which use
ent submodels can be installed on different the model and an experiment is the process of
processors. applying a given method to a particular
Modularity and submodel concepts are model and includes execution control.
particularly evident in present-day simula- The emergence of software engineering
tion tools which provide a graphical interface. principles in recent years has also had an
Other advanced simulation tools, such as the important influence on the way in which new
SYSMOD language, also provide highly simulation products have been developed [8].
developed facilities for libraries of submodels The use of software engineering methods
and extend these concepts to libraries of can have a significant effect on the cost of
experiments. maintaining software, and the introduction
In considering the value of separating of simulation tools which allow software
models and experiments it must be stressed engineering principles to be applied to the
that the conventional simulation experiment, development and maintenance of complex
in which a single time-domain response is simulation models is an important step.
generated, is a very elementary form of Ideally, software engineering principles
experiment. More complex experiments should be applied to all phases of a large sim-
involving, for example, linearization, opti- ulation project but it must be recognized that,
mization, parametric studies and sensitivity at present, many commercially available sim-
studies are clearly important for many types ulation products do not provide all the neces-
of simulation user. A good simulation tool sary facilities. However, as with other
should make it possible for the user to define software development tasks, the user of simu-
such complex experiments with ease, quite lation languages can benefit considerably
separately from the definition of the model. In from adopting structured programming
a very basic continuous system simulation methods.
language, such as SLIM, the only way to
perform an experiment is through the
15.2 IMPROVEMENTS IN THE
INITIAL, DYNAMIC and TERMINAL sections
MAN-MACHINE INTERFACE
of the simulation program. Every time the
experiment is to be changed the simulation The user interface in simulation has to
program itself has to be changed. An alterna- provide facilities for model definition, for
tive is provided by the concept of the 'experi- experimentation with the simulation model
mental frame' which was introduced by and for the presentation of results. Trends in
Ziegler [5] and Oren and Ziegler [6]. This each of these areas will be examined in this
involves designing simulation tools in which section.
the model, the simulation experiment and In terms of model definition, current activi-
execution control features are separated. ties by the developers of simulation tools
Experiments are defined as a function of a appear to be almost exclUSively directed
model and an experimental frame, with toward the graphical interface and to the
model specification and experimental frame further enhancement of graphiCS editors of
specification at the same hierarchical level. the kind described in Chapter 7. However,
Execution control is at a hierarchical level there is a major division of opinion within the
below that of the model and experimental community of simulation users concerning
Developments involving parallel processor systems 229
the wisdom of adopting a graphical interface become 'immersed' in a simulated world
as the only or main method for model defini- through the use of visual displays built into a
tion. The provision of a graphical editor is helmet system equipped with head position
certainly seen as a useful enhancement to a sensors. Exploration of a simulated environ-
simulation environment, but it is not neces- ment in this way may involve not only vision
sarily ideal for all users. A graphical interface but also other senses such as touch through
is certainly of enormous value when a simula- the provision of special gloves. Already in use
tion model is being demonstrated or dis- for architectural planning applications, and
cussed with people who may be unfamiliar for some military purposes, this is a rapidly
with simulation languages. Beginners and developing field which has major implica-
inexperienced users may also find significant tions for the general area of human-computer
benefits from the use of a graphical editor, interaction [9].
but it is not clear whether a graphical inter- Post-processing facilities for presentation of
face for model development assists those who simulation results are becoming more and
are already efficient users of equation- more powerful as general-purpose graphics
oriented simulation tools. Development of a packages are developed and enhanced. In
block diagram on the screen can be a time- many situations, simulation results are most
consuming and frustrating task and does not conveniently displayed by exporting results
appeal automatically to all types of user. files from the simulation software to a
Separation of the model from the experi- general-purpose presentation package of
ment is an important feature of modern simu- some kind. Integration of simulation software
lation software, as discussed already in the with a powerful graphics environment and
previous section. This trend is likely to con- report-generating facility is essential for
tinue and further enhancement of the interac- many types of application, and new devel-
tive capabilities of simulation environments is opments are under way to provide such a
an important area in which much research user-friendly and fully integrated environ-
effort is currently being expended. One key ment. Other developments such as animated
issue, in terms of improved levels of interac- graphics will have an important impact on
tion, is that of response time and computa- the simulation community in some applica-
tional speed. The inherent parallelism and tion areas.
high bandwidth of analog computers allowed
levels of performance in terms of speed in
15.3 DEVELOPMENTS INVOLVING
some application areas which are still hard to
PARALLEL PROCESSOR SYSTEMS
match by digital techniques even on the most
powerful facilities available today. As a
15.3.1 HARDWARE DEVELOPMENTS IN
result, analog machines could provide a high
PARALLEL PROCESSING FOR SIMULATION
level of interaction and experimental con-
venience for the skilled user, which is also The concepts of multiple instruction-multiple
hard to match with a keyboard type of user data (MIMD) organization have already been
interface. Enhanced windows-based experi- introduced in Chapter 14 in the context of
mental environments may be of assistance in special-purpose digital computer hardware for
this respect. real-time applications. This form of architec-
In some application areas, virtual environ- ture is likely to be the most relevant for many
ment technology, which is still at a very early other advanced simulation applications which
stage in its development, may have a very attempt to exploit the benefits of parallelism.
important role in providing an improved user Massively parallel machines having a
interface for experimentation with simulation capacity approaching the teraflop level (10 12
models. This technology allows the user to floating-point operations per second) are
230 Current trends in continuous system simulation
already on the horizon and will inevitably cantly more work than the average over
lead to new areas of application for large- all the processes.
scale simulation techniques. 2. In order to reduce data movements and
avoid data access conflicts the distribu-
tion of computational tasks must reflect
15.3.2 SIMULATION SOFTWARE FOR
natural boundaries in the model.
PARALLEL PROCESSOR SYSTEMS
In the context of boundaries, it is interest-
The problem with parallelism in a simulation
ing to consider the fact that a computation
context is that, in order to exploit the computa-
which can be formulated in terms of commu-
tional power of parallel architectures, a very
nicating processes can also be described using
large amount of effort will have to be devoted
graphs. A graph structure of the computation
to the development of new computational
involves a set of directed graphs in which
methods. Algorithms developed for sequential
nodes represent communicating processes
machines must be adapted to a parallel form
and arcs carry the data dependency relation-
or new algorithms found which exploit the
ships between the computations executed at
parallelism in a natural way. More user-
the nodes. Each node may be associated with
friendly and more reliable system software
a separate processor. The graph structure of a
and applications packages must be developed
computation model thus has analogies with
for parallel architectures.
the graphical representation of dynamic
An improved level of portability for appli-
system models. These are also directed
cations programs on parallel systems is of
graphs and thus provide a possible basis for a
great importance since users are unlikely to
systematic approach to the allocation of
be willing to invest time and effort in
processors for the parallel execution of a
repeated parallelization of existing code. The
simulation model.
most promising approach to the portability
One interesting feature of some new lan-
problem may well be through the creation of
guages are 'segments' [8]. These are parts of a
a machine-independent user interface which
model which communicate with each other
incorporates constructs for all the necessary
only at predefined instants of time and have
parallel communication and process manage-
proved to be especially convenient in a multi-
ment functions. One example of an interface
processor environment. Variables transferred
of this kind is PARMACS [10], which has
between segments are treated as being con-
been developed at the Gesellschaft fur
stant between communication instants.
Mathematik und Datenverarbeitung (GMD)
in Germany.
An interesting overview of methodological
15.4 ARTIFICIAL INTELLIGENCE AND
implications of parallel systems on high-per-
SIMULATION
formance scientific computing is provided by
a recent paper by Linden, Schuller and This section is concerned mainly with discus-
Trottenberg [11]. A number of issues of direct sion of some techniques which are widely
relevance to continuous system simulation used by the artificial intelligence (AI) commu-
are highlighted in that paper and criteria are nity which are believed to have significance
given for efficient execution on parallel in the broader fields of modeling and simula-
systems. In the context of simulation these tion. Potential contributions of the tools of
criteria mean the following: continuous system simulation to AI are not
considered in detail and should be evident to
1. The workload of the processes should be any AI specialist from reading other sections
balanced so that no process has signifi- of the book.
Artificial intelligence and simulation 231
In recent years much research has been involve uncertainties within the system
carried out to investigate possible ways in description. Rule-based systems could, in
which links between techniques of AI and principle, be used not only as advisory
techniques of dynamic modeling and com- systems but also as systems linked to simula-
puter simulation can be exploited. Examples tion models for decision making and intelli-
of cross-links of this kind include the possible gent control.
use of heuristic and fuzzy knowledge within Advisory systems are systems which give
a traditional form of simulation language. advice to the user on a chosen topic following
This covers both the application of expert a process of consultation. They have potential
system techniques to simulation and methods applications in continuous system simulation
for the development of dynamic models in a number of different areas. These include
which have a more qualitative form than has highly technical areas such as the selection of
been common in traditional approaches to integration algorithms and much broader
continuous system simulation. areas involving knowledge of the modeling
process. One complication is the fact that sim-
ulation is applied to a very wide range of dis-
15.4.1 KNOWLEDGE-BASED SYSTEMS IN
ciplines and advisory systems may have to
MODELING AND SIMULA nON
cover the domain of application as well as the
A knowledge-based system may be defined simulation aspects. O'Keefe [13] has sug-
as a computer program which brings together gested that it may be necessary therefore to
the use of knowledge and inference processes distinguish between simulation advisory
to solve problems which are of sufficient com- systems for domain experts and domain advi-
plexity to otherwise require a reasonably high sory systems for simulation experts.
level of human expertise for their solution. In Decision-support systems involve the gen-
the case of specialized areas of application the eration of predictive information which can
knowledge-based software is frequently be of assistance for decision making. Expert
termed an 'expert system'. systems have potential for assisting in the
Two broad classes of knowledge-based experiment stage of the modeling and simula-
system can be defined. These differ in terms tion process through, for example, the inter-
of the knowledge representation methods pretation of trends and the definition of new
used and are termed 'rule-based' systems and experiments. Few applications have been
'frame-based' (or 'object-oriented') systems. reported in the continuous system simulation
Both classes are potentially important for field so far.
simulation applications. The frame-based
approach is discussed separately in section
15.4.2 KNOWLEDGE REPRESENTAnON
15.4.2. This section is concerned primarily
USING FRAMES AND INHERITANCE
with the use of the rule-based approach in
simulation and with the role of expert Nielsen [14] has suggested that, although AI
systems. techniques have a potential role in a number
As has been pointed out by Kerckhoffs and of different areas within the simulation field,
Koppelaar [12], there are important similari- the most significant contributions are likely to
ties between knowledge-based programs and be in terms of knowledge representation
simulation programs. For example, both must within a model. The concepts of frames and
incorporate knowledge and expertise about a inheritance and the associated field of object-
system and its behavior, both involve flow oriented programming are of special impor-
control within the program, which depends tance in this respect. Frame-based methods
on the results of logical decisions, and both and object-oriented programming techniques
232 Current trends in continuous system simulation
have been widely adopted by the AI commu- assembled using relations such as 'belongs to'
nity as a basis for knowledge representation, or 'has a'.
but have wide applicability in other areas, Claims have been made that object-oriented
including simulation. Indeed it may be programming methods allow a separation of
claimed that many of the concepts of object- functions which, in terms of modeling, allow
oriented programming are derived from chosen model functions to be changed with
features of the Simula language, which was minimal effect on the remainder of the model.
developed in the 1960s for discrete event This is of considerable interest for continuous
simulation applications [15]. system simulation applications, but it must be
An object (or frame) resembles a record. It pointed out that applications of object-
has a name and information about it as an oriented techniques to continuous system
entity. So-called 'roo!' objects are generic enti- simulation lag considerably behind applica-
ties which underlie more specific objects. tions in the discrete-event simulation field. The
These specific objects have a capability of entities conventionally used by the discrete-
inheriting information from the generic event simulation community can very readily
objects in the knowledge base, as in inheri- be considered as objects in an object-oriented
tance from a parent to a child. formulation, but the move to object-oriented
Two types of data, factual and behavioral, methods by the continuous systems simulation
are associated with each object. The factual community involves a more fundamental
data establish the capabilities, state and para- process of re-education. As has been pointed
meters of the object, while the behavioral data out by Nielsen [14], the concepts of object-
characterize the behavior of the object under oriented programming were first made avail-
given conditions. More specifically, each able through features of the discrete-event
object has a number of 'slots' which represent simulation language Simula and are now
class properties, and each of these slots is being returned to the simulation community in
made up of 'facets'. One of these facets con- an improved form through modern object-
tains an attribute, while another contains a oriented software tools such as SmallTalk. An
value, or fact or rule associated with that informative review of object-oriented methods
attribute. Slot values are inherited from and the potential benefits of this type of
parent object to child object. Objects can thus approach for engineering applications is
be considered as representing a broad class of provided in a paper by Barker et al. [16].
a particular type of item, a subclass, a sub-
subclass, and so on until an object is defined
15.4.3 QUALITATIVE MODELING AND
which is a specific instance and is unique.
QUALITATIVE SIMULATION
Messages sent to an object either initiate
specific behavior or a response which is based The term 'qualitative modeling' can be viewed
on selected factual data, such as the current in a number of ways, and has been touched on
state of the object. Knowledge bases within an already in earlier chapters of this book. It can
object-oriented simulation should incorporate include, for example, the assessment of models
facts about each object in the system being and of model performance in terms of qualita-
modeled and information about the relation- tive features and links closely with discussion
ship between a given object and other objects. in Chapter 9 concerning model validity.
Any new entity introduced may be a member Depending upon the nature of the intended
of a particular class of entities already application, and the level of prior knowledge
defined, with certain differences in terms of available about the system being considered, a
the number of slots, the slot values or defined model may be validated externally at a
relationships. Complete systems may be number of different levels, some of which put
References 233
more emphasis on qualitative features than on one may be forced to start the modeling
precise quantitative data. The same division process in a purely qualitative way using a
can also be applied to other aspects of the causal graph or some form of cause and effect
modeling and simulation cycle. Qualitative table for the system description instead of a
modeling is, in itself, not a new concept and set of differential equations. Bond graph
was not developed exclusively by those in the modeling can be particularly helpful in this
AI field. For example, the study of socioeco- respect and provides a generic method of
nomic problems through the application of approach which is applicable to a wide range
Forrester's 'system dynamics' methods [17, 18] of different domains in which the underlying
involves well-established tools, such as concepts such as effort, flow, inertia and
DYNAMO [19], which encourage qualitative capacitance can be used. In the case of
thinking. Users of such established software outputs it may not always be helpful to
tools can start by establishing a causal graph emphasize precise numerical values in the
from which code can eventually be written. assessment of the output, although these are
What is new, and has come in part from the AI likely to be available from a simulation in
community, is the more systematic study of quantitative form. For example, in the model-
qualitative methods. ing of biological systems or in socioeconomic
Qualitative modeling and simulation system simulation, many situations can arise
methods generally emphasize qualities of a in which it is more useful to characterize the
system and of system behavior, and the term form of the output using qualities rather than
'qualitative' may be applied to the model, to precise quantitative values.
the model output, and to the input. There is It is clear from this brief outline of the field
no well-defined dividing line between quali- of qualitative modeling and simulation that
tative techniques and quantitative techniques, qualitative methods should not be viewed
but it must be stressed that the qualitative merely as an esoteric alternative to quanti-
approach puts particular emphasis on the tative techniques. The development of tools
study of high-level features of the system for qualitative simulation should set the
being simulated. process of modeling on a firmer foundation
In many cases quantitative descriptions can and, as Fishwick [20] suggests, should allow
evolve from a model which is available ini- 'simulation model engineering' to be defined
tially only in qualitative form. This can as a new area akin to 'software engineering'
perhaps be best understood by considering in computing science.
inputs, models and outputs separately in the
first instance. In the case of inputs there are
many situations in which the model devel- REFERENCES
oper may be lacking in precise information 1. Crosbie, R.E., Javey, S., Hay, JS. and Pearce,
about the true nature of the system input. A J.G. (1985) ESL - a new continuous system
starting point may be to define the input simulation language. Simulation, 44 (5), 242-46.
using qualitative terms such as 'decreasing' 2. Kettenis, D.L. (1986) COSMOS: a member of a
or 'oscillating' or 'pulsing' and attempt at a new generation of simulation languages, in
later stage in the model development to Proceedings of the 2nd European Simulation
define these inputs in a more quantitative Congress, 1986, Antwerp, SCS Europe,
University of Ghent, pp. 26~9.
fashion. Appropriate adjectives such as 'lin- 3. Baker, N.J.C. and Smart, P.J. (1983) The
early' or 'exponentially' or 'almost' can be SYSMOD simulation language, in Proceedings
used to modify the chosen qualities in some of the 1st European Simulation Congress, 1983,
way. Similarly, in the case of a model, there Aachen (ed. W. Ameling), Springer, Berlin,
may be so many uncertainties initially that pp.281-86.
234 Current trends in continuous system simulation
4. Hay, J.L. (1981) A new CSSL Standard: an ductory review, in Biomedical Modeling and
implementation view, in UKSC8l: Proceedings Simulation on a PC (eds RP. van Wijk van
of the UKSC Conference on Computer Simulation, Brievingh and D.P.F. Moller), Springer, New
1981, Harrogate, Westbury House, Guildford, York, pp. 53-73.
pp.35-43. 13. O'Keefe, RM. (1986) Advisory systems in sim-
5. Ziegler, B.P. (1976) Theory of Modelling and ulation, in AI Applied to Simulation, Simulation
Simulation, John Wiley, New York. Series, Vol. 18, No. 1 (eds E.J.H. Kerckhoffs,
6. Oren, T.I. and Ziegler, B.P. (1979) Concepts for G.c. Vansteenkiste and B.P. Ziegler), Simu-
advanced simulation methodologies. Simu- lation Councils, San Diego, CA, pp. 73-78.
lation, 32 (3), 69-82. 14. Nielsen, N.R (1991) Application of artificial
7. Breitenecker, F. and Solar, D. (1986) Models, intelligence techniques to simulation, in
methods and experiments - modern aspects of Knowledge-based Simulation (eds P.A. Fishwick
simulation languages, in Proceedings of the 2nd and RB. Modjeski), Springer, New York,
European Simulation Congress, 1986, Antwerp, pp.1-19.
SCS Europe, University of Ghent, pp. 195-99. 15. Dahl, O.J. and Nygaard, K. (1966) SIMULA -
8. Hay, J.L. (1986) ESL - advanced simulation An Algol-based simulation language. Com-
language for parallel processors, in Parallel munications of the ACM, 9, 671-78.
Processing Techniques for Simulation (eds 16. Barker, H.A., Grant, p.w., Jopling, c.P. and
M.G. Singh, A.Y. Allindina and B.K. Daniels), Townsend, P. (1993) The object oriented
Plenum Press, New York. paradigm: a means of revolutionising soft-
9. Sheridan, T.B. (1992) Telerobotics, Automation, ware development. Computing and Control
and Human Supervisory Control, MIT Press, Engineering Journal, 4 (1), 10-14.
Cambridge, MA, Section 2.8, pp. 199-212. 17. Forrester, J.w. (1961) Industrial Dynamics, MIT
10. Bomans, L., Hempel, R and Roose, D. (1990) Press, Cambridge, MA.
The Argonne/GMD macros in FORTRAN for 18. Forrester, J.w. (1971) World Dynamics, Wright-
portable parallel programming and their Allen Press, Cambridge, MA.
implementation on the Intel iPSC/2. Parallel 19. Roberts, N, Andersen, D., Deal, R et al. (1983)
Computing, 15, 119-32. Introduction to Computer Simulation: A System
11. Linden, J., Schuller, A. and Trottenberg, U. Dynamics Approach, Addison-Wesley, Reading,
(1992) Methodological aspects of high perfor- MA.
mance scientific computing, in Computational 20. Fishwick, P.A. (1991) Methods for qualita-
Systems Analysis 1992 (ed. A. Sydow), Elsevier, tive modelling in simulation, in Knowledge-
Amsterdam, pp. 1-10. based Simulation (eds P.A. Fishwick and
12. Kerckhoffs, E.J.H. and Koppelaar, H. (1993) RB. Modjeski), Springer, New York,
Artificial intelligence and simulation: an intro- pp.36-52.
APPENDIX A
THE LAPLACE TRANSFORM

A.1 INTRODUCTION Table A.1 Table of Laplace transforms for some


common functions
Laplace transform techniques are based upon
the definition of the direct Laplace transform Time function x(t) Laplace transform Xes)
F(s) of the function f(t). This definition is as
follows: Unit impulse 1

1
Sf' [f(t)] = F(s) = J
f(t)e- st dt t >0 (A1)
Unit step
s
1

The quantity s which appears within this inte- -at 1


e
gral is a complex variable. By convention, s+a
capital letters are used to denote transformed 1
t e-at
variables, so that f(t) in the time-domain (s+a)2
transforms to F(s) in the s-domain.
Although equation (A1) allows the trans- sin wt
form of a given time-domain function to be
S
dl!termined from first principles, it is seldom cos wt
S2 +w 2
necessary to go through this process in prac-
tice. Tables of Laplace transform pairs are
widely available (e.g. ref. 1), and Table A1
provides examples of a few common func- necessary first to accept some simple theo-
tions in the time domain along with their rems which are presented here without proof.
s-domain equivalents.
Laplace transforms are important for the A.2 LINEARITY THEOREM
study of linear dynamic systems in that they
provide a very convenient way of solving
linear time-invariant ordinary differential
equations. The transformed equations are This theorem states that the transform of a sum
purely algebraic in form, and the process of of terms is the sum of the transforms of the
finding differential equation solutions is con- individual terms. Also, the transform of a con-
siderably more straightforward using this stant times a given function fit) is given by the
approach than by other well-known methods. constant times the transformed variable F(s).
Having found a solution in the s-domain the
tables of transforms may be used in the reverse A.3 DIFFERENTIATION THEOREM
direction to find a solution in the time domain.
In order to be able to apply Laplace trans-
form techniques to practical problems it is
Sf' [dt] = sF(s) - f(O) (A3)
236 Appendix A

The Laplace transform of this linear ordinary


Y I::t1= S2 F(s) - s/(O) - dt (0) (A4) differential equation is

~ (0)]
Y [ :;t] = s" F(s) - s"-I/(O)
M[S2Y (S)-SY(0)-

+ R[sY(s) - y(O)] +KY(s) = F(s) (AlO)


_S"-2 dl (0) _ ... _ d "-I1(0) (A5)
dt dt"-I When the initial condition for the velocity is
zero we have
This theorem giyes the transform of a deri-
vative of any order. Note that this always MS2Y(S) + RsY(s) + KY(s)
involves initial values of the time-domain
= Msy(O) - Ry(O) + F(s) (All)
function I(t) and its derivatives, evaluated at a
time instant just before any forcing input is and solving for Y(s) gives
applied. This means that if all initial con-
ditions are zero it is possible to regard s as the Y(s) = (Ms + R)y(O) + F(s) (A12)
differential operator so that MS2 +Rs+K MS2 +Rs+K

d For the particular case where M = 1 kg,


s=- (A6)
dt K = 2 N m- I and R = 3 N m-I s and where there
is no applied force l(t), this is
Similarly, the integral operator is given by
Y(s) = (s + 3)y(O) (A13)
1 }t
;= dt (A7) (s+ 2)(s+ 1)
o
which may be rewritten, using a partial frac-
tion expansion, as
A.4 FINAL VALUE THEOREM
-1 2
Y(s)=-+- (A14)
One additional result, which is useful in some s+2 s+l
situations, is that the final or 'steady-state'
value of a variable can be determined directly From Table Al this means that the complete
from the Laplace transform of that variable response in the time domain for the imposed
without having to carry out the inversion initial condition is given by
process. This is because of the existence of the
final value theorem, which states that Y(t) = 2e -t -e -2t (A15)

limf(t) = limsF(s) (A8) A graph of y(t) would provide the complete


t~o s~o
time history. Note that, although it is clear
from the form of y(t) that the final value in
this case is zero, the final value could have
A.S EXAMPLE
been obtained in one step from the transform
Consider the problem of determining the Y(s) using the final value theorem.
forced motion of a mass-spring-damper sys-
tem described by the second-order equation
REFERENCE
d 2 d 1. Doebelin, E.O. (1985) Control System Principles
M -.JL + R -.lL + Ky = I(t) (A9)
dt 2 dt and Design, John Wiley, New York, Chapter 2.
APPENDIXB
THE TRANSFER FUNCTION

The transfer function of a linear system is One very important point about a transfer
defined as the ratio of the Laplace transform function model is that, when it is used as an
of the system output variable to the Laplace element within a description of a larger
transform of the system input variable, with system, there are constraints on the type of
all initial values taken to be zero. It is there- interactions which are allowed with other ele-
fore inherently an input-output form of ments of the system. More specifically, it is
system description and does not provide any essential to ensure that the device which the
information about the internal system struc- transfer function represents does not load the
ture or about any intermediate variables. source that provides the input signal.
For the mass-spring-damper system of Similarly, the output of the device must not
equation (A.9) in Appendix A the transfer be loaded by the element that follows it and
function is obtained from the transformed receives its output signal. Thus, in electrical
equation with zero initial conditions. This terminology, it may be said that an element
gives the following equation described by a transfer function ideally has
input from a source with zero (or low) inter-
Ms2y(S) + RsY(s) + KY(s) = F(s) (B.1) nal impedance and supplies its output to an
element which has infinite (or high) input
The transfer function is therefore given by impedance. If these conditions are not satis-
fied the transfer function model will be incor-
G(s) = yes) = 1 (B.2) rect. The process of ensuring that a transfer
F(s) MS2 +Rs+K function description satisfies appropriate
interaction constraints is essentially part of
The denominator of the transfer function, the process of establishing suitable bound-
when set equal to zero, is called the charac- aries for the sub model which the transfer
teristic equation, since the roots of this function represents. Further details of trans-
equation characterize the time response fer function modeling techniques may be
whatever the input forcing function. The found in many textbooks on dynamics and
roots of the characteristic equation are called control (e.g. ref. 1).
the poles of the system transfer function.
Roots of the equation formed by equating
the numerator polynomial to zero in the REFERENCE
same way are known as zeros of the system 1. Thaler, G.J. (1989) Automatic Control Systems,
transfer function. West Publishing, St Paul, MN, Chapter 2.
APPENDIXC
BLOCK DIAGRAMS AND SIGNAL FLOW
GRAPHS

C.l INTRODUCTION block diagram variables. For example, if one


considers the combination of two blocks con-
The block diagram representation of a system
nected in cascade, as in the first entry of
is widely used in many fields, but is particu-
Fig. C2, it is clear that we can write
larly important in control engineering. It has
been adopted in continuous system simula-
tion mainly because of the insight which this (Cl)
form of system description has been found to
provide and, to a lesser extent, because of where X/s) is the input to the first block and
historical links with analog simulation tech- X2(s) is the output. Similarly for the second
niques in which block diagram representa- block the output is
tions were central to the development of a
simulation model. Signal flow graphs are
(C2)
very similar to block diagrams in terms of the
information which they convey.
Hence, it follows immediately that
C.2 BLOCK DIAGRAMS
A block diagram consists of a set of intercon-
nected unidirectional blocks representing
operations within the system under consider- and thus the two blocks in cascade are equiv-
ation. These blocks may be single elements, alent to a single block having a transfer func-
such as a gain factor, a coefficient, an integra- tion equal to the product of the individual
tor, a multiplier, a nonlinear function or a transfer functions. It is important to note that
summing element. They may also be transfer in carrying out this operation it is assumed
functions representing a more complex sub- that the loading effect of the second block on
model. Figure Cl shows some typical linear the first block is negligible. If this is not the
block diagram elements with the correspond- case, a combined transfer function must be
ing equations. derived from first principles, as explained in
For the purposes of analysis it is often Appendix B. A second important example of
useful to reduce a block diagram so that it reduction processes involves the elimination
involves a smaller number of blocks and of a feedback loop, as in the last entry in
fewer separate closed loops. Block diagram Fig. C2. Here the most convenient starting
reduction is a straightforward process in the point is to define the difference between the
case of linear systems, and Fig. C2 shows input Xj(s) and the feedback signal X3(s) as a
some simple block diagram transformations. new variable E(s). Thus
These transformations and reduction pro-
cesses arise directly from the algebra of the (C4)
240 Appendix C
a) Gain factor or coefficient

yet) = Iru(t)

yes) = kU(s)

yet)
yet) = UI(t) + u,(t) + u,(t)

Yes)
yes) = UI(s) + U,(s) + U,(s)

c) Integrator

~J +1 t
yet) = yeO) u(r)dr
o

~'J Yes) = U(s)/s

d) Traosfer function

"(.J J" I Y('J


I s +s + 1 I Yes) = U(s)/(s' + s + 1)

Fig. C.l Examples of linear block diagram elements. Where appropriate both s-domain and time-domain
versions are given. The time-domain versions are also applicable in block diagrams involving nonlinear
functions and other nonlinear elements, such as multipliers and dividers.

and it follows that since (e.7)

(e.S) and thus

and
(e.S)
(e.6)
The complete feedback loop may therefore be
the equations (e.4), (C.S) and (C.6) may be replaced by a single block having a transfer
combined to give function
Signal flow graphs 241
a) Combination of cascaded blocks

b) Combination of blocks in parallel

----8-
c) Elimination of a feedback loop

--1
Fig. C.2 Examples of simple block diagram operations.

it produces a diagram which is less cumber-


G(s) = G1(s) (C.9)
1 + G1 (s)G 2 (s) some than the equivalent block-based
description. Another possible advantage of
Further details of block diagram analysis flow graph descriptions is the availability of a
techniques can be found in many textbooks flow graph reduction formula (Mason's gain
concerned with automatic control systems rule) which can be of assistance for the reduc-
analysis and design (e.g. ref. 1). tion of linear models in flow graph form [1].
The basic element within a signal flow
graph is a line segment which forms a uni-
C.3 SIGNAL FLOW GRAPHS
directional branch which is equivalent to
Signal flow graphs present the same informa- a block in a block diagram representation.
tion as a block diagram but involve the use of The input and output points are nodes. All
line segments and nodes instead of blocks branches leaving a node transmit the nodal
and summing points. The main advantage of signal to the output node of the branch in ques-
the signal flow graph approach is the fact that tion. All branches entering a node give a total
242 Appendix C

U 6 Y
a) 0 ) 0 Y(s) = G(s)U(s)

Y1
Y,(s) G,(s)U(s)

c) Y2 Y,(s) = G,(s)U(s)

Y,(s) = G,(s)U(s)

Y3

d) Y(s) = G,(s)U,(s) + G,(s)U,(s) + G,(s)U,(s)

Fig. C.3 Signal flow graph examples.

node signal which is the sum of the individ- REFERENCE


ual branch outputs. Nodes can thus act as 1. Thaler, G.J. (1989) Automatic Control Systems,
junctions, for both incoming and outgoing West Publishing, St Paul, MN, Chapter 2.
signals. Figure C.3 provides some simple
illustrative examples.
APPENDIXD
DISCRETE-TIME MODELS AND
SAMPLED-DATA THEORY

D.l INTRODUCTION D.3 DISCRETIZATION OF A


CONTINUOUS-TIME MODEL
Discrete-time models, sampled-data theory
and digital control are topics which are Consider the standard linear time-invariant
covered in considerable detail in many spe- system model
cialized texts in the control, signal processing
and communications areas (e.g. ref. 1). Useful x(t) = Ax(t) + Bu(t) (0.3)
introductions are to be found in many general
textbooks on automatic control principles y(t) = Cx(t) + Du(t) (0.4)
(e.g. refs. 2 and 3).
where x(t) is the system state vector, u(t) is
the input vector and y(t) is the output vector.
It can be shown readily (e.g. ref. 3) that the
D.2 DISCRETE-TIME MODELS response of a system model in this form, in
In discrete-time systems, the states, inputs terms of the system state, is given by
and outputs are defined only at discrete time
intervals. For linear discrete-time systems the
dynamic behavior may be described by a set
f
I

x(t) = eA1x(O) + eA(t-riBu(r)dr (0.5)


o
of difference equations of the form

x(k + 1) = Ax(k) + Bu(k) (0.1) In sampled-data systems, and in other sys-


tems which incorporate analog to digital con-
verters, such as a digital control system, the
y(k) = Cx(k) + Du(k) (0.2)
input u changes only at discrete instants of
time. This implies the presence of a hold func-
where x(k), u(k) and y(k) are the values of the tion which gives an output
state vector, input vector and output vector
respectively at time t = kT. Here k is an u(t) = u(k) kT::s t::s (k + l)T k = 0,1,2, ...
integer and T is a fixed sampling time inter-
val. This pair of equations can also represent (0.6)
a continuous system in which all the rel-
evant variables are sampled at time inter- where T is the sampling period. From equa-
vals T. tion (0.5) it follows that
244 Appendix D
(k+l)T Hence, in situations where only the response
x(k + 1) = e A (k+l)T x(O) + f eA(kT +T -"l") BU(T )d T at the sampling instants is relevant, the con-
o tinuous set of state equations (equations 0.3
and 0.4) may be replaced by the discrete time
(0.7)
equations
and thus
(0.12)

(0.13)
f
(k+l)T

+ eA(kT+T-t)Bu(T )dT (0.8)


where
kT

where x(k + 1) denotes the value of x(t) at time


t = (k + l)T. The input u is constant within the
~
A.. e" B, ~ B[J e'"da)
interval kT to (k + l)T and equation (0.8) is Cd =C Dd =D
thus equivalent to
D.4 THE SAMPLING PROCESS

Figure 0.1 shows a schematic diagram of the


sampling process in a sampled-data system
(0.9) or digital control system. In this diagram, the
samples, shown by vertical lines of length
This is identical to an equation of the form proportional to the continuous signal at the
time instant of each sample, are held constant

~
during each sample interval by the action of a
x(k + 1) e" x(k) + BU(k{J eMda) (0.10) zero-order hold device. This is essentially the
same as the hold function assumed in the
analysis of section 0.3. A zero-order hold is
where the simplest type of hold device and simply
maintains its output at the level of the preced-
a=(k+1)T-T (0.11) ing sample until the next sampling instant

T
uft) / ulll .. jlERO-ORDER yltl
-----., ee-----_. HOLD

Fig. D.l Schematic diagram of the sampling process.


The sampling process 245
occurs. Figure D.l may be regarded as a sim- z-transform of a signal, in terms of an infinite
plified model of the action of an analog to series representation, the coefficient of each
digital converter: a sample is taken and con- negative power of z represents the sampled
verted to an equivalent digital number which value of the underlying continuous signal at
is held at the converter output until the next the time instant under consideration.
sample is taken. It should be noted that, unlike Laplace
In mathematical terms, the sampling transforms where there is a unique time-
process is conventionally represented by the domain function for any given function in the
multiplication of the continuous signal being s-domain, many different functions in the
sampled by a train of unit impulses at the time domain can correspond to a given z-
sampling instants. Thus for a continuous domain function. The inverse z-transform is
signal x(t) we have a sampled signal x*(t) therefore not unique. This may be understood
given by the equation very readily in physical terms if one considers
the sampling of a sinusoidal function. Unless
k=~
one samples the continuous waveform at a
x' (t) = L x(kT)8(t - kT) (D.14) frequency which is high compared with the
k=~
frequency of the sinusoidal signal one obtains
a discrete representation which could be
where 8(t - k n represents a unit impulse at fitted equally well by many other continuous
time t = kT. Applying the Laplace transforma- waveforms. In the limit, if one samples the
tion to equation (D.14) gives sinusoidal waveform only once per cycle the
sampled record becomes identical to that
k=~

F'(s) = Lx(kT)e-kTS (D.15) obtained from sampling a constant source.


k=~
This has important implications in simulation

This leads to the definition of the z-transform


Table 0.1 Table of z-transforms for some common
which is a powerful tool for the analysis of functions
sampled-data and digital systems. Let one
define Time function x(t) xCi) z-transform X(z)
z
(D.16) Unit step Unit step
z-1
so that equation (D.15) becomes Tz
iT
(z-W
k=~
pz(z + 1)
X(z) = L x(kT)z-k (D.17) t' (m' (z _1)3
k=~
z
e-<" f3'
Equation (D.17) represents an infinite series in z-f3
[Link] many practical situations the lower t e-<" Tf3z
iTf3'
limit in the summation may be taken as zero (z - f3)2
since we are concerned with the time history sin(8)z
sin wt sin(iO)
of sampled values after some event which is z' - 2 cos(8)z + 1
defined as the time origin. Closed forms can 1-cos(8)z
be derived for the z-transforms of many cos wt cos(i8)
Z2 - 2 cos(8)z + 1
important functions, and Table D.1 provides
some examples. It should be noted that in the
246 Appendix D
and in the interpretation of graphical results REFERENCES
from simulation programs.
One important point about the sampling 1. Isermann, R. (1989) Digital Control Systems,
process is that there is an effective time 2nd edn, Springer, Berlin.
2. Thaler, G.J. (1989) Automatic Control Systems,
delay introduced by a zero-order hold. This West Publishing, St Paul, MN, Chapter 9.
amounts to approximately one-half of the 3. Jamshidi, M., Tarokh, M. and Shafai, B. (1992)
sampling period. Such a delay can have an Computer-aided Analysis and Design of Linear
important destabilizing influence in closed- Control Systems, Prentice-Hall, Englewood
loop systems. Cliffs, NJ.
APPENDIXE
SLIM SOFTWARE INSTRUCTIONS

E.1 INTRODUCTION files created by SLIM may of course also be


used as input to user-written programs in-
A number of different versions of SLIM have
volving more standard and more versatile
been developed. All incorporate the basic
graphics software. SLIMPLOT provides only
facilities outlined in Chapter 6. Some versions
the most basic facilities.
have additional features which extend the
Simulation programs for the Van der Pol
capabilities of the simulation language
oscillator of Chapter 6 and for each of the
through the introduction of pure time delays,
examples considered· in Chapter 8 are
function tables and a choice of integration
included on the diskette. SLIM files are also
algorithms. Other versions of SLIM provide
included for the models used in the case
additional features which are of importance
studies of Chapters 10, 11 and 12.
for simulation in specialized application
areas, such as neurophysiology, and are not
intended for more general applications. E.2 HARDWARE REQUIREMENTS
The SLIM software included on the diskette
accompanying this book is the most basic The SLIM and SLIMPLOT programs run on
version of the SLIM family. Only one integra- any IBM-compatible personal computer
tion method is available and features such as running the Microsoft DOS (MS-DOS) operat-
function tables, pure delays, the use of arrays, ing system. A computer with at least an 80286
the use of multiple DERIVATIVE sections, or 80386 microprocessor is preferred, although
submodel capabilities etc. are not provided. not essential. It is also recommended that the
Such features may be found in many commer- computer has the 80287 or 80387 floating-
cially supported simulation languages. SLIM point co-processor which will significantly
provides only the most basic simulation facili- reduce the time required to obtain results.
ties but it is a very easily used simulation tool A hard disk is desirable and the computer
and, with a little ingenuity, can be applied to must have CGA, EGA or VGA display capa-
a remarkably wide range of problems, as bilities. The computer should contain a
shown by the examples in Chapter 8 and by minimum of 512k bytes of RAM memory. A
the case studies in Chapters 10, 11 and 12. standard ASCII text editor is necessary.
Also included on the diskette is the
SLIMPLOT program. This provides post-pro-
E.3 SOFTWARE INSTALLATION
cessing facilities to allow the results from
SLIM simulation runs to be presented on the The README. DOC file on the diskette pro-
screen in graphical form. Both y-t and x-y vides full details of procedures for installation
plots may be created and the production of of the SLIM and SLIMPLOT software, includ-
hard-copy is relatively straightforward, as ing a list of the names of all the files which are
explained in section E.7. The ASCII output provided and any updated features. The file
248 Appendix E
[Link] is an ASCII file which pro- and the SLIM program should start to execute.
vides user documentation and may be It first requests the name of the SLIM program
printed to form a user's guide and provide a file to be run. From this point the sequence of
convenient source of reference information operations follows the pattern of the example
when using the SLIM software or writing of section 6.6.4. It may be useful to use the
SLIM programs. The [Link] file VDPOLS.5LI program file from the example
includes much of the information in section in that section to ensure that you are using
6.6, together with some additional details SLIM correctly and that the results of Chapter
concerning the syntax of the SLIM language. 6 can be reproduced on your own computer.
The information contained in this appendix is At the end of a simulation run the user is
also included in [Link]. provided with an opportunity to carry out a
SLIM and SLIMPLOT will run successfully further run with the same program through a
from a floppy disk drive but most users prefer query of the form:
to mount the software on their hard disk. To
do this you should create a new directory (nor- DO YOU WANT ANOTHER RUN? (YIN)
mally named SLIM) on the hard disk. All files Responding N returns the user to DOS and
on the distribution diskette should be trans- the DOS prompt appears.
ferred to this new directory. To create such a
directory follow the normal DOS commands:
E.S USEFUL HINTS FOR USING SLIM
mkdir slim
In preparing simulation programs using the
If you wish you could then create separate SLIM language features described in Chapter
path-accessible subdirectories for user files. 6 and in the user's guide supplied in the file
However, for simplicity, it is assumed in the [Link] on the diskette it is im-
remainder of these notes that all SLIM files are portant to take note of the following points:
in the SLIM directory, that the default hard
disk drive is c: and that floppy disk drive is a:. 1. A SLIM program must follow the conven-
To transfer the files from the SLIM diskette tions explained in Chapter 6 and in the
to the hard disk place the diskette in the a: reference file [Link]. These con-
drive and copy all the distribution files into ventions are similar in many respects to
the \SLIM directory as follows: the conventions for Fortran 4 or Fortran
77 programming.
copy a: *.*c:\slim 2. It should be noted that executable code
must start in column 7 of each line of
It is important to make back-up copies of all
program. Columns 1 to 5 are reserved for
the files supplied on the distribution diskette
labels or for use in comment lines.
prior to attempting to make use of the soft-
Column 6 must always contain a space.
ware. The original diskette should be stored
Comments must start with an upper-case
safely.
C in column 1.
3. In creating a SLIM program using a
EA STARTING AND EXITING SLIM general-purpose text editor, use of the
TAB key should be avoided. The space
Make the SLIM directory the current direc-
bar should be used to move the cursor to
tory by entering the DOS command cd\slim. the required column (e.g. column 7).
When the DOS prompt (in this case 4. No blank lines should be included in a
C: \SLIM» appears, type:
SLIM program. The presence of a blank
slim line in a SLIM source program causes
Useful hints for using SLIMPLOT 249
problems at the translation stage and may values of variables Xl, X2 and X3. If one
cause the computer to 'hang'. wanted to plot Xl and X3 the columns to be
5. Continuation lines are not permitted in entered in response to the prompt from the
SLIM programs and care must be taken to SLIMPLOT program would be 2 and 4. These
avoid lengthy statements which involve column numbers may be entered as:
more than 70 characters or spaces. At-
2,4
tempts to use longer statements in a SLIM
program may cause the computer to 'hang' or
at the translation stage. Long statements
must be split into two or more statements, 2 4
each occupying a separate line of code. Text can be inserted by the user to provide
6. The distinction between integer and real a main (top) title and up to two secondary
quantities is important and involves the titles which appear below the graph. Both
normal naming conventions of Fortran. upper- and lower-case characters may be
Real and integer quantities cannot be . used in these titles.
used in direct combination within a When graphical output has been displayed
single statement. on the screen, and the user wishes to move on
7. All executable statements in a SLIM to a further stage of processing, pressing the
program must involve only upper-case ENTER key clears the graphical output from
letters. Comments may involve upper- the screen and causes a new menu to appear.
case and lower-case letters but must This has one option which allows the user to
include an upper-case C in column 1. exit from the SLIMPLOT program and others
which allow further plots to be produced.
E.6 STARTING AND EXITING SLIMPLOT
SLIMPLOT is extremely easy to use. It is E.7 USEFUL HINTS FOR USING SLIMPLOT
entered using the following command: The following points should be noted:
slimplot
1. Problems will be encountered if the
The program then prompts the user for the number of time steps in a SLIM output file
file name of the SLIM output file which is to is greater than the maximum allowed by
be plotted. This is followed by a request to the SLIMPLOT. If the maximum is exceeded
user to select the type of output file (y versus an error message is displayed during the
time or an x-y plot), the number of variables running of the SLIMPLOT program. The
(in the case of a y-t plot) and the column SLIM program should then be re-run with
numbers of the variables. an increased communication interval
The column numbers referred to in the (CINTERVAL) or a shorter duration of
SLIMPLOT prompts are the column numbers simulation run (i.e. reduced TMAX in the
in the TYPE statement which generates the example programs in this book).
data for the output file resulting from the 2. Hard-copy output from SLIMPLOT is
SLIM program. For example, if the output is most easily obtained using the DOS
obtained from a statement of the form: graphics command and the use of the
Print Screen key. An alternative, if an
TYPE T,Xl,X2,X3
appropriate printer is available, is to
there will be four columns in the output file. make use of the printer or plotter facilities
Column 1 involves values of T (time) and in the list of output devices which is dis-
columns 2 to 4 involve the corresponding played during the SLIMPLOT run.
INDEX

Absolute error 56,96 Communication interval 96,131, Direct construction method 32-5,
ACSL xii, 31. 88, 92, 103-4, 106, llO, 219 38-9
111,125,126,127,179 Comparator 124,210 Discontinuity
Action potential 126,128 Compartmental analysis 5,176--9 detection problem 64-6
Active state (of muscle) 187 Complementary function 13 location problem 64--{i
Adams-Bashforth integration Computer state 63-4,131-8
method 61, 217-18 analog 13-17,123,209-17,225 time 64
Adams-Moulton integration method digital 2,13,15-18,208-9,221-2 Discrete even simulation xi, 2,
61 hybrid 15-16,223 48-50,131-8
AD-10 209 Contractile element (of muscle) 188, DISCRETE section 103,137
AD-100 209, 221-2 189-205 Discretization of continuous model
ADSIM 222 Control systems engineering 3, 13, 243-4
Advisory systems 231 21,48-50,121-5,131-8, Distributed time delay 33,41-3
Aircraft 21. 148-9, 163-73, 207, 224 153--{j2,223 Documentation 139
Algebraic loop 66, 88 Co-processor, numeric 18 DOS xii, 92, 247-9
Analog computer 14-16,123, COSMOS 227 Double precision 62
209-17,225 CRAY-l 208 Dynamic check 143-4
Analog simulation 13-17,209-17, Criterion function 144 DYNAMIC segment 88-91, 92, 95,
225 CSMP /358 85,88 104, 128-9, 131
Analog to digital converter 2,49-50, CSMP-1130 85,110 DYNAMO 233
131 CSSL-III 88
Array processor 208,221-2 CSSL-IV 88,101-3 EASY5 112
Artificial intelligence 19,230-3 CSSL'67 recommendations 87-8, Education 21,223, 225--{j
Automatic landing system, aircraft 91 Effort store 27
163-5, 169-73 Effort variable 27
Auxiliary inputs 6,147-9 D-operator 13 Electrical circuit simulation 5, 18,
Damping, viscous 13 117-20
Backlash 123-5 DAS 17 Empirical validation 145-50,160-2,
BCKLSH function 125 DASSL 87 181, 223
Biological systems xii, 8-10, 21, Delay Emulation 207
125-9,175-85,187-205,225 distributed 33,41-3 Engineering design 20-21
Biomedical engineering xii, 8-10, 21, pure 33,41,88,110 ENIAC 16
125-9,175-85,187-205,225 Delta operator 80 ENPORT 31
BIOPSI 110, 113 DERIVATIVE section 88,92,95, Equation
Block diagram xii, 23, 32-40, 110, 128-9, 131 difference 67-84,132
239-41 DESCTOP 105 ordinary differential xii, 5, 13, 14,
Bond graph 23,27-31,66,233 Design of experiments 20,147,149 23
Boxer-Thaler operator 76 DESIRE 104-5 partial differential 14,41,42
Differential analyzer 14 Equation-oriented methods xii,
CAMP-G 31 Differential equations 85-106
Causality 28 ordinary 4,5,13,14,23 Errormeasures 56--7,61-2,96,220
Chemical process simulation 18,63, partial 14, 41-3 ESL 227
225 Digital control system 2, 48-50, Euler's integration method 52--{j,
CINTERVAL 96,167 131-8 218
Coefficient unit 212 Digital to analog converter 49-50, 13 Experimental design 20,147,149
252 Index
Expert knowledge 147,223 Integration methods continuous-variable 2
Expert system 19,231 Adams-Bashforth method 61, discrete-event 2
Explicit integration methods 52-63 217-18 discrete-time 243-6
External validation 144-50, 160-2, Adams-Moulton method 61 distributed parameter 14,40-43
181, 223 Euler's method 52-6 linear 3
explicit methods 52-63 linearized 21,148,156-7
Final value theorem, of Laplace Fehlberg method 62 lumped parameter 13,14,16,
transforms 236 first difference method 76-83 23
First-difference operator 76-83 fixed step methods 52-62 nonlinear 3,13, 18,63-6,70-74,
Flight control system, aircraft 21, for stiff systems 62-3 121-33, 153-62, 169-74,
148-9, 163-73 Gear's method 63 175-85, 187-205
Flight simulator 8, 16,207,224 implicit methods 52 of data 3,148
Flow store 27 improved Euler method 57-8 of a digital computer 2,48-50,
Flow variable 27 multistep methods 60-61 131-8
Fluid-power system simulation 18 one-step methods 52-60 of systems 3
Fortran xiii, 16, 69, 85, 86, 92, 111 operational methods 75-83 reduced form 24
Frame based systems 231-2 predictor-corrector method 60-61, state space 26,74-5
Frequency response of integrator 83 76 statistical 3
Friction Ralston's method 59 stiff 62-3
static 13 Runge-Kutta methods 56-60,61, time invariant 3
viscous 13 62,76 time series 148
Fuzzy knowledge 231 trapezoidal method 60 time varying 3,63-6,81-3,176-9
variable step methods 62-3, 218 MATLAB 86,111-12,114
Gamma operator 80 Integration operators 75-83 MATRIX 86,111
Gas-exchange, pulmonary 5,8-10, Integration step size selection 51, Matrix packages 86-7
175-85 144,219 Medical applications xii, 8-10, 21
Graphical interface 109,229 Integrator 110,211-12 Menu 109
Gyrator 29-31 Integrator frequency response 83 MERROR 96
INTERACT 222 MICRODARE 105
Halijak operator 76 Interactive simulation 17,19, MIDAS 17
Hardware-in-the-Ioop testing 207, 207-26,228-9 MIMESIS 91
222-3 Internal verification 142-4 MIMIC 17
Helicopter 21, 149 International Association for MINTERV AL 96
Hold Mathematics and Computers Mode 217
triangular 49, 67, 68-9 in Simulation (IMACS) 227 Model
zero-order 67,68 Iterative construction method 36-7, applicability 5
Hold mode 217 40 assumptions 5
Hybrid computer 15-16,223 boundaries 4, 6, 10
Hybrid simulation 15-16,223 Junction, bond graph 28-31 calibration 6, 8
Hydraulic system simulation 18, discrete-time form 246-8
121-5, 153-62 Knowledge representation 231-2 evaluation 10
Hypothesis testing 2, 8, 18-20 linearization 21, 156-7
Hysteresis 13,110 Laplace transform 13,26,32,156, of mechanical system 24, 26, 32,
235-6 121-5,213-14,223
Icon 109 Lateral beam guidance system, of systems 3
Identifiability 148 aircraft 165, 169--73 optimization 18
Identification 8, 148-50 Limit cycle 125 qualitative 232-3
ILLIAC-IV 208 Linearization 156-7 sampled-data form 67-84,243-6
Implicit integration 52 Lung 5,8-10,175-85 sensitivity 18
Implicit loop 66, 88 simplification 6
Improved Euler integration 57-8 MACPUF 21, 225 state space form 26,74-5
IMSL subprogram library 16 Macro facility 103 state-variable form 24-6, 32-40,
Inertia 27 Madwed operator 76 74-5
Inheritance 231-2 Man-machine interface 109,228-9 statistical 3
Initial condition mode 217 Mass-spring-damper system 24-6, testing xii, 6-10, 141-2
INITIAL segment 88-91, 92 213-14 transfer function form 3, 23, 26,
Instability, numerical 51,61-2, Mathematical models 32-40,76-81,165-73,237
219 'black box' 3 validation xii, 6-10, 43,141-51,
INTEG function 95 compartmental 5 160-2, 181
Index 253
Model-method-experiment concept Potentiometer 212 Simulation of transfer function
228 Predictor-corrector integration by direct construction 32-5,38-9
Mouse 17,109 method 76 by iterative construction 36-7, 40
Multiple instruction-multiple data Project Whirlwind 16 by parallel construction 35-36,
(MIMO) 221,229-30 PSI 110 39-40
Multiplier 110, 213 Pure time delay 33,41-3 Simulator 8, 16,21,223-6
Multiprocessor systems 208,221-2 SIMULINK 86, 111-12, 114, 119-20,
Multirate methods 220-1 Qualitative simulation 232-3 125,137-8,181,210
Multistep integration methods Single instruction-multiple data
60-61 Real-time simulation xii, 15, 16, 18, (SIMO) 221
Muscle spindle receptor 125 207-26 Single instruction-single data (SISO)
Reduced form 24 221
NAG subprogram library xiii,16 Relative error 56,96 Single step integration methods
Neural encoder 125-9 Respiratory control system xii, 8-10, 52-60
Neuromuscular control system 125 175-6 Skeletal muscle 187-205
Normalized variables 213-16, Robustness issue, in model SLIM language
219-20 validation 149-50 examples 97-101,118-20,125-9,
NOSORT 90 Round-off error 61-2 129-31. 131-7, 157-9, 167-9,
Numerical instability 51,61-2 Rule-based systems 19,231 171-3, 179-85
Numerical methods Runge-Kutta integration methods hardware requirements 247
discontinuities 63-6 76,87,218 language features 91-2,106,228
integration 51-63 Runtime commands 103 output facilities and graphics
round-off errors 61-2 96-7,251
stability 61-2 S component 28 software installation 247-8
subprograms 16 Sampled-data models 67-84,243-6 syntax 92-6
truncation errors 61-2 Sampling process 244-6 SLIMPLOT program 96-7,100,
'Numerical Recipes' subprograms Scaling calculations 247-9
16 amplitude 213-16,219-20 SmallTalk 232
time 216-17, 225 Society for Computer Simulation 17,
Object-oriented systems 231-2 Sensitivity analysis 18,43-8,98-202 87, 142, 150
ODEPACK 87 Sensitivity coefficient 43, 44-8, Software engineering 233
Operational amplifier 14,209-12 196-202 SORT 90
Operational methods 76-83,218 Sensitivity co-system 44-8, 196-8 Sorting 89-90,103
Operators 76-83,218 Sensitivity function 43, 44-8, Source 27
Optimization 146 196-202 Stability of integration methods
Series elastic element (of muscle) 61-2
Package, simulation 16,85,87 188, 189-205 Standards 17,87-91,227
Pade approximation 42-3 S-function 112 State space 26,74-5
Parallel construction method 35-6, Signal (bond graph) 30 State variable 24-6,32-40,74-5
39-40 Signal flow diagram 23, 32-40, Static check 143
Parallel elastic element (of muscle) 241-2 Static friction 13
188, 189-205 SIMNON 110,111 Steady state finder 143
Parallelism 208,210,221-2,229-30 SIMsystem 222 Stiff models 62-3
Parallel processing 146,208,221, Simulation Submodel 6,28,146,227
229-30 analog 13-17,217-19,225 Summing unit 110,211
Parameter sensitivity analysis 18, block diagram-oriented xii, 17, Superposition principle 3
43-8,146 110-16 SYSMOO 227, 228
PARMACS 230 discrete-event xi, 2, 131-8 SYSTEM 100, 222
Parsimony principle 6 equation-oriented xii, 85-106 SYSTEM BUILD 111-12
Partial system testing 207, 222-3 hybrid 15-16,223 System dynamics methods 233
Particular integral 13 interactive 17,19,207-26,228-9 System identification 8,148-50
Pascal 16,69,86 languages 17,87-106,227-8
Pendulum 129-31 packages 16,85,87 Tanks, coupled 153-62
Peripheral array processor 208, qualitative 232-3 Taylor series 43,53,56-60
221-2 real time xii, 15, 16, 18, 207-26 TERMINAL segment 88-91,92
Physiological systems xii, 8-10, 21, run 18 Testing xii, 6-10, 141-2
175-85, 187-205 standards 17,87-91,227 Tetanus (of muscle) 188
Pipelining 208, 221 study 18 Time delay, distributed 33,41-3
Post-processing 229 Simulation Councils Inc. 17,87 Time delay, pure 33,41-3
254 Index
Training simulators 8, 16, 21, 223-5 empirical 145-9 Water turbine speed control 121-5,
Transfer function 3,23,26,32-40, external 144-50, 160-2, 181 223
76-81,218,237 robustness 149-50 Whirlwind Project 16
Transformer 29-31 terminology 142 WIMP interface 109
Transputer 222 Validity Windows environment 17,229
Trapezoidal integration 60 empirical 145-9,223
Triangular hold 67, 68 heuristic 144 XANALOG 111,112-13,114-16,
Truncation errors 61-2 pragmatic 144 119-20, 125, 127, 129, 137-8,
Tustin operator 76, 80, 83 theoretical 144-5 157-8, 181, 193-5, 210
Twitch (of muscle) 187 Van der Pol's equation 97-101,113
Variable-step integration 62-3, XERROR 96
User interface 109,228-29 218
VAX/VMS 222 Z-transform analysis 67-84,136-7,
Validation Verification 142-4 245
documentation 150-1 Viscous damping 13 Zero-order hold 49,244-6
Chapman & Hall specifically disclaim all warranties, express or
implied including, but not limited to, implied warranties of
merchantability and fitness for a particular purpose. With respect to
the disc and the programs reproduced on the disc, Chapman & Hall
shall have no liability with respect to any loss or damage directly or
indirectly arising from the use of the disc or any program reproduced
on the disc. Without limiting the foregoing, Chapman & Hall snall not
be liable for any loss of profit, interruption of business, damage of
equipment or data, interruption of operations or any other commercial
damage, including but not limited to, direct, indirect, special,
incidental, consequential or other damages.

You might also like