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. Murray-Smith Originally published by Chapman & Hall in 1995 Typeset by EXPO Holdings, Malaysia ISBN 978-1-4613-6066-7 DOI 10.1007/978-1-4615-2504-2 ISBN 978-1-4615-2504-2 (ebook) Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the UK Copyright Designs and Patents Act, 1988, this publication may not be reproduced, stored, or transmitted, in any form or by any means, without the prior permission in writing of the publishers, or in the case of reprographic reproduction only in accordance with the terms of the licences issued by the Copyright Licensing Agency in the UK, or in accordance with the terms of licences issued by the appropriate Reproduction Rights Organization outside the UK. Enquiries concerning reproduction outside the terms stated here should be sent to the publishers at the London address printed on this page. The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in 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 Library Library of Congress Catalog Card Number: 94-72017 (bb) Printed on permanent acid-free text paper, manufactured in accordance with ANSI/NISO Z39.48-1992 and ANSI/NISO 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
13.4 Simulation of the complete twitch response and repetitive stimulation 13.5 Discussion References 14 Real-time simulation 14.1 An introduction to real-time applications 14.2 Hardware and software aspects of real-time simulation 14.3 Analog simulation techniques 14.3.1 The operational amplifier 14.3.2 The summing unit 14.3.3 The integrator unit 14.3.4 The coefficient unit 14.3.5 Multipliers and other nonlinear units 14.3.6 Scaling of variables 14.3.7 Operating modes 14.4 Digital techniques 14.4.1 Real-time integration algorithms 14.4.2 Choice of communication interval 14.4.3 Error analysis in real-time simulation 14.4.4 Multirate methods 14.5 Special-purpose hardware for real-time digital simulation 14.5.1 Introduction 14.5.2 Array processors and multiprocessor systems 14.5.3 Transputer-based parallel systems 14.6 Hardware-in-the-Ioop simulation and partial-system testing 14.7 Applications in training and education 14.7.1 Introduction 14.7.2 Simulators for operator training 14.7.3 Real-time simulation in teaching References 15 Current trends in continuous system simulation 15.1 Developments in simulation languages 15.2 Improvements in the man-machine interface 15.3 Developments involving parallel processor systems 15.3.1 Hardware developments in parallel processing for simulation 15.3.2 Simulation software for parallel processor systems 15.4 Artificial intelligence and simulation 15.4.1 Knowledge-based systems in modeling and simulation 15.4.2 Knowledge representation using frames and inheritance 15.4.3 Qualitative modeling and qualitative simulation References Appendix A The Laplace transform A.l Introduction A.2 Linearity theorem Contents ix 203 204 205 207 207 208 209 210 211 211 212 213 213 217 217 217 219 220 220 221 221 221 222 222 223 223 224 225 226 227 227 228 229 229 230 230 231 231 232 233 235 235 235
x Contents A3 Differentiation theorem A4 Final value theorem A5 Example Reference 235 236 236 236 Appendix B The transfer function Reference Appendix C Block diagrams and signal flow graphs C1 Introduction C2 Block diagrams C3 Signal flow graphs Reference Appendix D Discrete-time models and sampled-data theory D.1 Introduction D.2 Discrete-time models D.3 Discretization of a continuous-time model D.4 The sampling process References Appendix E SLIM software instructions E.1 Introduction E.2 Hardware requirements E.3 Software installation E.4 Starting and exiting SLIM E.5 Useful hints for using SLIM E.6 Starting and exiting SLIMPLOT E.7 Useful hints for using SLIMPLOT Index 237 237 239 239 239 241 242 243 243 243 243 244 246 247 247 247 247 248 248 249 249 251
computer. This language, which is fully described in Chapter 6, provides a basis for some preliminary work on equation-oriented methods and can be used by the reader to gain practical experience before considering more complex examples involving use of more comprehensive simulation languages, such as ACSL. Although the software provided on the diskette is limited in terms of the size of problems that can be tackled and in the range of facilities provided, it is hoped that it may enhance the text considerably for those having access to a personal computer. The limitations of the language are fully described and comparisons are made, in terms of its facilities and performance, with commercially supported languages. However, it must be emphasized that this software is intended only as an aid to understanding simulation methods and is not a substitute for established and supported modem simulation languages which have many features not included within SLIM. The case studies in Chapters 10, 11, 12 and 13 have been chosen to be of interest to readers with a background principally in engineering, physics or applied mathematics. However, both here and in other sections of the book, some use is also made of bioengineering examples to emphasize the importance of simulation in biomedical fields and to highlight some of the problems that can arise in the modeling and simulation of such systems. In every example background information is provided which is intended to provide readers not active in the field with sufficient information to allow them to understand the problem, the associated mathematical model and the particular simulation issues raised. Care has been taken to ensure that objectives for the simulation work are stated clearly in the case studies presented. Other topics covered in later chapters include real-time simulation techniques, which are of great importance for many types of engineering and laboratory applications, and a brief review of current trends in simula- xii Preface as much as it is of any other computer application area. Recognizing the fact that information inherent in the underlying model is at fault can present serious problems even for experienced users of simulation techniques. Careful consideration must be given to methods of testing and validation. Without this the potential advantages of a simulation approach are nullified. The first chapter of the book sets the scene in this respect with a review of the objectives of modeling and simulation and an account of systematic procedures which help to ensure that these objectives are satisfied. More detailed discussion of the verification and validation of simulation models is presented in later sections, especially in Chapter 9 and in the case study of Chapter 10. The book is intended mainly for readers with little or no previous experience of computer simulation methods but having a reasonably numerate background. An elementary understanding of ordinary differential equations and some knowledge concerning their use in the mathematical modeling of physical systems is necessary. Large sections of the book should also be of value to those already working in the field of computer simulation and modeling. The objective has been to cover the general principles of continuous system simulation methods in a thorough fashion and, through appropriate examples and case studies, to illustrate the application of these principles using modem simulation packages. Both equation-oriented languages and block diagram-based packages are considered. Separate chapters are included which cover the questions of problem description and organization at a mathematical level and the principles of numerical modeling before any attempt is made to discuss specific problem-oriented languages. A simple continuous system simulation language called SLIM (Simulation Language for Introductory Modeling) is provided with the book on a diskette which can be used on any DOS-based IBM-compatible personal
PREFACE Computer simulation of dynamic systems is a topic which is growing steadily in importance in the physical sciences, engineering, biology and medicine. The reasons for this trend relate not only to the steadily increasing power of computers and the rapidly falling costs of hardware, but also to the availability of appropriate software tools in the form of simulation languages. Problem-oriented languages of this kind assist those who are not specialists in computational methods to translate a mathematical description into a simulation program in a simple and straightforward fashion. They can also provide useful diagnostic information when difficulties are encountered. Therefore, a simulation language provides, in comparison with languages such as Fortran, Basic, Pascal or C, the same type of advantages for simulation which those standard high-level languages provide over an assembly language for other computer applications. Simulation involves experimentation with models of real systems. The reasons for using a simulation approach to problem solving depend, to some extent, on the field of application. In engineering, simulation techniques can often allow valuable insight to be gained at an early stage in a design, when it would otherwise be unobtainable until a prototype system or scale model was constructed. In some engineering applications, such as the development of aircraft flight-control systems, simulation may be the only feasible and safe approach for initial investigations. Even at much later stages of system development, a simulation-based approach may still be useful, since the required results may often be obtained by simulation more quickly, effectively and cheaply than by experimentation and testing of the real system. System performance can also be investigated using simulation for a much wider range of conditions than can be contemplated for the real system because of operating constraints or safety requirements. Similar factors can apply in other fields, such as biomedical systems engineering. System simulation, using digital computers, can relate either to models based on continuous variables or to discrete-event descriptions. Continuous system simulation techniques are applied to systems described by sets of differential equations and algebraic equations. Such descriptions of dynamic properties are applicable to many types of engineering system, to a wide range of problems in the physical sciences and to certain types of biological system. Discrete-event simulation is also concerned with systems which are dynamic in nature, but in this case events and the times at which they occur are of primary importance. Examples of applications for which discrete-event simulation is important are in air and road traffic control, in manufacturing systems and in the optimization of computer systems or communications networks. This book is concerned primarily with continuous system simulation and includes discussion of di~crete-event techniques only in the context of mixed models which include some discrete elements together with continuous system descriptions. The proper use of simulation techniques cannot be separated from the intelligent use of mathematical models. The concept of 'garbage in, garbage out' is true of simulation
tion. Topics covered under this latter heading include the effects of new developments in conventional computer hardware and software, the influence of parallel architectures on simulation methods, and links which are being established between the fields of artificial intelligence and simulation. In preparing a book intended for engineers and scientists in a number of different disciplines it has been recognized that readers may not all be fully familiar with the relevant mathematical techniques. A number of appendices have therefore been included to cover relevant topics such as the Laplace transform, transfer function descriptions and block diagram notation. The graphical routines included in the accompanying software are part of the NAG Graphics Library. This product contains a collection of over 100 carefully designed routines which provides Fortran and C programmers with a convenient and versatile means of producing a graphical representation of numerical and statistical results. It is used worldwide in commerce, financial modeling, industry, academic research and many other areas, and is available for a wide spectrum of machines. Interfaces are also supplied to the most commonly used plotting packages. NAG also provide a wide range of other products such as mathematical and statistical routines in Fortran, C, Pascal and Ada; Fortran 90 compilers and tools; symbolic solvers; data visualization software; linear programming software and a gateway generator which automatically generates MATLAB gateway. For further information, a quotation or details of your local distributor please contact: Preface xiii Sales Department NAG Ltd Wilkinson House Jordan Hill Road Oxford OX2 9BX United Kingdom Many people have contributed to the preparation of this text and the accompanying software. First of all, I wish to thank many students in the Department of Electronics and Electrical Engineering at the University of Glasgow who have assisted in the development of some of the material through their project work, by pointing out errors in sections which have been used to support courses at undergraduate and post-graduate level, and by helping with the development and testing of the SLIM software. In particular, I wish to mention the contribution made by Fran<;ois Gaudaire, who developed many of the XANALOG simulation diagrams used in the examples and case studies of Chapters 8, 10, 11, 12 and 13. I also wish to thank Mingrui Gong for her assistance with some of the model validation results included in Chapter 10. I have also had very helpful feedback from experienced engineers on postgraduate short courses, most recently at one organized by PROPESA at the Centro Tecnico Aeroespacial, Sao Jose dos Campos, Brazil. To all the many individuals who have provided assistance, of one kind or another, I wish to express my sincere appreciation. Finally, I must acknowledge the support, encouragement and patience of my wife, Effie, who has helped to make this book possible. David Murray-Smith Glasgow 1994