- samle
- PLD Syllabus New
- JPR Chapter 1
- CSharpCheatSheet
- Mini Project Report
- 10 Th Exercise
- Hfm Objects
- Library Management System.pptx
- ICSE 2011 Computer Application Solved Paper
- CSE 115_115L Course Objective and Outcome
- SAP Tip: Create custom transaction for GR55 Reports
- Main
- IindraLogic Prog 04 2007 e
- Convergence Hints (aspen)
- Lecture 2
- SPIRV
- question_bank.docx
- how to learn c
- C Language Tutorial
- ZPIO
- Week 2 - Iterative Data Processing - For Students
- Lecture04 Computation (2)
- CS 100 Outline 02
- Course Work Syllabus (1)
- Assignment 1
- MELJUN CORTES C++_Chap2
- plc_st
- primex
- Python Tutorial
- operating system memory management
- time1.pdf
- pi3_gpio
- 4 Datetime — Basic Date and Time Types — Python 3.6
- 5 Datetime — Basic Date and Time Types — Python 3.6
- 6 Datetime — Basic Date and Time Types — Python 3.6
- time2
- 1990 TI Optoelectronics Data Book
- 2 Datetime — Basic Date and Time Types — Python 3.6
- 7 Datetime — Basic Date and Time Types — Python 3.6
- 10 Datetime — Basic Date and Time Types — Python 3.6
- time3
- Time
- 3 datetime — Basic date and time types — Python 3.6.pdf
- 3 Datetime — Basic Date and Time Types — Python 3.6
- time1.pdf
- Automation Body of Knowledge.pdf
- percikan 2
- Stepper 2
- Stepper 1
- percikan kisah
- percikan 1
- Shift Bit Register (%SBR)
- SnapTrack Under Bonding Grounding
- kabel
- 0m8NTozFZL8C(15233856)
- Help - Asynchronous Machine __ Blocks (SimPowerSystems™).pdf
- Stepper 3
- Hour 11. Using Files
- 1 Datetime — Basic Date and Time Types — Python 3.6
- resistor.pdf

Language Reference Guide Version 3.0 March 2010

The AEgis Technologies Group, Inc. 410 Jan Davis Drive Huntsville, AL 35806 U.S.A. Phone: (256) 922-0802 info@acslx.com www.acslx.com

acslX Language Reference Guide Copyright © 2003 – 2010 The AEgis Technologies Group, Inc. All Rights Reserved. Printed in the United States of America. ACSL, acslX, and PowerBlock are registered trademarks of The AEgis Technologies Group, Inc. acslX and acslXpress are trademarks of The AEgis Technologies Group, Inc. Microsoft, Windows, Microsoft .NET, and Microsoft Internet Explorer are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. FLEXlm is a registered trademark of Globetrotter Software, Inc., A Macrovision Company All other brand and product names mentioned herein are the trademarks and registered trademarks of their respective owners. Information in this document is subject to change without notice. The software described in this document is furnished under a license agreement. The software and this documentation may be used only in accordance with the terms of those agreements.

The AEgis Technologies Group, Inc. 410 Jan Davis Drive Huntsville, AL 35806 U.S.A. Phone: (256) 922-0802 info@acslx.com www.acslx.com March 2010

Table of Contents

Chapter 1 Introduction ........................................................................................................... 6

1.1 Simulation Language ....................................................................................................................... 6 1.2 The Model Editor Windows .............................................................................................................. 6 1.3 Building Process .............................................................................................................................. 8 1.4 Language features ........................................................................................................................... 8 1.4.1 Operators and functions ............................................................................................................ 9 1.4.2 Integration.................................................................................................................................. 9 1.4.3 INTEG operator ......................................................................................................................... 9 1.4.4 Redundant state variables....................................................................................................... 10 1.4.5 Limit cycle example ................................................................................................................. 10 1.4.6 Runtime commands................................................................................................................. 11 1.5 Coding procedure........................................................................................................................... 11 1.5.1 Separator ................................................................................................................................. 11 1.5.2 Continuation............................................................................................................................. 12 1.5.3 Comments ............................................................................................................................... 12 1.5.4 Blank lines ............................................................................................................................... 12 1.6 Reserved names ............................................................................................................................ 12 1.6.1 System variable defaults ......................................................................................................... 12 1.6.2 Precedence of names.............................................................................................................. 13

**Chapter 2 Language Elements .............................................................................................14
**

2.1 Introduction .................................................................................................................................... 14 2.2 Constants ....................................................................................................................................... 14 2.2.1 Integer...................................................................................................................................... 14 2.2.2 Promotion of integers .............................................................................................................. 15 2.2.3 Floating point ........................................................................................................................... 15 2.2.4 Logical ..................................................................................................................................... 15 2.2.5 Character ................................................................................................................................. 16 2.3 Variables ........................................................................................................................................ 16 2.3.1 Types ....................................................................................................................................... 16 2.3.2 Subscripts ................................................................................................................................ 16 2.3.3 Array order............................................................................................................................... 16 2.4 Labels............................................................................................................................................. 17 2.4.1 Syntax...................................................................................................................................... 17 2.4.2 Statement labels and macro expansion .................................................................................. 17 2.4.3 CONTINUE statements ........................................................................................................... 18 2.5 Expressions.................................................................................................................................... 18 2.5.1 Arithmetic operators ................................................................................................................ 18 2.5.2 Parentheses............................................................................................................................. 18 2.5.3 Warning - dividing by integer ................................................................................................... 19 2.5.4 Relational operators ................................................................................................................ 19 2.5.5 Logical operators ..................................................................................................................... 19 2.5.6 Operands ................................................................................................................................. 19

**Chapter 3 Program Structure................................................................................................22
**

3.1 Implicit and explicit structure .......................................................................................................... 22 3.2 Program flow .................................................................................................................................. 22 3.2.1 INITIAL..................................................................................................................................... 23 3.2.2 DERIVATIVE DISCRETE ........................................................................................................ 24 3.2.3 DYNAMIC ................................................................................................................................ 24 3.2.4 STOP flag ................................................................................................................................ 24 3.2.5 Integration................................................................................................................................ 24 3.2.6 Transfer control ....................................................................................................................... 25 3.2.7 TERMINAL............................................................................................................................... 25 Language Reference Manual i

.................................................... 33 4.......................................... 45 4......................................................................................... 25 3................................................. 30 4...........................................................5.....5........3 Program sorting.........1 States.................................. 30 4............................ 27 3................................................................................................................ 39 4...............................................5............................................................ and TERMINAL sections.........................................1........15 CINTERVAL ..5.............................. 43 4........................................................................................7 Gear's stiff..........1 Arithmetic..1............................................... 41 4.....................................................................................................................10 NSTP with variable step algorithms .................................................................................7 ASIN .....................1.........5................................ 27 Chapter 4 acslX Statements ............................................................................ 41 4........................................................................................1............... 45 4..... 44 4..................................................................................................................................3..................................4.............2 Diagnosing loops .................................................................................................... 29 4...... 37 4...............1..........6 ANINT............................................. 31 4....1................2 Recommended integration control ....................1 Adjusting step size to CINT ............. 42 4..... 28 4..........................................12 Determining appropriate step size............................................................................................... 40 4................11 Error summary.............................10 ATAN2................................... 26 3.........................................................5 Equal sign (=) ............6 Preset of derivatives............................... 38 4...........1. 28 4..4 Program Structure Preset of User Variables. 29 4............5............................................................................................................ 26 3............................................ 43 4............................3 ACOS .4... 45 4............................ 26 3..1 Array with multiple sections ............9 ATAN................................................................... 35 4.........................................................11 Precision of acslX operators........3 Multiple INITIAL................10 Standalone form of operators .......................................5............................................................... 37 4...........................4.........................3.....8.......................................... : .........12 Forcing precision ......................... 26 3.......................... 41 4.......................................6 Adams-Moulton ...............8 State operators ................................................. 31 4...............................5 Preset of user variables .................................................................................... 28 4.......................15............................. 41 4.....9 MINT with variable step algorithms .........................11 BCKLSH .............................................................................................................................................................................................................................................................8 Runge-Kutta-Fehlberg ...............................13 CALL .......1 Documentation convention ............ 26 3....................................................................................1........................1...........................................................................................................2 ! & ...4............................................... 40 4.................... 28 4..............................5......................................................................................................2 ABS 32 4..........2 CONSTANT ............................. 38 4..................................................3 Fixed step algorithms ........................................................... 35 4............................. 39 4........................5..............................................................................13 Efficiency and accuracy........ 29 4.................................................................................................................................................................................................................................................................................... 39 4.............................1.................................................5........................................................................................................................................................................................................................2 Logical .......................................................................................................... 33 4.................................................................7 Operators for simulation models....................................12 BOUND ............................. 30 4.....6 Equal sign in PROCEDURAL ..........................................................................4 Section nesting . 26 3...........................5.........................................................................3 Character .................................................................................................................................................8 Assignment statements........3 CONSTANT recompilation .. 46 Language Reference Manual ii ...........................................................................................................................................1. 27 3...........................................................................................................................................................................4 Runge-Kutta procedure .....................................................................................8...................................................................... 43 4................................................4 Debugging ................................. 34 4..........1 Algebraic loops .............................................................................................9 Array name conflicts ......5.................... 29 4.1..................................................................................................................................................... DYNAMIC.........................4 AINT .................................................................................................................. 42 4.................................................................1 Introduction ..............................................................................................................5 ALGORITHM.....14 CHARACTER..............8.................................3....................5 Variable step algorithms ............... 32 4.....................28 4................ 32 4...................5........

............................................................................. 85 4..........................................................54 INTVC........................................................................................................................30 DIM 62 4.......................................... 92 Language Reference Manual iii ................................................................................................................................38 EXP 67 4...............................................................................................40 GAUSI...... 50 4..... 62 4.....................................................................34 DOUBLE PRECISION....... MINTERVAL....................59 LOGICAL..................................................................24 DEAD ................................22 DBLE .42 GO TO................. 67 4............................................................................................15.................................................................................................... 84 4................................... 86 4..........................................52 INTEGER ..........................................................................................................................27 DELVC ......................4.. 90 4...........................29 DERIVT ..... 87 4..................................................................................................................................................................................................................................................21 COS 53 4............... 70 4................................................... 87 4..................69 NSTEPS ........................................................................................................................................................................................................................ 47 4..............49 INITIAL ................................................................................................................................. 67 4.............................................. 59 4.................................... 91 4...26 DELSC .................................................................16 CMPXPL ............................................................3 Changing default name .............................. 64 4........... 68 4........... UNIFI....................................... 81 4...............................................................43 HARM..................62 MAX 88 4...................................................2 Calculating CINT .................................15..........................53 INTERVAL......... 60 4......................................................................... 71 4..........................51 INTEG .................................................................................................................................58 LOG10...........................................................................37 ERRTAG .17 Comment (!) ...36 END 66 4..................... 51 4.............. 88 4....................................................................................... XERROR.................................. 49 4.................. 92 4................................................................................... 78 4........68 NINT . 79 4...............................................................................19 Continuation (&) ...................................................................................................... 69 4...................................................................................................46 IMPLC ................................................................................50 INT 79 4... 56 4............................................................................ 77 4...........................................33 DO 65 4.......................................................................................................................................................................................................................................................................................................................................................... 82 4................................................... 74 4.........................................................61 MACRO ....31 DIMENSION .........................20 CONTINUE ............47 IMPVC .........................................63 MAXTERVAL....................... 71 4...................................... 53 4............................56 LIMINT..........................................................35 DYNAMIC........................57 LOG 86 4..................................................................................................................................................................................................................................................................................................... IF-THEN-ELSE .................................................................................................................................. RSW . 69 4................ 66 4........................................................................................................................................................... 48 4...........................................................41 GAUSS........................ 88 4.....................................................................................15....................... 92 4.................................................... 65 4.............................................................................................................65 MIN 91 4....................................... 81 4....................................................................................................................................................................32 DISCRETE ...28 DERIVATIVE............................................................................................................................................ 61 4........................................................................55 LEDLAG ..............................60 LSW..................... 76 4............66 MINTERVAL............................................................................................................................ 52 4.................................................................................................... 53 4.............................................................................23 DBLINT.......64 MERROR........................................................45 IF............................. 48 4... 46 4.................................................................................................................... 56 4.............................. 58 4....................................................................................................................67 MOD ............................................39 FCNSW ...........4 Bound on integration step....48 INCLUDE ...........................................................................18 CONSTANT .....................44 HISTORY ...................................25 DELAY............................................

................................................ 104 4................................105XERROR ..1..........................................7 Macro definitions ...........................92 SORT ...................................................................................83 SAVE........................................................................................................................ 116 4......1.............................................................................................................................. 115 4..1..............................................................................................................................................................................................................................................................78 REAL ...............................................................................................................................................................................................................93 SQRT ..............................................................................................................................1 Macro versus subroutine ......................8 Macro definition header ......................................................................................................................................71 PARAMETER.................................................. 132 5.................................................................................................................. 105 4................................70 OU 94 4......................97 TERMINAL ............................87 SCHEDULE State Event Specification .............................................. 109 4..................................................................... 130 4...............................1. 104 4......................................... 136 5..........................................................................95 TABLE ......................... DISCRETE............................................. 133 5....................................................103UNIFI .........81 RSW ..................................9 First form............................6 INITIAL............................................................... and TERMINAL sections ............. 124 4.......................13 Macro directive statements.......................................................................................................................................................................................................................................................................89 Separator (. 137 5...............................................................................................................................84 SCALE.................................................. 133 5..........76 QNTZR..........................104VARIABLE.......................................................1.........82 RTP 104 4....................................................................................................85 SCHEDULE................ 101 4.. 132 5.......86 SCHEDULE Time Event Specification..........1..............................................................1................................. 134 5........................................ 115 4.......1.............................................................. 130 4................................................4...........3 Features....................17 MACRO CONTINUE ........ 130 Chapter 5 Macro Language................................. 135 5............................................101Type 128 4................................ 130 4.......1............................... 138 Language Reference Manual iv ...... 134 5........................................................................... 102 4............................................................. DYNAMIC......................................88 SCHEDULE State Event Mechanization......... 131 5.........................98 TERMT ................ 105 4...1................................102UNIF ................. 111 4..........................1...... 123 4....................................... 96 4..............................................................94 STEP ..................................................131 5....................................................77 RAMP ................... 102 4..................................................1.........1................................................11 Substitutable symbols........... 111 4............................96 TAN 122 4.....73 PROGRAM..........................................................................................1.................... 101 4................. 132 5........................................... 136 5.....................................................................................................................................................1 Introduction .... 122 4.........................................................2 Macro definitions ..........................................................................................................................12 Concatenation...................................................... 126 4.................................................................................................................. 119 4...............................................................................................90 SIGN...................................................................................... 118 4..................................................................1..........................................74 PTR 99 4.......................................................................................................4 Forms of call ....99 TRAN...................100TRANZ .79 REALPL ....................................................... 135 5......................................................80 RESET ............................... 134 5............1. 103 4.......................................5 Concatenation..............................................15 MACRO ASSIGN.......14 Labels ......1............................................................................................................................................................ 116 4............................................................................................................91 SIN 115 4.......16 Arithmetic macro directives ... 100 4... 137 5............................................................................................................................ 131 5............72 PROCEDURAL .............................................................. 131 5...........................................................................................................................................10 Second form ............................................................................................................................................................................................... 97 4.................) ............................................................................................................. 99 4...................................75 PULSE....

..........1..............................................4 6..............20 MACRO EXIT .......................26 MACRO REDEFINE ...............................................4 REDEFINE..................2..............................................2 6.......................................................................................................................2..........2 Dot product ............ 142 5........................19 MACRO DIVIDE ...............................................................1 6.....2..................... 145 5..............1......................................................................................................... 145 5.............................................2..................................................................................1............................ 155 Linear Operations......................................................23 MACRO INCREMENT ............................................................1........ 140 5....................... 147 5................................................................... 143 5........................................................................................................................................... 145 5............. 144 5....................24 MACRO MULTIPLY................................................... 139 5.........................................................3 Argument substitution............................................3............2...................................................................................................... 157 Math Operations........................................15 Advantages of concatenation .................................................................................11 Invocation .....................3 Second type..........................................................................12 Expansion ................................................ 146 5.....................1.........................................................5 6........................................................................................................2....3 Macro invocation ...........2..................................................................................18 Dimensions ......................................................................................................................7 6.........................................2 Standalone forms ...................................................................... 140 5.................................2..........................................3.....1............ 149 5................................................................................................................... 143 5.....................................................................................................................................................................................6 MACRO IF .................................................2............................................................................................................................................................................................................................................................................................................................................................... 146 5....................................................... 141 5........................................................17 Matrix multiply macro........2..................... 147 5...............................7 Expansion ..................................................................................................................... 153 Controls Operations ................ 154 Filters Operations.................... 164 Appendix A General Purpose Utilities.............13 Constants and variables .......................................................................... 146 5...................................................................... 150 5.........1.......................................... 150 5...................................................................8 Pressure tank................................. 163 Trigonometry Operations ...................... 140 5.............................. 145 5.............................2...........................10 Definition................. 149 5.................................................................................................. 142 5.........................2.... 143 5.........166 Language Reference Manual v ......3 6.....................................1..........................................2...........4 Use of parentheses ............... 159 Nonlinear Operations ................................................................................................5 Dimensions ....................2................................................................................ 138 5......... 138 5...................1.....................................................2...........9 Boolean ....................................... 144 5..........................................1 Sampler ................ 146 5.............14 Alternative form ........................................................1 Single output.............................................................21 MACRO GO TO......... 147 5................22 MACRO IF .........................25 MACRO PRINT.................................................2....................................................................................152 6...........................5....................18 MACRO DECREMENT ......................................................................................... 139 5................................ 138 5. 161 Sources Operations ............19 Invocation .............................................................................................................. 150 Chapter 6 Standard Block Libraries .......9 Concatenation............................6 6.....................................16 Matrix operations .........................................2.........2 Macro examples......................................................... 145 5...........8 6.....................................................................1................27 MACRO RELABEL ............................................ 139 5............................................3............................................................1............ 140 5...........2..........3..........................................2........ 160 Plots Operations.......... 143 5.......................................................28 MACRO STANDVAL ....................................................

The acslX text code editor window can be used to build.2 The Model Editor Windows With acslX the user has the choice to describe models in textual or graphical form. nonlinear differential equations and/or transfer functions. edit.1 Simulation Language The simulation of physical systems is a standard analysis method used to evaluate designs prior to actual construction. Users can derive code for the simulation model from block diagrams. mathematical equations. vehicle handling. microprocessor controllers. etc. Figure 1-1: acslX code window Language Reference Manual 6 . acslX provides a simple method of modeling systems described by time-dependent. 1. fluid flow. Typical continuous simulation applications include control system design. missile and aircraft simulation.csl file as well as other text files used within the acslX system. power plant dynamics. and heat transfer analysis. conventional C/C++ or Fortran statements. or display a . chemical process representation. biomedical systems.Chapter 1 Introduction 1.

place the cursor at the end of the previous line. then press Enter. To copy/paste text. click the left mouse button to highlight the line. then click and hold the left mouse button while dragging the text to the new position. For creating block diagrams the block diagram window and the schematic editor is used. To add a line. place the cursor at the location where the text should be and start typing. Place the cursor where the text needs to be pasted. Press Ctrl-C or right-click and select Copy from the pop-up menu. place the mouse cursor just to the left of the line. To drag-and drop text. • • • • To delete a line. Press Ctrl-V or right-click and select Paste from the pop-up menu. then press Delete. Figure 1-2: acslX Block Diagram Window Language Reference Manual 7 .There are a few commands that are essential for work with the text editor. select the text. and when an arrow appears. • • • • • Select the text to be copied. To add text. acslX allows you to describe models using graphical block diagrams as well.

At this point. Simulation Execution Simulation Control Commands: simulation control commands.4 Language features Working from an equation description of the problem. for example. Language Reference Manual 8 . The sorting of the continuous model equations is a feature of acslX. which contains a slightly modified version of CSL code. look at the results. Plotting flexibility is provided by using a number of external forcing functions. the compiled simulation can be run using one of the following methods: • • • interactively at the command prompt of the command window (“>”) by executing a runtime file by selecting a toolbar or menu item which results in execution of the simulation 1. Model Translation Model Translation takes place in two steps.dll) file. Additional toolkit libraries are available for certain application areas and users can build their own block libraries. can be submitted in runtime files (so-called M-Files) or entered interactively.A block can be a compound block. trying different spring constants or actuator limits. By default.3 Building Process Once the process of defining and representing a model using either the graphical block diagrams or a CSL model is completed the program is ready for the acslX translators. or a PowerBlock. 1. all calculations are double-precision. Interactively you can run the simulation. backlash. The second stage translation converts the XML to the desired target language. which again is build from connected blocks. and quantization are included. which exercise the model. Many simulation-oriented operators such as variable time delay. and change constants to experiment with the model. acslX statements are written to describe the proposed system. dead zone. Model Compilation During this stage the model code is compiled and linked to create the model executable (. The elements of the standard block libraries are described in Chapter 6. in contrast to general purpose programming languages such as C/C++ Fortran where program execution depends on statement order. acslX is delivered with a large set of standard block libraries. either C/C++ or FORTRAN. In first stage translation the model representation is converted to XML.

UNIF (uniform random number). Expressing this equation in terms of the highest derivative.4. etc. The functions. The MACRO capability allows extension of the special acslX statements. differential operators must be changed into integration operators by expressing the highest derivative of a variable in terms of lower derivatives and other variables. library functions are available. This is written in the form: r = INTEG(x. a set of special acslX statements. xic) In general. this process transforms the original set of differential equations to a set of first order equations which can be solved directly by integrating. 1. describes the available function blocks for block diagram programs.The language consists of a set of arithmetic operators. listed in Chapter 4.2 Integration Integration is a special acslX operator that is called by either INTEG (scalar) or INTVC (vector). Since x appears on the right hand side. either at the system level for each installation. relational. and logical operators are described in Chapter 2.1 Operators and functions The arithmetic. consider the spring dashpot system excited by a given function of time F(t). MOD (modulus).. For example.3 INTEG operator & & This derivative can then be integrated once for x and again for x. or for each individual user. SQRT (square root). and a MACRO capability. The two integrations can be written in the program as: xd = INTEG(F(T) . e. In general form.4. && x &&( t ) = F( t ) − 2 ⋅ ζ ⋅ ω ⋅ x( t ) − ω 2 ⋅ x( t ) & x 1. standard functions. it must be given a name (xd). xdic) x = INTEG(xd. 1. rzero) which implies: T r = rzero + ∫ x ⋅ dt 0 This integration operator is the heart of the simulation system. this is: &&( t ) + 2 ⋅ ζ ⋅ ω ⋅ x( t ) + ω 2 ⋅ x( t ) = F( t ) & x where ω is the natural frequency and ζ the damping ratio. Language Reference Manual 9 .w**2*x. In building any model.4. etc. In addition.2*ze*w*xd . consist of special acslX operators such as QNTZR (quantization).g.

xdic) .r2)/SQRT(r2). xic) In these two equations.2*ze*w*INTEG(xdd. but two are integrations of XDD with the same initial condition.w**2*x Now x is the second integral of xdd and can be calculated as follows: x = INTEG(INTEG(xdd. `Time Limit') (8) END (9) output t x y (10) start Language Reference Manual 10 . it does not represent the complete problem statement. xdd = F(T) . yz = 0.5 .0 (3) CINTERVAL cint = 0.r2)/SQRT(r2).r2)/SQRT(r2).2 (4) r2 = x**2 + y**2 (5) x = INTEG( y + x*(1. yz) (7) TERMT(t . we will outline a simple example using arithmetic operators and the SQRT and INTEG functions.4.e.4. the reference to x (xd) could have been avoided by calculating && (xdd) directly and embedding an INTEG operator in the x expression. 0.tf = 4. 0. xdic).. 5 & y = −x + y ⋅ (1 − x 2 − y 2 ) x2 + y2 .0) While this series of statements completely describes the equations to be solved. tf. 1. i. x( 0 ) = 0 .0 . y( 0 ) = 0 .5) y = INTEG(-x + y*(1. In the above sequence.1. The following listing shows the complete running program including the runtime commands. xz) (6) y = INTEG(-x + y*(1.5 Limit cycle example To introduce the process of coding a model.4 Redundant state variables Be careful to avoid introducing redundant state variables in the transformation & process. (1) DERIVATIVE ! limit cycle (2) CONSTANT xz = 0. One is redundant and can be eliminated by explicitly naming the first derivative as shown previously.0 . The following equations define a limit cycle: & x=y+ x ⋅ (1 − x 2 − y 2 ) x2 + y2 . 0 The equations are coded as follows: r2 = x**2 + y**2 x = INTEG(y + x*(1.ge.0 .0-r2)/SQRT(r2).0 . there are three INTEG operators (each one a state variable).

(1) A DERIVATIVE statement defines the beginning of the program.5 Coding procedure When writing acslX models it is useful to follow some rules in placing statements to make programs easier to read. to document how the program should run.7 (13) start Figure 1-3: Limit cycle example of model code and runtime commands NOTE: Statements are numbered for reference. Language Reference Manual 11 . The $ character may also be used in place of the semicolon to delimit statements. (2) It is better to use a symbol set to the value instead of literal constants (e. which gives more detailed explanations and shows examples of results and plots. (7) The TERMT statement specifies the termination condition. (3) The CINTERVAL operator specifies the communication interval (data logging rate). (12) Changes the initial condition.5).5.g.1 Separator More than one statement can be placed on one line by separating the statements with a semicolon (.. (9) OUTPUT defines the variables to be listed on the screen at each communication interval as the run progresses. and the stop time TF are preset in the CONSTANT statement. Changes then occur in one place in the program.4.). (11) Comment. The whole example is described in more details in the Examples Manual. This END statement tells the translator that no more acslX statements are expected.6 Runtime commands NOTE: (9) through (13) of Figure 1-3 are examples of runtime statements of the analysis language (also known as M-Languange). (8) The END statement matches the DERIVATIVE statement and completes the program definition.(11) % Change initial conditions and run again (12) XZ=0. 1. (13) Runs the model again. So X(0) and Y(0). 1. 1. (10) The model is then executed by the command start. and values can also be changed at runtime. 0.

1. 1. Starting with column 1.g.5. defining MAXT as a state variable) could cause conflicts. where n is any digit and a is any alphanumeric character. Language Reference Manual 12 . NOTE: Other uses of these names (e. Trailing blanks are removed from the line containing the ampersand and the following line is added directly. with the limitation that the double-quoted comment may not be inside of a parenthesized expression (due to the ambiguity cause by quoted arguments to macros). Incorrect use of double-quote comment: C = C1*exp(-A1*t “exponential decay”).6 Reserved names The only reserved names in the language are those of the form Znnnnn and ZZaaaa. 1. the default names exist so they can be set by program control in the model definition section.g.2 Continuation Any statement can be continued on the next line by adding an ampersand (&) at the end of the line. An empty line needs two ampersands because a single one can't be distinguished. it is as though the characters were strung on the end after the last nonblank character of the preceding line.1. defining MAXT as a state variable).1 System variable defaults System variable default names are listed in Figure 1-4. 1.5. to the right of any nonblank information. using names that have already a meaning could always cause problems (e. These default names can be changed to any name.4 Blank lines Blank lines can be placed anywhere in the program and have no effect. Example: Correct use of double-quote comment: “Linear acceleration:” accel = F/M “MKS Units”. In-line comments may be specified by placing the comment text between double quotes.. but if names are not specified.5.6. All generated variables and system subroutine names are in this form. Comments can be added after the trailing ampersand since comments are stripped off first.. However. Leading blanks of the continuation line are not suppressed unless a leading ampersand is present on the continuation line.3 Comments Everything after an exclamation point (!) is considered a comment and ignored by the program translator and the runtime executive (in runtime commands).

1.6. Language Reference Manual 13 . the system searches first in the dictionary of acslX system symbols.2 Precedence of names When using a symbol name at the command prompt.0E-10 0.1 .Statement ALGORITHM CINTERVAL ERRTAG MINTERVAL VARIABLE Default name Default value Definition IALG CINT none MINT T 5 0.FALSE.0 Integration algorithm Communication interval Error flag Maximum calculation interval Minimum calculation interval Independent variable MAXTERVAL MAXT Figure 1-4: System Variable Defaults 1.0E+10 1. Generally duplicating system symbol names within the program interferes with the ability to modify system default values. However. it takes precedence over the acslX system symbol. if a system symbol is used as a name in the program.

Chapter 2

2.1 Introduction

• •

Language Elements

The following outline the major points of the acslX language. . Coding - Free format in program lines, only restricted by the underlying compiler. Labels - Labels can be alphanumeric. Labels are separated from the their statements by a colon; i.e., label: statement. Due to conflicts with macro expansions within labeled statements, labels should only be used with CONTINUE statements. See the section on labels. Variable names - Name length is limited by the target language compiler. Names should not be of the form Znnnnn or ZZaaaa where n is any number and a is any alphanumeric character. Blanks are not allowed within names. Types - All variables and functions are considered floating point (single or double precision depending on the library specified) unless typed explicitly otherwise. Continuation - An ampersand (&) at the end of a line indicates continuation onto the next line. Comments - An exclamation point (!) indicates a comment. acslX ignores all code from an exclamation point to the end of the line.

• • • •

2.2 Constants

Constants may be integer, floating point (double precision), logical, or character. It is better to assign constants to variable names (see section 2.3). Literal constants can be used in the source code, but their values can not be changed at runtime. To change a literal constant, all occurrences in the source code must be changed and the program retranslated, compiled, and linked. It is better to give all constants symbolic names using CONSTANT statements; i.e., rather than

area = 3.142*r**2

**the following code is preferred
**

CONSTANT pi = 3.142 area = pi*r**2

2.2.1

Integer

An integer constant is a whole number, written without a decimal point, exponent, or embedded blanks. Positive numbers may be prefixed with a plus sign; negative numbers must be prefixed with a minus sign. The maximum length of an integer is machine dependent. Subscripts of arrays are generally limited to five digits. Examples of integer constants include:

0 +526 -63 476

Language Reference Manual

14

2.2.2

Promotion of integers

A number without a decimal point (1 instead of 1.0) can normally be used where a floating point number is expected. The number is converted to floating point before it is used. However, a decimal point (or a variable name) should be used in arguments to functions, macros, or subroutines.

2.2.3

Floating point

A floating point constant is written with a decimal point and/or an exponent. Positive numbers may be prefixed with a plus sign; negative numbers must be prefixed with a minus sign. The exponential form is D for double precision. Examples of floating point constants include:

3.1416 0.000345 31.416D-1 0.347D03 7.9566314D-4 -27.6D+220 3D1

Numbers entered with a decimal point and no exponent (e.g., 1.234) are given a double precision exponent of D0 (e.g., 1.234D0) when the global double precision translator option is selected. Numbers in expressions such as:

x = y*1.234

are handled by the compiler; i.e., the constant 1.234 is automatically promoted to double precision if y is double precision. However, since 1.234 is not an exact binary number, it is not as precise as 1.234D0. This promotion feature is primarily used in arguments to subroutines where it is impossible for the compiler to determine the precision of the subroutine argument when used inside the routine. Use care when mixing integers and floating point numbers in subroutine arguments because the type may change. For example:

CALL mysub(1, 1.234)

must have arguments that are an INTEGER and a REAL. To prevent a mismatch in this situation, use the exponent form or one of the type conversion functions DBLE or REAL. REAL(1.234) is always single precision, and DBLE(1.234) and 1.234D0 are always double precision, but 1.234E0 is changed to 1.234D0. To ensure that the second argument is always single precision use the form:

CALL mysub(1, REAL(1.234))

2.2.4

Logical

Logical constants may be one of two values.

.TRUE. .FALSE.

However, when logicals are plotted in acslX, zero corresponds to .FALSE. and one to .TRUE.

Language Reference Manual

15

2.2.5

Character

Character constants are strings of letters, numbers, and other characters and are defined by placing them in single quotes. Single quotes can be inserted by doubling them; for example, to define a string abc'def, use

`abc''def' SET TITLE = `Limit Cycle, Run1’

2.3 Variables

Variable names are symbolic representations, usually for numerical quantities, that may or may not change during a simulation run. They refer to a location and the value is equal to the current number stored in that location. Both simple and subscripted variables may be used. Generally, variable name must start with a letter and be followed by up to thirty letters and digits, but this is limited only by the target language compiler. Underscores can be included in variable names to make them more readable.

this_long_name = INTEG(motor_velocity, init_cont)

2.3.1

Types

There are four types of variables: INTEGER, REAL, CHARACTER or LOGICAL. All acslX program variables are assumed to be DOUBLEPRECISION (single or double precision, depending on the library specified) unless explicitly typed otherwise. Type REAL specifies single precision. only; Examples of simple variables include:

a a57 ab57 d k20

2.3.2

Subscripts

A subscripted variable may have up to six subscripts enclosed in parentheses. Subscripts can be expressions in which the operands are simple integer variables and integer constants, and the operators are addition, subtraction, multiplication, and division only. For more information on storage allocation, see DIMENSION. Examples of subscripted variable names include:

b(5,2) c47(3) b53(5*i + 2, 6, 7*k + 3) array(2) plate(2,2,3,3,2,2)

In the above examples, I and K must be declared explicitly to be INTEGER variables.

2.3.3

Array order

Elements of arrays are written and accessed by column, then row; for example, the elements of b(2,5)can be shown:

11 12 13 14 15 21 22 23 24 25

Language Reference Manual

16

4. followed by the labeled statement. label: x = GAUSS(mean. the order is: 11 21 12 22 13 23 14 24 15 25 2. label: CONTINUE x = GAUSS(mean..Extracted as a single-dimensioned vector. Z09999 = MEAN + GRV(ZZSEED)*(SIGMA) 99996 X = Z09999 With the macro call in a labeled statement. if a CONTINUE is used at the labeled statement as follows: GO TO label .. 2. the effect of a macro call inside a statement is that the macro is expanded first. the intermediate variable Z09999 is not assigned a value when the GO TO transition is executed.. sigma) This expands to the Fortran code: GO TO 99996 .e. acslX uses labels starting at 99999 and working downwards. which is a macro. L1: CONTINUE x = a + b 1000: y = c + d GO TO L1 2. therefore avoid labels with high numeric values to avoid possible conflicts.4.4 Labels A label can be attached to a statement so that control is transferred to it by GOTO statement.. For example.1 Syntax A label is set off from the statement to which it applies by a colon (:). However. Labels are alphanumeric.. It could be used in a labeled statement in a PROCEDURAL as follows: GO TO label . only CONTINUE statements are recommended.2 Statement labels and macro expansion Although statement labels can be attached to any executable statements. consider the random number generator GAUSS. sigma) The code expands into the correct sequence as follows: Language Reference Manual 17 . The difficulty is that the labeled statement may be translated into several statements. i. as in this example...

and logical operators... when evaluated. since the label must be the last operation of the loop (statements after the labeled statement are not in the loop).1 Arithmetic operators The arithmetic operators are: + * / ** addition subtraction multiplication division exponentiation Two arithmetic operators can not appear next to each other in an arithmetic expression. IF (condition) GO TO label 2. If minus is to be used to indicate a negative operand.. the sign and the element must be enclosed in parentheses if preceded by an operator. DO label i = 1. but the following is not: b*a/-c 2. produces a single numerical value. 2. b*a/(-c) -a*b ..GO TO 99996 .3 CONTINUE statements Attaching the LABEL to the first line of the code generated from the macro can work. but they cannot be used to indicate multiplication.4. Expressions may contain arithmetic. 20 . Language Reference Manual 18 . Even if acslX differentiates between the DO loop labels.5.5 Expressions An expression is a combination of operators and operands which.g.. e.g. the language allows a loop with direct GO TOs to the terminating statement label.2 Parentheses Parentheses can be used to indicate groupings as in ordinary mathematical notation.5.c a*(-c) are all valid. However. 99996 CONTINUE Z09999 = MEAN + GRV(ZZSEED)*(SIGMA) X = Z09999 2.. e. DO loops become a problem. relational.

4 Relational operators The relational operators. assuming that the integer is promoted to floating point) sometimes gives incorrect results.LT. variables (simple or subscripted).GE. .NOT.EQ. The following guidelines apply: 1/2 1/2. the results of which can be only TRUE or FALSE.76 -(c + del*aero) 3 + 16. or functions.5 Logical operators .OR.e.2. otherwise.EQV.0/pi zero correct ANSI standard forbids changing I/J/R to a supposedly equivalent I/(J*R).NEQV.3 Warning .5.GT.5. the first calculation results in zero. the value is FALSE . the value is FALSE .6 Operands Operands may be constants. equal to not equal to greater than less than greater than or equal to less than or equal to 2. . .5. the value is FALSE 2. otherwise.5. but specifying the 2 in floating point gives the correct result: x = 1/2/pi x = 1/2.0 1/(2*pi) 1/pi/2 integer zero floated to floating point okay okay 2. combines two logical expressions to give the value TRUE when both are TRUE. reverses the truth of the logical expression that follows it .AND. For example.NE. .LE. combines two logical expressions to give the value TRUE when they are equivalent. are: . combines two logical expressions to give the value of TRUE when they are not equivalent and FALSE when they are equivalent. otherwise. .5 Language Reference Manual 19 . .. combines two logical expressions to give the value TRUE when either is TRUE. Examples of arithmetic expressions include: a 5.dividing by integer Dividing by an integer (i.

y) & . Examples of valid relational expressions include: a . and lfunc have been declared to be of type LOGICAL.SQRT(a**2 + x**2))/2.b + a(5)/2. 0. The general form of the logical expression is: l1 op l2 op 13 op ln where li are logical operands or relational expressions.NOT. aa NOTE: The symbolic names aa. cc . ASCII is almost universal.AND. Character expressions Character constants and variables can be joined together by the // operator. A relational operator must have two operands combined with one operator. lfunc(x. The relational expression will have the value TRUE or FALSE depending on whether the stated relation is valid or not.AND.OR.GE.EQ. for example: name = first//last//CHAR(period) Language Reference Manual 20 .0 Relational expressions Relational expressions are a combination of two arithmetic expressions with a relational operator. (4.75 b . b a57 . (b . y) .0 . will have a value of TRUE or FALSE. c2. Substrings of characters can be selected by a colon (:) operator. and c3 are character variables.0 a + d . (x .0*b . when evaluated. lfunc aa . a substring may not be of zero length.OR. Examples are: LOGICAL aa. The general form of the relational expression is: a1 op a2 where ai are arithmetic expressions and op is a relational operator.0) .GT.3 5. cc.c) Logical expressions Logical expressions are combinations of logical operands and/or logical operators which.. A character variable may not appear on both the left and right hand side of the same statement. 5.3. c) . Mapping for the CHAR function depends on the character code used by the compiler.LE. For example: c1 = c2(5:10)//c3 where c1.LE. cc. and lfunc is a function with a TRUE or FALSE result calculated from the value of the variables x and y.AND.LT. Integers can be converted to characters through the CHAR function.

an arbitrary depth of complexity can be generated.COS(a + z/SIN(5.3*c) & c*y/SIN(SIN(x + y)*pi))) The sole requirement for an expression is that it have only one value when evaluated numerically. be expressions. Using the SIN and COS function as an example. Since expressions can contain functions. Language Reference Manual 21 . the following is a valid expression: a + SIN(x*COS(5*x + y) . in general.Single characters can be converted to integer (in the opposite direction to CHAR) by the ICHAR function. Expressions in functions Arguments of functions may.

The order of the sections must be as shown. the model is said to have implicit structure: i. and each section must be terminated with its own END statement. especially in handling initial conditions. it is implied that the whole program is a DERIVATIVE section. any or all of the five explicit blocks may be included. END !of Terminal Section END !of Model Figure 3-1: Outline of Explicitly Structured Program 3. If this method is chosen. This simple structure has limitations. PROGRAM INITIAL Statements executed before the run beings.1 Implicit and explicit structure When an acslX simulation model contains only PROGRAM and END statements to outline the model structure. A program is activated with a runtime start command Language Reference Manual 22 .2 Program flow Figure 3-1 outlines the flow of an acslX program with explicit structure. DERIVATIVE Statements to be integrated continuously. The more flexible explicit structure includes INITIAL. END !OF Discrete Section END !of Dynamic Section TERMINAL Statements executed after the run terminates. and TERMINAL sections. State variables do not contain the initial conditions yet. END !of Derivative Section DISCRETE Statements executed at discrete points in time. DYNAMIC (with embedded DERIVATIVE and DISCRETE).Chapter 3 Program Structure 3. as shown in Figure 3-1. END !of Initial Section DYNAMIC Statements executed each communication interval.e..

Initial condition values are moved to the state variables (outputs of integrators) at the end of the INITIAL section.2. Usually some Language Reference Manual 23 .Figure 3-2: Main Program Loop of acslX Model 3. the section for calculations performed once before the dynamic model begins.1 INITIAL The program proceeds sequentially through the INITIAL section. but not all initial conditions will have been defined.

On the other hand. if any TERMT statements are included in the DYNAMIC block. the STOP flag is reset and the program executes the code within the DYNAMIC block. The integration routine returns with the states advanced through the communication interval and again the STOP flag is tested. There are no restrictions on the variables that can be referred to in this DYNAMIC section. the initialization procedure involves transferring all initial condition values into the corresponding states and evaluating the code in the DERIVATIVE and DISCRETE sections once. control is transferred at this check when one of the arguments of TERMT becomes true. 3. 3.2. Any variables that do not change their values during a run can be computed in INITIAL. the flag Language Reference Manual 24 . If the STOP flag has not been set. the STOP flag is tested. 3.2.3 DYNAMIC After initialization and evaluation of the DERIVATIVE and DISCRETE code.2 DERIVATIVE DISCRETE The integration routine is initialized when control transfers out of the INITIAL section.initial conditions are calculated at this point. they are not executable and can be placed anywhere in the program. and intermediate calculations in the DERIVATIVE and DISCRETE sections have been executed. The STOP flag is set by the TERMT statement. the program writes out the values of all the variables specified in the output and prepare lists.2. 3. NOTE: It may appear from the program listing that the DYNAMIC section is executed before the DERIVATIVE section. if the flag has been set.2. in fact. To ensure that all calculated variables are known before recording the first data point. DERIVATIVE and DISCRETE are evaluated first and should not rely on calculations in the DYNAMIC section to initialize variables for DERIVATIVE or DISCRETE sections. CONSTANT statements are not required to be placed in the INITIAL section. However.5 Integration The integration routine is now asked to integrate over a communication interval (or until a termination condition is met) using the code embedded in the DERIVATIVE blocks to evaluate the state variable derivatives. control is transferred to the TERMINAL region.4 STOP flag After the DYNAMIC section has been evaluated. At this point. all values calculated in the DERIVATIVE and DISCRETE sections are available in the DYNAMIC section. the latter to a scratch file for later plotting and/or printing. All the states have values. the former to the output file or terminal.

7 TERMINAL Program control transfers to the TERMINAL section when the STOP flag has been set TRUE. the last output is not written out unless the LOGD operator is used (see Chapter 4). sorting takes place only on the left hand or output variable so that the block is positioned before any use of the variable. Control cannot be transferred either into or out of DERIVATIVE or DISCRETE sections since these are changed into a separate subroutine and. never across sections. On passing out of the last END. if needed. none of the variables on the input variable list have their calculated flags set (meaning that the variable has already been calculated). which reads and processes any further runtime commands (PLOT. control returns to the acslX executive. the statement is added to the output statement list and the calculated flag for the output variable (or variables) is turned off. are inaccessible to the main program loop. so also is transfer between INITIAL and TERMINAL blocks. PROCEDURAL sections are sorted as a unit based on the declared inputs and outputs. The sort algorithm is relatively simple and consists of two passes. Pass number two-examines the list of statements one at a time. if not. output variables are marked as calculated and an input variable list consisting of all variables on the right of the equal sign is established for the statement. It is illegal to transfer into the DYNAMIC region. If. • Pass number one-examines each statement. for a particular statement. and no sorting is performed within the PROCEDURAL. as such. Transfer from the dynamic region to either INITIAL or TERMINAL is quite acceptable. If any statement has been added to the output statement list. etc. 3. In this case.2.2.6 Transfer control Control can be transferred between some sections using GO TO statements and statement labels.3 Program sorting The acslX translator sorts the code in the DERIVATIVE section so that outputs are calculated before they are used. since the integration initialization then could not be performed correctly. all the saved statements are re-examined to see if they can now be added to the output • Language Reference Manual 25 . the statement is placed in a temporary "saved" list and the next statement examined. Sorting takes place only within sections. DISPLAY. 3. A variable name may appear simultaneously on both left and right hand sides of an equal sign in either an assignment statement or PROCEDURAL header. If any variables on the input variable list are marked calculated.). Note that if a jump (GO TO) sends control from the TERMINAL section back to the INITIAL.may have been set by a TERMT statement in a DERIVATIVE or DISCRETE section. Normal statements are sorted individually. the program loops and re-executes the DYNAMIC section. 3.

PROCEDURALs.3.4 Program Structure Preset of User Variables 3. This is considered an error since true algebraic loops should be broken by calculations. 3. 3. 3. thought it is recommended that constants be defined prior to their frst use. Second. The translator appends each INITIAL section to the end of any collected previously (to a default null INITIAL if there is no explicit user INITIAL before the DYNAMIC or DERIVATIVE). d) a = c b = d END ! of procedural d = a causes an algebraic loop to be reported since it implies that a is a function of both c and d. Use PROCEDURALs sparingly and with care. first check the PROCEDURALs for errors. This algorithm works because any output variables that have already been processed have their calculated flags reset. Only output variables appearing later in the program are flagged and as such can hold up statements that depend on these outputs. 3.1 Algebraic loops Algebraic loops are identified during translation by the fact that statements are left over at the end of the DERIVATIVE section sort.statement list and their output variables reset. Using many small PROCEDURALs is better than using a few large ones.2 Diagnosing loops When an algebraic loop is diagnosed.2 CONSTANT For code readability. TERMINAL sections are collected as the Language Reference Manual 26 . although this is not actually the case. States are calculated by the integration routine before all derivative evaluations. or the implicit integrators IMPLC (scalars) or IMPVC (vectors).1 States State variables are not flagged as calculated. Similarly.4. the following code: PROCEDURAL (a. b = c. 3. DYNAMIC. CONSTANT statements may be placed where they are used.3.4.3 Multiple INITIAL. Most algebraic loops are errors caused by incorrect PROCEDURAL headers or missing state equations. For example. and TERMINAL sections INITIAL sections and TERMINAL sections can be placed anywhere in a program. check for a modelling error such as a missing state in a control loop.4.

4.5555E33. to any level of nesting. DISCRETE. the executive checks that all derivatives have changed from the preset value. integers to 55555333. INTVC. or TERMINAL) can be nested within any other section. Setting all user variables to a large number aids in identifying uncalculated variables in the first debugging runs.001). Language Reference Manual 27 . in a DERIVATIVE section. one can write: SCHEDULE burnout .translator sorts through the program. occur before the code in an explicit final TERMINAL section. an error message is produced: DERIVATIVE NO. Thus.AT. n NOT CALCULATED This message usually indicates that a derivative calculation has been skipped or that a derivative is specified with a CONSTANT statement.6 Preset of derivatives The acslX executive presets all derivatives and residuals (as defined in INTEG.33333333E-33. DERIVATIVE. acceleration DISCRETE burnout INITIAL. and logicals to . For example. for example.050. After the initial evaluation of the DERIVATIVE section. DYNAMIC.XN. t + dt END ! of burnout 3.FALSE. 0. particularly where a value of zero would allow the program to proceed when it should not. END SCHEDULE separation . any TERMINAL sections defined in a DERIVATIVE section. which is not executable. if not.4 Section nesting Any section (INITIAL. NOTE: When variables are not calculated before being used and where more than one start is executed in a runtime session. 3. dt = GAUSS(0. Determine which derivative is referenced in the message by checking a DEBUG dump or DISPLAY/ALL and counting down the list of derivatives.5 Preset of user variables The acslX executive presets all floating point variables to 5. each appended to any collected previously. This helps prevent unknowingly using wrong values if the variable is used before it is calculated. 3. IMPLC. and IMPVC statements) before each start to 3. all runs after the first use values left at the end of the previous run.

Wild cards (* and ?) are available for many of the runtime commands. The form is specified as: state = INTEG(deriv. and Separator (. use ABS instead of IABS. variables) and may be replaced with any character string that satisfies the definition. AMAX1. for example. DABS. it issues the following warning message: Warning: Re-computing a constant See the section on CONSTANT in this chapter.). elements in lower case are syntactical elements (i.: The use of these characters in program code is described in this chapter under Comment (!). DMAX0. In specifying the integration operator. The ampersand (&) is also used for concatenation in macros (see Chapter 5). MAX1. INTEGER or REAL type. MAX0. 4. while the generic functions adapt to single or double precision.1 Documentation convention In the following examples and descriptions.. Continuation (&). Language Reference Manual 28 .g. Elements shown in upper case must be exactly as spelled out in the statement (although not necessarily in upper case).. ic) An example would then be in the form: x = INTEG(xd.1 Introduction acslX Statements This chapter describes in detail all the basic statements recognized by the acslX translator. automatically. using a colon (:). xic) 4.1.1.3 CONSTANT recompilation Variables defined in CONSTANT statements generally should not also be defined in assignment statements. Statement labels. The generic form of functions is recommended. If the translator encounters this situation. acslX places no restriction on column placement of the code.e. are discussed in Chapter 2.1. or DMAX1. the word INTEG must be given exactly while all the other elements are variables you name as part of the model.2 !&. e. The warning message can be suppressed. To specify a typed (non-generic) function reduces flexibility.Chapter 4 4. 4. or CABS and MAX instead of AMAX0. but are not used in program code.

4 Debugging Calls to LOGD can help debug a program when a system debugger is not available. In general.e. 4. block of statements END This code tells the translator to treat the statements bracketed by the PROCEDURAL and its matching END statement as a block (i. not to rearrange the order within the block). Constants need not appear on the list. In assignment statements.TRUE. Logical or relational expressions are used to determine switching criteria in the special functions. 4. Language Reference Manual 29 . See the PROCEDURAL section in this chapter for details on when and how to use this structure. c = d.1. that D and E are inputs. the output of each function is a single number (usually floating point) and the arguments are arithmetic expressions of arbitrary complexity. b.e. are used for logical constants. Only variables calculated elsewhere in the same DERIVATIVE section must be listed on the input list. and C are outputs. Only . e) . B. acslX needs to know the each statement's inputs and outputs so that the statement sequence can be sorted into the correct order... these expressions may contain functions which contain arguments which contain functions to any depth. See Chapter 3 for information on program flow and statement sorting.6 Equal sign in PROCEDURAL This concept of the use of equal signs is extended to the PROCEDURAL. i. and that A..1.FALSE.5 Equal sign (=) acslX uses the equal sign in an unfamiliar way. In translating a program..1.. This concept is extended to cases where more than one element is an output. all elements to the left of the equal sign are considered outputs and those to the right are considered inputs. Other logical representations may not be recognized because the bit pattern of logicals depends on the installation and compiler in use. State variables (output of state operators) must not appear on the list. i.7 Operators for simulation models This chapter includes descriptions of several functions especially designed for simulation models.1.e. all variables to the right of the equal sign are inputs. or .4. 4. which has the following possible form: PROCEDURAL(a. the variable to the left is given the single numerical value of the right hand expression and thus is the output. See LOGD in this chapter for a description of this procedure.

it is seen as an argument to the system macro. acslX operators whose names should not be used for arrays are shown below in Figure 4-2 Figure 4-2: acslX operators that should not be used for arrays 4. They also cannot be iterated in a DO loop.1. There is no problem with scalars. While they may be included in a first level PROCEDURAL block. the derivative for the state variable is usually left a non-zero value (constant while the operator is skipped) so that the internal state variable continues to change.9 Array name conflicts acslX operator macro names should not be used for arrays names because of a potential conflict. but when an array element is referenced on the right side of an equal sign.10 Standalone form of operators Some operators are defined as macros.1.8 State operators Some operators involve state variables and can be invoked only from within a DERIVATIVE section. the first order lag: Language Reference Manual 30 . these operators are always executed and cannot be successfully bypassed by jumping around them. acslX cannot check that the name is also defined as an array because the TABLE statement defines an array to hold the data and a macro of the same name for table lookup. consider the conventional use of REALPL.4. 4. Figure 4-1 is a partial list of such operators: Figure 4-1: State operators If an attempt is made to skip around any of these statements. two alternative forms of invocation (conventional and standalone) are possible. The correct method for stopping a state variable from changing is to ensure that the derivative is set to zero. For example.1. When the operator has only one output.

11 Precision of acslX operators By default. DBLE(ds1). i.y = k1*REALPL(t1. k1*x) In this case (only) the variable y is assigned to the state table. and still all forms are numerically equivalent.. x) The state variable (output of the real pole function) is given a dummy name (a Z variable). It usually helps to multiply the input rather than the output by constants (synonymous if the operator is linear) as follows: y = REALPL(t1.e. 4. one scalar double and one vector double precision arguments. Assume a subroutine MYSUB with two scalar real arguments. This standalone form is usually preferred to minimize the number of dummy variables.12 Forcing precision Forcing precision is usually necessary only if a variable is to be an argument to an external subroutine within which a particular precision is specified. CALL mysub(rs1. dv2) Then types would be specified as follows to ensure consistency within the subroutine: REAL rs1.1. k1*x) Now the input to the operator is an expression and in this form the standalone macro invocation can be used as follows: REALPL(y = t1. They are listed below in Figure 4-3 Figure 4-3: Operators that can be given in standalone form 4.1. Operators that can be given in standalone form are noted in their individual descriptions. ds1.rs2 DOUBLEPRECISION ds1.dv2(20) Another approach is to use the generic type changing functions REAL( ) and DBL( ) for the scalars. rs2. the precision of operators in acslX is DOUBLEPRECISION. Then the type has to be specified only for the vector as follows: DOUBLEPRECISION dv2(20) CALL mysub(REAL(rs1). REAL(rs2). dv2) Language Reference Manual 31 .

0. The output type (INTEGER. lies between zero and p.0 and +1. Example: cd = cdz + cdal*al + cdde*ABS(dle) 4. in radians.This is the preferred way since the actual precision of the variables RS1.2 ABS Form: y = ABS(x) Description: The output y is the absolute value of x where x is an expression. a = AINT(-3.4 AINT Form: y = AINT(x) Description: The output y is the truncation of x where x is a floating point variable or expression. Example: th = ACOS(x/r) 4. The result. the result is -3.7) Language Reference Manual 32 . In the following example.0.3 ACOS Form: y = ACOS(x) Description: The output y is the arc cosine of x where x is a floating point variable or expression lying between -1. The result type (REAL or DOUBLEPRECISION) depends on the input type. This function differs from INT where the output is type INTEGER for any type input. and DV1 is immaterial in the acslX program. RS2. 4. DOUBLEPRECISION) depends on the input type. The output type (REAL or DOUBLEPRECISION) depends on the input type. or REAL.

put an ALGORITHM statement with a unique name in the section. then it is the global default for all DERIVATIVE sections. This statement can change the system variable name and/or the choice of integration routine.) Using INT( ) in this situation doesn't work since the argument is passed with type integer. Example: DERIVATIVE ALGORITHM fastalg = 4 Language Reference Manual 33 . DISCRETE sections have their algorithm slot set automatically zero.5. If the program has more than one DERIVATIVE and/or DISCRETE section then IALG becomes an array. . the only situation where it is necessary to use AINT( ) is in the argument to a subroutine in order to force the type. The elements in IALG then correspond to the sections in the order they are encountered in the source code. Example: If the first argument of MYSUB is floating point.. If ALGORITHM is defined outside a DERIVATIVE section.1 Array with multiple sections Description: If a program contains only one DERIVATIVE section and no DISCRETE sections. but transmitted as a floating point number: CALL mysub(AINT(v1). The name IALG is the default and its value may be set numerically at runtime even if the ALGORITHM statement has not been specified in the program. ALGORITHM name (referred to by its default name IALG hereafter) is a scalar.5 ALGORITHM Form: ALGORITHM name = integer constant Default: name:IALG integer constants: 5 Description: Where name is the new name for the integer defining the runtime algorithm. the following ensures a truncated (integer) value. To change the algorithm for a specific DERIVATIVE section. 4.Since INT( ) is promoted to REAL or DOUBLE as appropriate in any expression. 4..

CINT/NSTP) H = MIN(H. The communication interval and/or integration step size can be changed. it does not look again to see if it has changed.5. 4. At runtime. time_to_next_event) CINT is divided by NSTP. if the DERIVATIVE section is first in the program.The scalar name given is equivalenced to the array element. Language Reference Manual 34 . If NSTP is 1 and MAXT is less than CINT.2 Recommended integration control Description: Figure 4-4 lists the available integration algorithms. state events or time events activated by SCHEDULE statements. After acslX determines the IALG for a run. FASTALG is equivalenced to IALG(1). Events include DISCRETE sections (usually controlled by an INTERVAL statement). then MAXT sets the integration step size and CINT affects only the data logging rate. The integration step size for fixed step algorithms is calculated by: H = MIN(MAXT. IALG(1) = 1 FASTALG = 8 NOTE: Do not change during run. we recommend setting NSTEPS (NSTP) to 1 so that you control the step size with MAXTERVAL (MAXT) and the data logging rate with the communication interval CINTERVAL (CINT). either the array element or the local name can be referenced. The choice of integration algorithm cannot be changed during a run because table space has to be allocated before the run begins. For fixed step algorithms. for example. CINT does not have to be an even multiple of MAXT since the integration steps up to it automatically. and CINT.

Euler is used for any integrations required by operators in DISCRETE sections. The Adams-Bashforth routin (IALG = 13) is a multistep method which obtains additional accuracy for a fixed number of derivative evaluations by retaining derivative evaluations from the previous step to compute updates to the states. twice at the midpoint. A weighted combination of these derivatives is then used to step across the interval. the derivative k is evaluated at the beginning. 4. and once at the end of the integration step as follows: Language Reference Manual 35 .3 Fixed step algorithms Description: The Runge-Kutta routines (IALG = 4 and 5) evaluate the derivatives at various points across a step. If x is the state.5. it should run about twice as fast. For the same step size. Optimizing the step size and algorithm is generally worth the effort. This usually needs a somewhat smaller step than Runge-Kutta fourth order (four derivative evaluations per step). Runge-Kutta second order advances the state with two derivative evaluations per step.IALG 1 2 3 4 5 8 9 13 14 15 Algorithm Adams-Moulton Gear's stiff Euler Runge-Kutta Runge-Kutta Runge-Kutta-Fehlberg Runge-Kutta-Fehlberg Adams-Bashforth ODEPACK CVODE Step variable variable fixed fixed fixed variable variable fixed variable variable Order variable variable first second fourth second fifth Second variable variable Figure 4-4: Available Integration Algorithms 4. and t is time.4 Runge-Kutta procedure Description: Figure 4-5 shows the procedure for the fourth order Runge-Kutta algorithm. h is the integration step size. Euler (IALG=3) makes just one derivative evaluation and the step size must be small compared to that of other algorithms to achieve acceptable accuracy.5.

Language Reference Manual 36 . and MERROR (discussed below for the variable step algorithms) do not affect the fixed step algorithms in any way. XERROR. making one derivative evaluation at the beginning and another at a point two-thirds across the step as follows: The new state is then weighted by one-fourth and three-fourths and calculated by: MINT.The new state is then calculated by: The second order Runge-Kutta routine follows a similar procedure.

Figure 4-5: Runge-Kutta fourth order algorithm 4.W. This desired value is obtained by taking the maximum of the corresponding absolute allowed error (XERROR) and the relative allowed error (MERROR) multiplied by the maximum absolute value of the state so far: The order of integration starts at one and then changes dynamically as the program progresses.5. NJ 1971 pp 150 et seq 4. This algorithm can also help determine an appropriate step size for fixed step runs. Gear. For more information on mechanization of the variable step. Prentice-Hall. variable order integration routines that are self-initializing. The step size also changes dynamically as the integration routine attempts to take the largest possible step consistent with the allowed error bounds.5.6 Adams-Moulton Description: Adams-Moulton is useful for models in which the step size changes significantly during a simulation. In this case. as described below. variable order integration routines. as for a satellite in a highly eccentric orbit. a much larger step size can be used when the satellite is far from the earth than when it is near. C.5 Variable step algorithms Description: The Adams-Moulton (IALG=1) and Gear's Stiff (IALG=2) are both variable step. see subroutine DIFSUB in Numerical Initial Value in Ordinary Differential Equations. In general they attempt to minimize the step changing by always choosing a step size that divides evenly into the time-to-go to the next event and keeping the per-step error in each state variable below an allowed value. Language Reference Manual 37 .

4.5.7

Gear's stiff Description: Gear's algorithm is for stiff systems that have frequencies of three or four orders of magnitude difference, where the high frequency motions are extremely active at some point (such as in a chemical reaction, explosion, etc.) and then smooth to essentially zero amplitude. The Gear's stiff algorithm is then able to take large time steps since only the low frequency motions are of interest.

Gear's stiff integration can take steps that are orders of magnitude larger than the smallest time constant in a stiff system. There is an overhead involved, however, since a linearized state transition matrix must be formed and inverted. Tests have shown that for problems where the range of time constants differs by only one or two decades, there is little benefit in using this method; Adams-Moulton is invariably faster. If the range of time constants covers more than three or four decades, then this technique may be significantly faster than any other.

4.5.8

Runge-Kutta-Fehlberg Description: The Runge-Kutta-Fehlberg algorithms (IALG = 8, 9) are fixed order but variable step. They are useful for models with a number of discontinuities, such as a system in which a spring is encountered periodically. The Adams-Moulton method uses information from previous steps to determine the size of the current step, but the Runge-Kutta-Fehlberg method starts fresh each step, thus having less difficulty with discontinuities. These routines adjust the step length to keep the error per step less than that specified by XERROR and MERROR. The relative error (MERROR) values are applied to the largest absolute value of the state so far, not the current value.

Algorithm 8 evaluates the derivative three times per step and makes a second order state advance; algorithm 9 evaluates the derivative six times and makes a fifth order state advance. If any error in a state is larger than that allowed, the step size is reduced (by no more than 0.1 at a time) until the error criteria are satisfied for all states or the minimum step size (MINT) is reached. After a successful step, the new step size is set to be 0.8 (for IALG = 8) or 0.9 (for IALG = 9) of a step size which would result in the maximum allowable error (as calculated during the previous step), except that the new step size is not less than the previous successful one. The lower order algorithm (IALG = 8) is recommended for most applications because it usually uses less computer time.

Language Reference Manual

38

4.5.9

ODEPACK and CVODE Description: These integrators are based on the popular stiff-system ODE solver packages of the same names. They are particularly suited to systems which exhibit a sparse Jacobian; for such systems, these solvers may yield a significant performance improvement over the Gear algorithm.

For the CVODE algorithm, the sparsity structure of the Jacobian may be specified using the UBWITG and LBWITG system variables; these are used to set the upper and lower Jacobian bandwidths, respectively. By default, ODEPACK automatically determines the sparsity structure of the system.

4.5.10

MINT with variable step algorithms Description: The variable step algorithms never take steps smaller than MINTERVAL (MINT). The integration step size for variable step algorithms is calculated as for the fixed step algorithms with the addition of a check on the minimum step size as follows:

H = MAX(MINT, MIN(MAXT, CINT/NSTP))

4.5.11

NSTP with variable step algorithms Description: NSTP can be set to help a variable step algorithm start off. If the first try (CINT/NSTP) is too large (i.e., if the estimated error is larger than the allowed error), the algorithm reduces the step size and tries again, until it finds a small enough step size to start off. Setting NSTP to a fairly large number (1000, for example) starts the routine at small step size, which is then increased automatically as the run progresses until it reaches the most efficient size. Beware of leaving NSTP at a large value and switching to a fixed step algorithm.

4.5.12

Error summary Description: An error summary is produced automatically at the end of simulation runs using variable step algorithms, giving the weight each state had in controlling step size. The error criteria (XERROR and MERROR) can be adjusted using this information. The number of times the predictor-corrector algorithm failed to converge and caused a general step size reduction is also listed. This is usually considered a more serious failure than bumping into the allowable error tolerance. The summary may be suppressed by setting the system variable

Language Reference Manual

39

WESITG (write error summary, integration control) to FALSE. Current step size (CSSITG) and current integration order (CIOITG) are available as system variables that can be output or prepare.

4.5.13

Determining appropriate step size Description: Determining an appropriate step size for a fixed step algorithm is important. If a step size is too large, the results are inaccurate or even catastrophic; if too small, computer time is wasted.

One approach is to use a variable step algorithm to see what acslX believes to be appropriate. Use the Adams-Moulton routine and the system variables for current step size and current integration order as follows:

IALG=1 prepare T CSSITG CIOITG ... start plot(_t,_cssitg)

Check that the step size is not being constrained by CINT. If it is, increase CINT and MAXT and run the simulation again. Look at the shape of CSSITG. If it is steady, use a fixed step size just slightly larger than the values chosen by the variable algorithm (the system choice of step size is somewhat conservative, so a slightly larger step is usually adequate). If the curve varies widely, however, consider using one of the variable algorithms. The system choice of CIOITG should also be steady and can be factored into the choice of algorithm order and step size.

4.5.14

Efficiency and accuracy Description: The efficiency of the various algorithms can be compared with the tic and toc analysis commands. Example:

IALG = 4 tic;start @NoCallback;toc IALG = 5 tic;start @NoCallback;toc

Each toc command lists the cpu time elapsed since the previous tic command. Compare the accuracy of the results by printing (or plotting) significant variables or by getting debug dumps.

Language Reference Manual

40

4.6 ANINT

Form:

y = ANINT(x)

Description: The output y is the nearest whole number of x where x is a floating point variable or expression. The output type (REAL or DOUBLEPRECISION) depends on the input type.

Since NINT is promoted to REAL or DOUBLE as appropriate in any expression, the only situation where it is necessary to use ANINT( ) is in the argument to a subroutine to force the type.

Example: If the first argument of MYSUB is floating point, the following ensures the nearest whole number (integer) value, but transmitted as a floating point number:

CALL mysub(ANINT(v1), ...)

4.7 ASIN

Form:

y = ASIN(x)

Description: The output y is the arc sine of x, where x is a floating point variable or expression between -1.0 and +1.0. The output is in radians (-p § 2 <= y <= + p§ 2 ); its type (REAL or DOUBLEPRECISION) depends on the type of the argument. Example: ASIN could be used as follows:

area = 0.5*pi*r**2 - x*SQRT(r**2 - x**2) + (r**2)*ASIN(x/r))

4.8 Assignment statements

4.8.1 Arithmetic Form:

variable = expression

Language Reference Manual

41

Description: Where variable may be simple or subscripted. If a subscripted variable is used in a sorted section, it must be enclosed in a PROCEDURAL block. On execution, the single value of the expression is stored into the location defined by variable; for example, the results of the expression on the right side of the following statement is stored into location y:

y = a*b + c/d

A special form of the assignment statement is the integration statement. The use of the INTEG operator marks the variable as a state variable.

**Example: In this example, a is marked as a state variable and ad is stored as the derivative of A.
**

a = INTEG(ad, aic)

Type conversion is performed automatically from an integer, real, or double precision expression to an integer, real, or double precision variable.

4.8.2

Logical Form:

lvariable = lexpression

Description: where lvariable may be simple or subscripted and lexpression is a logical expression formed from a logical operator. Example:

flag = a .NE. b .OR. flag2

4.8.3

Character Form:

cvariable = cexpression

**Description: where cvariable is a character variable or substring and cexpression is a character expression. Example:
**

cvar(5:10) = string(1:4)//'Z'

Language Reference Manual

42

concatenates a Z to four characters extracted from STRING and places them in character positions 5 through 9. Unfilled character positions in cvariable are filled with blanks. If the length of cexpression exceeds that for cvariable, the character expression is truncated on the right.

4.9 ATAN

Form:

y = ATAN(x)

Description: The output y is the arc tangent of the floating point argument x where x is unlimited except for infinity and the result is in radians in the range (-p § 2 < y < +p§ 2 ). Example:

al = ATAN(-vmm(3)/vmm(1))

For full coverage of the circle, it is better to use ATAN2.

4.10 ATAN2

Form:

z = ATAN2(y, x)

Description: The output z is the arc tangent of an angle formed by the point with floating point coordinates x, y and the positive x-axis; x and y can be both positive and negative, defining the full circle of revolution. The result is in radians in the range (-p < z <= + p ). Example:

pdgn = ATAN2(dlq, dlp + 1.0E-30)

4.11 BCKLSH

Form:

y = BCKLSH(ic, dl, x) BCKLSH(y = ic, dl, x)

Description:

ic = dl = initial condition of y half the width of the backlash

Language Reference Manual

43

5*(ul . tb. if y is to move when x is greater than (Y+UL) or less than (Y-LL).0. x) Dscription: bb = bottom bound tb = top bound x = input (a floating point variable or expression) The output y is as follows: y y y = bb when = x when = tb when x < bb bb < x < tb x > tb This function bounds or limits variables.dl) and (x + dl).12 BOUND Form: y = BOUND(bb. 0. It should not be used to limit the output of an integrator since the integrator itself continues to wind up and must actually integrate out of the limit. Example: MAXT = BOUND(maxtmn. then: y = BCKLSH(yic.5*(ul + ll)) NOTE: The BCKLSH operator must be in a sorted (DERIVATIVE) section. For example. Figure 4-6: Mechanism Illustrating BCKLSH Operator For asymmetrical applications. maxtp) Language Reference Manual 44 . x . The function LIMINT should be used in this case. Figure 4-6 illustrates the backlash mechanism. 4.ll).x = input (a floating point variable or expression) The output always lies between the limits (x . the input x expression should be rewritten. maxtmx.

. p2.15 CINTERVAL Form: CINTERVAL name = real constant Language Reference Manual 45 .. it should be embedded in a PROCEDURAL block that describes the inputs and outputs. o2) END Now the translator sorts this section correctly since it has been told which variables are inputs and which are outputs. o3.. pi are actual arguments that may be expressions of arbitrary complexity for input values. o2. Arguments may be variables.4. p3. If the call is in a sortable section of the program. p3.. p2. arrays. p3. o1.14 CHARACTER See TYPE. p2. then the following statements are valid: PROCEDURAL (o1.. a PROCEDURAL is recommended to avoid the "Symbol used but not defined" diagnostic. p2. and oi are output variables (names or arrays). . . pn) Description: Where name is the name of a subroutine being called. pn) CALL name (o1. o3) 4. the subroutine could be called with: CALL subr(o1. o2. on = p1. the translator cannot tell which arguments are inputs and which are outputs. p4) CALL subr(o1. The third form of the call is available for the case in which the subroutine is defined with the input expressions on the left and the output variables on the right. If the call is any other section..13 CALL Form: CALL name CALL name (p1. o3 = p1. In this form. p1. Example: If oi are output variables and pi are input variables or expressions. p2... p3) The translator rearranges the order and changes the equal sign to a comma so that the resulting call to FORTRAN is: CALL subr(p1. o3 = p1. o2.. In the third form. . o2. 4. or subscripted variables. p4. p2.

1). print. assume that a missile simulation has the following four phases of flight: 1) 2) 3) 4) Initial turn Midcourse Acquisition Terminal It is useful to measure these phases at different rates.1. To prevent accumulated round-off error.Default: name: CINT real constant: 0. In general.1 Description: Where name is a simple unsubscripted variable. no finer detail can be seen in output. the time is about 0.2 Calculating CINT The value of the name defined in the CINTERVAL statement can be calculated in the program so that different phases can be viewed at different data rates. the long midcourse only every second. PHASE is declared to be an integer and initialized to one. An array CINTTAB is defined and Language Reference Manual 46 . In the INITIAL section.g. For example. Sampling effect Be careful of the sampling effect where high frequency oscillations can be folded down to lower frequencies or even a DC level if the sampling time is not small enough. e.15. or plot. with MAXT = 0. whichever is larger). CINT is multiplied by a power of ten until it is close to an integer. then time is accumulated as an integer but divided by the multiplier before being used. 4. initial turn at a fairly fine level of 0.1 second. the step is discarded as negligible.1 Adjusting step size to CINT If the next integration step to a communication interval is less than 1.. a small adjustment is made to the communication interval. after ten steps.0E-11 (1.0E-6 in single precision) of the current time (or CINT. A communication interval that generates about 100 to 200 data points during a run is sufficient detail for most applications.1 because of rounding in both 0. so it is important to choose this value with care. The integration algorithm takes steps up to the next communication interval by accumulating the fixed step (for example.01 and 0. 4. and acquisition and terminal at a fine rate of 50 msec. The communication interval CINTERVAL is the interval at which the DYNAMIC section is executed and the variables on the output and prepare lists have their values recorded. This situation can occur because of accumulation and rounding on a binary machine.15. Figure 4-7 outlines a procedure for setting the communication interval for each phase.01and CINT = 0.

. In the DERIVATIVE section. In the DYNAMIC section. This code is shown as a block since the algorithm depends on the implementation of the model.. ) .. INITIAL INTEGER phase DIMENSION cinttab(4) CONSTANT cinttab = 0.1.05. END ! of initial DYNAMIC DERIVATIVE ! Compute phase of flight PROCEDURAL(phase = . 0. 0. .. the value of PHASE is maintained in the range one to four. the communication interval (using default name CINT) is set using the current value of the flight PHASE (which ranges from one to four)..filled with the communication intervals to match the phases of flight as numbered above. 1. Language Reference Manual 47 . END ! of procedural .001 Now all references are to CI when the value is recorded or changed.0.05 phase = 1 ! Initialize phase to start . ..3 Changing default name The name of the variable defining the communication interval can be changed from the default CINT.15..... Example: CINTERVAL CI = 0. END ! of derivative CINT = cinttab(phase) . END ! of dynamic Figure 4-7: Outline of program to vary communication interval 4. but no matter how it is implemented. the value of PHASE is computed from the logic used to establish the different flight regions.

x.16 CMPXPL Form: y = CMPXPL(p. ic1.15. implements a second order transfer function where the output y is related to input x through the transfer function: such that: Language Reference Manual 48 . This subject is discussed in more depth under DYNAMIC. x.4. The actual integration step is obtained from the following algorithm: H = MIN(MAXT. ic2) CMPXPL(y = p. 4. q. time_to_next_event) This applies a bound of MAXT to CINT/NSTP and then limits the step to be no more than the time left in the current communication interval or to the next other event.4 Bound on integration step CINTERVAL acts as an upper bound on the integration step size (and also for the last integration step of a communication interval) since the model is advanced no further than to the data recording time no matter how large the calculated integration step size. q. CINT/NSTP) H = MIN(H. ic2) Description: This operator. listed in Figure 4-8. ic1.

x.0 MACRO REDEFINE ydot ydot = INTEG(((x)-(y)-(q)*ydot)/(p).0.MACRO cmpxpl(y.p.ic2) MACRO STANDVAL ic1=0. NOTE: This operator (as all the memory operators) should be used only in sorted sections and should not be used in a PROCEDURAL block. The time constants p and q may be expressions of arbitrary complexity.Calculate the derivative x = a + b ! Add `a' and `b' and place in `x' a = sin(w*t) ! Forcing function acceleration Language Reference Manual 49 . ic2) MACROEND Figure 4-8: Macro for 2nd order transfer function Restrictions The same restrictions on initial conditions apply as for the INTEG operator. and both ICs may be omitted if zero.ic1. xp) 4. as can be seen in Figure 4-8. b. Example: ! -----------.ic2=0. However.17 Comment (!) Form: !string Description: A comment is all text after an exclamation point to the end of the line. The CMPXPL operator could be used as follows: x = k2*CMPXPL(a. The text is reproduced in the listing and then discarded. ic1) y = INTEG(ydot. do not set p to zero because it results in division by zero.q.

assignment statement The CONSTANT statement effect is quite different from that of an assignment statement. The recommended placement is just before the statement using the CONSTANT value. cm = cmz + cmal*al & ! pitch moment coefficient + cmde*dle + (cb/(2*v))*(cmad*ald + cmtd*q) 4. The assignment statement moves data from one place to another (into the location for the variable to left of the equal sign) every time control passes through the statement. Examples Examples of the correct use of the CONSTANT statement include: LOGICAL switch1 INTEGER ii DIMENSION a(2) CONSTANT switch1=. integer subscripts may be used to fill individual elements within the array. The CONSTANT statement.63 Language Reference Manual 50 . The CONSTANT statement is used to preset symbolic locations with numeric data.76 CONSTANT vs. b=-5.. on the other hand. Implied DO loop notation may not be used.70 k2 = 7. just presets the variable to the left of the equal sign when the simulation is loaded into memory.TRUE. d3 = a31. The variable can then be overridden by assignment statements or at runtime. k = integer constant or integer PARAMETER name repetition factors. d2 = k*a2.0. should be avoided: INITIAL k1 = 5. or else the entire array must be filled. it can be placed anywhere in the program. k*a33 Description: di = identifiers representing simple variables or array names. ii=2.Comments can be added after continuations (& at end of code) because comments are stripped off before the translator analyzes the rest of the line. Assignment statements for constants. Since it is not an executable statement. a=2*1.18 CONSTANT Form: CONSTANT d1 = a1. ai = literals and signed or unsigned constants or PARAMETER names. such as the following. If di is an array name. the literal following the asterisk is repeated k times. a32.

The warning does not abort translation. 4.70. If the counter were initialized using a CONSTANT statement. but any subsequent runs would start with the value left over at the end of the previous run. Warning message When a variable is given a value in a CONSTANT statement and later appears on the left side of an equal sign. they are returned to the original value as soon as the assignment statements are executed.. This precludes doing runs with different values of the parameters.19 Continuation (&) Form: statement & [&]continuation Description: Any model source code (or runtime) statement can be continued onto another line by ending the first line with an ampersand (&).. counters are often initialized in the INITIAL section and then incremented later: INITIAL INTEGER n n = 0 END DYNAMIC n = n + 1 . > K1 = 6. the translators issues a warning message: Warning: Re-computing a constant.0 Initializing counters CONSTANT statements should not be used to initialize counters. Any number of continuation lines is allowed (although the resulting Fortran code may be limited to twenty Language Reference Manual 51 . the results would be correct for the first run. For example.63 Now the values of k1 and k2 can be changed at runtime and remain that value until changed again from the command prompt.0 > K2 = 8.END Although these values can be changed at runtime at the command prompt. Warning messages can be suppressed with a switch on the call to acslX. Replace the code above with a CONSTANT statement as follows: CONSTANT k1 = 5. k2 = 7.

The translator removes blanks between the end of the code and the ampersand on the first line but carries blanks at the beginning of the continuation line onto the compile file.0 . 270. 10 & /-10. this allows name and character strings to be continued without starting the continuation line in column one.0 . 5. charactervariable = `longcharact& &erstring' In other words. 60. then blanks at the beginning of the line are dropped.0 . 240. 210.0 & . Blank lines Because the syntax analyzer looks for the leading ampersand in continuations. use two ampersands. 30. 1.3 .6 .7 . cm = cmal*al + (cmq*wm(2) & + cmbep*be*wm(1))*d/(2.0 .0 . 10. 5. Note that code using Language Reference Manual 52 . for example: TABLE xyz. blanks between the two ampersands are eliminated. 6.2 & . 150.0 & & . 16.packed lines) and the ampersand may appear in any column up to 72. 8. 4. 8. 120.2 .33 .0 . 0.0 .7 / Comments Comments can be added to a continued line as follows: x = a + b & ! Comment on the sum + SIN(a/b)*m ! Explanation of sine function The translator strips comments off before looking back from the end of the line for an ampersand. 1.20 CONTINUE Form: label: CONTINUE Description: CONTINUE is normally used to transfer control after a GO TO command or to terminate a DO loop.0*vmam(1)) If the continuation line begins with an ampersand.0 .33 . 4. To introduce blank lines in continuations.6 & & .0 & . a blank line results in a syntax error. 8. It is the preferred statement for all labels due to problems with macro expansions as explained in Chapter 2. 180.

single precision.wm(3)*SIN(fim))/COS(thm) 4.CONTINUEs and labels generally requires the use of PROCEDURALs in sorted sections. then the type can be forced in the form. tb) Description: x = xd = displacement velocity () Language Reference Manual 53 .21 COS Form: y = COS(x) Description: The output y is the cosine of x where x is a floating point variable or expression in radians. xd = xic. The main use of DBLE is to force the precision of arguments to subroutines where the precision of the argument cannot be deduced by the compiler. bb.0 ). xdic. 4. Example: CALL mysubr(DBLE(x1). .22 DBLE Form: DBLE(x) Description: This function converts an integer. The type (REAL or DOUBLEPRECISION) of the output and function depends on the type of the argument.. Example: simd = (wm(2)*COS(fim) . xdd. ) NOTE: See Type Reference 4.23 DBLINT Form: DBLINT(x.0 <= y <= + 1. The result is in the range (-1. or double precision argument x to double precision. DBLE(x2).. If a subroutine requires a double precision argument.

.vic. initial condition of bottom bound top bound macro dblint(x.vic).ubx). i. initial condition of x the input.v.ubx) macro redefine vl.ic constant ic=0. i.lbx.xic = xdd = ) xdic = . acceleration ( x(0). shown in Figure 4-9.x.vl=ic. is for integrator limiting when the limited output is the second integral of an acceleration.lbx. Language Reference Manual 54 .xic.a.lbx.e.integ(zzlimf(x.e.a.ubx) x=intvc(v.0 callzzdlim(v..xic) macroend Example: Figure 4-9: DBLINT operator macro The DBLINT (double limited integration) operator. bb = tb = x(0).

The mass must remain stopped until the force acting on it (f (t) . and Kd the Language Reference Manual 55 . Alternate implementation An alternate way of performing this operation is to wrap a stiff spring around the loop when the wall is approached.cx) changes sign.Figure 4-9: Alternate implementation for DBILINT Mass-spring damper system This type of limiting can best be explained in terms of the mass-spring-damper system described by: such that: where physical stops constrain the mass to move only between xbb (bottom bound) and xtb (top bound). Figure 4-9 is a block diagram of such a system where Ks is spring stiffness. Kw wall stiffness. xbb < x < xtb When the displacement (x) of the mass reaches its limit. i. this corresponds to what happens physically since the wall always has a finite spring constant. implying that the velocity ( ) is zero.e. the mass must stop..

damping constant. tb. nmx. 4.bb . The problem with this representation is in the behavior of the digital integration routine in the vicinity of the wall when the wall stiffness is extremely high. vmx. ic = the initial value of the output until the independent variable has advanced by the delay. ic. NOTE: This operator (as all memory operators) can be used only in DERIVATIVE sections and should not be put in a PROCEDURAL block. REINIT needs a name into which to store the current DELAY output as the initial condition for subsequent runs. Language Reference Manual 56 . tdl.25 DELAY Form: y = DELAY(x. x) Description: The DEAD operator implements a dead zone in output y when x lies between a specified bottom bound bb and top bound tb. tdl = the delay time between input and output (any expression with a value 0.0 . bb < x < tb y = x . delmin) DELAY(y = x. The results can be represented as follows: y = x . delmin) Description: x = the input (an arithmetic expression of arbitrary complexity). x < bb y = 0. This argument must be a variable name (rather than a literal constant) for the runtime command REINIT to work. ic. v3) 4.0). A more accurate but more complex approach is to use the SCHEDULE operator to find times of both wall impact and wall leaving (when the force changes sign or crosses zero). tdl. tdl. x > tb Example: The dead zone operator could be used as follows: v2 = v1 + k*DEAD(vmn.24 DEAD Form: y = DEAD(bb.tb . nmx.

Each entry in the table is associated with a time. This argument may be omitted. cmx. For example: co = DELAY(ci. extending over all past history. in which case a default of zero is used. cic. treating it as a circular list. delmin= minimum interval between saving of data points in delay buffer. so direct feedback (without an integrator) is illegal. an error is reported and the run terminates. tdl. then nmx should be somewhat larger than the maximum delay times expected (tdl) divided by this delmin (or by the integration step if it is larger). If not enough data points are present. tdl (the current time delay) is subtracted from the independent variable value and the table is searched for time values that bracket this required previous time. cdl. The DELAY operator delays a variable in time to model transport effects such as passage through a pipe. 2*nmx words long. To compute the output value. whichever is larger) a new value is inserted into the array. Varying time delay When tdl changes dynamically. 1000. the following for example is not allowed: y = DELAY((n . cic. cmn) This integer nmx allocates space in a circular buffer to hold the history data of previous sample times and previous input values. and prefilling it with the value of ic. cdl. If delmin is defined. NOTE: This integer must be a literal integer or a parameter name with an integer value.y)/k. 1000. cmn) Using a PARAMETER variable: INTEGER cmx PARAMETER(cmx=1000) co = DELAY(ci. and at each new integration step (or delmin. yic. 0. Implementation The DELAY operator is implemented by allocating a dummy array.nmx = a literal integer giving the maximum number of saved data points needed to represent the delay. The integration step size may vary but the sum of nmx integration steps must always be greater than the current time delay. Typically delmin can be a tenth or a hundredth of the expected delay time and still represent dynamics adequately. It should not be used lightly since it may require considerable storage unless delmin is specified. Direct feedback not allowed The operator provides an algebraic path from input to output. this operator approximates the pipeline with a varying flow rate.1) Language Reference Manual 57 . A linear interpolation is performed between the corresponding input values.

in the form Znnnnn) is used for the state name. TFILT is chosen to be small relative to the delay time (tdl).. the output of the DELAY can be filtered through a real pole to break the loop. 4. if an expression is used for the initial condition. For example: y = REALPL(tfilt. a real constant. or a general expression enclosed in parentheses. 0. 1000.. When the delay statement is alone. so that this form is normally to be avoided. Language Reference Manual 58 .If direct feedback is really necessary.26 DELSC Form: state = DELSC(xn. yic. not a DERIVATIVE section. DELAY((in . may contain further DELSC statements or other functions or macros. i. This is a good idea anyway since it eliminates jumps in the slope of the DELAY output produced by the straight line interpolation.1)) In this situation. embedding it in an expression means that an acslXgenerated variable (i. The implementation of the expression form involves the following expression: if(zzicfl) state = ic so it is only after the expression is seen that the states has a value the first time. then the DELSC expression must be placed before any reference to the state and after the calculation of the next value. ic) DELSC(state = xn. DELSC may be embedded in any legal expression as a function that has a single output: the value of the state.e.e. NOTE: The DELSC statement can be placed only in a DISCRETE section. tdl. ic = a simple non-subscripted variable.y)/k. With initial conditions Since DISCRETE sections are not in general sorted. ic) Description: state = a simple variable (DELVC handles vectors) xn = an arithmetic expression of arbitrary complexity. DELSC produces a one-step delay between the calculation of the xn value and its assignment to the state so that it shows up in the variable at the beginning of the next step. then the state name can be identified.

The restrictions on the DELSC operator with regard to arrays can be avoided by using this vector integrator operator. XN. See the description of the INTEG statement for a general description of the way the acslX system build tables of states. the initial condition variable is equivalenced into the initial condition table and the values for all the states are moved at once before any DERIVATIVE or DISCRETE section code is executed at all. zic) 4. DELSC places the state in the state table. 0) z = DELSC(znext.5). xic(10). respectively. yic) ! scalar delay x = DELVC(xn. the next state in the derivative table. DELVC must be placed after the calculation of its inputs. xic) Description: Where X. m(5. In unsorted DISCRETE blocks. derivatives. The integration algorithm knows to update the delay state variables by: xn+1 = xn whereas the continuous states are updated by: xn+1 = xn + h*xd(effective)n Examples of the use of the DELSC statement include: y = DELSC(5. yz) x = 4.0*(x(2) + c). The restrictions on the DELVC operator are identical to those on the INTVC operator with the additional one that the DELVC statements can appear only inside DISCRETE blocks. and the initial condition value in the initial condition table. and XIC are arrays of the same size and correspond to state. derivative. DELSC must be placed after the calculation of its inputs.5) y = DELVC(yn. xic) DELVC(x = xn.0*DELSC(4*y. mic(5. and initial conditions.27 DELVC Form: x = DELVC(xn.In the more general case. mn(5. and initial conditions. mic) ! matrix delay Language Reference Manual 59 . Example: DIMENSION x(1). xic) ! vector delay m = DELVC(mn. Placement In unsorted DISCRETE blocks.5).

The DERIVATIVE statement must be paired with a matching END statement.e. the actual step is reduced so that the last step is made exactly up to the event.. END Description: The DERIVATIVE keyword identifies the beginning of a block of code performed at the request of the integration routine to evaluate the state variable derivatives. Transfers illegal All the statements in the DERIVATIVE section are translated into a separate subroutine. The actual number of evaluations depends on the integration algorithm employed. the next time on the event list is called the barrier time. The acslX system does not require this. If integration with the current step size would exceed the barrier time. or SCHEDULE The only break in the regular progression is at a communication interval or at an equivalent barrier represented by a DISCRETE section or a SCHEDULE event.28 DERIVATIVE Form: DERIVATIVE [name] . the integration algorithm calls the DERIVATIVE section. For example.4.. Barriers at CINT. DYNAMIC. i. DISCRETE. it is acceptable to choose a fixed step length for the continuous section of 4 msec. DISCRETE. a sampling INTERVAL in the DISCRETE block of 11 msec. All states then line up in time for the event to take place. CINT as integer multiple of step size Integration step sizes and communication intervals are usually chosen to be integer multiples of each other. so it is illegal to transfer control by GO TO's from DERIVATIVE sections to other sections (INITIAL. For the DERIVATIVE block.. and communication actions are entered onto the event list where all actions are ordered in time. the current step size is checked against the current time (T) and the barrier time from the next event list. and a Language Reference Manual 60 . The times for all DISCRETE. or TERMINAL) or vice versa. SCHEDULE. Implementation The integration routine is called from the DYNAMIC section and asked to advance the state over the next communication interval using the code embedded in the DERIVATIVE blocks to evaluate the state variable derivatives.

Language Reference Manual 61 . Then two more normal steps are followed by a short step of 1 msec to bring time up to the communication time of 20 msec.29 DERIVT Form: y = DERIVT(ic. This formulation can be represented by a single line of acslX code: y = (k*x . Since the derivative operator is a first order approximation. The first few integration step sizes would then be (in msec): 4. 4. . 3. 2. i.. integral. 4. 1. The only time this may be justified is for a minor term where a large amount of extra calculation may be needed to reform the problem in terms of the states. 3. 3. 4. it is always combined with a lag to make it realizable. x) DERIVT(y = ic. but in hardware.. The first short step of 3 msec brings time up to 11 msec.. PID example As an example of how DERIVT can be avoided. Variable step algorithms look ahead to the next barrier to compute a constant step size which reaches the barrier without requiring a final short step. which is due to the DISCRETE section. 4. There is a tendency to use DERIVT for this term. 4. The next barrier is the DISCRETE block at 22 msec causing a step size of 2 msec. The derivative can be expressed instead in terms of all the other states in the system. x) Description: ic = y(0) x = the input (an arithmetic expression) The derivative function differentiates x and can be implemented if absolutely necessary. 4. the first barrier time. 4.communication interval of 20 msec. NOTE: It is never necessary to invoke a derivative.INTEG(y.e. it is always implemented by a differentiation over a first order lag. consider the D term in a PID (proportional. 4. ic))/t1 Nature never has a free differentiator. derivative) controller. and so on. it can lead to instability if it is used to represent any major loop.

al) 4. root locus..)...) Language Reference Manual 62 . otherwise REINIT tries to overwrite the global zero with the one in the common block. v2(a. This is another good reason not to use DERIVT. Negative extension cancels zero force with a cable. . . x1 > x2 otherwise The following logic is often used: PROCEDURAL(x = y. z)) DIM is useful for representing cable spring stiffness.x2 y = 0. The DERIVT operator (as all memory operators) should be used only in sorted sections and should not be put in a PROCEDURAL block. and frequency response plots).z IF(x .LT.Jabobian Sorting Initial Condition The use of DERIVT invalidates the Jacobian calculation from the ANALYZE command.30 DIM Form: y = DIM(x1.31 DIMENSION Form: DIMENSION v1(a. The result can be represented as follows: y = x1 .0 ... Use a variable name rather than a literal constant for the initial condition so that REINIT has a place to store it.0) x = 0.. 0..z) x = y .0 END a = SQRT(x) One line using DIM can solve the same problem: a = SQRT(DIM(y. Example An example of a DERIVT statement could be: ald = DERIVT(alic.). DIM takes its type and types its output based on the type of the arguments.. 4. vn(a. x2) Description: The output y is the positive difference between x1 and x2 where x1 and x2 can be variables or expressions.. including all the derived data (zeros.

5.. acslX cannot check that the name defined as an array is also a macro because the TABLE statement defines an array to hold data and a macro of the same name for table lookup.5) can be shown: 11 12 13 14 15 21 22 23 24 25 Extracted as a single-dimensioned vector. SPACE(5. NOTE: Names of certain acslX macros should not be used as arrays. This operator allocates space for up to six dimensions to be associated with a variable name. but it must appear before any invocation of a macro that uses dimension information. e.g.5.5. the elements of b(2. or INTEGER statements.5). the order is: 11 21 12 22 13 23 14 24 15 25 Examples An example of a DIMENSION statement is: Language Reference Manual 63 .e. then row. j = column). The names of the following acslX operators should not be used for arrays (as scalars is not a problem): Array order Elements of arrays are written and accessed by column. For example. The statement can appear anywhere in the program. DIMENSION is preferred for floating point variables unless the type of precision needs to be forced.5. (a(i. The subscripts may be symbolic if the symbols are declared INTEGER and defined in a PARAMETER statement.j) where i = row. Using DIMENSION allows the type to adjust depending on the global option (single or double precision) selected.Description: The variable names vi may have up to six integer constant subscripts separated by commas.. Type declaration Arrays can also be dimensioned using the REAL. i. DOUBLEPRECISION.

Like the DERIVATIVE section.) Executed at discrete event DISCRETE sections are executed at a discrete event or time point.3. hold(2. the section is re-entered on the event list with a time of execution equal to the current time plus the current value of the INTERVAL variable.. ensuring that the integration routine takes a final step (which may be short) up to the barrier time before the code in the DISCRETE section is executed. Code is never sorted across sections. Language Reference Manual 64 . Another common application is changing state or other variables when a state event occurs (in which case execution of the DISCRETE section is handled by a SCHEDULE statement). If execution is controlled by an INTERVAL statement.32 DISCRETE Form: DISCRETE [name] . DISCRETE sections are placed inside it. Sorting The translator does not automatically sort the code. END Description: The keyword DISCRETE introduces a section to be executed by either an INTERVAL statement or the SCHEDULE operator. The time of the execution is controlled by the keyword INTERVAL or by a SCHEDULE statement. (See Chapter 3 for further information on explicit program structure.n).3).. each DISCRETE section has a time associated with it that is entered into an event list.4. This time becomes a barrier for DERIVATIVE sections. Use the SORT keyword to have code within a DISCRETE section sorted. Explicit structure level DISCRETE sections are at the same level as any DERIVATIVE sections.DIMENSION rm(3). If a DYNAMIC section is used. x(3.4.2. DISCRETE sections are intended primarily for modeling digital sampled data controllers where the communication to and from the continuous world occurs at fixed times known in advance.5) 4. The section is concluded by a matching END statement. em(3. nor are the sections themselves sorted.

which must follow the DO statement. The range of the repetition extends from the DO statement to the terminal statement. m1 = initial parameter. When the value of i surpasses the value of m2. The m1. the amount i is increased with each repetition. This variable may not be changed within the loop. DYNAMIC. i = a simple integer variable called the index variable. or expressions of arbitrary complexity. m3 = increment parameter. 4. DISCRETE. PROCEDURAL in sorted sections This is the standard DO statement. m2. refer to the specific language reference manual. the value of i during the first loop.33 DO Form: DO n i = m1. DO execution is terminated and control goes to the statement immediately following the terminal statement.. final value. variables. its value is altered by the increment parameter m3. Errors of structure are indicated by the language compiler. m2[. and m3 may be integer constants. they must be declared explicitly to be INTEGER variables. Error checking For more information on the structure of the DO statements. A DO statement makes it possible to repeat a group of statements a designated number of times using an integer variable whose value is progressively altered with each repetition. With each repetition.34 DOUBLE PRECISION See TYPE.4. m3] . or TERMINAL sections. Using a PROCEDURAL is not necessary within INITIAL. and rate of increase of this integer variable are defined by the set of indexing parameters included in the DO statement. if variables. The initial value. n:CONTINUE Description: n = a label (numeric or symbolic) of the terminal statement of the loop. The default value of m3 is 1. m2 = terminal parameter. Language Reference Manual 65 .. The acslX translator checks the syntax of the DO statement but does not validate the correct nesting of loops or terminal statements. and this whole sequence is called the DO loop.

4.. thus obtaining variable data recording rates (see CINTERVAL for an example). except that it terminates blocks of statements. DERIVATIVE. based on some simulation phase or configuration. The time to the next communication interval can be calculated in the model. Use the SORT keyword to have it sorted. Language Reference Manual 66 . a PROCEDURAL block) or section (DYNAMIC. It must be accompanied by a matching END statement.. the DYNAMIC section is not intended for computing variables to be input to DERIVATIVE or DISCRETE sections. One of the most common errors in programming a model is not getting the right number of ENDs to balance the program sections. Code in the DYNAMIC block is not sorted automatically.g... The following error messages are issued when the count is incorrect. Chapter 3 shows the use of ENDs in structuring an explicit program.35 DYNAMIC Form: DYNAMIC .. etc. The DYNAMIC section is the place to put output-related calculations so they can be performed at the usually slower data recording rate rather than at each derivative evaluation.Not enough ends . .. 4.Too many ends The END statement acts like a right parenthesis in an arithmetic expression..36 END Form: END Description: An END statement denotes the end of a block (e. Most calculations that affect code in the DERIVATIVE section should be in a separate DISCRETE section so model behavior is independent of the data recording action.). which do not affect DERIVATIVE calculations. END Description: The DYNAMIC keyword identifies the beginning of a section of code that is performed every CINTERVAL communication interval throughout the run. an incorrect count corresponds to unbalanced parentheses. Examples of calculations generally performed in this section are unit conversions (such as radians to degrees).

4.4. x1. x3) Language Reference Manual 67 . The value of this name is set TRUE to indicate an attempt by a variable step size integration algorithm to reduce the integration step size to satisfy the error bounds.38 EXP Form: y = EXP(x) Description: The output y is the exponential of the floating point argument x. The variable step integration routine calls the derivative subroutine once with the name given under ERRTAG set to TRUE if it needs to reduce the step size below the specified minimum MINT.39 FCNSW Form: y = FCNSW(p. x2. This statement changes the name of the variable to a name of your choice. Control should then revert to the TERMINAL section (if any) and the executive. and the next runtime command is read. then care must be taken that a very small step size does not result in excessive computer time being used. ERRTAG defines the system variable name that is used to indicate an attempt to reduce the step size below the minimum. If it is still TRUE on return. The type of name is automatically set to LOGICAL and the value is preset to FALSE. MINT. where x is limited in size such that the maximum machine word size should not be exceeded by the exponential. If provision is made to handle this case and reset the flag. Example: The expression is represented mathematically: y = ex 4. the termination flag for that run is set.37 ERRTAG Form: ERRTAG name Description: Where name is a simple unsubscripted variable.

Language Reference Manual 68 . Input k is an integer constant or expression and should be a large. The macro for and GAUSI operator macros is shown in Figure 4-10.0 y = x3 p > 0.0 y = x2 p = 0.Description: The output y of the function switch operator is determined by the input function p as follows: y = x1 p < 0.0 Note that zero almost never exists in the span of real numbers unless some other action forces it there. vneg. Example: v = FCNSW(ain. vzer. vpos) 4. Figure 4-10: GAUSS and GAUSI operator macros Only one of the initialization routines should be used since they both set the same seed variable.40 GAUSI. positive odd number for a maximal length sequence. UNIFI Form: GAUSI(k) UNIFI(k) Description: The output of these functions is the seed for the random number generator. either may be used with any other routine as they perform exactly the same function.

The random number generators are provided with a default seed initialization.42 GO TO Form: GO TO label GO TO (n1. nm). Figure 4-10 gives a listing of the operator macro. n2. vmsg) 4. Language Reference Manual 69 .. 4. the random numbers do not change. The default seed number is 55555555.. If the operator is executed repeatedly. so these initialization routines are required only when you wish to override the default. a different random sequence is in effect for each run. what is usually more important. . If not set. i Description: Where ni are statement labels that correspond to a possible label and i is a simple integer variable that has been given a value between 1 and m. NOTE: GAUSS is not intended for use in a DERIVATIVE section because the power density (or.0. GO TO statements transfer control to labeled statements whose references are fixed or which are assigned during execution of the program. the low frequency power) depends on the integration step size. Example: vmic = GAUSS(0. s) Description: Where m is the mean and s is the standard deviation. The output y is a normally distributed random variable. or provision must be made to skip over it except at the beginning of each run in an implicit program.41 GAUSS Form: y = GAUSS(m. s) GAUSS(y = m. Instead. use the OU operator. The seed need not be specified for each invocation of the random number generators since subsets of random sequences are also uncorrelated random sequences. The GAUSI or UNIFI operator should be invoked only in the INITIAL section of an explicit program. Seed The seed for a random sequence can be reset by UNIFI or GAUSI..

The reason for this is that the integration routines must be initialized at the start of the run. Example: Examples of valid GO TO statements include: GO TO loop GO TO (100. INITIAL. Execution resumes at the statement with the referenced label. DERIVATIVE DISCRETE The DERIVATIVE section is a separate program block and control cannot be transferred into or out of it. 300. w.Transfers between sections The statement labels used in the GO TO statements must be associated with executable statements in the same program unit as the GO TO statement. a discontinuity is involved.tz ) + p ) T tz Descrption: tz = delay (sec) w = frequency (rad/sec) p = phase shift (rad) Note that if p is nonzero. DYNAMIC. 400. In explicit programs. However. 4. 500).43 HARM Form: y = HARM(tz. control cannot be transferred into the DYNAMIC region. the INITIAL. Control also cannot be transferred between DISCRETE and DYNAMIC. Language Reference Manual 70 . and TERMINAL sections exist in a single program unit. We recommend using a CONTINUE as the labeled statement to avoid possible problems with sorting.0 T < tz y = sin (w * (T . ibin A large number of GO TOs is considered harmful to the successful completion of any simulation project. this initialization operation is done on leaving the INITIAL section and entering the DYNAMIC section. Control can be transferred from the DYNAMIC region to the INITIAL or TERMINAL section and between INITIAL and TERMINAL sections. p) The output y is a sinusoidal or harmonic drive function with the results: y = 0. or TERMINAL sections because DISCRETE sections are in the same subroutine as the DERIVATIVE section. Statement labels A statement label may be either numeric or symbolic. 200.

in general. 4) and then we can form a filter by extracting the history elements as equivalent delay line taps: filt = b0*sinhist(1) + b1*sinhist(2) + b4*sinhist(4) Placement HISTORY can appear only in DISCRETE sections since it makes use of the DELVC operator to delay the history elements. n = must be an integer constant or integer parameter name (not a variable name) that gives the number of history elements to keep track of. sin(2*w*t + fi). In unsorted DISCRETE sections. The elements of the array are initialized to zero the first time. etc. phased) 4. HISTORY should be placed after the calculation of all its input variables. 4. IF-THEN-ELSE Form: IF(lexpr) statement IF(lexpr) THEN block1 Language Reference Manual 71 . Extracting past history is then just a reference to y(2) for two time steps ago. yic = a scalar variable or expression of arbitrary complexity that is stored in the first slot (y(1)) in the output array while the other elements in the array are pushed down. Example As an example.44 HISTORY Form: HISTORY(y. w1. yic.Example: drive = HARM(tdrive. Since the output is a vector. only scalar values can be passed across the equal sign. the following statement records four samples of a sine wave into a history array: HISTORY(sinhist. n) Description: y = a variable name that will be used to create an array. y(3) for three time steps ago. this statement cannot be invoked as an assignment statement.45 IF.

breakout) THEN vdot = netforce/mass ELSE vdot = 0.ELSE IF(lexpr1) THEN block2 ELSE block3 END IF Description: IF statements are used to transfer control or perform calculations conditionally. one that produces a single value (either TRUE or FALSE). Logical IF Description: In the logical IF form.0 Language Reference Manual 72 .GT. Examples: IF(a .0) a = a + 0.LT. in order to maintain statement order. The logical expression lexpr is a logical or relational expression. At the time of execution. as in the second example. This example however would be better handled with a block IF construct. Only a single statement can be included in the logical IF statement. xmax) GO TO finish x = k*xprev xprev = x finish: CONTINUE END Logical IF statements that transfer control in sections that are sorted by acslX (DERIVATIVE sections or implicit programs) must be enclosed in PROCEDURAL blocks.1 PROCEDURAL(x = ) IF(x . Block IF Description: Block IF statements conditionally execute blocks (groups) of statements. statement is any executable statement.GT. Such a sequence is called a statement block. a sequence of zero or more complete CSL statements including other IF-THENELSE blocks. Examples: IF(ABS(force) . 5. an expression in the IF statement is evaluated and the result determines whether the rest of the statement is executed.

b/2 END IF Initializing variables Note that the same output variables should always be defined in all branches of the logic. I = 1 . turning it into a separate statement. make the derivative zero. Thus the block is placed after the calculation of all the input variables and before the use of any of the output variables. b) THEN vdot = f(a) ELSE ydot = f(b) END IF Assuming A starts off less than B. When A becomes greater than or equal to B.GT. it just means that the derivative is not being calculated. This is not necessarily wrong. This results in the last calculated value being used. should not be used inside statement blocks. then VDOT is not given a value but YDOT is. REALPL. PROCEDURAL PROCEDURAL blocks are used to hide logical code from the translation sorting process. Language Reference Manual 73 . If they are not.g. then VDOT is given a value but YDOT continues to hold its last value. either VDOT or YDOT is not initialized: IF(a . TRAN. just an issue to consider when coding logic. the last value placed in the variable is left around and used in subsequent integration steps..b ELSE IF(a . but that doesn't stop the integration from taking place. ENDIF Memory operators Memory operators such as INTEG. in the following code. etc. b/2) THEN d = b/2 f = a . For example. b) THEN d = b f = a . IF(lexpr) THEN .END IF IF(a . It's possible to step over an integration statement with logic. e. The sorting algorithm looks at all the outputs of the block (those variables on the left side of an equal sign) and all the inputs (those variables on the right side of an equal sign) and positions the block according to the normal sorting rules.GE. If you don't want a state to be integrated. Statements on same line The IF-THEN statement takes no additional statements on the same line unless the separator (a semi-colon) is used. but IF blocks are moved as one and don't require the PROCEDURAL.GT.

or other integration statements) zic = a simple unsubscripted variable. may contain functions.4. or a general expression enclosed in parentheses. Implicit integration In implicit integration. this residual is then kept at or close to zero. Residual The residual expression must be related to the algebraic variable by a path such that the partial derivative of all the residuals. an arithmetic expression of arbitrary conplexity (i.. If it is a simple variable (preferred). Z ) 0 = G(Y. zic) Description: z = a simple algebraic variable (IMPVC handles vectors) r = residual. derivative. Specifying the unknown quantity (pressure or voltage) as dependent on the residual of the sum of the flows allows it to be adjusted until the sum is really zero. where the junction has flows or currents that sum to zero (Kirchoff's Law). algebraic constraints are defined by an expression that evaluates to a residual. Z ) Here the Y's are the state variables and the Z's are the algebraic variables.46 IMPLC Form: z = IMPLC(r. Examples The example Tank with Boiling Benzene in Appendix A illustrates a PI controller with the implicit operators. state. Must be in DERIVATIVE The implicit operators must be in DERIVATIVE sections. One use of this feature is in solving for pressure or voltages at junctions. macros. The aircraft example ACRFTS also uses IMPLC. taken as a vector with respect to all the algebraic variables again taken as a vector. or system variable name. The state and algebraic variables can be seen more clearly in the following: Y = F(Y. is a non-singular matrix.e. a floating point constant. and they cannot be skipped over in logical structures such as PROCEDURAL or IF-THEN-ELSE blocks. This is now expressed for scalars as: Language Reference Manual 74 . then this variable name must not be used as another initial condition.

this is transformed into an integration statement and an algebraic constraint as follows: y = INTEG(yd. Since we must be able to solve the residual relationships for Z.t). 0. yic) z = IMPLC(G(Y.e.0) DAE Implementation The acslX translator builds up vectors for states. yic) z = IMPVC(g. yic) In actual implementation. derivatives. for vectors: y = INTVC(f.t). and initial conditions using the INTEG and INTVC operators. Z). and initial guesses for the algebraic variables (to the initial condition vector). yd = IMPLC(F(y. Derivative It sometimes is not possible to extract the derivative explicitly from the left-hand side of an equation.y = INTEG(F(Y. These now look like the following: Language Reference Manual 75 . zic) or. residuals (to the derivative vector).yd. case we have overloaded the IMPLC and IMPVC syntax by defining a second variable on the left. zic) where now F and G are vectors that have been filled with derivatives and residuals respectively in a separate operation. this means that the partial of G with respect to Z must be non-singular. At this level. we have added to these vectors the algebraic variables (to the state vector). Z).yd. so that the model equations are expressed as: To handle this. The acslX translator builds a complete vector of states and a complete vector of residuals for all the component parts.. For scalars. yic) yd = IMPLC(F(y. Of course scalar and vector variables can be used and mixed freely. the above equation would be written: y. i.

a1 a2 a3 derivatives d1 d2 d3 ... The usual problem is finding the algebraic (Z) variable at the very beginning when the initial guesses may be far from the true solution. Language Reference Manual 76 .. ig1 ig2 ig3 This matrix is the one used in the Gear stiff algorithm since every time the derivatives are evaluated the Z variables are simultaneously adjusted to force the residuals to zero. The nonlinear equation solver to find the Z variables is similar to the one used by the runtime ANALYZE command. zic) Description: Where Z.. this iteration usually converges in one or two evaluations using the Newton-Raphson step. 4.47 IMPVC Form: z = IMPVC(r. R. and ZIC are arrays of the same size and correspond to algebraic variable. residual.states s1 s2 s3 .. and initial condition. It essentially computes a Newton-Raphson step: and a steepest descent step: Then it takes a linear combination of these two calculations depending on how successful the iteration is or has been.. Since changes are usually small from one iteration step to the next. The mechanization of this operator is explained under IMPLC above. respectively. r2 r3 ICs ic1 ic2 ic3 .

b) rv(1) = a + b rv(2) = c .48 INCLUDE Form: INCLUDE ‘filename’ Description: Where `filename' is in single quotes. Example: INCLUDE ‘. and/or TERMINAL sections with their matching END statements. the residual name is equivalenced directly into the array of residuals and no extra assignment statement is generated. TERMINAL INCLUDE files can contain separate INITIAL. The residual array cannot appear any where else as a state. The array size may be one. DYNAMIC. or initial condition.: 1.Restrictions apply to the IMPVC operator that are similar to those for vector integration. a simple undimensioned variable can be used instead. IMPVC cannot be used in an expression. 4. 2. 3. or. algebraic variable. DYNAMIC. In this case. Language Reference Manual 77 . INITIAL.e. xz) 4./mod1. INTVC. equivalently. The INCLUDE file must comprise complete acslX statements and must result in a valid program when combined with the surrounding code. it cannot be a literal constant or an expression.inc’ Procedure The INCLUDE statement directs the acslX translator to suspend reading statements from the current file and read the statements from the INCLUDE file. i.b END x = IMPVC(rv. The initial condition must be a variable name. Example: PROCEDURAL(rv = a. These blocks are added to the current sections being built as the acslX translator works its way through the model definition file..

Sorting Code within the INITIAL section is not automatically sorted. 4. then brought into a DERIVATIVE section in a larger model by means of INCLUDE statements.inc' INCLUDE `autopilot. END Description: The INITIAL keyword identifies the beginning of a section of code that is performed just once at the start of each run.. Language Reference Manual 78 . i. The INITIAL statement must have a matching END statement. at any nesting level. DERIVATIVE INCLUDE `seeker.49 INITIAL Form: INITIAL . NOTE: MACROs with INITIAL sections cannot be called from within PROCEDURAL sections. e. Multiple INITIAL sections Any number of INITIAL sections may be used within a program. This is because at the moment the INITIAL keyword must be at a PROCEDURAL nesting level of zero...e. the SORT keyword can be used.inc' INCLUDE `airframe. Refer to Chapter 3 for rules of explicitly structured programs.. for example).inc' END ! of derivative Nesting INCLUDE files can themselves contain other INCLUDE statements. This feature is particularly useful in conjunction with INCLUDE files and/or acslX macros. If the sections of code to be added need to be in a particular order (so that a variable is defined before being used.g. The translator collects all the INITIAL sections in the order encountered and adds them to the end of the INITIAL section to be executed.Example An example of using INCLUDE files is to break a simulation into modules which are then brought into a skeleton.inc' INCLUDE `actuator. Use the SORT keyword to have an INITIAL section sorted. modules can be developed in separate files with their own INITIAL sections.

e. or system variable name.) deriv = an arithmetic expression of arbitrary complexity. state. ic) Description: state = a simple variable. The type of the arguments to subroutines however cannot be inferred. the first argument is forced to be INTEGER and the second. may contain further INTEG statements. i. derivative. then this variable name must not be used as another initial condition. but then the result is floated according to normal conversion rules.4. If an expression is used. The implementation is that n is the sign of x times the largest integer <= | x |. Language Reference Manual 79 . a consequence of this is that XERROR and MERROR do not recognize the state name. 4. INT could be used as in the following example: INTEGER ibin. REAL..50 INT Form: n = INT(x) Description: The output n is the integerization of the argument x. functions. or macros.51 INTEG Form: state = INTEG(deriv. y = INT(x) In this case. the value of x is integerized.. ic = a simple non-subscripted variable. In the following. CALL mysubr(INT(x1). for example. ibin1 ibin = ibin1 + INT(xz + x*y) Example: INT or AINT can be used on the right side of an equal sign. . or a general expression enclosed in parentheses. both the initial condition and the state are given dummy variable names. If it is a simple variable (preferred).. a real constant. AINT(x2). (INTVC handles integration of vectors. so INT or AINT must be chosen to match the argument type.) Now the arguments won't change type with a change in the acslX translator mode.

In performing integrations. Problems may occur when using this form with the REINIT command at runtime. All integration schemes for the set of first order differential equations in the form: are transformed into: where (0. then the state name can be identified. When the integration statement is alone. 0.e. Initial conditions as expressions If an expression is specified for an initial condition. the integration algorithms utilize two intervals: (1) the integration step size and (2) the communication interval. Equations using the state then follow. the value of the state. The expression is always evaluated and substituted for an initial condition established by the reinitialization operation. see the explanation of the Runge-Kutta fixed-step fourth order algorithm in the section on ALGORITHM. the integration step is the fundamental interval over which the state variables are updated. however. Examples Examples of use of the INTEG statement include: y = INTEG(5. (2.0) + bt w = INTEG(wdot. No finer detail is accessible except by some interpolation method. Implementation All integration in an acslX program is handled by a centralized integration routine. yic) z = p*INTEG(zdot. Note that with suitable conditions on continuity and differentiability.. the expression is sorted in such a way that all components in the expression are evaluated before the state value is assigned in the first (initialization) evaluation of the derivatives. usually by expanding the derivative function in a Taylor series about the current state.0 <= a <= 1.0*al*SIN(th))) Language Reference Manual 80 . in the form Znnnnn) must be used for the state name. For an example of how this is implemented. Different integration schemes approximate the derivative in different ways.0) and h is the integration step size.0*x(1) + c. the mean value theorem guarantees that an a exists that produces an exact answer for the state trajectory. The problem is to find the effective derivative to use in updating the state vector.INTEG may also be embedded in any legal expression as a function that has a single output. Since digital integration is basically a discrete process. embedding it in an expression means that an acslX-generated variable (i. finding it is another matter.

An example of an INTERVAL statement could be: DISCRETE dac INTERVAL dt = 0. or system variables.53 INTERVAL Form: INTERVAL name = floating point number Description: where name is a simple unsubscripted variable name. Integrating vectors The INTVC operator should be used for integrating vectors or multidimensional arrays.1 . except that CINT can be used if the system default name for the communication interval has been changed with a CINTERVAL statement: yy = INTEG(yyd. It is used to define both the name of the variable controlling the repetition period and its initial value. w) ! w is a state defined above zk = INTEG(kk..0. CINT) ! CINT is a system variable 4.52 INTEGER See TYPE. No defaults There is no default for the INTERVAL name or value.. other initial conditions. The following statements are all illegal when used with above example statements.Z in the above is not a state since the INTEG function appears embedded in an expression. A DISCRETE section without an INTERVAL statement is not executed automatically. Initial condition names Names of initial conditions can be only names not used as states. The INTERVAL statement schedules repeated execution of a DISCRETE section and can be used only in a DISCRETE section. 4. END Language Reference Manual 81 . An alternative means of activating a DISCRETE section is with a SCHEDULE statement. yic) ! yic is IC for y defined above zz = INTEG(z*4.

Restrictions The restrictions on the INTEG operator with regard to arrays can be avoided by using this vector integrator operator. a difference can develop. The problem is that decimal fractions (0. If CINT is 0. In order to maintain accuracy. or else the INTERVAL value can be biassed by setting it to. it is possible for small errors in timing to result in a beating or strobe effect.1s by this method is 100 exactly. or at runtime). and xic are arrays of the same size and correspond to state. while a thousand additions of 0.In MINT array The mechanization of the INTERVAL feature is to use the slot in the global MINTERVAL array corresponding to the DISCRETE section.1. The missile example in Appendix A uses INTVC.1 for example) are never exact on a binary machine. derivative. Since CINT is adjusted and INTERVAL statements are not.01. If no INTERVAL statement is placed within the DISCRETE block. Changing value The INTERVAL value may be changed (anywhere in the program.1000001 or 0.0 is used as the default.54 INTVC Form: x = INTVC(xd.1 (not a power of two and so a rounded number) has significant error. If this is an important consideration. a value of -1. and initial condition. 4. This flags the DISCRETE section as not to be executed during the initialization phase. for example. The INTERVAL variable is equivalenced into this array. acslX finds an integer multiplier of CINTERVAL such that the result is an integer (to machine accuracy). It is the value which is current when the DISCRETE section has completed execution which determines the next execution time. xic) Description: where x. The restrictions on the INTVC operator are as follows: Language Reference Manual 82 .099999999 instead of 0. A thousand 0. respectively. The communication interval times are obtained by accumulating integer ones and finding the end point by dividing by ten. Strobe effect When the INTERVAL for activating a DISCRETE section is a decimal fraction. the multiplier is 10. Once the DISCRETE section is on the event list. double precision can help. changes in the INTERVAL value do not affect the next execution time. 0. for example. xd.

The derivative array cannot be preset with a CONSTANT statement since it is cleared automatically to a small number before the derivative evaluation routine is called the first time (at the end of the INITIAL section) after every start. ric) Use in sorted sections only INTVC should be used only in sorted sections or implicit programs. use the block transfer (XFERBR) subroutine to move it into another array before using INTVC. INTVC is the preferred method for integrating scalars if the derivative is a scalar as well. the derivative name is used explicitly and no extra assignment statement is generated. For example. Language Reference Manual 83 .md(5.5. INTVC cannot be used in an expression. and acceleration vectors: DIMENSION r(3). Examples Following are examples using INTVC: DIMENSION x(10). rd(3). 6. it cannot be either a constant or an expression. velocity. 3) r = INTVC(rd.mic(5. ric) since these statements ask for v to be considered as both a state and a derivative at the same time. v. a(3) the following is illegal: v = INTVC(a. ric(3). 7.5). 9. for instance. The initial condition must be a variable name. v(3). 8. Using the XFERBR (transfer block) subroutine and defining an RD (R dot) array. xic) ! vector integration m = INTVC(md. ric(3). A single undimensioned variable can also be used. The derivative array must not appear anywhere else as a state.xic(10). vic) r = INTVC(v. a(3) v = INTVC(a.xd(10). vic) CALL XFERBR(rd = v. and a are range.5) y = INTVC(yd. in which case. and it should not be used in a PROCEDURAL. yic) ! scalar integration x = INTVC(xd. which has been integrated from acceleration and is then the derivative of range).m(5. vic(3). mic) ! matrix integration NOTE: A variable cannot be a derivative in one INTVC statement and a state in another.5). If a state must be used as a derivative (velocity. The array size may be one. if r. the sequence becomes: DIMENSION r(3). vic(3). v(3).

or system variable name. An example using LEDLAG is: xp = k1*LEDLAG(ta1. x[. ta2. derivative. q. x[. If the initial condition ic is not specified. The lag value q may not be zero or else a division by zero results. the name must not be used as another initial condition. e) Language Reference Manual 84 .55 LEDLAG Form: y = LEDLAG(p. has the same restrictions as the initial condition of the INTEG operator. Setting p to zero makes LEDLAG behave like a pure lag (see REALPL).4. it is given a default of zero. Time constants The time constants p and q may be expressions of arbitrary complexity. ic]) LEDLAG(y = p.e. state. ic]) Description: The lead-lag compensator output y is related to input x through the transfer function: Such that: Restriction on initial condition The initial condition. if it is a variable name.. q. It should not be used in a PROCEDURAL. ic. i. Setting p equal to q makes LEDLAG behave like an assignment statement: y = x Use in sorted sections only This operator (as all memory operators) should be used only in sorted sections or implicit programs.

0*t. bb. derivative. state.. with the same restriction as on the INTEG initial condition (i.4.0. -dlmx. The LIMINT operaator holds the integrator at the limit as long as the derivative is of such a sign to drive it further into limit. bb. 0. 1. However. ic. LIMINT and BOUND can be used together to force a hard limit: y = BOUND(0.0.e. or system variable name). 1. LIMINT(2. dlmx) Figure 4-11: Effect of LIMINT Operator Use with BOUND Integrators should not be limited using the BOUND function since the integrator continues to integgrate and then must integrate out of the limit when the derivative changes sign. dlic. the name must not be used as another initial condition.0. tb) LIMINT(y = yd. When the derivative reverses sign. ic. if it is a variable name.0)) Language Reference Manual 85 .0. tb) Description: yd = derivative (variable name or expression) ic = initial condition of y. may be omitted if zero (but comma must be included) bb = bottom bound on y tb = top bound on y Example: The LIMINT operator could be used as follows: dl = LIMINT(dld.56 LIMINT Form: y = LIMINT(yd. 0. the integrator immediately comes off the limit.

57 LOG Form: y = LOG(x) Description: The output y is the natural logarithm of x where x is a floating point variable or expression.LOG(ABS(SIN(w*t))) 4. use the SCHEDULE operator to force iteration until the limit penetration point is found.e.. Use another SCHEDULE statement to find the point at which the integrator comes back out of the limit and execute another DISCRETE section to begin using the calculated derivative again. If it is necessary to find the limit points with more precision. xic. SCHEDULE forces an iteration to the point when X just crosses the symmetric boundary ±xmx. ABS(x)-xmx Varying the limits The limits should not vary in time while the system is in the limit. 4.58 LOG10 Form: y = LOG10(x) Language Reference Manual 86 . xmx) SCHEDULE . In this case. x = LIMINT(xd. especially if the approach is at high velocity (i. and it should not be used in a PROCEDURAL.SCHEDULE alternative The LIMINT operator can penetrate the limit. Example: An example using LOG is: y = a . Use in sorted sections This operator (as all memory operators) should be used only in sorted sections or implicit programs. the LIMINT operator is used and no DISCRETE section is executed. then execute a DISCRETE section to set the derivative to zero. -xmx.XP. large values for the derivative and step size). In the following example. SCHEDULE with LIMINT The integration routine can be forced to step up to the limit by using SCHEDULE.

xmin NOTE: All arguments in the statement are evaluated.e. In the following example. otherwise they have the value of the third argument.GT.machmx. assignment statements are simpler and clearer. RSW is floating point. j2 or x2. j1 or x1.59 LOGICAL See TYPE.. Example: An example using LOG10 is: gdbn = 10. ncount-1) cmal = cmalf(mach)*RSW(mach. The j1 and j2 are any integer expressions. 0.EQ. The LSW function is typed INTEGER intrinsically. ncount+1.GT. therefore. 1.Description: The output y is the common logarithm (i. Example: Examples of LSW and RSW statements are as follows: INTEGER ncount LOGICAL count ncount = LSW(count. when the logical expression p has the value TRUE. 4. x. to the base 10) of x where x is a floating point variable or expression.0. x2) Description: Where LSW is the integer switch. switch is TRUE when x is greater than xmin and FALSE otherwise: switch = x . RSW Form: i = LSW(p. j1. The following statement. x1. x1 and x1 are floating point expressions. The outputs i or y take on the value of the second argument.60 LSW. and RSW is the real (floating point) switch. x/p) Language Reference Manual 87 .0) Alternative for logicals For logical switches. (xcg xcp)/d. j2) y = RSW(p.0*LOG10((dlp**2 + dlq**2)*(w/pi*xmag))**2) 4. results in an error if p becomes zero: y = RSW(p . whether or not they are used.

. xn) Description: The keyname MACRO denotes the beginning of a MACRO definition (if not already within a MACRO definition). or DOUBLEPRECISION) of the output is implied from the arguments.62 MAX Form: y = MAX(x1. 2*jj) w = MAX(wmn.. 1. the following solution is preferable because it eliminates an IF statement: y = x/(p + 1.0. Negative values are considered less than positive values. MINTERVAL Form: MINTERVAL name = real constant Default: name = MINT Language Reference Manual 88 . it denotes special subcommands to be interpreted by the macro processor. Example: The type (INTEGER. x2. a maximum of ten arguments may be included... Within a definition. num2. kw*w) 4. xn) Description: The output y is the value of the maximum argument. see Chapter 5. ..0E-33) The probably of p being -1.Writing the statement as follows avoids the problem of division by zero: y = x/RSW(p .63 MAXTERVAL. nmax = MAX(num1. where the arguments xi are variables or expressions. x2. . For a full description of the macro capability..61 MACRO Form: MACRO name(x1. p) However.0.0E-33 is effectively zero! 4. REAL.EQ. 4. 0.

the elements for DISCRETE sections are ignored. To change MAXT for a specific DERIVATIVE section. The elements in MAXT then correspond to the sections in the order they are encountered in the source code. Fixed step algorithms ignore MINTERVAL. more than one DERIVATIVE and/or DISCRETE section results in MAXT becoming an array.001 MAXTSM = 8. is set.0E-10 Description: Where name is a simple. Language Reference Manual 89 . if any. If the error tag has already been set. MAXTERVAL name (referred to by its default name MAXT hereafter) is a scalar. MINTERVAL If a variable step size integration algorithm attempts to take a step smaller than the value of the applicable MINTERVAL. MAXTERVAL MAXTERVAL is the upper bound on the integration step size for both variable step and fixed step algorithms. Arrays with multiple sections If a program contains only one DERIVATIVE section and no DISCRETE sections. At runtime. The maximum and minimum value of the integration step size can be controlled and renamed with these statements. either the array element or the local name can be referenced. unsubscripted variable. the error tag variable (see ERRTAG). DERIVATIVE MAXTERVAL maxtsm = 0. put a MAXTERVAL statement with a unique name in the section.real constant = 1. a -1 indicates that there is no INTERVAL statement for the corresponding section. then the termination flag is set. however. if the DERIVATIVE section is first in the program.0001 The scalar name given is equivalenced to the array element. for example. If MAXTERVAL is defined outside a DERIVATIVE section. then it is the global default for all DERIVATIVE sections. MAXT(1)=0. MAXTSM is equivalenced to MAXT(1). for example.05 MINTERVAL is similar. except that for DISCRETE sections the MINTERVAL elements contain the value of the INTERVAL statement.

64 MERROR.. H = MIN(MAXT. . This approach decouples control of the step size from the communication interval CINT. if the following statement is in a program. Individual elements cannot be given separate error tolerances. MAXT is the integration step size. a lower bound of MINT is added: H = MAX(MINT.e. For example. CINT/NSTP) For variable step algorithms. Runtime The values of these variables can be set by assignment statements in the program or by SET commands at runtime. It is seldom necessary to change MINTERVAL. XERROR Form: MERROR v1=real constant... and vi are nonsubscripted variable names that are state variables (i.0E-6 then at runtime its value can be changed at the command prompt with: > MAXT1 = 2.Integration step size The integration step size H for fixed step algorithms is calculated from CINT/NSTP (see CINTERVAL and NSTEPS statements) and then bound by MAXT. MAXTERVAL MAXT1 = 1. v2=real constant. vn Description: Where MERROR is the relative error bound. The state itself can be an array. CINT then is the data logging rate. Language Reference Manual 90 . MIN(MAXT.. we recommend setting NSTP to 1 and MAXT to the desired step size.0E-6 Even if the MAXTERVAL and MINTERVAL statements are not included in the program.... but then the errors specified apply to all elements in the array. vn XERROR v1=real constant. XERROR is the absolute error bound.e. the first specification encountered is applied to all integrators that are unspecified. they can be accessed at runtime using the default names of MAXT and MINT. . appear on the left side of an INTVC or INTEG statement that is not embedded in an expression). 4. v2=real constant. i. If any relative or absolute errors are specified.. and each can be set separately without affecting the other. CINT/NSTP)) Control of fixed step integration For fixed step algorithms.

xic) y = INTEG(yd. Example: The type (INTEGER.. Language Reference Manual 91 . y=1. is set TRUE and the run aborted. the step size is reduced appropriately. which can potentially be a problem. the allowable error bound is defined to be: Ei = MAX (Xi. where arguments xi are variables or expressions.0*INTEG(zzz. The MERROR and XERROR statements have meaning only for the variable step integration algorithms and are used to limit the error introduced at each step. the ERRTAG variable. The actual state is a generated variable name in the Znnnnn form that is placed in the translated assignment statement instead of the INTEG operator. Negative values are considered less than positive values. xn) Description: The output y is the value of the minimum argument. . REAL.0.Example: MERROR x=1. 4. or DOUBLEPRECISION) of the output is inferred from the arguments. Mi |vi| max) If any of the predicted errors in an integration step is greater than the corresponding allowable error Ei. the absolute error dominates.. yic) z = 5. k5) maxtc = MIN(period/nstmn. 0.66 MINTERVAL See MAXTERVAL. If the error is still too large after the step size has been reduced to the minimum (MINTERVAL). ilo = MIN(imn+1.65 MIN Form: y = MIN(x1. Absolute error is used to cover cases when the variable is near zero. A maximum of ten arguments may be included.0E-4. Usually relative error is the important consideration. j. x2.0) + COS(x) Note that z in the above example cannot have any error bounds specified since it is not a state.0E-6 where: x = INTEG(xd. Based on the maximum absolute value of a state variable |vi |max since the start of the run (a continue runtime command is considered the start of a run in this context). maxtxz) 4. For states that are always less than 1. if any.

idiv) fis = MOD(INTEG(fisd. The output type is always INTEGER. where x1 and x2 are constants. . This function differs from INT or AINT. Example: NINT could be used in a subroutine argument list as follows: CALL mysub(NINT(v1). etc. The actual implementation can be written as: x1 = where [ ] is an integer with magnitude of not more than the argument and with the same sign. twopi) 4.) 4. The type (INTEGER or FLOAT) of the function and the output is inferred from the arguments. k. idiv.69 NSTEPS Form: NSTEPS name = integer constant Language Reference Manual 92 . The generic MOD function is preferred over the more specific AMOD1.68 NINT Form: n = NINT(x) Description: The output y is the nearest integer of x where x is a floating point variable or expression. which truncate the input.67 MOD Form: y = MOD(x1. x2) Description: The output y is the remainder of x1 divided by x2. fisic). icount icount = 100 + MOD(j*k+100. and from ANINT.4. which is the nearest whole number with output of type REAL or DOUBLEPRECISION. variables. Example: Examples of MOD are: INTEGER j. or expressions. MOD0...

Setting NSTP to a fairly large number (1000. which is then increased automatically as the run progresses until it reaches the most efficient size. for example) starts the routine at a small step size. MINT is ignored so the step size is calculated by: H = MIN(MAXT. CINT/NSTP) We recommend that NSTP be set to 1 so that the integration step size can be controlled by MAXT. If the first try is too large (i. until it finds a small enough step size to start off.Default: name: NSTP integer constant: 10 Description: Where name is a simple. Fixed step algorithms For fixed step algorithms (IALG = 3. Setting NSTP to a relatively large number is a means of helping a variable step algorithm start at an appropriate size. nonsubscripted variable. the step size H is determined by: H = MAX(MINT. i. the algorithm reduces the step size and tries again. for example: NSTEPS nstp1 = 1 MAXTERVAL maxt1 = 0. Variable step algorithms The effect of NSTEPS with variable step algorithms differs from that with fixed step algorithms. MIN(MAXT. or 5). NOTE: Beware of leaving NSTP at a large value and switching to a fixed step algorithm. CINT/NSTP)) In other words. For variable step algorithms..e. The NSTEPS statement defines the integration step size in terms of the communication interval. 4. The NSTEPS statement can also be used to rename the variable something different from the default of NSTP. the communication interval is divided by NSTP and then the results is bounded by MINT and MAXT.. specified based on knowledge of the plant dynamics. Type The variable named in the NSTEPS statement is automatically typed INTEGER.1 Language Reference Manual 93 . if the estimated error is larger than the allowed error). NSTEPS is the number of integration steps in a communication interval.001 CINTERVAL cint = 0.e.

For DISCRETE sections. For DERIVATIVE sections. Band limited white noise is implemented by this Ornstein-Uhlenbeck function. For a random number generator in a nonsorted section. use MAXTERVAL to enforce this constraint. s) OU(y = t. NSTEPS becomes an array of length ZZNBLK (the number of sections in the program). thus eliminating any problem of having to include the current integration step size in the standard deviation of the random variable. the slot in NSTEPS is ignored and INTERVAL is used for the step size of any integrations.70 OU Form: y = OU(t. m. 4. The Ornstein-Uhlenbeck process maintains a constant source of power over a specified frequency band. It should not be used in a PROCEDURAL. Array of NSTP When a program contains more than one DERIVATIVE and/or DISCRETE section. The operator is implemented by generating a correlated noise sequence from the general formula: Language Reference Manual 94 . so casual use of GAUSS into a low pass filter leads to ill-defined variation of this quantity as the step size is changed. The elements of the array correspond to the sections in same order as they appear in the program. which can be set either globally or else individually for each section. A normal random number generator (GAUSS) delivers a fixed total power (RMS value). the break frequency is 1/( (2p t) Hz m = mean value of y s = standard deviation (RMS value) of y The OU operator may be used only in a sorted section or implicit program. s) Description: t= low-pass filter time constant. use GAUSS or UNIF. each slot contains the appropriate value of NSTEPS. Usually the low frequency power density is important.With this procedure. the data logging rate (CINT) is decoupled from the integration step size (now simply MAXT1) so that each can be set independently without affecting the other. NOTE: that in general the roll-off time constant t should be at least twice the size of the maximum integration step. but the frequency spread depends on the current step size. m.

An example using the OU operator is: Language Reference Manual 95 .e.. i. But: so: and now the sequence can be expressed by where gi is a Gaussian random variable of zero mean and unit variance.where: t = correlation time constant D t = sample interval wi = Gaussian random variable In order to find the wi that produces the correct noise power such that: square the above equation for n i+1 and take the expected values: It can be assumed that the random drive is uncorrelated with the noise sequence.

71 PARAMETER Form: PARAMETER(p1 = e1[. -. Placement in program The PARAMETER statement must appear in the program before the parameter is used. Expression The expression (ei) can consist of literal constants. or N. K.. /). even if they begin with letter I. real.noise = OU(ta1..Parameter already defined NAME Example: PARAMETER statements are useful for defining things like array sizes and for keeping the definitions in one place. The symbolic name may then be used whenever an integer. L. the translator produces an error message: . Include an INTEGER type statement for any integer PARAMETER variable names before they are used.0 Language Reference Manual 96 . Type INTEGER PARAMETER variables are not automatically typed INTEGER. v(maxdim). logical. PARAMETER names.) Description: The PARAMETER statement associates the symbolic name with an expression that can be made up of constants and/or previously defined parameters but not variables. or character constant would normally appear in the program code. Dictionary The PARAMETER name pi does not appear in the program dictionary and is replaced everywhere by the value of the corresponding expression ei.. r(maxdim) CONSTANT v = maxdim*1. *. sigma) 4. otherwise.maxdim). mean. INTEGER maxdim PARAMETER (maxdim = 5) DIMENSION a(maxdim.. and arithmetic operators (+. p2 = e2] . J. For example. M.

PROCEDURAL blocks are required only in sections that are sorted. enand vi are nonsubscripted variable names while ei may be variables or expressions.. Calculated variables are needed because they tell the sorter where to put the procedural in relation to calculations. i. the code within the PROCEDURAL block is not sorted by the acslX translator..e. informing the sort routine to place the block before reference to any element of the array A. y. as follows: PROCEDURAL(a = x.. The variable names may belong to arrays. Array example As an example. z) a(1) = x + y a(2) = y + z END Language Reference Manual 97 . The PROCEDURAL keyword denotes the beginning of a block of PROCEDURAL code to be executed in the sequence given.. An acceptable form would embed this sequence in a PROCEDURAL block.. v2. END Description: output list = v1. e2. . vn input list = e1. in which case the entire array must be filled within the block. States and constants do not need to be included in the argument list because they are available all the time.4. They are permitted but not required in non-sorted sections of the program. The sort algorithm requires that values appear as outputs only once in sorted code.. .. however. The PROCEDURAL header must be paired with a matching END statement. Arguments The header list should contain only nonsubscripted variable names..72 PROCEDURAL Form: PROCEDURAL(output list = input list) . otherwise the error message "Multiply defined symbol" is issued.. the following statements in a sorted program result in the variable A being flagged as defined twice: a(1) = x + y a(2) = y + z This is illegal.

and since it then cannot be moved. a subroutine call may not be sorted correctly. no input or output argument list is necessary. Typical operations which must be enclosed in PROCEDURAL blocks include DO. DERIVT. In breaking implicit loops this way. This also destroys the validity of the Jacobian and all derived quantities such as eigenvalues. DBLINT.Sorting operation The entire PROCEDURAL block is moved by the translator within a DERIVATIVE section so that it is placed after the calculation of all variables on the input list and before the use of any variables on the output list. so it is possible to break algebraic loops for approximate solution by omitting one of the loop variables from the PROCEDURAL input list. IF. NOTE: Statements involving memory operators should not be included in PROCEDURAL blocks because parts of these operators must be separated for sorting. Use IMPLC to handle algebraic loops. The IF-THEN-ELSE block does not require a PROCEDURAL even in sorted sections. and OU. Although other variables may be present on the list. zeros. The acslX translator never looks inside the PROCEDURAL block to ensure compliance with the list supplied. and array calculations. When required PROCEDURAL blocks should always be used in sorted sections around code constructs in which the order must not be changed. Language Reference Manual 98 . The entire DERIVATIVE section can be made a PROCEDURAL. the last value of the variable is used. With subroutine calls Another construct which may require a PROCEDURAL is the subroutine call. Be warned however that the results change with step size and a variable phase shift is present in traversing the implicit block. Enclosing subroutine calls in PROCEDURAL blocks or using an equal sign in the subroutine argument list are methods of clarifying input and output lists for the translator (see CALL). With algebraic loops Experts may lie in specifying what is on the input/output lists. etc. LIMINT. CMPXPL. If acslX is not informed which arguments are inputs and which are outputs. initialization in the INITIAL section is required. Since this variable is used before it is calculated. sorting is only with respect to variables calculated within the same DERIVATIVE section. which is satisfactory in a large number of cases. The sort operation never moves code across section boundaries. GO TO. It is better to use more small PROCEDURALs rather than fewer large ones. These operators are BCKLSH.

y = r. REALPL.Integration operators Using integration operators (INTEG.. END 4. The PROGRAM statement is the first line in an explicit model definition.. END Description: Where string may contain any number of characters. The character string is not used in any way and serves merely to identify the model file and listing. etc.e. which are ignored. use DERIVATIVE rather than PROGRAM..74 PTR Form: PTR(x.73 PROGRAM Form: PROGRAM [string] .. but for a title with more than one word. This approach is required because some system macros have INITIAL sections.. It must be accompanied by a matching END statement to terminate the model definition. 4. th) Description: The polar to rectangular operator resolves angle q (which must be expressed in radians) and radius r into Cartesian coordinates x and y (with the same units as r) by the following equations: x = r cos q y = r sin q Language Reference Manual 99 . Example: PROGRAM a missile 6DOF simulation For implicit programs (i.) inside PROCEDURAL is not illegal but does not make sense. only derivatives can. use the comment indicator. A DERIVATIVE statement can include a name. DERIVATIVE ! title of program . which expect explicit structure with the PROGRAM statement. those with no explicit structure statements). States cannot be computed procedurally.

0) at the beginning of the first integration step following the exact turn-on time. Do not use PULSE as a strobe to periodically activate parts of a program. The output is always turned on (y = 1.0 or 1.0) starting at the first integration step at which time equals or exceeds tz. width) Figure 4-12: Mechanization of PULSE Function Language Reference Manual 100 . Example: PULSE could be used as follows: drive = k*PULSE(tdrive. The independent variable. rt2 = lrt. Thus. period. Note that the integration step size may affect the answers in that too large a step could cause the pulse to seem to stay on indefinitely. w) Description: Where y is a pulse train (0. default T. The period is p and width is w. it can only stand alone. The width is not synchronized to the integration step size. p. drives the PULSE function.75 PULSE Form: y = PULSE(tz. as shown in Figure 4-12. This is a job for DISCRETE sections executed by means of INTERVAL statements or the SCHEDULE operator.This form is not a functional representation since there are two outputs. this statement cannot be embedded in an expression. fi) 4. An example of PTR is: PTR(rt1. The width cannot be zero. so it should be significantly larger than the step size.

starting at a specified time tz.76 QNTZR Form: y = QNTZR(p.tz .oldsig) Figure 4-13: QNTZR quantizer function 4.77 RAMP Form: y = RAMP(tz) Description: The RAMP function generates a linear ramp of unit slope.0 . T < tz y = T . x) Description: Where x and p are real variables or expressions. This is a zero centered system. Example: An example of QNTZR is: epq = QNTZR(ep. RAMP starts at the first integration step that equals or exceeds tz. signal .4. T > tz Example: An example of a RAMP statement is: z = k1 + k2*RAMP(tramp) Language Reference Manual 101 . as shown in Figure 4-13. The output y is the value of x quantized in discrete steps of resolution p. It is another way of applying a dead zone to the independent variable. The output can be expressed as follows: y = 0.

or system variable name. but it cannot be zero or division by zero results. ic]) REALPL(y = p. or single precision argument x to a single precision value.4.e. 4. if it is a simple variable (the preferred form).79 REALPL Form: y = REALPL(p.. i. Language Reference Manual 102 . Figure 4-14: REALPL operator macro The initial condition has the same restrictions as the INTEG operator. state.78 REAL Form: REAL(x) Description: This function converts an integer. this variable name must not be used as another initial condition. x[. ic]) Description: The REALPL operator produces a first order lag where output y is related to input x through the transfer function: where: y(0) = ic Figure 4-14 lists the macro to implement this operator. double precision. The time constant p may be an expression of arbitrary complexity. x[. See DBLE for a discussion of usage. If the initial condition is zero. See also REAL as a single precision floating point variable type under TYPE. it may be omitted. derivative.

Accelerometer example RESET could be used for example in calculating the initial conditions on accelerometer filters in a missile simulation. the equivalent of RESET("NOEVAL"). If the undefined initial conditions are preset in a CONSTANT statement (0.Example: An example of a REALPL statement is: xm = k3*REALPL(ta3. To obtain the nominal acceleration. the output of the accelerometer filter is used later and if initialized indefinite leads to an arithmetic error. Be sure that unknown initial conditions have reasonable values to prevent arithmetic errors (division by zero. the derivative subroutine calculates body acceleration using the state variable names. and the aerodynamic coefficient data looked up to obtain force coefficients. Calculation of all state variable derivatives is attempted. the missile velocity vector must be rotated into the missile axes. the angle of attack determined. so there was more reason to use this operator. If the RESET("EVAL") statement is placed at the beginning of the INITIAL section. Previously. This code must be expressed in terms of the initial condition variables rather than the state variables unless the RESET operator is used.80 RESET Form: RESET("EVAL") RESET("NOEVAL") Description: This special operator is provided for use in the INITIAL section to initialize the state variables and optionally perform intermediate calculations. then the calculation can proceed and the meaningless numbers can be disregarded. In the above example.5 is a useful default number). NOTE: The problem in using RESET is that the process is not selective. states had been initialized at the end of the INITIAL section. Now only RESET("EVAL") is needed. x) 4. The important consideration is that all the calculations be able to proceed without arithmetic errors Language Reference Manual 103 . Argument The arguments EVAL and NOEVAL specify whether or not a complete derivative evaluation is to be attempted. for example). When states are initialized The states are initialized at the beginning of the INITIAL section.

Note that the second argument of the arc tangent (ATAN2) is modified by the addition of a very small amount. x ) Figure 4-15 shows the mechanization of this operator as a system macro. th = x.81 RSW See LSW. y) Description: The rectangular to polar operator resolves the input Cartesian coordinates x and y into polar angle q (which is in radians in the range .82 RTP Form: RTP(r.83 SAVE Form: SAVE Description: The macro tables containing the macro names and packed definitions are written (in binary) on the acslX system macro file.0 to return an angle of zero instead of indefinite.4.0. it can be used only in the standalone form as shown. The SAVE operation allows you to maintain your own files of macros separate from the system file. 0. This enables inputs of 0. Thus.p to + p depending on the magnitude and sign of x and y) and radius r (which has the same units as x and y) by the following equations: q = ATAN2 (y. Language Reference Manual 104 . 4. this statement cannot be embedded in an expression. 4. Figure 4-15: RPT operator macro This form of the operator is not a functional representation since there are two outputs.

scale factors. ymx) 4. no user macro definitions are present.Normally the system reads the contents of the user macro file into the macro definition tables before the translation begins. ymx) Description:: ymn. The SCALE operator is then used in the TERMINAL section of an explicit program to establish scale factors for subsequent PLOT commands.e. It is used only when two or more plots need the same. ymx = ymn. thus destroying the original contents. smx = scaled minimum and maximum to be used on a plot (i. 4. smx = ymn.XP. i. 4.84 SCALE Form: SCALE(smn. rounded multiples of 1. The SCALE operator rounds the inputs so that they are suitable for plotting. the following statement replaces actual minimum and maximum values with the rounded ones: SCALE(ymn. The inputs ymn and ymx are usually collected in the DYNAMIC section by keeping track of the smallest and largest values of the variable of interest.XN. The action of SAVE is to write the current contents of the macro tables back on this file. 2. .XZ.. The first two arguments need not be distinct from the second.e. . you must have WRITE permission on the current macro file. or 10). = following expression specifies time at which block is to be activated (may not be used in a DERIVATIVE section) Language Reference Manual 105 .AT. To use SAVE. ymx = minimum and maximum values smn.AT.85 SCHEDULE Form: SCHEDULE SCHEDULE SCHEDULE SCHEDULE block/flag block/flag block/flag block/flag . . originally unknown. time-expression real-expression real-expression real-expression Description:: block = optional block name of DISCRETE section to be executed after the state has been advanced just over the boundary flag = optional flag name that is automatically made type LOGICAL and set TRUE when the event has occurred (may not be an array) . If such a file does not exist..

tstp. it is set TRUE just before the DISCRETE section is executed. `Stop on time'). however.XN. = zero crossing (negative direction only) of following expression initiates execution of a discrete event.) .XP.GE. The block / flag is optional.XZ. = zero crossing (positive direction only) of following expression initiates execution of a discrete event. generally within a single DISCRETE section.XZ. then is set back to FALSE.5 ENDIF IF(f2) THEN y =-2. x+0.5 TERMT(t . = zero crossing (positive or negative direction) of following expression initiates execution of a discrete event.5 SCHEDULE d/f2 .0 END ! of Initial DERIVATIVE x = SIN(t) SCHEDULE d/f1 . as in the following example: PROGRAM INITIAL y = 0.9 END DISCRETE d IF(f1) THEN y = 2. This realexpression must be a true function of the state variables in that the same set of state variables must produce identical values of the function no matter how many Language Reference Manual 106 . SCHEDULE can be used without a block or flag in order to force integration to a certain point. flag cannot be used without a block also being present. the zero crossing of which (in the appropriate direction) defines the event.5 ENDIF END ! of Discrete END ! OF Program Expressions The time-expression defines a time (real value) of the independent variable at which the event is to be activated. stays TRUE during execution of the section.XZ. . x-0. Flag setting If a flag is specified. The real-expression defines a function.CONSTANT tstp=4. Flag example The flag is available to handle logic..

In the example. default TRUE) to FALSE.cannot proceed WEDITG A summary of the activity at the time of an event (i. Digital controller example Another example is a digital controller. the position of the section among the DERIVATIVE and DISCRETE sections in the program) executed. the macroscopic view shows the velocity changing discontinuously (by the coefficient of restitution) at the instant of bounce. This output can be suppressed by setting runtime system symbol WEDITG (write event description. which Language Reference Manual 107 . From a macroscopic viewpoint. Bouncing ball example In the example of a ball bouncing. If the real-expression is not a true function. discontinuities arise from simplifying the model and observing the system behavior in a macro time scale. Nature has no real discontinuities given a sufficiently fine time scale. the following error message may be produced.e. The automatic variable step algorithms such Adams-Moulton or Gear's Stiff (IALG = 1 or 2) or Fehlberg (IALG = 8 or 9) reduce the step size in the region of a discontinuity in F at the expense of increased processing time. Event vanished . The integration algorithms used to solve equations in the form: conventionally require the function F to be continuous and differentiable within an integration step.e. the event finder is activated in the first line and the window is narrowed over five iterations. In the microscopic view. the spring constant of the ball is taken into account and all the forces of deformation are calculated. The last two lines of the summary give the values of the independent variable and the zero crossing expression along with the number of the DISCRETE section (i. Handling dicontinues The SCHEDULE operator handles the introduction of discontinuities into an otherwise continuous simulation. and it is debatable how well the error control mechanism works in the event of a discontinuity in one of the state variables. significantly increasing the model complexity but eliminating the discontinuity.intermediate evaluations occur.. the output is an analog control voltage through a digital to analog converter (DAC).. finding and narrowing thewindow and calculating the value of the expression at each evaluation) is produced at runtime at each occurrence of an event.

the solution on either side of the discontinuity can be treated as piecewise continuous. an iteration brackets the event to a finer and finer tolerance until a specified accuracy is reached. the zero velocity plane in Coulomb stiction/friction. Such surfaces include the zero height plane in the bouncing ball problem.jumps discontinuously at the output time points. The integration algorithm advances in discrete steps which at some point takes the model across the critical surface. Switch point If a point of discontinuity can be located. State events can be visualized as occurring at surfaces in state space.e. . In the friction Language Reference Manual 108 . A possible penalty is that the variable step algorithms may have to be restarted after a discontinuity since they keep track of an estimate of derivatives (a Nordsieck vector) which is probably invalidated at a switch point. t) = 0 where g is a single-valued function of the state variables and time. Changing boundaries In actual fact. where the boundary is a general surface in state space. Mathematically the problem is stated: . the situation can be complicated by the boundary function changing when the state equations switch from F1 to F2.. the designer deciding which time scale of events is important for model validity. so no iteration is required. the integration step can always be taken as the minimum of the normal step or the time left to the event. a voltage jump) for efficiency. hysteresis. which is a wall perpendicular to the time axis. Finding the event In the special case of a time event. and Coulomb friction. Time vs. voltages cannot change discontinuously since finite capacitances are always present and must be charged through some sort of resistive network. Time events can always be defined as state events. where the plane in state space distinguishing the event can be expressed by: g(x. state events Two types of discontinuity are encountered in general simulation models. but for efficiency they are extracted as a separate case. Examples of changing boundaries include backlash. and the critical temperature plane for a reactor shutdown event. For state events. the problem is in finding the exact crossing point. A simulation normally takes the macroscopic view (i. At a microscopic level. one we call a time event and the other a state event.

Time events can be used inside IF or DO constructs in unsorted sections such as DISCRETE or INITIAL. Multiple IF statements are dangerous. NOTE: State events cannot be scheduled from IF constructs because acslX has to keep a count of the state event statements. Digital controller example An example of the use of time events is the modeling of a digital controller with an analog to digital converter (ADC) sampling values from the continuous process.004 SCHEDULE dac . the event list would fill with these markers.. the block is executed immediately after the current DISCRETE block has finished. END Execution time If the value of the time-expression is less than the current time.AT. form of the SCHEDULE statement. The time event SCHEDULE must be specified in a DISCRETE section (or in the INITIAL section) and may not be included in a DERIVATIVE section. For example. Time in the continuous section can never go backwards (with the exception of the entire model moving backwards as described in Chapter 8). which covers all the bases so a value is not left around inadvertently.010 outp = F(sampled inputs) CONSTANT dlt = 0. If this were executed in a DERIVATIVE section where the code is executed and re-executed many times under the control of the integration algorithm. the code for the relevant DISCRETE sections could be as follows: DISCRETE adc INTERVAL tsamp = 0. a delay while control output values are computed. use an IF-THEN-ELSE construct. for a sampling time of 10 msec and compute delay of 4 msec. but also as switch closings to activate solenoids and control valves.AT. A simple example in an INITIAL section to execute DISCRETE switch: INITIAL CONSTANT swtime = 10. 4. T + dlt END ! of adc section DISCRETE dac Language Reference Manual 109 . and then transfer of these values. instead. the boundary function is zero velocity when the body is sliding and applied force exceeding breakout force when the body is stuck.. swtime .86 SCHEDULE Time Event Specification A time event is defined by the .model. usually as voltages through DACs. Every execution of the time event operator places a marker in the event list to execute a block at a particular time.AT.0 SCHEDULE switch .

and time events must be specified within DISCRETE or INITIAL sections. When control is transferred to the continuous integration section. The output can be calculated but must be hidden from the continuous world because it actually comes out of the DAC some time later. it is hidden by giving it a different name (OUTP). The communication interval for data recording is itself classed as an event and entered on this list. The SCHEDULE statement in the ADC section asks for the DAC time event to be executed at T + 0. every time the DERIVATIVE or DISCRETE section is executed). The Discrete Sampled Compensator example in Appendix A shows how time events can be used in a digital data system.. Language Reference Manual 110 . When all DERIVATIVE blocks have arrived within the tolerance EPMX (explained in the section on the state event mechanization) of the time event point. which is ordered in time.004 sec after the ADC section has executed. except for possible quantization noise. the name used by the continuous part of the simulation. Time advances the 4 msec and the DAC block is executed.e. The DAC block is entered on the event list and control returns to the integration algorithms to advance the continuous state variables until the next event occurs. the only time it is executed is when it is SCHEDULEd from the ADC section. No INTERVAL Since the DISCRETE section DAC has no INTERVAL statement.010 sec. advancing with the normal step size selection mechanism until a short step is required to reach the event.! Executed 4 msec after adc out = outp END ! of dac section The DISCRETE section ADC contains an INTERVAL statement which ensures that the section is executed every 0. it first checks the event list for the next time event and makes this its goal. When it is executed. DISCRETE scheduling itself As mentioned above. In the program. so they are all available as though they had been passed across an ADC channel. only DISCRETE sections can be scheduled for execution. transferring the hidden output variable OUTP into OUT. thus replacing the INTERVAL statement. Scheduling time events in DERIVATIVE or DYNAMIC sections results in the same event being scheduled many times (i. A DISCRETE section can schedule itself for execution in the future. the event is deleted from the event list and the associated DISCRETE block (if any) is executed. Event list All time events are kept on the event list. all the state variables in the continuous section have been advanced to the sampling time.

In the BOUNCE section. Bouncing ball example An example of a state event specification is finding the bounce point of a ball dropping (under the acceleration of gravity) with the following statement: SCHEDULE bounce . 4. h which executes a DISCRETE block called BOUNCE when height h crosses zero in the negative direction. (cross negative). All state SCHEDULE statements must be evaluated at every DERIVATIVE evaluation because they are known by the count of order of appearance. (cross positive).XN. the DERIVATIVE code is executed. then there is no need to test for an event at each step. the integration system saves all the state variables at the beginning of a step. If no active state events are present. velocity is reversed and modified by the coefficient of restitution as follows: DISCRETE bounce v = -kr*v END Flag vs. Each call to the state event handler increments a counter so that acslX knows how many events are in operation. The forms of SCHEDULE which apply to state events are . makes the step without regard to Language Reference Manual 111 . They may appear only in DERIVATIVE sections.4.XZ.XN. (cross zero).XP. NOTE: The state event SCHEDULE operator must be placed in a DERIVATIVE section. but using SCHEDULE operators with separate DISCRETE blocks can remove that requirement. multiple DISCRETE Handling multiple events with a single block usually requires a flag so that the events can be sorted out.87 SCHEDULE State Event Specification Specifying an event boundary activates an iteration within the integration algorithm to cross the event boundary with a minimum step size. . but execution is slightly more efficient if it is placed at the beginning of the section since only the code necessary to evaluate the event zero crossing expressions is executed when the time comes to test the event. It may not be placed inside a PROCEDURAL. and . The statement may be placed anywhere in the DERIVATIVE section. It may not be skipped over by the use of GO TOs or other control transfer mechanisms (such as the various IF constructs) since acslX needs to keep a count of the SCHEDULE statements. Implementation After the integration algorithm has been initialized.88 SCHEDULE State Event Mechanization At the beginning of a simulation run.

then no event is signalled. If the expressions are functions of only state variables. for instance). a count is kept and when all expressions corresponding to the state event definitions have been evaluated. 0) GO TO event Starting on zero Note that if the previous expression EXPP is exactly zero. The first derivative evaluation during the initialization process saves the current value of the real-expression (EXPR) as the previous value (EXPP). the DISCRETE block (if any) associated with each active event is executed so that model conditions can be changed. in which case time is advanced to the most positive edge of the window by calculating the appropriate step size from the saved state condition (at the beginning of the activating step). The code is as follows: IF(expr*expp . Iterating to step The iteration within a step proceeds until the zero crossing is within a window less than the tolerance. then the smallest value of the independent variable (time) is selected. then the remainder of the code is skipped. Multiple events Any number of events can be specified and they all are found in sequence.AND. 0 . it is possible that more than one event occurs in the same step Language Reference Manual 112 . An advantage of this method is that the expression can start at zero and no event is indicated until the expression returns to cross zero.LT. At each subsequent step. Testing is not done during intermediate evaluations of the derivatives since these are extrapolations of much lower accuracy in general than the final step. the current value is tested to see if EXPP and EXPR bracket zero. the event specification is sorted to a position just after the calculation of its inputs.NE. Executing DISCRETE Once the step has been taken. thus minimizing the code executed at the threshold test phase. and then calls the DERIVATIVE evaluation block one last time to see if the states have crossed the event threshold. An event is defined as starting from a non-zero value. expp . If they are functions of intermediate calculated quantities (dynamic pressure. However. A crossing point is estimated for each event activated within a step. with the new value crossing or landing exactly on the zero point. Since this final evaluation is not part of the evaluation of the derivatives and states (its purpose is only to evaluate the expressions required to execute the DISCRETE block associated with the event). Usually there is only a single event pending since it is separated in time from other events.any events. the sorter does not have to move them.

which allows the event to be found. SIGN example An example of a discontinuity to which the SCHEDULE operator can be applied is the SIGN function. i. slopes and states changed. The DERIVATIVE equations can then remain continuous through the event. it sticks when the velocity crosses zero. fixed step algorithms such as Runge- Language Reference Manual 113 . Any current events are thus taken off the active list since the expression must now cross zero from the other side (. the switching function fi can be written: fi = RSW(stuk.e. In the case of friction. Newtons of force when the body is stuck. Re-evalutate DERIVATIVE After each pending event has been serviced by executing the associated DISCRETE block. it returns the third argument. When the body is stuck (STUK is TRUE). when the expression ABS(FORCE) . The following statement: force = SIGN(kslid.) or return to the other side in order to cross zero from the same direction (.XP. ABS(force) . which affects the integration step when the velocity crosses zero. the event occurs when the force acting on the body (FORCE) exceeds a breakout force (BREAKF). i.e. The units of the zero crossing function thus change depending on the regime in which the model stands. The actual integration step that crosses the boundary has trouble with the discontinuity.e. In some cases it fails to cross the boundary entirely when the actual step is taken by adding up the weighted intermediate calculated (i.. When the body is not stuck.XZ. -veloc) indicates that FORCE is to change discontinuously to oppose the velocity..) for the next event. and the integration routine restarted so that past derivative history is discarded.and then each associated DISCRETE block (which may be the same one called by different events) is executed in servicing each event. the DERIVATIVE routine is executed one last time with a flag set to cause replacement of all previous values (EXPP) with current values. veloc) where the function RSW (real switch) returns the value of the second argument if the first argument is TRUE. and meters per second for velocity when it is not stuck. otherwise..BREAKF crosses zero. Handling discontinuities Confining discontinuities to the DISCRETE event servicing block is a sound approach.breakf. DISCRETE can change switching function Note that the execution of the associated DISCRETE block can set variables in such a way as to change the switching function completely.

input . also work correctly. NOTE: The event finder also has a problem with the acslX operators which have their own internal memory (or state variables) when it is unable to back up and reproduce the previous step before iterating to find the zero crossing. CMPXPL. so the zero crossing finder may find the expression on the same side of zero after the single step backup.dl). the backlash operator BCKLSH works by using the statement: yl = MIN(MAX(yl. First order filter One workaround for these situations is to put the variable through a first order filter with a fast enough time constant to act the same as a step so the event finder iterates on the continuous (though steep) function.. -veloc) END ! of discrete Now the force is continuous and differentiable (a constant) in the continuous section. Algebraic operators (such as STEP and RTP). OUTPUT is the previous value YL (Y last) unless INPUT exceeds YL by more than the backlash value DL. giving the integration algorithm an easier task. The operators that have internal state variables (potential sources of problems with SCHEDULE) are: BCKLSH DBLINT DERIVT GAUSS IMPL LIMINT OU UNIF Operators that are implemented as differential equations (such as REALPL. For example. however. Another approach is to write a routine to perform the same function using integrators that can be handled by the zero crossing finder. Backing up may leave YL at the same value. at which point it stops with the message Event vanished. height TERMT(height . Such a high frequency pole can increase computer running time. a better implementation is as follows: force = fslid SCHEDULE handl . DELAY is configured so that it works with SCHEDULE.XZ.LE. veloc . To stop on impact with the ground.Kutta fourth order with first order extrapolators). For this case. which pass a signal directly with no memory..XN. do not do the following: SCHEDULE . input + dl) output = yl Thus. NOTE: Be careful finding a stopping condition at the boundary since the integration algorithm must take a step that crosses the boundary before recognizing that an event has occurred. and TRAN) have no problem. 0) Language Reference Manual 114 . DISCRETE handl fslid = SIGN(kslid.

Comments can be placed only after the last statement on a line since everything after an exclamation point (!) is ignored by the translator. The output y is the sign of x2 times the absolute value of x1. statement Description: A semi-colon (. zsign) 4. Instead use a DISCRETE section.The step that makes HEIGHT less than zero also sets the STOP flag so the run is terminated before it can back up and find the zero crossing.. END DISCRETE stop TERMT(.9 ! Stop Run 4. or expressions.91 SIN Form: y = SIN(x) Language Reference Manual 115 ..) separates any valid acslX statements.90 SIGN Form: y = SIGN(x1.tstop). for example: SCHEDULE stop . Example: TERMT(t.GE..) Form: statement . x2) Description: Where x1 and x2 are floating point constants. SIGN could be used as follows: z = k*SIGN(zbase. variables. height . 4.89 Separator (. CONSTANT tstop=4.TRUE.XN. Then the handler DISCRETE block is executed to set the STOP flag and terminate the run. `Stopped on zero height') END Now the state event iteration takes the step to or just below the HEIGHT equal to zero plane.

4. or TERMINAL).5. DISCRETE.0 <= y <= +1. DYNAMIC.0) 4. lam) Description: The output y is the square root of x where x is positive floating point variable or expression. This feature could be used for INITIAL sections which have been built from a number of INCLUDE statements without regard to correct order. Example: SIN could be used: p = INTEG(y*SIN(w*t + fi). In order to catch and handle any errors gracefully. Example: An example using the SQRT function is: miss = SQRT(xmt**2 + ymt**2 + zmt**2) Alternative functions Compilers on different systems handle situations such as negative arguments to the square root function differently. A negative argument results in a exception trap on most computer systems. the result is in the range (. which must be in radians.92 SORT Form: SORT Description: The SORT keyword notifies the translator to sort all statements from the keyword to the end of the section (INITIAL.Description: The output y is the sine of the floating point argument x.0).93 SQRT Form: y = SQRT(x) y = SSQRT(x) y = FSQRT(x.1. All DERIVATIVE sections are sorted automatically. 0. Both convert automatically to Language Reference Manual 116 . SSQRT (signed square root) and FSQRT (flow square root) functions have been added to the library at Version 11.

single or double precision. flows become zero and noise in the calculations can result in small values on the negative side of zero. The signed square root function takes the square root of the absolute value of the input. In these situations. The flow square root function switches to laminar flow when the pressure drop equals the second argument. and then gives the result the sign of the input. the BOUND function would probably be used to keep the variable from going negative. but also add a TERMT operator to stop the run and report the problem. it should not only use SSQRT to avoid a numerical problem. In some models. Figure 4-16: Signed Square Root Function (SSQRT) Language Reference Manual 117 . Some mathematical models are physically incorrect when the state of the system brings the simulation to the point where it is taking the square root of a negative number. The functions are listed in Figure 4-16 and Figure 4-17. In this case.

94 STEP Form: y = STEP(tz) Description: The STEP function output y changes from zero to one at a specified value tz of the independent variable.Figure 4-17: Flow Square Root Function (FSQRT) 4.0 . The result is y = 0. T < tz y = 1.0 . T > tz Language Reference Manual 118 .

The value is accessed by name(arg1). respectively. arg2. for example. list = floating point constants. d = unsigned integer constants (may not be variable names). arg2). two. the independent variables are all listed in the call. n = an unsigned integer constant giving the number of independent variables. or 3. Accessing a TABLE TABLE statements must be defined before the table is referenced. A separate TABLE statement must be used to define each function. the number of constants must correspond to the value of n. 2. arg3) for functions of one.95 TABLE Form: TABLE name. Then the dependent values are listed with the fastest varying argument first. The table is accessed by name and the independent variable. The TABLE statement describes any arbitrary function of one. two. The arguments are of any arbitrary level of complexity. or three variables. d /list/ Description: name = name of the function. this number must be 1. n.5*CLP(mach)*b*wm(1)/mvm More than one variable For a function of more than one variable.4. The values of the independent variable are listed first. or name(arg1. in the order given in the table: cl = CLP(mach. or three variables. name(arg1. The number of function data points must equal the product of the dimensions. A dimension of one is illegal. al) Language Reference Manual 119 . The values of the constants give the number of discrete data points for each successive independent variable. The number of these points must equal the sum of the dimensions. if CLP has been defined as a table with one independent variable and MACH is a variable calculated previously in the program: cl = CLP(mach) Accessing as a function The table can also be accessed within a statement as with any function: cd(1) = 0.

Language Reference Manual 120 . b3. respectively. f22. a2. the first statement is correct but the second results in a translator error message. 10 / 10*0.. f121. f134. b2. 1. values may be identical but a breakpoint must never be less than a preceding value.7 results in 6. The breakpoints are 2 for F1ARG. Values between breakpoints in the table are interpolated linearly.0 / TABLE tab2.Breakpoints increase monotonically All data points for the independent variables (breakpoints) must be of monotonically increasing order. Each TABLE statement may contain as many data points as desired. 3. f224. f11.Bad break data count. and three variables are shown below. In the following tables. f232 & . f12. two. f113. f1. a2.. b1..g. 1. f213. and 9 for F3ARG and the number of data points are 2.. f211. However. 5 for F2ARG.0. 10*0. f132. 4 & / a1. and 24. Once the function has been defined.. f123. f111.7 repeated five times). f23 / c1. . / b2. b1. 2. f233 & . Repeat counts Repeat counts may be used in the data specification (e. i. The first breakpoint appears first in the data. f223. c3. 3. the breakpoints and data points are read into separate locations by the translator and cannot be specified in the same repeat count. TABLE F3ARG. f221. f114. 5*6. f231 & . f112... f222. 3 / a1. b3 & f13. 2 / a1. f212. c2. a2. 2. TABLE F1ARG. & . f122. f124. c4 Linear extrapolation and interpolation If the calculated values of the independent variables lie outside the range specified by the TABLE statement. f131. 6. TABLE tab1. it may be referenced just like any other acslX function. f21. f234 / 1. f133. 10 / 20*0.0 / . f2 2. Examples: Examples of tables of one. the values for the function are obtained by extrapolating linearly from the last values given.e. f214. TABLE F2ARG.

The elements of the array cannot be accessed in the program because parentheses indicate a function call.50. To change the function value at Mach 1.5 to Mach 1.83. For example. 0.0). DISPLAY. 0. call: CALL getav(cm. 1. 1.51. 0. This array name is entered into the dictionary and it may be accessed in by SET. 1.65 To change the breakpoint from Mach 1. 1. 0.92. returned in array value D. then the breakpoint values follow. 0. array The function name followed by parentheses (cm(2. 1.6. 5 / 0. while the table function name without parentheses stands for the array that contains the function and breakpoint values.0.5. Order of data entry One point to note is the order of data entry into the array: The function data is listed first. second. 0. 0. 0. the following runtime command can be used at the command prompt: CM(4) = 0. but the array name can be passed to a FORTRAN subroutine (or function) to return the value of the array element.8.51.5.2. etc.5. third argument.2.6 Multidimensional tables For multidimensional tables.15 / This statement produces an array CM(10) in which the first five elements contain the function values 0. 0. 3. the position in the table is calculated (5 + 4) and the command becomes: CM(9) = 1.5 & .5. to access the third element of array CM. 2. 0.15 and elements six through ten contain the breakpoint values 0.50. An array is also defined with the same name and enough storage to contain both function data values and the corresponding argument breakpoint values. d) where the subroutine is defined at the end of the acslX program: Language Reference Manual 121 . Function vs.83. This order is the opposite from that listed in the TABLE statement since it was considered that the more normal operation at runtime is changing function values rather than breakpoints.Macro and array defined The TABLE operator makes up a macro having the same name as the function so that all references to the TABLE after its definition are caught.92. As an example.8. then the breakpoint data in the order of first. the function data is all listed in the array first. for example) on the right hand side of an equal sign implies a call to look up the function value. 0.0. runtime commands. 2. consider a pitching moment table as a function of Mach number: TABLE cm.

0.96 TAN Form: y = TAN(x) Description: The output y is the tangent of the real argument x.9. however.6.8. 1. sorting can be specified with the SORT keyword. Code in the TERMINAL section is not sorted automatically. 0. Set up the table in the model. 0. n.4.2. 0.97 TERMINAL Form: TERMINAL .0. 10 & / 0. 10*0.SUBROUTINE getav(f. It must be paired with a matching END statement.0. Example: TAN could be used as follows: a = b + TAN(theta) 4. 1.0.. 0.0 / 4. for example: TABLE k. but fill the data by using a multiplier. 1. av) DIMENSION f(1) av = f(n) RETURN END Reading data into array Data can be read into a TABLE array.5. 1. 0. either by calling a subroutine within the model or at runtime. 10*0.0.. Language Reference Manual 122 .0 / or. 0. 10 / 10*0. if the breakpoints are known and only the data is to be filled in later: TABLE k. END Description: The TERMINAL keyword identifies the beginning of the block of code performed at the end of each run. which must be expressed in radians.0 & .

OR. to provide information at runtime on which condition actually terminated the run: TERMT(h . This feature is particularly useful in conjunction with INCLUDE files and/or acslX macros. tmax. vmin.0.GE. and DISCRETE) except PROCEDURAL. (v . It is considered low volume data and so appears on the screen as well as in the print file. Any number of termination conditions may be specified. DERIVATIVE. 0.LE. DYNAMIC. Modules can be developed in separate files with their own TERMINAL sections. the calculations can be placed in the TERMINAL section and executed only at the end of the run. 0. They may appear in any other section (INITIAL. tmax)) or. for example). This means that code introduced in DERIVATIVE or DISCRETE sections appears before code in the explicit TERMINAL section. 4. The `string' argument is an option for printing out user information on the condition that terminates the run.0) .GE. then brought into a DERIVATIVE section in a larger program by means of INCLUDE statements. vmin) . `string']) Description: A run terminates when the logical expression in the TERMT statement becomes TRUE.98 TERMT Form: TERMT(logical expression[. Multiple TERMINAL sections Any number of TERMINAL sections can be used within a program. The translator collects all the TERMINAL sections in the order given. Example An example of a typical TERMT statement is: TERMT((h .LE.To save calculating certain variables over and over again during the simulation run. `Termination on TMAX time limit') Language Reference Manual 123 . `Termination on flying backwards') TERMT(T .LE. `Termination on hitting ground') TERMT(v .LE. and the first condition to become TRUE terminates the run. If the sections of code need to be in a particular order (so that a variable is defined before being used.OR. It is useful to include this argument even when there is only one stopping condition since it confirms the run terminating normally. use the SORT keyword. (T .

With SCHEDULE In some cases. qn. `Termination on hitting ground') For the SCHEDULE operator to work. if the statement above is around.0. `Termination on hitting ground') END ! of discrete stop This procedure is useful for stopping runs at precise events (see. Do not at the same time use an additional statement: TERMT(h ..XN. The result is that the run stops on the other side of the zero crossing rather than precisely on it. the description of stopping missiles at intercept). nd. qd. x) Description: nn = integer constant or PARAMETER name (may not be a variable name).Placement in program TERMT statements can be placed in any of the DYNAMIC. it stops the run at the integration step following the logical expression becoming TRUE. DERIVATIVE. 4. END ! of derivative DISCRETE stop TERMT(. and a DISCRETE section contains the TERMT statement: SCHEDULE stop . In a DERIVATIVE section.. may be a real constant if nn is zero qd = coefficient array for the denominator Language Reference Manual 124 . for example.TRUE. the order of the numerator polynomial nd = integer constant or PARAMETER name (may not be a variable name). For example. A TERMT statement placed in the DYNAMIC section of an explicit program stops the run at a communication interval. the order of the denominator polynomial qn = coefficient array for the numerator (can be an expression). nd. or DISCRETE sections. thereby stopping the run before SCHEDULE has iterated to find the zero crossing. x) TRAN(y = nn. 0. h must actually cross zero. However.LE. a DISCRETE section is executed solely to terminate the run when a state event is detected. it sets the stop flag. h . In a DISCRETE section.. the run stops at the execution following the expression becoming TRUE. qn.99 TRAN Form: y = TRAN(nn. SCHEDULE finds the state event of H (height) crossing zero. qd.

and nn and nd must be literal integer constants or PARAMETER names. Note also that nn and nd must be entered as the numbers themselves. The simple first order transfer functions REALPL and LEDLAG and second order CMPXPL should be used when possible since the code generated is more efficient than that for TRAN. but not variable names. q = 1.0. QD(1) must be nonzero. for example: Language Reference Manual 125 . p. s. Order can be changed by arranging for common factors in the numerator and denominator polynomials. 3. assignment statement. Order The transfer function polynomials are in the form of highest power of s coefficient first and any missing order with its coefficient input as zero. not the number of coefficients. q(4) CONSTANT p = 3. 2. an arithmetic expression of arbitrary complexity Transfer functions in the form of a ratio of polynomials in the Laplace operator. q. may be directly implemented by the transfer function simulation operator.0 out = TRAN(1. 5. variable names are not allowed. NOTE: The order of the denomenator must be greater than or equal to that of the numerator. The order cannot be changed artificially by setting the highest power of the denominator polynomial to zero. note that the s1 term has to be filled in as a zero in the Q (denominator) array. or expression) must be provided. For a transfer function in the following form. If the order of the numerator and the order of the denominator are the same and there is a feedback path around the operator. an unsortable statement block may result. Example In the following example. array element. Requirements All initial conditions are taken as zero. When the numerator is a single value (zero order). in) Arrays Variable names as well as literal constants can be used in the arrays. Some way of calculating the value (constant. 0. For the transfer function: the model code becomes: DIMENSION p(2). however. TRAN is appropriate for higher order operators. 2.0.0.0. otherwise division by zero results. it does not need to be declared in an array. Note that nn+1 and nd+1 numbers are required in the numerator and denominator arrays since it is the order that is defined.x = input.0.

k. Figure 4-18: TRAN operator macro Integration step size When choosing the integration step size for the model.0. the reciprocal roots of the denominator polynomial should be considered.0 z = TRAN(0. 5*x + COS(th)) Macro implementation Figure 4-18 Figure 4-18 lists the mechanization of the TRAN operator as a system macro. 0. This listing is an example of the complexities that can be implemented using macros.100 TRANZ Form: y = TRANZ(nn. qn. qn. x) TRANZ(y = nn. qd. 0. nd. nd.0. 3. 4. x) Language Reference Manual 126 .0. 1. d. qd.only one array is required and the code could be: DIMENSION d(4) CONSTANT d = 1.

Note that nn+1 and nd+1 numbers are required in the numerator and denominator arrays since it is the order that is defined. 2.166667. 0.0 out = TRANZ(3. 0. the order of the numerator polynomial nd = integer constant or PARAMETER name (may not be a variable name). an arithmetic expression of arbitrary complexity Transfer functions in the form of a ratio of polynomials in Z-1 may be directly implemented in acslX by the TRANZ operator. 0 . qn(3) CONSTANT pn = 1. not the number of coefficients.166667 out = TRANZ(1. in) Coefficients If the number of coefficients in the numerator exceeds those in the denominator. 3. make the denominator order the same as the numerator and fill the trailing coefficients with zeros. in) matches: outn = 1*inn + 2*inn+1 + 3*inn+2 + 4*inn+3 Language Reference Manual 127 . the order of the denominator polynomial qn = coefficient array for the numerator (can be an expression or real constant if nn is zero) qd = coefficient array for the denominator x = input. pn. pn.5 CONSTANT qn = 1. Usually the qd(1) element is unity (1.Description: nn = integer constant or PARAMETER name (may not be a variable name).0) and the remainder zeros. for example. In the following example. use a denominator coefficient array with unity in the first element (qn(1) = 1. DIMENSION pn(4). When there are no denominator coefficients.-0. qn(4) CONSTANT pn = 1.-0. 3. note: for which the model code becomes: DIMENSION pn(2). qn. 4 CONSTANT qn = 1.0). Order The transfer function polynomials are in the form of highest power of Z-1 coefficient first and any missing order with its coefficient input as zero. qn. 2.

k1 DOUBLEPRECISION vm(3). Examples: INTEGER k. v2.. dot Variables are considered to be floating point double precision unless typed otherwise. Complex filters For complex Z transform filters. v2. jj(10). . Language Reference Manual 128 ... It is very easy to come up with a filter design that doesn't behave correctly and needs double precision in order to work The TRANZ statement must be placed inside a DISCRETE section. . fred(2. .. vn CHARACTER v1*n... CHARACTER The length of CHARACTER variables defaults to 1 if not specified.5). v2*n. a warning is in order concerning the accuracy of the calculations.TRUE. vn INTEGER v1.FALSE. v2. vn REAL v1. variable names are not allowed. 4. Subscripts must be numerical or a symbol defined in a previous PARAMETER statement. .. vn DOUBLEPRECISION v1.but this is probably better implemented using the HISTORY operator..101 Type Form: DIMENSION v1... or . vn*n Description: Where the vi are either simple variable names or else subscripted arrays with up to six integer constant subscripts separated by commas.. vn LOGICAL v1. 2) LOGICAL flag CHARACTER mytitle*480 REAL x(5. .. v2..... The variables are typed and (optionally) dimensioned at the same time.. . LOGICAL LOGICAL variables can take on values of .. v2.

i. REAL vm(3). Language Reference Manual 129 .1 increments could be written. DOT mvm = SQRT(DOT(vm. then acslX must type these appropriately rather than relying on automatic typing unless double precision mode is always used: DOUBLEPRECISION vm(3). and also states. Arguments A potential problem with mixed single and double precision variables in a program is in their being passed as arguments to subroutines and being returned from functions. The variables can be declared in all of the blocks that are wired together.e. MAXT. The variables can be forced to single or double precision by explictly declaring them to be REAL (single precision) or DOUBLEPRECISION. are changed automatically by the acslX system and cannot be specified their type. quantizing a signal to 0. and initial conditions.Floating point Variables are cast as DOUBLEPRECISION by default. derivatives. All the acslX subroutines change type automatically.vm)) If DOT is written to accept double precision arguments and return a double precision result. CINT. vm) The generic SQRT adjusts automatically to the type of its argument and result. and MINT. Duplicates permitted This is useful in graphic models when declared variables are output from acslX blocks. vm)) If DOT is single precision.. but if any other routines are used. System symbols System symbols such as T. although it is not good programming practice since the value cannot be changed at runtime. Declarations must match exactly. rather than only in the block that computes the variable. provision must be made to force the appropriate type. the DOT product function returns the dot product of two threecomponent vectors. Literal constants Other problems occur when using literal constants as arguments to subroutines. For example. A total velocity magnitude could be obtained by: REAL vm(3) mvm = SQRT(DOT(vm. the opposite must be specified. or a diagnostic is produced. For example. DOT mvm = SQRT(DOT(vm.

the independent variable could be called TIME and be given a negative initial condition as follows: VARIABLE time.104 VARIABLE Form: VARIABLE name [.105 XERROR See MERROR. the low frequency power) depends on the integration step size.4. 4. timeic=-5.0 4. If the variable name T is to be used for temperature. Using the VARIABLE statement allows you to designate the independent variable with a nonsubscripted name. Language Reference Manual 130 . 4. UNIF could be used as follows: drive = k*UNIF(dlo. The value for the initial condition cannot be a name. Variable step integration methods can produce peculiar results. the initial condition name is then also accessible.103 UNIFI See GAUSI. It has an initial value of 0. for example. dhi) This operator is not intended for use in a DERIVATIVE section because the power density (or. tb) Description: The output y is a random variable uniformly distributed between a bottom bound bb and a top bound tb. See OU for details on generating noise in a DERIVATIVE section. ic name [= floating point constant]] Description: The default independent variable is called T. what is usually more important.0 and the initial condition name is not accessible.102 UNIF Form: y = UNIF(bb.

2 • • Macro definitions Macros can be defined: in the program in which they are called. the translator generates the code (often referred to as macro expansion) for compilation. Macros are slightly more efficient and have the advantage of being able to define operators involving integrators and memory functions. On some systems.1 Macro versus subroutine A macro is similar to a subroutine or function in FORTRAN or procedure or function in C/C++ because it is defined once and then can be invoked as many times and from as many places in the model code as needed.. for example). In general.1 Introduction Macro Language Macros are useful for standardizing certain functions for an industry or discipline. The macro definitions are added to the file (i. 5. 5. The translator produces a set of statements in the target language compile file for each macro invocation. but the extra storage used for such statements is usually small. this file must be given WRITE permission. Language Reference Manual 131 . Usually the code is slightly different with each call (because of arguments resulting in different variable names.Chapter 5 5. before the first invocation. Macros are used instead of target language subroutines: • • • if any acslX operators are involved to gain visibility of internal variables for concatenation to generate unique variables for each application of a macro and the new variable values are used for printing and plotting.1. These operators are called from the program. Macros can also be used to capture special expertise for other users to incorporate into their programs. Only translation is required. so stop the acslX build procedure before compilation. From the macro directives. make a local copy of the system macro file and specify this local copy as the macro file for the program to save macro definitions.1.e. Code is generated each time the macro is called. they are cumulative). The program concludes with a SAVE statement (see the SAVE command in Chapter 4) that saves the macros to the current macro file. usually with arguments. in a separate program containing only the macros. so generally it is best to start with a fresh copy of the system macro file. acslX's language can be expanded using the macro capability to define new operators.

1. The number of macro input arguments is not limited.1.. Such a count is not performed and the first MACRO END terminates the definition.z = x) 5.. macro definitions may not be nested because nesting would require a count of the nesting level within the definition to match up with the correct MACRO END.1.b..4 Forms of call Macros can be called in three ways.c). Macro definitions may invoke other macros to an unlimited level of complexity. For example. These arguments must be valid expressions (of arbitrary complexity) with balanced parentheses and any character string enclosed in quotation marks. y = v1 Language Reference Manual 132 . Macro definitions can include INITIAL and/or TERMINAL sections.3 • • • Features Some of the more important features of the macro language are: Variables and statement labels may be locally generated. However. The third form must be used with more than one output. This prevents variables or labels being defined multiple times if the macro is called more than once. Macros may be placed anywhere within an acslX program. the most recent version is used in the expansion. The concatenation operator (#) allows arguments to be placed together without intervening spaces. Function calls return one value and are always in the form of y = func(a. but they must be defined before they are used. • • • 5. The second form. is generally preferred because it clearly identifies the usage of MACRO. it enables generation of unique names with multiple calls to a macro. procedures.5 Concatenation The ampersand (#) is the concatenation operator that allows a substitutable argument to appear next to a character string. and functions. y = MAC(x) MAC(y = x) MAC(y. This makes the statement distinct from subroutine. Its use is discussed in more detail under Macro Definition Header. a useful way of making up variable names. Subroutines or procedures must be invoked using the CALL statement.5. called standalone. In general. variable V1 is accessed in the following expansion: MACRO abc(x) y = v#x# MACRO END abc(1) . A macro may be redefined.

The translated macro body with arguments substituted is referred to as the skeleton.7 Macro definitions The macro definition is a block of code that consists of: 1) Macro definition header 2) Macro directive or acslX statements 3) MACRO END The macro definition header specifies the name of the current definition and a list of dummy reference parameters.. sets it off so it can be substituted: MACRO abc(x) y = v#x#gh MACRO END abc(2) . 5. If the argument is an expression. The translator collects all the code in the order presented (or expanded in the case of macros).1. must be present to flag the translator to return to direct translation. and local labels identified by a RELABEL (see MACRO RELABEL). MACRO END. flagging them for substitution by the actual argument supplied on invocation. and TERMINAL sections can be used in macro definitions.. If a macro name is the same as one already defined. y = v2gh 5. These sections are not sorted unless the SORT keyword is specified. Other names that may be substituted during macro expansion are the ASSIGN variable (see MACRO ASSIGN). either in the system macro file or the current model definition. DYNAMIC. and TERMINAL sections INITIAL. DISCRETE. DYNAMIC. Argument strings are substituted for each appearance of the macro argument name. however. The translator scans the statements in the macro body for the appearance of these names. No substitution would take place in the following situation: MACRO abc(x) y = v#xgh MACRO END An additional ampersand after the x. The definition terminator. care must be taken that the resulting code is correct after the substitution (see the section on macro calls). local variable names identified by a REDEFINE (see MACRO REDEFINE).1. the new macro definition replaces the old one.6 INITIAL. DISCRETE. analogous to dummy arguments in a target language subroutine.The substituted name must be separated from any other characters by either a space or an ampersand. Language Reference Manual 133 . No error message is issued since this is considered to be a feature whereby you can always override an old macro definition.

Arguments p.0*B and z by d everywhere throughout the definition. d) ! definition ! invocation In this example. Form: MACRO identifier(x1. if needed. each element of which identifies the respective element in the argument list at invocation time. xn) MACRO MACRO identifier(p.10 Second form The second macro form is useful when handling arrays of indefinite size. it will be replaced by the ith argument (symbol or expression) when the macro is invoked. constants. r. Anywhere the string of characters xi is referred to in the macro definition.. then a variable named p must not be used in the macro.. r. and s appear. q. r.1. 5. y is replaced by 5.1. The argument p is the dummy reference parameter and may be thought of as a vector. r. but x does not appear explicitly in the invocation.1.. or expressions p = primary argument specifying an array of input expressions q. The secondary arguments q. The first is preferred for most applications send and accept variable names as arguments. and s may be any unsubscripted variable name.g.9 First form The first macro form is preferred for most purposes. the output of the function is the first argument x. and s = secondary arguments giving the names of array dimensions within the macro definition. The second is useful for handling arrays and can be identified by headers starting MACRO MACRO. z) x = y*z MACRO END c = a*mult(5. MACRO mult(x. This form has an extra MACRO in the header. but do not appear in the invocation argument list. in the definition header and may be used in the macro definition. x2.5. q.. 5. NOTE: If p is the name of the argument of a MACRO MACRO. Elements of p that are acslX arrays must be dimensioned prior to the macro Language Reference Manual 134 . s) Description: identifier = macro name xi = variable names. You specify only p in the invocation. e.8 Macro definition header There are two types of macros that can be defined. y. .0*b.

invocation.. and p(7) are not dimensioned arrays. the first argument. Arguments q. and s may also be thought of as arrays. Here the space is all important. It serves as a separator for symbol identification.. Note that macros written in this second form are very hard to read since no mnemonic symbols can be used for the arguments. p(4) is replaced by the expression e+f. low) ! definition ! invocation Arguments at invocation time are delimited by either commas or an equal sign. q(3). Symbols substituted for the secondary arguments r and s act similarly to q except they provide the second and third dimensions respectively. and third dimensions. The following example. In the example above. h(4.. the fourth argument. p(1) appearing in the definition body is substituted by the symbol a. r. p(4). q.12 Concatenation The concatenation operator is the ampersand (#). and q(7) are scalar have a dimension of one. Thus. Any reference to q for an array accesses the first dimension. g(2. so the correct form is the following: ASSIGN z TO k 5. They refer to the first. for example. e+f. definition statements . r(5) is 3 and s(6) is 2.e. at invocation time. q(2) has the value 9 from the dimension of b in the previous DIMENSION statement. but only those elements corresponding to arrays in the p array contain values.. 5. It is used to allow a substitutable argument to appear next to a character string. combination of the above. shows how to generate unique symbols Language Reference Manual 135 . in this example. MACRO MACRO head(p. 4.1.11 Substitutable symbols In general. blank) or the concatenation symbol (#) in order for the scan to operate. s) . h. but p(1). -. 2) head(a.. second. *. MACRO END DIMENSION b(9). b = 5*d. g. respectively. r. q(4). the substitutable symbols must be separated from other character strings by non alphanumeric characters (i. but is removed when the macro is translated into the skeleton. 3).1. p(3). so q(1). If the above macro MULT contained the statement: ASSIGNz TO k the symbol z would not be identified for substitution. +. The array expressions are restricted to the following forms: 1) P(i) where i is a literal integer constant 2) P(n) where n is the ASSIGNed variable 3) P(n±i).

5. and symbols in the statements are substituted for the appropriate argument at invocation time. All these directive statements begin with the word MACRO to indicate that they are instructions to the macro processor. joe) results in the statement: A = SAM*FJOE where the new symbol FJOE has been defined.by adding an F to the third argument of the MULT macro and including it in an expression. The new name would be written F#Z (F concatenated with Z).g.14 Labels All macro directive statements can have labels attached to them. These labels must be distinct from any labels attached to non directive statements.13 Macro directive statements This section lists alphabetically the macro directive statements that may be included within a macro definition. e. If only the made up symbols are important. Language Reference Manual 136 . i. but can be used to provide extremely flexible control of the macro processing at invocation time. The acslX statements themselves produce code. the same expression is generated but now the symbol JOE is not be entered in the symbol table. 5.1.1. The argument in double quotes has the quotes removed and the literal string of characters (including any blanks) is substituted for the appropriate argument symbol. the argument may be quoted using double quotes as: a = mult(sam. The label is inserted after the leading MACRO of the directive. "joe") In this case. The labels on non directive statements control the sequence at runtime execution. MACRO s1: RELABEL i MACRO s2: CONTINUE MACRO s3: END NOTE: These labels control the sequence of the macro processor at macro invocation time. The above call MULT enters a symbol JOE on the symbol table.e. X = Y*F#Z# Invoking the MULT macro with: a = mult(sam. These statements do not produce code... the labels can be used by MACRO GO TO and MACRO IF directives.

MACRO END sam(x. Example: Using the second header type: MACRO MACRO sam(P) ! definition MACRO ASSIGN n .5. the current value of N refers to the Nth argument in the macro call list at invocation time. The ASSIGN directive assigns the number of arguments in the macro call to the variable N.1. Language Reference Manual 137 . z) ! invocation Within the macro definition.. s) of the second type of macro. subtracted from. The value of N may be added to. All arithmetic operations are performed in fixed point integer.e. N is always an integer. the secondary arguments (p. N is 3 since the invocation to SAM contains three arguments. multiplied.1. y(3) 5. q. i.. or divided. Whenever N is used as part of the dummy reference parameter subscript.16 Arithmetic macro directives Form: MACRO MACRO MACRO MACRO INCREMENT i DECREMENT i MULTIPLY i DIVIDE i Description: Where i is an unsigned integer constant. which is z p(1)(N) = x(3) p(n-1)(N) = Nth element of the (n-1) argument. y. r.15 MACRO ASSIGN Form: MACRO ASSIGN n Description: Where n is a symbol (usually N is used).. or a macro argument name that has a literal numeric integer value. and therefore: p(n) = Nth argument. If the dummy reference parameter contains a variable subscript. the variable must be the same as the variable used in the ASSIGN statement. These directives provide arithmetic operations on the ASSIGN variable N.

17 MACRO CONTINUE Form: MACRO CONTINUE Description: This macro directive is included so that it can be labeled.1. the dimension of the second argument.1. 5. MACRO L1: CONTINUE The MACRO IF or MACRO GO TO can then branch to this section within the definition. as. 5. q) ASSIGN n MULTIPLY 0 s1: IF(n = q(2)) s2 INCREMENT 1 GO TO s1 s2: CONTINUE On exit from this section. The action is the same as using a MACRO GO TO that transfers control to the macro definition terminator (MACRO END). In this way N can be used as a counter or control variable in addition to its basic purpose of transmitting the number of arguments from the invocation. the following code can be used: MACRO MACRO MACRO MACRO MACRO MACRO MACRO MACRO bil(p. 5. To make the ASSIGN variable equal to the dimension of the second argument.1.19 MACRO DIVIDE See Arithmetic macro directives.1.18 MACRO DECREMENT See Arithmetic macro directives. N (the assigned variable) has the integer value Q(2).Example: MULTIPLY 0 makes the ASSIGN variable zero. for example.20 MACRO EXIT Form: MACRO EXIT Description: The EXIT directive statement stops the generation of code at invocation time. 5. MACRO EXIT in a PROCEDURAL Language Reference Manual 138 .

The IF directive provides for a conditional branch to the macro directive label s inside the current definition if the relation e1 = e2 holds. Language Reference Manual 139 . integer constants. 5.21 MACRO GO TO Form: MACRO GO TO s Description: Where s is a statement label attached to another MACRO directive. if the definition is as follows: MACRO MACRO .e.block can result in translator errors because the END statement will be missing from the PROCEDURAL block.22 MACRO IF Form: MACRO IF(e1 = e2) s Description: Where s is a macro directive statement label and e1 and e2 can be the dummy reference parameters corresponding to the call list. They must not be expressions.1. The strings e1 and e2 are tested character by character (excluding blanks) for equality..23 MACRO INCREMENT See Arithmetic macro directives.. In order to compare a character string with a string passed as a macro argument. i. 5.1. 5.1.. The GO TO provides an unconditional branch to a labeled macro directive within the definition. character strings. MACRO MACRO test(arg) IF(arg = top) LAB1 LAB1: CONTINUE END and the invocation is: test("top") then the macro will expand via LAB1. or the identifier used in the ASSIGN directive. the string must be enclosed in quotes when the macro is invoked and then the MACRO IF compares the argument with an un-quote string.

1.1.27 MACRO RELABEL Form: MACRO RELABEL 11.1.24 MACRO MULTIPLY See Arithmetic macro directives. The primary use is for you to diagnose your own errors at invocation time and print out informative messages.. starts with a letter although it may contain numbers after the first character). 1n Description: Where li is an alphanumeric label (i. The MACRO REDEFINE statement should appear before any statements which reference the redefined variables..5.).26 MACRO REDEFINE Form: MACRO REDEFINE v1. This directive lists the character string on the output device. The generated variables consist of the letter Z followed by five digits. including type declarations. It will override any global list control.e. v2.1.. REDEFINE identifies the variables as being locally defined and specifies that they are to be replaced by unique symbols at each invocation.. The messages appear with the word "WARNING" at the beginning for easier locating. any character string except $ Description: Error messages may be handled within the macro at invocation time by this PRINT directive statement using any a string of any characters except the dollar sign ($) or semicolon-colon (. .. vn Description: Where vi are variable names appearing in the body of the macro. . RELABEL specifies that all symbols in the list are locally defined statement labels which are to be substituted by unique generated labels at invocation time.. 5. 5. 12. 5.25 MACRO PRINT Form: MACRO PRINT or . These labels must be attached only to acslX Language Reference Manual 140 ..

28 MACRO STANDVAL Form: MACRO STANDVAL arg1 = c1. . MACRO STANDVAL P(i) = c1. For example: MACRO MACRO test(p) MACRO ASSIGN n ..1. they must be at the end of the list.. statements that use arg xyz: CONTINUE MACRO END 5.. arg2 = c2 .. MACRO L1: CONTINUE MACRO IF(n=5) L99 mac2(p(n)) MACRO DECREMENT 1 MACRO GO TO L1 MACRO L99: CONTINUE. integer. or logical. In the second form.. Omitted arguments If arguments can be omitted from an argument list. Language Reference Manual 141 . then the constant is used in its place. Description: Where argi are dummy argument names and ci are literal constants that can be real (single or double precision). P(j) = c2. i and j are unsigned integer constants.. not macro directive statements (statements beginning with the word MACRO).25 . If the specified argument is not given in the macro call. call another macro from within the loop. The STANDVAL statement is used to provide standard values for arguments of a macro. The following RELABEL statement is illegal because the label name begins with a number: MACRO RELABEL 110 It could be replaced by the following statement: MACRO RELABEL L110 To relabel within a macro loop. MACRO mac2(arg) MACRO RELABEL xyz MACRO REDEFINE k DO xyz k=1....statements..

which is substituted with the appropriate name from the macro invocation.1 Sampler A sampler can be created with a switch and two zero order holds.) At the sample time. ic1. The invocation could be: sample(y = dl. ic2) MACRO STANDVAL ic1=0. and YIC is the initial value of Y. x is the variable to be sampled. dt INITIAL samp = ic END DISCRETE d INTERVAL dt=0. x. (This requirement for macros is distinguished from target language functions.0 dt = dl samp = x END MACRO END Note that the output name must always be included in the argument list.2. Language Reference Manual 142 . begins as follows: MACRO cmpxpl(y. 5.. p. A macro to handle this could be defined as follows: MACRO sample(samp. q. This action saves the input value x as output value SAMP. For convenience. A call to this operator in the model source code then need not specify the two initial conditions if they are to be zero: CMPXPL(y = t1. the entire sequence can be embedded in a macro and invoked as a function.Placement The STANDVAL directive must immediately follow the macro header in the definition if it is used at all. x..0.2 Macro examples The following examples of macro calls demonstrate some of the uses of the directive statements and direct parameter substitution. where the single result is returned into the name of the function. ic2=0. t2. for example.0 . The operator for the second order transfer function (complex pole). dl. Example: Several of the acslX operators use this statement. ic) MACRO REDEFINE d. the DISCRETE section is executed. yic) When the sampler is repeated for every DL of the independent variable. yp) 5. x.

5. 5.2.4 REDEFINE The REDEFINE statement ensures the variable I will not conflict with any other use. 5. The header designates P as the primary variable and Q as the secondary variable. 5. b) where x is a scalar and a and b are vectors previously dimensioned in a DIMENSION statement. q) MACRO RELABEL loop MACRO REDEFINE loop MACRO IF(q(2) = q(3)) mll MACRO PRINT Conflicting dimensions in dot product MACRO EXIT MACRO mll:COONTINUE PROCEDURAL(p(1) = p(2).2. Since it is a function and thus has one output. The dimension of the vectors may change. a potentially disastrous effect.q(2) p(1) = p(1)(i)*p(3)(i) loop: continue END ! of procedural MACRO END !Invocation of dot macro DIMENSION y(10). p(3)) p(1) = 0. if not. z(10) dot(x = y. the DOT product is undefined and a macro error Language Reference Manual 143 . so it should not be specified in the call. z) Figure 5-1 for a listing of a DOT macro.5 Dimensions The test of Q(2) and Q(3) is needed to see if the second and third arguments have the same dimension.2.2 Dot product The following call could be used to take the vector dot product of two arrays a and b: x = DOT(a. See MACRO MACRO dot(p. a program variable I could have its value changed when the macro is executed.2.3 Second type The second form of the macro header is required in order to handle the array dimension. If this were omitted. the operator can be embedded in an arithmetic expression of arbitrary complexity. Q accesses the dimension of the corresponding primary argument.0 DO loop I = 1.

q(2) p(1) = p(1)(i)*p(3)(i) loop: continue END ! of procedural MACRO END !Invocation of dot macro DIMENSION y(10). z) Figure 5-1 results in the macro being translated into the following code: INTEGER Z99999 X = 0.0 DO 99999 Z99999 = 1. q) RELABEL loop REDEFINE loop IF(q(2) = q(3)) mll PRINT Conflicting dimensions in dot product EXIT Language Reference Manual 144 . p(3)) p(1) = 0. the DO loop summation is formed.6 MACRO IF The MACRO IF must branch to another macro directive statement.message is printed. the variable I is changed into a unique translator-generated variable (Z99999). q) MACRO RELABEL loop MACRO REDEFINE loop MACRO IF(q(2) = q(3)) mll MACRO PRINT Conflicting dimensions in dot product MACRO EXIT MACRO mll:COONTINUE PROCEDURAL(p(1) = p(2). The call shown in MACRO MACRO dot(p. 5. hence the label is attached to a MACRO CONTINUE. this code precedes the expression evaluation and a translator-generated variable in the form Znnnnn is used in the expression for the output variable name. 10 99999: X = X + Y(Z99999)*Z(Z99999) If the call to DOT is embedded functionally in an expression. Note that Q(2) and Q(3) are replaced at invocation time (as distinct from execution time) by integers corresponding to the array size of the respective arguments.2. If the dimensions are correct.2. 5. This label can not be attached to the following statement since it is not a macro directive statement but an assignment statement. z(10) dot(x = y. MACRO MACRO MACRO MACRO MACRO MACRO MACRO dot(p.0 DO loop I = 1.7 Expansion At invocation time.

2. for example.2.2.11 Invocation The basic equations for different vessels (tank 1 and tank 3. Total pressure is the integrated net flow divided by a volume. 5. The macro definition is thus: MACRO tank(n) f#n#i = (p#n#i .12 Expansion The invocation TANK(3). a macro is defined for a gas holding tank. for example) can now be established in the model by the statements: tank(1) tank(3) 5.2. z(10) dot(x = y. generates the following translated code: Language Reference Manual 145 .10 Definition In this example. The flow into the tank is calculated as the difference in pressure divided by a resistance. z) Figure 5-1: DOT product macro and invocation 5.8 Pressure tank This pressure tank example illustrates the use of concatenation in macros.0 DO loop I = 1. All REDEFINEd variables have this form. p(3)) p(1) = 0.q(2) p(1) = p(1)(i)*p(3)(i) loop: continue END ! of procedural MACRO END !Invocation of dot macro DIMENSION y(10). p#n#ic) MACRO END 5. An alternate approach is to use the concatenation feature to build unique symbols that are available for plotting or printing.2.p#n#)/r#n#i p#n# = (INTEG((f#n#i – f#n#o)/v#n#. This technique can also reduce considerably the length of the argument list.MACRO mll:COONTINUE PROCEDURAL(p(1) = p(2).9 Concatenation One of the problems with using macros is the tendency to generate large numbers of dummy variables (Znnnnn) which have no mnemonic meaning. 5. A similar example (physiological benchmark PHYSBE) appears in Appendix A. using a long argument list is the other alternative when unique symbolic names are required.

arguments can be expressions. argument lists become long and complicated. psource.2. Variables which must be defined elsewhere are the input pressure node P3I and the output flow F3O. multiplication. MACRO tank(n.g. but if you have control of the model design. v3. p3 = p3i.(fo))/v#n#. p3ic) 5. (p1 .2. and transposition can be defined by macros. e. An alternative TANK macro could have the output flow and downstream pressure specified in the argument list since these are likely to be expressions. but argument lists have the advantage of flexibility in naming. negation.. Language Reference Manual 146 . the volume V3. and initial pressure P3IC. for example.P3)/R3I P3 = INTEG((F3I . pi. fo) f#n#i = (pi – p#n#)/r#n#i p#n# = INTEG((f#n#i .13 Constants and variables Constants must be defined elsewhere for the resistance R3I. but can an alphanumeric variable name). in addition. the argument list is simple: one argument (usually a literal constant.F30)/V3. as follows: tank(1. Macros for these four operations are listed in Figure 5-2 through Figure 5-5 and the macro for matrix multiply (MMUL) is discussed in detail.15 Advantages of concatenation The trade-off in deciding how to define the macro can be stated generally as follows: Without the concatenation feature.2.16 Matrix operations Matrix operations such as addition. p#n#ic) MACRO END The invocation of this macro could.14 Alternative form An alternative form of the macro invocation without the concatenation feature would have to be a separate statement such as the following for each tank in the system: tank(f3i.F3I = (P3I . substitute a variable name for inlet pressure PI and an expression for the outlet flow FO.2. you can use this to advantage. r3i. f3o. P3IC) 5. This macro then makes available to other sections of the simulation the input flow F3I and tank pressure P3. 5. Using the concatenation feature. 5.p5)/r51) The disadvantage of the concatenation approach is the inflexibility in naming convention.

2). The arrays must be dimensioned before the macro call because the acslX translator makes only one pass over the input source code to generate text. in which array dimensions Q and R are used in the definition and are picked up automatically by the operator provided they have been defined prior to the macro call.2. 5.18 Dimensions All matrices must be doubly dimensioned. 3) MMUL(x = a. a) 5. n) for row vectors or (n. b) MMUL(y = x. Reversing the order of the calls for x and y would not work. Output matrices have their dimensions calculated and defined appropriately. Figure 5-2: Matrix multiply macro 5.Note that matrix operations are usually characterized by an n-cubed operation count and can be expensive for large matrices. input matrices a and b are dimensioned in a DIMENSION statement. has been dimensioned because it is the output from the macro in the previous line. B) Language Reference Manual 147 .2. b(2. Only matrices input to the macro must be dimensioned. the second pass is a sorting operation.2.17 Matrix multiply macro The MMUL operator (listed in Figure 5-2) uses the second type of macro definition header. DIMENSION a(3. In the following example. x. 1) for column vectors. Single dimension vectors may be dimensioned either (1.19 Invocation The calling sequence for MMUL is defined as follows: MMUL(C = A. which is input in the third line.

Figure 5-3: Matrix add macro Language Reference Manual 148 .which performs the matrix multiplication expressed mathematically as: [C] = [A][B] The macro definition includes a test that the row dimension of [A] is equal to the column dimension of [C]. a message is written out to you. if not.

MMUL(b. c)) which can be expressed mathematically.0) where the DOT product macro is embedded in the argument of the SIN function. respectively. a and b in this case correspond to the second and third argument of the macro. in the given order: Y = [A][B][C] Figure 5-4: Matrix negate macro Figure 5-5: Matrix transpose macro 5. it must be invoked with specific arguments listed for substitution. the output is the (understood) first argument.0*SIN(DOT(a. b)/4.3 Macro invocation Once a macro has been defined. only one output (a single number) should be produced by the macro. 5. An example of this form is: x = 5.1 Single output One form of call is to embed the macro name in an arithmetic expression.Three matrices can be multiplied together with a call such as: MMUL(y = a. Language Reference Manual 149 .3. For this form.

a. which has two forms as follows: DOT(x = a. i. massic) which produces the line of code: MASS = INTEG(WIN . xd = a. an expression for net flow out becomes: accum(mass = win. no error would result if the operator were invoked as follows: DOT(x. The solution.. MASSIC) 5. Only a single numerical value can be passed across the equal sign of an assignment statement. Passing more than one value across an equal sign is possible only in macro and subroutine calls. is to Language Reference Manual 150 .3. For example.3.3 Argument substitution The substitution of macro arguments is by replacement of the character string forming the argument with the substitutable name. Where expressions are used. when the operator precedence can cause a problem. w1. b) is an assignment statement and the name x is not substituted for the first argument.4 Use of parentheses This result is not exactly right. 5. Note especially that x = DOT(a. xic) In this call. the wrong answer can be obtained if parentheses are not placed around the argument.w2. consider a matrix integration operator which might be invoked as follows: matint(x.5. w2. two entire vectors are the output of the operator and have their values effectively passed across the equal sign. b) DOT(x. since the second flow WP2 has been made positive.WP1 + WP2. wp1 + wp2. consider a macro to integrate a difference in flow rate as follows: MACRO accum(tot.2 Standalone forms An alternative form of the call is as a standalone statement. b) The equal sign in the first form is to indicate to the reader that x is an output. The program determines the actual inputs and outputs as it processes the statements produced by the macro. On the other hand.e. ic) MACRO END At invocation. a = b) but it would be misleading to the user.3. ic) tot = INTEG(w1 .

(WP1 + WP2).surround the substitutable name with parentheses.(w2). ic) MACRO END Now at substitution the executed statement is: MASS = INTEG(WIN . ic) tot = INTEG(w1 . w2. Language Reference Manual 151 . MASSIC) It is not necessary to enclose the first parameter. w1. The macro above should have been defined as follows: MACRO accum(tot. or used as a divisor in the macro division. in parentheses since any expression substitution gives the correct answer. Trouble usually arises when arguments are negated. W1. multiplied. divided by other variables.

Figure 6-1: Block Libraries Window Language Reference Manual 152 . each library contains related building blocks that can be used to build simulation models in the Block Diagram Window. Each library and the related building blocks are described in this section. Custom libraries can be created. When opened. to customize the workspace for specific applications.Chapter 6 Standard Block Libraries The Block Library window contains libraries.

6. i1 and i2.ge.not. the second input i2. AND Returns a logical value of the logical AND of the two inputs i1 and i2. or equal to. i2 GT (>) Returns a logical value of whether the first input i1 is greater than the second input i2. i2 LT (<) Returns a logical value of whether the first input i1 is less than the second input i2. i2 LE (<=) Returns a logical value of whether the first input i1 is less than.and. or equal to.ne. Y = i1 . i2 GE(>=) Returns a logical value of whether the first input i1 is greater than. Y = i1 .gt. Y = i1 . Y = i1 .le. the second input i2.1 Boolean The Boolean library provides the blocks for logical operations. i2 EQ (==) Returns a logical value when the first input is equal to the second input. i2 NE (!=) Returns a logical value of whether the first input i1 is not equal to the second input i2.or. i2 Language Reference Manual 153 . Y = i1 . Testing for equality between two real numbers can be a problem. Y = i1 . i2 NOT Returns a logical value of the logical negation of the two inputs. Y = i1 . Y = i1 .eq. Y = i1 .lt. i2 OR Returns a logical value which is the logical OR of the two inputs i1 and i2.

Ic) Language Reference Manual 154 .V)/(Rfb*C).0 Constant TD = 1.XOR Returns a logical value which is the logical exclusive OR of the two inputs i1 and i2.0 = 1.0 Constant Ic = 0. Integral.0 = 1.0 Y = BOUND(-VMax.0 Constant Ic1= 0.INTEG(Xd. PI Constant K = 1. Ic)).2 Controls Operations The Control library contains various PI controller PowerBlocks. Ic1) + TD*Xd) !-----Estimated X dot Xd = (X .0 PID Constant TI = 1.0 = 0. Y = i1 . Constant K = 1.0 !-----Proportional.0 Constant Tau = 1.0 Constant Ic2= 0. Rfb*X/Rin + V) V = INTEG((Y . Ic2))/TF PIV Constant VMax = 1. VMax.xor.0 Constant TF = 1.0 Y = K*(X + INTEG(X/Tau.0 Constant Rfb Constant Rin Constant C Constant Ic = 1. Differential Controller Y = K*(X + INTEG(X/TI. i2 6.

q. the initial value is zero.6.0 o1 = cmpxpl(p. the state and Language Reference Manual 155 . u1 is the signal being integrated and u2 defines the initial value of the state of the operator. it is an element by element operation. If not provided. u1 is the signal being integrated and u2 defines the initial value of the state of the operator. the state and output are reset to the value of the input u4. if provided. the initial value will be zero (FALSE). u2) Resetable Fixed Rate Integration (integr) This function performs fixed rate. ic2) Single Step Delay (delayd) This function acts as a single step delay upon an input signal. For vectors and matrices. INPUTS: u1. u2]) Fixed Rate Integration (integ) This function performs fixed rate integration on an input signal. if not provided. For vectors and matrices. INPUTS: u1. resetable integration on an input signal.3 Filters Operations Complex The Complex Pole Transfer is represented by the Laplace Pole Transfer transform: Function 1/(p*s**2 + q*s + 1) (cmpxpl) constant p = 1. The u4 input is optional. it is an element by element operation. For vectors and matrices.0 constant q = 1. u2 = any matching types OUTPUT: y1 = same type as u1 y1 = delayd(u1 [. ic1. it is an element by element operation. This operator has a source-sink decomposition which may prove useful when resolving feedback loops.0 constant ic2 = 0. if the port is deleted. For example: y1/u1 = z^(-1) where z is the Z transform delay operator. u2 is the initial value of the state and output. u2 is optional. i1. u2 is optional. u2 = floats with the same dimensions OUTPUT: y1 = same type and dimensions as u1 y1 = integ(u1.0 constant ic1 = 0. u3 should be set to true to reset the state and output of the integrator.

output are reset to the value of u2. INPUTS: u1, u2, u4 = floats of the same dimensions u3 = logical OUTPUT: y1 = same type and dimensions as u1

y1 = integr(u1, u2, u3 [, u4]) constant ic = 0.0 constant P = 1.0 constant Q = 1.0 o1 = ledlag(P, Q, i1, ic) constant ic = 0.0 constant P = 1.0 o1 = realpl(P, i1, ic)

Lead Lag

Real Pole Transfer

Continuous State Space Filter Discrete Space Filter

Transfer (S)

Transfer (Ratio) Transfer (Z)

Language Reference Manual

156

6.4 Linear Operations

Complex pole (cmpxpl) Output o1 is the second order transfer function (complex pole) of input i1 with initial conditions ic1 and ic2. Arguments p and q are time constants for the first and second expressions in the denominator.

o1 = cmpxpl (p, q, i1, ic1, ic2)

Delay (delay)

Output o1 is the transport delay of input i1 with initial condition ic, delay time tdl, workspace nmx (a literal integer), and (optional) minimum interval in buffer delmin.

o1 = delay (i, ic, tdl, nmx, delmin)

Gain

**Output o1 is input i1 multiplied by a gain k.
**

constant k = 1 o1 = k * I1

Inverse Gain

**Inverse gain, multiplies the input i1 by reciprocal gain.
**

constant k = 1.0 o1 = i1/k

Implicit (implc)

**Output z is adjusted to drive the input residual r to zero with first guess zic.
**

constant zic = 0.0 z = implc (r, zic)

Implicit Scalar Integration (impvc)

Implicit scalar integrator operator adjusts an output variable to drive a residual to zero, as part of an implicit or algebraic loop, a loop without an integrator. z - a simple variable r - an arithmetic expression of arbitrary complexity zic - a real constant.

z = impvc (r, zic)

Language Reference Manual

157

Integrator (integ)

**Output state o1 is the integration of input derivative i1 with initial condition ic.
**

constant ic = 0.0 o1 = integ (i1, ic)

Lead Lag (ledlag)

Output o1 is the lead-lag compensation of input i1 with initial condition ic and time constants t1 (numerator) and t2 (denominator).

constant ic = 0.0 constant t1 = 1.0 constant t2 = 1.0 o1 = ledlag (t1, t2, i1, ic).

Real Pole (realpl)

The REALPL operator produces a first order lag where output o1 is related to input i1 through the transfer function:

o1 i1 1 ps + 1 -- = ------ where o1(0) = ic

Summation

Transfer function (tran)

Adds an unlimited number of inputs to produce output o. The default sign for input ports is positive (+). The Port Info dialog box lets you specify that a port should be negative (-). Transfer functions in the form of a ratio of polynomials in the Laplace operator, may be directly implemented in acslX by the transfer function simulation operator. The simple first order transfer functions REALPL and LEDLAG and second order CMPXPL should be used when possible since the code generated is more efficient than that for TRAN. TRAN is appropriate for higher order operators. NOTE: to change the dimension of num or den: • Make local copy (check Embed Code box in the Block Details dialog box) • • Double-click on block; edit code for dimensions and constants. Save. Right-click for menu, choose Constants; click on Reset all constants to GSL values.

dimension num(10), den(10)

Language Reference Manual

158

o1 = exp(i1) Output o1 is the natural logarithm of i1 where i1 is a floating point variable or expression. num. o1 = log10(i1) Output o1 is the remainder of i1 divided by i2. o1 = i1/i2 Exponential (exp) Logarithm (log) Output o1 is exponential of the floating point argument of i1. den. o1 = mod(i1.i2 Absolute (abs) Divide Output o1 is the absolute value of i1 where i1 is an expression. i1) 6. o1 = i1 + i2 Subtract Output o1 is determined by thesubtraction i1 from i2. o1 = i1 . o1 = abs (i1) Output o1 is determined by the division of i1 by i2. 1.constant num = 10*1 constant den = 10*1 o1 = TRAN(1. i2) Language Reference Manual 159 .5 Math Operations Add Output o1 is determined by the addition of i1 with i2. i2) Output o1 is smaller value of inputs i1 and i2. o1 = min(i1. o1 = log(i1) Base 10 Logarithm (log10) Modulus (mod) Minimum (min) Output o1 is the base 10 logarithm of i1 where i1 is a floating point variable or expression.

6 Nonlinear Operations Backlash (bcklsh) Output o1 is the backlash (or hysteresis) of input expression i1 with initial condition ic. o1 = i1 * i2 Maximum (max) Positive (dim) Output o1 is larger value of inputs i1 and i2. o1 = max(i1. or matrix to a scalar. Argument d1 is half the width of the backlash. It is -1 if the input is less than 0. This function raises a scalar. o1 = i1**i2 Transfer of Sign (sign) Sign (sgn) Output o1 is the sign of i2 times the absolute value of i1. o1 = sgn(i1) Square Root Output o1 is the square root of i1. o1 = dim(i1. vector. o1 = bcklsh (ic. i2) Power Output o1 is the result of raising i1 to the power of i2. If i1 is greater than i2 then the result is i1 . i1) Bound Output o1 is the bound of input expression i1 where bb is the bottom bound and tb is the top bound. dl. Use limint rather than bound to limit the output of an integrator. the resulting output is a vector or matrix respectively. o1 = sign(i1. element by element. otherwise the result is zero. Language Reference Manual 160 . In the case of a scalar raised to a vector or matrix power. i2) Output o1 is the positive difference of inputs i1 and i2.Multiply Output o1 is determined by multiplying i1 times i2. vector. (sqr) o1 = sqrt(i1) 6.i2. i2) Output o1 is +1 if the input is greater than or equal to 0. or matrix power.

and top bound tb. and double-click on the plot block. run the model. To change the plot's parameters. It produces a -1 output when the input crosses in a negative direction. i1. i1. and i3. tb) Output o1 is the quantization of input i1 at resolution p. it is equal to i1 otherwise.0 o1 = i3 if p > 0. i1) Dead Zone (dead) Output o1 is zero when input i1 lies between bottom bound bb and top bound tb. ic. o1 = rsw (p.o1 = bound (bb. such that: o1 = i1 if p < 0. i3) Function Switch (limint) Quantizer (qntzer) Real Switch (rsw) Output o1 is the limited integration of input i1 with initial condition ic. i2. wire variables to it. right-click on the plot block and choose Plot Block Details. i2. Also use the Details Plot Into dialog to add a description of the plot in the "center text" field. i2. If logical input p (bottom input port) is TRUE. the output takes the value of input expression i1 (top input port). bb. bottom bound bb. tb. so your description will appear below the Language Reference Manual 161 . i1) Function Switch (fcnsw) Output o1 is determined by the input function p (the bottom input port). i1) Output o1 is the output of a real (floating point) switch. the output takes the value of input expression i2 (middle input port). o1 = qntzr(p. tb. This output is held for one timestep. It produces a 0 otherwise. To use a plot block. to be one of the other three inputs. 6.7 Plots Operations Plot Block Plot blocks plot the value of variables. if p is FALSE.0 o1 = fcnsw (p. o1 = dead (bb.0 o1 = i2 if p = 0. o1 = limint (i1. i1) Cross Detection The CrossDetect block produces a +1 output when the input crosses a threshold in a positive direction.

Each variable plotted needs an input port (>). wire 2 or more variables to it. To add or delete ports on the plot block. right-click on the plot block. To add or delete input ports on the plot block (so you can add or delete variables on the plot). To use Block a strip plot block. wire variables to it. Strip plots are normally drawn with one variable per axis and stacked from the bottom up. Plot X vs Y . Language Reference Manual 162 . right-click on it. To change the plot's parameters.$PLOT_SETTINGS_FILE _NAME$). run the model. Strip Plot Strip Plot plots the variable values in strip plot form. right-click on the plot block and choose Plot Block details.$PLOT_SETTINGS_ FILE_NAME$).Standard time-history line plot of the input ports Logarithmic Standard time-history loglog of the input ports Axes loglog($_INDEPENDENT_VAR$.$_i 1$. so your description will appear below the icon. Contour 3D Standard time-history contour3 of the input ports Plot contour3($_i1$. bar($_i1$.icon. 3D Bar Plot Plot blocks plot the value of variables. run the model.$PLOT_SETTINGS_FILE_NAME$ ). To use a plot block. so your description will appear below the icon. and double-click on the block.To change the plot's parameters. and double-click on the plot block.$PLOT_SETTINGS _FILE_NAME$) Contour Plot Standard time-history contour of the input ports contour($_i1$. Also use the details dialog to add a description of the plot in the "center text" field. right-click on the plot block. To add or delete input ports on the plot block (so you can add or delete variables on the plot). right-click on the plot block and choose Plot Block Details. Also use the Details Plot Into dialog to add a description of the plot in the "center text" field. Bar Plot Standard time-history bar graph of the input ports.

call gausi(= i1) Harmonic Drive Output o1 is the harmonic drive or sinsoidal function with the results of o1 = 0.0 constant Sigma = 1. The default seed is 55555555. w) Ramp Output o1 is a linear ramp of unit slope starting at the first integration step after tz.0 Y = gauss(Mean. odd number for a maximal length sequence. Language Reference Manual 163 . p. w) Pulse Output o1 is a pulse that starts at the first integration step after tz with period p and width w. constant Mean = 0. and p is the phase shift. w is the frequency. p.0 for T < tz o1 = sin(w*(T . o1 = ramp(tz) Step Output o1 changes from zero to one starting at the first integration step after tz. WARNING: Not intended for use in a Derivative section.tz) + p) for T >= tz where tz is the delay in seconds.0 Random Number (Gaussian) Returns a random number drawn from a gaussian distribution. Constants can be set using a block's Constant Info box. o1 = pulse(tz. constant o1 = 1.8 Sources Operations Constant Output o1 is set to the value of the constant. o1 = pulse(tz. Random seed is ZZSEED . Sigma) Gaussian Seed This function sets the gaussian seed for the random number generator.6. The input i1 should be a large. positive.

o1 = ou(ta.9 Trigonometry Operations Arc Cosine (acos) Output o1 is the arc cosine of i1 where i1is an expression or floating point variable. m is the mean value of the output. m.0 o1 = unif(bb. Output is in radians. constant bb = 0. WARNING: Not intended for use in a Derivative section. and s is the standard deviation of the output. o1 = acos(x) ArcSine Output o1 is the arc sine of i1 where i1 is an expression or floating point variable. The Ornstein-Uhlenbeck process maintains a constant source of power over a specified frequency band. tb) Uniform Seed The Uniform Seed function sets the seed for the random number generator. thus eliminating any problem of having to include the current integration step size in the standard deviation of the random variable. The input should be a large. call unifi(= i1) White Noise (ou) Output o1 is band limited white noise.o1 = step(tz) Uniform The output of the uniform noise function is a random variable uniformly distributed between a bottom bound bb and a top bound tb. s) . positive. The default seed is 55555555. ta is the low-pass filter time constant.Uhlenbeck function. implemented by the Ornstein. Random number generator seed is ZZSEED.0 constant tb = 1. o1 = sin(x) Arc Tangent (atan) Output o1 is the arc tangent of the floating point argument i1 where i1 is unlimited except for infinity and the result is in radians in the range (-p/2 < y < +p/2) an expression or floating Language Reference Manual 164 . odd number for a maximal length sequence. 6.

point variable. o1 = atan(x) Arc Tangent . o1 = cosh(i1) Output o1 is the sine of i1 where i1 is an expression or floating point variable. defining the full circle of revolution. y. o1 = atan2(x) Cosine (cos) Output o1 is the cosine of i1 where i1 is an expression or floating point variable. and the positive x-axis. The result is in radians in the range (-p/2 < y < +p/2). o1 = tanh(i1) Language Reference Manual 165 .angle (atan2) Output o1 is the arc tangent of an angle formed by the point with floating point coordinates x. o1 = cos(x) CosineHyperbolic (cosh) sin Output o1 is the hyperbolic cosine of i1 where i1 is an expression or floating point variable. o1 = sinh(i1) tan Output o1 is the tangent of i1 where i1 is an expression or floating point variable. o1 = sin(x) sinh Output o1 is the hyperbolic sine of i1 where i1 is an expression or floating point variable. o1 = tan(x) (tanh) Output o1 is the hyperbolic tangent of i1 where i1 is an expression or floating point variable. x and y can be both positive and negative.

with large programs this approach can result in an overwhelming amount of output. such as during interactive runs. excluding arrays greater than MALPRN (maximum array limit for print). DISCRETE. A more restricted selection of dumps can be obtained by using the ACTION command (see Chapter 5) or by including a call to DEBUG at the end of the DERIVATIVE or DISCRETE sections as follows: IF(logical condition) CALL DEBUG NOTE: Sorted sections of a program are not always translated in the order given.Appendix A General Purpose Utilities This appendix describes the general purpose subroutines from the system library. a useful set of data. If HVDPRN (high volume display) is set TRUE. LOGICAL dump CONSTANT dump = . IF(dump) CALL DEBUG Language Reference Manual 166 . Reviewing the resulting FORTRAN listing will show the order of execution and the placement of the DEBUG call.TRUE. for example: > NDBUG=20 > start While useful as a checkout tool. Including the following call in the DYNAMIC section produces the dump at every communication interval and is synonymous with OUTPUT /ALL: CALL DEBUG Calling DEBUG from the TERMINAL section gives all final values plus initial conditions. the dump also appears on the display (DIS) unit.1 DEBUG Form: CALL DEBUG Description: A call to this routine produces a debug dump of all variables. and Jacobian evaluation. Putting the call on a logical switch as follows allows you to suppress the listing when you don't want it. on the print (PRN) unit. A. The simplest way to get debug dumps is to set NDBUG to a positive integer at runtime so that a debug list is produced at the end of every DERIVATIVE.

to transfer the three elements VM(1).might be used.2 DISSTR Form: CHARACTER buffer*nn CONSTANT buffer = `place string here` CALL DISSTR(buffer) Description: In window environments it is not possible to use Fortran WRITE and PRINT statements to write to screen. VM(2). The n elements in array x are moved into array y. for example. for example). i and j are integer arrays of the same length. Example: CHARACTER buffer*80.A. XFERBI Form: CALL XFERBR(y = x. and VM(3) into the first three elements of the array RMD as follows: CALL XFERBR(rmd = vm. To use DISSTR. an internal file is declared as a character buffer with enough space for a message (*80 for an 80-column line. n) Description: Where x and y are floating point arrays of the same length. Then a call to DISSTR(buffer) prints the buffer. If n is a variable. it must be declared as an INTEGER.3 XFERBR. The XFERB(transfer block) subroutines move arrays from one place to another without requiring DO loops. and n is an integer specifying the number of elements in the arrays. XFERBR is single or double precision. so the DISSTR (display string) utility is provided. XFERB. depending on its arguments. CONSTANT buffer = `Entering the discrete section ` CALL DISSTR(` `) CALL DISSTR(` `) CALL DISSTR(buffer) ! write two blank lines ! write the message A. No check is made to see whether these elements actually exist. n) CALL XFERBI(j = i. 3) Language Reference Manual 167 .

The call is usually used within a DISCRETE section that may be changing conditions discontinuously.A.4 RSTART Form: RSTART(blockname. thus invalidating the history data used by the integration routine in the continuous section. A call to RSTART routine restarts the step size and history of the variable step. variable order integration algorithms. newstep) Description: Where blockname refers to the DERIVATIVE section (default is currently the only derivative section allowed) and newstep is an integration step size. Language Reference Manual 168 . It has no effect on the fixed-step Runge-Kutta algorithms and also cannot be used with the Runge-Kutta-Fehlberg algorithms.

- samleUploaded byAnjanav Das
- PLD Syllabus NewUploaded byNeil R. Perolino
- JPR Chapter 1Uploaded byUmarfarooque Mursal
- CSharpCheatSheetUploaded byatruhoo
- Mini Project ReportUploaded byGajendra Bahadur Singh
- 10 Th ExerciseUploaded byRizwan Lateef
- Hfm ObjectsUploaded byligiamolguin9426
- Library Management System.pptxUploaded byPham Hoang Bao - FAID HN
- ICSE 2011 Computer Application Solved PaperUploaded byanislinek15
- CSE 115_115L Course Objective and OutcomeUploaded byRoksana Islam
- SAP Tip: Create custom transaction for GR55 ReportsUploaded bySAPStuff
- MainUploaded bysemabay
- IindraLogic Prog 04 2007 eUploaded byMiulen
- Convergence Hints (aspen)Uploaded bySaurabh Gupta
- Lecture 2Uploaded bypauldewater5058
- SPIRVUploaded byr2d23
- question_bank.docxUploaded byaattish
- how to learn cUploaded byIshan Tiwari
- C Language TutorialUploaded byGopi Jampani
- ZPIOUploaded byahmed_497959294
- Week 2 - Iterative Data Processing - For StudentsUploaded byzzytrasihotang
- Lecture04 Computation (2)Uploaded byMuhammad Yusuf Fadhlan
- CS 100 Outline 02Uploaded bymuhammadriz
- Course Work Syllabus (1)Uploaded bypap23
- Assignment 1Uploaded bysaikiran_99
- MELJUN CORTES C++_Chap2Uploaded byMELJUN CORTES, MBA,MPA
- plc_stUploaded byDragan Šašić
- primexUploaded byabasak
- Python TutorialUploaded bylearnwithvideotutorials
- operating system memory managementUploaded bybagrechaamit

- time1.pdfUploaded bynmulyono
- pi3_gpioUploaded bynmulyono
- 4 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- 5 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- 6 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- time2Uploaded bynmulyono
- 1990 TI Optoelectronics Data BookUploaded bynmulyono
- 2 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- 7 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- 10 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- time3Uploaded bynmulyono
- TimeUploaded bynmulyono
- 3 datetime — Basic date and time types — Python 3.6.pdfUploaded bynmulyono
- 3 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- time1.pdfUploaded bynmulyono
- Automation Body of Knowledge.pdfUploaded bynmulyono
- percikan 2Uploaded bynmulyono
- Stepper 2Uploaded bynmulyono
- Stepper 1Uploaded bynmulyono
- percikan kisahUploaded bynmulyono
- percikan 1Uploaded bynmulyono
- Shift Bit Register (%SBR)Uploaded bynmulyono
- SnapTrack Under Bonding GroundingUploaded bynmulyono
- kabelUploaded bynmulyono
- 0m8NTozFZL8C(15233856)Uploaded bynmulyono
- Help - Asynchronous Machine __ Blocks (SimPowerSystems™).pdfUploaded bynmulyono
- Stepper 3Uploaded bynmulyono
- Hour 11. Using FilesUploaded bynmulyono
- 1 Datetime — Basic Date and Time Types — Python 3.6Uploaded bynmulyono
- resistor.pdfUploaded bynmulyono