|
Chapter $$
Interactive Dynamic-system Simulation
under Microsoft Windows 95 and NT
by Granino A. Korn
ECE Dept., University of Arizona
and G.A. and T.M. Korn Industrial Consultants,
Chelan, WA
Foreword
Chapter 1. Computer Simulation of Dynamic
Systems
INTRODUCTION AND OVERVIEW
DYNAMIC- SYSTEM MODELS
1-1. Continuous-system Simulation and Discrete-event
Simulation
1-2. Models, Time Histories, and State Equations
1-3. Differential-equation Models
1-4. State-variable Models with Defined Variables
1-5. Classical Applications and Higher-order Differential Equations
SIMULATION PROGRAMS AND SIMULATION
LANGUAGES
1-6. Model Definition and Experiment Protocol
1-7. The Simulation-run Procedure
(a) Initialization, Integration, and Time-history Output
(b) Integration Rules
1-8. Simulation Programs: Subroutine Packages and
Equation Languages
1-9. Block-diagram Models and Block-diagram Editors
USER-INTERFACE REQUIREMENTS FOR COMPUTER
SIMULATION
1-10. A Wish List for Interactive Modeling
1-11. Interactive Experiments Need Direct Execution as well as
High Speed
1-12. Interactive Experiments Must Display Results Immediately
1-13. Simulation with DESIRE
(a) A Complete Simulation Program
(b) A User-friendly Environment for Interactive Experiments
Chapter 2. Examples of Complete Simulation
Programs
OVERVIEW
INTERACTIVE MODELING AND SIMULATION
2-1. Getting Started
2-2. Interactive Windows Operations
SIMPLE EXAMPLES FROM PHYSICS
2-3. Linear Oscillators
2-4. Nonlinear Oscillations and Phase-plane Plots
(a) Van der Pol's Differential Equation
(b) Simulation of a Simple Pendulum
(c) Lorenz Differential
Equations: an Example of Chaos
2-5. Nuclear-reactor Simulation
2-6. An Electric-circuit Simulation with 1583 Differential Equations
AEROSPACE AND RELATED APPLICATIONS
2-7. Ballistic Trajectories
2-8. Simple Flight Simulation
(a) Pitch-plane Flight Equations
(b) Linearized Flight Equations
2-9. A Simplified Autopilot
2-10. Torpedo Trajectory
2-11. Translunar Satellite Orbit
MODELS FROM PHYSIOLOGY AND POPULATION
DYNAMICS
2-12. Simulation of a Glucose-tolerance Test
2-13. Simulation of Epidemic Propagation
2-14. Simulation in Ecology. A Predator-prey System
Chapter 3. Simulation Runs and
DYNAMIC Program Segments
OVERVIEW
INTERPRETED EXPERIMENT PROTOCOL, COMPILED SIMULATION
UNS
3-1. The Experiment-protocol Program
3-2. Simulation Runs, Simulation Time, and Communication Points
(a) Simulation-run Procedure and DYNAMIC Program Segments
(b) Run Termination and Continued Runs
(c) Simulation Time Histories and Communication Points
3-3. DYNAMIC Segments with Differential Equations.
Default Parameter Values
(a) Integration Routines
(b) Simulation-time Range and Default Parameter Values
(c) Resetting Initial Conditions: reset
and drunr
3-4. DYNAMIC Segments Without Differential Equations
PROGRAMMING SIMPLE DYNAMIC SEGMENTS
3-5. The DYNAMIC Statement.
DYNAMIC-segment Code
3-6. Scalar Defined Variables
(a) Defined-variable Assignments
(b) Defined Variables: Order of Computation
3-7. Scalar Differential Equations
3-8. User-defined Functions
3-9. Runtime Time-history Output:
(a) Time-history Listings and Graphs: type,
dispt, dispxy,
and DISPXY
(b) Display
Coordinate Net , Labels, and Colors
(c) Display Scaling
(d) Stripchart-type Displays
(e) Time-history Listings on Files and Printers
(f) Printing and Saving Time-history Graphics
3-10. Sampling Operations
(a) The OUT
Statement
(b) SAMPLE
and step
Statements
SCALAR DIFFERENCE EQUATIONS
3-11. Recursive Assignments and Difference Equations
3-12. Multiple Difference Equations: State Equations and Predicted
Values
3-13. Pure Difference-equation Problems
(a) General Case
(b) Pure Difference Equations with Integer Time Steps
(c) Examples: Some Difference Equations Generate Chaos
3-14. Models with Both Differential Equations and
Difference Equations
CONDITIONAL RUN TERMINATION AND
if STATEMENTS
3-15. The Run-termination Operator
3-16. if
Statements in DYNAMIC Program Segments
Chapter 4. Models with Vector and Matrix
Operations
OVERVIEW
VECTOR
ASSIGNMENTS IN DYNAMIC PROGRAM SEGMENTS
4-1. Arrays and Subscripted Variables
4-2. Simple VECTOR
Expressions
(a) Vector Sums
(b) Sums of Product Terms
4-3. Linear Transformations
(a) Matrix/vector Products
(b) Syntax Rules
(c) Example: Rotation Matrices
4-4. Vector Functions
(a) Library Functions
(b) Output-limited Vectors
(c) Finding Maximum and Minimum Elements
4-5. VECTOR
Index-shift Operations and Convolutions
(a) Index-shifted Vectors
(b) Convolutions
DOT PRODUCTS, SUMS, AND VECTOR NORMS
IN DYNAMIC SEGMENTS
4-6. DOT
Products and Euclidean Norms of Vectors
(a) Simple DOT
Products
(b) Absolute Value (Euclidean Norm) of a Vector
4-7. Simple Sums and Taxicab Norms
4-8. More General DOT
Products
VECTOR DIFFERENTIAL EQUATIONS AND
DIFFERENCE EQUATIONS
4-9. STATE
Arrays and Vector Differential Equations
4-10. State-variable Declarations
4-11. Vector Difference Equations
TIME-HISTORY FUNCTION STORAGE AND
TIME-DELAY SIMULATION
4-12. Introduction
4-13. Function Storage and Recovery with store
and get
Operations
(a) store
and get
Operations
(b) Applications
4-14. Time-delay Simulation
4-15. Time-history Storage and Recovery Using Binary Files
Chapter 5. Function Generation and Submodels
OVERVIEW
GENERAL-PURPOSE FUNCTION GENERATION
5-1. Library Functions
5-2. Table Lookup and Interpolation
5-3. User-written Functions
TRICKS AND TREATS: SPECIAL PIECEWISE-LINEAR
FUNCTIONS
5-4. Limiters and Combinations of Limiters
(a) Using Simple Limiters
(b) Relations between Functions. Maximum and Minimum Functions
(c) Example: Automatic
Display Scaling and Envelope Generation
(d) Output-limited Integrators
5-5. Switches and Comparators
5-6. Hysteresis, Backlash, and Special Signal Generators
(a) A Comparator with Hysteresis
(b) Signal Generators
(c) Modulation Waveforms
(d) Hysteresis and Backlash
5-7. Simulation of Signal Quantization
SUBMODEL DECLARATION AND INVOCATION
5-8. Submodel Definition, Invocation, and Nesting
5-9. Submodels with Differential Equations
5-10. Example: Simulation of a Satellite Roll-control System
Chapter 6.
More Advanced Simulation Programs
OVERVIEW
PROGRAMMING THE EXPERIMENT PROTOCOL
6-1. Declarations and Array Initialization
6-2. Setting Simulation-run Parameters
6-3. Display Scaling and Display Control
6-4. Setting Initial Conditions
TWO MULTIRUN SIMULATION STUDIES
6-5. One Way to Create Logarithmic Plots
6-6. Solution Envelopes for Multiple Random-process Runs
MULTIPLE RUNS CAN SPLICE COMPLICATED
TIME HISTORIES
6-7. Simulation of Hard Impact: The Bouncing Ball
6-8. The EUROSIM Peg-and-pendulum Problem
6-9. The EUROSIM Switched-amplifier Problem
PROGRAMS WITH MULTIPLE DYNAMIC SEGMENTS
6-10. Multiple DYNAMIC Program Segments
6-11. Crossplotting Results from Multiple Runs: the Pilot-ejection
Problem
MORE EXAMPLES
6-12. Simulation of Human Blood Circulation
6-13. System Dynamics and World Simulation
INTERACTIVE CONTROL-SYSTEM SIMULATION
6-14. Introduction
6-15. Simulation of a Servomechanism.
Test Inputs and Error Measures
6-16. Parameter-sensitivity Studies and Parameter Optimization
(a) Parameter Sensitivity
(b) Iterative Optimization
6-17. Model Changes and Nonlinear Transfer Characteristics
6-18. Using Vector Differential Equations and Difference Equations
6-19. A Sampled-data Control System: Analog Plant with Digital
Controller
6-20. Frequency-response studies
(a) State-equation Models for Linear Time-invariant Systems
(b) Impulse Response and Frequency Response of a Linear
System
6-21. Control Systems with Neural Networks and Fuzzy Logic
TRICKS AND TREATS: INTERACTIVE MODELING
IN MULTIPLE WINDOWS
6-22. Run and Compare Programs from Multiple Editor
Windows
6-23. Program-line Numbers and Special Dialog-editor Windows
(a) Editing Selected Program Lines
(b) Programs with Line Numbers
(c) Editor Windows for Selected Program Lines
(d) Adding Comments and User Instructions
6-24. Testing Program Changes with Keyboard Commands
6-25. Use the ADD
Button to Combine Program Segments, Submodels,
and Library Functions
6-26. You Need Electronic Notes to Track Simulation
Studies
Chapter 7. General-purpose Scientific
Computation
OVERVIEW
COMPILED PROGRAMS NEED NOT BE SIMULATION
MODELS
7-1. Dummy Integration Repeats the DYNAMIC-segment
Code
7-2. Application: Fast Graph Plotting
(a) A Simple Function Plot
(b) Plotting Array Values
7-3. Fast Array Manipulation
7-4. Using Simple Difference Equations
7-5. Statistical Computations
COMPLEX-NUMBER OPERATIONS AND INTERPRETER
GRAPHICS
7-6. INTEGER
and COMPLEX
Quantities in the Interpreter Program
7-7. Interpreter Graphics, Complex-number Plots, and Conformal
Mapping
FAST FOURIER TRANSFORMS AND CONVOLUTIONS
7-8. Fast Fourier Transforms
(a) Complex FFTs
(b) Simultaneous Transformation of Two Real Arrays
(c) Cyclical Convolutions
INTERPRETED MATRIX OPERATIONS
7-10. Interpreted versus Compiled VECTOR
and DOT
Assignments
7-11. Interpreter Matrix Multiplication
7-12. Null and Identity Matrices
7-13. Matrix Inversion and Solution of Linear Equations
7-14. Matrix Transposition
Appendix A. Simulation Accuracy and Integration
Techniques
SIMULATION ACCURACY AND TEST PROGRAMS
A-1. Introduction
A-2. Roundoff Errors
A-3. Choice of Integration Rule and DT
A-4. Programs for Testing Integration
Routines
(a) Sensitivity Tests
(b) Testing a Protracted Simulation Run
DESIRE INTEGRATION RULES
A-5. Runge-Kutta and Euler Rules
A-6. Variable-order/variable-order Rules and Stiff Differential-equation
Systems
(a) Implicit Adams and Gear Rules
(b) Stiff Differential-equation Systems
(c) Examples Using Gear-type Integration
A-7. Integration of Discontinuous Functions
MISCELLANEOUS TOPICS
A-8. Perturbation Methods can Improve Accuracy
A-9. Avoiding Division
Appendix B. Supplementary Reference
Material
COMMAND-WINDOW OPERATIONS
B-1. Command Lines and Function Keys in
the Command Window
B-2. Function-key Commands on Personal Computers
B-3. Using Operating-system Commands
B-4. Command-window Editing and User-written Menus on Personal
Computers
EXPERIMENT-PROTOCOL PROGRAMMING:
ASSIGNMENTS
B-5. Expressions and Functions
B-6. data
Lists and read
Assignments
EXPERIMENT-PROTOCOL PROGRAM CONTROL
B-7. Labels, Branching, and Hot Keys
B-8. Conditional Branching: if
... then
... proceed
B-9. for,
while,
and repeat
Loops
B-10. Interpreter Procedures
B-11. new,
clear,
and STOP
EXPERIMENT-PROTOCOL INPUT/OUTPUT
B-12. Console, Text-file, and Device Output
B-13. Writing to Files or Devices
B-14. Console, File, and Device Input
B-15. Octal and Hexadecimal Numbers
DEBUGGING, AUTOMATIC NOTEBOOK FILE,
AND HELP FACILITY
B-16. Interactive Error Correction
B-17. Debugging Experiment Protocols with Programmed STOP
Statements
B-18. trace
and dump
Facilities
B-19. The Automatic Notebook File
B-20. The time
Statement
Appendix C. Using the Program Diskettes
RUNNING DESIRE UNDER MICROSOFT WINDOWS
95 OR NT
C-1. Introduction
C-2. Program Installation
C-3. Starting DESIRE. Editor Windows and Command Window
C-4. How to Load, Edit, Save, Print, and Run Simulation Programs
(a) File
and Edit
Menus and Buttons
(b) Transfer
Menu and Buttons
(c) Compiling and Running the Edited Program
(d) Restoring the Windows Display
C-5. Saving Graphs and Window Screens
C-6. How to Quit
(a) Ending a Session
(b) Uninstallation
C-7. Help Facilities
(a) Help for Editor Windows
(b) Command-window Help and User-written Help Screens
RUNNING DESIRE UNDER MS-DOS
C-8. Switching to MS-DOS Operation
C-9. Keyboard Commands
(a) Editing under MS-DOS
(b) File Manipulation
(c) Program Listing and Printing
RUNNING DESIRE UNDER WINDOWS NT
C-10. Command-window Operations
Appendix D. Large Differential-equation
Systems in Matrix Notation
Selected References
|