Statistics
85
Views
4
Downloads
0
Donations
Uploader

高宏飞

Shared on 2025-11-12
Support
Share

AuthorHarold Klee, Randal Allen

No description

Tags
No tags
Language: 中文
File Format: PDF
File Size: 21.4 MB
Support Statistics
¥.00 · 0times
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

(This page has no text content)
Simulation of Dynamic Systems with MATLAB® and Simulink® S E C O N D E D I T I O N Harold Klee Randal Allen CRC Press is an imprint of the Taylor & Francis Group, an informa business Boca Raton London New York
MATLAB® is a trademark of The MathWorks, Inc. and is used with permission. The MathWorks does not warrant the accuracy of the text or exercises in this book. This book’s use or discussion of MATLAB® software or related products does not constitute endorsement or sponsorship by The MathWorks of a particular pedagogical approach or particular use of the MATLAB® software. CRC Press Taylor & Francis Group 6000 Broken Sound Parkway NW, Suite 300 Boca Raton, FL 33487-2742 © 2011 by Taylor and Francis Group, LLC CRC Press is an imprint of Taylor & Francis Group, an Informa business No claim to original U.S. Government works Printed in the United States of America on acid-free paper 10 9 8 7 6 5 4 3 2 1 International Standard Book Number-13: 978-1-4398-3674-3 (Ebook-PDF) This book contains information obtained from authentic and highly regarded sources. Reasonable efforts have been made to publish reliable data and information, but the author and publisher cannot assume responsibility for the valid- ity of all materials or the consequences of their use. The authors and publishers have attempted to trace the copyright holders of all material reproduced in this publication and apologize to copyright holders if permission to publish in this form has not been obtained. If any copyright material has not been acknowledged please write and let us know so we may rectify in any future reprint. Except as permitted under U.S. Copyright Law, no part of this book may be reprinted, reproduced, transmitted, or uti- lized in any form by any electronic, mechanical, or other means, now known or hereafter invented, including photocopy- ing, microfilming, and recording, or in any information storage or retrieval system, without written permission from the publishers. For permission to photocopy or use material electronically from this work, please access www.copyright.com (http:// www.copyright.com/) or contact the Copyright Clearance Center, Inc. (CCC), 222 Rosewood Drive, Danvers, MA 01923, 978-750-8400. CCC is a not-for-profit organization that provides licenses and registration for a variety of users. For organizations that have been granted a photocopy license by the CCC, a separate system of payment has been arranged. Trademark Notice: Product or corporate names may be trademarks or registered trademarks, and are used only for identification and explanation without intent to infringe. Visit the Taylor & Francis Web site at http://www.taylorandfrancis.com and the CRC Press Web site at http://www.crcpress.com
To Andrew, Cassie and in loving memory of their mother and devoted wife, Laura. Harold Klee To Dave Lundquist and Steve Roemerman who believed in me. Randal Allen
This page intentionally left blank
Contents Foreword ........................................................................................................................................ xiii Preface............................................................................................................................................. xv Authors........................................................................................................................................... xix Chapter 1 Mathematical Modeling............................................................................................... 1 1.1 Introduction....................................................................................................... 1 1.1.1 Importance of Models ......................................................................... 1 1.2 Derivation of a Mathematical Model ............................................................... 4 Exercises...................................................................................................................... 8 1.3 Difference Equations ...................................................................................... 10 1.3.1 Recursive Solutions ........................................................................... 11 Exercises.................................................................................................................... 12 1.4 First Look at Discrete-Time Systems ............................................................. 13 1.4.1 Inherently Discrete-Time Systems .................................................... 17 Exercises.................................................................................................................... 20 1.5 Case Study: Population Dynamics (Single Species) ...................................... 21 Exercises.................................................................................................................... 28 Chapter 2 Continuous-Time Systems......................................................................................... 31 2.1 Introduction..................................................................................................... 31 2.2 First-Order Systems ........................................................................................ 31 2.2.1 Step Response of First-Order Systems.............................................. 32 Exercises.................................................................................................................... 36 2.3 Second-Order Systems.................................................................................... 38 2.3.1 Conversion of Two First-Order Equations to a Second-Order Model................................................................................................. 43 Exercises.................................................................................................................... 46 2.4 Simulation Diagrams ...................................................................................... 47 2.4.1 Systems of Equations ........................................................................ 53 Exercises.................................................................................................................... 55 2.5 Higher-Order Systems .................................................................................... 56 Exercises.................................................................................................................... 58 2.6 State Variables ................................................................................................ 59 2.6.1 Conversion from Linear State Variable Form to Single Input–Single Output Form ................................................................ 64 2.6.2 General Solution of the State Equations ........................................... 65 Exercises.................................................................................................................... 65 2.7 Nonlinear Systems.......................................................................................... 68 2.7.1 Friction .............................................................................................. 70 2.7.2 Dead Zone and Saturation................................................................. 72 2.7.3 Backlash ............................................................................................ 73 2.7.4 Hysteresis........................................................................................... 73 2.7.5 Quantization....................................................................................... 77 2.7.6 Sustained Oscillations and Limit Cycles........................................... 78 v
Exercises.................................................................................................................... 82 2.8 Case Study: Submarine Depth Control System ............................................. 85 Exercises.................................................................................................................... 89 Chapter 3 Elementary Numerical Integration ............................................................................ 91 3.1 Introduction..................................................................................................... 91 3.2 Discrete-Time System Approximation of a Continuous-Time Integrator...... 92 Exercises.................................................................................................................... 94 3.3 Euler Integration ............................................................................................. 96 3.3.1 Backward (Implicit) Euler Integration .............................................. 99 Exercises.................................................................................................................. 101 3.4 Trapezoidal Integration................................................................................. 102 Exercises.................................................................................................................. 106 3.5 Numerical Integration of First-Order and Higher Continuous-Time Systems ......................................................................................................... 107 3.5.1 Discrete-Time System Models from Simulation Diagrams ............ 107 3.5.2 Nonlinear First-Order Systems........................................................ 111 3.5.3 Discrete-Time State Equations ........................................................ 114 3.5.4 Discrete-Time State System Matrices ............................................. 118 Exercises.................................................................................................................. 119 3.6 Improvements to Euler Integration............................................................... 122 3.6.1 Improved Euler Method .................................................................. 122 3.6.2 Modified Euler Integration .............................................................. 125 Exercises.................................................................................................................. 135 3.7 Case Study: Vertical Ascent of a Diver ....................................................... 138 3.7.1 Maximum Cable Force for Safe Ascent.......................................... 144 3.7.1.1 Trial and Error ................................................................. 144 3.7.1.2 Analytical Solution .......................................................... 145 3.7.2 Diver Ascent with Decompression Stops........................................ 145 Exercises.................................................................................................................. 147 Chapter 4 Linear Systems Analysis ......................................................................................... 151 4.1 Introduction................................................................................................... 151 4.2 Laplace Transform........................................................................................ 151 4.2.1 Properties of the Laplace Transform............................................... 153 4.2.2 Inverse Laplace Transform.............................................................. 159 4.2.3 Laplace Transform of the System Response................................... 160 4.2.4 Partial Fraction Expansion .............................................................. 161 Exercises.................................................................................................................. 167 4.3 Transfer Function.......................................................................................... 168 4.3.1 Impulse Function............................................................................. 168 4.3.2 Relationship between Unit Step Function and Unit Impulse Function........................................................................................... 169 4.3.3 Impulse Response............................................................................ 171 4.3.4 Relationship between Impulse Response and Transfer Function ... 175 4.3.5 Systems with Multiple Inputs and Outputs ..................................... 178 4.3.6 Transformation from State Variable Model to Transfer Function........................................................................................... 184 Exercises.................................................................................................................. 187 vi Contents
4.4 Stability of Linear Time Invariant Continuous-Time Systems .................... 189 4.4.1 Characteristic Polynomial................................................................ 190 4.4.2 Feedback Control System................................................................ 194 Exercises.................................................................................................................. 198 4.5 Frequency Response of LTI Continuous-Time Systems.............................. 200 4.5.1 Stability of Linear Feedback Control Systems Based on Frequency Response................................................................... 210 Exercises.................................................................................................................. 213 4.6 z-Transform................................................................................................... 215 4.6.1 Discrete-Time Impulse Function ..................................................... 221 4.6.2 Inverse z-Transform......................................................................... 225 4.6.3 Partial Fraction Expansion .............................................................. 226 Exercises.................................................................................................................. 233 4.7 z-Domain Transfer Function......................................................................... 234 4.7.1 Nonzero Initial Conditions .............................................................. 236 4.7.2 Approximating Continuous-Time System Transfer Functions ....... 238 4.7.3 Simulation Diagrams and State Variables....................................... 244 4.7.4 Solution of Linear Discrete-Time State Equations ......................... 248 4.7.5 Weighting Sequence (Impulse Response Function)........................ 253 Exercises.................................................................................................................. 257 4.8 Stability of LTI Discrete-Time Systems....................................................... 259 4.8.1 Complex Poles of H(z) .................................................................... 263 Exercises.................................................................................................................. 269 4.9 Frequency Response of Discrete-Time Systems .......................................... 272 4.9.1 Steady-State Sinusoidal Response................................................... 272 4.9.2 Properties of the Discrete-Time Frequency Response Function..... 274 4.9.3 Sampling Theorem .......................................................................... 278 4.9.4 Digital Filters................................................................................... 284 Exercises.................................................................................................................. 289 4.10 Control System Toolbox .............................................................................. 292 4.10.1 Transfer Function Models ............................................................... 293 4.10.2 State-Space Models ......................................................................... 293 4.10.3 State-Space=Transfer Function Conversion..................................... 295 4.10.4 System Interconnections.................................................................. 298 4.10.5 System Response............................................................................. 299 4.10.6 Continuous-=Discrete-Time System Conversion............................. 302 4.10.7 Frequency Response........................................................................ 303 4.10.8 Root Locus ...................................................................................... 305 Exercises.................................................................................................................. 309 4.11 Case Study: Longitudinal Control of an Aircraft......................................... 312 4.11.1 Digital Simulation of Aircraft Longitudinal Dynamics .................. 325 4.11.2 Simulation of State Variable Model................................................ 327 Exercises.................................................................................................................. 329 4.12 Case Study: Notch Filter for Electrocardiograph Waveform....................... 330 4.12.1 Multinotch Filters ............................................................................ 331 Exercises.................................................................................................................. 338 Chapter 5 Simulink® ................................................................................................................ 341 5.1 Introduction................................................................................................... 341 5.2 Building a Simulink® Model........................................................................ 341 Contents vii
5.2.1 Simulink® Library ........................................................................... 342 5.2.2 Running a Simulink® Model........................................................... 345 Exercises.................................................................................................................. 347 5.3 Simulation of Linear Systems ...................................................................... 349 5.3.1 Transfer Fcn Block.......................................................................... 350 5.3.2 State-Space Block............................................................................ 353 Exercises.................................................................................................................. 362 5.4 Algebraic Loops ........................................................................................... 363 5.4.1 Eliminating Algebraic Loops .......................................................... 364 5.4.2 Algebraic Equations ........................................................................ 367 Exercises.................................................................................................................. 369 5.5 More Simulink® Blocks ............................................................................... 371 5.5.1 Discontinuities ................................................................................. 377 5.5.2 Friction ............................................................................................ 377 5.5.3 Dead Zone and Saturation............................................................... 377 5.5.4 Backlash .......................................................................................... 379 5.5.5 Hysteresis......................................................................................... 380 5.5.6 Quantization..................................................................................... 381 Exercises.................................................................................................................. 382 5.6 Subsystems ................................................................................................... 385 5.6.1 PHYSBE.......................................................................................... 386 5.6.2 Car-Following Subsystem ............................................................... 386 5.6.3 Subsystem Using Fcn Blocks.......................................................... 389 Exercises.................................................................................................................. 392 5.7 Discrete-Time Systems ................................................................................. 393 5.7.1 Simulation of an Inherently Discrete-Time System........................ 394 5.7.2 Discrete-Time Integrator.................................................................. 397 5.7.3 Centralized Integration .................................................................... 398 5.7.4 Digital Filters................................................................................... 402 5.7.5 Discrete-Time Transfer Function .................................................... 404 Exercises.................................................................................................................. 408 5.8 MATLAB® and Simulink® Interface ........................................................... 411 Exercises.................................................................................................................. 417 5.9 Hybrid Systems: Continuous- and Discrete-Time Components .................. 420 Exercises.................................................................................................................. 423 5.10 Monte Carlo Simulation ............................................................................... 424 5.10.1 Monte Carlo Simulation Requiring Solution of a Mathematical Model ................................................................ 428 Exercises.................................................................................................................. 434 5.11 Case Study: Pilot Ejection............................................................................ 437 Exercises.................................................................................................................. 441 5.12 Case Study: Kalman Filtering ...................................................................... 442 5.12.1 Continuous-Time Kalman Filter...................................................... 442 5.12.2 Steady-State Kalman Filter.............................................................. 443 5.12.3 Discrete-Time Kalman Filter........................................................... 443 5.12.4 Simulink® Simulations .................................................................... 444 5.12.5 Summary.......................................................................................... 455 Exercise ................................................................................................................... 456 viii Contents
Chapter 6 Intermediate Numerical Integration......................................................................... 457 6.1 Introduction................................................................................................... 457 6.2 Runge–Kutta (RK) (One-Step Methods)...................................................... 457 6.2.1 Taylor Series Method ...................................................................... 458 6.2.2 Second-Order Runge–Kutta Method............................................... 459 6.2.3 Truncation Errors............................................................................. 461 6.2.4 High-Order Runge–Kutta Methods ................................................. 466 6.2.5 Linear Systems: Approximate Solutions Using RK Integration ..... 467 6.2.6 Continuous-Time Models with Polynomial Solutions .................... 469 6.2.7 Higher-Order Systems ..................................................................... 471 Exercises.................................................................................................................. 478 6.3 Adaptive Techniques .................................................................................... 481 6.3.1 Repeated RK with Interval Halving................................................ 481 6.3.2 Constant Step Size (T¼ 1 min)....................................................... 485 6.3.3 Adaptive Step Size (Initial T¼ 1 min) ............................................ 485 6.3.4 RK–Fehlberg ................................................................................... 486 Exercises.................................................................................................................. 490 6.4 Multistep Methods........................................................................................ 492 6.4.1 Explicit Methods ............................................................................. 493 6.4.2 Implicit Methods ............................................................................. 495 6.4.3 Predictor–Corrector Methods .......................................................... 498 Exercises.................................................................................................................. 502 6.5 Stiff Systems................................................................................................. 503 6.5.1 Stiffness Property in First-Order System ........................................ 504 6.5.2 Stiff Second-Order System.............................................................. 506 6.5.3 Approximating Stiff Systems with Lower-Order Nonstiff System Models ................................................................................ 509 Exercises.................................................................................................................. 522 6.6 Lumped Parameter Approximation of Distributed Parameter Systems ....... 526 6.6.1 Nonlinear Distributed Parameter System ........................................ 531 Exercises.................................................................................................................. 534 6.7 Systems with Discontinuities........................................................................ 535 6.7.1 Physical Properties and Constant Forces Acting on the Pendulum BOB .................................................................... 543 Exercises.................................................................................................................. 549 6.8 Case Study: Spread of an Epidemic............................................................. 552 Exercises.................................................................................................................. 559 Chapter 7 Simulation Tools ..................................................................................................... 561 7.1 Introduction................................................................................................... 561 7.2 Steady-State Solver....................................................................................... 562 7.2.1 Trim Function.................................................................................. 564 7.2.2 Equilibrium Point for a Nonautonomous System ........................... 565 Exercises.................................................................................................................. 574 7.3 Optimization of Simulink® Models.............................................................. 576 7.3.1 Gradient Vector ............................................................................... 585 7.3.2 Optimizing Multiparameter Objective Functions Requiring Simulink® Models ........................................................................... 587 Contents ix
7.3.3 Parameter Identification................................................................... 590 7.3.4 Example of a Simple Gradient Search ............................................ 591 7.3.5 Optimization of Simulink® Discrete-Time System Models............ 599 Exercises.................................................................................................................. 605 7.4 Linearization ................................................................................................. 610 7.4.1 Deviation Variables ......................................................................... 611 7.4.2 Linearization of Nonlinear Systems in State Variable Form .......... 619 7.4.3 Linmod Function ............................................................................. 623 7.4.4 Multiple Linearized Models for a Single System ........................... 627 Exercises.................................................................................................................. 633 7.5 Adding Blocks to the Simulink® Library Browser ...................................... 637 7.5.1 Introduction ..................................................................................... 637 7.5.2 Summary.......................................................................................... 645 Exercise ................................................................................................................... 645 7.6 Simulation Acceleration ............................................................................... 645 7.6.1 Introduction ..................................................................................... 645 7.6.2 Profiler ............................................................................................. 647 7.6.3 Summary.......................................................................................... 647 Exercise ................................................................................................................... 648 Chapter 8 Advanced Numerical Integration ............................................................................ 649 8.1 Introduction................................................................................................... 649 8.2 Dynamic Errors (Characteristic Roots, Transfer Function).......................... 649 8.2.1 Discrete-Time Systems and the Equivalent Continuous-Time Systems............................................................... 650 8.2.2 Characteristic Root Errors ............................................................... 653 8.2.3 Transfer Function Errors ................................................................. 664 8.2.4 Asymptotic Formulas for Multistep Integration Methods............... 669 8.2.5 Simulation of Linear System with Transfer Function H(s) ............ 672 Exercises.................................................................................................................. 677 8.3 Stability of Numerical Integrators ................................................................ 680 8.3.1 Adams–Bashforth Numerical Integrators ........................................ 680 8.3.2 Implicit Integrators .......................................................................... 687 8.3.3 Runga–Kutta (RK) Integration ........................................................ 692 Exercises.................................................................................................................. 700 8.4 Multirate Integration ..................................................................................... 702 8.4.1 Procedure for Updating Slow and Fast States: Master=Slave¼RK-4=RK-4 ............................................................ 706 8.4.2 Selection of Step Size Based on Stability ....................................... 707 8.4.3 Selection of Step Size Based on Dynamic Accuracy ..................... 708 8.4.4 Analytical Solution for State Variables........................................... 712 8.4.5 Multirate Integration of Aircraft Pitch Control System .................. 714 8.4.6 Nonlinear Dual Speed Second-Order System ................................. 717 8.4.7 Multirate Simulation of Two-Tank System .................................... 723 8.4.8 Simulation Trade-Offs with Multirate Integration .......................... 725 Exercises.................................................................................................................. 728 8.5 Real-Time Simulation................................................................................... 730 8.5.1 Numerical Integration Methods Compatible with Real-Time Operation............................................................... 733 8.5.2 RK-1 (Explicit Euler) ...................................................................... 734 x Contents
8.5.3 RK-2 (Improved Euler) ................................................................... 734 8.5.4 RK-2 (Modified Euler) .................................................................... 735 8.5.5 RK-3 (Real-Time Incompatible) ..................................................... 735 8.5.6 RK-3 (Real-Time Compatible)........................................................ 736 8.5.7 RK-4 (Real-Time Incompatible) ..................................................... 736 8.5.8 Multistep Integration Methods ........................................................ 736 8.5.9 Stability of Real-Time Predictor–Corrector Method....................... 738 8.5.10 Extrapolation of Real-Time Inputs.................................................. 740 8.5.11 Alternate Approach to Real-Time Compatibility: Input Delay....... 746 Exercises.................................................................................................................. 753 8.6 Additional Methods of Approximating Continuous-Time System Models ............................................................................................. 754 8.6.1 Sampling and Signal Reconstruction .............................................. 754 8.6.2 First-Order Hold Signal Reconstruction.......................................... 759 8.6.3 Matched Pole-Zero Method............................................................. 760 8.6.4 Bilinear Transform with Prewarping............................................... 763 Exercises.................................................................................................................. 765 8.7 Case Study: Lego Mindstormse NXT ........................................................ 767 8.7.1 Introduction ..................................................................................... 767 8.7.2 Requirements and Installation ......................................................... 769 8.7.3 Noisy Model .................................................................................... 769 8.7.4 Filtered Model ................................................................................. 773 8.7.5 Summary.......................................................................................... 779 Exercise ................................................................................................................... 779 References .................................................................................................................................... 781 Index ............................................................................................................................................. 785 Contents xi
This page intentionally left blank
Foreword As the authors point out in the preface, there is not yet extant a universally accepted definition of the term simulation. Another approach to defining the field would be ‘‘the art of reproducing the behavior of a system for analysis without actually operating that system.’’ The authors have written a seminal text covering the simulation design and analysis of a broad variety of systems using two of the most modern software packages available today. The material is presented in a particularly adept fashion enabling students new to the field to gain a thorough understanding of the basics of continuous simulation in a single semester and providing, at the same time, a more advanced treatment of the subject for researchers and simulation professionals. The authors’ extensive treatment of continuous and discrete linear system fundamentals opens the door to simulation for individuals without formal education in a traditional engineering curriculum. However defined, simulation is becoming an increasingly important component of curricula in engineering, business administration, the sciences, applied mathematics, and the like. This text will be a valuable resource for study in courses using simulation as a tool for understanding processes that are not amenable to study in other ways. Chris Bauer, PhD, PE, CMSP Orlando, Florida Simulation has come a long way since the days analog computers filled entire rooms. Yet, it is more important than ever that simulations be constructed with care, knowledge, and a little wisdom, lest the results be gibberish or, worse, reasonable but misleading. Used properly, simulations can give us extraordinary insights into the processes and states of a physical system. Constructed with care, simulations can save time and money in today’s competitive marketplace. One major application of simulation is the simulator, which provides interaction between a model and a person through some interface. The earliest simulator, Ed Link’s Pilot Maker aircraft trainer, did not use any of the simulation techniques described in this book. Modern simulators, however, such as the National Advanced Driving Simulator (NADS), cannot be fully understood without them. The mission of the NADS is a lofty one: to save lives on U.S. highways through safety research using realistic human-in-the-loop simulation. This is an example of the importance simulation has attained in our generation. The pervasiveness of simulation tools in our society will only increase over time; it will be more important than ever that future scientists and engineers be familiar with their theory and application. The content for Simulation of Dynamic Systems with MATLAB® and Simulink® is arranged to give the student a gradual and natural progression through the important topics in simulation. Advanced concepts are added only after complete examples have been constructed using funda- mental methods. The use of MATLAB and Simulink provides experience with tools that are widely adopted in industry and allow easy construction of simulation models. May your experience with simulation be enjoyable and fruitful and extend throughout your careers. Chris Schwarz, PhD Iowa City, Iowa xiii
This page intentionally left blank
Preface In the first article of SIMULATIONmagazine in the Fall of 1963, the editor John McLeod proclaimed simulation to mean ‘‘the act of representing some aspects of the real world by numbers or symbols which may be easily manipulated to facilitate their study.’’ Two years later, it was modified to ‘‘the development and use of models for the study of the dynamics of existing or hypothesized systems.’’ More than 40 years later, the simulation community has yet to converge upon a universally accepted definition. Either of the two cited definitions or others that followed convey a basic notion, namely, that simulation is intended to reinforce or supplement one’s understanding of a system. The definitions vary in their description of tools and methods to accomplish this. The field of simulation is experiencing explosive growth in importance because of its ability to improve the way systems and people perform, in a safe and controllable environment, at a reduced cost. Understanding the behavior of complex systems with the latest technological innovations in fields such as transportation, communication, medicine, aerospace, meteorology, etc., is a daunting task. It requires an assimilation of the underlying natural laws and scientific principles that govern the individual subsystems and components. A multifaceted approach is required, one in which simulation can play a prominent role, both in validation of a system’s design and in training of personnel to become proficient in its operation. Simulation is a subject that cuts across traditional academic disciplines. Airplane crews spend hours flying simulated missions in aircraft simulators to become proficient in the use of onboard subsystems during normal flight and possible emergency conditions. Astronauts spend years train- ing in shuttle and orbiter simulators to prepare for future missions in space. Power plant and petrochemical process operators are exposed to simulation to obtain peak system performance. Economists resort to simulation models to predict economic conditions of municipalities and countries for policymakers. Simulations of natural disasters aid in preparation and planning to mitigate the possibility of catastrophic events. While the mathematical models created by aircraft designers, nuclear engineers, and economists are application specific, many of the equations are analogous in form despite the markedly different phenomena described by each model. Simulation offers practitioners from each of these fields the tools to explore solutions of the models as an alternative to experimenting with the real system. This book is meant to serve as an introduction to the fundamental concepts of continuous system simulation, a branch of simulation applied to dynamic systems whose signals change over a continuum of points in time or space. Our concern is with mathematical models of continuous- time systems (electric circuits, thermal processes, population dynamics, vehicle suspension, human physiology, etc.) and the discrete-time system models created to simulate them. The continuous system mathematical models consist of a combination of algebraic and ordinary differential equations. The discrete-time system models are a mix of algebraic and difference equations. Systems that transition between states at randomly occurring times are called discrete-event systems. Discrete-event simulation is a complementary branch of simulation, separate from con- tinuous system simulation, with a mathematical foundation rooted in probability theory. Examples of discrete-event systems are facilities such as a bank, a tollbooth, a supermarket, or a hospital emergency room, where customers arrive and are then serviced in some way. A manufacturing plant involving multiple production stages of uncertain duration to generate a finished product is another candidate for discrete-event simulation. Discrete-event simulation is an important tool for optimizing the performance of systems that change internally at unpredictable times due to the influence of random events. Industrial engineer- ing programs typically include a basic course at the undergraduate level in discrete-event simulation. xv
Not surprisingly, a number of excellent textbooks in the area have emerged for use by the academic community and professionals. In academia, continuous simulation has evolved differently than discrete-event simulation. Topics in continuous simulation such as dynamic system response, mathematical modeling, differ- ential equations, difference equations, and numerical integration are dispersed over several courses from engineering, mathematics, and the natural sciences. In the past, the majority of courses in modeling and simulation of continuous systems were restricted to a specific field like mechanical, electrical, and chemical engineering or scientific areas like biology, ecology, and physics. A transformation in simulation education is underway. More universities are beginning to offer undergraduate and beginning graduate courses in the area of continuous system simulation designed for an interdisciplinary audience. Several institutions now offer master’s and PhD programs in simulation that include a number of courses in both continuous and discrete-event simulation. A critical mass of students are now enrolled in continuous simulation–related courses and there is a need for an introductory unifying text. The essential ingredient needed to make simulation both interesting and challenging is the inclusion of real-world examples. Without models of real-world systems, a first class in simulation is little more than a sterile exposition of numerical integration applied to differential equations. Modeling and simulation are inextricably related. While the thrust of this text is continuous simulation, mathematical models are the starting point in the evolution of simulation models. Analytical solutions of differential equation models are presented, when appropriate, as an alterna- tive to simulation and a simple way of demonstrating the accuracy of a simulated solution. For the most part, derivations of the mathematical models are omitted and references to appropriate texts are included for those interested in learning more about the origin of the model’s equations. Simulation is best learned by doing. Accordingly, the material is presented in a way that permits the reader to begin exploring simulation, starting with a mathematical model in Chapter 1. A detailed derivation of the mathematical model of a tank with liquid flowing in and out leads to a simulation model in the form of a simple difference equation. The simulation model serves as the vehicle for predicting the tank’s response to various inputs and initial conditions. Additionally, the derivation illustrates the process of obtaining a mathematical model based on the natural laws of science. Chapters 2 and 4 present a condensed treatment of linear, continuous-time, and discrete-time dynamic systems, normally covered in an introductory linear systems course. Coverage is limited to basic topics that should be familiar to a simulation practitioner. Section 2.7 is extended to include a discussion of additional common nonlinear elements, namely, dead zone, quantization, relay, and saturation. The instructor can skip some or all of the material in these chapters if the students’ background includes a course in signals and systems or linear control theory. Numerical integration is at the very core of continuous system simulation. Instead of treating the subject in one exhaustive chapter, coverage is distributed over three chapters. Elementary numerical integration in Chapter 3 is an informal introduction to the subject, which includes discussion of several elementary methods for approximating the solutions of first-order differential equations. The material in Chapters 2 through 4 is a prerequisite for understanding general purpose, continuous simulation programs that are popular in the engineering and scientific community. Simulink®, from The MathWorks, is the featured simulation program because of its tight integration with MATLAB®, the de facto standard for scientific and engineering analysis, and data visualization software. Chapter 5 takes the reader through the basic steps of creating and running Simulink models. Section 5.5 includes new material related to simulation implementation of nonlinear systems using specific blocks from the Simulink library. Due to the popularity of the Kalman filter, a case study has been added in Section 5.12 on this topic. The continuous-time Kalman filter equations are developed and modeled in Simulink, including simulated output. Subsequently, the steady-state continuous-time Kalman filter equations are developed and modeled in Simulink. The steady-state results are compared with the continuous-time results. Finally, the xvi Preface
discrete-time Kalman filter equations are developed and modeled in Simulink. The discrete-time results are compared with the continuous-time results. Chapter 6 delves into intermediate-level topics of numerical integration, including a formal presentation of One-Step (Runge–Kutta) and multistep methods, adaptive techniques, truncation errors, and a brief mention of stability. Chapter 7 highlights some advanced features of Simulink useful in more in-depth simulation studies. A new section (Section 7.5) on S-blocks is introduced and an example is presented showing how to make the discrete-time Kalman filter available for drag-and-drop from the Simulink library. Other simulation programs offer similar features and the transition from Simulink to other simula- tion software is straightforward. Chapter 8 is for those interested in more advanced topics on continuous simulation. Coverage includes a discussion of dynamic errors, stability, real-time compatible numerical integration, and multi-rate integration algorithms for simulation of systems with fast and slow components. Due to the popularity of Lego’s Mindstormse NXT, a case study has been added in Section 8.7 on this topic. All but two chapters conclude with a case study illustrating one or more of the topics discussed in that chapter. The featured text examples and case studies are analyzed using MATLAB script files and Simulink model files, all of which are available from CRC Press. The text has been field-tested in the classroom for several years in a two-semester sequence of continuous simulation courses. Despite numerous revisions based on the scrutiny and suggestions of students and colleagues, it is naïve to think the final product is free of errors. Further suggestions for improvement and revelations of inaccuracies can be brought to the attention of the authors at rallen397@cfl.rr.com and klee@mail.ucf.edu. Numerous individuals deserve our thanks and appreciation for helping to make this book possible. In particular, a sincere ‘‘thank you’’ to Nora Konopka at Taylor & Francis=CRC Press for committing to the second edition and seeing it through to fruition. For MATLAB® and Simulink® product information, please contact: The MathWorks, Inc. 3 Apple Hill Drive Natick, MA, 01760-2098 USA Tel: 508-647-7000 Fax: 508-647-7001 E-mail: info@mathworks.com Web: www.mathworks.com Preface xvii
This page intentionally left blank
Authors Dr. Harold Klee received his PhD in systems science from Polytechnic Institute of Brooklyn in 1972, his MS in systems engineering from Case Institute of Technology in 1968, and his BSME from The Cooper Union in 1965. Dr. Klee has been a faculty member in the College of Engineering at the University of Central Florida (UCF) since 1972. During his tenure at UCF, he has been a five-time recipient of the college’s Outstanding Teacher Award. He has been instrumental in the development of simulation courses in both the undergraduate and graduate curricula. He is a charter member of the Core Faculty, which is responsible for developing the interdisciplinary MS and PhD programs in simulation at UCF. Dr. Klee served as graduate coordinator in the Department of Computer Engineering from 2003 to 2006. Two of his PhD students received the prestigious Link Foundation Fellowship in Advanced Simulation and Training. Both are currently enjoying successful careers in academia. Dr. Klee has served as the director of the UCF Driving Simulation Lab for more than 15 years. Under the auspices of the UCF Center for Advanced Transportation Systems Simulation, the lab operates a high-fidelity motion-based driving simulator for conducting traffic engineering–related research. He also served as editor-in-chief for the Modeling and Simulation magazine for three years, a publication for members of the Society for Modeling and Simulation International. Dr. Randal Allen is an aerospace and defense consultant working under contract to provide 6DOF aerodynamic simulation modeling, analysis, and design of navigation, guidance, and control systems. His previous experience includes launch systems integration and flight operations for West Coast Titan-IV missions, propulsion modeling for the Iridium satellite constellation, and field applications engineering for MATRIXx. He also chairs the Central Florida Section of the American Institute of Aeronautics and Astronautics (AIAA). Dr. Allen is certified as a modeling and simulation professional (CMSP) by the Modeling and Simulation Professional Certification Commission (M&SPCC) under the auspices of the National Training and Simulation Association (NTSA). He is also certified to deliver FranklinCovey’s Focus and Execution track, which provides training on achieving your highest priorities. Dr. Allen’s academic background includes a PhD in mechanical engineering from the University of Central Florida, an engineer’s degree in aeronautical and astronautical engineering from Stanford University, an MS in applied mathematics, and a BS in engineering physics from the University of Illinois (Urbana-Champaign). He also serves as an adjunct professor at the University of Central Florida in Orlando, Florida. xix
The above is a preview of the first 20 pages. Register to read the complete e-book.