You are on page 1of 428

$GYDQFHG&RQWLQXRXV

6LPXODWLRQ/DQJXDJH
$&6/

Reference Manual

AEgis Software, a divison of the AEgis Technologies Group, Inc.


6703 Odyssey Drive, Suite 103
Huntsville, AL 35806
U.S.A.
Phone: (256) 922-0802
Fax: (256) 883-5516

http://www.ACSLsim.com
Copyright:

Copyright (c) 1999 the AEgis Technologies Group Inc. All Rights Reserved. Printed in the United States of America.

ACSL is a registered trademark of the AEgis Technologies Group Inc.

Information in this document is subject to change without notice. The software described in this document is fur-
nished under a license agreement. The software and this documentation may be used only in accordance with the
terms of those agreements.

AEgis Software, a division of the AEgis Technologies Group Inc.


6703 Odyssey Drive, Suite 103
Huntsville, AL 35806
U.S.A.
http://www.ACSLsim.com

December 1999
Advanced Continuous
Simulation Language
(ACSL)

Reference Manual

AEgis Software, a division of the AEgis Technologies Group, Inc.


6703 Odyssey Drive, Suite 103
Huntsville AL 35806 USA
ACSL Reference Manual

Copyright © 1998-1999 by the AEgis Technologies Group, Inc.


ACSL is a registered trademark of the AEgis Technologies Group, Inc.
All rights reserved. Printed in the United States of America.
Foreword

This manual describes the Advanced Continuous Simulation Language, ACSL


(pronounced "axle"). The language is designed for modeling and evaluating the
performance of continuous systems described by time-dependent, nonlinear differential
equations.

Typical Applications of ACSL in new areas are being developed constantly. Typical areas in
applications which ACSL is currently applied include control system design, aerospace simulation,
chemical process dynamics, power plant dynamics, plant and animal growth,
toxicology models, vehicle handling, microprocessor controllers, and robotics.

Prerequisites This manual assumes that you are an engineer or scientist with some experience in
computers and programming. You thus know the basics of calculus and of FORTRAN,
C, or C++ and are familiar enough with a computer operating system to manage and
edit files.

Related This manual documents the machine-independent elements of ACSL. User guides
documents describing installation and execution on a particular computer are published separately
and shipped with each ACSL system. An ACSL Beginner's Guide is also available.

How to use this We recommend that you read through the first three chapters and then turn to the
manual example programs in Appendix A. The ACSL statements (Chapter 4) and runtime
commands (Chapter 5) are in alphabetical order for reference.
The linear analysis and frequency response features are described under the
ANALYZE command in Chapter 5. System symbols are listed in Appendix C.
Before running a simulation, be sure to study Chapter 7 on debugging.

ACSL Reference Manual Page iii


Page iv ACSL Reference Manual
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.1 Simulation language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-1
1.2 Job processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.3 Language features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-2
1.4 Coding procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4
1.5 Reserved names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5
1.6 Fortran subroutines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-6

2. Language Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1


2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
2.2 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-1
2.3 Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3
2.4 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4
2.5 Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5

3. Program Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1


3.1 Implicit and explicit structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.2 Program flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-1
3.3 Program sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4
3.4 Preset of user variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6
3.5 Preset of derivatives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-6

4. ACSL Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1


Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-1
ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
ACOS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
AINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4
ALGORITHM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-5
ANINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-10
ASIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Assignment statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Logical . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
Character . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-11
ATAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
ATAN2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
BCKLSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-12
BOUND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
CALL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-13
CHARACTER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
CINTERVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-14
CLOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
CMPXPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
Comment (!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-16
COMMON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-17
CONSTANT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-18
Continuation (&) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-19
CONTINUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
DBLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-20
DBLINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-21

ACSL Reference Manual Page v


DEAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
DELAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-22
DELSC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-24
DELVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
DERIVATIVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-25
DERIVT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
DIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-28
DIMENSION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-29
DISCRETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-30
DO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-32
DOUBLE PRECISION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
DYNAMIC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-33
END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
EQUIVALENCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-34
ERRTAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-35
EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-36
EXPF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-36
FCNSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-36
FORMAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-37
GAUSI, UNIFI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-37
GAUSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
GO TO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-38
HARM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-39
HISTORY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-39
IF, IF-THEN-ELSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-40
IMPLC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-42
IMPVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-44
INCLUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-45
INITIAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-45
INQUIRE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-46
INT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-46
INTEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-47
INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-49
INTERVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-49
INTVC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-50
I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-51
LEDLAG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-51
LIMINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-52
LINEAR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-54
LINES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-54
LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55
LOG10 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55
LOGD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-55
LOGICAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-56
LSW, RSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-57
MACRO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-57
MAX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-57
MAXTERVAL, MINTERVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-58
MERROR, XERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-59
MIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-60
MINTERVAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-60
MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-60
NINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-60
NSTEPS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-61
OPEN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-62
OU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-62
PAGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-63

Page vi ACSL Reference Manual


PARAMETER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-64
PRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-64
PROCEDURAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-64
PROGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-66
PTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-66
PULSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-67
QNTZR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-67
RAMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-68
READ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-68
REAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-69
REALPL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-69
RESET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-70
RSW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-70
RTP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-71
SAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-71
SCALE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-72
SCHEDULE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-72
Separator (;) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-80
SIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-80
SIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-81
SMOOTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-81
SORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-83
SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-83
STEP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-84
TABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-85
TAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-88
TERMINAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-89
TERMT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-89
TRAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-90
TRANZ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-92
Type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-93
UNIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-96
UNIFI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-96
USEDBV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-96
VARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-97
WRITE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-97
XERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-97

5. ACSL Runtime Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1


5.1 Runtime executive . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-1
5.2 ACTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-2
5.3 ANALYZE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4
5.4 Comment (!) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
5.5 Continuation (&) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-20
5.6 CONTINUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-21
5.7 DATA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-22
5.8 DISPLAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-24
5.9 END . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
5.10 EXIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
5.11 FILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-26
5.12 HELP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28
5.13 MATH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-28
5.14 MERROR, XERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30
5.15 OUTPUT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-30

ACSL Reference Manual Page vii


5.16 PAUSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32
5.17 PLOT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-32
5.18 PREPARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-42
5.19 PRINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-43
5.20 PROCEDURE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-45
5.21 QUIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-47
5.22 RANGE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-48
5.23 REINIT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-49
5.24 RESTORE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-50
5.25 SAVE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-51
5.26 Separator (;) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-52
5.27 SET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-52
5.28 SPARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
5.29 START . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-54
5.30 SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-55
5.31 Wild cards (* and ?) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-56
5.32 XERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-56

6. Macro Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1


6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-1
6.2 Macro definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
6.3 Macro definition header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4
6.4 Macro directive statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-6
6.5 Macro examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11
6.6 Macro invocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-17

7. Debugging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
7.1 Debugging procedure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-1
7.2 DEBUG printout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-4
7.3 Variable Step Algorithm Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-7
7.4 Output for debugging of integration process . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8
7.5 Jacobian Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16
7.6 Loss of accuracy with large bias terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-19

8. Application Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1


8.1 Parameter sweep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-1
8.2 Phase and gain plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-2
8.3 Summary output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-3
8.4 Impulse and step response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4
8.5 Externally defined variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-5
8.6 Stopping missiles at intercept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-6
8.7 State space linear matrix model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7
8.8 Full set matrix operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.9 Moving time backwards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-8
8.10 Plotting averages from Monte Carlo programs . . . . . . . . . . . . . . . . . . . . . . . . . . 8-9
8.11 Plotting arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-10
8.12 Calling subroutines in C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-11
8.13 Synchronizing DISCRETE events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13

Page viii ACSL Reference Manual


A. ACSL Example Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
1. Limit Cycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-1
2. Spring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-5
3. Control Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-9
4. Pilot Ejection Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-13
5. Temperature Distribution along a Radiating Fin . . . . . . . . . . . . . . . . . . . . . . . . . . A-20
6. Aircraft Arresting Gear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-34
7. Aircraft Longitudinal Study . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-41
8. Physiological Benchmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-52
9. Phase and Gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-62
10. Missile Airframe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-70
11. Discrete Sampled Compensator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-90
12. Aspirin Dosage Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-97
13. Block on a Rough Surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-102
14. Linear analysis example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-116
15. Tank with Boiling Benzene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . A-123

B. General Purpose Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1


B.1 AGET–, APUT– . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-1
B.2 DEBUG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
B.3 DISSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-2
B.4 INITD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3
B.5 INTEG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-3
B.6 LISTD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-4
B.7 RSTART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-5
B.8 SETI, SETR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-5
B.9 WEM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-5
B.10 XFERBR, XFERBI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . B-6

C. ACSL System Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1


C.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1
C.2 Plots in general . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-1
C.3 Printer plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-3
C.4 Continuous plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-3
C.5 Strip plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-5
C.6 Frequency plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-6
C.7 Print data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-8
C.8 Integration control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-8
C.9 Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-9

D. ACSL Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . D-1

E. References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . E-1

ACSL Reference Manual Page ix


Page i ACSL Reference Manual
1. Introduction
1.1 Simulation
language

Simulation of physical systems is a standard analysis tool used in the evaluation of


hardware design prior to actual construction. The continuous system simulation
language described herein, and referred to as ACSL (Advanced Continuous
Simulation Language), has been developed expressly for the purpose of modeling
systems described by time dependent, nonlinear differential equations and/or transfer
functions.*
Applications Typical application areas for continuous simulation are control system design,
chemical process representation, missile and aircraft simulation, power plant
dynamics, biomedical systems, vehicle handling, microprocessor controllers, fluid
flow, and heat transfer analysis. Users can derive model code from block diagrams,
mathematical equations, conventional Fortran statements, etc.
Graphical front A graphical front end for ACSL is available in a software package called Graphic
end Modeller. Block diagrams are developed on screen from pre-defined PowerBlocks
representing ACSL statements, operators, functions, and/or user-defined blocks in an
unlimited hierarchical structure. ACSL code is generated directly from the graphical
model.
Language Highlights of the ACSL language are free form input, function generation of up to
highlights three variables, and independent error control on each integrator. Flexibility is
provided for plotting the behavior of the models under a number of external forcing
functions. Many simulation oriented operators such as variable time delay, dead zone,
backlash, and quantization are included and made readily accessible. Global single or
double precision calculation can be selected.
The ACSL program is intended to provide a simple method of representing these
mathematical models on a digital computer. Working from an equation description of
the problem or a block diagram, the user writes ACSL statements to describe the
system under investigation. Runtime commands exercise the model; these statements
can be submitted for solution in batch mode or entered interactively. Interactively you
can run the simulation, look at the results, and change constants to experiment with the
model; for example, trying different spring constants or actuator limits.
An important feature of ACSL is its sorting of the continuous model equations, in
contrast to general purpose programming languages such as Fortran where program
execution depends critically on statement order. ACSL program structure and the
translator sorting procedure are described in Chapter 3.

* The basic structure follows the specification established by the Technical Committee on Continuous System
Simulation Languages and under the auspices of Simulation Councils, Inc. (SCi) in Simulation 9 (Dec. 1967) pp
281-303.

ACSL Reference Manual Page 1-1


1. Introduction 1.2 Job processing

1.2 Job
processing

Inputs to ACSL are in two parts. The program defines the system being modeled; the
runtime commands exercise this model (i.e., they change parameters, execute runs,
specify plots, etc.).
The program is read by the ACSL translator, which translates it to a Fortran compile
file. The Fortran code is then compiled, linked with the ACSL runtime library, and
executed, finishing at an ACSL runtime prompt:
ACSL>

At this point, ACSL is waiting for runtime commands, which can be entered
interactively, by reading a command file, or in a batch process. The commands are
read, decoded, and executed in sequence. See Chapter 5 for a description of the
commands. A minimum of a START command is necessary to exercise the model.

1.3 Language
features

The language consists of a set of arithmetic operators, standard functions, a set of


special ACSL statements, and a MACRO capability. The MACRO capability allows
extension of the special ACSL statements, either at the system level for each
installation, or for each individual user.
Operators and The arithmetic, relational, and logical operators, described in Chapter 2, work as they
functions do in Fortran. The functions, listed in Chapter 4, consist of special ACSL operators
such as QNTZR (quantization), UNIF (uniform random number), etc. In addition, all
the functions of the Fortran library are available; e.g., SQRT (square root), MOD
(modulus), etc.
Integration Integration is a special ACSL operator that is called by either INTEG (scalar) or
INTVC (vector). This is written in the form:
r = INTEG(x, rzero)

which implies:
T

R = RZERO + ∫ X dt
0

This integration operator is the heart of the simulation system. In building any model,
it is necessary to change differential operators into integration operators; this is
conventionally accomplished by expressing the highest derivative of a variable in
terms of lower derivatives and other variables. As an example, consider the spring
dashpot system excited by a given function of time F(t). In general form, this is:
.. .
x + 2ζωx + ω2x = F(t)

where ω is the natural frequency and ζ the damping ratio. Expressing this equation in
..
terms of the highest derivative, x, gives:
.. .
x = F(t) − 2ζωx − ω2x

Page 1-2 ACSL Reference Manual


1.3 Language features 1. Introduction

. .
INTEG operator This derivative can then be integrated once for x and again for x. Since x appears on
the right hand side, it must be given a name (XD). The two integrations can be written
in the program as:
xd = INTEG(F(T) - 2*ze*w*xd - w**2*x, xdic)
x = INTEG(xd, xic)

This process transforms the original set of differential equations to a set of first order
equations which can be solved directly by integrating.
Redundant state Be careful in the transformation process to avoid the introduction of redundant state
.
variables variables. In the above sequence, the reference to x (XD) could have been avoided by
..
calculating x (XDD) directly and embedding an INTEG operator in the expression; i.e.,
xdd = F(T) - 2*ze*w*INTEG(xdd, xdic) - w**2*x

Now X is the second integral of XDD and can be calculated as follows:


x = INTEG(INTEG(xdd, xdic), xic)

In these two equations, there are three INTEG operators (each one a state variable), but
two are integrations of XDD with the same initial condition. One of these is redundant
and can be eliminated by explicitly naming the first derivative as shown previously.
Limit cycle As an introduction to the process of coding a model, we will outline a simple example
example using the arithmetic operators and the SQRT and INTEG functions. The following
equations define a limit cycle:

. x (1 − x2 − y2 )
x = y + ; x(0) = 0.5

√x2 +y2
. y (1 − x2 − y2 )
y = −x + ; y(0) = 0.0

√x2 +y2

The equations are coded as follows:


r2 = x**2 + y**2
x = INTEG(y + x*(1.0 - r2)/SQRT(r2), 0.5)
y = INTEG(-x + y*(1.0 - r2)/SQRT(r2), 0.0)

Program code While this series of statements completely describes the equations to be solved, it does
not represent the complete problem statement. Figure 1-1 lists the complete running
program. Each statement is numbered for reference. A DERIVATIVE statement (1) is
needed to define the beginning of the program. The communication interval (data
logging rate) is specified by the CINTERVAL operator (3). A termination condition
must be specified in a TERMT statement (7). Finally, the program definition is
completed by an END statement (8) to match the DERIVATIVE statement. This END
statement tells the translator that no more ACSL statements are expected, although
Fortran subroutines or functions can be added at the end of an ACSL program.
A further refinement is in assigning symbolic names for the initial conditions, X(0)
and Y(0), and for the stop time TF. These are preset in the CONSTANT statement (2).
It is better programming practice to use a symbol preset to the value desired than to
embed literal constants (0.5, for example) in the program. Changes then occur in one
place in the program, and values can also be changed at runtime.
Runtime The second part of Figure 1-1 is an example of runtime statements. OUTPUT (9)
commands defines the variables that are to be listed on the screen at each communication interval
as the run progresses. The model is then executed by the command START (10). Line

ACSL Reference Manual Page 1-3


1. Introduction 1.4 Coding procedure

(1) DERIVATIVE ! limit cycle


(2) CONSTANT xz = 0.5 , yz = 0.0 ,tf = 4.0
(3) CINTERVAL cint = 0.2
(4) r2 = x**2 + y**2
(5) x = INTEG( y + x*(1.0 - r2)/SQRT(r2), xz)
(6) y = INTEG(-x + y*(1.0 - r2)/SQRT(r2), yz)
(7) TERMT(t .ge. tf, 'Time Limit')
(8) END

(9) OUTPUT t,x,y,sq


(10) START
(11) ! Change initial conditions and run again
(12) SET xz=0.7
(13) START
(14) QUIT

Figure 1-1. Limit cycle example of model code and runtime commands

(11) is a comment, (12) changes the initial condition, and (13) runs the model again.
Line (14) quits from the runtime session.
Section 1 of Appendix A lists the actual program, gives more detailed explanations,
and shows examples of results and plots.

1.4 Coding
procedure

The ACSL coding line contains eighty columns. ACSL statements may be placed
anywhere on the line, but we suggest that developing standards to make programs
easier to read. Suggested standards are as follows:
Section delineators (PROGRAM, INITIAL, END, etc.) start in column 1
PROCEDURAL brackets (PROCEDURAL/END) start in column 6
Unlabeled statements start in column 7
Labelled statements start label in column 6
Equal sign in assignment statements in column 15 or beyond
Separator More than one statement can be placed on one line by separating the statements with a
semicolon (;).
Continuation Any statement can be continued on to the next line by adding an ampersand (&) at the
end of the line, to the right of any nonblank information but before column 80. Any
trailing blanks are squeezed out of the line containing the ampersand and the following
line is added directly. Starting with column 1, it is as though the characters were strung
on the end after the last nonblank character of the preceding line. Leading blanks of
the continuation line are not suppressed unless a leading ampersand is present on the
continuation line. Comments can be added after the trailing ampersand since these
comments are stripped off first. An empty line needs two ampersands since a single
one can't be distinguished.
Comments Everything after an exclamation point (!) is considered a comment and is ignored by
the translator (in the program) and the runtime executive (in runtime commands).
Blank lines Blank lines can be placed anywhere in the program and have no effect.

Page 1-4 ACSL Reference Manual


1.5 Reserved names 1. Introduction

Table 1-1. System variable defaults

Statement Default name Default value Definition


ALGORITHM IALG 5 Integration algorithm
CINTERVAL CINT 0.1 Communication interval
ERRTAG none .FALSE. Error flag
MAXTERVAL MAXT 1.0E+10 Maximum calculation interval
MINTERVAL MINT 1.0E-10 Minimum calculation interval
VARIABLE T 0.0 Independent variable

Note: It is probably a good idea to treat these names as reserved and not use them for any purpose except that stated.

1.5 Reserved
names

The only reserved names in the language are those of the form Znnnnn and ZZaaaa,
where n is any digit and a is any alphanumeric character. All generated variables and
system subroutine names are in this form.
System variable It is a good idea, in addition, to keep in mind the system variable default names listed
defaults in Table 1-1. These default names can be changed to any name, but if names are not
specified, the default names will be in existence so they can be set by program control
in the model definition section. Other uses of these names (e.g., defining MAXT as a
state variable) could cause conflicts.
Runtime system A further level of names to be considered is the runtime system symbols listed in
symbols Appendix C. These are flags and numeric values that determine such things as plot
format, print intervals, etc. Quantities such as the Y axis length (YINCPL) for line
plots, grid line type (GLTPLT), etc. are under your control at runtime. All these
symbols have default values. Access is by runtime SET command; e.g.,
SET YINCPL = 5.0

Precedence of Symbols in SET commands are searched for first in the user's dictionary; i.e. the
names dictionary created from the variable names in the program code. If that search is
unsuccessful, the dictionary of ACSL system symbols is searched. Thus, if one of the
system symbols is used as a name in the program, that use takes precedence over the
ACSL system use. You should generally not duplicate system symbol names within
the program since doing so means that you will not have the luxury of modifying the
system default values.

ACSL Reference Manual Page 1-5


1. Introduction 1.6 Fortran subroutines

1.6 Fortran
subroutines

User-defined Fortran functions or subroutines can be used in an ACSL program by


including them at the end of the program; i.e. immediately following the last ACSL
END statement. The translator looks for the following:
REAL FUNCTION ...
INTEGER FUNCTION ...
LOGICAL FUNCTION ...
CHARACTER FUNCTION ...
DOUBLE PRECISION FUNCTION ...
SUBROUTINE ...
FUNCTION ...
PROGRAM ...

If one of these keywords is found, the translator assumes that all the subsequent lines
are to be passed directly to the Fortran compiler without any changes, so Fortran
format must be followed exactly; i.e., start in column seven or beyond, etc.
First line It is important that the line following the ACSL model really contain one of the
Fortran statements listed above. A Fortran comment (C in column one) is rejected
since it could be the beginning of a valid ACSL line; e.g.,
c = k1*x

Tabs The first line cannot contain a tab since ACSL sees a tab as a space until it determines
that it is in Fortran. Tabs are acceptable in the Fortran code itself.
TOO MANY ENDS If text following the ACSL model does not correspond to the beginning of a Fortran
routine, the error message Too many ends is produced. A model definition with too
many END statements causes the model file to close prematurely. The first statement
after an extra END statement looks the same to the translator as an incorrect Fortran
subroutine header.
$ for common The only change the translator makes in transferring the Fortran code is to look for a
blocks dollar sign ($) in column one. This line is replaced by all the ACSL common blocks
called /ZZCOMi/ and type statements (which may run to many lines). Using this
feature makes the names and values of an ACSL program available to the subroutine.
The dollar sign should appear before any DATA or executable statements, but can be
after type statements or comments.
Note that there is no selectivity in pulling in the common blocks; either all the symbols
are obtained or none. It is easy to get name conflicts or violate the translator sorting
algorithm by this action. We recommend using your own common blocks where
necessary to make names from one program or subroutine available in another.

Page 1-6 ACSL Reference Manual


2. Language Elements

2.1 Introduction
Most of the basic elements of ACSL are defined as in Fortran. Table 2-1 lists the
major differences. If you are familiar with Fortran, you could skip to the next chapter
after reading the table; if not, you should be sure you understand the language
elements described in this chapter.

2.2 Constants
Constants may be either integer, floating point (single or double precision), logical, or
character.
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

Table 2-1. Major differences between ACSL and Fortran syntax

labels Labels can be alphanumeric or numeric. Labels are separated from the statements to
which they are attached by a colon; i.e.,
label: statement

Due to conflicts with macro expansions within labeled statements, we recommend that
labels be used only with CONTINUE statements. See the section on labels.
names Blanks are not allowed within names. Names may have up to thirty-one characters.
Names should not be of the form Znnnnn or ZZaaaa where n is any number and a is
any alphanumeric character.
types Variables starting with I, J, K, L, M, or N are not automatically considered integer.
All variables and functions are considered floating point (single or double precision
depending on the library specified) unless typed explicitly otherwise.
coding Free format; use any columns 1 through 80.
continuation An ampersand (&) at the end of a line indicates continuation onto the next line. A
non-blank column six has no significance in free format.
comments An exclamation point (!) indicates a comment. ACSL ignores all code from an
exclamation point to the end of the line. A "C" in column one has no significance in
free format.

ACSL Reference Manual Page 2-1


2. Language Elements 2.2 Constants

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 forms are E (single precision) and D (double precision).
Examples of floating point constants include:
3.1416 31.416E-1 7.9566314D-4 3E1
-0.000345 0.347E03 -27.6E+220

Numbers entered with a decimal point and no exponent (1.234, for example) are given
a double precision exponent of D0 (i.e., 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. The main use of this promotion feature is in
arguments to subroutines where it is impossible for the compiler to determine the
precision of the subroutine argument when used inside the routine. Be careful when
using integers and floating point numbers in subroutine arguments in case the type is
accidentally changed. For example:
CALL mysub(1, 1.234)

must have arguments that are an INTEGER and a REAL, but when using the global
double precision translator, the second argument will be converted to 1.234D0 and the
subroutine's internal precision must be adjusted.
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 under global double precision. In the example above, you can ensure that the
second argument is always single precision by:
CALL mysub(1, REAL(1.234))

Promotion of A number without a decimal point (1 instead of 1.0) can be used in most circum-
integers stances where a floating point number is expected. The number is floated before it is
used. Be sure however to use a decimal point (or a variable name) in arguments to
functions, macros, or subroutines. Also, expressions with only integers are not
promoted, so 1/2/pi is zero, but 1/2.0/pi and 1/(2*pi) give correct results.
Logical Logical constants may be one of two values.
.TRUE. .FALSE.

However, when logicals are plotted in ACSL, zero corresponds to .FALSE. and one to
.TRUE. There is no equivalent to this in Fortran.
Character Character constants are strings of letters, numbers, and other characters.
SET TITLE = 'Limit Cycle, Run1'

Character constants are defined by a string of characters within single quotes. Single
quotes are inserted in a string by doubling them; for example, to define a string
abc'def, use 'abc''def'.
Constants as Constants are best given symbolic names in model code. While literal constants can be
symbols used in expressions directly, it is impossible to change their values at runtime. To
change a literal constant, the original source code must be changed and the program
retranslated, compiled, and linked. If the same constant appears more than once, more

Page 2-2 ACSL Reference Manual


2.3 Variables 2. Language Elements

changes in the source text are required. It is better to give all constants symbolic
names to be used in expressions, presetting these via 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.3 Variables
Variable names are symbolic representations of numerical quantities that may or may
not change during a simulation run. They refer to a location and have a value equal to
the current number stored in that location. Both simple and subscripted variables may
be used. A symbolic name must start with a letter and be followed by up to thirty
letters and digits (not more than thirty-one characters total).
Types All variables in an ACSL program are assumed to be real (single or double precision,
depending on the library specified) unless explicitly typed otherwise. The Fortran
convention for integers starting with the letters I through N does not apply. Type
REAL specifies single precision only; type DOUBLEPRECISION specifies double
precision only. Variables can also be of type INTEGER, LOGICAL, or
CHARACTER. Examples of simple variables include:
a a57 ab57d k20

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) b53(5*i + 2, 6, 7*k + 3)
c47(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.


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

Extracted as a single-dimensioned vector, the order is:


11 21 12 22 13 23 14 24 15 25

Underscore Underscores can be included in variable names to make them more readable, in
accordance with Fortran 88 standards.
this_long_name = INTEG(motor_velocity, initial_condition)

ACSL Reference Manual Page 2-3


2. Language Elements 2.4 Labels

2.4 Labels
A label can be attached to a statement so that control is transferred to it by GO TO or
so that a FORMAT statement is labeled.
Form A label can be either alphanumeric or numeric.
Reserved The ACSL system uses labels starting at 99999 and working downwards; you should
labels therefore avoid labels with high numeric values to avoid possible conflicts.
Syntax A label is set off from the statement to which it applies by a colon (:), as in this
example.
L1: CONTINUE
x = a + b
1000: y = c + d
GO TO L1

Statements Although it is legal to attach statement labels to any executable statements, only
attached to CONTINUE statements are recommended. The difficulty is that the labeled statement
may be translated into several statements; i.e., the effect of a MACRO call inside a
statement is that the macro is expanded first, followed by the labeled statement.
Macro As an example, consider the random number generator GAUSS, which is a MACRO.
expansion It could be used in a labeled statement in a PROCEDURAL as follows:
GO TO label
...
label: x = GAUSS(mean, sigma)

This expands to the Fortran code:


GO TO 99996
...
Z09999 = MEAN + GRV(ZZSEED)*(SIGMA)
99996 X = Z09999

With the MACRO call in a labeled statement, the intermediate variable Z09999 is not
assigned a value when the GO TO transition is executed. However, if a CONTINUE is
used at the labeled statement as follows:
GO TO label
...
label: CONTINUE
x = GAUSS(mean, sigma)

the code expands into the correct sequence as follows:


GO TO 99996
...
99996 CONTINUE
Z09999 = MEAN + GRV(ZZSEED)*(SIGMA)
X = Z09999

Use One solution to the label problem originally considered was to attach the LABEL to
CONTINUE the first line of the code generated from the MACRO. Then, however, DO loops
statements became the problem, since the label must be the last operation of the loop (statements
after the labeled statement are not in the loop). Even if ACSL differentiates between
the DO loop labels, the language allows a loop with direct GO TOs to the terminating
statement label; e.g.,

Page 2-4 ACSL Reference Manual


2.5 Expressions 2. Language Elements

DO label i = 1, 20
...
IF (condition) GO TO label
...
label: x = x + GAUSS(mean, sigma)

To formulate rules to translate this sequence appears to be impossible. If this operation


is programmed with labeled CONTINUE statements, two labels will be necessary and
the translation is straightforward; i.e.,
DO label1 i = 1, 20
...
IF (condition) GO TO label2
...
label2: CONTINUE
x = x + GAUSS(mean, sigma)
label1: CONTINUE

2.5 Expressions
An expression is a combination of operators and operands which, when evaluated,
produces a single numerical value. Expressions may contain arithmetic, relational, and
logical operators. ACSL syntax for expressions is the same as in Fortran.
Arithmetic The arithmetic operators are:
operators
+ addition
- subtraction
* multiplication
/ division
** exponentiation
Two operators Two arithmetic operators can not appear next to each other in an arithmetic
together expression. 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; e.g.,
b*a/(-c) -a*b - c a*(-c)

are all valid, but the following is not:


b*a/-c

Warning – Dividing by an integer (i.e., assuming that the integer is promoted to floating point)
dividing by sometimes gives incorrect results. For example, the first calculation results in zero, but
integer specifying the 2 in floating point gives the correct result:
x = 1/2/pi zero
x = 1/2.0/pi correct

ANSI standard forbids changing I/J/R to a supposedly equivalent I/(J*R). The


following guidelines apply:
1/2 integer zero
1/2.0 floated to floating point
1/(2*pi) okay
1/pi/2 okay

Parentheses Parentheses can be used to indicate groupings as in ordinary mathematical notation,


but they cannot be used to indicate multiplication.

ACSL Reference Manual Page 2-5


2. Language Elements 2.5 Expressions

Relational The relational operators, the results of which can be only TRUE or FALSE, are:
operators
.EQ. equal to
.NE. not equal to
.GT. greater than
.LT. less than
.GE. greater than or equal to
.LE. less than or equal to
Logical The logical operators are:
operators
.EQV. combines two logical expressions to give the value TRUE when they are
equivalent; otherwise, the value is FALSE
.NEQV. combines two logical expressions to give the value of TRUE when they
are NOT equivalent; when the two expressions are equivalent, the value
is FALSE
.NOT. reverses the truth of the logical expression that follows it
.AND. combines two logical expressions to give the value TRUE when BOTH
are TRUE; otherwise, the value is FALSE
.OR. combines two logical expressions to give value TRUE when EITHER is
TRUE; otherwise, the value is FALSE
Operands Operands may be constants, variables (simple or subscripted), or functions. Examples
of arithmetic expressions include:
a 5.76 -(c + del*aero)
3 + 16.5 b + a(5)/2.75 (b - SQRT(a**2 + x**2))/2.0

Relational Relational expressions are a combination of two arithmetic expressions with a


expressions relational operator. The relational expression will have the value TRUE or FALSE
depending on whether the stated relation is valid or not. The general form of the
relational expression is:

a1 op a2

where ai are arithmetic expressions and op is a relational operator. A relational


operator must have two operands combined with one operator; thus, the form:

a1 op a2 op a3

for example:
A .EQ. B .EQ. C

is not valid. Examples of valid relational expressions include:


a .EQ. b a + d .LT. 5.3
a57 .GT. 0.0 (5.0*b - 3.0) .LE. (4.0 - c)

Logical Logical expressions are combinations of logical operands and/or logical operators
expressions which, when evaluated, will have a value of TRUE or FALSE. The general form of the
logical expression is:

l1 op l2 op l3 op 〈 ln

where li are logical operands or relational expressions. Examples are:

Page 2-6 ACSL Reference Manual


2.5 Expressions 2. Language Elements

LOGICAL aa, cc, lfunc


aa .AND. (b .GE. c) .OR. cc .AND. lfunc(x,y) &
.AND. (x .LE. y) .OR..NOT. aa

Note that the symbolic names AA, CC, and LFUNC have been declared to be of type
LOGICAL, and LFUNC is a function with a TRUE or FALSE result calculated from
the value of the variables X and Y.
Character Character constants and variables can be joined together by the // operator. Substrings
expressions of characters can be selected by a colon (:) operator; a substring may not be of zero
length. For example:
c1 = c2(5:10)//c3

where C1, C2, and C3 are character variables. A character variable may not appear on
both the left and right hand side of the same statement.
Integers can be converted to characters through the CHAR function; for example:
name = first//last//CHAR(period)

Mapping for the CHAR function depends on the character code used by the compiler.
ASCII is almost universal.
Single characters can be converted to integer (in the opposite direction to CHAR) by
the ICHAR function.
Expressions Arguments of functions may, in general, be expressions. Since expressions can contain
in functions functions, an arbitrary depth of complexity can be generated. Using the SIN and COS
function as an example, the following is a valid expression:
a + SIN(x*COS(5*x + y) - 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.

ACSL Reference Manual Page 2-7


2. Language Elements 2.5 Expressions

Page 2-8 ACSL Reference Manual


3. Program Structure

3.1 Implicit and


explicit structure

It is possible to write a simulation model in ACSL with only PROGRAM and END
statements to outline the model structure. This is known as implicit structure because it
implies that the whole program is a DERIVATIVE section. This simple structure has
limitations, especially in handling initial conditions.
The more flexible explicit structure includes INITIAL, DYNAMIC (with embedded
DERIVATIVE and DISCRETE), and TERMINAL sections, as shown in Figure 3-1. If
this method is chosen, any or all of the five explicit blocks may be included. The order
of the sections must be as shown, and each section must be terminated with its own
END statement.

3.2 Program flow

Figure 3-2 outlines the flow of an ACSL program with explicit structure. A program is
activated with a runtime START command.

PROGRAM
INITIAL
Statements executed before the run beings.
State variables do not contain the initial conditions yet.
END
DYNAMIC
DERIVATIVE
Statements to be integrated continuously.
END
DISCRETE
Statements executed at discrete points in time.
END
Statements executed each communication interval.
END
TERMINAL
Statements executed after the run terminates.
END
END

Figure 3-1. Outline of explicitly structured program

ACSL Reference Manual Page 3-1


3. Program Structure 3.2 Program flow

INITIAL The program proceeds sequentially through the INITIAL section, the section for
calculations performed once before the dynamic model begins. Initial condition values
are moved to the state variables (outputs of integrators) at the end of the INITIAL
section, but not all initial conditions will have been defined. Usually some initial
conditions are calculated at this point. Any variables that do not change their values
during a run can be computed in INITIAL. However, CONSTANT statements are not
required to be placed in the INITIAL section; they are not executable and can be
placed anywhere in the program.
DERIVATIVE The integration routine is initialized when control transfers out of the INITIAL
DISCRETE section. This initialization procedure involves transferring all initial condition values
into the corresponding states and evaluating the code in the DERIVATIVE and
DISCRETE sections once. This action is taken to ensure that all calculated variables
are known before recording the first data point. Note that it may appear from the
program listing that the DYNAMIC section is executed before the DERIVATIVE
section; in fact, DERIVATIVE and DISCRETE are evaluated first and should not rely
on calculations in the DYNAMIC section to initialize variables for DERIVATIVE or
DISCRETE sections. On the other hand, all values calculated in the DERIVATIVE
and DISCRETE sections are available in the DYNAMIC section.
DYNAMIC After initialization and evaluation of the DERIVATIVE and DISCRETE code, the
STOP flag is reset and the program executes the code within the DYNAMIC block.
There are no restrictions on the variables that can be referred to in this DYNAMIC
section. All the states have values, and intermediate calculations in the DERIVATIVE
and DISCRETE sections have been executed.
STOP flag After the DYNAMIC section has been evaluated, the STOP flag is tested; if the flag
has been set, control is transferred to the TERMINAL region. The STOP flag is set by
the TERMT statement; if any TERMT statements are included in the DYNAMIC
block, control is transferred at this check when one of the arguments of TERMT
becomes true. If the STOP flag has not been set, the program writes out the values of
all the variables specified in the OUTPUT and PREPARE lists, the former to the
output file or terminal, the latter to a scratch file for later plotting and/or printing.
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.
The integration routine returns with the states advanced through the communication
interval and again the STOP flag is tested. At this point, the flag may have been set by
a TERMT statement in a DERIVATIVE or DISCRETE section; if not, the program
loops and re-executes the DYNAMIC section.
Transfer Control can be transferred between some sections using GO TOs and statement labels,
control if needed. It is illegal to transfer into the DYNAMIC region, since the integration
initialization then could not be performed correctly. Transfer from the dynamic region
to either INITIAL or TERMINAL is quite acceptable; so also is transfer between
INITIAL and TERMINAL blocks. Control cannot be transferred either into or out of
DERIVATIVE or DISCRETE sections since these are changed into a separate
subroutine and, as such, are inaccessible to the main program loop.
TERMINAL Program control transfers to the TERMINAL section when the STOP flag has been set
TRUE. On passing out of the last END, control returns to the ACSL executive, which
reads and processes any further runtime commands (PLOT, DISPLAY, etc.). Note that
if a jump (GO TO) sends control from the TERMINAL section back to the INITIAL,
the last output is not written out unless the LOGD operator is used (see Chapter 4).

Page 3-2 ACSL Reference Manual


3.2 Program flow 3. Program Structure

Figure 3-2. Main Program Loop of ACSL Model

ACSL Reference Manual Page 3-3


3. Program Structure 3.3 Program sorting

3.3 Program
sorting

The ACSL translator sorts the code in the DERIVATIVE section so that outputs are
calculated before they are used. Sections other than DERIVATIVE are sorted only if
the SORT keyword is specified. Sorting takes place only within sections, never across
sections. The sort algorithm is relatively simple and consists of two passes.
First pass Pass number one examines each statement; output variables are marked as calculated
and an input list consisting of all variables on the right of the equal sign is established
for the statement. 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. In this case, sorting takes place only on the left hand or output variable so that
the block is positioned before any use of the variable.
Second pass Pass number two takes the list of statements and examines them in turn. If none of the
variables on the input list have their calculated flags set (meaning that the variable has
already been calculated), the statement is added to the compile file and the calculated
flag for the output variable (or variables) is turned off. If any of the variables on the
input list are marked calculated, the statement is saved in memory and the next
statement examined. If any statement has been added to the compile file, all the saved
statements are re-examined to see if they can now be added to the compile file and
their calculated flags reset. 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.
States State variables are not flagged as calculated. States are calculated by the integration
routine before all derivative evaluations.
Counters One-line algebraic loops are allowed as a way to mechanize counters. Technically, it
should be identified as an unsortable statement block, but it is a useful procedure that
is generally not a problem.
x = x + b

Example The following example demonstrates the sorting procedure. These statements appear
in DERIVATIVE code:
CONSTANT pi = 3.142, rz = 1.0
area = pi*r**2
r = rz + lr
lr = INTEG(area, 0.0)

The first statement is translated into a Fortran DATA statement and an I/O list is
established. There are no inputs and variables PI and RZ have their calculated flags set.
DATA PI/3.142/,RZ/1.0/

The second statement has inputs PI and R, and variable AREA has its calculated flag
set. The third statement has inputs RZ and LR; the calculated flag for R is set. The last
statement establishes LR as a state and AREA as the derivative. The calculated flag for
LR is not set; it is assumed to be known from the start because it is a state variable.
At the end of the first pass, the symbol table looks like Table 3-1, and the calculated
flags are set as in column (a). The second pass starts by reading the statements in
sequence again, along with the associated I/O lists. The first statement has no input
list, so it can be output to the compile file directly, at which time the calculated flags
for PI and RZ are reset, as shown in Column (b).

Page 3-4 ACSL Reference Manual


3.3 Program sorting 3. Program Structure

Table 3-1. Calculated flags in symbol table during sort

(a) (b) (c) (d)


Symbol begin after after R= after AREA=
pass 2 CONSTANT statement statement
area ON ON ON
lr
pi ON
r ON ON
rz ON

No other statements are pending, so the second statement is read. The inputs are PI and
R. R is still flagged as calculated, so the statement is saved. The third statement is
read. The inputs to this statement are RZ and LR. Neither of these inputs is flagged, so
that statement is transferred to the compile file and the output variable flag for R is
reset, as shown in column (c). The saved statement is re-examined, and now no input
variables are flagged, so the statement can be disposed of, erasing the flag on AREA.
Any well posed problem (without algebraic loops) can be completely sorted by this
method and the compile file then has all the statements correctly ordered.
CONSTANT CONSTANT statements are best placed where they are used. Since CONSTANT
statements are treated like regular assignment statements for sorting purposes, they
should not be placed at the end of the program as almost all the other statements would
have to be saved or held up, slowing translation time.
Algebraic Algebraic loops are identified during translation by the fact that statements are left
loops over at the end of the DERIVATIVE section sort. This is considered an error since
true algebraic loops should be broken by calculations, PROCEDURALs, or the
implicit integrators IMPLC (scalars) or IMPVC (vectors).
The unsortable statement block diagnostic lists all the statements involved in the
algebraic loop. It is usually easiest to follow the loop backwards from the bottom of
the list, where you will find that each variable on the left side of an equal sign appears
on the right hand side of the statement above it. PROCEDURAL blocks make
following the path more difficult since the entire block is listed and considered as one
statement. The position is determined by the variables on the left and right hand side
of the PROCEDURAL header. When the code is reconstructed by the translator, the
PROCEDURAL header is lost, so the dependencies for the entire code block should be
noted by hand to clarify the sequence.
The translator diagnostic listing of the algebraic loop delimits each original line or
block by four periods (. . . .) so that each PROCEDURAL block can be recognized;
variable names may have been changed and macros expanded, making identification
of individual code blocks difficult without this aid.
Most algebraic loops are programming errors caused by incorrect PROCEDURAL
headers or missing state equations. For example, the following code:
PROCEDURAL (a, b = c, d)
a = c
b = d
END ! of procedural
d = a

ACSL Reference Manual Page 3-5


3. Program Structure 3.4 Preset of user variables

causes an algebraic loop to be reported since it implies that A is a function of both C


and D, although this is not actually the case. Use PROCEDURALs sparingly and with
care. Using many small PROCEDURALs is better than using a few large ones.
Diagnosing When an unsortable statement block is diagnosed, first check the PROCEDURALs for
loops errors. Second, check for a modelling error such as a missing state in a control loop.
Multiple INITIAL sections and TERMINAL sections can be placed anywhere in a program.
INITIAL, The translator appends each INITIAL section to the end of any collected previously (to
DYNAMIC, a default null INITIAL if there is no explicit user INITIAL before the DYNAMIC or
and DERIVATIVE). Similarly, TERMINAL sections are collected as the translator sorts
TERMINAL
through the program, each appended to any collected previously. Thus, any
sections
TERMINAL sections defined in a DERIVATIVE section, for example, occur before
the code in an explicit final TERMINAL section.
Section As of Version 11.5, any section (INITIAL, DYNAMIC, DERIVATIVE, DISCRETE,
nesting or TERMINAL) can be nested within any other section, to any level of nesting. For
example, in a DERIVATIVE section, one can now write:
SCHEDULE burnout .XN. acceleration
DISCRETE burnout
INITIAL; dt = GAUSS(0.050, 0.001); END
SCHEDULE separation .AT. t + dt
END ! of burnout

3.4 Preset of
user variables

The ACSL executive presets all floating point variables to 5.5555E33, integers to
55555333, and logicals to .FALSE. The reason for this presetting is so that if a
variable is used before it is calculated, drastic results are seen. This helps prevent your
unknowingly using wrong answers. It particularly points up situations where a value
of zero would allow the program to proceed when it should not.
An especially insidious situation can occur when variables are not calculated before
being used in the case where more than one START is executed in a runtime session.
All runs after the first then use values left around at the end of the previous run.
Setting all user variables to a large number allows you to identify uncalculated
variables in the first debugging runs.

3.5 Preset of
derivatives

The ACSL executive presets all derivatives and residuals (as defined in INTEG,
INTVC, IMPLC, and IMPVC statements) before each START to 3.33333333E-33.
After the initial evaluation of the DERIVATIVE section, the executive checks that all
derivatives have changed from the preset value; if not, an error message is produced:
DERIVATIVE NO. n NOT CALCULATED

This message usually indicates that a derivative calculation has been skipped or that a
derivative is specified with a CONSTANT statement, which is not executable. You
can determine which derivative is referenced in the message by checking a DEBUG
dump or DISPLAY/ALL and counting down the list of derivatives.

Page 3-6 ACSL Reference Manual


4. ACSL Statements

4.1 Introduction
This chapter describes in detail all the basic statements recognized by the ACSL
translator. A number of these are the same as equivalent Fortran statements, with the
exception that ACSL places no restriction on column placement of the code.
FORTRAN Descriptions of Fortran functions are included in this chapter for convenience. We
functions recommend using only the generic functions since these are typed according to the
type of argument and output; e.g., use ABS instead of IABS, DABS, or CABS and
MAX instead of AMAX0, AMAX1, MAX0, MAX1, DMAX0, or DMAX1. To
specify one of the typed (non-generic) functions reduces flexibility, while the generic
functions adapt to single or double precision, INTEGER or REAL type, automatically.
Documentation In the following examples and descriptions, elements in lower case are syntactical
convention elements (i.e., variables) and may be replaced with any character string that satisfies
the definition. Elements shown in upper case must be exactly as spelled out in the
statement (although not necessarily in upper case). In specifying the integration
operator, for example, the word INTEG must be given exactly while all the other
elements are variables you name as part of the model. The form is specified as:
state = INTEG(deriv, ic)

An example would then be in the form:


x = INTEG(xd, xic)

!&;: The use of these characters in program code is described in this chapter under
Comment (!), Continuation (&), and Separator (;). The ampersand (&) is also used for
concatenation in macros (see Chapter 6). Statement labels, using a colon (:), are
discussed in Chapter 2. Wild cards (* and ?) are available for many of the runtime
commands (see Chapter 5), but are not used in program code.
CONSTANT Variables defined in CONSTANT statements generally should not also be defined in
recomputation assignment statements, so if the translator encounters this situation, it issues the
following warning message:
Warning: Re-computing a constant

See the section on CONSTANT in this chapter. The warning message can be
suppressed, as described in the ACSL Sim User's Guide.
Debugging Calls to LOGD can help in debugging a program when no system debugger is
available. See LOGD in this chapter for a description of this procedure. See Chapter 7
for a complete discussion of debugging.
Equal sign (=) ACSL uses the equal sign in an unfamiliar way. In translating a program, ACSL needs
to know the inputs and the outputs to each statement so that the statement sequence
can be sorted into the correct order. In assignment statements, all variables to the right
of the equal sign are inputs; the variable to the left is given the single numerical value
of the right hand expression and thus is the output. This concept is extended to cases
where more than one element is an output; i.e., all elements to the left of the equal sign
are considered outputs and those to the right are considered inputs.

ACSL Reference Manual Page 4-1


4. ACSL Statements 4.1 Introduction

Equal sign in This concept of the use of equal signs is extended to the PROCEDURAL, which has
PROCEDURAL the following possible form:
PROCEDURAL(a, b, c = d, e)
... 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.e., not to rearrange the order within the
block); that D and E are inputs; and that A, B, and C are outputs. Only variables
calculated elsewhere in the same DERIVATIVE section must be listed on the input
list. Constants need not appear on the list. However, beware – today's constant is
tomorrow's variable! State variables (output of state operators) must not appear on the
list.
See the section in this chapter on PROCEDURAL for details on when and how to use
this structure. See Chapter 3 for information on program flow and statement sorting.
Operators for Included in this chapter are descriptions of a number of functions especially designed
simulation models for simulation models. In general, the output of each function is a single number
(usually floating point) and the arguments are arithmetic expressions of arbitrary
complexity; i.e., these expressions may contain functions which contain arguments
which contain functions to any depth. Logical or relational expressions are used to
determine switching criteria in the special functions; use only .TRUE. or .FALSE. for
logical constants. Any other representation for logicals may not be recognized since
the bit pattern of logicals depends on the installation and Fortran compiler in use.
State operators Some operators involve state variables and can be invoked only from within a
DERIVATIVE section. While they may be included in a first level PROCEDURAL
block, these operators are always executed and cannot be successfully by-passed by
jumping around them. They also cannot be iterated in a DO loop. The following is a
partial list of such operators:
CMPXPL DBLINT IMPLC IMPVC INTEG INTVC LEDLAG
LIMINT OU REALPL TRAN

If an attempt is made to skip around any of these statements, 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. The correct method for stopping
a state variable from changing is to ensure that the derivative is set to zero.
Array name ACSL operator macro names should not be used for arrays names because of a
conflicts potential conflict. There is no problem with scalars, but when an array element is
referenced on the right side of an equal sign, it is seen as an argument to the system
macro. ACSL 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. ACSL operators whose names should not be used for arrays are:
BCKLSH CMPXPL DBLINT DELAY DELAYP DERIVT
DELSC DELVC EXPF GAUSI GAUSS HISTORY
IMPL IMPLC IMPVC INTEG INTVC LEDLAG
LIMINT LIMIT LINEAR LINES MODINT OU
OUTPUT PREPAR PTR RADC RADCI RDIG
RDIGI REALPL RESET RSHM RSHM RSHMI
RTDEVICE RTP SCALE SMOOTH TERMT TRAN
TRANZ UNIF UNIFI WDAC WDACF WDIG
WDZGI WSHM WSHMI ZOH

Page 4-2 ACSL Reference Manual


4.1 Introduction 4. ACSL Statements

Standalone form Some operators are defined as macros, and when the operator has only one output, two
of operators alternative forms of invocation (conventional and standalone) are possible. As an
example, consider REALPL, the first order lag. A conventional use of this operator is:
y = k1*REALPL(t1, x)

where the state variable (output of the real pole function) is given a dummy name (a Z
variable). It is usually advantageous to multiply the input rather than the output by
constants (synonymous if the operator is linear) as follows:
y = REALPL(t1, k1*x)

so that the input to the operator is now an expression. In this form of the expression,
the standalone macro invocation can be used as follows:
REALPL(y = t1, k1*x)

and in this case (only) the variable Y is assigned to the state table. This standalone
form is usually preferred in order to minimize the number of dummy variables, but
numerically all forms are equivalent.
Operators that can be given in standalone form are so indicated in their individual
descriptions. They are:
BCKLSH CMPXPL DBLINT DELAY DELSC DELVC
EXPF GAUSS HISTORY LEDLAG LIMINT LINEAR
OU REALPL SMOOTH TRAN UNIF

Precision of In the description of arguments, many are described as real floating point expressions.
operator The precision of this type of expression varies according to the global ACSL
arguments translation mode; i.e., single precision or double precision. All the subroutines
described here adapt automatically to this type change, either by the conversion rules
of Fortran for intrinsic functions like SIN, COS, MAX, MIN, etc. or else by selection
of a different ACSL runtime library.
Precision of The runtime library provides copies of ACSL functions and subroutines with
ACSL operators arguments of the correct type. For example, BOUND comes in two versions, one that
accepts all the arguments in single precision and produces a single precision result,
and one that accepts all the arguments in double precision and produces a double
precision result. This changeover is automatic with the selection of the single or
double precision mode on the ACSL command.
Selecting global The mechanism for selecting the ACSL runtime library depends on the computer
precision operating system. For example, on Unix systems, the -x option specifies double
precision; on VAX systems, the /DOUBLEPRECISION switch does the same. See the
ACSL Sim User's Guide.
Specifying We recommend that single or double precision not be specified in the program so that
precision in ACSL can handle all floating point variables according to the runtime library selected.
model code All unspecified floating point variables are considered REAL (single precision) with
the single precision library and DOUBLEPRECISION with the double precision
library. When sizing arrays, use the DIMENSION statement rather than REAL or
DOUBLEPRECISION; for example:
DIMENSION a(2,4), b(5,5,5), rm(3)

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. Assume a
subroutine MYSUB with two scalar real arguments, one scalar double and one vector
double precision arguments; i.e.,

ACSL Reference Manual Page 4-3


4. ACSL Statements 4.2 ABS

CALL mysub(rs1, rs2, ds1, dv2)

Then types would be specified as follows to ensure consistency within the subroutine:
REAL rs1,rs2
DOUBLEPRECISION ds1,dv2(20)

Another approach is to use the generic type changing functions REAL( ) and DBL( )
for the scalars. Then the type has to be specified only for the vector as follows:
DOUBLEPRECISION dv2(20)
CALL mysub(REAL(rs1), REAL(rs2), DBLE(ds1), dv2)

This is the preferred way since the actual precision of the variables RS1, RS2, and
DV1 is immaterial in the ACSL program.

4.2 ABS
FORM: y = ABS(x)

The output y is the absolute value of x where x is an expression. The output type
(INTEGER, or REAL, DOUBLEPRECISION) depends on the input type. An example
using ABS is:
cd = cdz + cdal*al + cdde*ABS(dle)

4.3 ACOS
FORM: y = ACOS(x)

The output y is the arc cosine of x where x is a floating point variable or expression
lying between -1.0 and +1.0. The result, in radians, lies between zero and π; its type
(REAL or DOUBLEPRECISION) depends on the input type. An example using
ACOS is:
th = ACOS(x/r)

4.4 AINT
FORM: y = AINT(x)

The output y is the truncation of x where x is a floating point variable or expression.


The output type (REAL or DOUBLEPRECISION) depends on the input type. This
function differs from INT where the output is type INTEGER for any type input. In
the following example, the result is -3.0.
a = AINT(-3.7)

Since INT( ) is promoted to REAL or DOUBLE as appropriate in any expression, the


only situation where it is necessary to use AINT( ) is in the argument to a subroutine
in order to force the type. For example, if the first argument of MYSUB is floating
point, the following ensures a truncated (integer) value, but transmitted as a floating
point number:
CALL mysub(AINT(v1), ...)

Page 4-4 ACSL Reference Manual


4.5 ALGORITHM 4. ACSL Statements

Table 4-1. ACSL integration algorithms

IALG algorithm step order

1 Adams-Moulton variable variable


2 Gear's stiff variable variable
3 Euler fixed first
4 Runge-Kutta fixed second
5 Runge-Kutta fixed fourth
6 none – –
7 user-supplied – –
8 Runge-Kutta-Fehlberg variable second
9 Runge-Kutta-Fehlberg variable fifth
10 Differential algebraic system solver variable variable

Using INT( ) in this situation doesn't work since the argument is passed with type
integer.

4.5 ALGORITHM
FORM: ALGORITHM name = integer constant

DEFAULT: name: IALG


integer constants: 5

where name is the new name for the integer defining the runtime algorithm. With this
statement, you can change the system variable name and/or the choice of integration
routine. 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.
Array with If a program contains only one DERIVATIVE section and no DISCRETE sections,
multiple sections ALGORITHM name (referred to by its default name IALG hereafter) is a scalar;
however, more than one DERIVATIVE and/or DISCRETE section results in IALG
becoming an array. The elements in IALG then correspond to the sections in the order
they are encountered in the source code. If ALGORITHM is defined outside a
DERIVATIVE section, then it is the global default for all DERIVATIVE sections;
DISCRETE sections have their algorithm slot set automatically zero. To change the
algorithm for a specific DERIVATIVE section, put an ALGORITHM statement with a
unique name in the section; for example,
DERIVATIVE
ALGORITHM fastalg = 4

The scalar name given is equivalenced to the array element; for example, if the
DERIVATIVE section is first in the program, FASTALG is equivalenced to IALG(1).
At runtime, either the array element or the local name can be referenced.
SET IALG(1)=1
SET fastalg=8

ACSL Reference Manual Page 4-5


4. ACSL Statements 4.5 ALGORITHM

Warning – do not The choice of integration algorithm cannot be changed during a run because table
change during space has to be allocated before the run begins. After once determining IALG for a
run run, ACSL never looks again to see if it has changed. The communication interval
and/or integration step size can be changed.
Recommended Table 4-1 lists the available integration algorithms. For fixed step algorithms, we
integration control 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). The integration step size for fixed step algorithms is calculated
by:
H = MIN(MAXT, CINT/NSTP)
H = MIN(H, time_to_next_event)

CINT is divided by NSTP. If NSTP is 1 and MAXT is less than CINT, then MAXT
sets the integration step size and CINT affects only the data logging rate. Events
include DISCRETE sections (usually controlled by an INTERVAL statement), state
events or time events activated by SCHEDULE statements, and CINT. CINT does not
have to be an even multiple of MAXT since the integration steps up to it automatically.
Fixed step The Runge-Kutta routines (IALG = 4 and 5) evaluate the derivatives at various points
algorithms across a step. A weighted combination of these derivatives is then used to step across
the interval. 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.
Euler is used for any integrations required by operators in DISCRETE sections.
Runge-Kutta second order advances the state with two derivative evaluations per step.
This usually needs a somewhat smaller step than Runge-Kutta fourth order (four
derivative evaluations per step). For the same step size, it should run about twice as
fast. Optimizing the step size and algorithm is generally worth the effort.
Runge-Kutta Figure 4-1 shows the procedure for the fourth order Runge-Kutta algorithm. If x is the
procedure state, h is the integration step size, and t is time, the derivative k is evaluated at the
beginning, twice at the midpoint, and once at the end of the integration step as follows:

k1 = f (xn , tn )

 hk1 h
k2 = f  xn + , tn + 
 2 2

 hk2 h
k3 = f  xn + , tn + 
 2 2

k4 = f ( xn + hk3 , tn + h )

The new state is then calculated by:


h
xn+1 = xn + ( k1 + 2k2 + 2k3 + k4 )
6
The second order Runge-Kutta routine follows a similar procedure, making one
derivative evaluation at the beginning and another at a point two-thirds across the step
as follows:

k1 = f ( xn , tn )

 2hk1 2h 
k2 = f  xn + , tn +
 3 3 

Page 4-6 ACSL Reference Manual


4.5 ALGORITHM 4. ACSL Statements

Figure 4-1. Runge-Kutta fourth order algorithm

The new state is then weighted by one-fourth and three-fourths and calculated by:
h
xn+1 = xn + ( k1 + 3k2 )
4
MINT, XERROR, and MERROR (discussed below for the variable step algorithms)
do not affect the fixed step algorithms in any way.
Variable step The Adams-Moulton (IALG=1) and Gear's Stiff (IALG=2) are both variable step,
algorithms variable order integration routines that are self-initializing. 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. 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:

Ei = MAX (Xi, Mi ∗ |Yi |MAX )

The order of integration starts at one and then changes dynamically as the program
progresses. The step size also changes dynamically as the integration routine attempts
to take the largest possible step consistent with the allowed error bounds.*
Adams-Moulton Adams-Moulton is useful for models in which the step size changes significantly
during a simulation, as for a satellite in a highly eccentric orbit. In this case, a much
larger step size can be used when the satellite is far from the earth than when it is near.
This algorithm can also help determine an appropriate step size for fixed step runs, as
described below.

* For more information on mechanization of the variable step, variable order integration routines, see subroutine
DIFSUB in Numerical Initial Value in Ordinary Differential Equations, C.W. Gear, Prentice-Hall, NJ 1971 pp
150 et seq.

ACSL Reference Manual Page 4-7


4. ACSL Statements 4.5 ALGORITHM

Gear's stiff 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.
Runge-Kutta- The Runge-Kutta-Fehlberg algorithms (IALG = 8, 9) are fixed order but variable step.
Fehlberg 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.
Differential The DASSL code* (IALG of 10) is intended to directly solve implicit differential
algebraic system algebraic equations (DAEs) where the derivative term cannot be specifically isolated
solver (DASSL) on the left hand side of an equation. In this case, instead of:
.
Y = F(Y, t)

we have:
.
F(Y, Y, t) = RESIDUAL = 0
.
where F, Y and Y are N-dimensional vectors and the zero is really the residual that is
being driven to zero. The following introductory description is take from Brenan,
Campbell, and Petzold p. 117. The basic idea for solving the DAE system using
numerical ODE methods, originating with Gear, is to replace the derivative in the
above equation by a difference approximation and then solve the resulting system for
the solution at the current time using Newton's method. Replacing the derivative by
the first order backward difference, we obtain the explicit Euler formula:

* For more information on the mechanization of DASSL, see Numerical Solution of Initial Value Problems in
Differential Algebraic Equations, by E.E. Brenan, S.L. Campbell, and L.R. Petzold, North-Holland, 1989.

Page 4-8 ACSL Reference Manual


4.5 ALGORITHM 4. ACSL Statements

 Yn+1 − Yn 
F  Yn+1 , , tn+1  = 0
 h n+1 
where:

hn+1 = tn+1 − tn

This nonlinear system is then solved for Yn+1 using a variant of Newton's method.
DASSL uses a fixed leading coefficient implementation of the BDF formula which
can approximate the derivative to higher accuracy at higher orders. The advantage of
the fixed leading coefficient is that this is the term that appears in the iteration matrix,
and the matrix only has to be recalculated on a change of step size – not on every
subsequent step – as the history washes out of the range of information needed to be
saved by backward differences.
In ACSL, the implicit form:
.
F( Y, Y, t ) = 0

is expressed as:
y, yd = IMPLC(F(y,yd,t), yic)

and is really implemented by adding both y and yd to the state vector as:
y = INTEG(yd, yic)
yd = IMPLC(F(y,yd,t), 0.0)

Thus, for every algebraic/differential state, two slots are allocated in the state table.
MINT with The variable step algorithms never take steps smaller than MINTERVAL (MINT).
variable step The integration step size for variable step algorithms is calculated as for the fixed step
algorithms algorithms with the addition of a check on the minimum step size as follows:
H = MAX(MINT, MIN(MAXT, CINT/NSTP))

NSTP with NSTP can be set to help a variable step algorithm start off. If the first try
variable step (CINT/NSTP) is too large (i.e., if the estimated error is larger than the allowed error),
algorithms 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.
Error summary 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. You
can adjust the error criteria (XERROR and MERROR) 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. See Chapter 7 for a more
detailed discussion. The summary may be suppressed by setting the system variable
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 PREPAREd.
Determining Determining an appropriate step size for a fixed step algorithm is worth some effort. If
appropriate step a step size is too large, the results are inaccurate or even catastrophic; if too small,
size computer time is wasted.

ACSL Reference Manual Page 4-9


4. ACSL Statements 4.6 ANINT

For fixed step algorithms, the step size should normally be about the size of the
smallest time constant. One or two points per radian (six to ten per cycle) is sufficient
to keep the system from becoming unstable. The time constants can be determined
using the runtime command:
ANALYZE /EIGEN

The eigenvalues are listing in ascending order; these are the reciprocal time constants
of the system. The reciprocal of the largest eigenvalue is often a good choice for the
integration step size for fixed step algorithms.
Another approach is to use a variable step algorithm to see what ACSL believes to be
appropriate. Use the Adams-Moulton routine and the system variables for current step
size and current integration order as follows:
SET IALG=1
PREPARE T,CSSITG,CIOITG ...
START
PLOT CSSITG,CIOITG

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 your choice of algorithm order and step size.
Efficiency and You can compare the efficiency of the various algorithms with the SPARE command;
accuracy for example:
SET IALG=4
SPARE ; START ; SPARE
SET IALG = 5
SPARE ; START ; SPARE

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

4.6 ANINT
FORM: y = ANINT(x)

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
in order to force the type. For 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), ...)

Page 4-10 ACSL Reference Manual


4.8 Assignment statements 4. ACSL Statements

4.7 ASIN
FORM: y = ASIN(x)

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 (−π ⁄ 2 ≤ y ≤ + π ⁄ 2 ); its type (REAL
or DOUBLEPRECISION) depends on the type of the argument. 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

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. In the example
a = INTEG(ad, aic)

A is marked as a state variable and AD is stored as the derivative of A.


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

where lvariable may be simple or subscripted and lexpression is a logical expression


formed from a logical operator; for example:
flag = a .NE. b .OR. flag2

4.8.3 Character

FORM: cvariable = cexpression

where cvariable is a character variable or substring and cexpression is a character


expression; for example:
cvar(5:10) = string(1:4)//'Z'

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

ACSL Reference Manual Page 4-11


4. ACSL Statements 4.9 ATAN

Figure 4-2. Mechanism Illustrating BCKLSH Operator

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)

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 (−π ⁄ 2 < y < +π ⁄ 2 ). ATAN
could be used as follows:
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)

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
(−π < z ≤ + π ). An example of ATAN2 is:
pdgn = ATAN2(dlq, dlp + 1.0E-30)

4.11 BCKLSH
FORM: y = BCKLSH(ic, dl, x)
BCKLSH(y = ic, dl, x)

where:
ic = initial condition of y
dl = half the width of the backlash
x = input (a floating point variable or expression)

Page 4-12 ACSL Reference Manual


4.13 CALL 4. ACSL Statements

The output always lies between the limits (x - dl) and (x + dl). Figure 4-2 illustrates
the backlash mechanism.
For asymmetrical applications, the expression for the input x should be rewritten; for
example, if y is to move when x is greater than (Y+UL) or less than (Y-LL), then:
y = BCKLSH(yic, 0.5*(ul - ll), x - 0.5*(ul + ll))

Warning – sorting The BCKLSH operator must be in a sorted (DERIVATIVE) section.

4.12 BOUND
FORM: y = BOUND(bb, tb, x)

where:
bb = bottom bound
tb = top bound
x = input (a floating point variable or expression)
The output y is as follows:

y = bb when x < bb
y =x when bb ≤ x ≤ tb
y = tb when x > tb

This function bounds or limits variables. 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. The function LIMINT should be used in this case. A statement using
BOUND could be:
MAXT = BOUND(maxtmn, maxtmx, maxtp)

4.13 CALL
FORM: CALL name
CALL name (p1, p2, ..., pn)
CALL name (o1, o2, ..., on = p1, p2, ..., pn)

where name is the name of a subroutine being called, pi are actual arguments that may
be expressions of arbitrary complexity for input values, and oi are output variables
(names or arrays). Arguments may be variables, arrays, or subscripted variables.
Note that in the second form, the translator cannot tell which arguments are inputs and
which are outputs; if the call is in a sortable section of the program, it should be
embedded in a PROCEDURAL block that describes the inputs and outputs. If the call
is any other section, a PROCEDURAL is still recommended to avoid the Symbol used
but not defined diagnostic. For example, if oi are output variables and pi are input
variables or expressions, then the following statements are valid:
PROCEDURAL (o1, o2, o3 = p1, p2, p3, p4)
CALL subr(o1, p1, p2, p3, p4, o3, o2)
END

Now the translator sorts this section correctly since it has been told which variables are
inputs and which are outputs.

ACSL Reference Manual Page 4-13


4. ACSL Statements 4.14 CHARACTER

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. In this
form, the subroutine could be called with:
CALL subr(o1, o2, o3 = p1, 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, p2, p3, o1, o2, o3)

4.14 CHARACTER
See TYPE.

4.15 CINTERVAL
FORM: CINTERVAL name = real constant

DEFAULT: name: CINT


real constant: 0.1

where name is a simple unsubscripted variable.


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. In general, no finer detail can be seen in OUTPUT, PRINT, or PLOT,
so it is important to choose this value with care. A communication interval that
generates about 100 to 200 data points during a run is sufficient detail for most
applications.
Sampling effect Beware the sampling effect whereby high frequency oscillations can be folded down
to lower frequencies or even a DC level if the sampling time is not small enough.
Adjusting step If the next integration step to a communication interval is less than 1.0E-11 (1.0E-6 in
size to CINT single precision) of the current time (or CINT, whichever is larger), the step is
discarded as negligible. This situation can occur because of accumulation and
rounding on a binary machine. The integration algorithm takes steps up to the next
communication interval by accumulating the fixed step (for example, with MAXT =
0.01 and CINT = 0.1; after ten steps, the time is about 0.1 because of rounding in both
0.01 and 0.1). To prevent accumulated roundoff error, a small adjustment is made to
the communication interval. 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.
Double precision To get full precision when changing CINT and MAXT at runtime, use the double
precision specification:
SET cint = 0.1D0
SET maxt = 0.01D0

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. For example,
assume that a missile simulation has the following four phases of flight:

Page 4-14 ACSL Reference Manual


4.15 CINTERVAL 4. ACSL Statements

INITIAL
INTEGER phase
DIMENSION cinttab(4)
CONSTANT cinttab = 0.1, 1.0, 0.05, 0.05
phase = 1 ! Initialize phase to start
...
END ! of initial
DYNAMIC
DERIVATIVE
! Compute phase of flight
PROCEDURAL(phase = , , ... )
...
END ! of procedural
...
END ! of derivative
CINT = cinttab(phase)
...
END ! of dynamic

Figure 4-3. Outline of program to vary communication interval

1) Initial turn
2) Midcourse
3) Acquisition
4) Terminal
It would be useful to measure these phases at different rates; e.g., initial turn at a fairly
fine level of 0.1 second, the long midcourse only every second, and acquisition and
terminal at a fine rate of 50 msec. Figure 4-3 outlines a procedure for setting the
communication interval for each phase. In the INITIAL section, PHASE is declared to
be an integer and initialized to one. An array CINTTAB is defined and filled with the
communication intervals to match the phases of flight as numbered above. In the
DYNAMIC section, the communication interval (using default name CINT) is set
using the current value of the flight PHASE (which ranges from one to four). In the
DERIVATIVE section, the value of PHASE is computed from the logic used to
establish the different flight regions. This code is shown as a block since the algorithm
depends on the implementation of the model; but no matter how it is implemented, the
value of PHASE is maintained in the range one to four.
Changing default The name of the variable defining the communication interval can be changed from
name the default CINT; for example,
CINTERVAL CI = 0.001

Now all references are to CI when the value is recorded or changed.


Bound on CINTERVAL acts as an upper bound on the integration step size (and also for the last
integration step 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.
This subject is discussed in more depth under DYNAMIC. The actual integration step
is obtained from the following algorithm:
H = MIN(MAXT, CINT/NSTP)
H = MIN(H, 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.

ACSL Reference Manual Page 4-15


4. ACSL Statements 4.16 CLOSE

MACRO cmpxpl(y,p,q,x,ic1,ic2)
MACRO STANDVAL ic1=0.0,ic2=0.0
MACRO REDEFINE ydot
ydot = INTEG(((x)-(y)-(q)*ydot)/(p), ic1)
y = INTEG(ydot, ic2)
MACROEND

Figure 4-4. CMPXPL operator macro

4.16 CLOSE
FORM: CLOSE(UNIT = lu [, STATUS = p])

where:
lu = an integer variable or expression for a logical unit number
p = a character string of either KEEP or DELETE
This operator closes any file that has been opened with the OPEN command.

4.17 CMPXPL
FORM: y = CMPXPL(p, q, x, ic1, ic2)
CMPXPL(y = p, q, x, ic1, ic2)

This operator, listed in Figure 4-4, conveniently implements a second order transfer
function where the output y is related to input x through the transfer function:
y 1
= 2
x ps + qs + 1

such that:
.
y (0) = ic1
y (0) = ic2
Restrictions The same restrictions on initial conditions apply as for the INTEG operator, and both
ICs may be omitted if zero. The time constants p and q may be expressions of arbitrary
complexity, but p may not be zero. Setting p to zero results in division by zero, as can
be seen in the listing of the macro.
Warning This operator (as all the memory operators) should be used only in sorted sections and
should not be used in a PROCEDURAL block.
The CMPXPL operator could be used as follows:
x = k2*CMPXPL(a, b, xp)

4.18 Comment (!)


FORM: !string

All text after an exclamation point to the end of the line is considered a comment. The
test is reproduced in the listing and then discarded. Examples of comments are:

Page 4-16 ACSL Reference Manual


4.19 COMMON 4. ACSL Statements

! ---------------- Calculate the derivative


x = a + b ! Add 'a' and 'b' and place in 'x'
a = sin(w*t) ! Forcing function acceleration

Comments can also be added after continuations (& at end of code) since the
comments are stripped off before the rest of the line is analyzed by the translator.
cm = cmz + cmal*al & ! pitch moment coefficient
+ cmde*dle + (cb/(2*v))*(cmad*ald + cmtd*q)

4.19 COMMON
FORM: COMMON / cname / clist

where:
cname = the name of the common block. This name is communicated to the
linker.
clist = a comma-delimited list of variable names which may optionally be
dimensioned; e.g., K(2,3,4).
Note: Don't mix CHARACTER variables with other types (REAL,
DOUBLEPRECISION, INTEGER, LOGICAL) in the list. Also, user
common block variables are not preset (ANSI Fortran requirement).
The COMMON statement provides a means of associating variables in Fortran
subroutines and functions with the ACSL model code, and, in particular, entering the
variable names into the model dictionary. Entering names into the dictionary allows
constants to be changed and variables to be viewed and plotted at runtime.
Types Variable names in the COMMON block list are not typed automatically. Standard
Fortran conventions apply; i.e., variable names beginning with I, J, K, L, M, or N are
considered INTEGER, and all other names are assumed to be floating point single
precision. Deviations from these assumptions are handled by specific type statements,
which are usually bundled with the COMMON statement in an INCLUDE file.
System variables ACSL system variables, states, derivatives, and initial conditions are allocated to
and states specific places by the ACSL translator and cannot be moved to external common
blocks. The system variables include all those with names starting ZZ and the program
control variables such as T, CINT, IALG, NSTP, MAXT, and MINT.
The states, derivatives, and initial conditions (as listed in a debug dump) also cannot
be moved to external common blocks. ACSL needs to maintain them in a linear list for
the integration routines to see as a vector. See the chapter on Debugging for more
information on system variables and common block names.
Examples Examples of COMMON statements are:
COMMON / scalc / x,y,z(10)
REAL k1,k2
COMMON / adata / k1,k2,index

In INCLUDE file A bundle of statements in an INCLUDE file could look like:


LOGICAL flag1,flag2
INTEGER count1,count2
REAL k1,k2
COMMON / mcom / count1,flag1,k1,x2,count2,flag2,k2,x2,a(250)

ACSL Reference Manual Page 4-17


4. ACSL Statements 4.20 CONSTANT

4.20 CONSTANT
FORM: CONSTANT d1 = a1, d2 = k*a2, d3 = a31, a32, k*a33

where:
di = identifiers representing simple variables or array names. Implied DO
loop notation may not be used. If di is an array name, integer subscripts
may be used to fill individual elements within the array, or else the
entire array must be filled.
ai = literals and signed or unsigned constants or PARAMETER names.
k = integer constant or integer PARAMETER name repetition factors;
the literal following the asterisk is repeated k times.
The CONSTANT statement is similar to a Fortran DATA statement and is used to
preset symbolic locations with numeric data. Since it is not an executable statement, it
can be placed anywhere in the program. The recommended placement is just before
the statement using the CONSTANT value.
Examples Examples of the correct use of the CONSTANT statement include:
LOGICAL switch1
INTEGER ii
DIMENSION a(2)
CONSTANT switch1=.TRUE., ii=2, a=2*1.0, b=-5.76

CONSTANT vs. The effect of the CONSTANT statement is quite different from that of an assignment
assignment statement. The assignment statement moves data from one place to another (into the
statement location for the variable to left of the equal sign) every time control passes through the
statement. The CONSTANT statement, on the other hand, just presets the variable to
the left of the equal sign when the simulation is loaded into memory. The variable can
then be overridden by assignment statements or by runtime SET statements.
Assignment statements for constants such as the following should be avoided:
INITIAL
k1 = 5.70
k2 = 7.63
END

Although these values can be changed at runtime by SET statements, 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. Replace the code above with a
CONSTANT statement as follows:
CONSTANT k1 = 5.70, k2 = 7.63

Now the values of K1 and K2 can be changed at runtime and remain that value until
changed again by another SET statement.
Initializing CONSTANT statements should not be used to initialize counters. For example,
counters counters are often initialized in the INITIAL section and then incremented later:
INITIAL
INTEGER n
n = 0
END
DYNAMIC
n = n + 1
...

Page 4-18 ACSL Reference Manual


4.21 Continuation (&) 4. ACSL Statements

If the counter were initialized using a CONSTANT statement, the results would be
correct for the first run, but any subsequent runs would start with the value left over at
the end of the previous run.
Warning When a variable is given a value in a CONSTANT statement and later appears on the
message left side of an equal sign, the translators issues a warning message:
Warning: Re-computing a constant.

The warning does not abort translation. Warning messages can be suppressed with a
switch on the call to ACSL. See the ACSL Sim User's Guide.

4.21 Continuation (&)


FORM: statement &
[&]continuation

Any model source code (or runtime) statement can be continued onto another line by
ending the first line with an ampersand (&). Any number of continuation lines is
allowed (although the resulting Fortran code may be limited to twenty packed lines)
and the ampersand may appear in any column up to 72. 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.
cm = cmal*al + (cmq*wm(2) &
+ cmbep*be*wm(1))*d/(2.0*vmam(1))

If the continuation line begins with an ampersand, then blanks at the beginning of the
line are dropped; this allows name and character strings to be continued without
starting the continuation line in column one.
charactervariable = 'longcharact&
&erstring'

In other words, blanks between the two ampersands are eliminated.


Blank lines Because the syntax analyzer looks for the leading ampersand in continuations, a blank
line results in a syntax error. To introduce blank lines in continuations, use two
ampersands; for example:
TABLE xyz, 1 , 10 &
& &
/-10.0 , 0.0 , 30.0 , 60.0 , 120.0 &
, 150.0 , 180.0 , 210.0 , 240.0 , 270.0 &
& &
, 8.33 , 8.33 , 4.0 , 1.6 , 5.2 &
, 5.2 , 6.6 , 8.3 , 10.7 , 16.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.

ACSL Reference Manual Page 4-19


4. ACSL Statements 4.22 CONTINUE

4.22 CONTINUE
FORM: label: CONTINUE

CONTINUE is normally used to transfer control after a GO TO command or to


terminate a DO loop. It is the preferred statement for all labels due to problems with
macro expansions as explained in Chapter 2. Note that code using CONTINUEs and
labels generally requires the use of PROCEDURALs in sorted sections.

4.23 COS
FORM: y = COS(x)

The output y is the cosine of x where x is a floating point variable or expression in


radians. The result is in the range (−1.0 ≤ y ≤ + 1.0 ). The type (REAL or
DOUBLEPRECISION) of the output and function depends on the type of the
argument. A statement using COS could be:
simd = (wm(2)*COS(fim) - wm(3)*SIN(fim))/COS(thm)

4.24 DBLE
FORM: DBLE(x)

This function converts an integer, single precision, or double precision argument x to


double precision.
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. If a subroutine requires
a double precision argument, then the type can be forced in the form:
CALL mysubr(DBLE(x1), DBLE(x2), ... )

Now whether the global translation mode is single or double precision, the input
arguments to the subroutine are the correct type. Alternatively, arguments can be
forced to DOUBLEPRECISION type by:
DOUBLEPRECISION x1,x2
CALL mysubr(x1, x2, ... )

This method fails however with global single precision if the inputs x1 or x2 are states,
derivatives, initial conditions, or any of the ACSL system variables (e.g., CINT,
MAXT, etc.).
Variables that are given values by the subroutine can't be supplied in function form.
The reason this does not work is that the function form copies the actual argument to a
temporary location. Such variables must be forced to a precision by either
DOUBLEPRECISION or REAL; for example:
DOUBLEPRECISION y1,y2
CALL mysubr(DBLE(x1), DBLE(x2), y1, y2)

A similar procedure applies for single precision where REAL forces the single
precision type:
REAL y3,y4
CALL mysubr2(REAL(x3), REAL(x4), y3, y4)

Page 4-20 ACSL Reference Manual


4.25 DBLINT 4. ACSL Statements

macro dblint(x,v,xic,a,vic,lbx,ubx)
macro redefine vl,ic
constant ic=0.0
callzzdlim(v,vl=ic,x,integ(zzlimf(x,a,lbx,ubx),vic),lbx,ubx)
x=intvc(v,xic)
macroend

Figure 4-5. DBLINT operator macro

4.25 DBLINT
FORM: DBLINT(x, xd = xic, xdd, xdic, bb, tb)

where:
x =displacement
.
xd =velocity (x )
xic =x(0); i.e., initial condition of x
..
xdd =the input, acceleration (x )
. .
xdic = x (0); i.e., initial condition of x
bb = bottom bound
tb = top bound
The DBLINT (double limited integration) operator, shown in Figure 4-5, is for
integrator limiting when the limited output is the second integral of an acceleration.
Mass-spring- This type of limiting can best be explained in terms of the mass-spring-damper system
damper system described by:
.. .
mx + bx + cx = f (t )

such that:
.
x (0) = xdic
x (0) = xic

where physical stops constrain the mass to move only between xbb (bottom bound) and
xtb (top bound); i.e.,

xbb ≤ x ≤ xtb

When the displacement (x) of the mass reaches its limit, the mass must stop, implying
.
that the velocity (x ) is zero. The mass must remain stopped until the force acting on it
(f (t) − cx ) changes sign.
Alternate An alternate way of performing this operation is to wrap a stiff spring around the loop
implementation when the wall is approached; this corresponds to what happens physically since the
wall always has a finite spring constant. Figure 4-6 is a block diagram of such a
system where Ks is spring stiffness, Kw wall stiffness, and Kd the damping constant.
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. 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).
Warning This operator (as all memory operators) can be used only in DERIVATIVE sections
and should not be put in a PROCEDURAL block.

ACSL Reference Manual Page 4-21


4. ACSL Statements 4.26 DEAD

Figure 4-6. Alternate implementation for DBLINT

4.26 DEAD
FORM: y = DEAD(bb, tb, x)

The DEAD operator implements a dead zone in output y when x lies between a
specified bottom bound bb and top bound tb. The results can be represented as follows:

y = x − bb ; x < bb
y = 0.0 ; bb ≤ x ≤ tb
y = x − tb ; x > tb

The dead zone operator could be used as follows:


v2 = v1 + k*DEAD(vmn, vmx, v3)

4.27 DELAY
FORM: y = DELAY(x, ic, tdl, nmx, delmin)
DELAY(y = x, ic, tdl, nmx, delmin)

where:
x = the input (an arithmetic expression of arbitrary complexity).
ic = the initial value of the output until the independent variable has
advanced by the delay, tdl. This argument must be a variable name
(rather than a literal constant) for the runtime command REINIT to
work. REINIT needs a name into which to store the current DELAY
output as the initial condition for subsequent runs.

Page 4-22 ACSL Reference Manual


4.27 DELAY 4. ACSL Statements

tdl = the delay time between input and output (any expression with a value
≥ 0.0).

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.

Note: This integer must be a literal integer or a parameter name with an


integer value. For example:
co = DELAY(ci, cic, cdl, 1000, cmn)

Using a PARAMETER variable:


INTEGER cmx
PARAMETER(cmx=1000)
co = DELAY(ci, cic, cdl, cmx, cmn)

This integer nmx allocates space in a circular buffer to hold the history
data of previous sample times and previous input values. If delmin is
defined, 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).
delmin =minimum interval between saving of data points in delay buffer. This
argument may be omitted, in which case a default of zero is used.
Typically delmin can be a tenth or a hundredth of the expected delay
time and still represent dynamics adequately.
The DELAY operator delays a variable in time to model transport effects such as
passage through a pipe. It should not be used lightly since it may require considerable
storage unless delmin is specified.
Implementation The DELAY operator is implemented by allocating a dummy array, 2*nmx words
long, and prefilling it with the value of ic, extending over all past history. Each entry
in the table is associated with a time, and at each new integration step (or delmin,
whichever is larger) a new value is inserted into the array, treating it as a circular list.
To compute the output value, 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. A linear interpolation is performed between the corresponding
input values. If not enough data points are present, an error is reported and the run
terminates.
Varying time When tdl changes dynamically, this operator approximates the pipeline with a varying
delay flow rate.
Direct feedback The operator provides an algebraic path from input to output, so direct feedback
not allowed (without an integrator) is illegal; the following for example is not allowed:
y = DELAY((n - y)/k, yic, tdl, 1000, 0.1)

If direct feedback is really necessary, the output of the DELAY can be filtered through
a real pole to break the loop. This is a good idea anyway since it eliminates jumps in
the slope of the DELAY output produced by the straight line interpolation. For
example:
y = REALPL(tfilt, DELAY((in - y)/k, yic, tdl, 1000, 0.1))

In this situation, TFILT is chosen to be small relative to the delay time (tdl).

ACSL Reference Manual Page 4-23


4. ACSL Statements 4.28 DELSC

4.28 DELSC
FORM: state = DELSC(xn, ic)
DELSC(state = xn, ic)

where:
state = a simple variable (DELVC handles vectors)
xn = an arithmetic expression of arbitrary complexity; i.e., may contain further
DELSC statements or other functions or macros.
ic = a simple non-subscripted variable, a real constant, or a general
expression enclosed in parentheses.
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.
DELSC may be embedded in any legal expression as a function that has a single
output: the value of the state. When the delay statement is alone, then the state name
can be identified; embedding it in an expression means that an ACSL-generated
variable (i.e., in the form Znnnnn) is used for the state name.
Warning – The DELSC statement can be placed only in a DISCRETE section, not a
DISCRETE only DERIVATIVE section.
With initial Since DISCRETE sections are not in general sorted, if an expression is used for the
conditions initial condition, then the DELSC expression must be placed before any reference to
the state and after the calculation of the next value, so that this form is normally to be
avoided. 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.
In the more general case, 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.
Placement In unsorted DISCRETE blocks, DELSC must be placed after the calculation of its
inputs.
See the description of the INTEG statement for a general description of the way the
ACSL system build tables of states, derivatives, and initial conditions. DELSC places
the state in the state table, the next state in the derivative table, and the initial condition
value in the initial condition table. 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.0*(x(2) + c), yz)
x = 4.0*DELSC(4*y, 0)
z = DELSC(znext, zic)

Page 4-24 ACSL Reference Manual


4.30 DERIVATIVE 4. ACSL Statements

4.29 DELVC
FORM: x = DELVC(xn, xic)
DELVC(x = xn, xic)

where X, XN, and XIC are arrays of the same size and correspond to state, derivative,
and initial conditions, respectively.
The restrictions on the DELSC operator with regard to arrays can be avoided by using
this vector integrator operator. 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.
In unsorted DISCRETE blocks, DELVC must be placed after the calculation of its
inputs.
The following are examples using DELVC:
DIMENSION x(1), xic(10), m(5,5), mn(5,5), mic(5,5)
y = DELVC(yn, yic) ! scalar delay
x = DELVC(xn, xic) ! vector delay
m = DELVC(mn, mic) ! matrix delay

4.30 DERIVATIVE
FORM: DERIVATIVE [name]
...
END

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. The
DERIVATIVE statement must be paired with a matching END statement.
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; i.e., the integration
algorithm calls the DERIVATIVE section. The actual number of evaluations depends
on the integration algorithm employed.
Transfers illegal All the statements in the DERIVATIVE section are translated into a separate
subroutine, so it is illegal to transfer control by GO TOs from DERIVATIVE sections
to other sections (INITIAL, DYNAMIC, DISCRETE, or TERMINAL) or vice versa.
Multiple More than one DERIVATIVE section may be used, each with its own independent
DERIVATIVE integration algorithm and integration step size. Although this technique can save
sections execution time when correctly used, any implementation must be approached with
caution since, in general, incorrect answers are likely unless the model is split with a
full understanding of the effects of computation delays for variables that cross block
boundaries. This tool has been provided for research into problem splitting rules and
should be regarded more as a state-of-the-art technique rather than for every day
practical implementation. For a novice, no more than one DERIVATIVE section
should ever be used.
When using more than one DERIVATIVE section, each DERIVATIVE section is
closed with its own END statement, and all the DERIVATIVE sections are enclosed
within the DYNAMIC section. Each DERIVATIVE section can have its own
integration algorithm, maximum step size, minimum step size, and NSTEPS value.
Default values for these quantities are established in normal fashion. If a value is

ACSL Reference Manual Page 4-25


4. ACSL Statements 4.30 DERIVATIVE

Table 4-2. Translator event list

A B C D ... E F G

0.0 0.0 0.001 0.002 0.010 0.010 0.011


1 2 1 1 1 2 1

0.0 0.001 0.010 0.010 0.010 0.011 0.020


2 1 2 2 2 1 2

specified outside a DERIVATIVE section, this becomes the default for all
DERIVATIVE sections. Values relating to a particular DERIVATIVE section are
defined by including the appropriate statement within the DERIVATIVE section; e.g.,
ALGORITHM IALG = 4
NSTEPS NSTP = 1
DYNAMIC
DERIVATIVE sec1
ALGORITHM alg1 = 3
MAXTERVAL max1 = 0.001
...
END ! of sec1
DERIVATIVE sec2
MAXTERVAL max2 = 0.010
...
END ! of sec2
END ! of dynamic

The first two statements establish algorithm number four (4) to be the default
ALGORITHM and one (1) to be the default of NSTP. Within DERIVATIVE section
"sec1", the algorithm is specified to be three (3), with a maximum step size of 1 msec
(0.001). Within DERIVATIVE section "sec2", the default algorithm (4) is taken and
the maximum step size set to 10 msec (0.010). Since NSTP is one, these are the actual
step sizes.
Arrays of system These changes in block descriptor names are implemented by forming an array
variables dimensioned to the number of DERIVATIVE (and DISCRETE) sections for each one
of the describing quantities. The names used are the default or those specified outside
the DERIVATIVE sections. In the preceding example, these names and their
dimensions would be IALG(2), NSTP(2), MAXT(2) and MINT(2). Names specified
within the DERIVATIVE sections are equivalenced into appropriate slots of the main
array; e.g.,
EQUIVALENCE(IALG(1), alg1)
EQUIVALENCE(MAXT(1), max1)
EQUIVALENCE(MAXT(2), max2)

and preset to the values specified. These values can be changed by SET commands at
runtime. To change the integration algorithm for section two in the example, it must be
referred to as IALG(2) since a name was not explicitly given; i.e.,
SET alg1 = 5, ialg(2) = 5

Because of the equivalencing convention, it is important that unique names be used for
descriptors defined within DERIVATIVE blocks; do not use the same name in
different DERIVATIVE sections.

Page 4-26 ACSL Reference Manual


4.30 DERIVATIVE 4. ACSL Statements

Order of At the start of the simulation run, the DERIVATIVE blocks are placed on an event list
execution and executed in the order in which they are specified in the model definition section.

Each section is placed back on the event list assigned with the time to which that block
has advanced. In the case given of a 1 msec step associated with Section 1 and 10
msec step associated with Section 2, the event list is as in Table 4-2.
After Section 1 has been advanced one step to 1 msec, the event list has Section 2 at
the top (B) with a time of 0.0. Advancing this section one step leaves it at 10 msec and
now Section 1 is back at the head of the list again (C). Section 1 keeps on being
advanced until both sections are at 10 msec (E). Now we assume that 1 is a little ahead
of 2 and goes to 11 msec (F). Next step advanced 2 by 10 msec and the event list
picture changes to (G). This cycle then repeats.
Sections not Note that the sort algorithm cannot rearrange statements over a block boundary, so that
sorted if a value calculated in the second block is used in the first block, at the first evaluation
it is undefined. Such variables should be initialized in the INITIAL section.
Barriers at CINT, The only break in the regular progression is at a communication interval or at an
DISCRETE, or equivalent barrier represented by a DISCRETE section or a SCHEDULE event. The
SCHEDULE times for all DISCRETE, SCHEDULE, and communication actions are entered onto
the event list where all actions are ordered in time; the next time on the event list is
called the barrier time.
For all DERIVATIVE blocks, the current step size is checked against the current time
(T) and the barrier time from the next event list. If integration with the current step
size would exceed the barrier time, the actual step is reduced so that the last step is
made exactly up to the event. All states then line up in time for the event to take place.
NXEITG The setting of the ACSL system symbol NXEITG (no extra evaluation, default
.FALSE.) controls whether an extra derivative evaluation is calculated at
communication intervals and discrete events. The derivatives and intermediate
algebraic variables have values based on the last state vector, but this vector is
changed for the actual integration step. The default (with NXEITG set to FALSE) is to
re-evaluate the derivatives prior to any event, including the communication interval.
This action ensures that all derivatives and intermediate algebraic quantities
correspond to the actual state values.
A small amount of computer time can be saved by setting NXEITG to TRUE. This is
reasonable if the differences in the results are small, which is usually the case. If any
discrepancies are encountered, remember that the state variables are at the correct time
and any algebraic variables can be re-derived in the sampling code if necessary.
CINT as integer Most people choose integration step sizes and communication intervals that are integer
multiple of step multiples of each other. The ACSL system does not require this. For example, it is
size acceptable to choose a fixed step length for the continuous section of 4 msec, a
sampling INTERVAL in the DISCRETE block of 11 msec, and a communication
interval of 20 msec. The first few integration step sizes would then be (in msec):
4, 4, 3, 4, 4, 1, 2, 4, 4, 3, 4, 3, 4, ...

The first short step of 3 msec brings time up to 11 msec, the first barrier time, which is
due to the DISCRETE section. 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. The next
barrier is the DISCRETE block at 22 msec causing a step size of 2 msec, and so on.
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.

ACSL Reference Manual Page 4-27


4. ACSL Statements 4.31 DERIVT

4.31 DERIVT
FORM: y = DERIVT(ic, x)
DERIVT(y = ic, x)

where:
ic = y(0)
x = the input (an arithmetic expression)
The derivative function differentiates x and can be implemented if absolutely
necessary. Note that it is never necessary to invoke a derivative; the derivative can be
expressed instead in terms of all the other states in the system. Since the derivative
operator is a first order approximation, it can lead to instability if it is used to represent
any major loop. 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.
PID example As an example of how DERIVT can be avoided, consider the D term in a PID
(proportional, integral, derivative) controller. There is a tendency to use DERIVT for
this term, but in hardware, it is always implemented by a differentiation over a first
order lag; i.e.,
y Ks
=
x T1 s + 1

This formulation can be represented by a single line of ACSL code:


y = (k*x - INTEG(y, ic))/t1

Nature never has a free differentiator; it is always combined with a lag to make it
realizable.
Warning – The use of DERIVT invalidates the Jacobian calculation from the ANALYZE
Jacobian command, including all the derived data (zeros, root locus, and frequency response
plots). This is another good reason not to use DERIVT.
Warning – The DERIVT operator (as all memory operators) should be used only in sorted
sorting sections and should not be put in a PROCEDURAL block.
Warning – Use a variable name rather than a literal constant for the initial condition so that
initial condition REINIT has a place to store it; otherwise REINIT tries to overwrite the global zero
with the one in the common block.
Example An example of a DERIVT statement could be:
ald = DERIVT(alic, al)

4.32 DIM
FORM: y = DIM(x1, x2)

The output y is the positive difference between x1 and x2 where x1 and x2 can be
INTEGER, REAL, or DOUBLEPRECISION variables or expressions. DIM takes its
type and types its output based on the type of the arguments. The result can be
represented as follows:

y = x1 − x2 ; x1 > x2
y = 0.0 ; otherwise

Page 4-28 ACSL Reference Manual


4.33 DIMENSION 4. ACSL Statements

People often write the following logic:


PROCEDURAL(x = y,z)
x = y - z
IF(x .LT. 0.0) x = 0.0
END
a = SQRT(x)

when one line using DIM solves the problem elegantly:


a = SQRT(DIM(y, z))

DIM is useful for representing cable spring stiffness. Negative extension cancels zero
force with a cable. You can't push on a piece of string!

4.33 DIMENSION
FORM: DIMENSION v1(a...), v2(a...), ..., vn(a...)

The variable names vi may have up to six integer constant subscripts separated by
commas; e.g., SPACE(5,5,5,5,5,5). The subscripts may be symbolic if the symbols are
declared INTEGER and defined in a PARAMETER statement. This operator allocates
space for up to six dimensions to be associated with a variable name. The statement
can appear anywhere in the program, but it must appear before any invocation of a
macro that uses dimension information.
Type declaration Arrays can also be dimensioned using the REAL, DOUBLEPRECISION, or
INTEGER statements. DIMENSION is preferred for floating point variables unless
the type of precision needs to be forced. Using DIMENSION allows the type to adjust
depending on the global option (single or double precision) selected.
Warning – Names of certain ACSL macros should not be used as arrays. ACSL cannot check that
conflict with the name defined as an array is also a macro because the TABLE statement defines an
system macro array to hold data and a macro of the same name for table lookup. The names of the
names following ACSL operators should not be used for arrays (as scalars is not a problem):
BCKLSH CMPXPL DBLINT DELAY DELAYP DERIVT DELSC
DELVC EXPF GAUSI GAUSS HISTORY IMPL IMPLC
IMPVC INTEG INTVC LEDLAG LIMINT LIMIT LINEAR
LINES MODINT OU OUTPUT PREPAR PTR RADC
RADCI RDIG RDIGI REALPL RESET RSHM RSHM
RSHMI RTDEVICE RTP SCALE SMOOTH TERMT TRAN
TRANZ UNIF UNIFI WDAC WDACF WDIG WDZGI
WSHM WSHMI ZOH

Array order Elements of arrays are written and accessed by column, then row; i.e., (a(i,j) where i =
row, j = column). For example, the elements of b(2,5) can be shown:
11 12 13 14 15
21 22 23 24 25

Extracted as a single-demensioned vector, the order is:


11 121 12 22 13 23 14 24 15 25

Examples Examples of DIMENSION specifications include:


INTEGER n
PARAMETER(n=4)
DIMENSION rm(3), em(3,3), hold(2,n), x(3,4,2,4,3,5)

ACSL Reference Manual Page 4-29


4. ACSL Statements 4.34 DISCRETE

4.34 DISCRETE
FORM: DISCRETE [name]
...
END

The keyword DISCRETE introduces a section to be executed by either an INTERVAL


statement or the SCHEDULE operator. The section is concluded by a matching END
statement.
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. 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).
Sorting The translator does not automatically sort the code; if you want to have code within a
DISCRETE section sorted, use the SORT keyword. Code is never sorted across
sections, nor are the sections themselves sorted.
Explicit structure DISCRETE sections are at the same level as any DERIVATIVE sections. If a
level DYNAMIC section is used, DISCRETE sections are placed inside it. (See Chapter 3
for further information on explicit program structure.)
Synchronizing The DYNAMIC section acts like a DISCRETE section that does data logging every
with DYNAMIC communication interval (CINT). When a DISCRETE section is close to an integral
multiple of CINT, it can be difficult to tell whether the DYNAMIC event will occur
just before or just after the DISCRETE event. A call to LOGD(.TRUE.) at the end of
the DISCRETE section can help clarify the order.
Executed at DISCRETE sections are executed at a discrete event or time point. The time of the
discrete event execution is controlled by the keyword INTERVAL or by a SCHEDULE statement.
Like the DERIVATIVE section, each DISCRETE section has a time associated with it
that is entered into an event list. This time becomes a barrier for DERIVATIVE
sections, 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. If
execution is controlled by an INTERVAL statement, 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.
Example The Discrete Sampled Compensator example in Appendix A uses a DISCRETE block
to model a control computer; the program structure is outlined here:
PROGRAM discrete controller
...
DYNAMIC
DERIVATIVE contin
...(X depends on U)
END ! of derivative
DISCRETE sample
INTERVAL dtsamp = 0.100
...(U depends on X)
END ! of discrete
END ! of dynamic
END ! of program

In the continuous section, a plant is defined. The plant can be as complex as necessary
but structurally has an output X that depends on a control U. The control U should be
visualized as being generated via a digital-to-analog converter so that the value of the

Page 4-30 ACSL Reference Manual


4.34 DISCRETE 4. ACSL Statements

control remains constant between output intervals. The next section is a DISCRETE
section that is executed every DTSAMP seconds, defined by the INTERVAL
statement to be 0.1 seconds. This section uses the output value of the plant X, at the
sample time, to compute a control U which is used over the next sample interval. The
successful operation of this simulation requires the continuous section to be exactly at
the sample time when the plant value X is used to determine the next control U.
Effect on Jumps in the control U modify all the high order derivatives estimated for the
integration step continuous plant, so variable step algorithms (IALG = 1 or 2) may reduce the step size
size or even restart. Since the fixed step size algorithms and the Fehlberg algorithms retain
no memory of previous history, with these algorithms the new step starts out with a
new evaluation of the discontinuous derivatives. The key to the action is the fact that
the effective time of the continuous section is exactly at the sample time when the
DISCRETE section code is executed.
Initialization At time zero, the DERIVATIVE and DISCRETE blocks containing INTERVAL
statements are evaluated in the order of appearance. In general, in a closed loop
situation, some variables have to be initialized in the INITIAL section since they are
used before being calculated in a later block. For example, the control variable U in
the preceding code sequence is used in the continuous section before it is calculated in
the DISCRETE block. If used like this without initialization, the first value of U used
in the continuous section is the last value left behind by the previous run! A test of the
presence of these initialization problems is to make two identical runs (i.e., START ;
START) and check the values at time zero. If any answers are different, it usually
indicates an error in initialization.
Evaluation at The sequence of events for DISCRETE sections with INTERVAL statements at time
time zero zero differs somewhat from that of the DERIVATIVE section. For DERIVATIVE
sections, the initial conditions are moved to the state variable array and the derivative
code executed once. In integrating over the first step, the integration algorithm
re-evaluates the derivatives (the variable step algorithms IALG = 1 or 2 predict the
state variables first before the corrector iteration) so it appears that two derivative
evaluations are used at time zero. With the DISCRETE block, the first evaluation takes
place and then the block is placed back on the event list for execution at some time in
the future (depending on the INTERVAL statement). Now time advances for other
sections up to the DISCRETE section barrier time. If the DISCRETE section contains
any state variables, they are advanced to the current time by Euler integration. Then
the DISCRETE section code is re-evaluated.
Integration in Integration statements (INTEG or INTVC) are generally not used inside DISCRETE
DISCRETE sections since this facility is designed to represent sampling actions independent from
the continuous physical world. There is sometimes a need for a simplified integration
algorithm with a fixed step size and a single derivative evaluation per step. In this
case, the entire model can be placed in a DISCRETE block and no extra derivative
evaluations are inserted at the communication interval times. Since the states are
always advanced just before a re-evaluation of the derivative code, algebraic variables
are always synchronized to the state variables for data recording.
Access to state Before Version 11.5, values of state variables could not be changed in DISCRETE
values sections when IALG was 1 or 2 (the variable step, variable order algorithms). This was
the case when the DISCRETE section was activated in response to an INTERVAL
statement or a time event SCHEDULE statement. The only exception was when the
section was activated in response to a state event SCHEDULE statement. The reason
was that for IALG 1 and 2, the states were hidden. This restriction did not apply to the
other algorithms. At Version 11.5, the procedure has been changed so that all states
can be re-computed or reset in DISCRETE sections.

ACSL Reference Manual Page 4-31


4. ACSL Statements 4.35 DO

Arrays of system When a program contains more than one DERIVATIVE and/or DISCRETE section,
variables several system symbols (MAXTERVAL, MINTERVAL, ALGORITHM, NSTEPS,
and ZZNIST) expand into arrays of length ZZNBLK (number of blocks). The blocks
are associated with the elements of the arrays in the order they appear in the program.
You can see these arrays in the debug output. The mechanism by which ACSL
recognizes a DISCRETE section is to set an effective algorithm of zero in the
corresponding IALG (ALGORITHM) slot. The INTERVAL variable is equivalenced
into the MINT (MINTERVAL) array and preset to the appropriate numeric value (-1 if
no INTERVAL). Slots in the corresponding MAXT (MAXTERVAL) and NSTP
(NSTEPS) arrays are ignored.
Limit on number The total number of sections, including all INITIAL, DYNAMIC, DERIVATIVE,
of sections DISCRETE, TERMINAL, and PROCEDURAL, is limited. The limit depends on the
computer; it is 31 on 32-bit machines, and 63 on 64-bit machines. If the total is
exceeded, the following error message is produced:
...Too many deriv/discrete sections

This limit is seldom reached, but when it is, usually a large number of DISCRETE
sections has been defined. The number of sections can generally be reduced by
combining several DISCRETE sections into one, using the optional flag in the
SCHEDULE statement to activate the appropriate code.

4.35 DO
FORM: DO n i = m1, m2[, m3]
...
n..CONTINUE

where:
n = a label (numeric or symbolic) of the terminal statement of the loop.
i = a simple integer variable called the index variable. With each repetition,
its value is altered by the increment parameter m3. This variable may
not be changed within the loop.
m1 = initial parameter, the value of i during the first loop.
m2 = terminal parameter. When the value of i surpasses the value of m2, DO
execution is terminated and control goes to the statement immediately
following the terminal statement.
m3 = increment parameter, the amount i is increased with each repetition.
The default value of m3 is 1.
The m1, m2, and m3 may be integer constants, variables, or expressions of arbitrary
complexity; if variables, they must be declared explicitly to be INTEGER variables.
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. The initial value, final value, and rate of increase of this integer variable are
defined by the set of indexing parameters included in the DO statement. The range of
the repetition extends from the DO statement to the terminal statement, which must
follow the DO statement, and this whole sequence is called the DO loop.

Page 4-32 ACSL Reference Manual


4.37 DYNAMIC 4. ACSL Statements

PROCEDURAL This is the standard Fortran DO statement. Note that in DERIVATIVE sections and in
in sorted sections implicit programs the loop must be embedded in a PROCEDURAL block so the sort
routine does not rearrange the order of execution. Using a PROCEDURAL is not
necessary within INITIAL, DYNAMIC, DISCRETE, or TERMINAL sections.
No branch into The loop cannot extend from INITIAL to TERMINAL to execute a sequence of runs;
loop each loop must be closed within a single structural section because the runtime
CONTINUE statement branches directly into the DYNAMIC loop. Most Fortran
compilers reject a branch into a loop. If a loop around the DYNAMIC section is
established to make successive runs, then CONTINUE cannot have any meaning since
the initialization is not performed properly.
Error checking For more information on the structure of the DO statements, see your local Fortran
reference manual. The ACSL translator checks the syntax of the DO statement but
does not validate the correct nesting of loops or terminal statements. Errors of
structure are indicated by the Fortran compiler.

4.36 DOUBLE
PRECISION
See TYPE.

4.37 DYNAMIC
FORM: DYNAMIC
...
END

The DYNAMIC keyword identifies the beginning of a section of code that is


performed every CINTERVAL communication interval throughout the run. It must be
accompanied by a matching END statement.
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. Examples of calculations generally performed in this section are unit
conversions (such as radians to degrees), which do not affect DERIVATIVE
calculations. 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; the DYNAMIC section is not intended for computing variables to be
input to DERIVATIVE or DISCRETE sections.
The time to the next communication interval can be calculated in the model, based on
some simulation phase or configuration, thus obtaining variable data recording rates
(see CINTERVAL for an example).
Code in the DYNAMIC block is not sorted automatically; if you wish to have it
sorted, use the SORT keyword.

ACSL Reference Manual Page 4-33


4. ACSL Statements 4.38 END

4.38 END
FORM: END

An END statement denotes the end of a block (e.g., a PROCEDURAL block) or


section (DYNAMIC, DERIVATIVE, etc.). Chapter 3 shows the use of ENDs in
structuring an explicit program.
One of the most common errors in programming a model is not getting the right
number of ENDs to balance the program sections. The following error messages are
issued when the count is incorrect.
...Not enough ends
...Too many ends

The END statement acts like a right parenthesis in an arithmetic expression, except
that it terminates blocks of statements; an incorrect count corresponds to unbalanced
parentheses.

4.39 EQUIVALENCE
FORM: EQUIVALENCE(main variable, equivalenced variable(s))&
,(main variable, equivalenced variables(s)), ...

where main variable appears in the user's common block, and thereby reserves
storage, while the equivalenced variable(s) are assigned a position relative to the main
variable, but do not reserve space. All variables appear in the dictionary with their own
types and dimensionalities.
This operator is similar to the Fortran version in that it allows renaming of areas of
storage. Due to the nature of storage in ACSL, there are specific rules for the use of
EQUIVALENCE which do not occur in normal Fortran usage.
Rules for use in Rules which restrict the use of EQUIVALENCE are as follows:
ACSL

1) System variables (CINT, etc.), states, derivatives, and initial conditions may
appear only as main variables.
2) A main variable may never appear as an equivalenced variable.
3) An equivalenced variable must not appear more than once.
4) When being specified in an EQUIVALENCE statement, variables may have no
more than one subscript; if a subscript is specified, it must be an integer constant
(e.g., 18) or PARAMETER name. Multi-subscripted arrays must appear using
their equivalent single subscript. For example, given A(5,5), equivalencing the
(3,3) element to SAM would require a reference to A(5*2 + 3) or A(13); i.e.,
EQUIVALENCE(A(13), SAM).

Page 4-34 ACSL Reference Manual


4.40 ERRTAG 4. ACSL Statements

Multiply defined In using equivalenced variables, any reference to an equivalenced variable name is
symbol taken to be a reference to its associated main variable, even though the equivalenced
variable may be only one element of a large main variable array. Thus the sorter
produces the error message Multiply defined symbol if two equivalenced variables are
assigned values outside a PROCEDURAL block in sorted sections, as shown in the
following example.
DIMENSION rm(3)
EQUIVALENCE(rm(1), rm1), (rm(2), rm2), (rm(3), rm3)
...
rm1 = 0.0
rm2 = 10000.0
...Multiply defined symbol

Storage size Generally the main variable is equal to or larger than its equivalenced variable(s),
since the main variable reserves storage; i.e.,
DIMENSION a(10)
EQUIVALENCE(a, b)

Here A is the main variable and B is the equivalenced variable. Reference to B uses
the first element of A(i.e., A(1)). B(2) is not allowed unless B is a separately defined
array.
DIMENSION a(10)
EQUIVALENCE(b, a)

Now B is the main variable (which reserves one word of memory), and A is the
equivalenced variable. Because B occupies only one word, reference to A(2) accesses
the variable that follows B in the common block, a variable which is generally not
known and can change.

4.40 ERRTAG
FORM: ERRTAG name

where name is a simple unsubscripted variable. ERRTAG defines the system variable
name that is used to indicate an attempt to reduce the step size below the minimum,
MINT. This statement changes the name of the variable to a name of your choice. 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.
The type of name is automatically set to LOGICAL and the value is preset to FALSE.
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. If it is still TRUE on return, the termination flag for that
run is set. Control should then revert to the TERMINAL section (if any) and the
executive, and the next runtime command is read. If provision is made to handle this
case and reset the flag, then care must be taken that a very small step size does not
result in excessive computer time being used.

ACSL Reference Manual Page 4-35


4. ACSL Statements 4.41 EXP

4.41 EXP
FORM: y = EXP(x)

The output y is the exponential of the floating point argument x, where x is limited in
size such that the maximum machine word size should not be exceeded by the
exponential. The expression is represented mathematically:

y = ex

The function and output take on the type (REAL or DOUBLEPRECISION) of the
input, thus adjusting to the global type specified by the translator option. The EXP
operator could be used as follows:
b1 = EXP(-tsamp/tlag)

4.42 EXPF
FORM: y = EXPF(ic, ta, lexpr)
EXPF(y = ic, ta, lexpr)

where:

ic = y(0) ; 0.0 < y(0) < 1.0


ta = time constant (τ)
lexpr = a logical variable or expression denoting rise or decay
The exponential function can be switched on or off. The output is a function rising on
a time constant to 1.0 (lexpr = .TRUE.) or decaying to zero (lexpr = .FALSE.). The
output y is expressed as follows:

y = 1.0 − e(−(T − T0 ) ⁄ τ ) (lexpr = .TRUE.)


(−(T − T1 ) ⁄ τ )
y = e (lexpr = .FALSE.)

T0 and T1 are the times at which lexpr changes FALSE to TRUE and TRUE to FALSE
respectively.
An example using EXPF is:
f1 = EXPF(fic, ta1, T .GT. trise)

4.43 FCNSW
FORM: y = FCNSW(p, x1, x2, x3)

The output y of the function switch operator is determined by the input function p as
follows:

y = x1 p < 0.0
y = x2 p = 0.0
y = x3 p > 0.0

Note that zero almost never exists in the span of real numbers unless some other action
forces it there.

Page 4-36 ACSL Reference Manual


4.45 GAUSI, UNIFI 4. ACSL Statements

MACRO gauss(y,ave,sig)
MACRO REDEFINE grv
REAL grv
CALL zzgrv(grv=zzseed)
y = ave + grv*(sig)
MACROEND

MACRO gausi(seed)
PROCEDURAL(=seed)
zzseed=seed
END
MACROEND

Figure 4-7. GAUSS and GAUSI operator macros

An example using the function switch operator is:


v = FCNSW(ain, vneg, vzer, vpos)

4.44 FORMAT
FORM: label: FORMAT(string)

The Fortran FORMAT statement may be used and must have a label. In an explicit
program, the FORMAT statement and its corresponding I/O statement (READ,
WRITE, etc.) must both be in a DERIVATIVE or DISCRETE section or neither; i.e.,
if one of these statements appears in a particular DERIVATIVE or DISCRETE
section, its corresponding statement must appear in the same section.
The ACSL translator does not check the detailed syntax of the FORMAT statement.
For further specification, consult your local Fortran manual.

4.45 GAUSI, UNIFI


FORM: GAUSI(k)
UNIFI(k)

The output of these functions is the seed for the random number generator. Input k is
an integer constant or expression and should be a large, positive odd number for a
maximal length sequence. The macro for GAUSI is listed in Figure 4-7.*
Only one of the initialization routines should be used since they both set the same seed
variable; 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, so these
initialization routines are required only when you wish to override the default. The
default seed number is 55555555.

* For more information on how the random numbers are generated, see the article "Random Number Generators:
Good ones are hard to find" by Stephen K. Park and Keith W. Miller, Communications of the ACM, Volume 31
Number 10, October 1988.

ACSL Reference Manual Page 4-37


4. ACSL Statements 4.46 GAUSS

The GAUSI or UNIFI operator should be invoked only in the INITIAL section of an
explicit program, or provision must be made to skip over it except at the beginning of
each run in an implicit program. If the operator is executed repeatedly, the random
numbers do not change.
The seed need not be specified for each invocation of the random number generators
since subsets of random sequences are also uncorrelated random sequences.

4.46 GAUSS
FORM: y = GAUSS(m, s)
GAUSS(y = m, s)

where m is the mean and s is the standard deviation. The output y is a normally
distributed random variable. Figure 4-7 gives a listing of the operator macro.
Seed The seed for a random sequence can be reset by UNIFI or GAUSI. If not set, a
different random sequence is in effect for each run.
Warning – GAUSS is not intended for use in a DERIVATIVE section because the power density
do not use in (or, what is usually more important, the low frequency power) depends on the
DERIVATIVE integration step size. Instead, use the OU operator.

The GAUSS operator could be used as follows:


vmic = GAUSS(0.0, vmsg)

4.47 GO TO
FORM: GO TO label
GO TO (n1, n2, ..., nm), i

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.
GO TO statements transfer control to labeled statements whose references are fixed or
which are assigned during execution of the program.
Transfers The statement labels used in the GO TO statements must be associated with executable
between sections statements in the same program unit as the GO TO statement. In explicit programs, the
INITIAL, DYNAMIC, and TERMINAL sections exist in a single program unit.
However, control cannot be transferred into the DYNAMIC region. The reason for this
is that the integration routines must be initialized at the start of the run; 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.
DERIVATIVE The DERIVATIVE section is a separate program block and control cannot be
DISCRETE transferred into or out of it. Control also cannot be transferred between DISCRETE
and DYNAMIC, INITIAL, 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. Execution resumes at the
statement with the referenced label. We recommend using a CONTINUE as the
labeled statement to avoid possible problems with sorting.

Page 4-38 ACSL Reference Manual


4.49 HISTORY 4. ACSL Statements

Examples Examples of valid GO TO statements include:


GO TO loop
GO TO (100, 200, 300, 400, 500), ibin

A large number of GO TOs is considered harmful to the successful completion of any


simulation project.

4.48 HARM
FORM: y = HARM(tz, w, p)

The output y is a sinusoidal or harmonic drive function with the results:

y = 0.0 T < tz
y = sin (w ∗ (T − tz ) + p ) T ≥ tz

where:
tz = delay (sec)
w = frequency (rad/sec)
p = phase shift (rad)
Note that if p is nonzero, a discontinuity is involved.
An example using HARM is as follows:
drive = HARM(tdrive, w1, phased)

4.49 HISTORY
FORM: HISTORY(y, yic, n)

where:
y = a variable name that will be used to create an array.
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. Extracting past history is then just a reference to y(2)
for two time steps ago, y(3) for three time steps ago, etc.
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.
Since the output is a vector, this statement cannot be invoked as an assignment
statement; in general, only scalar values can be passed across the equal sign. The
macro of the HISTORY operator is listed in Figure 4-8.
Example As an example, the following statement records four samples of a sine wave into a
history array:
HISTORY(sinhist, sin(2*w*t + fi), 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)

ACSL Reference Manual Page 4-39


4. ACSL Statements 4.50 IF, IF-THEN-ELSE

macro history(x, xin, n)


macro redefine j, xn, xz
macro relabel loop
dimension x(n), xn(n), xz(n)
constant xz = n*0.0
procedural(xn = xin)
xn(1) = xin
do loop j = 2, n
xn(j) = x(j - 1)
loop:continue
end
x = delvc(xn, xz)
macro end

Figure 4-8 HISTORY macro

Placement HISTORY can appear only in DISCRETE sections since it makes use of the DELVC
operator to delay the history elements. In unsorted DISCRETE sections, HISTORY
should be placed after the calculation of all its input variables. The elements of the
array are initialized to zero the first time.

4.50 IF,
IF-THEN-ELSE
FORM: IF(lexpr) statement

IF(lexpr) THEN
block1
ELSE IF(lexpr1) THEN
block2
ELSE
block3
END IF

IF statements are used to transfer control or perform calculations conditionally. At the


time of execution, an expression in the IF statement is evaluated and the result
determines whether the rest of the statement is executed.
The logical expression lexpr is a logical or relational expression, one that produces a
single value (either TRUE or FALSE).
Logical IF In the logical IF form, statement is any executable Fortran statement except another IF
(either logical or block), a DO statement, or an END. Non-Fortran statements or those
particular to ACSL may expand to more than one actual Fortran statement, which is
not allowed. Only a single statement can be included in the logical IF statement.
Examples of logical IF statements include:
IF(a .LT. 5.0) a = a + 0.1
PROCEDURAL(x = )
IF(x .GT. xmax) GO TO finish
x = k*xprev
xprev = x
finish: CONTINUE
END

Page 4-40 ACSL Reference Manual


4.50 IF, IF-THEN-ELSE 4. ACSL Statements

Logical IF statements that transfer control in sections that are sorted by ACSL
(DERIVATIVE sections or implicit programs) must be enclosed in PROCEDURAL
blocks, as in the second example, in order to maintain statement order. This example
however would be better handled with a block IF construct.
Block IF Block IF statements conditionally execute blocks (groups) of statements, a sequence of
zero or more complete Fortran statements including other IF-THEN-ELSE blocks.
Such a sequence is called a statement block.
Examples of block IF constructs are:
IF(ABS(force) .GT. breakout) THEN
vdot = netforce/mass
ELSE
vdot = 0.0
END IF

IF(a .GT. b) THEN


d = b
f = a - b
ELSE IF(a .GT. b/2) THEN
d = b/2
f = a - b/2
END IF

Initializing Note that the same output variables should always be defined in all branches of the
variables logic. If they are not, the last value placed in the variable is left around and used in
subsequent integration steps. For example, in the following code, either VDOT or
YDOT is not initialized:
IF(a .GE. b) THEN
vdot = f(a)
ELSE
ydot = f(b)
END IF

Assuming A starts off less than B, then VDOT is not given a value but YDOT is.
When A becomes greater than or equal to B, then VDOT is given a value but YDOT
continues to hold its last value. This is not necessarily wrong, just an issue to consider
when coding logic.
Statements on The IF-THEN statement takes no additional statements on the same line unless the
same line separator (a semi-colon) is used, turning it into a separate statement; e.g.,
IF(lexpr) THEN ; I = 1 ; ENDIF

Memory Memory operators such as INTEG, REALPL, TRAN, etc. should not be used inside
operators statement blocks. It's possible to step over an integration statement with logic, but that
doesn't stop the integration from taking place; it just means that the derivative is not
being calculated. This results in the last calculated value being used. If you don't want
a state to be integrated, make the derivative zero.
PROCEDURAL PROCEDURAL blocks are used to hide logical code from the translation sorting
process, but IF blocks are moved as one and don't require the PROCEDURAL. 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. Thus the block is placed
after the calculation of all the input variables and before the use of any of the output
variables.

ACSL Reference Manual Page 4-41


4. ACSL Statements 4.51 IMPLC

4.51 IMPLC
FORM: z = IMPLC(r, zic)

where:
z = a simple algebraic variable (IMPVC handles vectors)
r = residual, an arithmetic expression of arbitrary conplexity (i.e., may
contain functions, macros, or other integration statements)
zic = a simple unsubscripted variable, a floating point constant, or a general
expression enclosed in parentheses. If it is a simple variable (preferred),
then this variable name must not be used as another initial condition,
state, derivative, or system variable name.
Implicit In implicit integration, algebraic constraints are defined by an expression that
integration evaluates to a residual; this residual is then kept at or close to zero.

One use of this feature is in solving for pressure or voltages at junctions, where the
junction has flows or currents that sum to zero (Kirchoff's Law). 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.
Examples The example Tank with Boiling Benzene in Appendix A illustrates a PI controller with
the implicit operators. The aircraft example ACRFTS also uses IMPLC.
Must be in The implicit operators must be in DERIVATIVE sections, and they cannot be skipped
DERIVATIVE over in logical structures such as PROCEDURAL or IF-THEN-ELSE blocks.
Residual The residual expression must be related to the algebraic variable by a path such that
the partial derivative of all the residuals, taken as a vector with respect to all the
algebraic variables again taken as a vector, is a non-singular matrix.
The state and algebraic variables can be seen more clearly in the following:
.
Y = F(Y, Z )
0 = G(Y, Z )

Here the Y's are the state variables and the Z's are the algebraic variables. This is now
expressed for scalars as:
y = INTEG(F(Y, Z), yic)
z = IMPLC(G(Y, Z), zic)

or, for vectors:


y = INTVC(f, yic)
z = IMPVC(g, zic)

where now F and G are vectors that have been filled with derivatives and residuals
respectively in a separate operation. Of course scalar and vector variables can be used
and mixed freely. The ACSL translator builds a complete vector of states and a
complete vector of residuals for all the component parts.
Since we must be able to solve the residual relationships for Z, this means that the
partial of G with respect to Z must be non-singular; i.e.,

 ∂G (Y, Z) 
  ≠ 0
 ∂Z 

Page 4-42 ACSL Reference Manual


4.51 IMPLC 4. ACSL Statements

states derivatives ICs

s1 d1 ic1
s2 d2 ic2
s3 d3 ic3
... ... ...
a1 r1 ig1
a2 r2 ig2
a3 r3 ig3

Figure 4-9. Layout of state vectors

Derivative It sometimes is not possible to extract the derivative explicitly from the left-hand side
of an equation, so that the model equations are expressed as:
.
F(Y, Y, T) = 0

To handle this, case we have overloaded the IMPLC and IMPVC syntax by defining a
second variable on the left. For scalars, the above equation would be written:
y, yd = IMPLC(F(y,yd,t), yic)

In actual implementation, this is transformed into an integration statement and an


algebraic constraint as follows:
y = INTEG(yd, yic)
yd = IMPLC(F(y,yd,t), 0.0)

DAE The ACSL translator builds up vectors for states, derivatives, and initial conditions
Implementation using the INTEG and INTVC operators. At this level, we have added to these vectors
the algebraic variables (to the state vector), residuals (to the derivative vector), and
initial guesses for the algebraic variables (to the initial condition vector). These now
look like Figure 4-9.
.
Y  F(Y, Z) 
  =  
R  G(Y, Z)
or, linearizing:
.
Y  FY FZ  Y
  = G G  Z
R  Y Z
Since R is nominally zero, the second line leads to:

GY Y = −GZ Z

and:
.
Y = ( FY − FZ G−1
Z GY ) Y

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.

ACSL Reference Manual Page 4-43


4. ACSL Statements 4.52 IMPVC

The nonlinear equation solver to find the Z variables is similar to the one used by the
runtime ANALYZE command. It essentially computes a Newton-Raphson step:

δNR = G−1
Z R

and a steepest descent step:

δSD = GTZ R

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, this iteration usually converges in one or two evaluations
using the Newton-Raphson step. The usual problem is finding the algebraic (Z)
variable at the very beginning when the initial guesses may be far from the true
solution.
Example An example using the implicit scalar operator is:
residtl = htotal - hl(t1) - hv(t1)
tl = IMPLC(residtl, tlic)

4.52 IMPVC
FORM: z = IMPVC(r, zic)

where Z, R, and ZIC are arrays of the same size and correspond to algebraic variable,
residual, and initial condition, respectively. The mechanization of this operator is
explained under IMPLC above.
Restrictions apply to the IMPVC operator that are similar to those for vector
integration, INTVC; i.e.:
1) IMPVC cannot be used in an expression.
2) The residual array cannot appear any where else as a state, algebraic variable, or
initial condition.
3) The initial condition must be a variable name, it cannot be a literal constant or an
expression.
4) The array size may be one, or, equivalently, a simple undimensioned variable can
be used instead. In this case, the residual name is equivalenced directly into the
array of residuals and no extra assignment statement is generated.
An example using the vector implicit operator is:
PROCEDURAL(rv = a,b)
rv(1) = a + b
rv(2) = c - b
END
x = IMPVC(rv, xz)

Page 4-44 ACSL Reference Manual


4.54 INITIAL 4. ACSL Statements

4.53 INCLUDE
FORM: INCLUDE 'filename'

where 'filename' is in single quotes and conforms to the local operating system syntax.
For example, on a Unix system, statement could be in the form:
INCLUDE '../mod1.inc'

and under VAX/VMS as follows:


INCLUDE '[-]mod1.inc'

Environment The syntax of the file name supports references to operating system environment
variables variables through the use of a prepended dollar sign ($). For example, if HOME is an
environment variable defined in the Unix or Windows operating system, then the
INCLUDE statement will find a file (xyz.inc) in the user's home directory:
INCLUDE '$HOME/syz.inc'

Paths The environment variable is explanded into the full path for the file, including
adjustment for differences in forward or backward slashes for the machine operation
system. If on a PC, forward slashes (/) are changed to back slashes (\), and if on a Unix
system, the opposite applies, so a common source file can be used for running on both
PC and Unix systems.
Procedure The INCLUDE statement directs the ACSL translator to suspend reading statements
from the current file and read the statements from the INCLUDE file.
The INCLUDE file must comprise complete ACSL statements and must result in a
valid program when combined with the surrounding code.
INITIAL, INCLUDE files can contain separate INITIAL, DYNAMIC, and/or TERMINAL
DYNAMIC, sections with their matching END statements. These blocks are added to the current
TERMINAL sections being built as the ACSL translator works its way through the model definition
file.
Example An example of using INCLUDE files is to break a simulation into modules which are
then brought into a skeleton; e.g.,
DERIVATIVE
INCLUDE 'seeker.inc'
INCLUDE 'autopilot.inc'
INCLUDE 'actuator.inc'
INCLUDE 'airframe.inc'
END ! of derivative

Nesting INCLUDE files can themselves contain other INCLUDE statements.

4.54 INITIAL
FORM: INITIAL
...
END

The INITIAL keyword identifies the beginning of a section of code that is performed
just once at the start of each run. The INITIAL statement must have a matching END
statement. Refer to Chapter 3 for rules of explicitly structured programs.

ACSL Reference Manual Page 4-45


4. ACSL Statements 4.55 INQUIRE

Sorting Code within the INITIAL section is not automatically sorted; if you wish to have an
INITIAL section sorted, use the SORT keyword.
Multiple INITIAL Any number of INITIAL sections may be used within a program, at any nesting level.
sections This feature is particularly useful in conjunction with INCLUDE files and/or ACSL
macros; i.e., modules can be developed in separate files with their own INITIAL
sections, then brought into a DERIVATIVE section in a larger model by means of
INCLUDE statements.
The translator collects all the INITIAL sections in the order encountered and adds
them to the end of the INITIAL section to be executed. If the sections of code to be
added need to be in a particular order (so that a variable is defined before being used,
for example), the SORT keyword can be used.
Warning – not in MACROs with INITIAL sections cannot be called from within PROCEDURAL
PROCEDURAL sections. This is because at the moment the INITIAL keyword must be at a
PROCEDURAL nesting level of zero.

4.55 INQUIRE
FORM: INQUIRE(UNIT = lu
, FILE = fin
, IOSTAT = ios
, ERR = s
, EXIST = ex
, OPENED = od
, NUMBER = num
, NAMED = nmd
, NAME = fn
, ACCESS = acc
, SEQUENTIAL = seq
, DIRECT = dir
, FORM = fm
, FORMATTED = fmt
, UNFORMATTED = unf
, RECL = rcl
, NEXTREC = nr
, BLANK = blnk)

where the arguments follow the Fortran 77 standard. See your local Fortran manual.
The only argument required is either (not both) the UNIT or FILE definition.

4.56 INT
FORM: n = INT(x)

The output n is the integerization of the argument x. The argument x can be either
single or double precision. The implementation is that n is the sign of x times the
largest integer ≤ | x |. INT could be used as in the following example:
INTEGER ibin, ibin1
ibin = ibin1 + INT(xz + x*y)

INT or AINT can be used on the right side of an equal sign; for example,
y = INT(x)

Page 4-46 ACSL Reference Manual


4.57 INTEG 4. ACSL Statements

In this case, the value of X is integerized, but then the result is floated according to
normal conversion rules. The type of the arguments to subroutines however cannot be
inferred, so INT or AINT must be chosen to match the argument type. In the
following, for example, the first argument is forced to be INTEGER and the second,
REAL.
CALL mysubr(INT(x1), AINT(x2), ...)

Since the type of AINT follows the argument (i.e., becomes either single or double
precision depending on the type of the argument), it is probably better to force the type
using DBLE or REAL.
CALL mysubr2(DBLE(AINT(x3)), REAL(AINT(x4)), ...)

Now the arguments won't change type with a change in the ACSL translator mode.

4.57 INTEG
FORM: state = INTEG(deriv, ic)

where:
state = a simple variable. (INTVC handles integration of vectors.)
deriv = an arithmetic expression of arbitrary complexity; i.e., may contain
further INTEG statements, functions, or macros.
ic = a simple non-subscripted variable, a real constant, or a general
expression enclosed in parentheses. If it is a simple variable (preferred),
then this variable name must not be used as another initial condition,
state, derivative, or system variable name. If an expression is used, both
the initial condition and the state are given dummy variable names; a
consequence of this is that XERROR and MERROR do not recognize
the state name.
INTEG may also be embedded in any legal expression as a function that has a single
output, the value of the state. When the integration statement is alone, then the state
name can be identified; embedding it in an expression means that an ACSL-generated
variable (i.e., in the form Znnnnn) must be used for the state name.
Initial conditions If an expression is specified for an initial condition, the expression is sorted in such a
as expressions way that all components in the expression are evaluated before the state value is
assigned in the first (initialization) evaluation of the derivatives. Equations using the
state then follow. Problems may occur when using this form with the REINIT
command at runtime. The expression is always evaluated and substituted for an initial
condition established by the reinitialization operation.
Implementation All integration in an ACSL program is handled by a centralized integration routine. In
performing integrations, the integration algorithms utilize two intervals: (1) the
integration step size and (2) the communication interval. Since digital integration is
basically a discrete process, the integration step is the fundamental interval over which
the state variables are updated. No finer detail is accessible except by some
interpolation method. All integration schemes for the set of first order differential
equations in the form:
.
x = f(x)

are transformed into:

ACSL Reference Manual Page 4-47


4. ACSL Statements 4.57 INTEG

xn+1 = xn + h∗f(xn+α )

where (0.0 ≤ α ≤ 1.0) and h is the integration step size. The problem is to find the
effective derivative to use in updating the state vector. Note that with suitable
conditions on continuity and differentiability, the mean value theorem guarantees that
an α exists that produces an exact answer for the state trajectory; finding it is another
matter, however. Different integration schemes approximate the derivative in different
ways, usually by expanding the derivative function in a Taylor series about the current
state. For an example of how this is implemented, see the explanation of the
Runge-Kutta fixed-step fourth order algorithm in the section on ALGORITHM.
Examples Examples of use of the INTEG statement include:
y = INTEG(5.0*x(1) + c, yic)
z = p*INTEG(zdot, 0.0) + bt
w = INTEG(wdot, (2.0*al*SIN(th)))

Z in the above is not a state since the INTEG function appears embedded in an
expression.
Integrating The INTVC operator should be used for integrating vectors or multidimensional arrays.
vectors

Initial condition Names of initial conditions can be only names not used as states, other initial
names conditions, or system variables. The following statements are all illegal when used
with above example statements, 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, yic) ! yic is IC for y defined above
zz = INTEG(z*4.0, w) ! w is a state defined above
zk = INTEG(kk, CINT) ! CINT is a system variable

Translation The reason for the rules may be better understood if the actual translation operation is
process explained. The translator is building up three lists of names that are placed in sequence
in three Fortran common blocks. The state list contains all the state variables and
arrays, the derivative list contains the corresponding derivatives, and the initial
condition list contains the corresponding initial conditions. Each name in these lists
must be unique.
The initial condition name for each state must be unique. If the initial condition is a
literal constant or an expression, a generated name (in the form Znnnnn) is used. If the
initial condition name is a simple variable, the translator uses that name directly. The
expression form is changed into a test (IF statement) on the first evaluation of a run, in
which case the expression is evaluated and the result stored into the state.
The derivative names are all generated variables to avoid possible conflict. The
statements
yd = INTEG(5.0*x, 1.0)
y = INTEG(yd, yic)

generate the following assignment statements:


Z99999 = 5.0*X
Z99998 = YD

and a DATA statement for the generated initial condition:


DATA Z99997/1.0/

Page 4-48 ACSL Reference Manual


4.59 INTERVAL 4. ACSL Statements

Now the state list is YD and Y; the derivative list is Z99999 and Z99998; and the initial
condition list is Z99997 and YIC. Each name on the list is unique.
Use in sorted The INTEG operator should be used only in sorted sections or implicit programs and
sections only should not be used in a PROCEDURAL.

4.58 INTEGER
See TYPE.

4.59 INTERVAL
FORM: INTERVAL name = floating point number

where name is a simple unsubscripted variable name. The INTERVAL statement


schedules repeated execution of a DISCRETE section and can be used only in a
DISCRETE section. It is used to define both the name of the variable controlling the
repetition period and its initial value.
No defaults There is no default for the INTERVAL name or value. A DISCRETE section without
an INTERVAL statement is not executed automatically. An alternative means of
activating a DISCRETE section is with a SCHEDULE statement.
An example of an INTERVAL statement could be:
DISCRETE dac
INTERVAL dt = 0.1
...
END

In MINT array The mechanization of the INTERVAL feature is to use the slot in the global
MINTERVAL array corresponding to the DISCRETE section. The INTERVAL
variable is equivalenced into this array. If no INTERVAL statement is placed within
the DISCRETE block, a value of -1.0 is used as the default. This flags the DISCRETE
section as not to be executed during the initialization phase.
Changing value The INTERVAL value may be changed (anywhere in the program, or at runtime). It is
the value which is current when the DISCRETE section has completed execution
which determines the next execution time. Once the DISCRETE section is on the
event list, changes in the INTERVAL value do not affect the next execution time.
Strobe effect When the INTERVAL for activating a DISCRETE section is a decimal fraction, it is
possible for small errors in timing to resulting in a beating or strobe effect. The
problem is that decimal fractions (0.1, for example) are never exact on a binary
machine. In order to maintain accuracy, ACSL finds an integer multiplier of
CINTERVAL such that the result is an integer (to machine accuracy). If CINT is 0.1,
for example, the multiplier is 10. The communication interval times are obtained by
accumulating integer ones and finding the end point by dividing by ten. A thousand
0.1s by this method is 100 exactly, while a thousand additions of 0.1 (not a power of
two and so a rounded number) has significant error. Since CINT is adjusted and
INTERVAL statements are not, a difference can develop. If this is an important
consideration, double precision can help, or else the INTERVAL value can be biassed
by setting it to, for example, 0.1000001 or 0.099999999 instead of 0.01.

ACSL Reference Manual Page 4-49


4. ACSL Statements 4.60 INTVC

4.60 INTVC
FORM: x = INTVC(xd, xic)

where x, xd, and xic are arrays of the same size and correspond to state, derivative, and
initial condition, respectively. The missile example in Appendix A uses INTVC.
Restrictions The restrictions on the INTEG operator with regard to arrays can be avoided by using
this vector integrator operator. The restrictions on the INTVC operator are as follows:
1) INTVC cannot be used in an expression.
2) The derivative array must not appear anywhere else as a state. If a state must be
used as a derivative (velocity, for instance, which has been integrated from
acceleration and is then the derivative of range), use the block transfer
(XFERBR) subroutine to move it into another array before using INTVC.
3) The initial condition must be a variable name; it cannot be either a constant or an
expression.
4) The array size may be one; or, equivalently, a single undimensioned variable can
be used instead. In this case, the derivative name is used explicitly and no extra
assignment statement is generated. INTVC is the preferred method for
integrating scalars as long as the derivative is a scalar as well.
5) 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.
Examples Following are examples using INTVC:
DIMENSION x(10),xd(10),xic(10),m(5, 5),md(5, 5),mic(5, 5)
y = INTVC(yd, yic) ! scalar integration
x = INTVC(xd, xic) ! vector integration
m = INTVC(md, mic) ! matrix integration

Warning – can't A variable cannot be both a derivative in one INTVC statement and a state in another.
be both state and For example, if R, V, and A are range, velocity, and acceleration vectors:
derivative

DIMENSION r(3), ric(3), v(3), vic(3), a(3)

the following is illegal:


v = INTVC(a, vic)
r = INTVC(v, ric)

since these statements ask for V to be considered as both a state and a derivative at the
same time. Using the XFERBR (transfer block) subroutine and defining an RD (R dot)
array, the sequence becomes:
DIMENSION r(3), rd(3), ric(3), v(3), vic(3), a(3)
v = INTVC(a, vic)
CALL XFERBR(rd = v, 3)
r = INTVC(rd, ric)

Use in sorted INTVC should be used only in sorted sections or implicit programs, and it should not
sections only be used in a PROCEDURAL.

Page 4-50 ACSL Reference Manual


4.62 LEDLAG 4. ACSL Statements

4.61 I/O
FORM: READ(clist) ilist
WRITE(clist) olist
READ f, ilist
PRINT f, olist

These statements transfer data between external files and internal variables following
the Fortran 77 conventions. The elements in the control list clist are taken from the
following:

[UNIT = ] ln integer logical unit


[FMT = ] f format statement
REC = rn record number
IOSTAT = ios I/O status
ERR = s statement label on error
END = s statement label on end-of-file

The input list ilist comprises variable names or arrays or implied DO loops of the form:
(a(j), j=jmn, jmx)

The output list olist can have constants such as character strings and arbitrary
expressions as well as the same type of variable names as implied DO loops as the
input list; for example,
WRITE(97, *) 'Value of V is ', D

The asterisk (*) specifies free format. This is the simplest format for transferring data
items if just visibility is required.
ACSL accepts the ANSI Fortran 77 standard format. For complete details of the
input/output forms, see your local Fortran reference manual.
I/O statements are not usually placed in DERIVATIVE sections except for debugging.
This is because of the frequency and unpredictability of execution of the
DERIVATIVE section.
There should be little need to program complicated input/output statements in ACSL
since most of the numeric output and plots are generated automatically. Typical
requirements for data transfer between external files is for reading experimental data
or writing values for a specialized plot program.

4.62 LEDLAG
FORM: y = LEDLAG(p, q, x[, ic])
LEDLAG(y = p, q, x[, ic])

The lead-lag compensator output y is related to input x through the transfer function:

y ps + 1
=
x qs + 1

such that:
p
y(0) = x(0) + ic
q
Figure 4-10 shows the mechanization of this operator as a system macro.

ACSL Reference Manual Page 4-51


4. ACSL Statements 4.63 LIMINT

MACRO ledlag(out,p,q,in,ic)
MACRO STANDVAL ic=0.0
MACRO REDEFINE x,y
x = in
out = y+(p)*x/(q)
y = INTEG((x-out)/(q),ic)
MACROEND

Figure 4-10. LEDLAG operator macro

Restriction on The initial condition, ic, has the same restrictions as the initial condition of the INTEG
initial condition operator; i.e., if it is a variable name, the name must not be used as another initial
condition, state, derivative, or system variable name. If the initial condition ic is not
specified, it is given a default of zero.
Time constants The time constants p and q may be expressions of arbitrary complexity. The lag value
q may not be zero or else a division by zero results.
Setting p to zero makes LEDLAG behave like a pure lag (see REALPL). Setting p
equal to q makes LEDLAG behave like an assignment statement:

y = x
Use in sorted This operator (as all memory operators) should be used only in sorted sections or
sections only implicit programs. It should not be used in a PROCEDURAL.

An example using LEDLAG is:


xp = k1*LEDLAG(ta1, ta2, e)

4.63 LIMINT
FORM: y = LIMINT(yd, ic, bb, tb)
LIMINT(y = yd, ic, bb, tb)

where:
yd = derivative (variable name or expression)
ic = initial condition of y, with the same restriction as on the INTEG initial
condition (i.e., if it is a variable name, the name must not be used as
another initial condition, state, derivative, or system variable name);
may be omitted if zero (but comma must be included)
bb = bottom bound on y
tb = top bound on y
Figure 4-11 shows the effect of the LIMINT operator. The LIMINT operator could be
used as follows:
dl = LIMINT(dld, dlic, -dlmx, dlmx)

Page 4-52 ACSL Reference Manual


4.63 LIMINT 4. ACSL Statements

Figure 4-11. Effect of LIMINT Operator

Use with BOUND Integrators should not be limited using the BOUND function since the integrator
continues to integrate and then must integrate out of the limit when the derivative
changes sign. The LIMINT operator holds the integrator at the limit as long as the
derivative is of such a sign to drive it further into limit. When the derivative reverses
sign, the integrator immediately comes off the limit. However, LIMINT and BOUND
can be used together to force a hard limit:
y = BOUND(0.0, 1.0, LIMINT(2.0*t, 0.0, 0.0, 1.0))

SCHEDULE The LIMINT operator can penetrate the limit, especially if the approach is at high
alternative velocity (i.e., large values for the derivative and step size). If it is necessary to find the
limit points with more precision, use the SCHEDULE operator to force iteration until
the limit penetration point is found, then execute a DISCRETE section to set the
derivative to zero. 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.
SCHEDULE with The integration routine can be forced to step up to the limit by using SCHEDULE. In
LIMINT this case, the LIMINT operator is used and no DISCRETE section is executed. In the
following example, SCHEDULE forces an iteration to the point when X just crosses
the symmetric boundary ±XMX.
x = LIMINT(xd, xic, -xmx, xmx)
SCHEDULE .XP. ABS(x)-xmx

Varying the limits The limits should not vary in time while the system is in the limit.
Use in sorted This operator (as all memory operators) should be used only in sorted sections or
sections implicit programs, and it should not be used in a PROCEDURAL.

ACSL Reference Manual Page 4-53


4. ACSL Statements 4.64 LINEAR

4.64 LINEAR
FORM: linear(y = 'datablock:argument')
y = linear('datablock:argument')

The argument inside the single quotes identifies the data block by name (in front of the
colon) and identifies which column of the data block to interpolate. This data block is
defined in a DATA statement at runtime, generally in a command file (see DATA in
Chapter 5). For this discussion, assume that there is defined a DATA block in the
command file as follows:
data foo(t, x, y)
0.0 2.0 2.0
1.0 3.0 2.0
2.0 1.0 2.5
3.0 3.0 3.5
4.0 9.0 1.5
5.0 8.0 4.5
6.0 2.0 5.0
7.0 2.0 5.0
8.0 2.0 6.3
9.0 2.0 8.1
end

The time column must be present and be of strictly monotonic increasing order for the
interpolation to work; i.e., each time point must be greater than (not equal to) the
preceding time point.
This operator linearly interpolates between data points down a column of the given
argument. As an example, extract X as follows:
LINEAR(x = 'foo:x')

or
x = LINEAR('foo:x')

This looks up the value of the independent variable (in this case it has to be T, since
this is a column of the data block FOO), finds the data points that bracket this time,
and then linearly interpolates to find the function value that is placed in the output
variable X.
Default data In all these cases, the name of the data block can be omitted from the quoted string
block name (part in front of the colon). In this case, the default data block is the one identified on
the start command; for example:
START/DATA=foo

If no default data block is specified, then the simulation run aborts since the operator
does not know where to get the data.

4.65 LINES
FORM: CALL LINES(n, "TOF")

where n is the number of lines about to be printed. If n lines are not available on the
current page, the page is ejected.

Page 4-54 ACSL Reference Manual


4.68 LOGD 4. ACSL Statements

The LINES command tells the executive processor how many lines are to be written
with PRINT or WRITE statements. At runtime, the executive processor keeps track of
the number of lines written on the output file and every 55 lines issues a top-of-form
and prints out the header and TITLE. If Fortran WRITE statements are included in the
model definition, they are expected to inform the processor how many lines they are
going to write so that the pagination is performed correctly.
CALL LINES(2, "TOF")
PRINT 99, a, b, c
99: FORMAT(1X, 2E12.5/1X, F12.2)

In order to force a top-of-form prior to the write command, call subroutine PAGE
before calling LINES. Placing a digit 1 in column one for top-of-form should not be
used in ACSL.

4.66 LOG
FORM: y = LOG(x)

The output y is the natural logarithm of x where x is a floating point variable or


expression. The function and output take the type (REAL or DOUBLEPRECISION)
of the input. This generic function is recommended over ALOG (REAL) or DLOG
(DOUBLEPRECISION) since it adjusts to the type of the translator option. An
example using LOG is:
y = a - LOG(ABS(SIN(w*t)))

4.67 LOG10
FORM: y = LOG10(x)

The output y is the common logarithm (i.e., to the base 10) of x where x is a floating
point variable or expression. The function and output take the type (REAL or
DOUBLEPRECISION) of the input. This generic function is recommended over
ALOG10 (REAL) or DLOG10 (DOUBLEPRECISION) since it adjusts to the type of
the translator option. An example using LOG10 is:
gdbn = 10.0*LOG10((dlp**2 + dlq**2)*(w/pi*xmag))**2)

4.68 LOGD
FORM: CALL LOGD(lexpr)

where lexpr is a logical variable or expression. Write the PREPARE and OUTPUT
lists. Output is written for each call to LOGD when lexpr is TRUE. Output is written
at every NCIOUT call to LOGD when lexpr is FALSE. LOGD can be called in any
section of an ACSL program, and in FORTRAN subroutines called from ACSL.
The data logging operation for the OUTPUT and PREPARE lists is forced by a call to
this subroutine. Data logging takes place automatically only at the end of the
DYNAMIC section and on exit from the TERMINAL section. LOGD can be used to
obtain finer detail where required. An example of its use is to force a data logging
action whenever a logical variable is TRUE as follows:

ACSL Reference Manual Page 4-55


4. ACSL Statements 4.69 LOGICAL

LOGICAL hirate
IF(hirate) CALL LOGD(.TRUE.)

Square corners Each time LOGD is called, a time point is saved for the values of the variables on the
for DISCRETE PREPAR list. This can be useful for squaring off plots of sampled data values. Force a
plots data logging before and after a sampling action (i.e., at the beginning and end of a
DISCRETE section). Variables are then logged precisely as they change and plots
accurately reflect the changes.
Help in On computers without a good system debugger, or in situations where the computer
debugging hangs, LOGD can help in debugging. Insert calls to LOGD throughout the program (at
the beginning and end of various sections, for example), or at least in areas of
suspected problems, along with a variable set to some number. If the call is in a sorted
section or implicit program, put it in a PROCEDURAL as follows:
PROCEDURAL
aaaaaa = < some number >
CALL LOGD(.TRUE.)
END

Use a different number at each call in order to identify which LOGD produced which
OUTPUT line. At runtime, add AAAAAA to the OUTPUT list. START the model
and note which call to LOGD (as indicated by AAAAAA) appears last before the run
crashes.
OUTPUT T,aaaaaa, ...
START

Check the model source file and/or the translated FORTRAN compile file for clues as
to which statement after this last call to LOGD and before the next one not executed
caused the problem.
Logical argument The logical argument of LOGD affects only the action of printing the OUTPUT list. If
the logical is TRUE, the values of variables on the OUTPUT list are printed regardless
of the count relative to NCIOUT (number of communication intervals per OUTPUT);
if FALSE, the call to LOGD is treated as another communication time and included in
the NCIOUT count. NCIOUT controls the OUTPUT rate.

4.69 LOGICAL
See TYPE.

Page 4-56 ACSL Reference Manual


4.72 MAX 4. ACSL Statements

4.70 LSW, RSW


FORM: i = LSW(p, j1, j2)
y = RSW(p, x1, x2)

where LSW is the integer switch, and RSW is the real (floating point) switch. The
outputs i or y take on the value of the second argument, j1 or x1, when the logical
expression p has the value TRUE; otherwise they have the value of the third argument,
j2 or x2. The j1 and j2 are any integer expressions; x1 and x2 are floating point
expressions. The LSW function is typed INTEGER intrinsically; RSW is floating
point. Examples of LSW and RSW statements are as follows:
INTEGER ncount
LOGICAL count
ncount = LSW(count, ncount+1, ncount-1)
cmal = cmalf(mach)*RSW(mach.GT.machmx, (xcg - xcp)/d, 1.0)

Alternative for For logical switches, assignment statements are simpler and clearer. In the following
logicals example, SWITCH is TRUE when X is greater than XMIN and FALSE otherwise:
switch = x .GT. xmin

Warning – Note that all of the arguments in the statement are evaluated, whether or not they are
all arguments used. The following statement, therefore, results in an error if P becomes zero:
evaluated

y = RSW(p .EQ. 0.0, x, x/p)

Writing the statement as follows avoids the problem of division by zero:


y = x/RSW(p .EQ. 0.0, 1.0, p)

However, the following solution is preferable because it eliminates an IF statement:


y = x/(p + 1.0E-33)

The probably of P being -1.0E-33 is effectively zero!

4.71 MACRO
FORM: MACRO name(x1, x2, ..., xn)

The keyname MACRO denotes the beginning of a MACRO definition (if not already
within a MACRO definition). Within a definition, it denotes special subcommands to
be interpreted by the macro processor. For a full description of the macro capability,
see Chapter 6.

4.72 MAX
FORM: y = MAX(x1, x2, ..., xn)

The output n is the value of the maximum argument, where the arguments xi are
variables or expressions; any number of arguments may be included. Negative values
are considered less than positive values. The type (INTEGER, REAL, or
DOUBLEPRECISION) of the output is implied from the arguments.
nmax = MAX(num1, num2, 2*jj)
w = MAX(wmn, kw*w)

ACSL Reference Manual Page 4-57


4. ACSL Statements 4.73 MAXTERVAL, MINTERVAL

4.73 MAXTERVAL,
MINTERVAL
FORM: MAXTERVAL name = real constant

DEFAULT: name: MAXT


real constant: 1.0E+10

FORM: MINTERVAL name = real constant

DEFAULT: name = MINT


real constant = 1.0E-10

where name is a simple, unsubscripted variable. The maximum and minimum value of
the integration step size can be controlled and renamed with these statements.
MAXTERVAL MAXTERVAL is the upper bound on the integration step size for both variable step
and fixed step algorithms.
MINTERVAL If a variable step size integration algorithm attempts to take a step smaller than the
value of the applicable MINTERVAL, the error tag variable (see ERRTAG), if any, is
set. If the error tag has already been set, then the termination flag is set. Fixed step
algorithms ignore MINTERVAL.
Arrays with If a program contains only one DERIVATIVE section and no DISCRETE sections,
multiple sections MAXTERVAL name (referred to by its default name MAXT hereafter) is a scalar;
however, more than one DERIVATIVE and/or DISCRETE section results in MAXT
becoming an array. The elements in MAXT then correspond to the sections in the
order they are encountered in the source code. If MAXTERVAL is defined outside a
DERIVATIVE section, then it is the global default for all DERIVATIVE sections; the
elements for DISCRETE sections are ignored. To change MAXT for a specific
DERIVATIVE section, put a MAXTERVAL statement with a unique name in the
section; for example,
DERIVATIVE
MAXTERVAL maxtsm = 0.0001

The scalar name given is equivalenced to the array element; if the DERIVATIVE
section is first in the program, for example, MAXTSM is equivalenced to MAXT(1). At
runtime, either the array element or the local name can be referenced.
SET MAXT(1)=0.001
SET maxtsm=8.05

MINTERVAL is similar, except that for DISCRETE sections the MINTERVAL


elements contain the value of the INTERVAL statement; a -1 indicates that there is no
INTERVAL statement for the corresponding section.
Integration step The integration step size H for fixed step algorithms is calculated from CINT/NSTP
size (see CINTERVAL and NSTEPS statements) and then bound by MAXT; i.e.,

H = MIN(MAXT, CINT/NSTP)
For variable step algorithms, a lower bound of MINT is added:
H = MAX(MINT, MIN(MAXT, CINT/NSTP))
Control of fixed For fixed step algorithms, we recommend setting NSTP to 1 and MAXT to the desired
step integration step size. This approach decouples control of the step size from the communication
interval CINT. CINT then is the data logging rate, MAXT is the integration step size,
and each can be set separately without affecting the other.

Page 4-58 ACSL Reference Manual


4.74 MERROR, XERROR 4. ACSL Statements

Runtime The values of these variables can be set by assignment statements in the program or by
SET commands at runtime. For example, if the following statement is in a program,
MAXTERVAL MAXT1 = 1.0E-6

then at runtime its value can be changed:


SET MAXT1 = 2.0E-6

Even if the MAXTERVAL and MINTERVAL statements are not included in the
program, they can be accessed at runtime using the default names of MAXT and
MINT. It is seldom necessary to change MINTERVAL.

4.74 MERROR,
XERROR
FORM: MERROR v1=real constant, v2=real constant, ..., vn
XERROR v1=real constant, v2=real constant, ..., vn

where MERROR is the relative error bound, XERROR is the absolute error bound,
and vi are nonsubscripted variable names that are state variables (i.e., appear on the left
side of an INTVC or INTEG statement that is not embedded in an expression). The
state itself can be an array, but then the errors specified apply to all elements in the
array. Individual elements cannot be given separate error tolerances.
If any relative or absolute errors are specified, the first specification encountered is
applied to all integrators that are unspecified. For example:
MERROR x=1.0E-4, y=1.0E-6

where:
x = INTEG(xd, xic)
y = INTEG(yd, yic)
z = 5.0*INTEG(zzz, 0.0) + COS(x)

Note that Z in the above example cannot have any error bounds specified since it is not
a state. 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.
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. 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), the
allowable error bound is defined to be:

Ei = MAX (Xi, Mi | vi | max )

If any of the predicted errors in an integration step is greater than the corresponding
allowable error Ei, the step size is reduced appropriately. If the error is still too large
after the step size has been reduced to the minimum (MINTERVAL), the ERRTAG
variable, if any, is set TRUE and the run aborted.
For states that are always less than 1.0, the absolute error dominates, which can
potentially be a problem. Absolute error is used to cover cases when the variable is
near zero. Usually relative error is the important consideration.

ACSL Reference Manual Page 4-59


4. ACSL Statements 4.75 MIN

4.75 MIN
FORM: y = MIN(x1, x2, ... xn)

The output y is the value of the minimum argument, where arguments xi are variables
or expressions. Any number of arguments may be included. Negative values are
considered less than positive values. The type (INTEGER, REAL, or
DOUBLEPRECISION) of the output is inferred from the arguments.
ilo = MIN(imn+1, j, k5)
maxtc = MIN(period/nstmn, maxtxz)

4.76 MINTERVAL
See MAXTERVAL.

4.77 MOD
FORM: y = MOD(x1, x2)

The output y is the remainder of x1 divided by x2, where x1 and x2 are constants,
variables, or expressions. The type (INTEGER, REAL, or DOUBLEPRECISION) of
the function and the output is inferred from the arguments. The generic MOD function
is preferred over the more specific AMOD1, MOD0, etc.
The actual implementation can be written as:

x1 − [x1 ⁄ x2 ] x2

where [ ] is an integer with magnitude of not more than the argument and with the
same sign. Examples of MOD are:
INTEGER j, k, idiv, icount
icount = 100 + MOD(j*k+100, idiv)
fis = MOD(INTEG(fisd, fisic), twopi)

4.78 NINT
FORM: n = NINT(x)

The output y is the nearest integer of x where x is a floating point variable or


expression. The output type is always INTEGER. This function differs from INT or
AINT, which truncate the input, and from ANINT, which is the nearest whole number
with output of type REAL or DOUBLEPRECISION. NINT could be used in a
subroutine argument list as follows:
CALL mysub(NINT(v1), ...)

Page 4-60 ACSL Reference Manual


4.79 NSTEPS 4. ACSL Statements

4.79 NSTEPS
FORM: NSTEPS name = integer constant

DEFAULT: name: NSTP


integer constant: 10

where name is a simple, nonsubscripted variable. The NSTEPS statement defines the
integration step size in terms of the communication interval; i.e., NSTEPS is the
number of integration steps in a communication interval.
The NSTEPS statement can also be used to rename the variable something different
from the default of NSTP.
Type The variable named in the NSTEPS statement is automatically typed INTEGER.
Variable step The effect of NSTEPS with variable step algorithms differs from that with fixed step
algorithms algorithms. Setting NSTP to a relatively large number is a means of helping a variable
step algorithm start at an appropriate size. For variable step algorithms, the step size H
is determined by:
H = MAX(MINT, MIN(MAXT, CINT/NSTP))
In other words, the communication interval is divided by NSTP and then the results is
bounded by MINT and MAXT. If the first try 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 a 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.
Fixed step For fixed step algorithms (IALG = 3, 4, or 5), MINT is ignored so the step size is
algorithms 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, specified based on knowledge of the plant dynamics; for
example:
NSTEPS nstp1 = 1
MAXTERVAL maxt1 = 0.001
CINTERVAL cint = 0.1

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.
Array of NSTP When a program contains more than one DERIVATIVE and/or DISCRETE section,
NSTEPS becomes an array of length ZZNBLK (the number of sections in the
program). The elements of the array correspond to the sections in same order as they
appear in the program. For DERIVATIVE sections, each slot contains the appropriate
value of NSTEPS, which can be set either globally or else individually for each
section. For DISCRETE sections, the slot in NSTEPS is ignored and INTERVAL is
used for the step size of any integrations.

ACSL Reference Manual Page 4-61


4. ACSL Statements 4.80 OPEN

4.80 OPEN
FORM: OPEN([UNIT =] lu
[, IOSTAT = ios
, ERR = s
, FILE = fin
, STATUS = sta
, ACCESS = acc
, FORM = fm
, RECL = rl
, BLANK = blnk])

where the arguments follow the Fortran 77 standard. See your local Fortran reference
manual. The only argument required is the logical unit number.

4.81 OU
FORM: y = OU(τ, m, s)
OU(y = τ, m, s)

where:

τ = low-pass filter time constant; the break frequency is 1 ⁄ (2π τ) 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. It should
not be used in a PROCEDURAL. For a random number generator in a nonsorted
section, use GAUSS or UNIF.
Band limited white noise is implemented by this Ornstein-Uhlenbeck function. A
normal random number generator (GAUSS) delivers a fixed total power (RMS value),
but the frequency spread depends on the current step size. Usually the low frequency
power density is important, 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 Ornstein-
Uhlenbeck process maintains a constant source of power over a specified frequency
band, thus eliminating any problem of having to include the current integration step
size in the standard deviation of the random variable.

Note that in general the roll-off time constant τ should be at least twice the size of the
maximum integration step; use MAXTERVAL to enforce this constraint.
The operator is implemented by generating a correlated noise sequence from the
general formula:

n i+1 = ni e−∆t ⁄ τ + ωi

where:

τ = correlation time constant


∆t = sample interval
ωi = Gaussian random variable

In order to find the ωi that produces the correct noise power such that:

Page 4-62 ACSL Reference Manual


4.82 PAGE 4. ACSL Statements

__ __
n2 = σ2

square the above equation for n i+1 and take the expected values:
____ __ ___
n2n+1 = n2i e−2 ∆ t ⁄ τ + ω21

It can be assumed that the random drive is uncorrelated with the noise sequence; i.e.,
____
n i ωi = 0

But:
__ ____ __
n2i = ni+1
2
= σ2

so:

ω2i = σ2 ( 1 − e− 2 ∆ t ⁄ τ )

and now the sequence can be expressed by

n i+1 = ni e−∆ t ⁄ τ + σ 


√1 − e− 2 ∆ t ⁄ τ gi
 
where gi is a Gaussian random variable of zero mean and unit variance. An example
using the OU operator is:
noise = OU(ta1, mean, sigma)

4.82 PAGE
FORM: CALL PAGE(K, NLL)

where K is a code to modify the page eject as follows:

-2 suppress auto page eject, eject next write


-1 suppress auto page eject
0 ignore auto page eject but return NLL
1 turn on auto page eject
2 turn on auto page eject, eject next write

and NLL is returned as the number of lines left on the current page.
The subroutine PAGE is used to force a top-of-form and turn on or suppress auto page
eject. As a by-product, the number of lines left on the current page is returned as the
second argument. For example, in order to force a new page before writing ten lines
via a formatted write statement, use the following code:
CALL PAGE(2, NLL)
CALL LINES(10)
WRITE(6, 99) ...

The ACSL system normally operates in an internal auto page eject mode. The
exception is the printer PLOT command, when plots can span page boundaries. Auto
page eject is then restored after each PLOT.
There may be a conflict using the PAGE statement when using the plotting package
DISSPLA, which also has a PAGE command.

ACSL Reference Manual Page 4-63


4. ACSL Statements 4.83 PARAMETER

4.83 PARAMETER
FORM: PARAMETER(p1 = e1[, p2 = e2] ...)

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.
The symbolic name may then be used whenever an integer, real, logical, 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.
Expression The expression (ei) can consist of literal constants, PARAMETER names, and
arithmetic operators (+, -, *, /).
Type INTEGER PARAMETER variables are not automatically typed INTEGER, even if they begin
with letter I, J, K, L, M, or N. Include an INTEGER type statement for any integer
PARAMETER variable names before they are used.
Placement in The PARAMETER statement must appear in the program before the parameter is
program used; otherwise, the translator produces an error message:
...Parameter already defined NAME

Example PARAMETER statements are useful for defining things like array sizes and for
keeping the definitions in one place. For example,
INTEGER maxdim
PARAMETER (maxdim = 5)
DIMENSION a(maxdim,maxdim), v(maxdim), r(maxdim)
CONSTANT v = maxdim*1.0

4.84 PRINT
See I/O.

4.85 PROCEDURAL
FORM: PROCEDURAL(output list = input list)
...
END

where:

output list = v1, v2, ..., vn


input list = e1, e2, ..., en

and vi are nonsubscripted variable names while ei may be variables or expressions.


The PROCEDURAL header must be paired with a matching END statement.
The PROCEDURAL keyword denotes the beginning of a block of PROCEDURAL
code to be executed in the sequence given; i.e., the code within the PROCEDURAL
block is not sorted by the ACSL translator. PROCEDURAL blocks are required only
in sections that are sorted. They are permitted but not required in non-sorted sections
of the program.

Page 4-64 ACSL Reference Manual


4.85 PROCEDURAL 4. ACSL Statements

Arguments The header list should contain only nonsubscripted variable names. The variable
names may belong to arrays, however, in which case the entire array must be filled
within the block. The sort algorithm requires that values appear as outputs only once
in sorted code; otherwise the error message Multiply defined symbol is issued.
States and constants do not need to be included in the argument list because they are
available all the time. Calculated variables are needed because they tell the sorter
where to put the procedural in relation to calculations.
Array example As an example, 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. An acceptable form would embed this sequence in a PROCEDURAL


block, informing the sort routine to place the block before reference to any element of
the array A, as follows:
PROCEDURAL(a = x, y, z)
a(1) = x + y
a(2) = y + z
END

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

ACSL Reference Manual Page 4-65


4. ACSL Statements 4.86 PROGRAM

MACRO ptr(x1,x2,r,th)
x1 = (r)*COS(th)
x2 = (r)*SIN(th)
MACROEND

Figure 4-12. PTR operator macro

Integration Using integration operators (INTEG, REALPL, etc.) inside PROCEDURAL is not
operators illegal but does not make sense. States cannot be computed procedurally, only
derivatives can.

4.86 PROGRAM
FORM: PROGRAM [string]
...
END

where string may contain any number of characters, which are ignored. The
PROGRAM statement is the first line in an explicit model definition. It must be
accompanied by a matching END statement to terminate the model definition. The
character string is not used in any way and serves merely to identify the model file and
listing. For example:
PROGRAM a missile 6DOF simulation

For implicit programs (i.e., those with no explicit structure statements), use
DERIVATIVE rather than PROGRAM. This approach is required because some
system macros have INITIAL sections, which expect explicit structure with the
PROGRAM statement. A DERIVATIVE statement can include a name, but for a title
with more than one word, use the comment indicator.
DERIVATIVE ! title of program
...
END

4.87 PTR
FORM: PTR(x, y = r, θ)

The polar to rectangular operator resolves angle θ (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 θ
y = r sin θ

This form is not a functional representation since there are two outputs. Thus, this
statement cannot be embedded in an expression; it can only stand alone as shown.
Figure 4-11 lists the mechanization of this operator as a system macro.
An example of PTR is:
PTR(rt1, rt2 = lrt, fi)

Page 4-66 ACSL Reference Manual


4.89 QNTZR 4. ACSL Statements

Figure 4-13. Mechanization of PULSE Function

4.88 PULSE
FORM: y = PULSE(tz, p, w)

where y is a pulse train (0.0 or 1.0) starting at the first integration step at which time
equals or exceeds tz. The period is p and width is w, as shown in Figure 4-13. The
width cannot be zero.
The independent variable, default T, drives the PULSE function. 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. The output is always turned on (y = 1.0) at the
beginning of the first integration step following the exact turn-on time. The width is
not synchronized to the integration step size, so it should be significantly larger than
the step size.
Do not use PULSE as a strobe to periodically activate parts of a program. This is a job
for DISCRETE sections executed by means of INTERVAL statements or the
SCHEDULE operator.
PULSE could be used as follows:
drive = k*PULSE(tdrive, period, width)

4.89 QNTZR
FORM: y = QNTZR(p, x)

where x and p are real variables or expressions. The output y is the value of x
quantized in discrete steps of resolution p. This is a zero centered system, as shown in
Figure 4-14. An example of QNTZR is:
epq = QNTZR(ep, signal - oldsig)

ACSL Reference Manual Page 4-67


4. ACSL Statements 4.90 RAMP

Figure 4-14. QNTZR quantizer function

4.90 RAMP
FORM: y = RAMP(tz)

The RAMP function generates a linear ramp of unit slope, starting at a specified time
tz. It is another way of applying a dead zone to the independent variable.
RAMP starts at the first integration step that equals or exceeds tz, as depicted in Figure
4-15. The output can be expressed as follows:

y = 0.0 ; T < tz
y = T − tz ; T ≥ tz

An example of a RAMP statement is:


z = k1 + k2*RAMP(tramp)

4.91 READ
See I/O.

Figure 4-15. RAMP function

Page 4-68 ACSL Reference Manual


4.93 REALPL 4. ACSL Statements

MACRO realpl(y,p,x,ic)
MACRO STANDVAL ic=0.0
y = INTEG((x-(y))/(p),ic)
MACROEND

Figure 4-16. REALPL operator macro

4.92 REAL
FORM: REAL(x)

This function converts an integer, double precision, or single precision argument x to a


single precision value. See DBLE for a discussion of usage.
See also REAL as a single precision floating point variable type under TYPE.

4.93 REALPL
FORM: y = REALPL(p, x[, ic])
REALPL(y = p, x[, ic])

The REALPL operator produces a first order lag where output y is related to input x
through the transfer function:
y 1
=
x ps + 1

where:

y(0) = ic

Figure 4-16 lists the macro to implement this operator.


The initial condition has the same restrictions as the INTEG operator; i.e., if it is a
simple variable (the preferred form), this variable name must not be used as another
initial condition, state, derivative, or system variable name. If the initial condition is
zero, it may be omitted. The time constant p may be an expression of arbitrary
complexity, but it cannot be zero or division by zero results.
An example of a REALPL statement is:
xm = k3*REALPL(ta3, x)

ACSL Reference Manual Page 4-69


4. ACSL Statements 4.94 RESET

4.94 RESET
FORM: RESET("EVAL")
RESET("NOEVAL")

This special operator is provided for use in the INITIAL section to initialize the state
variables and optionally perform intermediate calculations.
Argument The arguments EVAL and NOEVAL specify whether or not a complete derivative
evaluation is to be attempted. It is your responsibility to ensure that unknown initial
conditions have reasonable values to prevent arithmetic errors (division by zero, for
example).
When states are Starting at Version 11, the states are initialized at the beginning of the INITIAL
initialized section, the equivalent of RESET("NOEVAL"). Previously, states had been initialized
at the end of the INITIAL section, so there was more reason to use this operator. Now
only RESET("EVAL") is needed.
Accelerometer RESET could be used for example in calculating the initial conditions on
example accelerometer filters in a missile simulation. In order to obtain the nominal
acceleration, the missile velocity vector must be rotated into the missile axes, the angle
of attack determined, and the aerodynamic coefficient data looked up to obtain force
coefficients. This code must be expressed in terms of the initial condition variables
rather than the state variables unless the RESET operator is used. If the
RESET("EVAL") statement is placed at the beginning of the INITIAL section, the
derivative subroutine calculates body acceleration using the state variable names.
Warning – all The problem in using RESET is that the process is not selective; calculation of all state
derivatives variable derivatives is attempted. In the above example, the output of the
calculated accelerometer filter is used later and if initialized indefinite leads to an arithmetic
error. If the undefined initial conditions are preset in a CONSTANT statement (0.5 is a
useful default number), then the calculation can proceed and the meaningless numbers
can be disregarded. The important consideration is that all the calculations be able to
proceed without arithmetic errors.
Implementation The RESET operator is defined in terms of a state vector (S) and an initial condition
vector (IC). The state derivative vector is given by:
.
S = f (S, T )

Now the RESET(a) action can be expressed:

S ← IC (move initial conditions into state table)


T ← ZZTICG (move independent variable IC into independent variable)

IF(a = EVAL) evaluate f (S, T )

4.95 RSW
See LSW.

Page 4-70 ACSL Reference Manual


4.97 SAVE 4. ACSL Statements

MACRO rtp(r,th,x1,x2)
r = SQRT((x1)**2+(x2)**2)
th = ATAN2(x2,x1+1.0e-30)
MACROEND

Figure 4-17. RTP operator macro

4.96 RTP
FORM: RTP(r, θ = x, y)

The rectangular to polar operator resolves the input Cartesian coordinates x and y into
polar angle θ (which is in radians in the range − π to + π 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:

r = √

x2 + y2
θ = ATAN2 (y, x )

Figure 4-17 shows the mechanization of this operator as a system macro. Note that the
second argument of the arc tangent (ATAN2) is modified by the addition of a very
small amount. This enables inputs of 0.0, 0.0 to return an angle of zero instead of
indefinite.
This form of the operator is not a functional representation since there are two outputs.
Thus, this statement cannot be embedded in an expression; it can be used only in the
standalone form as shown.
An example of RTP is:
RTP(ra, tha = xa, ya)

4.97 SAVE
FORM: SAVE

The macro tables containing the macro names and packed definitions are written (in
binary) on the ACSL system macro file. The SAVE operation allows you to maintain
your own files of macros separate from the system file.
The normal operation of the system is to read into the macro definition tables the
contents of the user macro file before the translation begins. If such a file does not
exist, no user macro definitions are present.
The action of SAVE is to write the current contents of the macro tables back on this
file, thus destroying the original contents. To use SAVE, you must have WRITE
permission on the current macro file.
Since the procedure for writing a user macro file varies depending on the computer
system, it is described in the ACSL Sim User's Guide.

ACSL Reference Manual Page 4-71


4. ACSL Statements 4.98 SCALE

4.98 SCALE
FORM: SCALE(smn, smx = ymn, ymx)

where:
ymn, ymx = minimum and maximum values
smn, smx = scaled minimum and maximum to be used on a plot
(i.e., rounded multiples of 1, 2, 4, or 10).
The SCALE operator rounds the inputs so that they are suitable for plotting. 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. The SCALE operator is
then used in the TERMINAL section of an explicit program to establish scale factors
for subsequent PLOT commands. It is used only when two or more plots need the
same, originally unknown, scale factors.
The first two arguments need not be distinct from the second; i.e., the following
statement replaces actual minimum and maximum values with the rounded ones:
SCALE(ymn, ymx = ymn, ymx)

4.99 SCHEDULE
FORM: SCHEDULE block/flag .AT. time-expression
SCHEDULE block/flag .XZ. real-expression
SCHEDULE block/flag .XP. real-expression
SCHEDULE block/flag .XN. real-expression

where:
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)
.AT. = following expression specifies time at which block is to be activated
(may not be used in a DERIVATIVE section)
.XZ. = zero crossing (positive or negative direction) of following expression
initiates finding time of zero crossing (may be used only in
DERIVATIVE section)
.XP. = zero crossing (positive direction only) of following expression initiates
finding time of zero crossing (may be used only in DERIVATIVE
section)
.XN. = zero crossing (negative direction only) of following expression initiates
finding time of zero crossing (may be used only in DERIVATIVE
section)
The block / flag is optional; however, flag cannot be used without a block also being
present. SCHEDULE can be used without a block or flag in order to force integration
to a certain point.
Flag setting If a flag is specified, it is set TRUE just before the DISCRETE section is executed,
stays TRUE during execution of the section, then is set back to FALSE.

Page 4-72 ACSL Reference Manual


4.99 SCHEDULE 4. ACSL Statements

Flag example The flag is available to handle logic, generally within a single DISCRETE section, as
in the following example:
PROGRAM
INITIAL
y = 0.0
END ! of Initial
DERIVATIVE
x = SIN(t)
SCHEDULE d/f1 .XZ. x+0.5
SCHEDULE d/f2 .XZ. x-0.5
TERMT(t .GE. tstop, 'Stop on time');CONSTANT tstp=4.9
END

DISCRETE d
IF(f1) THEN
y = 2.5
ENDIF
IF(f2) THEN
y =-2.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. The real-expression defines a function, the zero crossing
of which (in the appropriate direction) defines the event. This real-expression 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 intermediate evaluations
occur. If the real-expression is not a true function, the following error message may be
produced.
Event vanished - cannot proceed

WEDITG A summary of the activity at the time of an event (i.e., finding and narrowing the
window and calculating the value of the expression at each evaluation) is produced at
runtime at each occurrence of an event. In the example in Figure 4-18, the event finder
is activated in the first line and the window is narrowed over five iterations. 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.e., the position
of the section among the DERIVATIVE and DISCRETE sections in the program)
executed.
This output can be suppressed by setting runtime system symbol WEDITG (write
event description, default TRUE) to FALSE.
Handling The SCHEDULE operator handles the introduction of discontinuities into an
discontinuities otherwise continuous simulation. The integration algorithms used to solve equations in
the form:
.
x = F (x, t)

conventionally require the function F to be continuous and differentiable within an


integration step. 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, and it is
debatable how well the error control mechanism works in the event of a discontinuity
in one of the state variables. Nature has no real discontinuities given a sufficiently fine
time scale; discontinuities arise from simplifying the model and observing the system
behavior in a macro time scale.

ACSL Reference Manual Page 4-73


4. ACSL Statements 4.99 SCHEDULE

Event number 1 activated at 1.00000000 with value 0.00499994

Event number 1
Window between -1.0000E+37 and 1.00000000
Currently at 0.99500000 with value -0.04392740

Event number 1
Window between 0.99500000 and 1.00000000
Currently at 0.99948900 with value -1.1064E-05

Event number 1
Window between 0.99948900 and 1.00000000
Currently at 0.99949000 with value 4.4703E-08

Event number 1
Window between 0.99948900 and 0.99949000
Currently at 0.99949000 with value -4.6305E-06

Event number 1
Window between 0.99949000 and 0.99949000
Currently at 0.99949000 with value 4.4703E-08
Event occurred at 0.99949000
Event 1 with expression value 4.4703E-08 serviced with block 2

Figure 4-18 Event activity summary when WEDITG is TRUE

Bouncing ball In the example of a ball bouncing, the macroscopic view shows the velocity changing
example discontinuously (by the coefficient of restitution) at the instant of bounce. In the
microscopic view, the spring constant of the ball is taken into account and all the
forces of deformation are calculated, significantly increasing the model complexity but
eliminating the discontinuity.
Digital controller Another example is a digital controller. From a macroscopic viewpoint, the output is
example an analog control voltage through a digital to analog converter (DAC), which jumps
discontinuously at the output time points. At a microscopic level, voltages cannot
change discontinuously since finite capacitances are always present and must be
charged through some sort of resistive network. A simulation normally takes the
macroscopic view (i.e., a voltage jump) for efficiency, the designer deciding which
time scale of events is important for model validity.
Switch point If a point of discontinuity can be located, the solution on either side of the
discontinuity can be treated as piecewise continuous. 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.
Time vs. state Two types of discontinuity are encountered in general simulation models; one we call
events a time event and the other a state event. Time events can always be defined as state
events, but for efficiency they are extracted as a separate case. State events can be
visualized as occurring at surfaces in state space. Such surfaces include the zero height
plane in the bouncing ball problem, the zero velocity plane in Coulomb
stiction/friction, and the critical temperature plane for a reactor shutdown event. The
integration algorithm advances in discrete steps which at some point takes the model
across the critical surface; the problem is in finding the exact crossing point.

* Nordsieck, A., "On the Numerical Integration of Ordinary Differential Equations" Math. Comp (1962) pp. 22-49.

Page 4-74 ACSL Reference Manual


4.99 SCHEDULE 4. ACSL Statements

Finding the event In the special case of a time event which is a wall perpendicular to the time axis, the
integration step can always be taken as the minimum of the normal step or the time left
to the event, so no iteration is required. For state events, where the boundary is a
general surface in state space, an iteration brackets the event to a finer and finer
tolerance until a specified accuracy is reached. Mathematically the problem is stated:
.
x = F1(x, t ) ; g(x, t ) ≥ 0
.
x = F2(x, t ) ; g(x, t ) < 0

where the plane in state space distinguishing the event can be expressed by:

g(x, t ) = 0

where g is a single-valued function of the state variables and time.


Changing In actual fact, the situation can be complicated by the boundary function changing
boundaries when the state equations switch from F1 to F2. Examples of changing boundaries
include backlash, hysteresis, and Coulomb friction. In the friction model, the boundary
function is zero velocity when the body is sliding and applied force exceeding
breakout force when the body is stuck.
Warning – State events cannot be scheduled from IF constructs because ACSL has to keep a
IF constructs count of the state event statements. Time events can be used inside IF or DO
constructs in unsorted sections such as DISCRETE or INITIAL. Multiple IF
statements are dangerous; instead, use an IF-THEN-ELSE construct, which covers all
the bases so a value is not left around inadvertently.

4.99.1 SCHEDULE
Time Event
Specification
A time event is defined by the .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. Every execution of the
time event operator places a marker in the event list to execute a block at a particular
time. 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 event list
would fill with these markers.
A simple example in an INITIAL section to execute DISCRETE switch:
INITIAL
CONSTANT swtime = 10.0
SCHEDULE switch .AT. swtime
...
END

Execution time If the value of the time-expression is less than the current time, the block is executed
immediately after the current DISCRETE block has finished. Time in the continuous
section can never go backwards (with the exception of the entire model moving
backwards as described in Chapter 8).
Digital controller An example of the use of time events is the modeling of a digital controller with an
example analog to digital converter (ADC) sampling values from the continuous process, a
delay while control output values are computed, and then transfer of these values,
usually as voltages through DACs, but also as switch closings to activate solenoids
and control valves. For example, for a sampling time of 10 msec and compute delay of
4 msec, the code for the relevant DISCRETE sections could be as follows:

ACSL Reference Manual Page 4-75


4. ACSL Statements 4.99 SCHEDULE

DISCRETE adc
INTERVAL tsamp = 0.010
outp = F(sampled inputs)
CONSTANT dlt = 0.004
SCHEDULE dac .AT. T + dlt
END ! of adc section

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

4.99.2 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. The forms of SCHEDULE which
apply to state events are .XZ. (cross zero), .XP. (cross positive), and .XN. (cross
negative). They may appear only in DERIVATIVE sections.

Page 4-76 ACSL Reference Manual


4.99 SCHEDULE 4. ACSL Statements

Bouncing ball An example of a state event specification is finding the bounce point of a ball
example dropping (under the acceleration of gravity) with the following statement:
SCHEDULE bounce .XN. h

which executes a DISCRETE block called BOUNCE when height H crosses zero in
the negative direction. In the BOUNCE section, velocity is reversed and modified by
the coefficient of restitution as follows:
DISCRETE bounce
v = -kr*v
END

Flag vs. multiple Handling multiple events with a single block usually requires a flag so that the events
DISCRETE can be sorted out, but using SCHEDULE operators with separate DISCRETE blocks
can remove that requirement.
Warning – don't The state event SCHEDULE operator must be placed in a DERIVATIVE section. It
skip over state may not be placed inside a PROCEDURAL. It may not be skipped over by the use of
event operator GO TOs or other control transfer mechanisms (such as the various IF constructs) since
ACSL needs to keep a count of the SCHEDULE statements. The statement may be
placed anywhere in the DERIVATIVE section, 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.

4.99.3 SCHEDULE
State Event
Mechanization
At the beginning of a simulation run, the DERIVATIVE code is executed. Each call to
the state event handler increments a counter so that ACSL knows how many events are
in operation. If no active state events are present, then there is no need to test for an
event at each step. All state SCHEDULE statements must be evaluated at every
DERIVATIVE evaluation because they are known by the count of order of appearance.
Implementation After the integration algorithm has been initialized, the integration system saves all the
state variables at the beginning of a step, makes the step without regard to any events,
and then calls the DERIVATIVE evaluation block one last time to see if the states
have crossed the event threshold. Testing is not done during intermediate evaluations
of the derivatives since these are extrapolations of much lower accuracy in general
than the final step. 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), a count is kept and when all
expressions corresponding to the state event definitions have been evaluated, then the
remainder of the code is skipped. If the expressions are functions of only state
variables, the sorter does not have to move them. If they are functions of intermediate
calculated quantities (dynamic pressure, for instance), the event specification is sorted
to a position just after the calculation of its inputs, thus minimizing the code executed
at the threshold test phase.
The first derivative evaluation during the initialization process saves the current value
of the real-expression (EXPR) as the previous value (EXPP). At each subsequent step,
the current value is tested to see if EXPP and EXPR bracket zero. The code is as
follows:
IF(expr*expp .LT. 0 .AND. expp .NE. 0) GO TO event

ACSL Reference Manual Page 4-77


4. ACSL Statements 4.99 SCHEDULE

Starting on zero Note that if the previous expression EXPP is exactly zero, then no event is signalled.
An event is defined as starting from a non-zero value, with the new value crossing or
landing exactly on the zero point. 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.
Multiple events Any number of events can be specified and they all are found in sequence. A crossing
point is estimated for each event activated within a step, then the smallest value of the
independent variable (time) is selected.
Iterating to step The iteration within a step proceeds until the zero crossing is within a window less
than the tolerance, 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).
Executing Once the step has been taken, the DISCRETE block (if any) associated with each
DISCRETE active event is executed so that model conditions can be changed. Usually there is only
a single event pending since it is separated in time from other events. However, it is
possible that more than one event occurs in the same step and then each associated
DISCRETE block (which may be the same one called by different events) is executed
in servicing each event.
Re-evalutate After each pending event has been serviced by executing the associated DISCRETE
DERIVATIVE block, the DERIVATIVE routine is executed one last time with a flag set to cause
replacement of all previous values (EXPP) with current values. Any current events are
thus taken off the active list since the expression must now cross zero from the other
side (.XZ.) or return to the other side in order to cross zero from the same direction
(.XP.) for the next event.
DISCRETE can Note that the execution of the associated DISCRETE block can set variables in such a
change switching way as to change the switching function completely. In the case of friction, the
function switching function FI can be written:
fi = RSW(stuk, ABS(force) - breakf, veloc)

where the function RSW (real switch) returns the value of the second argument if the
first argument is TRUE; otherwise, it returns the third argument.
When the body is stuck (STUK is TRUE), the event occurs when the force acting on
the body (FORCE) exceeds a breakout force (BREAKF); i.e., when the expression
ABS(FORCE) - BREAKF crosses zero. When the body is not stuck, it sticks when the
velocity crosses zero. The units of the zero crossing function thus change depending
on the regime in which the model stands; i.e., Newtons of force when the body is
stuck, and meters per second for velocity when it is not stuck. This sticking/unsticking
is discussed in more detail in the example on friction in Appendix A.
Window tolerance The tolerance for bracketting an event is chosen from the minimum step size (MINT)
for the DERIVATIVE section and a machine-dependent fractional multiplier on time
(referred to as EPMX). On 64 bit computers, EPMX is defined as 1.0E-9; thus the
window at a simulated time of 50 seconds is 0.05 µsec (50 x 1.0E-9), which is larger
than MINT (1.0E-10 by default). If MINT is increased from its default, then it would
normally become the control for tolerance, and you assume responsibility for choosing
the tolerance relative to the model dynamics. For 32 bit computers, machine accuracy
for single precision is only about one part in eight million, so the machine tolerance
EPMX is taken as 1.0E-6. Steps of zero length must be avoided when stepping through
the zero crossing; a factor of about ten to eighty times the machine precision seems to
be adequate.
Handling Confining discontinuities to the DISCRETE event servicing block is a sound
discontinuities approach. The DERIVATIVE equations can then remain continuous through the

Page 4-78 ACSL Reference Manual


4.99 SCHEDULE 4. ACSL Statements

event, which allows the event to be found, slopes and states changed, and the
integration routine restarted so that past derivative history is discarded. (Subroutine
RSTART, described in Appendix B, can be used to help restart a variable step
algorithm.)
SIGN example An example of a discontinuity to which the SCHEDULE operator can be applied is the
SIGN function. The following statement:
force = SIGN(kslid, -veloc)

indicates that FORCE is to change discontinuously to oppose the velocity, which


affects the integration step when the velocity crosses zero. The actual integration step
that crosses the boundary has trouble with the discontinuity. In some cases it fails to
cross the boundary entirely when the actual step is taken by adding up the weighted
intermediate calculated (i.e., fixed step algorithms such as Runge-Kutta fourth order
with first order extrapolators). For this case, a better implementation is as follows:
force = fslid
SCHEDULE handl .XZ. veloc
...
DISCRETE handl
fslid = SIGN(kslid, -veloc)
END ! of discrete

Now the force is continuous and differentiable (a constant) in the continuous section,
giving the integration algorithm an easier task.
Warning – It is not possible to ask the event finder to find an event introduced by another
state must be DISCRETE block. An event is defined as the zero crossing of a function g(x) which
reproducible must be reproducible; i.e., if g(xn) and g(xn+1) bracket a zero crossing, going back to
g(xn) must produce exactly the same answer as the first time. If the state changes in
such a way that it is not reproducible (something in the form of X=X+1, for example),
the error message Event vanished may be generated.
To check whether the function is reproducible, get debug dumps by setting NDBUG to
some number at the region of the event (see Chapter 7). Look at the function value for
each debug dump when ZZFRFL (FiRst FLag) is TRUE, which occurs just once per
integration step.
Warning – The event finder also has a problem with the ACSL operators which have their own
memory internal memory (or state variables) when it is unable to back up and reproduce the
operators previous step before iterating to find the zero crossing. For example, the backlash
operator BCKLSH works by using the statement:
yl = MIN(MAX(yl, input - dl), input + dl)
output = yl

Thus, OUTPUT is the previous value YL (Y last) unless INPUT exceeds YL by more
than the backlash value DL. Backing up may leave YL at the same value, so the zero
crossing finder may find the expression on the same side of zero after the single step
backup, at which point it stops with the message Event vanished. 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, CMPXPL,


and TRAN) have no problem. Algebraic operators (such as STEP and RTP), which
pass a signal directly with no memory, also work correctly. DELAY is configured so
that it works with SCHEDULE.

ACSL Reference Manual Page 4-79


4. ACSL Statements 4.100 Separator (;)

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. Such a high frequency pole can increase
computer running time, however. Another approach is to write a routine to perform the
same function using integrators that can be handled by the zero crossing finder.
Warning – Be careful with trying to find a stopping condition at the boundary since the
finding stopping integration algorithm must take a step that crosses the boundary before recognizing
conditions that an event has occurred. If you want to stop on impact with the ground, do not do
the following:
SCHEDULE .XN. height
TERMT(height .LE. 0)

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. Instead use a DISCRETE
section; for example:
SCHEDULE stop .XN. height
...
END
DISCRETE stop
TERMT(.TRUE., 'Stopped on zero height')
END

Now the state event iteration takes the step to or just below the HEIGHT equal to zero
plane. Then the handler DISCRETE block is executed to set the STOP flag and
terminate the run.

4.100 Separator (;)


FORM: statement ; statement

A semi-colon (;) separates any valid ACSL statements. Comments can be placed only
after the last statement on a line since everything after an exclamation point (!) is
ignored by the translator. An example using the separator is:
TERMT(t.GE.tstop) ; CONSTANT tstop=4.9 ! Stopping condition

4.101 SIGN
FORM: y = SIGN(x1, x2)

where x1 and x2 are floating point constants, variables, or expressions. The output y is
the sign of x2 times the absolute value of x1. SIGN could be used as follows:
z = k*SIGN(zbase, zsign)

Mathematical convention defines SGN as:

SGN(x) = + 1.0 ; x ≥ 0.0


SGN(x) = − 1.0 ; x < 0.0

If you wish to achieve the following:


y = x*SGN(z)

Page 4-80 ACSL Reference Manual


4.103 SMOOTH 4. ACSL Statements

you can implement it with the SIGN function as follows:


y = x*SIGN(1.0, z)

Note that the result of SIGN(X, Z) is not the same as X*SIGN(1.0, Z).

4.102 SIN
FORM: y = SIN(x)

The output y is the sine of the floating point argument x, which must be in radians; the
result is in the range (− 1.0 ≤ y ≤ + 1.0). The output and function type (REAL or
DOUBLEPRECISION) depends on the type of the input. SIN could be used:
p = INTEG(y*SIN(w*t + fi), 0.0)

4.103 SMOOTH
FORM: smooth(y = 'datablock:argument')
y = smooth('datablock:argument')

The argument inside the single quotes identifies the DATA block by name (in front of
the colon) and which column of the data block to interpolate.
This operator interpolates between data points down a column of the given argument.
The method used is due to Akima* and uses a third order polynomial to be placed
through four bracketing points. The advantage of Akima's method is that small
changes are localized and at abrupt discontinuities, the curve looks more like a manual
fairing as opposed to a spline fit that tends to oscillate at discontinuities. As an
example, extract X as follows:
SMOOTH(x = 'foo:x')

or
x = SMOOTH('foo:x')

This looks up the value of the independent variable (in this case it has to be T, since
this is a column of the data block FOO), finds the data points that bracket this time,
and then linearly interpolates to find the function value that is placed in the output
variable X.
Example The simulation model in Figure 4-19 sweeps time from zero to ten and looks up the
value of X in two different ways, and the command file contains the DATA block
definition.
The result of running this simulation and the plot is shown in Figure 4-20. We have
overlaid the data points using the /DATA=foo switch on the plot, showing that the
points are marked with symbol number one (an octagon). The smoothed curve does a
good job of fairing between time 5.0 when the plot is 8.0 and times 6.0, 7.0, etc. when
the value of the function is identically equal to 2.0. No ringing is observed at the
corner.

* Akima, Hiroshi, "A method of univariate interpolation that has the accuracy of a third-degree polynomial", ACM
Transactions on Mathematical Software, Volume 17 Number 3, September 1991, pp. 341-366.

ACSL Reference Manual Page 4-81


4. ACSL Statements 4.103 SMOOTH

DERIVATIVE
CINTERVAL cint = 0.05
CONSTANT tstp = 9.9
! define 'y' so it can be specified as
! argument (although unused) in data statement
CONSTANT y = 0
x = LINEAR('foo:x')
xsmooth = SMOOTH('foo:x')
TERMT(t.GE.tstp, 'Stop on time limit')
END ! of derivative

(a) Model code

SET TITLE = 'Test of linear/smooth interpolation'


PREPARE/ALL
DATA foo(t, x, y)
0.0 2.0 2.0
1.0 3.0 2.0
2.0 1.0 2.5
3.0 3.0 3.5
4.0 9.0 1.5
5.0 8.0 4.5
6.0 2.0 5.0
7.0 2.0 5.0
8.0 2.0 6.3
9.0 2.0 8.1
END
PROCEDURE p1
PLOT x/WIDTH=3/CHAR=1/DATA=foo,xsmooth/STYLE=1
END ! of procedure

(b) Command file

(c) Plot of LINEAR versus SMOOTH results

Figure 4-19. Testing LINEAR/SMOOTH interpolation

Page 4-82 ACSL Reference Manual


4.105 SQRT 4. ACSL Statements

function ssqrt(dlp)
c-------------------signed square root
c won't abort when the input becomes negative
c-@@--------------------------single/double
REAL dlp , ssqrt
c
c-------------------use signed root of absolute value
ssqrt = sign(sqrt(abs(dlp)), dlp)
return
end

Figure 4-20. Signed Square Root Function (SSQRT)

4.104 SORT
FORM: SORT

The SORT keyword notifies the translator to sort all statements from the keyword to
the end of the section (INITIAL, DYNAMIC, DISCRETE, or TERMINAL). All
DERIVATIVE sections are sorted automatically.
This feature could be used for DISCRETE sections written under levels of ACSL at 9
or below, when they were sorted automatically, or for INITIAL sections which have
been built from a number of INCLUDE statements without regard to correct order.

4.105 SQRT
FORM: y = SQRT(x)
y = SSQRT(x)
y = FSQRT(x, lam)

The output y is the square root of x where x is positive floating point variable or
expression. The type (REAL or DOUBLEPRECISION) of the output and function
depend on the type of the input. A negative argument results in a exception trap on
most computer systems. An example using the SQRT function is:
miss = SQRT(xmt**2 + ymt**2 + zmt**2)

Alternative Compilers on different systems handle situations such as negative arguments to the
functions square root function differently. In order to catch and handle any errors gracefully,
SSQRT (signed square root) and FSQRT (flow square root) functions have been added
to the library at Version 11.5. Both convert automatically to single or double precision.
The functions are listed in Figures 4-20 and 4-21.
The signed square root function takes the square root of the absolute value of the
input, then gives the result the sign of the input. The flow square root function
switches to laminar flow when the pressure drop equals the second argument.

ACSL Reference Manual Page 4-83


4. ACSL Statements 4.106 STEP

function fsqrt(dlp, dlplam)


c-------------------signed square root for flows. has switch to
c laminar flow when the pressure drop equals the second argument
c the second argument may be zero so that there is no switch
c to laminar
c
c-@@--------------------------single/double
REAL dlp , dlplam , absdlp , fsqrt
c
c-------------------take absolute value once
absdlp = abs(dlp)
c-------------------if the absolute value below laminar threshold
c note cannot use equal since possible divide by zero
if(absdlp .lt. dlplam) then
c-------------------flow is linearly related to pressure drop
fsqrt = dlp/sqrt(dlplam)
else
c-------------------use signed root of absolute value
fsqrt = sign(sqrt(absdlp), dlp)
endif
return
end

Figure 4-21. Flow Square Root Function (FSQRT)

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. In this case, it should not only use SSQRT to avoid a numerical problem, but
also add a TERMT operator to stop the run and report the problem.
In some models, flows become zero and noise in the calculations can result in small
values on the negative side of zero. In these situations, the BOUND function would
probably be used to keep the variable from going negative.

4.106 STEP
FORM: y = STEP(tz)

The STEP function output y changes from zero to one at a specified value tz of the
independent variable. The result is

y = 0.0 ; T < tz
y = 1.0 ; T ≥ tz

The step begins at the first integration step that equals or exceeds tz. The effect of the
function is diagrammed in Figure 4-22 with the default of time (T) as the independent
variable. An example of a statement using STEP is:
dle = 0.1*STEP(tz) + dlz

There is a potential conflict between the ACSL function STEP and a routine in the
plotting package DISSPLA. We suggest either renaming STEP in the ACSL library
(to, for example, STEPT) or replacing the statement in the model source code from:

Page 4-84 ACSL Reference Manual


4.107 TABLE 4. ACSL Statements

Figure 4-22. STEP Function

y = k*STEP(tz)

to the following, which is equivalent:


y = k*RSW(T .GE. tz, 1.0, 0.0)

4.107 TABLE
FORM: TABLE name, n, d /list/

where:
name = name of the function. The value is accessed by name(arg1),
name(arg1, arg2), or name(arg1, arg2, arg3) for functions of one, two,
or three variables, respectively. The arguments are of any arbitrary
level of complexity.
n = an unsigned integer constant giving the number of independent
variables; this number must be 1, 2, or 3.
d = unsigned integer constants (may not be variable names); the number of
constants must correspond to the value of n. The values of the constants
give the number of discrete data points for each successive independent
variable. A dimension of one is illegal.
list = floating point constants. The values of the independent variable are
listed first. The number of these points must equal the sum of the
dimensions. Then the dependent values are listed with the fastest
varying argument first. The number of function data points must equal
the product of the dimensions.
The TABLE statement describes any arbitrary function of one, two, or three variables.
A separate TABLE statement must be used to define each function.
Accessing a TABLE statements must be defined before the table is referenced. The table is
TABLE accessed by name and the independent variable; for example, 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)

ACSL Reference Manual Page 4-85


4. ACSL Statements 4.107 TABLE

Accessing as a The table can also be accessed within a statement as with any function:
function

cd(1) = 0.5*CLP(mach)*b*wm(1)/mvm

More than one For a function of more than one variable, the independent variables are all listed in the
variable call, in the order given in the table:
cl = CLP(mach, al)

Breakpoints All data points for the independent variables (breakpoints) must be of monotonically
increase increasing order; i.e., values may be identical but a breakpoint must never be less than
monotonically a preceding value. Each TABLE statement may contain as many data points as
desired. Once the function has been defined, it may be referenced just like any other
ACSL function.
Repeat counts Repeat counts may be used in the data specification (e.g., 5*6.7 results in 6.7 repeated
five times). However, the breakpoints and data points are read into separate locations
by the translator and cannot be specified in the same repeat count. In the following
tables, the first statement is correct but the second results in a translator error message.
TABLE tab1, 1, 10 / 10*0.0, 10*0.0 /
TABLE tab2, 1, 10 / 20*0.0 /
...Bad break data count....

Examples Following are examples of tables of one, two, and three variables. The breakpoints are
2 for F1ARG, 5 for F2ARG, and 9 for F3ARG and the number of data points are 2, 6,
and 24, respectively. The first breakpoint appears first in the data.
TABLE F1ARG, 1, 2 / a1, a2, f1, f2 /

TABLE F2ARG, 2, 2, 3 / a1, a2, b1, b2, b3 &


, f11, f21, f12, f22, f13, f23 /

TABLE F3ARG, 3, 2, 3, 4 &


/ a1, a2, b1, b2, b3, c1, c2, c3, c4 &
, f111, f211, f121, f221, f131, f231 &
, f112, f212, f122, f222, f132, f232 &
, f113, f213, f123, f223, f133, f233 &
, f114, f214, f124, f224, f134, f234 /

Linear If the calculated values of the independent variables lie outside the range specified by
extrapolation and the TABLE statement, the values for the function are obtained by extrapolating
interpolation linearly from the last values given. Values between breakpoints in the table are
interpolated linearly.
Macro and array The TABLE operator makes up a macro having the same name as the function so that
defined all references to the TABLE after its definition are caught. An array is also defined
with the same name and enough storage to contain both function data values and the
corresponding argument breakpoint values. This array name is entered into the
dictionary and it may be accessed in by SET, DISPLAY, etc. runtime commands.
Order of data One point to note is the order of data entry into the array: The function data is listed
entry first, then the breakpoint values follow. 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. As an example, consider a
pitching moment table as a function of Mach number:
TABLE cm, 1, 5 / 0.0, 0.8, 1.2, 1.5, 2.5 &
, 0.50, 0.51, 0.92, 0.83, 0.15 /

Page 4-86 ACSL Reference Manual


4.107 TABLE 4. ACSL Statements

This statement produces an array CM(10) in which the first five elements contain the
function values 0.50, 0.51, 0.92, 0.83, 0.15 and elements six through ten contain the
breakpoint values 0.0, 0.8, 1.2, 1.5, 2.5. To change the function value at Mach 1.5, the
following runtime command can be used:
SET cm(4) = 0.65

To change the breakpoint from Mach 1.5 to Mach 1.6, the position in the table is
calculated (5 + 4) and the command becomes:
SET CM(9) = 1.6

Multidimensional For multidimensional tables, the function data is all listed in the array first, then the
tables breakpoint data in the order of first, second, third argument.
Function vs. array The function name followed by parentheses (cm(2.0), for example) on the right hand
side of an equal sign implies a call to look up the function value, while the table
function name without parentheses stands for the array that contains the function and
breakpoint values. The elements of the array cannot be accessed in the program
because parentheses indicate a function call, but the array name can be passed to a
FORTRAN subroutine (or function) to return the value of the array element. For
example, to access the third element of array CM, returned in array value D, call:
CALL getav(cm, 3, d)

where the subroutine is defined at the end of the ACSL program:


SUBROUTINE getav(f, n, av)
DIMENSION f(1)
av = f(n)
RETURN
END

Reading data Data can be read into a TABLE array, either by calling a subroutine within the model
into array or at runtime. Set up the table in the model, but fill the data by using a multiplier; for
example:
TABLE k, 1, 10 / 10*0.0, 10*0.0 /

or, if the breakpoints are known and only the data is to be filled in later:
TABLE k, 1, 10 &
/ 0.0, 0.0, 0.2, 0.4, 0.5, 0.6, 0.8, 0.9, 1.0, 1.0 &
, 10*0.0 /

Subroutine call Thus, to fill a TABLE from outside data, call a subroutine as follows:
CALL getk(k, 10)

The subroutine then is defined as follows:


SUBROUTINE getk(table, n)
REAL table(1)
DATA lu / 55 /
OPEN(UNIT=lu, FILE='myfile')
C--------------read function values
READ(lu, 99) (table(j), j = 1, n)
C--------------read breakpoint values
READ(lu, 99) (table(j), j = n+1, 2*n)
CLOSE(lu)
RETURN
99 FORMAT( < match file data > )
END

ACSL Reference Manual Page 4-87


4. ACSL Statements 4.108 TAN

Placement of The fill subroutine must appear after the definition of the function by the TABLE
subroutine call statement. If the TABLE statement is specified and a variable with the same name has
already been seen, this causes an error.
Since the data needs to be read in only once, the call can be put in the pre-INITIAL
section, or else on a switch in the INITIAL section as follows:
LOGICAL first
CONSTANT first = .TRUE.
IF(first) CALL getk(k, 10)
first = .FALSE.
...

Runtime SET or At runtime, use a SET command, either interactively or defined in a command file to
ACSL Math change TABLE data. The order of the data at runtime is data first, then breakpoints.
Another option is to generate the data in ACSL Math; when control is returned to
ACSL, the new values are read in automatically.
Warning – We recommend that labels not be attached directly to statements containing references
statement labels to table functions. When used in a program, the function referenced is translated into
an assignment to a dummy variable from the function look up subroutine; for example,
for the statement:
q = 0.5*ro(h)*v**2

the translation becomes:


Z99999 = ZZF1(10, Z99998, RO, H)
Q = 0.5*Z99999*V**2

where the first argument of ZZF1 (the 10) is the number of breakpoints, the second
argument is the current breakpoint interval, the third argument is the array name that
contains the function value, and the fourth argument is the expression that is the
original argument.
If the original statement is labeled so that control can be transferred by other GO TOs;
for example:
L1: q = 0.5*ro(h)*v**2

the label is still attached to the Q statement in the translated text and thus the Z99999
assignment is bypassed unless control flows directly. Labels in general should be
avoided and when used should be attached only to CONTINUE statements to prevent
this flow problem (see Chapter 2 for more about labels).

4.108 TAN
FORM: y = TAN(x)

The output y is the tangent of the real argument x, which must be expressed in radians.
The output and function type (REAL or DOUBLEPRECISION) depends on the type
of the input. TAN could be used as follows:
a = b + TAN(theta)

Page 4-88 ACSL Reference Manual


4.110 TERMT 4. ACSL Statements

4.109 TERMINAL
FORM: TERMINAL
...
END

The TERMINAL keyword identifies the beginning of the block of code performed at
the end of each run. It must be paired with a matching END statement. Code in the
TERMINAL section is not sorted automatically; however, you can specify sorting
with the SORT keyword.
In order to save calculating certain variables over and over again during the simulation
run, the calculations can be placed in the TERMINAL section and executed only at the
end of the run. Radial miss distance is an example of this type of variable. The range
components XMT, YMT, and ZMT are available throughout the flight, and radial miss
distance is calculated from the equation:
miss = SQRT(xnt**2 + ymt**2 + zmt**2)

Placing this in the TERMINAL section saves the extra computer time to evaluate this
expression every integration step or communication interval.
Multiple Any number of TERMINAL sections can be used within a program. They may appear
TERMINAL in any other section (INITIAL, DYNAMIC, DERIVATIVE, and DISCRETE) except
sections PROCEDURAL. This feature is particularly useful in conjunction with INCLUDE
files and/or ACSL macros. Modules can be developed in separate files with their own
TERMINAL sections, then brought into a DERIVATIVE section in a larger program
by means of INCLUDE statements.
The translator collects all the TERMINAL sections in the order given. This means that
code introduced in DERIVATIVE or DISCRETE sections appears before code in the
explicit TERMINAL section. If the sections of code need to be in a particular order (so
that a variable is defined before being used, for example), use the SORT keyword.
Parametric runs One method of setting up parametric runs is to loop from the TERMINAL section
back to the INITIAL section. See Chapter 8 for details of this procedure.

4.110 TERMT
FORM: TERMT(logical expression[, 'string'])

A run terminates when the logical expression in the TERMT statement becomes
TRUE. Any number of termination conditions may be specified, and the first
condition to become TRUE terminates the run. A minimum of one termination
condition is required; usually a time limit is specified.
The 'string' argument is an option for printing out user information on the
condition that terminates the run. It is considered low volume data and so appears on
the screen as well as in the print file. It is useful to include this argument even when
there is only one stopping condition since it confirms the run terminating normally.
All models must contain some specification for terminating the run; the TERMT
statement is the usual and best method of accomplishing this. In an explicit program,
control transfers to the TERMINAL section and then to the runtime executive. In an
implicit program, control goes to the executive directly.

ACSL Reference Manual Page 4-89


4. ACSL Statements 4.111 TRAN

Example An example of a typical TERMT statement is:


TERMT((h .LE. 0.0) .OR. (v .LE. vmin) .OR. (T .GE. tmax))

or, to provide information at runtime on which condition actually terminated the run:
TERMT(h .LE. 0.0, 'Termination on hitting ground')
TERMT(v .LE. vmin, 'Termination on flying backwards')
TERMT(T .GE. tmax, 'Termination on TMAX time limit')

Placement in TERMT statements can be placed in any of the DYNAMIC, DERIVATIVE, or


program DISCRETE sections. A TERMT statement placed in the DYNAMIC section of an
explicit program stops the run at a communication interval. In a DERIVATIVE
section, it stops the run at the integration step following the logical expression
becoming TRUE. In a DISCRETE section, the run stops at the execution following the
expression becoming TRUE.
With SCHEDULE In some cases, a DISCRETE section is executed solely to terminate the run when a
state event is detected. For example, SCHEDULE finds the state event of H (height)
crossing zero, and a DISCRETE section contains the TERMT statement:
SCHEDULE stop .XN. h
...
END ! of derivative
DISCRETE stop
TERMT(.TRUE., 'Termination on hitting ground')
END ! of discrete stop

This procedure is useful for stopping runs at precise events (see, for example, the
description of stopping missiles at intercept in Chapter 8).
Do not at the same time use an additional statement:
TERMT(h .LE. 0.0, 'Termination on hitting ground')

For the SCHEDULE operator to work, H must actually cross zero. However, if the
statement above is around, it sets the stop flag, thereby stopping the run before
SCHEDULE has iterated to find the zero crossing. The result is that the run stops on
the other side of the zero crossing rather than precisely on it.

4.111 TRAN
FORM: y = TRAN(nn, nd, qn, qd, x)
TRAN(y = nn, nd, qn, qd, x)

where:
nn = integer constant or PARAMETER name (may not be a variable name);
the order of the numerator polynomial
nd = integer constant or PARAMETER name (may not be a variable name);
the order of the denominator polynomial
qn = coefficient array for the numerator (can be an expression); may be a
real constant if nn is zero
qd = coefficient array for the denominator
x = input; an arithmetic expression of arbitrary complexity

Page 4-90 ACSL Reference Manual


4.111 TRAN 4. ACSL Statements

macro tran(out,nn,nd,p,q,in)
macro assign n
macro redefine i,z,zd,zic
macro relabel l1,l2
macro multiply 0
macro increment nn
macro 10: if(n=nd)20
macro if(n=1000)999
macro increment 1
macro goto 10
macro 20: continue
array z(nd),zd(nd),zic(nd)
constant zic=nd*0.0
procedural(zd=p,q,in)
zd(1)=in-z(1)*q(2)
macro if(nd=1)25
do l1 i=2,nd
zd(1)=zd(1)-z(i)*q(i+1)
l1: zd(i)=z(i-1)
macro 25: continue
zd(1)=zd(1)/q(1)
end
macro decrement nn
macro if(nn=nd)26
procedural(out=p,z)
macro if(nn=0)30
out=p(1)*z(n)
macro goto 27
macro 26: continue
procedural(out=p,z,zd)
out=p(1)*zd(1)
macro 27: continue
do l2 i=1,nn
l2: out=out+p(i+1)*z(i+n)
macro goto 40
macro 30: continue
out=(p)*z(nd)
macro 40: continue
end
z=intvc(zd,zic)
macro exit
macro 999: print Numerator greater than denominator in TRAN
TRAN: out, nn, nd, p, q, in
macroend

Figure 4-22. TRAN operator macro

Transfer functions in the form of a ratio of polynomials in the Laplace operator, s, may
be directly implemented in ACSL 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.
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. Note that nn+1 and nd+1
numbers are required in the numerator and denominator arrays since it is the order that
is defined, not the number of coefficients.
Warning The order of the denomenator must be greater than or equal to that of the numerator. 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.

ACSL Reference Manual Page 4-91


4. ACSL Statements 4.112 TRANZ

Requirements All initial conditions are taken as zero, and nn and nd must be literal integer constants
or PARAMETER names, but not variable names. The order cannot be changed
artificially by setting the highest power of the denominator polynomial to zero. QD(1)
must be nonzero; otherwise division by zero results. Order can be changed by
arranging for common factors in the numerator and denominator polynomials.
Example In the following example, note that the s1 term has to be filled in as a zero in the Q
(denominator) array. Note also that nn and nd must be entered as the numbers
themselves; variable names are not allowed. For the transfer function:

3s + 2
G(s) =
s + 2 s2 + 5
3

the model code becomes:


DIMENSION p(2), q(4)
CONSTANT p = 3.0, 2.0, q = 1.0, 2.0, 0.0, 5.0
out = TRAN(1, 3, p, q, in)

Arrays Variable names as well as literal constants can be used in the arrays. When the
numerator is a single value (zero order), it does not need to be declared in an array.
Some way of calculating the value (constant, array element, assignment statement, or
expression) must be provided, however. For a transfer function in the following form,
for example:
K
G(s) = 3
s + 1

only one array is required and the code could be:


DIMENSION d(4)
CONSTANT d = 1.0, 0.0, 0.0, 1.0
z = TRAN(0, 3, k, d, 5*x + COS(th))

Macro Figure 4-22 lists the mechanization of the TRAN operator as a system macro. This
implementation listing is an example of the complexities that can be implemented using macros.
Integration step When choosing the integration step size for the model, the reciprocal roots of the
size denominator polynomial should be considered.

4.112 TRANZ
FORM: y = TRANZ(nn, nd, qn, qd, x)
TRANZ(y = nn, nd, qn, qd, x)

where:
nn = integer constant or PARAMETER name (may not be a variable name);
the order of the numerator polynomial
nd = integer constant or PARAMETER name (may not be a variable name);
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; an arithmetic expression of arbitrary complexity

Page 4-92 ACSL Reference Manual


4.113 Type 4. ACSL Statements

Transfer functions in the form of a ratio of polynomials in Z-1 may be directly


implemented in ACSL by the TRANZ operator.
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. Note that nn+1 and nd+1
numbers are required in the numerator and denominator arrays since it is the order that
is defined, not the number of coefficients. Usually the qd(1) element is unity (1.0).
In the following example, note:

1 + 0.5 z−1
G(z) =
1 − 0.166667 z−1 − 0.166667 z−2

for which the model code becomes:


DIMENSION pn(2), qn(3)
CONSTANT pn = 1, 0.5
CONSTANT qn = 1,-0.166667,-0.166667
out = TRANZ(1, 2, pn, qn, in)

Coefficients If the number of coefficients in the numerator exceeds those in the denominator, make
the denominator order the same as the numerator and fill the trailing coefficients with
zeros. When there are no denominator coefficients, use a denominator coefficient
array with unity in the first element (qn(1) = 1.0) and the remainder zeros; for example,
DIMENSION pn(4), qn(4)
CONSTANT pn = 1, 2, 3, 4
CONSTANT qn = 1, 0, 0 ,0
out = TRANZ(3, 3, pn, qn, in)

matches:
outn = 1*inn + 2*inn+1 + 3*inn+2 + 4*inn+3

but this is probably better implemented using the HISTORY operator.


Complex filters For complex Z transform filters, a warning is in order concerning the accuracy of the
calculations. It is very easy to come up with a filter design that doesn't behave
correctly and needs double precision in order to work. (See the method for selecting
global double precision for the entire model in the ACSL Sim User's Guide.)
The TRANZ statement must be placed inside a DISCRETE section.

4.113 Type
FORM: DIMENSION v1, v2, ..., vn
REAL v1, v2, ..., vn
DOUBLEPRECISION v1, v2, ..., vn
INTEGER v1, v2, ..., vn
LOGICAL v1, v2, ..., vn
CHARACTER v1*n, v2*n, ..., vn*n

where the vi are either simple variable names or else subscripted arrays with up to six
integer constant subscripts separated by commas. The variables are typed and
(optionally) dimensioned at the same time. Subscripts must be numerical or a symbol
defined in a previous PARAMETER statement; variable names are not allowed.
Examples of type statements include:

ACSL Reference Manual Page 4-93


4. ACSL Statements 4.113 Type

INTEGER k, jj(10), fred(2, 2)


LOGICAL flag
CHARACTER mytitle*480
REAL x(5,5), k1
DOUBLEPRECISION vm(3), dot

FORTRAN The Fortran convention that names starting with I, J, K, L, M, or N are integer does
convention not hold. Variables are considered to be floating point, either single or double
precision depending on the translation mode, unless typed otherwise. Integer variables
must be typed specifically.
LOGICAL LOGICAL variables can take on values of .TRUE. or .FALSE.
CHARACTER The length of CHARACTER variables defaults to 1 if not specified.
Floating point REAL or DOUBLEPRECISION should be used only to force a variable to single or
double precision specifically since variables declared DOUBLEPRECISION are
always double and variables declared REAL are always single. DIMENSION is
recommended for specifying the dimensions of an array; the array then becomes single
or double precision depending on the translation mode.
System symbols System symbols such as T, CINT, MAXT, and MINT, and also states, derivatives, and
initial conditions, are changed automatically by the ACSL system; you cannot specify
their type.
Duplicates Duplicate declarations are permitted starting at Version 11.5. This is useful in graphic
permitted models when declared variables are output from ACSL blocks. The variables can be
declared in all of the blocks that are wired together, rather than only in the block that
computes the variable. Declarations must match exactly, or a diagnostic is produced.
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.
All the ACSL subroutines change type automatically, but if any other routines are
used, provision must be made to force the appropriate type. For example, the DOT
product function returns the dot product of two three-component vectors. A total
velocity magnitude could be obtained by:
REAL vm(3)
mvm = SQRT(DOT(vm,vm))

If DOT is written to accept double precision arguments and return a double precision
result, then ACSL must type these appropriately rather than relying on automatic
typing unless double precision mode is always used:
DOUBLEPRECISION vm(3), DOT
mvm = SQRT(DOT(vm, vm))

If DOT is single precision, the opposite must be specified; i.e.,


REAL vm(3), DOT
mvm = SQRT(DOT(vm, vm)

The Fortran generic SQRT adjusts automatically to the type of its argument and result.
Literal constants Other problems occur when using literal constants as arguments to subroutines. For
example, quantizing a signal to 0.1 increments could be written:
CONSTANT increment = 0.1
out = QNTZR(increment, in)

Although it is not good programming practice since the value cannot be changed at
runtime, some people put the increment value directly into the code:

Page 4-94 ACSL Reference Manual


4.113 Type 4. ACSL Statements

out = QNTZR(0.1, in)

If the double precision runtime library has been specified, the QNTZR subroutine
expects a double precision value for the increment and without modification would
pick up extra undefined bits behind the 0.1 value. In order to solve this problem, the
ACSL translator adds a D0 to the end of each real constant; i.e., on the compile file,
the line becomes:
OUT = QNTZR(0.1D0, IN)

and the function sees a true double precision quantity. If you really want a single
precision quantity in this situation, you can use the REAL function to force it:
out = mysub(REAL(0.1D0), ...)

An alternative is to use an exponent form to force double precision:


out = mydoublesub(1.0D-1, ...)

Missile example An example of converting external subroutines is shown in the two versions of the
missile simulation model (MISSGL.CSL and MISDBL.CSL) in Appendix A. In the
subroutines, two at-signs (@) mark that the following line (the input and output)
should be changed from REAL to DOUBLEPRECISION or vice versa. For example,
in the vector rotate subroutine VECROT, the argument definition line is:
SUBROUTINE VECROT(VIN, RMX, VOUT)
C-@@--------------------------DOUBLE/SINGLE
DOUBLEPRECISION VIN(3), RMX(3,3), VNT(3)

This is followed by code to effect the transformation. ACSL changes the arguments
automatically, so you must edit the subroutine o maintain compatibility.
LINPACK LU Another example of maintaining an external subroutine is the use of the double
decomposition precision LINPACK routine for factoring (i.e., LU decomposition) which is called
DGEFA. The calling sequence is:
CALL DGEFA(A, LDA, N, IPVT, INFO)

To use this, we would have to ensure that the matrix A is always double precision:
INTEGER lda
PARAMETER (lda = 10)
DOUBLEPRECISION a(lda, ida)
INTEGER ipvt(lda), info
CALL DGEFA(ipvt, info=a, lda, lda)

In general, it is better to use default types rather than forcing to single or double
precision via REAL or DOUBLEPRECISION statements.
Warning – The translator cannot check the type of arguments to subroutines compiled separately
errors not found from ACSL, or in general external library routines. It would be possible to have a
template for all ACSL routines, but do so would reduce flexibility in redefining the
meaning of the ACSL functions and subroutines. This is a common problem and
cannot be overcome unless the compiler is given access to the subroutine and its call in
the same compilation run. Most compilers even then won't check matches across
subroutine boundaries. In the following example, the literal integer input argument is
an error because the bit pattern for the integer 3 seen on the calling side will probably
be zero (exponent all zeros) when seen from the subroutine side as a real number.

ACSL Reference Manual Page 4-95


4. ACSL Statements 4.114 UNIF

SUBROUTINE foo(ri, ro)


REAL ri, ro
...
CALL foo(3, ro)

4.114 UNIF
FORM: y = UNIF(bb, tb)

The output y is a random variable uniformly distributed between a bottom bound bb


and a top bound tb. UNIF could be used as follows:
drive = k*UNIF(dlo, dhi)

This operator is not intended for use in a DERIVATIVE section because the power
density (or, what is usually more important, the low frequency power) depends on the
integration step size. Variable step integration methods can produce peculiar results.
See OU for details on generating noise in a DERIVATIVE section.

4.115 UNIFI
See GAUSI.

4.116 USEDBV
FORM: usedbv('datablock:variable')

USEDBV stands for Use Data Block Variable. When a model is connected to the
ACSL Math or ACSL Optimize, it is useful to be able to know what data blocks and
what variables are used in a model so that they can be selected through a pull down
menu. Unfortunately, the presence of the LINEAR or SMOOTH function is not
recognized by the runtime system until the user has issued the first START command.
It at this time that the derivative evaluation code is evaluated and DATA blocks are
looked for to satisfy any lines containing these LINEAR or SMOOTH functions.
So that the ACSL Optimize can tell what data blocks are needed prior to execution, we
have added the routine USEDBV (Use Data Block Variable) that can be placed in the
pre-INITIAL section of the ACSL model. The pre-INITIAL code is executed once at
the very beginning of the simulation, before any runtime commands have been
executed (and only once per runtime session).
If the DATA block used in the model is unnamed, then the datablock name in the
above (part in front of the colon) can be eliminated. Reference to unnamed blocks
requires them to be specified as a switch to the start command (START/DATA=...).
Examples:
program
usedbv('foo:x')
usedbv('foo:y')
initial
...
end
...
end

Page 4-96 ACSL Reference Manual


4.119 XERROR 4. ACSL Statements

This says that somewhere in the derivative evaluation code there is a statement of the
form:
smooth(x = 'foo:x')
linear(y = 'foo;y')

For the unnamed data block we might see:


program
usedbv(':x')
usedbv(':y')
...

For models that are not used in conjunction with ACSL Optimize, this function can be
ignored.

4.117 VARIABLE
FORM: VARIABLE name [, ic name [= floating point constant]]

The default independent variable is called T. It has an initial value of 0.0 and the initial
condition name is not accessible. Using the VARIABLE statement allows you to
designate the independent variable with a nonsubscripted name; the initial condition
name is then also accessible. The value for the initial condition cannot be a name.
If the variable name T is to be used for temperature, for example, the independent
variable could be called TIME and be given a negative initial condition as follows:
VARIABLE time, timeic=-5.0

4.118 WRITE
See I/O.

4.119 XERROR
See MERROR.

ACSL Reference Manual Page 4-97


4. ACSL Statements 4.119 XERROR

Page 4-98 ACSL Reference Manual


5. ACSL Runtime Commands

5.1 Runtime executive

Runtime is the point at which the program has been translated, compiled, linked, and
executed. It is waiting at the ACSL runtime prompt for your commands to exercise the
model. The commands are sequential. The order of execution is the order given, and
although procedures can be called, no branching or looping commands are available.
Data values (i.e., names defined in the program by CONSTANT or TABLE
statements) may be set at runtime; once set, they remain the same until changed by a
subsequent command or else recalculated by code in the program.
Control Control stays in the runtime executive until you issue a START or CONTINUE
command; then control is released to the program and integration begins. Some
method of terminating the run must be present in the model definition code; otherwise
the runtime executive never regains control. (See TERMT operator, Chapter 4.)
For typical command sequences used to exercise various types of models, see the
examples in Appendix A.
Runtime Runtime commands can be entered into a file (default name model.CMD) and read in
command file automatically at the beginning of the runtime session (see the ACSL Sim User's
Guide). We recommend command files for commands such as OUTPUT and
PREPARE, for setting system symbols (for the plotting environment, for example),
and for defining PROCEDUREs. In general, we recommend issuing execution
commands such as START interactively, either directly or by executing a
PROCEDURE.
Names; Throughout the description of these runtime commands, symbols (variable names)
quotation marks imply the value stored in the location corresponding to the name. Strings in quotation
marks however stand for themselves; they are general character data and are usually
titles, comments, or file names.
!&;*? The use of these characters at runtime is described under Comment (!), Continuation
(&), Separator (;), and Wild cards (* and ?). The comment, continuation, and separator
are also available for use in program code (see Chapter 4).
Commands and Runtime statements begin with a command. Qualifying switches are introduced by
switches slashes (/). Both commands and switches may be abbreviated to just enough characters
for uniqueness (PL for PLOT, PRI for PRINT, PRE for PREPARE, PRO for
PROCEDURE, for example). The exceptions are the single character D for DISPLAY
and S for SET, since these are such frequently used commands. The required
characters are shown in boldface in the command definitions. A command such as:
PLOT x /CHARACTER=1 /TYPE=102 /RUN=2

can be reduced to:


PL x /CH=1 /TY=102 /R=2

Although abbreviations save time in interactive sessions, we recommend spelling out


the commands and switches in command files to improve readability.

ACSL Reference Manual Page 5-1


5. ACSL Runtime Commands 5.2 ACTION

Data types Data must be given in the appropriate format; i.e., integer, real, logical, or character.
An integer is a string of digits with no decimal point; a real number is a string of digits
with an optional decimal point and/or exponent; and a logical is .TRUE. or .FALSE.
(with short forms of .T. and .F.). Integers used for real variables are automatically
floated prior to use.
Data entered at runtime is converted to binary format before the type of the receiving
data is looked at. If double precision accuracy is needed, use a D exponent to signify
conversion to double precision immediately (2.56D3, for example). If E format is used
(2.56E3), the number is converted to single precision and then, if it is to be set into a
double precision variable, this single precision quantity is extended with trailing zeros.
CHARACTER Character variables can contain any printable character, and case is maintained in
character strings used for titles and plot tags. Character variables can be assigned with
the SET command by using a string delimited with single quotation marks:
SET charvar = 'This is a string'

To include a single quotation mark within a string, enter the quote twice:
SET charvar = 'This is ACSL''s possessive'

Symbolic data A symbol can be substituted for an expected data element; the program considers the
data element to be that contained in the symbol. The data type is that associated with
the symbol in the model definition. As an example, consider:
OUTPUT t, a, b /NCIOUT=i

The switch /NCIOUT expects an integer to define the number of communication


intervals between OUTPUTs. The current value in the symbol I is used to specify this
number. Since variables not typed INTEGER or LOGICAL are considered REAL, the
symbol I must have been typed explicitly in the model definition by:
INTEGER i

Arrays Arrays may have up to six dimensions and can be referenced at runtime by these
dimensions. For example, an array could be defined in the model:
DIMENSION vbody(3,5)

and an element accessed at runtime by:


DISPLAY vbody(2,4)

5.2 ACTION

FORM: ACTION /VARIABLE = <real-variable> &


/VALUE = <matching-variable> &
/LOCATION = name

SWITCH: /CLEAR

Actions can be scheduled at specified values of the independent variable. Examples of


variables you can control with the ACTION command are NDBUG (number of debug
dumps), NCIOUT (number of communication intervals per output), and variables
defined in the program by CONSTANT statements.
The ACTION command is issued before the START command that executes it. The
action occurs at the first integration step after the time specified by /VARIABLE.

Page 5-2 ACSL Reference Manual


5.2 ACTION 5. ACSL Runtime Commands

Switches /VARIABLE specifies the value of the independent variable (usually time) at which
the ACTION is to occur. /VALUE is the value to be placed into location
/LOCATION. The type (INTEGER, REAL, DOUBLEPRECISION, or LOGICAL) of
the value in /VALUE must match the type of the name in /LOCATION. /VARIABLE
and /VALUE must precede the /LOCATION they refer to; i.e., /LOCATION must be
the last switch specified for a given action.
Order ACTION statements are cumulative. Each action scheduled is inserted into to a linked
list of existing actions. It is not necessary to order the values of the independent
variables; i.e., you can command an earlier action after a later one. Each time
/LOCATION is mentioned, an ACTION is set up using the then current values for
/VARIABLE and /VALUE; thus, /VARIABLE and /VALUE need not be explicitly
stated with each ACTION command if they do not change.
/CLEAR Since the ACTION statement is cumulative, repeated commands, rather than
correcting previous commands, simply add to them. To remove all accumulated
actions and start over, use:
ACTION /CLEAR

Variable names As with all other commands, you can use a variable name where a data item is
for data expected and the contents of this variable are automatically substituted. The value
used, however, is the value at the time the ACTION statement is analyzed, not that at
the time the ACTION is performed (after the START).
Debug dumps The ACTION command can be used, for example, to produce debug printouts at
various times during a run. This ability is particularly useful for debugging a program
when something pathological occurs at a given time in the run. When the system
symbol NDBUG is an integer greater than zero, the debug dump is written out and
NDBUG is decremented by one. Issuing the following command before a START
produces five debug listings at time T=0.0 and two debug listings at T=1.0:
ACTION /VARIABLE=0.0 /VALUE=5 /LOCATION=ndbug
/VARIABLE=1.0 /VALUE=2 /LOCATION=ndbug

Controlling OUTPUT rates can be controlled by scheduling similar action on NCIOUT (the
OUTPUT rate number of communication intervals per output), which has a default of integer one.
Another example illustrates how /VARIABLE and /VALUE need not be explicitly
stated if they do not change:
ACTION /VARIABLE=0.0 /VALUE=5 /LOCATION=ndbug
/VALUE=2 /LOCATION=nciout &
/VARIABLE=1.0 /LOCATION=ndbug &
/VALUE=10 /LOCATION=nciout

In this example, two actions each are scheduled at 0.0 and 1.0, and /VALUE of 2 is set
into both NCIOUT (at /VARIABLE=0.0) and NDBUG (at /VARIABLE=1.0).
Model constants Constants specified in program code can be controlled by the ACTION command. For
example, if a CONSTANT named GAIN has been defined, it could be set as follows:
ACTION /VARIABLE=0.0 /VALUE=1.0 /LOCATION=gain
ACTION /VARIABLE=5.0 /VALUE=2.0 /LOCATION=gain &
/VARIABLE=10.0 /VALUE=4.3 /LOCATION=gain

However, using a variable in /LOCATION does not work if the variable is computed
in a DERIVATIVE section.
Warning – The integration routine allocates table space to handle the specified algorithm before a
don't change run begins. After once determining IALG for a run, ACSL never looks again to see if
IALG it has changed. Trying to change the algorithm with ACTION has no effect.

ACSL Reference Manual Page 5-3


5. ACSL Runtime Commands 5.3 ANALYZE

5.3 ANALYZE

FORM: ANALYZE

SWITCHES: /BODE
/CLEAR
/EIGEN
/INVNYQ
/JACOBIAN [= 'filename']
/NICHOLS
/NYQUIST
/ROOTLOCUS
/STATUS
/TRIM
/ZEROS

LISTS: /CONTROL = name, ..., name


/FREEZE = name, ..., name
/OBSERVE = name, ..., name
/RELEASE = name, ..., name

QUALIFIERS: /CINDEX = <integer-variable> [1]


/DEGREE = <logical-variable> [.TRUE.]
/DELAY = <real-variable> [0.0]
/DISPLAY = <logical-variable> [.FALSE.]
/FLOGSC = <logical-variable> [.TRUE.]
/FRACDL = <real-variable> [1.0]
/FRACPM = <real-variable> [1.0]
/FREQMN = <real-variable> [1.0]
/FREQMX = <real-variable> [1000.0]
/GAINDB = <logical-variable> [.TRUE.]
/GAINMN = <real-variable> [RMX]
/GAINMX = <real-variable> [RMX]
/GLOGSC = <logical-variable> [.TRUE.]
/HERTZ = <logical-variable> [.TRUE.]
/IMAGMN = <real-variable> [RMX]
/IMAGMX = <real-variable> [RMX]
/INC = <real-variable>
/LIST = <logical-variable> [.FALSE.]
/MINC = <real-variable> [0.0001]
/MUMAX = <integer-variable> [2000]
/NITRMX = <integer-variable> [50]
/OINDEX = <integer-variable> [1]
/PHASMN = <real-variable> [RMX]
/PHASMX = <real-variable> [RMX]
/REALMN = <real-variable> [RMX]
/REALMX = <real-variable> [RMX]
/RMSEMX = <real-variable> [0.0001]
/VECTORS = <logical-variable> [.FALSE.]
/XINC = <real-variable> [0.0001]

The ANALYZE command invokes a linear analysis capability to evaluate the


Jacobian, trim the state variables to null the rates, calculate eigenvalues and their
associated eigenvectors, and generate frequency response analysis and plots.
Executing an ANALYZE command before a START causes the initial condition
vector to be copied to the state vector, and the following informational message is
produced:
States not initialized. Moving IC vector to state vector.

Page 5-4 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

This initialization procedure however does not execute code in the INITIAL section. If
any initial conditions are calculated in the INITIAL section, execute the model at time
zero before using the ANALYZE commands as follows:
SET tstop=0.0 ! or equivalent termination condition
START
ANALYZE ...

The various switches, lists, and qualifiers are explained in the sections below. The last
section contains examples and further discusses use of the ANALYZE command.

5.3.1 ANALYZE lists

Switches are used to set up control variables and observables and to freeze and release
states. The lists associated with these switches are cleared with ANALYZE /CLEAR.
/MINC, /XINC, and /INC control perturbation of the control variables. These topics
are discussed in the following sections.

5.3.1.1 ANALYZE
/CONTROL
/OBSERVE

Switches /CONTROL and /OBSERVE define lists of controls and observables; e.g.:
ANALYZE /OBSERVE=y1,y2 /CONTROL=u1,u2,u3
ANALYZE /JACOBIAN

The /JACOBIAN following the /OBSERVE and /CONTROL lists the A, B, C, D


matrices in turn from the state space model formulated as:
.
X = [A] X + [B] U
Y = [C] X + [D] U
Matrix The matrix dimensions for the above example, assuming N state variables, are: [A], N
dimensions by N; [B], N by 3 (controls); [C], 2 (observables) by N; and [D], 2 by 3.
Restrictions on There are normally no restrictions on the observables, but the controls must not be
controls calculated (i.e., they must be defined in CONSTANT statements). This is because the
state variable and control variable lists are joined together and then each is perturbed
in the positive then negative direction, calculating a column in the combined matrix:

AB 
CD
 
In most models, control variables are calculated quantities since potential controllers
are built into the model, so terms are in the form:

U1 = G1(s)∗EP1
U2 = G2(s)∗EP2

For the linearized model, extra variables are required so they can be adjusted. The
code should be written in the form:
CONSTANT kc1=1.0, uz1=0.0
u1 = kc1*G(S)*EP1 + uz1

ACSL Reference Manual Page 5-5


5. ACSL Runtime Commands 5.3 ANALYZE

where the perturbation term UZ1 is a constant zero and is added on to the output of the
controller. For ANALYZE to obtain the open loop state matrix, first set KC1=0.0; i.e.,
SET kc1 = 0.0
ANALYZE /CONTROL=uz1 /JACOBIAN

Error messages If an attempt is made to include a nonconstant (calculated) variable to the /CONTROL
list, the following error message is produced when the matrices are calculated:
...Independent variable changed in Jacobian evaluation
...State changed in Jacobian evaluation

If the feedback path has a nonzero value, then setting KC1 to zero makes the control
zero and possibly disturbs the operating point. The constant value UZ1 can be adjusted
to keep the control value constant so that U1 keeps its value; i.e.,
SET uz1=u1, kc1 = 0

Other error messages may be produced when the Jacobian is evaluated. They include
messages relating to nonlinearity (a warning that the slope obtained by a positive
perturbation is different from that obtained by a negative perturbation) and
repeatability (which implies that the derivative evaluation routine is not a pure
function since one of the results is not repeatable with identical state values). See
Chapter 7 for a discussion of these messages.
Row and column Error messages stating row and column numbers refer to the combined matrix and so
designation can be outside the limits of the simple Jacobian. For example, consider a model with
five states, two observables (Y1, Y2), and three controls (U1, U2, U3). The actual
matrix being evaluated:

AB 
CD
 
has seven (5+2) rows and eight (5+3) columns. A message referring to row six
indicates the first observable (Y1), and column seven indicates the second control
(U2). Use the ANALYZE /JACOBIAN command to get a listing of the rows,
columns, and matrix elements.

5.3.1.2 ANALYZE
/FREEZE
/RELEASE

/FREEZE The /FREEZE switch eliminates the listed variables from the state vector; its purpose
is to eliminate open loop integrators before initiating the trim operation. Open loop
integrators are those states which have no effect on themselves or on other states or on
which other states have no effect.
An example of a state having no effect is a horizontal distance, obtained by integrating
horizontal velocity in an airplane simulation. Vertical motion affects density, which in
turn affects all forces and moments, but horizontal position is not usually used
anywhere in the model (unless position is important, for example in a landing control
system model). Variables of this type produce a zero column in the Jacobian.
State variables which are not affected by other states usually have a derivative that is a
constant or a function of only the independent variable. These are sometimes used as
forcing functions; e.g.,
force = INTEG(F(t), 0.0)

Page 5-6 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

Since no other states affect the state, this produces a zero row in the Jacobian. If the
Jacobian contains either a zero row or a zero column, its inverse does not exist.
Once frozen, variables stay frozen until you reset them with ANALYZE /CLEAR.
/RELEASE The /RELEASE switch is the complement of /FREEZE. The unfreezing or RELEASE
of a small number of states shortens the list when the user wants to study a small
subsystem embedded in a much larger model. The switch is not often used by itself.
/CLEAR with /CLEAR is equivalent to freezing all the states, but this applies only to the rest of the
/RELEASE line following the /CLEAR. If the ANALYZE command starts operating and finds all
states frozen (or no states active), then it automatically releases all the states. To
release a few states, use:
ANALYZE /CLEAR /RELEASE=x,y,z

rather than:
ANALYZE /CLEAR
ANALYZE /RELEASE=x,y,z

which does not work since all states are automatically released at the beginning of the
second ANALYZE.

5.3.1.3 ANALYZE
/CLEAR

The ANALYZE lists are cumulative. In order to remove all previous lists and start
over, use the /CLEAR switch; for example:
ANALYZE /CLEAR /OBSERVE=y1,y4

The /CLEAR switch resets only lists of variables affected by /FREEZE, /CONTROL,
and /OBSERVE (i.e., states and derivatives), not processing flags such as /LIST=.T.,
etc. It also does not reset variables such as /MINC or /NITRMX to their defaults.
The /CLEAR switch can be included within the ANALYZE command line; it executes
in sequence according to a left-to-right scan of the line.

5.3.1.4 ANALYZE
/MINC
/XINC
/INC

These three switches control perturbation of the /CONTROL variables. /MINC is the
fractional perturbation, /XINC is the absolute perturbation, and /INC overrides /MINC
and /XINC by specifying an actual increment for perturbation of the immediately
preceding /CONTROL variable. /MINC and /XINC apply to all /CONTROL variables
following their specification.
Perturbation of the state variables is taken to be the allowable error, as calculated by
the current values of MERROR and XERROR.An example using these switches is:
ANALYZE /XINC=1.0E-6 /CONTROL=u1,u2 /INC=0.01

Perturbation is calculated (and saved away) at the ANALYZE command that sees the
/CONTROL switch. In order to change the perturbation, the /CONTROL list must be
cancelled by /CLEAR. /CLEAR should be on a line by itself.

ACSL Reference Manual Page 5-7


5. ACSL Runtime Commands 5.3 ANALYZE

ANALYZE /CLEAR
ANALYZE /XINC=1.0E-7 /CONTROL=u1 /INC=0.001, u2/INC=0.01

The actual perturbation used is the maximum of /MINC and /XINC unless overridden
by /INC. The algorithm, which obtains a value even if the control variable is zero, can
be expressed:

∆ Uj = MAX ( XINCj, MINCj |Uj | )

where ∆ Uj is the perturbation applied to the jth control variable Uj.

5.3.2 ANALYZE
/JACOBIAN

/JACOBIAN calculates the Jacobian about the current point in state space by
numerical perturbation. The result is then printed out as a large matrix as shown in
Figure 5-1 where the rows are states and the columns are derivatives. This is
conventionally known as the A matrix.
If CONTROL or OBSERVE has been used to define lists of control or observable
variables, respectively, then the elements of the B, C, and D matrices are calculated
and displayed along with the A matrix by /JACOBIAN.
In order to simplify transfer of the state description to auxiliary programs, it can be
written to a file by specifying a file name in quotes as follows:
ANALYZE /JACOBIAN='myfile'

The file is binary. For an ASCII file, we suggest editing the runtime log file (.log).

5.3.3 ANALYZE
/EIGEN
/VECTORS

/EIGEN calculates the Jacobian and then evaluates and lists the complex eigenvalues
and optionally the eigenvectors.
/VECTORS determines whether eigenvectors are to be calculated; so, if used, it
should precede /EIGEN. Once set, /VECTORS stays the same until explicitly
changed. These switches could be used as follows, with results as shown in Figure 5-1:
ANALYZE /JACOBIAN /VECTORS=.T. /EIGEN

5.3.4 ANALYZE
/TRIM
/MUMAX
/FRACDL
/FRACPM
/RMSEMX
/NITRMX

/TRIM /TRIM transfers the initial conditions to the state variables, computes the Jacobian,
and then, using a combination of Newton-Raphson and steepest descent steps, adjusts
the state variables until the derivatives go to zero.

Page 5-8 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

Row vector names


TH 1 THD 2
Column vector names
Z09997 1 Z09998 2
Matrix elements - rows across, columns down
1 2
1 0. 1.0000000
2 -8.6975100 -0.0286102

Complex eigenvalues in ascending order


REAL IMAGINARY FREQUENCY DAMPING
1 -0.01430510 +/-2.94912000 2.949150 0.004851

Complex eigenvectors
1 2
1 0.3211180 0.0015576 0.3211180-0.0015576
2 0. -0.9470380 0. 0.9470380

Figure 5-1. ANALYZE /JACOBIAN /VECTORS=.TRUE. /EIGEN

If control and observable variables are specified, then /TRIM adjusts the combined
state and control vector to drive the combined derivative and observable vector to
zero. The requirement is that there be the same number of adjustable variables as
variables to be driven to zero. Since there is always an identical number of (unfrozen)
derivatives and states, this means that the number of controls and observables must
also be equal.
/MUMAX, /FRACPM, /RMSEMX, /NITRMX, /FRACDL, and /LIST should be set,
if desired, before invoking /TRIM; each of these switches, once set, remains the same
for any subsequent calls to /TRIM until explicitly changed.
The trim or steady state finder computes the Jacobian matrix [A] and then a Newton
step and the steepest descent step by:

∆ XNT = [ A ]−1 εX Newton


T
∆ XSD = [ A ] εX steepest descent

and then uses a parameter µ to choose between the two:

∆ X = ∆ XNT ∗ 2−µ + ∆ XSD ∗ µ ∗ 2−µ

If the step fails, µ is incremented; if the step succeeds, µ is decremented with a floor of
zero. When µ is zero, the step is a pure Newton step. When µ rises to four, a new
Jacobian is evaluated. As µ rises, the step becomes smaller and is biassed increasingly
towards the steepest descent step; improvement is guaranteed in this direction if the
Jacobian is correct.
/MUMAX /MUMAX stops the indefinite increase in the value of µ which will force very small
steps. Setting MUMAX to zero ensures that every step is a Newton step. When µ
equals MUMAX, Jacobians are evaluated repeatedly, however, not just when µ
exceeds four.
/FRACDL /FRACDL is an arbitrary multiplier (of value between 0.0 and 1.0) on the calculated
step length. The default of one (1.0) can be changed to a smaller number on the basis
that one of the usual problems with convergence is that too large a step moves the
calculation into a different region even though the direction is inherently correct. If
difficulty with convergence is encountered, try /FRACDL = 0.5 and /FRACDL = 0.1;

ACSL Reference Manual Page 5-9


5. ACSL Runtime Commands 5.3 ANALYZE

keep in mind, however, that the convergence rate will be affected and more
computation time required.
Iteration failure is reported when all of the steps are below /FRACPM of the allowable
state error and the system is considered to be at a local minimum. Convergence
success is reported when the weighted sum of squares becomes less than /RMSEMX.
/FRACPM /FRACPM multiplies the minimum step for each state in order to determine when the
iteration should terminate. Normally, when each step is less than the allowable state
error (determined by XERROR and MERROR values), then the iteration terminates
since the assumption is that the system is caught in a local minimum where not all the
derivatives have been driven to zero. Sometimes this is too loose a criterion and can be
tightened to force the iteration onward by using the /FRACPM qualifier; e.g.,
ANALYZE /FRACPM=0.01 /TRIM

where the iteration will stop only when each state step is less than one hundredth of
the state allowable error value.
/FRACPM can be set to zero to remove this stopping condition so that iteration will
terminate only on /RMSEMX or on the maximum number of iterations /NITRMX.
/RMSEMX /RMSEMX specifies the allowable error at which trim convergence is obtained. Each
state is associated with an allowable error dXj in the usual fashion by:

dXj = MAX ( XEj, MEj∗| Xj | )

where XEj and MEj are the absolute and relative errors specified for the particular
state. This quantity is used in the Jacobian calculation as from:
.
Xi = Fi ( X1, X2, ..., Xj, 〈 )

∂ (Fi) Fi ( ..., Xj + dXj, 〈 ) − Fi ( ..., Xj − dXj, 〈 )


=
∂ (Xj) 2 dXj

During trim, the weighted residual R is computed from:



N .
 Xj  2
∑  dXj 
j =1
R = N

∑  dXj  2
1

j =1  

We are trying to drive the derivatives to zero, and this quantity R serves to measure in
a weighted RMS sense. However, it does have the units of reciprocal time and so can
be influenced by time unit changes (seconds to hours to days to fortnights, etc.).
Change the value of /RMSEMX to a smaller value if the derivatives at convergence
are not small enough (see /FRACPM for keeping the iteration going if it terminates
prematurely, which may mean it thinks the iteration is caught in a local bowl).
/NITRMX /NITRMX specifies the maximum number of iterations before the trim or steady state
finder gives up.
At each step, the Jacobian is modified using the Broyden update method to attempt to
track changes due to nonlinearities along the iteration trajectory.

Page 5-10 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

Initial conditions Remember that /TRIM uses the initial condition values as its starting point for finding
the steady state. For a nonlinear system, judicious choice of initial condition values
may be necessary before a steady state can be achieved. It may be necessary to
START the simulation with a time limit of zero before using the /TRIM switch if any
initial conditions are computed in the model INITIAL section. Letting the system run
for a short time can bring high frequency components to steady state and can
sometimes help the steady state finder. Use REINIT to transfer states to initial
conditions prior to using /TRIM.

5.3.5 ANALYZE
Frequency response

This section describes the frequency response analysis in general, and the following
sections describe the switches and parameter settings in more detail. System symbols
that affect the frequency response analysis have names ending in the three characters
FPL and are described in Appendix C.
Frequency response plots are produced by the following commands:
ANALYZE /BODE Bode
ANALYZE /INVNYQ Inverse Nyquist
ANALYZE /NICHOLS Nichols
ANALYZE /NYQUIST Nyquist

The commands may be issued separately or all on one line. When the command is all
on one line, there is no pause between the plots.
The data for these plots is all obtained as a result of a frequency sweep, calculating the
phase and gain as a complex number (Gcosθ, Gsinθ) from a given control input
(CINDEX) to an observable (OINDEX).
The nonlinear simulation model is defined functionally by:
.
x = f (x, u)
y = g (x, u)

which is linearized to:


.
x = Ax + Bu
y = Cx + Du

and the transfer function from control to observable becomes:

= C ( sI − A )−1 B + D
y
u
If y and u are scalars, C is a row vector, B is a column vector, D is a scalar, and I is the
identity matrix, then the expression can be factored into:
m

∏(s − zi )
y i =1
= K n
u
∏(s − pi )
i =1

ACSL Reference Manual Page 5-11


5. ACSL Runtime Commands 5.3 ANALYZE

where the pi are the eigenvalues of A (poles) and the zi are the zeros. The zeros can be
printed out separately by using the /ZEROS switch; i.e.,
ANALYZE /ZEROS

This lists the finite zeros in order except that zeros corresponding to poles are
considered cancelable (see system symbol EPDFPL) and are listed separately.
Once the transfer function is expressed as a ratio of a product of zeros over a product
of poles, the frequency response can be obtained by sweeping frequency (s = 0, jω)
over a given range. The range is set by /FREQMN and /FREQMX, which should be
defined before (i.e., first in a left-to-right scan) the plot drawing verb (e.g., /BODE).
ANALYZE /FREQMN=1 /FREQMX=1000 /BODE

Units The units interpretation of the frequencies defined is modified by the /HERTZ switch,
which may be set TRUE or FALSE to specify frequencies in Hertz or radians/second
respectively; for example,
ANALYZE /HERTZ=.T. /FREQMN=10 /FREQMX=1.0E4
ANALYZE /BODE

sweeps from 10 to 10,000 Hz, obtaining the phase and gain of the transfer function
along the way; the following command keeps the same frequency end points but
interprets them as 10 to 10,000 radians/second.
ANALYZE /HERTZ=.F. /BODE

Frequency sweep During the frequency sweep from FREQMN to FREQMX, the frequency at any point
is multiplied by a number between DWNFPL and DWXFPL. If the phase change
between the two frequencies is greater than DFXFPL, then the multiplier is changed
by multiplying the part greater than one by a half and limiting the result to be no
smaller than DWNFPL; i.e.,
DWN = MAX(DWNFPL, 0.5*(DWN - 1) + 1)

and recalculating the frequency point. If the phase change is acceptable, it is then
tested for being less than one quarter of DFXFPL. If it is, then the fractional part of the
multiplier greater than one is doubled, with a limit of DWXFPL; i.e.,
DWN = MIN(DWXFPL, 2.0*(DWN - 1) + 1)

Restriction on The value of DWXFPL must be greater than that for DWNFPL, and both must be
sweep greater than 1.0.
Accumulating At each point in the frequency sweep, frequency, gain, and phase are saved for later
data use in the plotted outputs (Bode, Nyquist, etc.). The last frequency point is limited to
FREQMX irrespective of the last multiplier in use.

5.3.5.1 ANALYZE
/BODE

Bode plots are produced by plotting phase and gain as separate curves against
frequency as the frequency is swept from the specified FREQMN to FREQMX. See
the section above for details on the frequency sweep.
Qualifiers affecting the plot are as follows: GAINMN and GAINMX force the scale
for the gain axis, and the numeric interpretation is governed by the GAINDB logical
value: if TRUE, the gain is in dB; if FALSE, it is a numeric ratio. PHASMN and
PHASMX force the scales on the phase axis, and the numeric interpretation is

Page 5-12 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

governed by the DEGREE logical value: if TRUE, the plot is in degrees; if FALSE, in
radians. FLOGSC sets a logical flag to control whether the gain axis is logarithmic
(TRUE) or linear (FALSE). If GAINDB is TRUE, GLOGSC has no effect and the
scale is automatically linear. The defaults are gain in dB (linear scales), frequency in
Hz (logarithmic scales), and phase in degrees.
Since two curves are drawn in Bode plots, you have the option of drawing them either
both together in the same plot area or separately. This option is controlled by the
setting of the system variable DTCFPL (draw two curves). If TRUE, the Y axis length
is halved and rounded down to a whole number, and two curves are drawn in strip plot
format. For the default Y axis length YINFPL of 5.0 inches, this results in two 2x5
plots, with gain plotted above phase.
If the two curves are drawn on the same plot, line type (style, width, and color) is
controlled by FLTFPL (first line type) and SLTFPL (second line type).

5.3.5.2 ANALYZE
/INVNYQ

Inverse Nyquist plots are obtained in a manner similar to normal Nyquist plots
(described under /NYQUIST), with the exception that the points plotted correspond to
the reciprocal of the complex gain; i.e.,

Nyquist G cosθ against G sinθ


Inverse Nyquist cosθ ⁄ G against sin(−θ) ⁄ G

for different values of the frequency. Plot scale bounds and frequency tick marks are
controlled in the same manner as for Nyquist plots.

5.3.5.3 ANALYZE
/NICHOLS

Nichols plots are gain plotted against phase. Conventional Nichols diagrams usually
have fixed scales, but in ACSL these plots are sized as usual to the data range or
forced via GAINMN, GAINMX, PHASMN, and PHASMX. Frequency is indicated
by tick marks on the side of the curve at every decade (large tick and printed power of
ten) and smaller ticks at integer values in between; i.e., 1, 2, 3, ... 9.

5.3.5.4 ANALYZE
/NYQUIST

Nyquist plots are phase and gain plotted as points on the complex plane as the
frequency is swept from FREQMN to FREQMX. Scales for the real and imaginary
axes are chosen automatically unless specified directly by REALMN, REALMX,
IMAGMN, and IMAGMX. Frequency is indicated by tick marks on the side of the
curve at every decade (large tick and printed power of ten) and smaller ticks at integer
values in between; i.e., 1, 2, 3, ... 9.
Placing the exponent symbols and handling the spacing of the tick marks can become
problematical. The exponent symbols can be removed altogether with the system
symbol NESFPL (no exponent symbol) set TRUE. An alternative is to control the
window within which exponents are written by EMNFPL (exponent minimum) and
EMXFPL (exponent maximum). Once one decade tick is established, then the others
are reasonably easy to count. If the ticks crowd too close together, then the tick marks

ACSL Reference Manual Page 5-13


5. ACSL Runtime Commands 5.3 ANALYZE

are suppressed and you will have to magnify the region with REALMN, REALMX,
IMAGMN, and IMAGMX for the ticks to appear again.

5.3.5.5 ANALYZE
Frequency analysis
qualifiers

This section describes (in alphabetical order) the ANALYZE qualifiers that set
numeric values for later use by the verb switches. The input may be a number or a
variable of the type indicated; i.e., floating point, INTEGER, or LOGICAL.
Some default values are listed as RMX. RMX is a large machine-dependent number
(1.0E+38 on 32-bit computer systems, for example) used as a flag to trigger
autoscaling. It is generally preferable to use zero for a flag, but unfortunately, for
items such as axis maxima and minima and phase and gain, zero is a perfectly legal
value and thus cannot be used as a flag.
/CINDEX Specifies the control variable for the single input/single output transfer function from
the list of control variables (specified in the /CONTROL switch). The default of 1
selects the first variable on the list.
/DEGREE Specifies the units for phase values: TRUE for degrees; FALSE, radians.
/DELAY Specifies the value of loop delay to be added into the transfer function expression. An
approximation for a discrete controller delay is half the sample time plus the full value
of the compute time delay or time between ADC input to the next DAC output.
/FLOGSC Specifies whether the frequency axis of a frequency plot is scaled logarithmically
(TRUE) or linearly (FALSE).
/FREQMN Specify the minimum and maximum values through which the frequency is swept.
/FREQMX FREQMN can't be zero because (1) it is used as a multiplier for the next frequency
and (2) we must be able to take the logarithm of the number. The units of the numbers
(Hertz or radians/second) are determined by the current setting of HERTZ when the
action using the frequency takes place.
/GAINDB Specifies whether the gain axis scale is in dB (TRUE) or a ratio (FALSE). If FALSE,
it is recommended to use GLOGSC (logarithmic scales) for the gain axis. GAINDB
controls the interpretation of the units of the GAINMN and GAINMX axis settings.
/GAINMN Specify the minimum and maximum values on the gain axis, forcing the plot scales.
/GAINMX The default is a machine-dependent large number that implies scales calculated by
normal rounding of the calculated minimum and maximum gain during the frequency
sweep. The units depend on the setting of GAINDB at the time the plot command is
entered.
/GLOGSC Specifies whether the gain axis of a Bode or Nichols plot is scaled logarithmically
(TRUE) or linearly (FALSE). If GAINDB is TRUE, GLOGSC has no effect and the
scale is automatically linear (in deciBels).
/HERTZ Specifies the units of the frequency range and the display of the frequency axis
variable on Bode plots and the frequency ticks on Nichols, Nyquist, and inverse
Nyquist plots. The units are Hz (TRUE) or rad/sec (FALSE).
/IMAGMN With REALMN and REALMX specify the view window onto the complex plane. The
/IMAGMX units are reciprocal time units. The default value is a machine-dependent large number
that implies scales calculated by normal rounding to define an area which contains all
the poles (root locus) or real/imaginary range (Nyquist and inverse Nyquist).

Page 5-14 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

/OINDEX Specifies the observable variable for the single input/single output transfer function
from the list of observables (specified with the /OBSERVE switch). The default of 1
selects the first variable on the list.
/PHASMN Specify the minimum and maximum values on the phase axis, forcing the plot scales.
/PHASMX The default value is a machine-dependent large number that implies scales calculated
by normal rounding of the calculated minimum and maximum phase during the
frequency sweep. Units (degrees or radians) depend on the setting of /DEGREE at the
time the plot command is entered.
/REALMN Together with IMAGMN and IMAGMX specify the view window onto the complex
/REALMX plane. The units are reciprocal time units. The default is a machine-dependent large
number that implies scales calculated by normal rounding to define an area that
contains all the poles (root locus) or real/imaginary range (Nyquist, inverse Nyquist).

5.3.6 ANALYZE
/ROOTLOCUS

The root locus plot follows the roots of the linear system as they vary with changing
gain fed back from the observable output to the control input. If G(s) corresponds to
the transfer function from input to output and is expressed as a product of zeros over a
product of poles, then the closed loop system has a transfer function of:

G(s)
1 + KG(s)

The root locus follows the roots of this or the zeros of 1+KG(s) as K is varied. The
region of the complex plane is determined by REALMN, REALMX, IMAGMN, and
IMAGMX. Locus tracks start at any poles within the region or at the edges of the
region for incoming tracks (going towards a zero).
Controls System symbols control details of the root locus tracker. At each step along a locus, an
iteration is performed to minimize the phase angle to below EPFFPL (epsilon phase).
Once this iteration has converged, a check is made by going sideways to left and right
by a distance tolerance measure EPDFPL (epsilon distance) to make sure the phase
crosses zero in between. If not, the iteration continues, so at step exit, the reported
point is within the distance tolerance of the exact locus.
The default settings for SSXFPL, SSNFPL, and EPDFPL are all zero to indicate that
the system should take a reasonable default. For the step size maximum (SSXFPL),
this is taken to be 5% of the diagonal distance across the plot; for the step size
minimum (SSNFPL), it is 0.4% of the maximum step size (1/250); and the distance
tolerance (EPDFPL) is a tenth of the minimum step size.
In order to find incoming loci, each edge is searched by dividing it up into NEDFPL
(number of edge division) parts, where a phase zero crossing is tested. If the phase
crosses zero between two points, the point is refined by iteration.
During plotting of the curve, tick height is controlled by TKHFPL, exponent minimum
by EMNFPL, and exponent maximum by EMXFPL.
With /LIST If the LIST flag is TRUE (specifying output of internal details), the complex point,
gain, and step size are listed at each step. This data is considered high volume, so it
appears only on the PRN until unless HVDPRN or ANALYZE/DISLPLAY are set
TRUE to direct high volume data to the screen as well.

ACSL Reference Manual Page 5-15


5. ACSL Runtime Commands 5.3 ANALYZE

If the list is requested, HVDPRN or ANALYZE/DISPLAY is TRUE, and the plot is


drawn on the screen, the printed output overwrites the plot. If switching HVDPRN,
DISPLAY, and/or the list off doesn't solve the problem, probably error messages are
being written to the screen. Direct the plot to a hardcopy device or file until the errors
have been diagnosed and fixed.

5.3.7 ANALYZE
/ZEROS

/ZEROS calculates the poles (eigenvalues) and finite zeros and attempts to cancel
using as a cancellation radius the current value in system symbol EPDFPL. This action
is invoked by:
ANALYZE /ZEROS

The transfer function gain K is listed as a fraction and an exponent since the products
of the poles and zeros can exceed the floating point range. After the gain, the transfer
function zeros are listed, followed by the cancelled zeros/poles in pairs.

5.3.8 ANALYZE
/LIST
/DISPLAY
/STATUS

/LIST /LIST turns on a flag so that internal details of various operations are written out. This
affects output from the following commands:
/TRIM /ROOTLOCUS
/BODE /NICHOLS /NYQUIST /INVNYQ

When used with /TRIM, details of the iteration (i.e., successive values of the state
vector, the derivative vector, and the residual) are written out.
ANALYZE /LIST=.T. /TRIM

With the frequency response verbs, the gain and phase at each frequency point
calculated are written out.
With /ROOTLOCUS, the complex plane location, gain, and step size are listed. If the
list is requested, HVDPRN or ANALYZE/DISPLAY is TRUE, and the root locus plot
is drawn on the screen, the printed output overwrites the plot. If switching HVDPRN,
DISPLAY, and/or the list off doesn't solve the problem, probably error messages are
being written to the screen. Direct the plot to a hardcopy device or file until the errors
have been diagnosed and fixed.
Setting the /LIST parameter back to its default value of FALSE suppresses all this
output. The /LIST flag remains as set until you change it explicitly.
/DISPLAY In general, ANALYZE operations are considered high volume operations and are thus
written only on the PRN unit (as are PRINT and debug dumps). If /DISPLAY is set
TRUE, output is repeated on the DIS unit (if different from PRN) for monitoring at the
terminal. The /DISPLAY flag remains as set until you change it explicitly.
/STATUS To review the current status of all the internal ANALYZE qualifiers, use the command:
ANALYZE /STATUS

Page 5-16 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

Control index (CINDEX ) 1


Degrees instead of rads (DEGREE ) .TRUE.
Value of pure delay (DELAY ) 0.
Display results flag (DISPLAY) .FALSE.
Freq logarithmic scale (FLOGSC ) .TRUE.
Fractn change multiplier (FRACDL ) 1.00000000
Min fractional multiplier (FRACPM ) 1.00000000
Minimum frequency (FREQMN ) 1.00000000
Maximum frequency (FREQMX ) 1000.00000
Use gain in db (GAINDB ) .TRUE.
Minimum gain (GAINMN ) 1.0000E+38
Maximum gain (GAINMX ) 1.0000E+38
Gain logarithmic scale (GLOGSC ) .TRUE.
Hertz instead of rad/sec (HERTZ ) .TRUE.
Min imag on complex plane (IMAGMN ) 1.0000E+38
Max imag on complex plane (IMAGMX ) 1.0000E+38
List internal working (LIST ) .FALSE.
Rel increment of control (MINC ) 1.0000E-04
Max value of mu (MUMAX ) 1000
Max number of interations (NITRMX ) 50
Observer index (OINDEX ) 1
Minimum phase (PHASMN ) 1.0000E+38
Maximum phase (PHASMX ) 1.0000E+38
Min real on complex plane (REALMN ) 1.0000E+38
Max real on complex plane (REALMX ) 1.0000E+38
Rms error max (RMSEMX ) 1.0000E-04
Eigen vector flag (VECTORS) .FALSE.
Abs increment of control (XINC ) 1.0000E-04

Figure 5-2. ANALYZE /STATUS output

which lists the names alphabetically with their respective values and definitions as
shown in Figure 5-2. To review the current status of the system symbols relating to
frequency analysis, find all the variables with six characters ending in FPL by using
wild cards with the DISPLAY command; i.e.,
DISPLAY ???fpl

For a listing of the state matrices, see ANALYZE /JACOBIAN.

5.3.9 ANALYZE examples

Following are some examples of the ANALYZE command. In general, qualification


statements appear before action statements. The sequence of operations is from left to
right. You can use as many continuation lines as necessary.
ANALYZE /LIST=.T. /FREEZE=x /TRIM /EIGEN /JACOBIAN

This command turns on the request for a detailed listing, eliminates (with /FREEZE)
the state X and its corresponding derivative from the Jacobian, finds the steady state,
and then evaluates the eigenvalues and Jacobian at the steady state point in state space.
START
ANALYZE /JACOBIAN /VECTORS=.T. /EIGEN

This command determines the Jacobian about the point in state space where the
simulation terminated, specifies that eigenvectors are required, and then calculates
both eigenvalues and eigenvectors. Note that if /TRIM had been used, the ending
states would have been overwritten with the initial conditions.

ACSL Reference Manual Page 5-17


5. ACSL Runtime Commands 5.3 ANALYZE

Figure 5-3. System for Frequency Response Analysis

ANALYZE /TRIM
REINIT

This command uses the current initial conditions to establish a steady state, and then
the REINIT command writes the current state vector back over the initial condition
vector. Every subsequent START now starts from a trim, or steady state, condition.
Model definition The use of ANALYZE presupposes that the model is defined by a sequence of
nonlinear equations of the form:
.
X = F ( X1, ..., Xj, ..., Xn, t )
Restrictions The use of self-contained states within the model (those not defined by INTEG and
INTVC) usually prevents the correct evaluation of the Jacobian. Likewise, memory
operators such as BCKLSH should not be present.
State description Following is an example of extracting the full state space description:
ANALYZE /XINC=1.0E-6 /CONTROL=u1,u2 /INC=0.01
ANALYZE /OBSERVE=y1,y2,y3
ANALYZE /JACOBIAN

Here the default value for the absolute perturbation for the control variables is
specified as 1.0E-6, the control variables are listed, and then an overriding control
variable perturbation of 0.01 is applied only to U2. The observable list is defined, and
then the Jacobian, which prints out the four [A, B, C, D] matrices, is requested.
Lists Note that the ANALYZE lists are cumulative; i.e, the lists of the control variables and
observables, for instance, remain in effect from one call to another until explicitly
CLEARed.
Initial conditions Another point to keep in mind is that all initial conditions must be defined before
/TRIM is invoked. Executing any ANALYZE command prior to START triggers
copying of the initial condition vector to the state vector. However, if some initial
conditions are calculated in the INITIAL section, set a run time of zero and execute
(START) the simulation prior to using ANALYZE. For example:
SET tstop=0.0
START
ANALYZE /LIST=.T. /TRIM
REINIT
SET tstop=99.9
START

Page 5-18 ACSL Reference Manual


5.3 ANALYZE 5. ACSL Runtime Commands

Figure 5-4. Examples of frequency response plots


(a) Bode, (b) root locus, (c) Bode in strip plot form

Use REINIT after the /TRIM to move the trimmed state variables back into the initial
condition values so that the steady state point in state space becomes the starting point
for any subsequent run (START).
Third order Figure 5-3 is a block diagram of a third order plant with compensator to be analyzed
example for frequency response. This example also appears in Appendix A as Linear Analysis
Example (model TRUXAL). As the diagram shows, the feedback path is completed
through a gain K. Constant terms EZ and UZ are added in the forward path. These
terms are initialized to zero but used as control inputs in addition to the reference R so
that the open loop response can be determined for either the complete system, the
plant alone, or the compensator alone by selecting the appropriate input/output pair.
The following commands generate an open loop Bode plot as shown in Figure 5-4.
SET k=0, TITLE(41)='Open Loop Response', SLTFPL=100
ANALYZE /CONTROL=r,ez,uz /OBSERVE=y,u
ANALYZE /CINDEX=2
ANALYZE /HERTZ=.F. /FREQMN=0.1 /FREQMX=1000
ANALYZE /BODE

Open loop The open loop response is obtained by setting the loop gain K to zero, establishing the
list of control and observable variables, setting the control index to EZ (the second
item on the list of control variables), specifying the frequency range and units, and
then requesting the Bode plot. Setting SLTFPL to 100 results in the gain curve being a
dotted line.
To get the plant response, Y/UZ, set the control index to 3; for the compensator, U/EZ,
set the control index to 2 and the observable index to 2.
To get a root locus plot of the open loop system, follow the commands above with:
ANALYZE /IMAGMN=-10 /IMAGMX=10 /REALMN=-10 /LIST=.T.
ANALYZE /ROOTLOCUS

The first command sets the area of interest on the complex plane; the second command
plots the loci. If the boundaries of the plot are not specified, the area is sized from the

ACSL Reference Manual Page 5-19


5. ACSL Runtime Commands 5.4 Comment (!)

poles (-20 to zero on the real axis) and -1 to +1 on the imaginary axis, resulting in a
somewhat distorted view. Position, gain, and step length are printed out during the
locus tracking since /LIST is TRUE.
Closed loop For a closed loop Bode plot, the gain K is specified. Separate plots are chosen with
the system symbol DTCFPL (draw two curves), and the Y axis length and a plot scale
factor are also modified. The control index is changed to R (first on the list of control
variables) and the Bode plot requested.
SET TITLE(41)='Closed Loop Response'
SET k=1438, DTCFPL=.T., YINFPL=6, PSFFPL=0.9
ANALYZE /CINDEX=1 /BODE

5.4 Comment (!)

FORM: ! <string>

Comments may be included in the runtime statements. Any characters after an


exclamation point (!) to the end of the line are considered comment and are not
executed. For example:
! Select stiff integration algorithm
SET IALG=2
START ! Execute the model

Comments are retained inside PROCEDURE text but are ignored on execution when a
PROCEDURE is invoked. However, they are shown when a PROCEDURE is
displayed or when system symbol HVDPRN is TRUE (the default at Version 11).

5.5 Continuation (&)

The continuation character is the ampersand (&). The runtime executive appends the
subsequent line to the end of the continued line without any trailing blanks, but
leading blanks on the continuation line are not suppressed.
PLOT /XAXIS=w /XLOG /XLO=wmn /XTAG='(Hz)' &
pgd /TAG='Phase (deg)', gdb /TAG='Gain (dB)'

Any number of continuation lines may be used at runtime. Splitting a symbol between
lines is allowed, but be careful not to accidentally insert any blanks into the resulting
string. Delimiters between symbols (usually commas) must not be overlooked
between lines; they can be placed at the end of the line before the ampersand or at the
beginning of the following line. The latter is preferred mainly because the commas
stand out more so you are less likely to make errors.
Comments can be added to a continued line since the runtime executive strips
comments off before looking back from the end of the line for an ampersand.
PLOT /XAXIS=w /XLOG /XLO=wmn /XTAG='(Hz)' & ! Log scale
pgd /TAG='Phase (deg)', gdb /TAG='Gain (dB)'

Page 5-20 ACSL Reference Manual


5.6 CONTINUE 5. ACSL Runtime Commands

5.6 CONTINUE

FORM: CONTINUE

SWITCHES: /CHARACTER = '<character>' ['<blank>']


or <integer-variable>
/HI = <real-variable> [1.0]
/LO = <real-variable> [0.0]
/PLOT
/RESCALE
/TYPE = ijk [000]

A run may be continued where it was stopped by changing the stopping condition and
using the CONTINUE command. The switches control plotting of output variables
during the simulation run and are described under START.
Initial conditions The CONTINUE operation bypasses the INITIAL section and does not put the initial
conditions into the state vector; therefore, the program continues to integrate from the
current point in state space.
CONTINUE makes sense only after a START or ANALYZE/TRIM command has
established the states. Also, the termination condition of the previous run must have
been changed; otherwise, the CONTINUE run will terminate immediately.
For example, using the following definitions in the model:
CONSTANT tf=10.0
TERMT(T .GE. tf, 'Run terminated on time TF'))

and runtime commands:


SET NRWITG=.F. ! Erase results of any previous runs
START ! Run to 10.0 sec
SET NRWITG=.T. ! Add results to previous run record
SET tf=15.0 ! Extend stopping condition to 15.0 sec
CONTINUE ! Run 10.0 to 15.0 sec

results in the model running to 10.0 seconds, stopping (at which time any variables
can be examined), then continuing to 15 seconds. Note that by default START and
CONTINUE overwrite the data logging scratch file (i.e., NRWITG = .FALSE.). If the
data is to be accumulated, the no rewind option should be set TRUE as in the example.
/RESCALE One difference in plotting with CONTINUE compared with START is that if
/RESCALE is used with CONTINUE, the scales for the X axis must be overridden.
/RESCALE takes its data from the previous run, which stopped at the point where the
new run continues on, so /LO and /HI should be used to specify the new scales:
CONTINUE /PLOT /RESCALE t /LO=10 /HI=15

After RESTORE CONTINUE may be used after RESTORE, but with care. If the model contains
DISCRETE sections or SCHEDULE statements, for example, the event list should be
saved (see SAVE/EVENT).

ACSL Reference Manual Page 5-21


5. ACSL Runtime Commands 5.7 DATA

5.7 DATA

FORM: DATA name (arg1, arg2[, arg3...])


d11 d12 [d13 ...]
d21 d22 [d23 ...]
d31 d32 [d33 ...]
d41 d42 [d43 ...]
...
END

Measured data can be defined at runtime, either interactively or in a command file, and
plotted alongside the simulation-generated variables. The measured data is plotted
with symbols at the data points and no curve drawn between the points.
Definition The definition begins with the keyword DATA, followed by the name of the DATA
block and a comma-delimited list of arguments in parentheses. The data follows,
delimited by a space or a comma. The number of data items must be an integer
multiple of the number of arguments. An END statement concludes the definition.
Not in The definition cannot be in a PROCEDURE, but any number of DATA blocks can be
PROCEDURE defined, at any time. The appropriate one can be accessed from a PROCEDURE.
The DATA statement (with word DATA, the name of the block, and the list of
arguments) is intended to be one line; if it is written on more than one line (to line up
columns with the data which follows, for example), it must be explicitly continued by
the ampersand (&). No continuation characters are needed for the lines of data, which
may contain any number of data items. Lining up the data in columns improves
readability but is not required.
The independent variable (usually time) must be included in the definition; it is
generally the first argument. A minimum of two arguments is required.
Missing or Data may be marked as missing by entering a question mark (?) in place of the data
questionable point. A question mark can also be placed directly after a data point (with no space
data points between the data and the question mark) to imply questionable data. Indicating
missing data is necessary for completing the data table even though no data can be
plotted. For questionable data, however, the point is plotted with the same symbol as
the other data points but with an I-beam twice the size of the symbol added. This
I-beam does not scale the error, it just marks a point of questionable data.
PLOT /DATA The PLOT command has a switch /DATA for specifying that measured data be
plotted. The measured data in the DATA definition is plotted with a symbol at each
data point. The default symbol begins with the letter A and increments through the
alphabet for each variable on a given plot. Symbols can be specified using the PLOT
/CHARACTER switch.
The simulation results are plotted with a line connecting the values, so the measured
data points can be compared with it. To see only the data from the DATA block, set
LINCPL (line between data points) to FALSE so that no line is drawn between the
simulation data points, then the calculated values do not appear. It may be necessary to
force the scales in this case since the axes are scaled to the hidden simulation values.
Example Following is an example of data entered for the VANDPL example (distributed with
each ACSL system). The DATA statement is defined:

Page 5-22 ACSL Reference Manual


5.7 DATA 5. ACSL Runtime Commands

Figure 5-5. Measured data (a) with simulation results and (b) alone

DATA test1 &


(t, x, xd)
0.4 0.5 -0.3
1.2 0.0 -0.5
2.0 -0.2? -1.0
2.8 ? 0.0?
3.4 -1.4 0.5
4.2 -0.4 0.9
5.0 0.6 1.7
5.4 1.3 1.3?
5.8 1.7 0.0
6.6 1.3 -0.6
7.0 1.0 ?
7.8 0.0? -2.2
8.2 -1.0 -1.8
9.2 -2.2? 0.0
9.8 -1.5 0.8
END

Figure 5-5(a) shows the data plotted with simulation results from the command:
PLOT /DATA=test1 /CHARACTER=2 xd,x

Figure 5-5(b) shows the measured data for XD by itself from the commands:
SET LINCPL=.F.
PLOT /DATA=test1 /CHARACTER=2 xd

ACSL Reference Manual Page 5-23


5. ACSL Runtime Commands 5.8 DISPLAY

5.8 DISPLAY

FORM: DISPLAY name, ..., name

SWITCHES: /ALL
/CONSTANTS
/PROCEDURE [= <procedure-name>]
/VARIABLES
/VERSION

DISPLAY displays the current values of the items listed. This command is usually
used at the end of a run to determine final values, or before a run to confirm input
constants before starting the run (when running interactively). To display values at a
specified time during a run, use the window feature of either RANGE or PRINT.
Wild cards Wild cards may be used with this command. An asterisk (*) stands for zero or more
characters, and a question mark (?) stands for any one character.
Wild cards find not only user variable names, but also extend through the ACSL
system dictionary; for example, the system symbols relating to frequency plots
(six-character symbols ending in FPL) can be listed by:
DISPLAY ???fpl

All symbols of zero or more characters in both program and system dictionary are
listed by:
DISPLAY *

This is useful for finding hidden symbols in the system dictionary (i.e., those covered
by duplicates in the model).
/ALL /ALL displays all user variables and constants (but not ACSL system symbols) in
dictionary order (i.e., system symbols, states with their derivatives and initial
conditions, then algebraic variables) when the /ALL switch is invoked. See Figure 5-6.
DISPLAY /ALL

Arrays are listed completely with the /ALL option only if their dimensions do not
exceed MALPRN, the system symbol specifying maximum array length for printing.
If MALPRN (default 10) is exceeded, the array dimension and the value of the last
element are listed.
/CONSTANTS /CONSTANTS displays the values of all symbols defined in CONSTANT statements.
/VARIABLES /VARIABLES displays the values of all variables which are not CONSTANTs or
dummy variables of the form Z0nnnn.
Both /CONSTANTS and /VARIABLES listings are in alphabetical order rather than
dictionary order as in the /ALL listing. See Figure 5-6.
Arrays Arrays, if not explicitly referred to by element, are listed in total (except with the
/ALL option, as noted above). For example, if RM and A are both arrays, the
commands
START
DISPLAY t,x,y1,rm(3),a

produce a list including only the third element of array RM but all elements in the
array A. Displaying T (time) is often useful in determining if the run has been
completed as anticipated.

Page 5-24 ACSL Reference Manual


5.8 DISPLAY 5. ACSL Runtime Commands

DISPLAY/CONSTANTS
CINT 0.02500000 G 32.2000000 IALG 4
KDAMP 0.00500000 LENGTH 2.00000000 MAXT 0.01250000
MINT 1.0000E-09 NSTP 1 THDIC 0.
THIC 1.00000000 TSTP 4.90000000 WEIGHT 5.00000000
ZZSEED 55555555

DISPLAY/VARIABLES
T 4.91250000 TH 0.88881500 THD 0.87794500
THDD-12.4949000

DISPLAY/ALL
T 4.91250000 ZZTICG 0. CINT 0.02500000
ZZIERR F ZZNBLK 1 ZZICON 0
ZZSTFL T ZZFRFL F ZZICFL F
ZZRNFL F ZZJEFL F ZZNIST 2
ZZNAST 0 IALG 4 NSTP 1
MAXT 0.01250000 MINT 1.0000E-09

State Variables Derivatives Initial Conditions


TH 0.88881500 Z09997 0.93044900 THIC 1.00000000
THD 0.87794500 Z09998-12.4949000 THDIC 0.

Algebraic Variables

Common Block /ZZCOMU/


G 32.2000000 KDAMP 0.00500000 LENGTH 2.00000000
THDD-12.4949000 TSTP 4.90000000 WEIGHT 5.00000000
ZZSEED 55555555

Figure 5-6. DISPLAY /CONSTANTS /VARIABLES /ALL

/PROCEDURE After defining a number of PROCEDUREs, it is sometimes difficult to recall what


procedure commands are available, or, even if the names are known, what they do.
The names of all procedures are listed in response to the command:
DISPLAY /PROCEDURE

If the name of one of the defined PROCEDUREs is specified, then the PROCEDURE
arguments are listed, followed by default strings if given, and then the text listing. For
example:
PROCEDURE pp(xl=0.0, xh=5.0, tag='LongTag', a, b)
PLOT /XLO=&xl /XHI=&xh &a /TAG=&tag
PLOT &b /TAG=&tag
END
...

DISPLAY /PROCEDURE=pp
PP

ARGUMENTS (DEFAULT VALUES)

1 XL (0.0)
2 XH (5.0)
3 TAG (LongTag)
4 A
5 B

ACSL Reference Manual Page 5-25


5. ACSL Runtime Commands 5.9 END

PROCEDURE TEXT

PLOT /XLO=&001 /XHI=&002 &004 /TAG=&003


PLOT &005 /TAG=&003

All arguments in the argument list are transformed to upper case, but any text in the
listing of default values and the text in the PROCEDURE TEXT listing retain their
original case.
Argument substitution is indicated in the listing of the PROCEDURE TEXT by an
ampersand followed by a three-digit number (&007 for the seventh argument, for
example) rather than the text in the definition.
/VERSION The version of ACSL in use can be determined at runtime with this switch. For
example,
DISPLAY /VERSION
ACSL Version 11.2.2

5.9 END

FORM: END

The END command at runtime defines the end of a PROCEDURE or DATA


definition. To terminate an ACSL runtime session, use the QUIT command.

5.10 EXIT

FORM: EXIT

EXIT is a synonym for QUIT; it terminates the ACSL runtime session.

5.11 FILE

FORM: FILE

SWITCHES: /CMDFILE = 'filename' [keyboard]


/DISFILE = 'filename' [screen]
/PLTFILE = 'filename' [screen]
/PRNFILE = 'filename' ['model.LOG']
/RRRFILE = 'filename' ['model.RRR']

FILE specifies a file name for any of the runtime logical units, which are:
Name Default Description
CMD 5 command file (model.CMD), keyboard
DIS 6 display file (primary output)
PLT 6 plot file
PRN 9 print (or log) file
RRR 8 data logging file (raw run record)

Page 5-26 ACSL Reference Manual


5.11 FILE 5. ACSL Runtime Commands

ACSL> FILE/RRRFILE='test1.bin'
ACSL> Closing logical unit 8 as file VANDPL.RRR;1
ACSL> Opening logical unit 99 as file TEST1.BIN;1
ACSL> START
ACSL> ...
ACSL> FILE/RRRFILE='test2.bin'
ACSL> Closing logical unit 99 as file TEST1.BIN;1
ACSL> Opening logical unit 98 as file TEST2.BIN;1
ACSL> START
ACSL> ...
ACSL> FILE/RRRFILE='test3.bin'
ACSL> Closing logical unit 98 as file TEST2.BIN;1
ACSL> Opening logical unit 99 as file TEST3.BIN;1
ACSL> START
ACSL> ...

Figure 5-7. FILE command switching RRR unit

The default number is the internal logical unit number. Display output and plots
appear on the screen unless directed otherwise. The command file is read in
automatically and the RRR and log files are written out automatically to the default
named files unless directed otherwise. See ACSL Sim User's Guide for more
information on these files.
On recognition of the FILE command, the system checks for the next unused Fortran
logical unit number starting at 99 (this number may be system dependent) and working
downwards. When an open unit number is found, it is assigned to the appropriate
integer variable (CMD, DIS, PLT, PRN, RRR) and the file is opened. In order to
prevent excess open files, for every file except the CMD input file, the previous
logical unit is closed. The command input file is not closed since it must normally read
to end-of-file, at which point the file is closed and the previous file is recovered from a
stack.
Multiple RRR files Figure 5-7 shows the use of multiple RRR files. The first command is:
FILE/RRRFILE='test1.bin'

This closes logical unit 8 (the default RRR logical unit number) and opens logical unit
99 as the new file. The next file assignment closes unit 99 and opens 98 (the test for
the next available open unit is done before the first file is closed). For the third FILE
command, unit 99 is free again, and so this is opened after closing unit 98.
Specify CMD file On most computer systems, ACSL reads in a command file (default name
model.CMD) if it is available. Figure 5-8 show the sequence for changing this file.
The command:
FILE/CMDFILE='doit.cmd'

opens logical unit 99 as this file, which is then read to an end-of-file when control
reverts to the previous file, which in this case is the keyboard (unit 5).
Warning – If Fortran logical unit numbers are used in a program, we recommend avoiding
logical unit numbers below 10 and from 99 downwards for probably ten to twenty possible units
numbers opened.

ACSL Reference Manual Page 5-27


5. ACSL Runtime Commands 5.12 HELP

ACSL> ...
ACSL> file/cmdfile='doit.cmd'
ACSL> Opening logical unit 99 as file DOIT.CMD;1
ACSL> start
ACSL> display x,xd
ACSL> X-1.45462417 XD 0.96626579
ACSL> End of file found on unit 99
ACSL> Reverting to logical unit number 5
ACSL> ...

Figure 5-8. FILE command switching CMD unit

5.12 HELP

FORM: HELP [command [/switch] ]

The HELP command brings up a help facility for the runtime commands. Because
implementing this facility depends on the computer operating system, it may not be
available on every system.
If no command is specified, a list of the commands appears. If a command is specified,
that command is explained and the switches for the command are listed.
HELP plot

To go directly to information about a switch, list the command and then the switch:
HELP plot /xaxis

Help for the ACSL system symbols is found under topic SYMBOLS.

5.13 MATH

ACSL provides plotting capabilities with the PLOT command and linear analysis
capabilites with the ANALYZE command, but a more powerful approach to plotting
and analysis is available in ACSL Math. For complete details on ACSL Math, see the
ACSL Math User's Guide and ACSL Math Reference Manual.
ACSL Math is a software package that provides:
. A platform for running ACSL models
. Tools for plotting
. Tools for analysis
. Scripting language
. Means of comparing model output to empirical data

First, build a model in ACSL, then run and analyze it in ACSL Math. The ACSL
runtime commands are available in ACSL Math. ACSL Math comes up in an Output
window that shows output text and a prompt for typing commands:
MATH>

Page 5-28 ACSL Reference Manual


5.13 MATH 5. ACSL Runtime Commands

Other windows appear as needed for figures.


You can toggle back and forth between the ACSL Math prompt and the ACSL prompt
with two exclamation points (!!):
MATH> !!
ACSL> !!
MATH>

You can also issue ACSL commands directly from ACSL Math by preceeding the
command with two exclamation points:
MATH> !!start

ACSL Math is case sensitive. Its syntax is similar to that used by many mathematical
packages on the market, so the functionality of these packages is availablealong with
your ACSL command files.
All the variables in an ACSL model can be read and written from ACSL Math. To see
a list of all variables in the ACSL Math workspace, type who at the command prompt.
For the ACSL Van der Pol example model (VANDPL), after it has been loaded and
run, the results are:
MATH> who
Your Variables are:

CINT IALG LA MAXT MINT NSTP T TSTP X XD XDD


XDIC XIC ZZSEED _t _x _xd _xdd

ACSL model variables are in uppercase, and the time history variables begin with an
underscore (_). The items with underscores are on the Prepare list in the VANDPL
command file. Only variables on the Prepare list are collected for time history, and
they appear in this list only after a run has been initiated with a START command.
You can examine final values from the model by typing the names of the variables at
the ACSL Math prompt:
MATH> T
T =
10

Capitalization is significant. If you were to type the names in lower case, you would
see the following error message:
MATH> t
! Error
Undefined variable or function "t"

Variables can be changed from the ACSL Math command line and the model rerun;
for example, change the damping factor LA and rerun the VANdPL model as follows:
MATH> !!set LA = 0.2; start

You can plot the the time history variables in ACSL Math. Following are the basic
commands to plot X against time, label the axes, and add a title.
MATH> plot(_t,_x)
MATH> xlabel('T (time)')
MATH> ylabel('X (position)')
MATH> title('Van der Pol Oscillator')

See the ACSL Math documents for more information on importing data, writing
scripts, and many other features of ACSL Math.

ACSL Reference Manual Page 5-29


5. ACSL Runtime Commands 5.14 MERROR, XERROR

5.14 MERROR, XERROR

FORM: MERROR name = <real-variable>


XERROR name = <real-variable>

The relative and absolute errors allowable during variable order, variable step
integrations may be individually specified by MERROR and XERROR.
Each state is associated with a corresponding entry in the relative error table
(MERROR) and absolute error table (XERROR). These two commands behave like a
SET command except that they access the error table corresponding to the state name
rather than the state name itself. For example:
MERROR sv1=1.0e-3, sv2=0.01
XERROR sa1=5*0.0001, sa2(3)=0.02

where SVi and SAi are state variables and state arrays, respectively.

Note that arrays may be filled by a repeat count (for example, 5*0.0001). This action
may overflow the array, but that should not be a problem. An individual array element
may be specified at runtime; at model definition time, the same allowable error must
be specified for all elements in an array.
During the integration step, the estimated error for each state variable is compared to
the allowable error, Ei, obtained from:

Ei = MAX ( Xi, Mi |Yi |max )

where |Yi |max is the maximum absolute value of the state achieved so far during the
run.

5.15 OUTPUT

FORM: OUTPUT name, ..., name

SWITCHES: /ALL
/CHARACTER = '<character>' ['<blank>']
or <integer-variable>
/CLEAR
/HI = <real-variable> [1.0]
/LO = <real-variable> [0.0]
/NCIOUT = <integer-variable> [1]
/TYPE = ijk [000]

The OUTPUT command designates variables to be listed or plotted during a run.


The OUTPUT command is given before a START; output of the values occurs in
response to a START or CONTINUE command
If listed, the output appears at each time step on both the low volume output file (DIS)
and high volume output file (PRN) as the run progresses. This is distinguished from
the PRINT command, which lists data in columnar form on the high volume output
file (PRN) only after the run has been completed.
Independent Note that the independent variable is not included on the OUTPUT list automatically;
variable you must list it explicitly to see it.

Page 5-30 ACSL Reference Manual


5.15 OUTPUT 5. ACSL Runtime Commands

Wild cards Wild cards can be used in the OUTPUT list specification (* for zero or more
characters and ? for any one character); for example:
OUTPUT t,v*,k??

/ALL /ALL adds to the OUTPUT list all the model variables listed out by the debug dump,
except for constants and ACSL dummy variables (those of the form Z0nnnn).
/NCIOUT The values of the list elements are normally written out at every communication
interval. If this rate is too high, it can be reduced with /NCIOUT (number of
communication intervals between output listings). For example, the following
command results in an output every five communication intervals:
OUTPUT t,a,b /NCIOUT=5

Only one value for /NCIOUT can be in effect at one time; the last value set stays in
effect until changed in a subsequent OUTPUT command. It is not possible to
designate different variables to be recorded at varying data rates as all elements on the
list are output together.
NCIOUT is a system variable which can be SET or DISPLAYed in addition to being
controlled with the OUTPUT switch.
SET NCIOUT=100

ACTION (another runtime command) can be used to change NCIOUT at different


values of the independent variable; thus, although all the list elements will be recorded
at the same rate, that rate can be changed over the course of a run.
ACTION /VARIABLE=2.0 /VALUE=10 /LOCATION=nciout
/VARIABLE=4.9 /VALUE=1 /LOCATION=nciout

Forcing LOGD can be called from within the model source code to increase the number of
additional data times data is logged and thus the amount of output. Data is logged automatically at
logging each communication interval, at the end of the DYNAMIC section code. It is often
helpful to see output when a DISCRETE section is executed, for example. Insert a call
to LOGD at the end of a DISCRETE section and then include variables calculated or
changed in that section on the OUTPUT list to see their progress at critical times. See
Appendix B for more details on LOGD.
DISCRETE sw
switch = .TRUE.
...
CALL LOGD(.TRUE.)
END

Arrays Array elements can be listed by referring to the specific element; for example, A(3). If
the name listed is an array, but no specific element is called for, all elements are output.
/CLEAR The OUTPUT commands are cumulative; i.e, rather than correcting previous
specifications, additional commands simply add variables to the list. This can lead to
inadvertently long and/or duplicated lists. To clear the list and start over, use the
/CLEAR switch; for example,
OUTPUT /CLEAR t,x,y,z

Width of listing OUTPUT is considered low volume and is written to both the DIS and PRN units if
they are different. The width of the line is controlled by system variable TCWPRN
(terminal character width), which controls data sent to the DIS logical unit. If
TCWPRN is 80 (the default), output is three variables across; if 132, five variables

ACSL Reference Manual Page 5-31


5. ACSL Runtime Commands 5.16 PAUSE

across. For the PRN print log file, PCWPRN controls the printer character width
(default 132).
Plotting OUTPUT START/PLOT and CONTINUE/PLOT commands result in the OUTPUT variables
data being plotted rather than listed. The first variable on the OUTPUT list is used for the
X axis (the independent variable); all the other variables appear as Y axes. Several
OUTPUT switches establish default characteristics of the plots. The same switches are
available with START and CONTINUE and override the values specified in OUTPUT.
Plot scales /HI and /LO specify the scales of the Y axes. If given with OUTPUT itself, they apply
to all variables not otherwise given specific scales. For a particular variable, the switch
applies to the variable immediately to its left.
OUTPUT /LO=-10 /HI=10 t /LO=0, a,b,c

The scales for T are zero to +10 and for A, B, and C are -10 to +10. The independent
variable is scaled in the same way as the dependent variables, the only difference
being that it is the first item in the list.
/CHARACTER /CHARACTER specifies a character symbol to appear on the curve if SYMCPL is
TRUE. The use of characters is the same as for the PLOT command except that the
default character is blank rather than "A".
/TYPE /TYPE specifies the style (i), width (j), and color (k) of a curve as described for the
PLOT command.

5.16 PAUSE

FORM: PAUSE

The PAUSE command simply waits for a carriage return from the keyboard. Its main
use is to wait between plots in a sequence of PLOT commands, usually specified in a
PROCEDURE in interaction operation.
In a series of plots, each new PLOT command erases the screen and writes over the
previous plot. This action usually occurs too quickly to view the plot in any detail.
With the PAUSE command, each plot can be viewed as long as needed before moving
on to the next one.
A PROCEDURE using the PAUSE command could be in the form:
PROCEDURE p3
PLOT th
PAUSE
PLOT thd
PAUSE
PLOT thdd
END

Page 5-32 ACSL Reference Manual


5.17 PLOT 5. ACSL Runtime Commands

5.17 PLOT

FORM: PLOT name, ..., name

SWITCHES: /ALL
/CHARACTER = '<character>' ['A']
or = <integer-variable>
/CLOSE
/COLOR = <integer-variable> [0]
/DATA = <name-of-DATA-block>
/HI = <real-variable>
/LO = <real-variable>
/LOG
/OVER
/RUN = <integer-variable>
/SAME
/STYLE = <integer-variable> [0]
/TAG = '<string>'
/TYPE = ijk [000]
/WIDTH = <integer-variable> [0]
/XAXIS = name
/XHI = <real-variable>
/XLO = <real-variable>
/[NO]XLOG [/NOXLOG]
/XTAG = '<string>'

Line plots, strip plots, and/or printer plots can be generated for any variables on the
PREPARE list. The form of the plots is controlled by system symbols CALPLT (for
line plots), STRPLT (for strip plots), and PRNPLT (for printer plots); the default form
is line (continuous) plots. Frequency analysis plots are described under ANALYZE.
Wild cards Wild cards (* and ?) can be used with the PLOT command. To limit the number of
variables plotted, only ten matches are allowed before an error message is printed out.
The order of commands is generally:
PREPARE ... ! Establishes list of variables to be saved
START ! Runs model, logs values of PREPARE variables
PLOT ... ! Makes plots using data saved during run

The order of items on the PLOT command is: first, any X axis switches, then Y axis
variables separated by commas, with Y axis switches immediately to the right of the
variables to which they apply.
PREPARE list The PLOT command uses the current PREPARE list to find the data for each variable
on the intermediate data file (RRR); therefore, the PREPARE list cannot be changed
between the START command and the PLOT command that uses the data generated
by the START.
X axis variable The X axis variable can be specified with the /XAXIS switch, explained below. If no
variable is specified, the plotting routine assumes that the first variable on the
PREPARE list is the independent variable and is to be plotted on the X axis.
Plot number A vertical text string containing a plot number (from the start of the session) and the
date and time at which the session was initiated is drawn at the right of the plot image
unless suppressed by setting DPNPLT to FALSE.
Automatic scaling Automatic plot scales are chosen by rounding to multiples of 1, 2, 4, or 5. If the
difference between the maximum and minimum is less than ten percent, the scale is
expanded.

ACSL Reference Manual Page 5-33


5. ACSL Runtime Commands 5.17 PLOT

Switches The first section describes the PLOT switches relating to the X axis, the second
describes the Y axis qualifiers, and the third describes several miscellaneous switches.
Some examples of typical PLOT commands are given in the last section. Example
programs which include commands and the resulting plots are found in Appendix A.
System symbols Plot size, grid lines, and other characteristics are set with system symbols which are
accessible by SET commands at runtime. See Appendix C for an explanation of the
system symbols related to plotting and a list of device drivers.

5.17.1 PLOT X axis switches


/XAXIS
/XLO
/XHI
/[NO]XLOG
/XTAG

Order of The X axis qualifiers should always be specified first on the PLOT command line
specification because the automatic scaling for the Y axis variables is determined by picking
maxima and minima within the current X axis window for each Y axis variable as it is
reached in the left to right scan by the executive.
Resetting X axis X axis related parameters, once set, stay the same for all subsequent PLOT commands
qualifiers unless either they are respecified or the X axis variable itself is changed. Changing the
X axis variable resets all parameters to their default values, which are: no tag string,
linear scales, and automatic scaling. Thus, changes to any of the X axis qualifiers must
follow (reading left to right) the specification of the XAXIS variable. Respecifying the
same X axis variable also resets all the related parameters to their defaults.
/XLOG can be reset with /NOXLOG without affecting the other X axis qualifiers.
/XAXIS The independent variable is assumed by the plot driver to be the first item on the
PREPARE list; however, you can specify it with /XAXIS instead; e.g.:
PLOT /XAXIS=th, thd

Phase plane plots and trajectory plots are examples of plots where the X axis variable
is usually specified.
/XLO /XHI /XLO and /XHI set the limits of the X axis scales. Specifying the plot scale limits is
often used to expand an area of interest on a plot and to control scales from run to run
so that anomalies in the results are easily detected.
PLOT /XAXIS=al /XLO=-5 /XHI=5, be
PLOT /XAXIS=t /XLO=0 /XHI=2, th

/XLOG /XLOG specifies a logarithmic scale for the X axis. Zero or negative scale limits are
not permitted with logarithmic scales and produce a diagnostic message and
replacement with linear scales. The automatic scaling chooses a low value for
logarithmic scales which is the power of ten below the lowest value of the variable in
the window; e.g., if the variable to be plotted has a lowest value of 0.002, automatic
scaling chooses a low value of 0.001. /XAXIS, /XLO, and /XHI can be used with
/XLOG as with linear scales, with the exception that /XLO cannot be zero or negative.
The logarithmic scale for the X axis can be turned off with /NOXLOG or by changing
the X axis variable with /XAXIS.

Page 5-34 ACSL Reference Manual


5.17 PLOT 5. ACSL Runtime Commands

/XTAG /XTAG specifies a character string to be appended to the right of the X axis variable
name on the plot label. This string is often used to identify units or spell out the
variable name:
PLOT /XAXIS=w /XTAG='Frequency (rad/sec)' /XLOG &
/XLO=wmn /XHI=wmx gain, phase

One space is automatically placed between the variable name and the character string.
The number of characters available for the tag depends on the length of the axis. If the
variable name plus the tag contains more characters than are available on one line, the
excess characters are simply dropped.

5.17.2 PLOT Y axis switches


/CHARACTER
/COLOR
/LO
/HI
/LOG
/STYLE
/TAG
/TYPE
/WIDTH

These PLOT switches all follow the Y axis variable names as qualifiers, applying to
the variable name to the immediate left. In contrast to the X axis qualifiers, Y axis
qualifiers are not carried from plot to plot and must be specified each time they are
needed.
Y axis scales If scales are not specified for any given variable, they are chosen automatically. The
/LO /HI maximum and minimum values of the variable are determined while the X axis
variable is between its limits of /XLO and /XHI; checking first for the X axis window
ensures that the appropriate scales are chosen for a particular plot since it may be that
only a small fraction of the total simulation run is being plotted. You can specify the Y
axis plot scales with the switches /LO and /HI; for example:
PLOT y1 /LO=0 /HI=10, y2, y3 /LO=5 /HI=10

results in Y1 scaled from zero to 10 and Y3 scaled from 5 to 10, while the scales for
Y2 are chosen automatically.
Variable names can be used in the scale specifications. These variables can be set at
runtime, but must first have been defined in the model code. It is also sometimes
useful to set a group of scales to the same, originally unknown, value. If maximum
and minimum values can be collected in the model definition (preferably in the
DYNAMIC section), they can be used to set scale factors as follows:
PLOT y1 /LO=ymin /HI=ymax

/LOG /LOG sets a logarithmic scale for the Y axis. Zero or negative scale limits are not
permitted with logarithmic scales and produce a diagnostic message and replacement
with linear scales. The automatic scaling chooses a low value for logarithmic scales
which is the power of ten below the lowest value of the variable in the window; e.g., if
the variable to be plotted has a lowest value of 0.07, automatic scaling chooses a low
value of 0.01.
PLOT w2 /LOG /LO=0.001 /HI=10.0

ACSL Reference Manual Page 5-35


5. ACSL Runtime Commands 5.17 PLOT

/TAG /TAG specifies a character string or tag to be appended to the right of the variable
name on the plot label; for example:
PLOT v3 /TAG='Vehicle velocity (ft/sec)'

The number of characters available on the plot axis depends on the length of the axis.
On strip plots, if the variable name plus the tag contains more characters than are
available on one line, the variable name appears on one line and the tag character
string on a second line. If the tag character string still exceeds the length of the axis,
the excess characters are simply dropped. On regular line plots, excess characters are
simply dropped.
/TAG applies only to the variable name immediately to its left on the PLOT command.
/CHARACTER /CHARACTER specifies a character (or symbol) to be placed on the plot curve. For
printer plots (PRNPLT), the character forms the curve itself; for line (CALPLT) and
strip (STRPLT) plots, no character appears unless SYMCPL or SYMSPL is TRUE,
when the character is drawn at each NPCCPL or NPCSPL data points (default of 10).
A sample of the symbol is drawn at the right of the axis label.
Once a character has been specified, symbols for subsequent curves follow in order
from the ASCII character set through the letters, then the digits, then back through the
letters, etc. The thirteen centered symbols (shown in Appendix C) correspond to
integer values of one through thirteen (normally non-printing ASCII control
characters). To access these centered characters, use a non-quoted integer. The
following results in the picnic table character being centered on the plot curve:
PLOT x /CHARACTER=7

The centered symbols also cycle in sequence within the set of centered symbols. Any
symbol other than a letter, digit, or centered symbol (e.g., percent, colon, etc.) repeats
itself. This includes the blank, so that the following command results in a blank
symbol on all three curves:
PLOT /CHARACTER=' ' x,y,z

The character can be specified prior to naming the first ordinate, which is useful with
/ALL. The following command plots three plots per page (i.e., the default of NPPPLT)
with each curve given a character in sequence 1, 2, 3, etc.:
PLOT /CHARACTER='1' /ALL

/TYPE /TYPE specifies the style, width, and color of the curve for devices that support those
features. The three digits (ijk) are integers; i is extra width (in units of line width); j is
the style (0=solid, 1=dotted, 2=dashed); and k is the device dependent color.
PLOT y1 /TYPE=213
PLOT y2 /TYPE=400
PLOT y3 /TYPE=026

In this example, Y1 is dotted, width of two lines plus the original, and color three. Y2
is solid, four lines added to the width, and default color (usually black). Y3 is dashed,
single line width, and color six.
/COLOR /COLOR, /STYLE, and /WIDTH are alternatives to /TYPE. They can be used if only
one of the options is needed, or more than ten selections within an option. If only color
is to be specified, for example, but the color palette has sixteen or sixty-four colors:
PLOT y1/COLOR=12, y2 /COLOR=8, y3 /COLOR=15

Page 5-36 ACSL Reference Manual


5.17 PLOT 5. ACSL Runtime Commands

Setting system symbol ALCPLT (automatic line color) to TRUE results in automatic
cycling through the colors starting with color number 1. Specifying a color of zero
turns off color for the variable to its immediate left and all variables to the right.
PLOT /COLOR=0 x,y,z
PLOT x,y,z /COLOR=0
PLOT x,y /COLOR=0, z,a,b,c

In the first example, color is turned off for the whole plot; in the second, X and Y have
colors of 1 and 2 but Z has no color; and in the third, only X is colored.
Selecting a non-zero color initializes the color sequence. This can be done as a switch
to the PLOT command itself (which initializes the sequence beginning with the first
variable to be plotted) or to a variable (which initializes the sequence beginning with
the variable to its immediate left).
PLOT /COLOR=5 x,y,z
PLOT x,y /COLOR=5, z

/STYLE /WIDTH /STYLE specifies solid, dotted, or dashed lines, depending on the device capabilities.
/WIDTH adds the specified number of line widths to the original line, with half on one
side and half on the other so that the original line is always in the middle. /STYLE
may not work correctly on some systems.
PCs On the PC, the /WIDTH switch does not function for window plots. Also, the middle
digit of /type doesn't do anything. The hundreds digit (left-most) has the following
effects:
value style width
----- ----- -----
0 solid 1
1 - - 1
2 .... 1
3 -.-. 1
4 -..-.. 1
5 solid 2
6 solid 3
7 solid 4
8 solid 5

The ones digit (right-most) gives the following colors, which have been enhanced at
Version 11.5 so they will appear darker on PC screens:
value color RGB intensities
----- ----- ---------------
0 black 000 000 000
1 blue 000 000 255
2 green 000 128 000
3 red 255 000 000
4 purple 128 000 128
5 teal 000 128 128
6 peasoup 128 128 000
7 gray 128 128 128
8 purple 128 064 128
9 peasoup 128 128 064

Plot device If a device does not have the requisite capability, /TYPE, /COLOR, /STYLE, and
capabilities /WIDTH are ignored. Sometimes the selected color can be the background color and
the curve is invisible. Some installations may not have colors available but still have
the capability to implement the style and width options; some screens handle colors

ACSL Reference Manual Page 5-37


5. ACSL Runtime Commands 5.17 PLOT

but not style or width. See the machine specific instructions for details of plotter
capabilities at a given site.
Multi-run cycling When system symbol FTSPLT (flyback trace suppression) is set TRUE for multi-run
of color and plots, character and color are cycled automatically for each run if they are specified.
symbol Multi-run plots are accumulated by looping from TERMINAL to INITIAL in the
model source code, by multiple START commands with system symbol NRWITG (no
rewind) set to TRUE, or by deferring plots with system symbol DEFPLT. The
criterion for incrementing the character or color is when the first variable on the
PREPARE list becomes more negative than its previous value.
Arrays When an array is plotted, the array name by itself stands for all its elements, and any
qualifiers such as scale factors explicitly given apply to all elements of the array. To
apply individual qualifiers, each element of the array must be individually specified on
the PLOT command. For the array Z:
PLOT z ! Each scale chosen automatically
PLOT z /LO=5 /HI=10 ! All elements have same scale
PLOT z(1) /LO=5,/HI=10 & ! Each scale specified separately
,z(2) /LO=0 /HI=20 &
,z(3) /LO=0 /HI=10

5.17.3 PLOT switches


/ALL
/CLOSE
/DATA
/OVER
/RUN
/SAME

/ALL /ALL plots all the variables on the PREPARE list; this is normally used for debugging
purposes. This is not recommended for plots on a CRT plot device because the screen
is cleared after each plot. System symbol NPPPLT (default 3) specifies the number of
plots per page.
PLOT /ALL

/CLOSE The /CLOSE switch closes the plot file (logical unit PLT) so that any existing plots
can be spooled to a plot queue if available. Spooling can be done at runtime via the
SYSTEM command. The /CLOSE switch must be the only switch on the PLOT
command when it is used since plotting after closing a file will open the file again and
destroy the old contents. An error message is produced as follows:
PLOT x,y /CLOSE
The /CLOSE switch must be alone on the PLOT command

/DATA /DATA specifies the name of a defined DATA block for plotting measured data along
with the simulated values. See the section on the runtime command DATA for the
definition of the data. The measured data points are plotted using symbols (specified
with /CHARACTER) and are not connected by lines.
PLOT /DATA=test1 y1,y2,y3

Data is plotted for any of these variables for which DATA has been defined. Data
could be defined for all the variables, or for only some of them. Variables for which no
data has been defined are plotted from the simulation results as normal, without any
DATA information.

Page 5-38 ACSL Reference Manual


5.17 PLOT 5. ACSL Runtime Commands

Symbols do not appear on the simulation curves unless system symbol SYMCPL or
SYMSPL is set TRUE, so the unconnected symbols of the measured data are clearly
distinguished from the simulation results.
/DATA qualifying a specific Y axis variable selects from the specified DATA block,
which may be different from the default.
PLOT /DATA=test1 y1,y2,y3 /DATA=test2, y4

The independent variable must appear in every DATA block definition.


/RUN /RUN extracts data from a specified run if more than one run has been collected on the
RRR intermediate data file. Collecting runs is accomplished either by looping from
TERMINAL to INITIAL in the model source code or by executing separate START
commands with system symbol NRWITG (no rewind) set TRUE. If the switch
appears with PLOT, it becomes the default for all the variables:
PLOT /RUN=2 y1,y2,y3

When attached to individual variables, it applies to the variable immediately to its left:
PLOT y1/RUN=2, y2/RUN=3, y1/RUN=1

/SAME /SAME applies the scales selected for the first element on the list to the rest of the
elements; i.e., normally the scale is that of the first element on the list, but it can be
overridden by choosing scales for another element to the left of the /SAME switch.
For example:
PLOT y1 /LO=0 /HI=10, y2,y3 /SAME

results in all plots having the specified scale of zero to 10.


PLOT y1,y2,y3 /SAME

results in all plots having the same scale, a scale chosen automatically from the values
of Y1 and not taking into account the values of Y2 or Y3.
/OVER The switch /OVER is used to suppress extraneous printing of axes and is normally
used in conjunction with /SAME. The command:
PLOT y1,y2,y3 /OVER

draws and labels the vertical axes for Y1, the first element on the list, but suppresses
the separate axes and labels, even though the scales may be different, of Y2 and Y3.
To ensure the same plot scales, use /SAME:
PLOT y1,y2,y3 /OVER /SAME

The main use for /OVER is to overlay plots using the strip plot option; the default is
for each variable on the list to be drawn on a separate area of the plot.

5.17.4 PLOT examples

PLOT commands can be simple, taking advantage of defaults and automatic scaling,
especially for initial runs and debugging. More elaborate specifications can be added
as the need arises. For a first look at a model, the following commands could be given:
SET TITLE='Rigid Pendulum Model'
PREPARE t,th,thd,thdd
START
PLOT th,thd

ACSL Reference Manual Page 5-39


5. ACSL Runtime Commands 5.17 PLOT

Figure 5-9. PLOT examples with (a) defaults, (b) symbols and tags, (c) strip plots

Figure 5-7(a) shows the resulting plot, with the first item on the PREPARE list
assumed to be the independent variable and both curves on the same plot. The scales
are chosen automatically.
In order to differentiate the curves, the system symbol SYMCPL (symbols on line
plots) and LTFCPL (line type fragment) are turned on and /CHARACTER is added as
shown in (b). A sample of the curve, including the symbol, appears at the right of the
corresponding Y axis label. The specification for the character is unquoted, so the
symbol is taken from the special centered character set shown in Appendix C.
Additional information is added to both the X and Y axis text with /XTAG and /TAG.
X axis qualifiers always appear before the Y axis variables.
SET SYMCPL=.T., LTFCPL=.T.
PLOT /XTAG='(sec)' th /CHARACTER=1 /TAG='(rad)' &
, thd /TAG='(rad/sec)'

If not specified, the characters are letters starting with 'A'. The variables could also be
plotted separately:
PLOT th ; PLOT thd

To stack the plots as in (c), turn off the line plot option (CALPLT) and turn on the
strip plot option (STRPLT). The X axis tag remains in effect, but the Y axis tags must
be respecified each time they are needed since they apply only to the variable to their
left and only for the immediate plot. Note that tags and titles retain their case although
variable names are drawn in all upper case.
SET CALPLT=.F.,STRPLT=.T.
PLOT th /TAG='(rad)', thd /TAG='(rad/sec)'

No symbols appear on the curves in the strip plot because SYMSPL is not TRUE.
The X axis variable can be changed, which is useful for phase plane plots. The length
of the X and Y axes are controlled with XINCPL and YINCPL. The line type
fragment is set back to FALSE since there is only one curve. The following commands
produce Figure 5-10(a).
SET STRPLT=.F., CALPLT=.T., XINCPL=4, YINCPL=4, LTFCPL=.F.
PLOT /XAXIS=th /XTAG='(rad)' thd /TAG='(rad/sec)'

Page 5-40 ACSL Reference Manual


5.17 PLOT 5. ACSL Runtime Commands

Figure 5-10. PLOT examples with (a) phase plane plot, (b) scales, (c) respecifying X axis

Now the plot is square, but the scales are not. Although the X axis is automatically
scaled from -1 to +1, the Y axis is -5 to +5, so in (b) the limits of the Y axis scale are
set to ±4. A centered symbol is chosen, and its frequency is controlled with NPCCPL
(number of points per character). The communication interval CINT for this program
is 0.025 sec, so NPCCPL of 40 results in symbols appearing at one-second intervals.
Information is added to the title on the second line; i.e., beginning at character 41.
SET NPCCPL=40, TITLE(41)='Time ticks at each 1.0 sec'
PLOT thd /TAG='(rad/sec)' /HI=4 /CHARACTER=3

Once set, all X axis qualifiers stay the same until either they are reset or else the X
axis variable itself is changed. If the next plot specifies T as the independent variable,
the scale and tag revert to the default; i.e., linear scale, automatic scaling, and no tag,
as shown in (c):
SET TITLE(41)=40*' '
PLOT /XAXIS=t th

The second line of the title is cleared by specifying blanks for all the characters in the
line. A symbol still appears on the curve at the rate specified previously by NPCCPL,
but it is the default character since the character has not been specified. The axis
lengths remain as previously set.
In addition to the system symbols mentioned above, others enable deferred plotting
(DEFPLT), specifying grid line type (GLTPLT), moving the plot origin (XZPPLT and
YZPPLT), and scaling the size of the whole plot (PSFCPL and PSFSPL). The plot
device driver is selected with DEVPLT, and the plot unit with PLT. The values
available for these last two symbols depend on the computer system.
Several plots can be given the same scale, the scale either specified or left to automatic
scaling. When chosen automatically, the scale for the first item affected by /SAME is
used for all the others; in other words, the scale chosen does not necessarily fit all the
variables.
PLOT x,y,z /SAME
PLOT x /LO=0 /HI=10, y,z /SAME

Array elements are treated individually in automatic scaling, but if scales are specified,
they apply to all elements of the array.

ACSL Reference Manual Page 5-41


5. ACSL Runtime Commands 5.18 PREPARE

PLOT a /LO=-50 /HI=50

If /SAME is used with automatic scaling for an array, the scale chosen for all elements
is that of the first element (a(1) in the following example):
PLOT a /SAME

Array elements can be plotted individually by specifying the element:


PLOT a(3)
PLOT /XAXIS=a(1), a(2)

The logarithmic scale is available for both the X and Y axes:


PLOT w /LOG /TAG='(Hz)'
PLOT /XAXIS=w /XLOG /XLO=0.01 /XTAG='(rad/sec)' &
x /LOG /LO=0.001 /HI=100 /TAG='Gain'

Further examples of plots are in the example programs in Appendix A. The system
symbols that affect plots are described in Appendix C.

5.18 PREPARE

FORM: PREPARE name, ..., name

SWITCHES: /CLEAR
/ALL

PREPARE specifies the variables whose values are to be recorded on the intermediate
data (RRR) file during subsequent runs. The PREPARE statement is given before a
START command. These variables can be printed and plotted after the START has
been executed and control returned to the ACSL prompt.
Only variables listed by PREPARE are available to the RANGE, PRINT, and PLOT
commands. DISPLAY displays the current values of any variables and/or constants at
the termination of the run. The OUTPUT command is not affected by PREPARE.
Data logging Data is logged on the scratch file at each communication interval (CINT)
automatically. Additional logging can be forced with calls to LOGD in the model (see
Appendix B).
Independent The PLOT programs assume as a default that the X axis variable is the first one on the
variable PREPARE list. The independent variable is not included in the PREPARE list
automatically; it must be explicitly listed to be seen and to be made available for the
PLOT programs.
Wild cards Wild cards can be used in specifying the variable list. The asterisk (*) stands for a
name with zero or more characters, and the question mark (?) stands for any one
character.
PREPARE t,x*,k??

Arrays Array elements can be listed by referring to the specific element; for example, A(3). If
the name given is an array, but no specific element is called for, all elements are
PREPAREd.
/CLEAR The PREPARE list is cumulative; i.e., additional commands do not correct the list but
add to it. To clear previous lists and start over, use the /CLEAR switch.
PREPARE /CLEAR t,a,v,w(1)

Page 5-42 ACSL Reference Manual


5.19 PRINT 5. ACSL Runtime Commands

/ALL /ALL adds all the model variables as listed in the debug dump (except for constants
and ACSL dummy variables; i.e., those of the form Znnnnn) to the PREPARE list.

5.19 PRINT

FORM: PRINT name, ..., name

SWITCHES: /ALL
/FILE = 'filename' [model.LOG]
/IHI = <real-variable> [RMX]
/ILO = <real-variable> [-RMX]
/IVAR = <name> [first PREPARE]
/NCIPRN = <integer-variable> [1]
/NOHEADER [header]
/RUN = <integer-variable> [all]

PRINT lists the values of the variables on the PREPARE list in columns after a run
has been completed. The default format is ten columns per page, with line numbers
included automatically. With the /FILE switch, the default is 999 columns per page
since in this case the purpose is to create a data file rather than print a page.
PRINT differs from OUTPUT in that OUTPUT operates during the run while PRINT
operates afterwards. The OUTPUT listing is in blocks rather than columns. PRINT
takes its data from the intermediate data file (RRR) collected during the run.
Logical unit PRN PRINT data is considered high volume and is listed on the PRN logical unit (print file)
for later disposal to the printer queue. If HVDPRN (high volume display) is TRUE,
the listing also appears on the low volume unit (DIS), usually a terminal.
Width of listing System symbol PCWPRN (printer character width) controls the width of the print file.
The default of 132 holds ten columns of PRINT data. For A size paper (81⁄2 x 11 in.),
set PCWPRN to 80, which holds five columns. TCWPRN (terminal character width)
controls the width of printout to the screen; its default of 80 results in five columns of
PRINT data on the screen if high volume data is directed to the screen.
Wild cards Wild cards can be used in specifying the list of variables. An asterisk (*) stands for
zero or more characters, and a question mark (?) stands for any one character.
PRINT t,k*,?d??

Arrays Array elements can be specified; if an array is named but no element specified, the
complete array is printed. Assuming X, XD, and XDD to be three-element arrays, the
first command prints only one element of each array; the second, the complete arrays.
PRINT t,x(1),xd(1),xdd(1)
PRINT t,x,xd,xdd

/ALL /ALL prints all the variables on the PREPARE list. Some thought in setting up the
PREPARE list can result in more useful printouts; for example, including the
independent variable with each set of data. In the following example, the independent
variable T is first on each line, the first two lines contain three-element arrays and the
third line scalar variables, so three lists of ten columns are printed.
PREPARE t,x,xd,xdd
PREPARE t,w,wd,wdd
PREPARE t,k1,k2,q,th,fi,si,switch,z
START
PRINT /ALL

ACSL Reference Manual Page 5-43


5. ACSL Runtime Commands 5.19 PRINT

/NCIPRN /NCIPRN (number of communication intervals per print) controls PRINT volume.
You may wish to log data at a high rate for plotting, but then print at a lower rate. For
example, to print every tenth line of logged data:
PRINT /NCIPRN=10 t,x,y,z

It is important that /NCIPRN be given first. In the following example, all the variables
are printed before the PRINT command sees the /NCIPRN qualifier:
PRINT /ALL /NCIPRN=10

This statement should be written:


PRINT /NCIPRN=10 /ALL

NCIPRN is also a system symbol which can be SET or DISPLAYed at runtime. Once
set, NCIPRN stays the same until you change it explicitly.
PRINT window /IHI, /ILO, and /IVAR together establish a window for printing in a region of interest.
The window ranges from /ILO to /IHI for the variable /IVAR (any variable on the
PREPARE list). The values of the other variables are printed over this window.
PRINT /ILO=20 /ALL
PRINT /IVAR=t /ILO=5 /IHI=6 x,y,z
PRINT /IVAR=x(1) /ILO=200 /IHI=300 t,w,th

If /ILO is greater than /IHI, the region outside the window is printed; i.e., in the first
line of the following example, everything in the window from 5 to 7 is printed, but in
the second line, everything except what's in the window from 5 to 7 is printed:
PRINT /ILO=5 /IHI=7 x,y,z
PRINT /ILO=7 /IHI=5 z,b,c

Once set, /IVAR, /ILO, and /IHI remain the same for subsequent PRINT commands
unless explicitly changed. Respecifying /IVAR resets the values of /ILO and /IHI to
their defaults. The defaults for /ILO and /IHI are -RMX and RMX, respectively, where
RMX is the largest floating point number available on the computer. The default for
/IVAR is the first variable on the PREPARE list.
/RUN /RUN extracts data for a specified run if more than one run has been collected on the
RRR intermediate data file. Collecting runs is accomplished either by looping from
TERMINAL to INITIAL in the model source code or by executing separate START
commands with system symbol NRWITG (no rewind) set TRUE.
PRINT /RUN=3 t,x,y,z

/RUN applies to all the variables specified by the PRINT command. It is not possible
to specify different runs for different (or the same) variables. The RRR file is
sequential and ACSL makes only one pass to PRINT data (as opposed to PLOT,
which makes a pass for each variable being plotted).
/FILE When a PRINT file is specified with this switch, the data is written with a single
header at the beginning of the file, a column on the left with line numbers, and
uninterrupted columns of data. Figure 5-9 shows the results of a command:
PRINT/FILE='testrun.dat' t,x,xd,t

The second T is just to show that variables can be duplicated if necessary.


Only one set of data is kept in a file. If the same file is specified in a subsequent
PRINT command, it is opened and the new data written into it, erasing the old data.

Page 5-44 ACSL Reference Manual


5.20 PROCEDURE 5. ACSL Runtime Commands

Line T X XD T
0 0. 0.50000000 0. 0.
1 1.00000000 0.22806700 -0.55097100 1.00000000
2 2.00000000 -0.52946100 -0.84948000 2.00000000
3 3.00000000 -1.07931000 -0.08726660 3.00000000
4 4.00000000 -0.64942700 0.92205200 4.00000000
5 5.00000000 0.72023700 1.64531000 5.00000000
6 6.00000000 1.67220000 0.01099750 6.00000000
7 7.00000000 1.06116000 -1.11657000 7.00000000
8 8.00000000 -0.60672500 -2.15435000 8.00000000
9 9.00000000 -1.93461000 -0.08165130 9.00000000
10 9.90000000 -1.45462000 0.96626600 9.90000000

Figure 5-9. Output of PRINT /FILE command

/NOHEADER This switch eliminates all headers at the top of the columns of data. The main use is
for importing data into external applications such as Lotus and Excel.
This switch should in general appear first; in particular, it must precede /ALL in the
PRINT command line to take effect.
Each PRINT command reverts to the default of generating headers unless the
/NOHEADER switch is applied again.

5.20 PROCEDURE

FORM: PROCEDURE name [(arg1[=<default-value>] &


[,arg2[=<default-value>]] ...)]
... <runtime commands>
END

CALLS: name
name <arg1val>, <arg2val> ...
name arg2=<arg2val>, arg1=<arg1val> ...

A PROCEDURE is a block of commands which begins with the PROCEDURE


statement (with optional arguments and default values) and terminates with an END
statement. It is invoked at runtime by calling its name. The commands in the body of
the PROCEDURE may be any runtime commands, including calls to other
PROCEDUREs. PROCEDUREs can be nested to any level.
PROCEDUREs are defined to avoid repeating long command sequences. They are
useful, for example, in setting up runs and plot sequences.
The PROCEDURE (a runtime statement) should not be confused with the
PROCEDURAL, which is used in a sorted section of a model source program.
Names Names of PROCEDUREs may be any legal symbol; i.e., starting with a letter,
continuing with letters or digits, and delimited by anything not a symbol (e.g., space,
period, etc.). Don't choose a name which is already a runtime command. Since the
runtime executive checks PROCEDURE names first and then runtime commands,
using a runtime command as a PROCEDURE name means the runtime command can
never be executed. For example, if the following procedure is defined, the short form
of the SET command (S) is hidden:

ACSL Reference Manual Page 5-45


5. ACSL Runtime Commands 5.20 PROCEDURE

PROCEDURE s
SET k=0.4,xic=1.0
START
END

Example An example of a typical PROCEDURE without arguments is:


PROCEDURE go
SET NDBUG=2
START
PRINT /ALL
PLOT /XAXIS=t n,m
PLOT /XAXIS=x y,z
END

Execution The set of commands is saved when defined, but not executed until the PROCEDURE
name is given as a command, at which time the entire sequence is executed. The
following commands change a model parameter then run, print, and plot for each
condition by calling the GO PROCEDURE. These commands could themselves be
defined in a PROCEDURE.
SET a=5.0 ; go
SET a=5.5 ; go
SET a=6.0 ; go

Arguments Arguments may be specified in the PROCEDURE header, with substitutions indicated
in the body by an ampersand (&), as in the following example:
PROCEDURE df(val)
SET a=&val, b=&val, c=&val
END
...
df 20

Defaults Default values may be given to the arguments, as in this plot command:
PROCEDURE p1(x, lo=0, hi=10)
PLOT &x/LO=&lo /HI=&hi
END
...
p1 A
p1 B, -2, 2

In the first call to this PROCEDURE, the variable to be plotted is named, but the
default values of HI and LO are used. In the second call, different values are given to
the arguments.
Positional or In the previous example, the arguments were called in the same order as they had been
keyword given in the definition. These are called positional arguments. Arguments can also be
argument calls called out of order by keyword assignments; the previous PROCEDURE could be
called with the arguments out of order as follows:
p1 hi=20, x=th

Once a keyword assignment appears on a call line, all the subsequent arguments must
also be by keyword. The following, for example, is illegal:
p1 y2 /lo=0, 5

Set value and A handy way to set a value and include that information in the TITLE array is with the
TITLE argument to a PROCEDURE.

Page 5-46 ACSL Reference Manual


5.21 QUIT 5. ACSL Runtime Commands

PROCEDURE setk(val)
SET k=&val, TITLE(41)="Gain=&val'
END

setk 0.7

Use of The ampersand can be used for substituting arguments into the TITLE array and other
ampersand in strings; therefore, it cannot also be used simply as a character in a string. In the
TITLE string following example, the first ampersand sets a value, the second sets the information
into the TITLE array, and the third is illegal, producing the error message.
PROCEDURE run1(val)
SET a=&val
SET TITLE="Actuator gain = &val"
SET TITLE(41)="DB&K simulation"
END

Argument K is not defined in procedure header.


Replaced by null string

If the procedure is then invoked, the ampersand and the following character are
dropped.
run1 5
SET a=5
SET TITLE="Actuator gain = 5"
SET TITLE(41)="DB simulation"

There is no restriction on using the ampersand as a character in strings when the


strings are not inside a PROCEDURE. The line above that produced the error message
when inside the procedure, for example, would not be an error if it were simply in a
command file but not in a PROCEDURE.
Display PROCEDURE names, arguments, defaults, and text can be displayed at runtime. See
DISPLAY for further information.
DATA definition DATA definitions cannot be in PROCEDUREs, but any number of DATA blocks can
be defined, at any time. The appropriate one can be accessed from a PROCEDURE.

5.21 QUIT

FORM: QUIT

The QUIT command tells the runtime executive that no more commands follow and
control is to be returned to the operating system.
This command should always be the last command issued so that all the files and plots
established by the executive are cleaned up or terminated correctly.

ACSL Reference Manual Page 5-47


5. ACSL Runtime Commands 5.22 RANGE

5.22 RANGE

FORM: RANGE name, ..., name

SWITCHES: /ALL
/IHI = <real-variable> [RMX]
/ILO = <real-variable> [-RMX]
/IVAR = name [first PREPARE]
/RUN [all]
/TIMES

The RANGE command determines the maximum and minimum values of variables on
the PREPARE list. A typical sequence of commands is:
PREPARE t, ..., z
START
RANGE t, ..., z

Wild cards Wild cards can be used in specifying the list of variables. An asterisk (*) stands for
zero or more characters, and a question mark (?) stands for any one character.
Arrays Elements of arrays can be specified. If an array name is given and no element is
specified, the entire array is assumed.
Error message If any name on the RANGE list is not defined in the PREPARE list, an error is
reported.
RANGE th,k
TH-0.91880100 1.000000000
Can-t find K

/ALL /ALL results in RANGE reporting on all the items in the PREPARE list. RANGE with
no list and no /ALL produces no output.
/TIMES /TIMES produces a listing of the times at which the maxima and minima of the
variables occur. For the following command, for example,
RANGE /TIMES th,thd,thdd

the answer is in the form:


TH-0.91880100 AT 0.82500 1.00000000 AT 0.
THD-3.69781000 AT 0.40000 3.42172000 AT 1.25000
THDD-13.5477000 AT 0. 12.8163000 AT 0.80000

Windows Windows for sub-ranges may be defined. The independent variable is specified by
/IVAR along with its low /ILO and high /IHI to define the test. For example,
RANGE /IVAR=x /ILO=50 /IHI=100 /ALL

would report the maximum and minimum values of all the elements on the PREPARE
list when the variable X lies between 50 and 100.
Once set, /IVAR, /ILO, and /IHI remain the same for subsequent RANGE commands
unless you change them explicitly. Respecifying /IVAR resets the values of /ILO and
/IHI to their defaults. The defaults for /ILO and /IHI are -RMX and RMX,
respectively, where RMX is the largest floating point number available on the
machine. The default for /IVAR is the first variable on the PREPARE list.
Switch order The /TIMES and /IVAR switches must be given before the list of variables (in a left to
right scan) so that the value of IVAR at the maximum and minimum can be found; for
example, use /TIMES before /ALL as follows:

Page 5-48 ACSL Reference Manual


5.23 REINIT 5. ACSL Runtime Commands

RANGE /TIMES /ALL

/RUN /RUN extracts data for a specified run if more than one run has been collected on the
RRR intermediate data file. Collecting runs is accomplished either by looping from
TERMINAL to INITIAL in the model source code or by executing separate START
commands with system symbol NRWITG (no rewind) set TRUE.
RANGE /RUN=3 x,y,z

/RUN applies to all variables specified in the RANGE command. It is not possible to
specify different runs for different (or the same) variables. The RRR file is sequential
and ACSL makes only one pass to access RANGE data (as opposed to PLOT, which
makes a pass for each variable being plotted).

5.23 REINIT

FORM: REINIT

REINIT (REINITialize) writes the current values of the state variables into their
corresponding initial conditions, thereby destroying the original initial conditions.
For example, this command could be used for a missile flight, where the simulation is
stopped just before the terminal phase. This point is then established as the starting
point for subsequent runs. The runtime command sequence could be:
SET tstop=30
START ! Run through flight midcourse
REINIT ! Establish initial conditions at this point
SET tstop=50 ! Otherwise run will stop again immediately
START ! Run terminal phase of flight
SET rtic(1)=50000 ! Change target position
START ! Run terminal phase again

With SAVE and The SAVE command can be used to save the original conditions if needed:
RESTORE
START
SAVE /FILE='state1' ! Saves original initial conditions
REINIT

The saved files can then be called in by RESTORE to restore the desired initial
conditions. This can be useful in restarting the whole problem since REINIT changes
the entire initial condition table and it can be difficult otherwise to get back to the
original point in state space.
Calculated initial If initial conditions are calculated in the INITIAL section, you need a provision for
conditions skipping over this code after REINIT; otherwise, the current state values, which are
moved into the initial condition vector by REINIT, are recalculated after the START.
For example, code in the model could be in following form:
INITIAL
LOGICAL reinitf ; CONSTANT reinitf=.FALSE.
IF(reinitf) GO TO skipin
... [INITIAL section calculations]
skipin..CONTINUE

Then at runtime, the following commands result in the calculations being skipped:

ACSL Reference Manual Page 5-49


5. ACSL Runtime Commands 5.24 RESTORE

REINIT
SET reinitf=.TRUE.
START

Initial conditions Initial conditions in operators (DELAY, EXPF, etc.) must be given variable names
in operators rather than be expressed in literal constants (0.0, for example) in order for the
operators to work with REINIT. REINIT can write the new initial condition into a
variable name, but not into a literal constant.
REINIT versus For simple models without DISCRETE sections or events, START/REINIT/START is
SAVE/RESTORE straightforward and usually sufficient. For more complex model, however, it is
probably better to use START/SAVE/RESTORE/CONTINUE.
CONTINUE not CONTINUE should not be used after REINIT. CONTINUE causes certain operators
allowed after to continuously reinitialize themselves by computing their initial conditions until a
REINIT START occurs.

5.24 RESTORE

FORM: RESTORE [name, ..., name]

SWITCHES: /[NO]EVENTS [/NOEVENTS]


/FILE = 'filename'
/STATES

The RESTORE command restores data by variable name from an external file that has
been generated by a SAVE command. The variable list is optional, but a file name
must be specified. The default file name for SAVE is ACSLSAV.
Warning If no list of names is given, then RESTORE reads each variable from the given file
messages with its associated data value, looks it up in the model dictionary, and then replaces
the current value with the value from the file. Names with no match are identified by
the message:
No match in model for file variable AAAAAA

If not all variables are restored, the untouched ones are identified by:
No restore for model variable AAAAAA

Wild cards Wild cards can be used in specifying the variable list. An asterisk (*) stands for zero or
more characters, and a question mark (?) stands for any one character.
/STATES /STATES specifies restoring only the state variables defined by integration statements.
There is no check that all the state variables in this model have been restored; ACSL
reads in the names on the file that correspond to state variables in the current model.
/EVENTS /EVENTS specifies restoring the event list if one was saved on the file. /NOEVENTS
ignores any event list on the file. If the event list is restored, it is usually possible to
CONTINUE from the restored situation.
File format The /BINARY and /ICS switches used with the SAVE command are not needed with
RESTORE. ACSL senses the file format and handles it appropriately, and the initial
conditions restore automatically from the file.

Page 5-50 ACSL Reference Manual


5.25 SAVE 5. ACSL Runtime Commands

Examples Following are examples of typical RESTORE commands.


RESTORE /FILE='acslsav'
RESTORE /FILE='case1.bin' /STATES /NOEVENTS
RESTORE /FILE='gains.sav' k*
RESTORE /FILE='mysave.asc' a,v,x,w /EVENTS

5.25 SAVE

FORM: SAVE [name, ..., name]

SWITCHES: /[NO]BINARY [/BINARY]


/EVENTS
/FILE = 'filename' ['ACSLSAV']
/ICS
/STATES

SAVE saves the user's data block on an external file. The variable list is optional. The
default file name is ACSLSAV.
The runtime SAVE command should not be confused with SAVE when used in a
program. In the program, SAVE writes macro definitions to a macro file.
Defaults If no variable list is specified, all model variable values are written to the file,
including initial conditions and states. If no switches are given, events are not
included. If a variable list is specified, initial conditions and states are not added.
Modified model Variables are saved by name and value so that on RESTORE they are brought back to
the same location even though the model may have been changed.
Znnnnn variables One potential problem when a model has been modified between the SAVE and
RESTORE is in the saving of internal ACSL variables; i.e., those of the form Znnnnn
(Z99987 for instance). These variables are also saved and restored. A change in the
model, while keeping the model names intact, can result in a reordering of these
internal variables. If the internal variables names have changed, RESTORE could
bring data values back into the wrong locations.
/NOBINARY /NOBINARY results in the data being written out as a text file. The advantage of the
text file is that it can be read and edited. The disadvantage is that decimal fractions can
never be represented exactly on a binary machine, so a subsequent RESTORE brings
back numbers that are slightly different from the values at SAVE time. If /BINARY is
in effect, then the RESTORE is exact, but the file produced cannot be listed or edited.
/NOBINARY must be specified with each SAVE command for which it is desired.
/STATES /STATES specifies saving only the state variables defined by integration statements.
Other state variables are not saved. These are for example when a variable is
accumulated in the form:
x = x + dlx

/ICS /ICS specifies saving only the initial condition names corresponding to the names
defined by integration statements. These are sometimes more meaningful than the state
names. Initial conditions defined as literal constants (0.0 for example) are assigned
names in the form Znnnnn and are not restored by /ICS.

ACSL Reference Manual Page 5-51


5. ACSL Runtime Commands 5.26 Separator (;)

/EVENTS /EVENTS specifies adding a copy of the event list at the end of the file. /BINARY
must be in effect when using /EVENTS. Including the event list on the SAVE file is
important if SCHEDULE statements or DISCRETE sections are used in the model.
Examples Following are examples of typical SAVE commands.
SAVE
SAVE /FILE='case1.bin' /EVENTS
SAVE /FILE='mysave.asc' /NOBINARY
SAVE /FILE='gains.sav' k*,x*,y*
SAVE /FILE='case3' /STATES /ICS /EVENTS

5.26 Separator (;)

The command separator is the semicolon. More than one command can be written on
the same line, as, for example:
SPARE ; START ; SPARE

Comments can be placed only after the last command since everything after an
exclamation point (!) is ignored by the runtime executive.
SET k1=0.5 ; START ; DISPLAY x,xd ! Case 1

5.27 SET

FORM: SET name = <matching-variable> [, name = ...]

Data can be set into any known constant, array, or variable by the SET command;
however, normally it is used only for constants, either system symbols or model
variables defined in CONSTANT statements.
Data type The data type must match the type of the symbol (i.e., REAL, DOUBLEPRECISION,
INTEGER, LOGICAL, CHARACTER), except that integer values may be set into
real variables (automatic floating point conversion takes place). Single precision
numbers are automatically changed to double and vice versa as required. Integer
values must not have a decimal point, and logical variables can be only .TRUE. or
.FALSE. (short forms .T. and .F.).
Once set, a variable holds its value until explicitly changed by another SET command
or, after a START, by code in the model.
Arrays Individual elements of arrays can be set. Arrays can also be filled by a data list, where
succeeding data items will be stored in subsequent array slots. Attempting to exceed
the array length results in a diagnostic message. In the following example, B has five
elements:
SET a(2)=5.5
SET b=3*4.5,6.7,5.4,2.1
Reference out of limit of array B

Arrays can have up to six dimensions, and they can be accessed with the dimensions;
for example:
SET b(3,5)=8.5

Page 5-52 ACSL Reference Manual


5.27 SET 5. ACSL Runtime Commands

Symbolic data Data can also be obtained from another symbolic location by using the symbol name:
SET rm1=rng, rmt=rng

This statement results in the variables RM1 and RMT containing the value of the
number stored in the symbol RNG after execution. This concept is useful if a data item
must be stored in many places; it can be stored by value once and then picked up by
name subsequently, so the value need be changed in only one place.
Array elements can also be accessed symbolically as well as by number; for example,
assuming KBOIL contains an integer 3, the following are synonymous:
SET gain(kboil)=0.3
SET gain(3)=0.3

Character data Character data can be set into a symbol or array that is of type character. Generally
only the system array TITLE uses character data.
TITLE The TITLE array can be accessed as one long string or as a series of characters. The
number of characters in the TITLE array has a default of 120 but can be expanded to
as many as 480 with system symbol NCTPRN.
One advantage to accessing separate characters in TITLE is to change selected
portions for different runs while leaving others the same from run to run. For example:
SET TITLE='Project XYZ Simulation ABC'
SET TITLE(41)='09/09/99'
SET TITLE(61)='Gain=5'
START ; PRINT /ALL
SET gain=10, TITLE(61)='Gain=10'
START ; PRINT /ALL
SET TITLE=120*' ' ! Erase title

The TITLE can be erased by setting it (or portions of it) to blanks. In the last line
above, a space is required between two single quotes to indicate a blank.
DCVPRN To confirm a variable as it is modified by a SET command and reinforce that the value
being changed is really what you thought, both the old and new values are listed when
system symbol DCVPRN (Display Changed Variables) is TRUE. For example:
SET DCVPRN=.T.
SET y1z=3, y2z=4, xarray(2)=3.1
Y1Z (Old value) 2.50000000 (New value) 3.00000000
Y2Z (Old value) 3.70000000 (New value) 4.00000000
XARRAY(2) (Old value) 2.80000000 (New value) 3.10000000

Examples Typical legal SET commands include the following:


SET nstp=10, rm(1)=5.6E3, mass=4.6, gain=5.2D2
SET logvar=.TRUE., array(5)=4.3, switch=.T.
SET array(2)=2.0,3.0,4.0, tstop=9.99, count=20 &
,TITLE='Doppler Study', array(6)=5*0.0

ACSL Reference Manual Page 5-53


5. ACSL Runtime Commands 5.28 SPARE

5.28 SPARE

FORM: SPARE

The SPARE command is provided to link to a user-supplied runtime subroutine named


SPARE. A default subroutine provided by ACSL lists the central processor time, both
accumulated from the start of the run and elapsed since the previous use of SPARE.
SPARE is useful for timing simulation execution. Execution of the default subroutine
results in output in the following form:
SPARE
ACCUMULATED CP TIME nnn.nnn SEC. ELAPSED CP TIME nnn.nnn SEC

The accumulated time is normally the time from the beginning of the job; the elapsed
time is the incremental time from the previous invocation of SPARE. The ELAPSED
CP TIME resulting from the following sequence shows the simulation execution time:
SPARE ; START ; SPARE

When a user supplies a subroutine called SPARE, the SPARE runtime command
executes the user subroutine rather than ACSL's. A user subroutine such as the
following could be used to create a new runtime command implemented by a
subroutine called, for example, "foo":
SUBROUTINE spare
CALL foo
RETURN
END

The runtime sequence then could be:


PROCEDURE foo
SPARE
END

5.29 START

FORM: START

SWITCHES: /CHARACTER = '<character>' ['<blank>']


or = <integer-variable>
/HI = <real-variable> [1.0]
/LO = <real-variable> [0.0]
/PLOT
/RESCALE
/TYPE = ijk [000]

The START command starts execution of the simulation model. It allows the model to
integrate over the state trajectory.
With the START command, control is handed over to the model definition at the top
of the INITIAL section. All states are given their initial conditions at the end of the
INITIAL section. The DERIVATIVE and DISCRETE sections are evaluated in order,
the DYNAMIC code is evaluated, then integration begins.
The simulation is allowed to run until a termination condition (usually defined in a
TERMT statement) is met. Finally, the TERMINAL section is executed once before

Page 5-54 ACSL Reference Manual


5.30 SYSTEM 5. ACSL Runtime Commands

control is returned to the runtime executive for the next runtime command. A typical
sequence for executing a run is:
PREPARE t,x,xd,xdd
OUTPUT t,x,xd /NCIOUT=20
START

Switches The switches for START control plotting of variables on the OUTPUT list during a
simulation run. This is different from the PLOT command, which operates only after
the run has been completed and control returns to the ACSL prompt.
All the switches except /PLOT and /RESCALE follow the name of a variable. The
variable must also have been specified on the OUTPUT list. Once values have been
sspecified, they remain in effect until explicitly changed. The values established by
/RESCALE also remain in effect until explicitly changed. However, /PLOT must be
specified for a plot to be generated; otherwise, numerical data appears.
/PLOT /PLOT specifies plotting the variables on the OUTPUT list (rather than printing the
numeric values). The first variable on the OUTPUT list is plotted as the X axis; a
separate Y axis is drawn for each other variable on the list. At least two variables must
be present for a plot to be drawn.
Scales Scales are established by switches on the OUTPUT statement but can be modified at
the START (or CONTINUE) command. If /RESCALE is specified, the maximum and
minimum values for each variable from the previous plotted run are converted to
round numbers for the current scale factors. /HI and /LO must follow a variable name;
they specify the plot scales for that variable.
OUTPUT t,x,y
START /PLOT
START /PLOT /RESCALE
START /PLOT t/HI=10, x/LO=-4/HI=4, xd/LO=-20/HI=20

/CHARACTER /CHARACTER specifies a character to be drawn on the curve at NPCCPL data points.
START /PLOT x/CHARACTER=1
START /PLOT u/CHARACTER='U',v/CHARACTER='V',w/CHARACTER='W'

/TYPE /TYPE specifies line color, width, and style (solid, dotted, dashed), as described under
PLOT. /TYPE results are device-dependent.
Plot controls The system symbols for line plots (i.e., those ending in CPL) can be used to control
such characteristics as axis length, plot scale factor, etc. See Appendix C for
descriptions of the system symbols.

5.30 SYSTEM

FORM: SYSTEM [<operating-system-command>]

The SYSTEM command allows escape to the computer operating system on systems
which allow such a procedure. The command accepts any character string.
If an operating system command is specified with the SYSTEM command, control is
returned to the ACSL runtime prompt when the command has completed execution.
On most systems, the SYSTEM command with no arguments spawns a subprocess
from which general computer commands can be issued.

ACSL Reference Manual Page 5-55


5. ACSL Runtime Commands 5.31 Wild cards (* and ?)

As an example, a command file could be edited on a VAX system as follows:


SYSTEM edit model.cmd

On PCs, the SYSTEM command opens a DOS window.


SYSTEM commands can be included in PROCEDUREs, which allows, among other
benefits, system tasks to be given short names; for example, the above command could
be stored in a PROCEDURE and executed:
PROCEDURE ed(name)
SYSTEM edit &name
END
...
ed 'model.cmd'

5.31 Wild cards (* and ?)

An asterisk (*) or a question mark (?) in a name is a wild card. The asterisk stands for
a character string of zero or more characters, and the question mark stands for any one
character. For example, to display all symbols starting with a K including K itself if
present (K followed by zero characters), use:
DISPLAY k*

Wild card matches search both user and system dictionaries, which is useful for
accessing groups of system symbols. To find all six-character symbols ending in PLT:
DISPLAY ???plt

Other runtime commands that accept wild cards are:


OUTPUT PREPARE PRINT RANGE RESTORE

For the PREPARE command, constants and dumy variables (Zaaaaa) are excluded in
the wild card match.

5.32 XERROR

See MERROR.

Page 5-56 ACSL Reference Manual


6. Macro Language

6.1 Introduction

ACSL's macro capability allows you to expand the language by defining new
operators. These operators are called from the program, usually with arguments. From
the macro directives, the translator generates the code for compilation. Code is
generated each time the macro is called. Usually the code is slightly different with
each call (because of arguments resulting in different variable names, for example).
The generated code is often referred to as a macro expansion.
Macros are useful for standardizing certain functions for an industry or discipline.
Macros can also be used to capture special expertise for other users to incorporate into
their programs.
Macro versus A macro is similar to a subroutine or function in that it is defined once and then
subroutine invoked as many times and as from as many places in the model code as needed. The
translator produces a set of statements in the Fortran compile file for each macro
invocation, but the extra storage used for such statements is usually small. Macros are
slightly more efficient than subroutines or functions and have the advantage of being
able to define operators involving integrators and memory functions.
Macros are used rather than Fortran subroutines if any ACSL operators are involved,
or to gain visibility of internal variables. Concatenation is another reason to use
macros. It allows the generation of unique variables for each application of a macro,
and the values of these variables are available for printing and plotting.
Placement of Macros can be defined two ways. They can be defined in the program in which they
definitions are called, before the first invocation (not at the end of the program like subroutines).

Alternatively, definitions can be in a separate program containing only the macros; the
program concludes with a SAVE statement (see Chapter 4) that saves the macros to
the current macro file. Since the procedure for writing a user macro file varies
depending on the computer system, it is described in the document ACSL Sim User's
Guide. In general, 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. On some systems,
this file must be given WRITE permission. The macro definitions are added to the file
(i.e., they are cumulative), so generally you will want to start with a fresh copy of the
system macro file. Only translation is required, so stop the ACSL build procedure
before compilation.
Examples For two examples of macros using integrators, see the Physiological Benchmark
program in Appendix A. Other examples are found at the end of this chapter.
Features Some of the more important features of the macro language are:

1) Variables and statement labels may be locally generated. In the event the macro is
called more than once, this prevents multiply defined variables or labels.
2) An unlimited number of macro input arguments may be used. These arguments
must be valid expressions (of arbitrary complexity) with balanced parentheses
and any character string enclosed in quotation marks.

ACSL Reference Manual Page 6-1


6. Macro Language 6.1 Introduction

3) Macro definitions may invoke other macros to an unlimited level of complexity.


Note, however, that macro definitions may not be nested. Nesting macro
definitions would require a count of nesting level within the definition to match
up with the correct MACRO END; such a count is not performed and the first
MACRO END terminates the definition.
4) Macros may be placed anywhere within an ACSL program, but they must be
defined before they are used. A macro may be redefined; the most recent version
is used in the expansion.
5) The concatenation operator (&) allows arguments to be placed together without
intervening spaces, a useful way of making up variable names.
6) Macro definitions can include INITIAL and/or TERMINAL sections.
Forms of call Macros can be called in three ways. The second form, called standalone, is generally
preferred. The third form is must be used with more than one output.
y = MAC(x)
MAC(y = x)
MAC(y,z = x)

Concatenation The ampersand (&) is the concatenation operator that allows a substitutable argument
to appear next to a character string. Its use is discussed in more detail under Macro
Definition Header. In general, it enables generation of unique names with multiple
calls to a macro. For example, variable V1 is accessed in the following expansion:
MACRO abc(x)
y = v&x
MACRO END
abc(1)
...
y = v1

The substituted name must be separated from any other characters by either a space or
an ampersand. No substitution would take place in the following situation:
MACRO abc(x)
y = v&xgh
MACRO END

An additional ampersand after the X, however, sets it off so it can be substituted:


MACRO abc(x)
y = v&x&gh
MACRO END
abc(2)
...
y = v2gh

INITIAL INITIAL, DYNAMIC, DISCRETE, and TERMINAL sections can be used in macro
DYNAMIC definitions. The translator collects all the code in the order presented (or expanded in
DISCRETE the case of macros). These sections are not sorted unless the SORT keyword is
TERMINAL specified.
Arguments Argument strings are substituted for each appearance of the macro argument name. If
the argument is an expression, care must be taken that the resulting code is correct
after the substitution (see the section on macro calls). Other names that may be
substituted during macro expansion are the ASSIGNed variable (see MACRO
ASSIGN), local variable names identified by a REDEFINE (see MACRO
REDEFINE), and local labels identified by a RELABEL (see MACRO RELABEL).

Page 6-2 ACSL Reference Manual


6.1 Introduction 6. Macro Language

Warning – Substitutable symbols on the left side of an equal sign in a macro definition should not
use of DO begin with DO. The problem with using DO is that the ACSL translator, when it is in a
macro definition, looks for substitutable strings, but in order to prevent substitution of
DO, it checks for leading characters in this form. Unfortunately, Fortran syntax does
not require spaces, so:
DO100 = 1, 5

is an acceptable form, and ACSL also cannot assume that a space will be used to set
off the DO construct. ACSL thus does not make the expected substitution when the
name begins with DO.
Warning – Another potential area for error in substitution is the use of the same name in different
substitution errors circumstances. In the following macro, for example:
MACRO test(L, x)
MACRO RELABEL L1, form
IF(x .GT. 0.0) TO TO L1
WRITE(6, form) L
L1: CONTINUE
form: FORMAT(1X, L1)
MACRO END

The FORMAT statement becomes:


99998 FORMAT(1X, Z09996)

which is invalid. L1 in the FORMAT should not have been substituted. Fix this by
changing the label name to a unique character string.
Two types of macro The section on the macro definition header describes the two types of macros that can
definitions be defined. The first type is preferred for most applications and accepts variable names
as arguments. The second type is useful for handling arrays and can be identified by
headers starting MACRO MACRO.

ACSL Reference Manual Page 6-3


6. Macro Language 6.2 Macro definitions

6.2 Macro
definitions

The macro definition is a block of code that consists of the following:


1) Macro definition header
2) Macro directive or ACSL statements
3) MACRO END
The macro definition header specifies the name of the current definition and a list of
dummy reference parameters, analogous to dummy arguments in a Fortran subroutine.
The translator scans the statements in the macro body for the appearance of these
names, flagging them for substitution by the actual argument supplied on invocation.
The definition terminator, MACRO END, must be present to flag the translator to
return to direct translation. The translated macro body with arguments substituted is
referred to as the skeleton.
If a macro name is the same as one already defined, either in the system macro file or
the current model definition, the new macro definition replaces the old one. No error
message is issued since this is considered to be a feature whereby you can always
override an old macro definition.

6.3 Macro
definition header

FORM: MACRO identifier(x1, x2, ..., xn)


MACRO MACRO identifier(p, q, r, s)

where identifier is the macro name, xi are variable names, constants, or expressions, p
is the primary argument specifying an array of input expressions, and q, r, and s are
secondary arguments giving the names of array dimensions within the macro
definition. The arguments p, q, r, and s may be any unsubscripted variable name. If P
is the name of the argument of a MACRO MACRO, then you must not use a variable
named P in the macro.
First type For its relative simplicity, the first type of macro is preferred for most purposes.
Anywhere the string of characters xi is referred to in the macro definition, it will be
replaced by the ith argument (symbol or expression) when the macro is invoked; e.g.,
MACRO mult(x, y, z) ! definition
x = y*z
MACRO END
c = a*mult(5.0*b, d) ! invocation

In this example, the output of the function is the first argument (X); X does not appear
explicitly in the invocation. Y is replaced by 5.0*B and Z by D everywhere throughout
the definition.
Second type The second type of definition is useful when handling arrays of indefinite size. This
form has an extra MACRO in the header.
Arguments for The argument p is the dummy reference parameter and may be thought of as a vector,
second type each element of which identifies the respective element in the argument list at
invocation time. You specify only p in the invocation. The secondary arguments q, r,
and s appear, if needed, in the definition header and may be used in the macro
definition, but do not appear in the invocation argument list. Elements of p that are

Page 6-4 ACSL Reference Manual


6.3 Macro definition header 6. Macro Language

arrays must be dimensioned prior to the macro invocation. Arguments q, r, and s may
also be thought of as arrays, but only those elements corresponding to arrays in the p
array contain values. They refer to the first, second, and third dimensions, respectively.
MACRO MACRO head(p, q, r, s) ! definition
... definition statements ...
MACRO END
DIMENSION b(9), g(2, 3), h(4, 4, 2)
head(a, b = 5*d, e+f, g, h, low) ! invocation

Arguments at invocation time are delimited by either commas or an equal sign. Thus,
in this example, P(1) appearing in the definition body is substituted by the symbol A,
the first argument, at invocation time. P(4) is replaced by the expression E+F, the
fourth argument.
Any reference to Q for an array accesses the first dimension. In the example above,
Q(2) has the value 9 from the dimension of B in the previous DIMENSION statement,
but P(1), P(3), P(4), and P(7) are not dimensioned arrays, so Q(1), Q(3), Q(4), and
Q(7) are scalar have a dimension of one.
Symbols substituted for the secondary arguments R and S act similarly to Q except
they provide the second and third dimensions respectively; for example, R(5) is 3 and
S(6) is 2.
Note that macros written in this second form are extremely hard to read since no
mnemonic symbols can be used for the arguments. 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), combination of the above.
Substitutable In general, the substitutable symbols must be separated from other character strings by
symbols nonalphanumeric characters (i.e., *, +, -, blank) or the concatenation symbol (&) in
order for the scan to operate. If the above macro MULT contained the statement:
ASSIGNz TO k

the symbol Z would not be identified for substitution. Here the space is all important,
so the correct form is the following:
ASSIGN z TO k

Concatenation The concatenation operator is defined to allow the substitutable argument to appear
next to a character string. This operator is the ampersand (&). It serves as a separator
for symbol identification, but is removed entirely when the macro is translated into the
skeleton. As an example, consider generating unique symbols 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); i.e.,
X = Y*F&Z

Invoking the MULT macro with:


a = mult(sam, joe)

results in the statement:


A = SAM*FJOE

ACSL Reference Manual Page 6-5


6. Macro Language 6.4 Macro directive statements

where the new symbol FJOE has been defined. The above call MULT enters a symbol
JOE on the symbol table. If only the made up symbols are important, the argument
may be quoted using double quotes as:
a = mult(sam, "joe")

In this case, the same expression is generated but now the symbol JOE is not be
entered in the symbol table. 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.

6.4 Macro
directive
statements

The following section lists in alphabetical order the macro directive statements that
may be included within a macro definition. No code results from these statements, but
extremely flexible control of the macro processing at invocation time is possible. The
ACSL statements themselves produce code, 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.
Labels All macro directive statements can have labels attached to them; the labels can be used
by MACRO GO TO and MACRO IF directives. These labels must be distinct from
any labels attached to nondirective statements. The label is inserted after the leading
MACRO of the directive; e.g.,
MACRO s1: RELABEL i
MACRO s2: CONTINUE
MACRO s3: END

Note that these labels control the sequence of the macro processor at macro invocation
time. The labels on nondirective statements control the sequence at runtime execution.

6.4.1 MACRO ASSIGN

FORM: MACRO ASSIGN n

where n is a symbol (usually N is used). The ASSIGN directive assigns the number of
arguments in the macro call to the variable N; N is always an integer. If the dummy
reference parameter contains a variable subscript, the variable must be the same as the
variable used in the ASSIGN statement. Whenever N is used as part of the dummy
reference parameter subscript, the current value of N refers to the Nth argument in the
macro call list at invocation time. For example, using the second header type:
MACRO MACRO sam(P) ! definition

MACRO ASSIGN n
...
MACRO END
sam(x, y, z) ! invocation

Within the macro definition, N is 3 since the invocation to SAM contains three
arguments, and therefore:

Page 6-6 ACSL Reference Manual


6.4 Macro directive statements 6. Macro Language

p(n) = Nth argument, which is z


p(1)(N) = x(3)
p(n-1)(N) = Nth element of the (n-1) argument; i.e., y(3)

6.4.2 Arithmetic macro


directives

FORM: MACRO INCREMENT i


MACRO DECREMENT i
MACRO MULTIPLY i
MACRO DIVIDE i

where i is an unsigned integer constant, the secondary arguments (p, q, r, s) of the


second type of macro, or a macro argument name that has a literal numeric integer
value.
These directives provide arithmetic operations on the ASSIGNed variable N. The
value of N may be added to, subtracted from, multiplied, or divided. All arithmetic
operations are performed in fixed point integer. For example,
MULTIPLY 0

makes the ASSIGNed variable zero. To make the ASSIGNed variable equal to the
dimension of the second argument, the following code can be used:
MACRO MACRO bil(p, q)
MACRO ASSIGN n
MACRO MULTIPLY 0
MACRO s1: IF(n = q(2)) s2
MACRO INCREMENT 1
MACRO GO TO s1
MACRO s2: CONTINUE

On exit from this section, N (the assigned variable) has the integer value Q(2), the
dimension of the second argument. 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.

6.4.3 MACRO
CONTINUE

FORM: MACRO CONTINUE

This macro directive is included so that it can be labeled, as, for example,
MACRO L1: CONTINUE

The MACRO IF or MACRO GO TO can then branch to this section within the
definition.

6.4.4 MACRO
DECREMENT

See Arithmetic macro directives.

ACSL Reference Manual Page 6-7


6. Macro Language 6.4 Macro directive statements

6.4.5 MACRO DIVIDE

See Arithmetic macro directives.

6.4.6 MACRO EXIT

FORM: MACRO EXIT

The EXIT directive statement stops the generation of code at invocation time. The
action is the same as using a MACRO GO TO that transfers control to the macro
definition terminator (MACRO END).
MACRO EXIT in a PROCEDURAL block can result in translator errors because the
END statement will be missing from the PROCEDURAL block.

6.4.7 MACRO GO TO

FORM: MACRO GO TO s

where s is a statement label attached to another MACRO directive. The GO TO


provides an unconditional branch to a labeled macro directive within the definition.

6.4.8 MACRO IF

FORM: MACRO IF(e1 = e2) s

where s is a macro directive statement label and e1 and e2 can be the dummy reference
parameters corresponding to the call list, integer constants, character strings, or the
identifier used in the ASSIGN directive. They must not be expressions. The IF
directive provides for a conditional branch to the macro directive label s inside the
current definition if the relation e1 = e2 holds. The strings e1 and e2 are tested
character by character (excluding blanks) for equality.
In order to compare a character string with a string passed as a macro argument, the
string must be enclosed in quotes when the macro is invoked and then the MACRO IF
compares the argument with an unquoted string; i.e., if the definition is as follows:
MACRO test(arg)
MACRO IF(arg = top) LAB1
...
MACRO LAB1: CONTINUE
MACRO END

and the invocation is:


test("top")

then the macro will expand via LAB1.

6.4.9 MACRO
INCREMENT

See Arithmetic macro directives.

Page 6-8 ACSL Reference Manual


6.4 Macro directive statements 6. Macro Language

6.4.10 MACRO
MULTIPLY

See Arithmetic macro directives.

6.4.11 MACRO PRINT

FORM: MACRO PRINT any character string except $ or ;

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 (;). This directive lists the character string on the output device. It
will override any global list control. The primary use is for you to diagnose your own
errors at invocation time and print out informative messages.
The messages appear with the word "WARNING" at the beginning for easier locating.
they can be suppressed by invoking ACSL with the /NOWARNINGS switch (-w on
Unix systems).

6.4.12 MACRO
REDEFINE

FORM: MACRO REDEFINE v1, v2, ..., vn

where vi are variable names appearing in the body of the macro. REDEFINE identifies
the variables as being locally defined and specifies that they are to be replaced by
unique symbols at each invocation. The generated variables consist of the letter Z
followed by five digits.
The MACRO REDEFINE statement should appear before any statements which
reference the redefined variables, including type declarations.

6.4.13 MACRO
RELABEL

FORM: MACRO RELABEL 11, 12, ..., 1n

where li is an alphanumeric label (i.e., starts with a letter although it may contain
numbers after the first character). 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. These labels must be attached only to ACSL statements, not macro
directive statements (statements beginning with the word 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

ACSL Reference Manual Page 6-9


6. Macro Language 6.4 Macro directive statements

To relabel within a macro loop, call another macro from within the loop; for example:
MACRO MACRO test(p)
MACRO ASSIGN n
...
MACRO L1: CONTINUE
MACRO IF(n=5) L99
mac2(p(n))
MACRO DECREMENT 1
MACRO GO TO L1
MACRO L99: CONTINUE...
MACRO mac2(arg)
MACRO RELABEL xyz
MACRO REDEFINE k
DO xyz k=1,25
... statements that use arg
xyz: CONTINUE
MACRO END

6.4.14 MACRO
STANDVAL

FORM: MACRO STANDVAL arg1 = c1, arg2 = c2 ...


MACRO STANDVAL P(i) = c1, P(j) = c2, ...

where argi are dummy argument names and ci are literal constants that can be real
(single or double precision), integer, or logical. In the second form, i and j are
unsigned integer constants.
The STANDVAL statement is used to provide standard values for arguments of a
macro. If the specified argument is not given in the macro call, then the constant is
used in its place.
Omitted arguments For arguments to be omitted from an argument list, they must be at the end of the list.
Placement The STANDVAL directive must immediately follow the macro header in the
definition if it is used at all.
Example Several of the ACSL operators use this statement. The operator for the second order
transfer function (complex pole), for example, begins as follows:
MACRO cmpxpl(y, p, q, x, ic1, ic2)
MACRO STANDVAL ic1=0.0, ic2=0.0
...

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, t2, yp)

Page 6-10 ACSL Reference Manual


6.5 Macro examples 6. Macro Language

6.5 Macro
examples

The following examples of macro calls demonstrate some of the uses of the directive
statements and of direct parameter substitution.

6.5.1 Sampler

A sampler can be built up of a switch and two zero order holds; for convenience, the
entire sequence can be embedded in a macro and invoked as a function. The
invocation could be:
sample(y = dl, x, yic)

where the sample is repeated every DL of the independent variable, X is the variable to
be sampled, and YIC is the initial value of Y. A macro to handle this could be defined
as follows:
MACRO sample(samp, dl, x, ic)
MACRO REDEFINE d, dt
INITIAL
samp = ic
END
DISCRETE d
INTERVAL dt=0.0
dt = dl
samp = x
END
MACRO END

Note that the output name must always be included in the argument list. (This
requirement for macros is distinguished from Fortran functions, where the single result
is returned into the name of the function.) At the sample time, the DISCRETE section
is executed. This action saves the input value X as output value SAMP, which is
substituted with the appropriate name from the macro invocation.

6.5.2 Dot product

The following call could be used to take the vector dot product of two arrays A and B:
x = DOT(a, b)

where X is a scalar and A and B are vectors previously dimensioned in a DIMENSION


statement. Since it is a function and thus has one output, the operator can be embedded
in an arithmetic expression of arbitrary complexity. The dimension of the vectors may
change, so it should not be specified in the call.
Second type The second form of the macro header is required in order to handle the array
dimension. See Figure 6-1 for a listing of a DOT macro. The header designates P as
the primary variable and Q as the secondary variable; Q accesses the dimension of the
corresponding primary argument.
REDEFINE The REDEFINE statement ensures the variable I will not conflict with any other use.
If this were omitted, a program variable I could have its value changed when the
macro is executed, a potentially disastrous effect.

ACSL Reference Manual Page 6-11


6. Macro Language 6.5 Macro examples

MACRO MACRO dot(p, q)


MACRO RELABEL loop
MACRO REDEFINE i
MACRO IF(q(2)=q(3)) ml1
MACRO PRINT Conflicting dimensions in dot product
MACRO EXIT
MACRO ml1: CONTINUE
PROCEDURAL(p(1) = p(2), p(3))
p(1) = 0.0
DO loop i = 1, q(2)
p(1) = p(1) + p(2)(i)*p(3)(i)
loop: continue
END ! of procedural
MACRO END

! Invocation of dot macro


DIMENSION y(10), z(10)
dot(x = y, z)

Figure 6-1. DOT product macro and invocation

Dimensions The test of Q(2) and Q(3) is needed to see if the second and third arguments have the
same dimension; if not, the DOT product is undefined and a macro error message is
printed. If the dimensions are correct, the DO loop summation is formed. 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.
MACRO IF The MACRO IF must branch to another macro directive statement, hence the label is
attached to a MACRO CONTINUE. This label can not be attached to the following
statement since it is not a macro directive statement but an assignment statement.
Expansion At invocation time, the variable I is changed into a unique translator-generated
variable (Z99999). The call shown in Figure 6-1 results in the macro being translated
into the following code:
INTEGER Z99999
X = 0.0
DO 99999 Z99999 = 1, 10
99999: X = X + Y(Z99999)*Z(Z99999)

If the call to DOT is embedded functionally in an expression, 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.

6.5.3 Pressure tank

This pressure tank example illustrates the use of concatenation in macros. A similar
example (physiological benchmark PHYSBE) appears in Appendix A.
Concatenation One of the problems with using macros is the tendency to generate large numbers of
dummy variables (Znnnnn) which have no mnemonic meaning. All REDEFINEd
variables have this form. An alternate approach is to use the concatenation feature to
build unique symbols that are available for plotting or printing. This technique can
also reduce considerably the length of the argument list; using a long argument list is
the other alternative when unique symbolic names are required.

Page 6-12 ACSL Reference Manual


6.5 Macro examples 6. Macro Language

Definition In this example, a macro is defined for a gas holding tank. The flow into the tank is
calculated as the difference in pressure divided by a resistance. Total pressure is the
integrated net flow divided by a volume. The macro definition is thus:
MACRO tank(n)
f&n&i = (p&n&i - p&n)/r&n&i
p&n = (INTEG((f&n&i - f&n&o)/v&n, p&n&ic)
MACRO END

Invocation The basic equations for different vessels (tank 1 and tank 3, for example) can now be
established in the model by the statements:
tank(1)
tank(3)

Expansion The invocation TANK(3), for example, generates the following translated code:
F3I = (P3I - P3)/R3I
P3 = INTEG((F3I - F30)/V3, P3IC)

Constants and Constants must be defined elsewhere for the resistance R3I, the volume V3, and initial
variables pressure P3IC. Variables which must be defined elsewhere are the input pressure node
P3I and the output flow F3O. This macro then makes available to other sections of the
simulation the input flow F3I and tank pressure P3.
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, p3 = p3i, r3i, f3o, v3, p3ic)

Advantages of The trade-off in deciding how to define the macro can be stated generally as follows:
concatenation Without the concatenation feature, argument lists become long and complicated, but
argument lists have the advantage of flexibility in naming; in addition, arguments can
be expressions. Using the concatenation feature, the argument list is simple: one
argument (usually a literal constant, but can an alphanumeric variable name). An
alternative TANK macro could have the output flow and downstream pressure
specified in the argument list since these are likely to be expressions; e.g.,
MACRO tank(n, pi, fo)
f&n&i = (pi - p&n)/r&n&i
p&n = INTEG((f&n&i - (fo))/v&n, p&n&ic)
MACRO END

The invocation of this macro could, for example, substitute a variable name for inlet
pressure PI and an expression for the outlet flow FO, as follows:
tank(1, psource, (p1 - p5)/r51)

The disadvantage of the concatenation approach is the inflexibility in naming


convention, but if you have control of the model design, you can use this to advantage.

6.5.4 Matrix operations

Matrix operations such as addition, multiplication, negation, and transposition can be


defined by macros. Macros for these four operations are listed in Figures 6-2 through
6-5 and the macro for matrix multiply (MMUL) is discussed in detail.
Note that matrix operations are usually characterized by an n-cubed operation count
and can be expensive for large matrices.

ACSL Reference Manual Page 6-13


6. Macro Language 6.5 Macro examples

!-----------------------------Matrix Multiply. Calling sequence is:


!
! mmul(c = a, b)
!
! This defines a new matrix C of dimension col(A) by row(B) and
! performs the matrix multiplication

MACRO MACRO mmul(p, q, r)


MACRO RELABEL L110
MACRO REDEFINE j, k, l
MACRO IF (r(2)=q(3)) ok
MACRO PRINT Row dimension 1st arg unequal to col dimnsn 2nd arg
MACRO EXIT

MACRO ok..CONTINUE
DIMENSION p(1)(q(2), r(3))
PROCEDURAL(p(1) = p(2), p(3))
DO L110 k = 1, r(3)
DO L110 j = 1, q(2)
p(1)(j,k) = 0.0
DO L110 l = 1, r(2)
p(1)(j,k) = p(1)(j,k) + p(2)(j,l)*p(3)(l,k)
L110: CONTINUE
END ! of procedural
MACROEND

Figure 6-2. Matrix multiply macro

Matrix multiply The MMUL operator (listed in Figure 6-2) uses the second type of macro definition
macro header, 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.
The reason the arrays must be dimensioned before the macro call is that the ACSL
translator makes only one pass over the input source code to generate text; the second
pass is a sorting operation.
Dimensions All matrices must be doubly dimensioned; single dimension vectors may be
dimensioned either (1, n) for row vectors or (n, 1) for column vectors. Only matrices
input to the macro must be dimensioned; output matrices have their dimensions
calculated and defined appropriately. In the following example, input matrices A and B
are dimensioned in a DIMENSION statement; X, which is input in the third line, has
been dimensioned by virtue of being output from the macro in the previous line.
Reversing the order of the calls for X and Y would not work.
DIMENSION a(3, 2), b(2, 3)
MMUL(x = a, b)
MMUL(y = x, a)

Invocation The calling sequence for MMUL is defined as follows:


MMUL(C = A, B)

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]; if not, a message is written out to you.

Page 6-14 ACSL Reference Manual


6.5 Macro examples 6. Macro Language

!-----------------------------matrix add. Up to 4 matrices can be


! added into an output matrix which is created automatically.
! Calling sequence:
!
! madd(y = a, b, ..., d, e)
!
! where the input matrices must have exactly the same dimen-
! sions (both rows and columns) and this will be the size of
! the output matrix Y.

MACRO MACRO madd(p, q, r)


MACRO RELABEL L110
MACRO REDEFINE j, k
MACRO ASSIGN n
DIMENSION p(1)(q(2), r(2))
MACRO IF (n=3) 3
MACRO IF (n=4) 4
MACRO IF (n=5) 5
MACRO IF (n=6) 6

MACRO PRINT Too many or too few arguments to matrix add


MACRO EXIT

MACRO 3: CONTINUE
PROCEDURAL(p(1)=p(2), p(3))
DO L110 k=1,r(2)
DO L110 j=1,q(2)
p(1)(j,k) = p(2)(j,k) + p(3)(j,k)
L110: CONTINUE
END ! of procedural
MACRO EXIT

MACRO 4: CONTINUE
PROCEDURAL(p(1)=p(2), p(3), p(4))
DO L110 k=1,r(2)
DO L110 j=1,q(2)
p(1)(j,k) = p(2)(j,k) + p(3)(j,k) + p(4)(j,k)
L110: CONTINUE
END ! of procedural
MACRO EXIT

MACRO 5: CONTINUE
PROCEDURAL(p(1)=p(2), p(3), p(4), p(5))
DO L110 k=1,r(2)
DO L110 j=1,q(2)
p(1)(j,k) = p(2)(j,k) + p(3)(j,k) + p(4)(j,k) + p(5)(j,k)
L110: CONTINUE
END ! of procedural
MACRO EXIT

MACRO 6: CONTINUE
PROCEDURAL(p(1)=p(2), p(3), p(4), p(5), p(6))
DO L110 k=1,r(2)
DO L110 j=1,q(2)
p(1)(j,k) = p(2)(j,k) + p(3)(j,k) + p(4)(j,k) + p(5)(j,k) + p(6)(j,k)
L110: CONTINUE
END ! of procedural
MACRO EXIT
MACRO END

Figure 6-3. Matrix add macro

ACSL Reference Manual Page 6-15


6. Macro Language 6.5 Macro examples

!-----------------------------Matrix Negate. The output matrix is


! created and the input matrix is moved into it, changing the
! sign of each element on the way

MACRO MACRO mnegat(p, q, r)


MACRO RELABEL L110
MACRO REDEFINE j, k
DIMENSION p(1)(q(2), r(2))
PROCEDURAL(p(1) = p(2))
DO L110 k = 1, r(2)
DO L110 j = 1, q(2)
p(1)(j,k) = -p(2)(j,k)
L110: CONTINUE
END ! of procedural

MACROEND

Figure 6-4. Matrix negate macro

Three matrices can be multiplied together with a call such as:


MMUL(y = a, MMUL(b, c))

which can be expressed mathematically, in the given order:

Y = [A][B][C]

!-----------------------------Matrix Transpose. The output matrix is


! created and the input matrix is moved into it, swapping rows
! and columns on the way

MACRO MACRO mtrans(p, q, r)


MACRO RELABEL L110
MACRO REDEFINE j, k
DIMENSION p(1)(r(2), q(2))
PROCEDURAL(p(1) = p(2))
DO L110 k = 1, r(2)
DO L110 j = 1, q(2)
p(1)(k,j) = p(2)(j,k)
L110: CONTINUE
END ! of procedural

MACROEND

Figure 6-5. Matrix transpose macro

Page 6-16 ACSL Reference Manual


6.6 Macro invocation 6. Macro Language

6.6 Macro
invocation

Once a macro has been defined, it must be invoked with specific arguments listed for
substitution.
Single output One form of call is to embed the macro name in an arithmetic expression. For this
form, only one output (a single number) should be produced by the macro. An
example of this form is:
x = 5.0*SIN(DOT(a, b)/4.0)

where the DOT product macro is embedded in the argument of the SIN function. A
and B in this case correspond to the second and third argument of the macro,
respectively; the output is the (understood) first argument.
Standalone forms An alternative form of the call is as a standalone statement, which has two forms as
follows:
DOT(x = a, b)
DOT(x, a, 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; i.e., no error would result if the operator were invoked as
follows:
DOT(x, a = b)

but it would be misleading to the user. Note especially that


x = DOT(a, b)

is an assignment statement and the name X is not substituted for the first argument.
Only a single numerical value can be passed across the equal sign of an assignment
statement.
On the other hand, consider a matrix integration operator which might be invoked as
follows:
matint(x, xd = a, xic)

In this call, two entire vectors are the output of the operator and have their values
effectively passed across the equal sign. Passing more than one value across an equal
sign is possible only in macro and subroutine calls.
Argument The substitution of macro arguments is by replacement of the character string forming
substitution the argument with the substitutable name. Where expressions are used, the wrong
answer can be obtained if parentheses are not placed around the argument. For
example, consider a macro to integrate a difference in flow rate as follows:
MACRO accum(tot, w1, w2, ic)
tot = INTEG(w1 - w2, ic)
MACRO END

At invocation, an expression for net flow out becomes:


accum(mass = win, wp1 + wp2, massic)

which produces the line of code:


MASS = INTEG(WIN - WP1 + WP2, MASSIC)

ACSL Reference Manual Page 6-17


6. Macro Language 6.6 Macro invocation

Use of parentheses This result is not exactly right, since the second flow WP2 has been made positive.
The solution, when the operator precedence can cause a problem, is to surround the
substitutable name with parentheses. The macro above should have been defined as
follows:
MACRO accum(tot, w1, w2, ic)
tot = INTEG(w1 - (w2), ic)
MACRO END

Now at substitution the executed statement is:


MASS = INTEG(WIN - (WP1 + WP2), MASSIC)

It is not necessary to enclose the first parameter, W1, in parentheses since any
expression substitution gives the correct answer. Trouble usually arises when
arguments are negated, multiplied, divided by other variables, or used as a divisor in
the macro division.

Page 6-18 ACSL Reference Manual


7. Debugging

7.1 Debugging
procedure

One of the important features of the ACSL language is the availability of tools to
assist in pinpointing errors. These tools include informational messages, error
messages, and debug dumps. This chapter outlines the debugging procedure and
explains the debug dump, the messages produced by the variable step integration
algorithms, and the messages produced by the Jacobian evaluation. ACSL error
messages (from both the translator and the runtime executive) are listed alphabetically
in Appendix F along with an explanation for each and often a suggested remedy.
Start translation When you start the ACSL system (see the ACSL Sim User's Guide document), it
translates the model source code onto a Fortran compile file, compiles the Fortran into
an object file, links or loads the object files with libraries needed for runtime
execution, and finally executes the program, arriving at the ACSL prompt, which on
most systems is:
ACSL>

At this point, ACSL is waiting for runtime commands.


Translation errors The first run through the translator often produces messages indicating syntax errors
(probably the most common error) and/or semantic errors. Semantic error messages
are listed in Appendix F. The translator analyzes each model code statement in turn. If
it encounters a syntax error, it writes out the statement in error, including any
continuations, with a line of asterisks underneath the acceptable part of the statement.
The asterisks thus stop just before the error. For example:
X = Y + (SIN(Y.Y))
...Syntax error....the line is listed with a pointer to the error
X = Y + (SIN(Y.Y))
**************

Here the asterisks appear under everything through the first Y in the argument to the
SIN function, but not under the period, indicating that the period separating the two Y's
is not allowed; it undoubtedly should be an asterisk, for multiplication.
Finds only first Two points should be noted about the error messages. The first point is that only the
error in line first error in the statement will be indicated. If this error is corrected, a second (or
third) run may be needed to uncover other problems further into the statement. When
making a correction, you should take a long hard look at the rest of the statement.
Continuation The second point is that if continuation statements are used, the line listed may not
statements look exactly like the input text. The error listing gives the complete string to be
analyzed after the blanks have been squeezed from any continued statements.
Search for .... Translation errors can be found in the translator output file by searching for "....".
Avoiding these in the program code makes it easier to search for errors with an editor.
Spelling errors After correcting translation errors, check for misspellings. Names may be typed
incorrectly and intended changes may be overlooked. Any variables listed under

ACSL Reference Manual Page 7-1


7. Debugging 7.1 Debugging procedure

Symbol used but not defined are probably misspellings, constants left unspecified, or
correct variables that had their names misspelled at the statements defining them.
FORTRAN The ACSL translator catches most errors that would also fail at the compiler stage;
compilation errors however, occasionally a compiler error is produced. The name of the compile file
depends on your computer system. For example, on Unix systems, the default file
name is model.f; on PC systems, model.FOR. If you find any compiler errors, refer to
your FORTRAN manual for details. Correct the ACSL program code, then begin the
translation process again.
Unsatisfied Next, take note of any unsatisfied external references listed in the load map. These
external may correspond to arrays not declared in a DIMENSION statement; without the
references declaration, they look just like functions. Another possibility is a referenced library
that has not been specified in the link or load statement.
First run For the first run, set the stop condition (the condition in the TERMT statement) to a
small value (typically one communication interval) so that no time is wasted
calculating incorrect values. Also set up a debug action as follows:
SET NDBUG=10,HVDPRN=.T.,tstop=0.1
START

NDBUG specifies the number of DEBUG dumps to be printed. A debug dump is


produced each time a DERIVATIVE or DISCRETE section has been evaluated, and
for each perturbation during a Jacobian evaluation. HVDPRN is set true so that the
debug dumps appear on the screen; this is the system default. The stopping condition
is assumed in this example to depend on a CONSTANT in the program named TSTOP.
Evaluating debug The debug output is probably the most important data to help in debugging; the
dumps previous steps were merely to ensure that the mechanics were correct (commas in the
right place, spelling consistent, etc.). This debug output gives the actual numbers
calculated for every one of the state derivatives and intermediate variables. Look at the
numbers carefully and check for reasonableness using your knowledge of the system
you are trying to model. For example, check that the derivatives are of the sign and
magnitude you expect. The next section in this chapter explains the order of the debug
dump and meaning of the system symbols printed out.
Initial conditions It is a good idea to start with initial conditions nonzero. If there are too many zero
values, the arithmetic calculations can conceal errors. For preference, pick conditions
so the derivatives all have a nonzero value which can be checked. Check the values
that are listed for the constants.
Preset variables The translator presets all user variables to 5.5555E33 (double precision to 5.5555D33
and integers to 55555333). This procedure helps catch variables that are not yet
calculated before being used. If a run stops on an error, large numbers in the debug
dump point out variables which have not been calculated; often these can be traced in
the ACSL or FORTRAN listing to some error in initialization, spelling, or ordering.
Preset derivatives The initialization subroutine presets all derivatives to 3.33333E-33. During the initial
evaluation of the DERIVATIVE section, ACSL checks that all derivatives have
changed from this preset value; if not, an error message is produced to indicate that a
derivative calculation has been skipped:
...Derivative no. N not calculated

Arrays All elements of an array are listed in debug dump if the size of the array is less than
the value of the integer system variable MALPRN (maximum array limit for printout,
default 10). If the array size exceeds MALPRN, the name of the array, its size, and the
value of the last element of the array are printed out; for example:

Page 7-2 ACSL Reference Manual


7.1 Debugging procedure 7. Debugging

A(16) 4.590000000 B(12) 2.000000000

See Appendix C for descriptions of MALPRN and other system symbols.


Initialization test One of the best tests of initialization is to START the same run twice; i.e.,
SET NDBUG=2 ; START
SET NDBUG=2 ; START

The corresponding debug dumps from each run should be the same down to the last
significant digit; if they are not, the second run must be using a value left over from
the first run, indicating that some variable has not been correctly initialized. Be sure
that any random number generators are initialized with the same seed.
First full run Now the time comes to try the first full run. Plan what significant output variables will
enable you to deduce correct model operation. Specify these in an OUTPUT
statement, increase the termination time, and give the START command.
It is at this point that the modeller's skill comes in, to rationalize the behavior of the
simulation in terms of the way the real world system is expected to behave. Once
questionable areas have been uncovered, schedule debug printouts to cover the area of
interest so that as much information is recorded as possible.
ACTION for To obtain debug dumps at a particular time in the run, use the ACTION command. A
debug during run number of dumps can be scheduled either at the beginning of the run or at a point of
interest, such as where the behavior of the system becomes questionable. ACTION
gives a debug printout after each START until an ACTION /CLEAR subcommand is
issued. (See the section on ACTION in Chapter 5 for details.) Typical calls to
ACTION are:
ACTION /VARIABLE=0.0 /VALUE=10 /LOCATION=NDBUG
ACTION /VARIABLE=4.98 /VALUE=50 /LOCATION=NDBUG

System On some computer systems, a run might crash without giving very much diagnostic
debuggers information. In this situation, we suggest using your computer system debugger; for
example, on Unix systems, the -g flag starts up the debugger, and on VAX systems
the /DEBUG switch starts the symbolic debugger. In the debugger, when an abort
occurs, a 'where' or TRACEBACK pinpoints the offending line.
Debugging If there is no Fortran or system debugger to help isolate the problem, try inserting calls
without a system to LOGD (see Chapter 4) or calls to DEBUG along with a diagnostic variable as
debugger follows:
PROCEDURAL
aaaaaa = 1
CALL LOGD(.TRUE.)
END

Place these calls at strategic points in the ACSL program, such as at the beginning and
end of DERIVATIVE and DISCRETE sections, using a different value of AAAAAA
for each call for identification purposes. LOGD forces data logging both to the RRR
file and to the OUTPUT listing. At runtime, put AAAAAA and any other variables of
interest on the OUTPUT list and START a run.
OUTPUT t,aaaaaa, ...
START

Note the last value of AAAAAA before the run crashes. Check the program listing
and/or the Fortran compile file for clues as to which statement after this last call to
LOGD and before the next one (not executed) caused the problem. You may need to
add more calls to further narrow the area of interest and isolate the problem.

ACSL Reference Manual Page 7-3


7. Debugging 7.2 DEBUG printout

Choosing step A possible cause of a model stopping without apparent reason or with a cryptic
size message can be an integration step size that is too large. The step size should never be
larger than the smallest time constant in the model (except in cases where the energy
dies out of the high frequency motion, where the Gear's stiff algorithm can be used to
take larger steps).
Finding time If you don't know the system time constants, there are two methods of determining an
constants with appropriate step size. The frequency analysis command ANALYZE /EIGEN lists the
ANALYZE eigenvalues in ascending order (see the section on ANALYZE in Chapter 5); these are
the reciprocal time constants of the system.
ANALYZE /EIGEN

ACSL's choice of Another approach is to find out what ACSL chooses for a step size with the variable
step size step, variable order algorithm, Adams-Moulton (IALG=1). The system symbols
CSSITG (current step size) and CIOITG (current integration order) can be put on the
PREPARE list for printing and/or plotting.
SET IALG=1
PREPARE T,CSSITG,CIOITG, ...
START
PLOT CSSITG,CIOITG

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
more conservative than necessary, so a slightly larger step is adequate). If the current
step size varies widely, however, consider using one of the variable step algorithms.
Check that the step size is not being constrained by CINT. If it is, increase CINT and
run the simulation again.
The system choice of integration order CIOITG can be factored into the decision on
what order and step size of a fixed step algorithm to use.

7.2 DEBUG
printout

The debug output is generated whenever NDBUG is greater than zero or when a call
to DEBUG appears in the model code. The call to DEBUG is often put on a logical
switch; for example:
LOGICAL dump ; CONSTANT dump=.TRUE.
IF(dump) CALL DEBUG

At runtime, NDBUG can be set before starting the run:


SET NDBUG=10
START

ACTION statements can set NDBUG at any value of the independent variable:
ACTION /VARIABLE=2.0 /VALUE=20 /LOCATION=NDBUG
START

Figure 7-1 shows a debug dump. The listing is divided into three major sections:
system variables, state variables (with derivatives and initial conditions), and algebraic
variables (further divided into common blocks). Each of these sections is described in
more detail below.

Page 7-4 ACSL Reference Manual


7.2 DEBUG printout 7. Debugging

....Debug dump - System Variables. NDBUG is 1, block number 1


T 0. ZZTICG 0. CINT 0.02500000
ZZIERR F ZZNBLK 1 ZZICON 1
ZZSTFL F ZZFRFL T ZZICFL F
ZZRNFL F ZZJEFL F ZZNIST 2
ZZNAST 0 IALG 4 NSTP 1
MAXT 0.01250000 MINT 1.0000E-09

State Variables Derivatives Initial Conditions


TH 1.00000000 Z09997 0. THIC 1.00000000
THD 0. Z09998-16.5097000 THDIC 0.

Algebraic Variables

Common Block /ZZCOMU/


DICT F DPR 57.2958000 DUMP F
FILE 11 G 9.81000000 KDAMP 0.30000000
LENGTH 0.50000000 MASS 1.00000000 THDD-16.5097000
TSTOP 4.99000000 XTH 57.2958000 ZZSEED 55555555

Figure 7-1. ACSL debug dump

NDBUG and The header gives the value of NDBUG (which is decremented at each dump) and the
block number block number. The block number tells you which DERIVATIVE or DISCRETE
section has just been evaluated. The number is assigned by counting all
DERIVATIVE and DISCRETE sections in the order they appear in the program code,
counting the first block as one.
When debug A debug dump is produced at every derivative evaluation as long as NDBUG is
dumps are greater than zero. For example, Runge-Kutta fourth order integration takes four
produced derivative evaluations – one at the beginning, two in the middle, and one at the end.
The independent variable thus appears to advance in half-steps, with two derivative
evaluations each step. There is an additional evaluation prior to each communication
interval (i.e., pass through the DYNAMIC section). Debug dumps are also produced
each time a DISCRETE section is evaluated and for each perturbation during a
Jacobian evaluation.
ACSL system The first seventeen variables in the dump are ACSL system variables. The names
symbols and/or values of certain system variables can be changed from their defaults by
statements in the program (CINTERVAL, VARIABLE, for example). The default set
of system variables is defined as follows:
T Floating point. Independent variable; may have been renamed in a VARIABLE
statement.
ZZTICG Floating point. Initial condition of the independent variable; may have been renamed
in a VARIABLE statement.
CINT Floating point. Current communication interval; may have been renamed in a
CINTERVAL statement.
ZZIERR LOGICAL. Variable step error flag; may have been renamed in an ERRTAG
statement. It becomes TRUE if the variable integration algorithm attempts to take a
step size smaller than MINT.
ZZNBLK INTEGER. Number of DERIVATIVE plus DISCRETE blocks in use. Several of the
other system variables are arrays of length ZZNBLK; i.e., ZZNIST, ZZNAST, IALG,
NSTP, MAXT, MINT.

ACSL Reference Manual Page 7-5


7. Debugging 7.2 DEBUG printout

ZZICON INTEGER. Distinguishes pre-initial (0), START (1), and CONTINUE (2).
ZZSTFL LOGICAL. Stop flag; starts FALSE, eventually set TRUE by TERMT or by an
operator interrupt.
ZZFRFL LOGICAL. First flag; set TRUE at first derivative evaluation of every integration step.
ZZICFL LOGICAL. Initial condition flag; set TRUE for the first derivative evaluation of every
run, immediately after initial conditions have been transferred to states.
ZZRNFL LOGICAL. Reinitialize flag; set TRUE by REINIT, used during initialization
(ZZICFL=.TRUE.), and then turned FALSE.
ZZJEFL LOGICAL. Jacobian evaluation taking place when TRUE. The Jacobian is evaluated
for some ANALYZE operations and during integration with the Gear's stiff algorithm.
ZZNIST INTEGER. Array of length ZZNBLK; number of integration state variables in each of
the DERIVATIVE and DISCRETE blocks.
ZZNAST INTEGER. Array of length ZZNBLK; number of algebraic state variables in each of
the DERIVATIVE and DISCRETE blocks.
IALG INTEGER. Array of length ZZNBLK; integration algorithm number to be used for
each block, zero for DISCRETE sections; may have been renamed in an
ALGORITHM statement.
NSTP INTEGER. Array of length ZZNBLK; communication interval divisor for each block;
may have been renamed in a global NSTEPS statement.
MAXT Floating point. Array of length ZZNBLK; maximum integration step size for each
block; may have been renamed in a global MAXTERVAL statement.
MINT Floating point. Array of length ZZNBLK; minimum integration step size for each
block, value of INTERVAL for DISCRETE sections, -1 for DISCRETE sections
without an INTERVAL statement; may have been renamed in a global MINTERVAL
statement.
Arrays Several system variables (ZZNIST, ZZNAST, IALG, NSTP, MAXT, and MINT)
become arrays when there is more than one DERIVATIVE and/or DISCRETE block
in the program. See the section on DERIVATIVE in Chapter 4 for more details.
State variables, Next in the debug print out is the list of state variables in DERIVATIVE block order
derivatives, and and in alphabetical order within each block. Each state is listed with it corresponding
initial conditions derivative and initial condition on the same line. If the line width (see PCWPRN,
TCWPRN, and HVDPRN) is sufficient (126), the corresponding value of absolute
error (XERR) and relative error (MERR) are also listed on the same line. In general,
the derivatives will have dummy names (i.e., in the form Znnnnn), except for those
defined by the INTVC integration operator.
Algebraic After the states, the algebraic variables are listed in order of common blocks.
variables

Common blocks First is the single precision common block /ZZCOMU/. Second, if any double
precision variables are used, a double precision common block called /ZZCOMP/
appears. Third, if any character variables are specified, there is a common block called
/ZZCOMC/. The variables in these three blocks are listed in alphabetical order,
reading left to right in rows. Then come any common blocks you have specified, with
the variables given in the order you specified when defining the blocks. In Figure 7-1,
there are no user-specified common blocks.
Equivalence Any EQUIVALENCEd variables are listed at the end of each block.

Page 7-6 ACSL Reference Manual


7.3 Variable Step Algorithm Messages 7. Debugging

ZZSEED System variable ZZSEED is the random number seed variable, which changes with
every call for a new random number (i.e., using GAUSS, UNIF, or OU).
Value of A value of I in the output stands for infinity. A value of R stands for NaN (not a
I or R number). This indicates that the bit pattern does not correspond to a floating point
format, which often occurs when a floating point variable contains integer data, or
when dividing zero by zero.

7.3 Variable Step


Algorithm
Messages

A summary message is produced at the end of a simulation run when using one of the
variable step integration algorithms; i.e., IALG = 1 (Adams-Moulton), IALG = 2
(Gear's Stiff), IALG = 8 or 9 (Runge-Kutta-Fehlberg second or fifth order) or
IALG=10 (DASSL). Unless the summary is suppressed by setting the ACSL system
symbol WESITG (write error summary) to FALSE, the message is produced and
appears in the following form:
COUNT OF TIMES STATE CONTROLLED STEP SIZE
MINUS (-) REL ERR ALWAYS BELOW ABS ERR
ST1 PC FAIL 0 ERR CONTROL 15-
ST2 PC FAIL 0 ERR CONTROL 1
ST3 PC FAIL 0 ERR CONTROL 127
...

PC FAIL At each time step of a variable step algorithm, a predictor/corrector (PC) iteration
occurs until the estimated integration error is less than the allowable error specified (or
implied) by the model (see MERROR, XERROR). If all state derivatives fail to
converge to within a given error tolerance within three attempts, the predictor/
corrector iteration is considered to have failed and the state responsible (or the state
with the largest relative error) is marked with the PC FAIL count incremented and the
step size is arbitrarily reduced by a factor of 0.25. Relative error is the ratio of
estimated error to allowable error and can be different for each state variable. The step
size is reduced arbitrarily because convergence failure implies that a discontinuity.
ERR CONTROL If the predictor corrector iteration converges, then an estimate of the actual error made
in the step is calculated. This error estimate is compared with the allowable error. One
state always has the largest relative error, even though in general this will be less than
unity; this state has a corresponding ERR CONTROL counter incremented. The
counter is reported as an ERR CONTROL count in the summary message at the end of
the run. The sum of all the ERR CONTROL counts is approximately the total number
of integration steps taken.
Reducing the If any comparison of estimated error with allowable error exceeds unity (i.e., the
step size estimated error is greater than the allowable error), a reduced step size is calculated
and the predictor-corrector iteration is performed again. This sequence is continued
until the step size is such that all the estimated errors are below the allowable errors.
Note however that only one count is added to the ERR CONTROL vector at each
integration step, and that count is for the state with the largest relative error on the first
calculation of estimated error.
Minus sign (-) The minus sign (-) that follows the ERR CONTROL count is a flag to warn that the
absolute error (XERROR) may be swamping the relative error for this state. Since
absolute error must have the same units as the state, it is possible for this to be
accidentally much larger than that allowed by the relative error specification. Using

ACSL Reference Manual Page 7-7


7. Debugging 7.4 Output for debugging of integration process

the standard defaults of 1.0E-4 for both MERROR and XERROR, if the state value
never exceeds one, then control is always by the absolute error and the minus sign
flags the state. Problems are possible if a state varies over microradians, for example,
where a 0.01% fractional error would be 1.0E-10 and the absolute value is still the
default of 1.0E-4. This is not necessarily a problem, though, since other states may be
more important or may be the controlling states. The minus sign simply indicates that
it is worthwhile examining the conditions.

7.4 Output for


debugging of
integration
process

One of the standard difficulties of producing a working simulation is validating the


data produced by the model. The problem with the OUTPUT and PREPARE
statements is that they record data only every communication interval. There may be
many derivative evaluations between these points of visibility. One of the problems
we've encountered is seeing a derivative with a positive value but the state moves in a
negative direction. The explanation for this can be seen by turning on the ACSL debug
output (NDBUG = positive integer) so that each derivative evaluation can be
examined. This usually exposes the problem since the state moves due to some linear
combination of derivative values and if they are all visible, then the problem can be
explained.
For the above, the derivative seen in an OUTPUT or PRINT line is the derivative
evaluated last before the data recording action. In order for the state to move negative,
there must have been enough negative derivatives prior to the positive one shown by
OUTPUT or PRINT to produce a net negative change. Unfortunately, with large
simulation models of thousands of variables, a single debug listing can go for tens of
pages (with width not constrained to a terminal, it is five variables/line, 55 lines per
page, roughly four pages/1000 variables).

7.4.1 Write Normal


Data (WNDITG)

The important information that determines the evolution of the simulation is the state
values and the derivatives that are making the state move. In order to get just this
information, we introduced an extra system variable WNDITG (write normal data
during the integration). This flag has somewhat differing effects depending on the
integration algorithm but the basic idea is to generate enough information so that the
integration process can be followed.
We ran the single precision version of the missile model (MISSGL.CSL) to generate
sample output using this switch. We chose the missile model because it has twelve
state variables that make it more interesting than just the two in the spring model.
The output is shown in Figures 7-2 through 7-10 for each of the different algorithms.
Euler The simplest one is shown in Figure 7-2 for algorithm three (IALG=3), Euler
integration. With one derivative evaluation per step, the listing shows the current value
of the independent variable as x and the current step size as h. These are the names
that are actually used in the integration routines rather than the user changeable default
names such as T (independent variable) or MAXT (maximum step size). After the step

Page 7-8 ACSL Reference Manual


7.4 Output for debugging of integration process 7. Debugging

Start of step: Order is 1


State/derivative vectors: x = 0.01000000 , h = 0.01000000
1 0. 21.5480003 10000.0000 0. 0.
6 0. 2154.80005 -0.50673878 0. 0.
11 0. 0.02019195

1 0. 2154.80005 -0.50673878 0. 0.
6 0.02019195 0. -47.6358032 0. 0.
11 0. 1.90546012

Figure 7-2. Euler integration (IALG = 3)

size information is listed, the state vector (really the transpose since it is laid out across
the page) and derivative vector are shown.
Runge-Kutta Next in complexity is the Runge-Kutta second order (IALG=4), shown in Figure 7-3.
Now we see the state and derivative after the first derivative evaluation and also for
the second one two-thirds across the step (h). The next state vector is calculated by
adding a weighted sum of these two derivatives (0.25, 0.75) to the original state
vector. Very similar is the fourth order Runge-Kutta shown in Figure 7-4. In this case,
there are four derivative evaluations per step, each one being shown in turn.
Runge-Kutta- The variable step Runge-Kutta-Fehlberg algorithms (IALG=8, 9) are shown in Figures
Fehlberg 7-5 and 7-6. Here we have a number of state extrapolations with derivative
evaluations, and then an estimate of the errors made for each element of the state
vector. This error vector is normalized by dividing the actual estimated error term by
the allowable error (for XERROR and MERROR), so that for a successful step all
entries in the estimated error vector should be less than or equal to one.
In several of these figures, intermediate evaluations have been edited out to save space.

Start of step: Order is 2


State/derivative vectors: x = 0.01000000 , h = 0.01000000
1 0. 21.5480003 9999.99707 0. 0.
6 1.0096D-04 2154.80005 -0.49154842 0. 0.
11 0. 0.01962327

1 0. 2154.80005 -0.49154842 0. 0.
6 0.01962327 0.00143591 -46.4225960 0. 0.
11 0. 1.88084292

Second eval. State/derivative vectors: x = 0.01666667


1 0. 35.9133339 9999.99414 0. 0.
6 2.3178D-04 2154.80005 -0.80103236 0. 0.
11 0. 0.03216222

1 0. 2154.80005 -0.80103236 0. 0.
6 0.03216222 0.00247475 -42.8770714 0. 0.
11 0. 1.7746803

Figure 7-3. Runge-Kutta 2nd order integration (IALG = 4)

ACSL Reference Manual Page 7-9


7. Debugging 7.4 Output for debugging of integration process

Start of step: Order is 4


State/derivative vectors: x = 0. , h = 0.01000000
1 0. 0. 10000.0000 0. 0.
6 0. 2154.80005 0. 0. 0.
11 0. 0.

1 0. 2154.80005 0. 0. 0.
6 0. 0. -50.6738815 0. 0.
11 0. 2.01919460
...
Fourth eval. State/derivative vectors: x = 0.01000000
1 0. 21.5480003 9999.99707 0. 0.
6 9.8116D-05 2154.80005 -0.48548239 0. 0.
11 0. 0.01950018

1 0. 2154.80005 -0.48548239 0. 0.
6 0.01950018 0.00140264 -46.4956970 0. 0.
11 0. 1.88270521

Figure 7-4. Runge-Kutta 4th order integration (IALG = 5)

Start of step: Order is 2


State/derivative vectors: x = 0. , h = 0.01000000
1 0. 0. 10000.0000 0. 0.
6 0. 2154.80005 0. 0. 0.
11 0. 0.

1 0. 2154.80005 0. 0. 0.
6 0. 0. -50.6738815 0. 0.
11 0. 2.01919460

Second eval. State/derivative vectors: x = 0.00500000


1 0. 10.7740002 10000.0000 0. 0.
...
Third eval. State/derivative vectors: x = 0.01000000
1 0. 21.5480003 9999.99707 0. 0.
...
Estimated error: fflg = 0
1 0. 0. 9.6017D-06 0. 0.
6 0.00383310 1.2969D-07 0.82940382 0. 0.
11 0. 0.02700307

State number 8 has largest relative error of 0.82940400

Figure 7-5. Runge-Kutta-Fehlberg 2nd order integration (IALG = 8)

Page 7-10 ACSL Reference Manual


7.4 Output for debugging of integration process 7. Debugging

Start of step: Order is 2


State/derivative vectors: x = 0. , h = 0.01000000
1 0. 0. 10000.0000 0. 0.
6 0. 2154.80005 0. 0. 0.
11 0. 0.

1 0. 2154.80005 0. 0. 0.
6 0. 0. -50.6738815 0. 0.
11 0. 2.01919460

Second eval. State/derivative vectors: x = 0.00250000


1 0. 5.38700008 10000.0000 0. 0.
6 0. 2154.80005 -0.12668470 0. 0.
11 0. 0.00504799

1 0. 2154.80005 -0.12668470 0. 0.
6 0.00504799 0. -49.9143639 0. 0.
11 0. 1.99076092
...
Sixth eval. State/derivative vectors: x = 0.00500000
1 0. 10.7739992 9999.99902 0. 0.
...
Estimated error: fflg = 0
1 0. 0. 3.5304D-08 0. 0.
6 9.1747D-06 7.7587D-09 0.00649173 0. 0.
11 0. 1.1720D-04

State number 8 has largest relative error of 0.00649173

Figure 7-6. Runge-Kutta-Fehlberg 5th order integration (IALG=9)

Adams-Moulton, Moving to the Adams-Moulton and Gear algorithms, outputs from these routines are
Gear listed in Figures 7-7 and 7-8. The current situation is saved in a Nordsieck vector
which maintains the components of a Taylor series expansion to predict the value one
step size (h) away, i.e.;

h2 h3
y(x + h) = y(x) + hy′(x) + y′′(x) + y′′′(x) + 〈
2! 3!

The components of the Nordsieck vector are just the values of the separate terms in the
above equation. It is really the state vector at the current time at the beginning of the
step (Y(X)) and successive derivatives scaled by increasing powers of h. One big
advantage of the Nordsieck vector is the prediction step, which just adds the
components. Changing step size just means multiplying each term by a step size ratio
(r) to a power; i.e., r, r2, r3, ....
References For the details of what is calculated, reference should be made to Gear[2]. The last of
these sequences of outputs is shown in Figure 7-9. This is the output from the DASSL
integrator, and for the details of this, reference is made to Brenan, Campbell, and
Petzold[1].

ACSL Reference Manual Page 7-11


7. Debugging 7.4 Output for debugging of integration process

Start of step: Order is 2


Saved Nordsieck vector: xsv = 8.8520D-04 , hsv = 2.9407D-04
1 2 3 4 5
1 0. 1.90743566 10000.0000 0. 0.
2 0. 0.63367027 -1.3151D-05 0. 0.
3 0. 0. -2.1791D-06 0. 0.

6 7 8 9 10
1 1.0528D-06 2154.80005 -0.04469361 0. 0.
2 5.2415D-07 4.7032D-09 -0.01481967 0. 0.
3 8.6867D-08 1.3981D-09 1.4061D-05 0. 0.

11 12
1 0. 0.00178137
2 0. 5.9077D-04
3 0. -5.1048D-07

Corrector iteration: fail flag 0, count 1


Current Nordsieck vector: x = 0.00130998 , h = 4.2477D-04
1 2 3 4 5
1 0. 2.82273698 10000.0000 0. 0.
2 0. 0.91530144 -2.8065D-05 0. 0.
3 0. 0. -4.5466D-06 0. 0.

6 7 8 9 10
1 1.9907D-06 2154.80005 -0.06606957 0. 0.
2 1.1187D-06 1.5268D-08 -0.02134572 0. 0.
3 1.8124D-07 2.9169D-09 2.9337D-05 0. 0.

11 12
1 0. 0.00263362
2 0. 8.5117D-04
3 0. -1.0651D-06

Current error relative to maximum


1 0. 3.1249D-04 -2.4776D-08 0. 0.
6 8.9358D-06 -1.2254D-08 -0.01797453 0. 0.
11 0. 3.6729D-04

Corrector converged.
Sum of all derivative differences
1 0. 5.9605D-08 -2.4776D-08 0. 0.
6 8.9358D-10 -2.6405D-09 -1.7975D-06 0. 0.
11 0. 3.6729D-08

State 8 has largest relative error of 0.01797450


Scaled error that must be less than unity is 0.00149788

Figure 7-7. Adams-Moulton integration (IALG = 1)

Page 7-12 ACSL Reference Manual


7.4 Output for debugging of integration process 7. Debugging

Start of step: Order is 1


Saved Nordsieck vector: xsv = 0. , hsv = 1.00000000
1 2 3 4 5
1 0. 0. 10000.0000 0. 0.
2 0. 2154.80005 0. 0. 0.

6 7 8 9 10
1 0. 2154.80005 0. 0. 0.
2 0. 0. -50.6738815 0. 0.

11 12
1 0. 0.
2 0. 2.01919460

Corrector iteration: fail flag 0, count 1


Current Nordsieck vector: x = 0.01000000 , h = 0.01000000
1 2 3 4 5
1 0. 21.5480003 9999.99512 0. 0.
2 0. 21.5480003 -0.00455353 0. 0.

6 7 8 9 10
1 1.8642D-04 2154.80005 -0.45535287 0. 0.
2 1.8642D-04 3.4438D-05 -0.45535287 0. 0.

11 12
1 0. 0.01864164
2 0. 0.01864164

Current error relative to maximum


1 0. -0.00344383 0.00455353 0. 0.
6 -1.86416483 -1.5982D-04 -513.859131 0. 0.
11 0. 15.5030489

State number 12 has largest error


Corrector iteration: fail flag 0, count 2
Current Nordsieck vector: x = 0.01000000 , h = 0.01000000
1 2 3 4 5
1 0. 21.5480003 9999.99512 0. 0.
2 0. 21.5480003 -0.00455355 0. 0.

6 7 8 9 10
1 1.8642D-04 2154.80005 -0.45535532 0. 0.
2 1.8642D-04 2.4861D-05 -0.45535532 0. 0.

11 12
1 0. 0.01864206
2 0. 0.01864206

Current error relative to maximum


1 0. 9.5778D-04 2.4492D-08 0. 0.
6 -4.1162D-05 4.4449D-05 0.02449157 0. 0.
11 0. -0.00420351

Corrector converged.
Sum of all derivative differences
1 0. -2.4861D-07 0.00455355 0. 0.
6 -1.8642D-04 -2.4861D-05 -0.05138346 0. 0.
11 0. 0.00154988

Figure 7-8(a). Gear stiff Integration (IALG = 2)

ACSL Reference Manual Page 7-13


7. Debugging 7.4 Output for debugging of integration process

State 8 has largest relative error of 513.835000


Scaled error that must be less than unity is 256.917000
Step change factors at different orders
Best factor 0.02495530 : factor current order 0.02495530
Factor one lower 0. , factor one higher 0.
Corrector iteration: fail flag 1, count 1
Current Nordsieck vector: x = 2.4955D-04 , h = 2.4955D-04
1 2 3 4 5
1 0. 0.53773743 10000.0000 0. 0.
2 0. 0.53773743 -3.1510D-06 0. 0.

6 7 8 9 10
1 1.2557D-07 2154.80005 -0.01262654 0. 0.
2 1.2557D-07 5.7891D-10 -0.01262654 0. 0.

11 12
1 0. 5.0318D-04
2 0. 5.0318D-04

Current error relative to maximum


1 0. -1.4447D-09 3.1510D-06 0. 0.
6 -0.00125570 -2.6866D-09 -0.19296737 0. 0.
11 0. 0.00715956

Corrector converged.
Sum of all derivative differences
1 0. -1.4447D-13 3.1510D-06 0. 0.
6 -1.2557D-07 -5.7891D-10 -1.9297D-05 0. 0.
11 0. 7.1596D-07

State 8 has largest relative error of 0.19296700


Scaled error that must be less than unity is 0.09648370

Figure 7-8(b). Gear's stiff integration (IALG=2)

Iteration before If models have algebraic constraints, then there must be an iteration before any
derivative derivative evaluation to drive the residuals to zero. This is also made visible via the
evaluation WNDITG flag. The new BOILER.CSL model described in the Appendix has two
algebraic constraints and Figure 7-9 shows one iteration to drive the residuals to zero
prior to a derivative evaluation using Euler (IALG=3). The information here is
essentially the same as that generated by the ANALYZE/TRIM command and
described under the ANALYZE command. The convergence however is when the
actual step is less than all the allowable errors in these states.

Page 7-14 ACSL Reference Manual


7.4 Output for debugging of integration process 7. Debugging

State vector - iteration number 1


MV 0.53387800 TL 139.802000
Residual vector - current rms 12.9154000 previous 1.0000E+37
Scaled residual is 902.827000 previous 1.0000E+37
Z99992 5.0259E-04 Z99990-1805.65000

Newton step 0.32581800 steep desc step 0.20191800


Relative step 40.0125000 mu 0

State vector - iteration number 2


MV 0.53062500 TL 139.477000
Residual vector - current rms 0.00700697 previous 12.9154000
Scaled residual is 0.48896600 previous 902.827000
Z99992 6.1512E-05 Z99990 0.97729500

Newton step 1.7195E-04 steep desc step 1.1142E-04


Relative step 0.08816350 mu 0
T 0.50000000 RESIDMV 9.5367E-07 RESIDTL 0.00439453

State vector - iteration number 1


MV 0.53063400 TL 139.477000
Residual vector - current rms 3.1521E-05 previous 1.0000E+37
Scaled residual is 0.00221420 previous 1.0000E+37
Z99992 9.5367E-07 Z99990 0.00439453

Newton step 7.3193E-07 steep desc step 5.2732E-07


Relative step 0.00115801 mu 0

Figure 7-9. Iteration to solve algebraic constraints

7.4.2 Write Extra


Data (WXDITG)

Jacobians can be very high volume in some cases since the size goes up by the square
of the number of state variables. The printing of these matrices is controlled separately
by another system variable, WXDITG, or write extra data during the integration.
Figure 7-10 shows the output taken from the BOILER.CSL model when using the
Gear's stiff integrator (IALG=2). The number of dynamic states leads to a 3x3 matrix.

First Jacobian evaluated - Jacobian matrix:


1 0. 3.4318D-11 -1.0008D-05
2 95.0857162 -0.37937951 66.1989746
3 1.00000000 -9.2765D-05 0.01130192

Figure 7-10. Jacobian value from Gear's stiff integrator (WXDITG = .TRUE.)

ACSL Reference Manual Page 7-15


7. Debugging 7.5 Jacobian Messages

7.5 Jacobian
Messages

Jacobian messages are generated during simulation runs that use the Gear's Stiff
integration algorithm (IALG = 2) or with the runtime command ANALYZE explicitly
for the Jacobian (subcommand /JACOBIAN) or implicitly for eigenvalues (/EIGEN)
or steady state (/TRIM). The messages are produced when the ACSL system symbol
CJVITG (check Jacobian validity) is TRUE (which is the default). The two messages
relating to the Jacobian evaluation are:
Jacobian nonlinear measure for now M and column N is X
Function evaluation not repeatable, row N

Row and column To see how the Jacobian rows and columns are numbered, use the following runtime
numbers command (see the section on ANALYZE in Chapter 5):
ANALYZE /JACOBIAN

The Jacobian The Jacobian is the partial derivative of the derivative vector with respect to the state
matrix variables. It is a square matrix of dimension equal to the number of state variables.
With ANALYZE, the addition of control (/CONTROL) and observable (/OBSERVE)
variables extends the state and derivative vectors, respectively, making the Jacobian
non-square, although it is actually listed out as a square A matrix and possibly
non-square B, C, and D matrices. Freezing some state variables (/FREEZE) reduces
the dimension of the state and derivative vectors together.
Perturbation The Jacobian is calculated numerically by perturbing each of the states first positively,
then negatively, computing the derivative vector for each value. The difference
divided by twice the perturbation produces one column of the matrix for each state as
it is evaluated in turn.
Nonrepeatable The Function evaluation not repeatable message refers to a nonrepeatable derivative
value which is checked by perturbing the state again in the positive direction (only if
CJVITG is TRUE), then checking to see if all derivatives are identical to those
obtained during the first perturbation (i.e., identical to the bit precision of the machine
by a REAL equal or .EQ. test). This test is fairly stringent, and it fails if any iterations
are present in the derivative evaluation code, a relatively rare occurrence. This
guarantees that the state equation:
.
x = F(x, t)

is a true function with no side effects. It returns the same derivative value no matter
how often the function (the model) is evaluated, provided the arguments are identical.
Turn off Turn off the warning messages by setting system symbol CJVITG (Check Jacobian
messages Validity) to FALSE. Setting system symbol TJNITG (Threshold for flagging Jacobian
Nonlinearities) to 1.0 also effectively turns off the messages.
Number of The number of extra derivative evaluations during the Jacobian is determined by both
evaluations CJVITG (check Jacobian validity) and TSMITG (two-sided matrix calculation). The
number of evaluations per state for the various settings of the flags is as follows:
CJVITG TSMITG evaluations
FALSE FALSE 1
FALSE TRUE 2
TRUE FALSE 3
TRUE TRUE 3

Page 7-16 ACSL Reference Manual


7.5 Jacobian Messages 7. Debugging

Controls and When calculating the extended state matrices with control and observable variables,
observables the state vector is extended by the controls and the derivative vector by the
extend matrix observables. In the actual calculation, messages giving row and column number refer
to this expanded matrix. For example, if there are ten states, three controls, and four
observables, a message Function evaluation not repeatable, row 3 refers to the third
derivative. Function evaluation not repeatable, row 12 refers to the second observable,
the output of the C matrix, since the first ten rows are states and the last four are
observables.
Seriousness of The message that the function is not repeatable is not necessarily bad since the Stiff
nonrepeatable integration is fairly forgiving of the accuracy of the Jacobian. However, it is a more
message important indication than the message regarding nonlinearity (described next), and it
deserves investigation into the source of the problem. Nonrepeatability normally
invalidates any results from the ANALYZE command (i.e., eigenvalues, zeros, root
loci, or frequency response plots) and for these applications the message is to be taken
seriously.
Nonlinear The Jacobian nonlinear measure message refers to Jacobian nonlinearity. An attempt
message has been made to identify a nonlinear measure which can be estimated from the
difference between the slopes of the derivative function when perturbed positive and
when perturbed negative. Figure 7-12 shows the function of the state F(x) with a
nominal value in the middle of the box where the perturbation results in a smaller
slope in the positive direction to F(x+dx) than in the negative direction to F(x-dx). If
the system were linear, then the midpoint would lie on the average of the two outer
points; i.e., at (F(x+dx) - F(x-dx))/2. Any deviation of F(x) from this midpoint implies
a nonlinearity.
Normalized A simple difference has units and can not be fixed in value since a change of basis
difference (from meters per second to feet per second, for example) would change the difference
and invalidate any threshold setting. To avoid this problem, the difference is
normalized by the total vertical dimension of the rectangle; i.e., F(x+dx) - F(x-dx). The
nonlinear measure tested can be expressed as follows:

| F(x) − 0.5 (F(x + dx) + F(x − dx)) |


| F(x + dx) − F(x − dx) |

Effect of bowl This expression does not work well if the function lies in the bottom of a bowl; in this
case, the difference between F(x+dx) and F(x-dx) can be a very small number (even
zero), exaggerating any difference of F(x) from the midpoint. If there is only a very
small slope between end points, no message is generated; i.e., for EPMX of 1.0E-6 on
32-bit systems and 1.0E-9 on 60 and 64-bit systems:

| F(x + dx) − F(x − dx) | < EPMX ∗ F(x)

Threshold for The nonlinear measure is tested against a threshold TJNITG (threshold for Jacobian
message nonlinearity, an ACSL system symbol with a default of 0.1). If the threshold is
exceeded, the error message is reported, with the nonlinear measure expressed in a real
number. The message can be suppressed by setting TJNITG to a large number;
1.0E33, for instance.
State at a limit A nonlinear measure of 0.5 may be due to the state sitting at a limit. This is the worst
possible value if the function is monotonic. Assuming a positive limit, a change from
F(x) to F(x+dx) does not change the function value at the limit and the F(x) point lies
at the top bar of the rectangle in Figure 7-11. The difference from the midpoint is
exactly half of the vertical dimension, thus giving a nonlinear measure of 0.5. If the

ACSL Reference Manual Page 7-17


7. Debugging 7.5 Jacobian Messages

Figure 7-11. Perturbation of state F(x)

center point is outside the box of the two end points (a bowl or a roof), then there is no
limit to the size of the nonlinear measure.
Negative It is possible for negative values of the Jacobian nonlinear measure to be reported
measure since the absolute value is not applied. The actual test is on the absolute value of the
difference between the center point and the average of the two outside points, but the
report prints just the difference, as follows:
(0.5*(CPLUS + CMNUS) - CZERO)/(CPLU - CMNUS + 1.0E-30)

where CZERO is the center function value and CPLUS and CMNUS are the values of
the positive and negative perturbations. Thus, center function values above the average
of the two ends, or a decreasing slope from left to right, produces a negative value.
It is again to be emphasized that the messages are not necessarily bad, but they serve
as a warning that the perturbations are showing up real nonlinearities in the system.

Page 7-18 ACSL Reference Manual


7.6 Loss of accuracy with large bias terms 7. Debugging

7.6 Loss of
accuracy with
large bias terms

There is a potential problem in evaluating the Jacobian when small terms coexist with
large ones that nominally cancel. As an example, consider torque applied to an inertia
where the torque is resisted by a small damping term and a spring. The equations are:
nettorque = appliedtorque - damping - spring
damping = k1*thetadot ! k1 is 0.0229
spring = k2*theta ! k2 is 0.1500
thetadotdot = nettorque/inertia

The K1 and K2 values give a damping factor of 0.5 and the inertia just time scales the
problem so its value is immaterial.
The problem is with the NETTORQUE equation in equilibrium with say a 100 Nm
applied torque. In equilibrium, the spring action equals the applied torque and the
damping is zero since the velocity is zero (steady state). In calculating the derivative of
the torque term with respect to velocity (THETADOT) for the Jacobian, a nominal
perturbation of 1.0E-4 is applied (which may be much smaller if specified via the
XERROR and MERROR statements), resulting in:
deltatorque = 100 + 0.0229*1.0E-4 - 100.0

The middle term is very small compared with the hundred, and so the difference
(100.00000229 - 100) is completely lost at single precision; even double precision
loses eight decades of precision (or more if the perturbation has been reduced from the
default).
The solution to the problem is to group terms with parentheses so that large terms are
subtracted before small ones are included. In the example above, we would write:
nettorque = (appliedtorque - spring) - damping

which results in:


nettorque = (100 - 100) - 0.0229*1.0E-4

and the damping term is evaluated with full precision. On some computer systems,
reordering the calculation as follows:
nettorque = appliedtorque - spring - damping

happens to work, but the order of calculation is not guaranteed to be from left to right.
Parentheses force the order.
This is a standard problem with numeric differentiation where relatively large constant
terms are present in the equations.

ACSL Reference Manual Page 7-19


7. Debugging 7.6 Loss of accuracy with large bias terms

Page 7-20 ACSL Reference Manual


8. Application Notes

This chapter describes a number of advanced application techniques.

8.1 Parameter
sweep

This example outlines a procedure to set up parametric studies within a program.


Parameter sweeps differ from Monte Carlo runs in that Monte Carlo models are
pseudo-random (using GAUSS or OU, for example) while parameter sweeps are
orderly. This model uses a sequence of runs in which a parameter (P) is varied from a
low limit (PMN) to a high limit (PMX) by a certain increment (PDL) between runs.
Program structure The model is programmed in explicit structure. Plots are generated with a set of curves
showing the parametric variation. The program structure is:
PROGRAM sweep
INITIAL
p = pmn
loop: CONTINUE
CALL INITD
END ! of initial
DYNAMIC
DERIVATIVE
... model definition (depends on P) ...
END ! of derivative
TERMT(T .GE. tstop)
END ! of dynamic
TERMINAL
CALL LOGD(.TRUE.)
p = p + pdl
IF(p .LE. pmx) GO TO loop
END ! of terminal
END ! of program

INITD utility INITD is a utility routine which clears the event list. The event list notes the times at
which events (such as DISCRETE sections, communication intervals, SCHEDULE
time events) are scheduled to occur. The list is cleared automatically by a START
command, but not in a loop as described above. See Appendix B for more on INITD.
Runtime The runtime commands are then as follows:
PREPARE t,y1,y2, ...
SET FTSPLT=.TRUE.
START
PLOT y1,y2, ...

The independent variable (T) is named as the first variable on the PREPARE list since
the PLOT command assumes the first PREPARE variable is plotted as the X axis.
Flyback trace FTSPLT (flyback trace suppression on plots) is set TRUE to signal the plot command
suppression to lift the pen when the first variable on the PREPARE list is less than its previous

ACSL Reference Manual Page 8-1


8. Application Notes 8.2 Phase and gain plots

value. At the same time, the symbol character is incremented. Each transition from the
INITIAL section into the DYNAMIC section resets the independent variable to its
initial value. This is the characteristic which allows this structure to work for
parametric runs and allows the plots to differentiate the curves.
Single runs Single runs can be easily generated, either by setting the maximum value to the
minimum value:
SET pmx=pmn

or by making the increment very large:


SET pdl=1.0E38

Warning – It is possible with this type of loop that if a TERMT statement is in the DERIVATIVE
TERMT in section and the event list is not cleared, eventually the table space is filled. The
DERIVATIVE problem is that when the run stops in the DERIVATIVE section, an event has been
entered on the event list for the next communication interval. Stopping prematurely
leaves the event on the event list. The event list is not cleared because there may be a
following CONTINUE. This problem does not arise if a call to INITD is included in
the INITIAL section to clear the event list after the loop back. It also does not occur if
the TERMT statement is in the DYNAMIC section since the event is removed from
the list at the communication interval and so does not accumulate.

8.2 Phase and


gain plots

Phase and gain characteristics of a model forced by a sine wave are often useful. With
the system described here, the excitation frequency can be varied logarithmically and
the phase and gain characteristics determined and plotted as a function of this
frequency.
Frequency sweep First a name W, for frequency ω, is established. This variable is swept from minimum
(WMN) to maximum (WMX) by using a geometric progression with multiplier KW
(generally set in the range 1.2 to 1.5). The model structure is as follows:
PROGRAM phase and gain
INITIAL
w = wmn
loop: CONTINUE
END ! of initial
DYNAMIC
DERIVATIVE
... model ...
END ! of derivative
TERMT(...)
END ! of dynamic
TERMINAL
pw = LOG10(w)
CALL LOGD(.TRUE.)
w = w*kw
IF(w .LE. wmx) GO TO loop
END ! of terminal
END ! of program

While the frequency is varied, PW is calculated for the X axis of the plot to be made;
the actual scale will then be logarithmic.

Page 8-2 ACSL Reference Manual


8.3 Summary output 8. Application Notes

Phase and gain To find the phase and gain, assume that the signal is injected into an equation for the
variable F. The gain and phase between F and the output variable X can be expressed:
X
= G(jω)
F
The in-phase (P) and quadrature (Q) components will be given by the following
equations where the integration is taken over any complete cycle:
t

∫ X sin (ω t ) dt
ω
P =
π
ts

∫ X cos (ω t ) dt
ω
Q =
π
ts

Cycle The key to obtaining correct results is to start the integration after sufficient time has
elapsed so that the initial transients have decayed away, then integrate over one
complete cycle. This can be done by logic within either the DYNAMIC or
DERIVATIVE sections; it is usually easier to set the communication interval to force
the full cycle integration. It is immaterial at what point in the drive sine wave the
window begins; any whole cycle is sufficient.
Alternative The technique described here requires a complete simulation run for each point; i.e.,
technique the model code cycles from TERMINAL to INITIAL every time a new frequency
point has been calculated. Another way of generating frequency response in a single
run is described in Section 9 of Appendix A. While the implementation described
there is fairly complicated, it reduces somewhat the time spent for settling (which is
wasted computer time) and also allows more direct control of the phase accuracy
calculated.

8.3 Summary
output

It is often useful to obtain a complete list of all simulation variable values in order to
document the state of the simulation. Setting NDBUG = 1 gives a picture at the very
first derivative evaluation, but this is not as useful as a picture obtained at the end of
the run. In a final value debug dump, initial conditions are still available in the initial
condition arrays, but all other variables document the termination condition.
In order to easily obtain this final value listing, incorporate the following code in the
TERMINAL section:
TERMINAL
LOGICAL dump ; CONSTANT dump = .TRUE.
IF(dump) CALL DEBUG
END ! of terminal

The call to subroutine DEBUG produces the debug dump (explained in detail in
Chapter 7); having the call under the control of a logical variable that can be set at
runtime in order to turn the output on or off is a convenience, especially for interactive
runs.

ACSL Reference Manual Page 8-3


8. Application Notes 8.4 Impulse and step response

8.4 Impulse and


step response

Determining the response of a system to impulses and steps in the control variables is
a common method of checking a simulation model. In most cases it is not necessary to
use special operators as these forcing functions can usually be handled by parameter
changes.
Impulse as An actual impulse is of infinite height and zero time width and so is impossible to
integrator output generate directly. The effects, however, are felt at all integrators the impulse is fed to,
and result is a unity jump in the output of these integrators. The easiest way to
implement this jump in practice is to apply a value to the integrator initial condition
which models receiving the impulse immediately prior to time zero. When the
simulation program starts to execute, it then follows a solution trajectory in response
to this hypothetical impulse.
Impulse example As an example, consider a pendulum model described by the equations:
omega = INTEG(-g*SIN(theta)/l, omegaz)
theta = INTEG(omega, thetaz)

An impulse in force transferred to the pendulum ball at time zero is modeled by


specifying a nonzero value for the angular rate initial condition OMEGAZ.
Determining this rate may need some calculation since it may involve equations
governing momentum transfer. These would apply if, for example, the pendulum bob
were struck with a mallet, and such equations would correctly be placed in the
INITIAL section.
If the impulse is applied at times other than time zero, then the integral equation must
be modified to add in the net integrated impulse; i.e.,
omega = INTEG(-g*SIN(theta)/l, 0.0) + dlomeg

Now the variable DLOMEG (delta OMEGA) is added in and becomes the initial
condition on OMEGA (since the INTEG has an initial condition of zero). In this
configuration, DLOMEG can be changed; and since it is always added to the state
variable or output of the INTEG operator, OMEGA jumps discontinuously when this
happens. If DLOMEG has been changed, it must be reset in the INITIAL section prior
to the start of each run. It itself becomes an effective state variable. Most cases can be
handled by using the initial condition, but when true impulses are applied during a run,
then the added variable becomes necessary (see the aspirin example in Appendix A).
Step response Step responses are a different excitation technique, usually handled by adding a
constant (initialized to zero) at a summing junction, but often loops must also be
broken. A typical requirement is to examine the response of a missile (pitch rate, pitch
angle, and accelerometer reading) to a step in fin deflection. This would normally be
applied at time zero and the dynamic response recorded. Unfortunately, a simple
change of initial condition on the fin angle integrator is not sufficient since after the
run starts, the fin deflection will change due to the dynamics built into the actuator
model. The key now is to break the outer loop and prevent this fin motion; the ease
with which this can be done depends somewhat on the actual fin dynamics model
itself. A simple fin model is a first order lag with a typical time constant of 5 to 50
msec, so motion can easily be stopped by setting temporarily the time constant to
1.0E30. This very large value ensures that the output will remain constant irrespective
of what the input does. Alternatively, there may be a gain between torquer and
velocity integrator which can be made zero, thus ensuring zero derivatives and a
constant output.

Page 8-4 ACSL Reference Manual


8.5 Externally defined variables 8. Application Notes

Parameter names For these types of test cases, it is important that model parameter values be given
symbolic names, preset by CONSTANT statements. The symbolic name enters these
into the ACSL dictionary and the CONSTANT statement is just a preset so values
changed will not be changed back as they would if they were set via an assignment
statement. It is not good practice to specify numbers within the code sequence since no
name can be assigned to the value and the value itself is always fixed, requiring a
re-edit of the program in order to effect any changes.
Step example As an example, for a first order lag fin model with a time constant of 20 msec, two
choices are available:
a) REALPL(dl = 0.020, dlc, dlic)

b) CONSTANT tact = 0.020


REALPL(dl = tact, dlc, dlic)

The second form is far better since now the variable TACT can be changed at runtime
by SET commands. For step responses, the following commands could be used at
runtime to generate the response for a fixed fin deflection of -10 milliradians:
SET tact=1.0E30, dlic=-0.010
START

8.5 Externally
defined variables

It is sometimes necessary to suppress the message Symbol used but not defined that is
generated if names are found that never appear on the left hand side of an equal sign.
This happens with external Fortran subroutines that are communicating with the
ACSL program via the dollar sign in column one (as described in Chapter 1). In order
to tell the ACSL system that these variables are calculated and at the same time enter
the name in the ACSL model dictionary, they may be listed in a dummy
PROCEDURAL block placed anywhere in the program.
Consider variables XF, YF, and ZF, which we know to be defined elsewhere. Add the
following two lines
PROCEDURAL(xf, yf, zf =)
END

This indicates that it is known that the variables XF, YF, and ZF are defined
somewhere. In this method, it is assumed that sorting problems are handled separately.
There is no check that the inside of a PROCEDURAL block agrees with the
input/output list stated on the header. While this can be a useful feature, you should be
careful when using it.

ACSL Reference Manual Page 8-5


8. Application Notes 8.6 Stopping missiles at intercept

8.6 Stopping
missiles at
intercept

Ensuring that a simulation stops at a defined event is a common problem. A solution is


illustrated in the example of stopping a missile simulation at the distance of closest
approach to a target (known as the intercept point). A typical closing velocity for a
modern missile is about 1500 meters/second. A typical integration step required for a
missile simulation is about 10 msec. An integration step thus corresponds to 15 meters
distance, too coarse an interval to determine miss distance (distance of closest
approach), which should be in the range of 1 to 5 meters.
Warning – avoid A technique which is sometimes used, but which should be avoided, is to switch to a
small steps much finer integration step when intercept is near. Typically, switching to an
integration step of 0.1 msec within a time-to-go of 50 msec allows stopping to within
0.15 meters accuracy, adequate for the application. However, the code for this is
clumsy and usually difficult to implement.
Forecast intercept The recommended solution is to continually forecast when the intercept will occur and
adjust the last communication interval so that the integration routine arrives exactly
(neglecting acceleration) at the intercept point. Implementing this method begins with
the relative position and velocity vectors (RMT and VMT), which measure the missile
from the target motion as though the target has been stopped. The distance to the point
of closest approach is the range vector resolved onto the velocity vector:


RMT VMT
VMT 
Time-to-go This quantity divided by the magnitude of the relative velocity vector gives the time to
closest approach (i.e., time-to-go) as follows:

TGO =

RMT VMT
VMT
2

Recomputing The communication interval (CINT) is continually recomputed in the DYNAMIC


CINT section, where CINTZ is the nominal communication interval, by:
CINT = MIN(tgo, cintz)

CINT not In addition, however, a precaution to prevent CINT from becoming negative is
negative necessary. The extrapolation assumes no acceleration, which is a source of inaccuracy,
but in practice time-to-go accuracy turns out to be better than 0.1 msec, so a protection
that the communication interval never goes below a specified minimum and a TERMT
statement to stop the simulation when time-to-go reaches this minimum prevents
CINT from becoming negative. The statements might read as follows:
CONSTANT cintmn = 0.0001, cintz = 0.05
CINT = MAX(cintmn, MIN(tgo, cintz))
TERMT(tgo .LE. cintmn, 'Stop on TGO')

There is still a problem with this formulation if the relative range is increasing at
launch. Once the motor ignites, a missile accelerates rapidly and overtakes the target,
but in the simulation all conditions must be taken into account. In a launch against a
receding target, time-to-go will be negative, so both TERMT and CINT must be
protected. This protection can be implemented with a TFLTMN (time of flight

Page 8-6 ACSL Reference Manual


8.7 State space linear matrix model 8. Application Notes

minimum) parameter on TERMT and by making TGO a large number until the
minimum flight time has been exceeded. Then statements for TERMT and TGO are:
TERMT(tgo .LE. cintmn .AND. T .GE. tfltmn, 'Stop on TGO')
tgo = RSW(T .GE. tfltmn, tgo, 1.0E30)

This sequence shows the build up of complexity as real-life simulation models are
developed and problems with operation are found and resolved. Note that all the
problems have been solved without resorting to IF or GO TO statements.
SCHEDULE Still another approach to finding the missile intercept point is to introduce a
solution SCHEDULE statement to force an iteration on the sign of the closing velocity. When
the dot product of VMT on RMT changes sign from positive to negative, the intercept
point is signalled. This implementation of the SCHEDULE statement ignores the
initial crossing of zero at the beginning of the flight when closing velocity changes
from negative to positive:
SCHEDULE final .XP. DOT(vmt, rmt)

The final iteration is probably not needed for this particular application of a missile
intercept, so we would use the forecasting method, but either technique is acceptable.
The handler block FINAL that stops the model when a zero crossing has been found
can be in the form:
DISCRETE final
TERMT(.TRUE., 'Stop at intercept')
END ! of final

Warning – Be careful of using the following with the SCHDULE statement since for the
incorrect TERMT SCHEDULE operator to work, it must actually cross zero prior to iterating; this sets
with SCHEDULE the stop flag, thereby stopping the run and also the SCHEDULE iteration:
TERMT(tgo .LE. 0.0)

8.7 State space


linear matrix
model

The matrix multiply macro listed in Figure 6-2 can be used to solve the dynamics of
the linear matrix equation:
.
X = [A ] X

The following code fragment handles up to tenth order systems; if fewer than ten state
variables are used, the A array is completed with zeros:
ARRAY x(10,1), xic(10,1), a(10,10)
CONSTANT a = <... 100 numeric values ...>
CONSTANT xic = 1.0, 9*0.0
MMUL(xd = a, x)
x = INTVC(xd, xic)

The derivative vector (XD) is automatically dimensioned to match X; i.e., (10,1). The
code above produces an impulse on the first state in the vector by setting the first
element in the initial condition vector (XIC) to 1.0; to produce impulses on any other
states, change the corresponding elements in XIC to 1.0 using a SET command at
runtime.

ACSL Reference Manual Page 8-7


8. Application Notes 8.8 Full set matrix operations

8.8 Full set


matrix operations

The behavior of an error covariance matrix can be modeled based on the following
matrix differential equation:
.
Σ = A Σ + Σ AT + Ξ − Σ CTC Σ
.
where Σ, Σ, A, and Ξ are three-by-three matrices and C is a one-by-three vector. The
following mnemonic names are used for programming:
.
Σ ≡ SGD
Σ ≡ SG
Ξ ≡ XI

Using the macros defined in Figures 6-2 through 6-6, the calculation can be written on
one line as follows:
ARRAY a(3,3), sg(3,3), c(1,3), sgic(3,3)
MADD(sgd = MMUL(a, sg), MMUL(sg, MTRANS(a)), xi, &
MNEGAT(MMUL(sg, MTRANS(c)), MMUL(c, sg))))

and the derivative is then integrated using the vector integration operator:
sg = INTVC(sgd, sgic)

Dimensions Only the input matrices A, SG, and C and the initial condition vector (SGIC) need to
be dimensioned. The matrix add (MADD) operator automatically dimensions SGD to
be (3,3). SGIC must be dimensioned to match SG for the vector integration operator.
Intermediate In practice, it is probably necessary to calculate some of the intermediate quantities so
variable names that they can be printed, plotted, and checked. The above equations could also be
implemented as follows:
MMUL(ASG = a, sg)
MMUL(sgat = sg, MTRANS(a))
MMUL(sgct = sg, MTRANS(c))
MMUL(csg = c, sg)
MADD(sgd = asg, sgat, xi, MNEGAT(MMUL(sgct, csg)))
sg = INTVC(sgd, sgic)

Providing values for the input arrays A, C, and SGIC defines the evolution of the
system. The ANALYZE /TRIM and /EIGEN can be used to determine the eigenvalues
and the appropriate step size for a fixed step integration algorithm.

8.9 Moving time


backwards

Most dynamic simulations move forward in time, as nature does, but some in some
situations it is useful to simulate time (or some other variable) moving backwards.
This can be accomplished by establishing an independent variable to integrate in the
negative direction as follows:
CONSTANT timeic = 5.0
time = INTEG(-1.0, timeic)

Page 8-8 ACSL Reference Manual


8.10 Plotting averages from Monte Carlo programs 8. Application Notes

Use TIME (or some other name) rather than the ACSL default independent variable T
throughout the program in calculations, and at runtime in printouts and plots. Any
variable name may be used. The name T may also be used if the ACSL default is
changed using the VARIABLE command; for example,
VARIABLE dummy, dumic = 0.0
CONSTANT TIC = 5.0
T = INTEG(-1.0, TIC)

On a related subject, to start from a negative value of time and move forward, simply
specify the initial condition of T using the VARIABLE command; e.g.,
VARIABLE T, TIC =-200.0

8.10 Plotting
averages from
Monte Carlo
programs

In running Monte Carlo or parametric programs (such as described in Section 8.1), it is


sometimes desirable to collect results over a number of runs and plot them. One
approach is to set up an array for the variable (an average, for example), an index into
the array, and a calculation for the average as follows:
INITIAL
DIMENSION avge(100)
INTEGER index, runnum
index = 0
runnum = 0
IF(runnum .EQ. 0) CALL SETR(0.0, avge, 100)
runnum = runnum + 1
...
END
DYNAMIC
DERIVATIVE
...
END ! of derivative
index = index + 1
aplot = avge(index)
avge(index) = (avge(index)*(runnum - 1) + a)/runnum
END ! of dynamic

Note that the average is always the up-to-date average from the beginning of the run; it
is calculated on the fly, so to speak, since the average is defined as the sum so far
divided by the total number of runs. The formula for the average multiplies the old
average by the previous run number, adds the new value of the variable (A), and then
divides by the current run number.
In the following runtime commands, first the parametric data is generated, then a final
START forces a single run. Since APLOT is extracted from AVGE before AVGE is
updated, this last START plays back the previous average.

ACSL Reference Manual Page 8-9


8. Application Notes 8.11 Plotting arrays

PREPARE t,aplot
START
...
START
START
PLOT aplot

With this procedure, each START accumulates a new average. An alternate method
would be to loop back from the TERMINAL section to the INITIAL section, to just
before RUNNUM is incremented, incrementing RUNNUM to some specified
maximum as in a parametric run; then only two START commands are required.
The average can be reset by setting RUNNUM to zero prior to a START.

8.11 Plotting
arrays

Data collected into arrays can be plotted even when it is not a function of the
independent variable. This is accomplished by cycling through the array elements in
the TERMINAL section, then logging the data to the RRR file with LOGD. For
example, if an array is filled as a histogram in the DYNAMIC section as follows:
DIMENSION hx(imax)
INTEGER i, imax
i = (x - xmin)/(xmax - xmin)*imax + 1 ! x into imax bins
i = MAX(1, MIN(imax, i)) ! limit overflow
hx(i) = x(i) + 1 ! increment element

Then in the TERMINAL section:


DO 110 i=1, imax
h = hx(i)
a = (xmax - xmin)*(i - 1)/imax - xmin
CALL LOGD(.FALSE.)
110..CONTINUE

At runtime, add the variables H and A (the abscissa) to the PREPARE list and plot:
ACSL> PREPARE a,h, ...
ACSL> START
ACSL> PLOT /XAXIS=a h

Since data logging during the run saves values for H and A that don't correspond to
any calculated value, the values of H and A should be initialized in the INITIAL
section; zero is probably a good number to choose:
h = 0
a = 0

Page 8-10 ACSL Reference Manual


8.12 Calling subroutines in C 8. Application Notes

8.12 Calling
subroutines in C

Subroutines written in C can be called from ACSL. Just be sure arguments are
received as pointers since FORTRAN passes variables by reference. For example, the
following in ACSL:
INTEGER a
REAL b
DOUBLEPRECISION c
CALL foo(a, b, c)

should appear as follows in C:


void
foo_(int*a, float*b, double*c)
{
...
}

Place all the routines in a library and link the library to the program object code at link
time (see the document ACSL Sim User's Guidefor details).
Underscore Most Unix Fortran systems append an underscore (_) to external C names, which is
why the entry point foo in the example above on Unix systems is shown as:
foo_(...)

As function C routines can also be called as functions from ACSL; in the following calls, Xx is
output.
x = foo(a)

Example Here is an ACSL program to demonstrate the interface between ACSL and C.
VECTEST.CSL is an ACSL program that demonstrates a call to subroutine
VECADD.C. There are two methods for calling the C subroutine: using an equal sign
in the argument list, or calling from within a PROCEDURAL.
program vecadd
! demonstrate interface to C with a vector addition operator
!
array x(3), y(3)
constant x = 1.0, 2.0, 3.0
constant y = 10.0, 20.0, 30.0

!-----call the C routine using an equal sign in the arg list


array sumxy(3)
call vecadd(sumxy = x, y)

!-----now do it with a procedural


array sum(3)
procedural(sum = x, y)
call vecadd(x, y, sum)
end ! of procedural

termt(.true.)

end ! of program

ACSL Reference Manual Page 8-11


8. Application Notes 8.12 Calling subroutines in C

The C subroutine contains ifdef statements to handle differences between various


systems such as Cray, Microsoft PowerStation, Watcom, and VMS. VECADD.C is an
example that should work on any known system. IFDEF's are only needed for those
systems that are not standard.

/* *********************************************************
*
* PURPOSE: demonstrate C interface to ACSL programs
*
* INPUTS: two single precision vectors ("a" amd "b")
* OUTPUTS: the single precision sum of the input vectors
*
** ******************************************************/
#ifdef cray
#define vecadd_ VECADD
#endif

#ifdef usoft
#define vecadd_ __stdcall VECADD
#endif

#ifdef watcom
#pragma aux VECADD "*"
#define vecadd_ VECADD
#endif

#ifdef vms
#define vecadd_ vecadd
#endif

void
vecadd_(a, b, c)
float *a, *b, *c;
{
*c++ = *a++ + *b++;
*c++ = *a++ + *b++;
*c = *a + *b ;
}

Run the model as follows, compiling the C routine first and adding its object file to the
ACSL command.
cc -c vecadd.c
acsl vectest vecadd.o
ACSL> display/all
ACSL> start
ACSL> display/all
ACSL> quit

On the Cray, Microsoft PowerStation, Watcom, or VMS system, add the appropriate
-D flags to the C compiler command line (i.e., cc -Dcray -c).

Page 8-12 ACSL Reference Manual


8.13 Synchronizing DISCRETE events 8. Application Notes

8.13
Synchronizing
DISCRETE events

Let's say your model has three DISCRETE sections that run at 1.0, 0.1, and 10.0
second intervals. What happens at the 10 second interval? If you do not care about the
order of execution of the three DISCRETE sections when their events coincide, then
each section can be described with its own INTERVAL statement:
DISCRETE a
INTERVAL dta = 1.0
...
END ! of a
DISCRETE b ! section with
INTERVAL dtb = 0.1 ! relatively
... ! small interval
END ! of b
DISCRETE c ! section with
INTERVAL dtc = 10.0 ! relatively
END ! of c ! large interval

With this structure, the relative order of execution of the sections is indefinite at the
1.0 second and 10 second intervals. If these sections control independent processes
that do not depend on each other and are in fact unsynchronized in the real world, then
this model is a good representation.
When you are modeling major and minor cycles of the same process, it is often
necessary to specify who goes first, what goes second, and I don't know goes third.
You accomplish this by putting an INTERVAL statement only in the section to be
executed first in the case of a tie. Then SCHEDULE statements activate the other
sections in the order desired.
In the example above, assume the order desired to be:
ABC at 0.0 and at every 10 seconds thereafter
AB at every 1.0 second interval

This order can be set up by the code outlined below. The code in section A determines
how many times (countb) section B is to be executed for each cycle of section A.
This demonstrates a technique for controlling a high frequency DISCRETE section.
The code in section B determines how many times (countc) section B is to be
executed before activating section C. This demonstrates a technique for controlling a
low frequency DISCRETE section.
The time when indexc equals countc can also be checked with a modulus (or
remainder) operator; e.g.,
indexc = MOD(indexc, countc) + 1
IF(indexc .EQ. 1) THEN
...
ENDIF

In a model like this, you may want to record data every second, including the data that
changes every ten seconds. Do this by including a CALL LOGD(.TRUE.) at the end
of sections B and C. If you want to graphically show (plot) the discrete nature of what
is happening at every second, add another call to LOGD at the beginning of section B,
which will square up the plots of variables calculated between two calls.

ACSL Reference Manual Page 8-13


8. Application Notes 8.13 Synchronizing DISCRETE events

DISCRETE a ! first section


INTERVAL dta = 1.0 ! in sequence
...
INITIAL
INTEGER countb ! count for b
countb = dta/dtb + 0.5 ! rounded up
END ! of initial
DO schedb j=1, countb ! loop to
SCHEDULE b .AT. t+(j-1)*dtb ! schedule b
schedb..CONTINUE
END ! of a

DISCRETE b
CONSTANT dtb = 0.1 ! section with
... ! small interval
INITIAL
INTEGER countc, indexc ! count for c
countc = dtc/dtb + 0.5 ! rounded up
indexc = countc ! c counter
END ! of initial
IF(indexc .EQ. countc) THEN
indexc = 0 ! schedule c
SCHEDULE c .AT. t ! when counted
ENDIF ! time reached
indexc = indexc + 1
END ! of b

DISCRETE c ! section with


CONSTANT dtc = 10.0 ! relatively
... ! large interval
END ! of c

Page 8-14 ACSL Reference Manual


A. ACSL Example Programs
Introduction

The following example programs illustrate the use of ACSL. Each problem is
described physically and mathematically, the ACSL code and features are explained,
and the program and its printed and plotted output are shown.
The computer input for each example consists of two files: the model source and the
runtime commands. The model source code describes the model under examination. In
most cases the model can be considered to be parallel; i.e., variables need not be
calculated prior to their use. The translator will rearrange the program until it is in
correct sequence for execution. On the other hand, runtime commands are sequential;
they tell the model what to do next. A minimum of a START command is necessary to
exercise a model. Listings of the model source code and runtime commands are
included in each of the examples.
In the examples we have capitalized the ACSL keywords to differentiate them from
names and text, which are model-dependent. However, ACSL is not case sensitive.
You can use any case in your programs and at runtime. The exception is the TITLE
array, which is reproduced in printouts and plots in upper and lower case as given.
Outputs from the simulation runs include printouts and line plots. Although the full
thirteen inch width of the line printer is available in ACSL, the output shown here is
designed to fit on standard A size paper (8 1⁄2 x 11 inches) where possible for ease of
reproduction. The width of output viewed at the terminal is controlled by the ACSL
system variable TCWPRN (terminal character width), and the width of log file (or
print logical unit) is PCWPRN (printer character width). In these examples, TCWPRN
is set to 72 and PCWPRN to 80 so the output fits on an 81⁄2 inch wide page.

1. Limit Cycle

This example illustrates a simple nonlinear model and the runtime commands required
to run the program. A limit cycle in the XY plane is described by the equations:

. Kx (1 − x2 − y2 )
x = y +

√x2 + y2
. Ky (1 − x2 − y2 )
y = −x +

√x2 + y2

where:

x(0) = xz
y(0) = yz

The limit cycle is a circle of radius 1.0; that is, no matter what initial conditions are
imposed on x and y (except x = y = 0), (x2 + y2 ) → 1 as t → ∞.

ACSL Reference Manual Page A-1


A. ACSL Example Programs A1. Limit Cycle

DERIVATIVE ! limit cycle


!-----------------------define all the preset variables
CONSTANT xz = 0.5 , yz = 1.0
CONSTANT k = 0.2 , tf = 9.99
CINTERVAL cint = 0.2 ! communication interval
!-----------------------give name to radius value
sq = SQRT(x**2 + y**2)
!-----------------------common factor
kk = (1.0 - sq**2)/sq
!-----------------------limit cycle equations
x = INTEG( y + k*x*kk, xz)
y = INTEG(-x + k*y*kk, yz)
!-----------------------define stopping condition
TERMT(t .ge. tf, 'Time Limit')
END ! of derivative

Figure A1-1. Limit cycle model

The source code for this model is shown in Figure A1-1. SQ defines the root sum
square value as a named item so that it can be listed and plotted. Calculating a
common subexpression only once also saves computer execution time, and so KK is
also calculated separately. X and Y specify the integration equations. The expressions
for the derivatives are placed directly in the INTEG arguments along with the initial
conditions. They could be named and calculated in separate statements (as XD and
YD, for example) so they could be plotted and/or printed. Breaking out such
calculations is often helpful in debugging programs.
Every program must have a termination condition, expressed in a TERMT statement.
In this case, the program stops when time becomes equal to or greater than TF. TF is
specified in a CONSTANT statement as slightly less than the desired termination time
of 10 sec. If it were to be specified exactly 10.0, an extra integration step would be
taken since equality is rarely obtained in floating point numbers. The value of T,
obtained by summing many small increments, will in general be slightly less than the
exact value. By terminating at just under 10.0, we automatically have a plot scale
which makes the best use of the plot area. If the model stops after 10.0, the plot scales
automatically to 20.0, the next rounding point.
The runtime commands are listed in Figure A1-2 and a log of the runtime session in
Figure A1-3. The runtime commands may be entered interactively, from a command
file, or in batch mode. See the document ACSL Sim User's Guide for instructions on
executing an interactive ACSL runtime session, using a command file, or running in
batch mode.

SET TITLE = 'Limit Cycle Example'


SPARE
SET TCWPRN=72 ! Force 3 column output width
OUTPUT t,x,y,sq/NCIOUT=5 ! Define list to be printed during run
PREPARE t,x,y,sq ! Define list to be saved for later use
START
PLOT x,y,sq ! Plot as function of time
PLOT/XAXIS=x,y ! Phase plane plot
SPARE ! List execution time
QUIT

Figure A1-2. Limit cycle runtime commands

Page A-2 ACSL Reference Manual


A1. Limit Cycle A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10A 9-DEC-90 16:48:11 Page 1

SET TITLE = 'Limit Cycle Example'


SPARE
Accumulated cp time 15.19000. Elapsed cp time 0.
SET TCWPRN=72 ! Force 3 column output width
OUTPUT t,x,y,sq/NCIOUT=5 ! Define list to be printed during run
PREPARE t,x,y,sq ! Define list to be saved for later use
START
T 0. X 0.50000000 Y 1.00000000
SQ 1.11803000

T 1.00000000 X 1.07143000 Y 0.11524400


SQ 1.07761000

T 2.00000000 X 0.65941100 Y-0.81887100


SQ 1.05137000

T 3.00000000 X-0.32732300 Y-0.98097500


SQ 1.03414000

T 4.00000000 X-0.99128100 Y-0.25178700


SQ 1.02276000

T 5.00000000 X-0.74193800 Y 0.69293300


SQ 1.01520000

T 6.00000000 X 0.18130800 Y 0.99375800


SQ 1.01016000

T 7.00000000 X 0.93107100 Y 0.38308500


SQ 1.00680000

T 8.00000000 X 0.82357300 Y-0.57520100


SQ 1.00455000

T 9.00000000 X-0.03897800 Y-1.00229000


SQ 1.00305000

Time Limit
T 10.0000000 X-0.86359200 Y-0.50823200
SQ 1.00204000

PLOT X,Y,sq ! Plot as function of time


Drawing plot number 1
PLOT/XAXIS=x,y ! Phase plane plot
Drawing plot number 2
SPARE ! List execution time
Accumulated cp time 18.29000. Elapsed cp time 3.100000
QUIT

Figure A1-3. Limit cycle log file

SPARE is a utility which gives the accumulated and elapsed cp time by default. It is
called SPARE because it is available to be linked to a user-supplied subroutine for
runtime invocation. Finding the elapsed cp time is useful for comparing the execution
times of various runs, integration algorithms, etc.
The OUTPUT command lists the variables to be output at the terminal (and echoed on
the PRN unit) during the run. The /NCIOUT switch is set to five so that output is
reduced to only every fifth communication interval (every second).

ACSL Reference Manual Page A-3


A. ACSL Example Programs A1. Limit Cycle

Figure A1-4. Limit cycle time plot

PREPARE specifies which variables are to be collected for later printing or plotting.
START initiates the run, with output appearing during the run. When the run is
completed, the first PLOT command is given, producing the plot in Figure A1-4. As
can be seen, X and Y are sinusoidal and the root sum square value SQ approaches 1.0.
A phase plane plot, in which Y is plotted against X, is shown in Figure A1-5. X is
specified as the X axis variable with the PLOT switch /XAXIS.
Another SPARE command produces the elapsed cp time from the beginning of the
runtime session, and QUIT returns you to the computer operating system.
You can exercise the model by changing the values of the CONSTANTs (XZ, YZ, K)
with SET commands followed by another START command, etc.

Figure A1-5. Limit cycle phase plane plot

Page A-4 ACSL Reference Manual


A2. Spring A. ACSL Example Programs

2. Spring

The spring damping example illustrates the use of the RANGE command and the
effect of setting scales with the PLOT command. It is written in English units of lbs,
slugs, and seconds and demonstrates the complexities involved when we have to use
slugs as the unit of mass even though colloquially we talk of mass in lbs. A much
better system is the SI (System Internationale) set of units where force, mass, and time
are expressed in Newtons, kg, and seconds.
Figure A2-1 shows a spring supporting a mass with a viscous damper attached. This
system can be modeled by a linear second order differential equation derived by
writing the expression for the force acting on the mass and then using Newton's Law
to calculate the acceleration. If x is the linear displacement of the spring, the spring
restoring force is -Ax lbs, where A is the spring constant (lbs/ft). The viscous damping
.
is proportional to the velocity and opposing it; i.e., −Kx lbs, where K is the coefficient
of viscous friction in lbs/(ft/sec). If W is the weight in lbs attached to the spring
(tending to extend it), then the mass is W ⁄ g slugs, where g is the acceleration due to
gravity. With this, Newton's Law can be expressed:

W .. .
g x = W − Kx − Ax

Dividing both sides of the above equation by W ⁄ g, the expression for the highest
derivative is obtained and then integrated twice:
.
.. W − Kx − Ax
x =
W
g
. ..
x = ∫ x dt
.
x = ∫ x dt

Figure A2-1. Spring with weight and damper

ACSL Reference Manual Page A-5


A. ACSL Example Programs A2. Spring

PROGRAM spring
DERIVATIVE
!-----------------------spring damping problem. models releasing
! a mass from initial conditions of zero
! velocity and displacement
CINTERVAL cint = 0.02
!-----------------------define model default constants
CONSTANT k = 0.02 , a = 1.0 , g = 32.2
CONSTANT w = 1.0
!-----------------------another way of changing the independent
! variable
time = INTEG(1.0, 0.0)
!-----------------------calculate acceleration
xdd =(w - k*xd - a*x)/(w/g)
!-----------------------integrate accel for velocity and position
CONSTANT xic = 0.0 , xdic = 0.0
xd = INTEG(xdd, xdic)
x = INTEG(xd , xic )
!-----------------------specify termination condition
CONSTANT tstp = 3.99
TERMT(t.ge.tstp, 'Time Limit')
END ! of derivative
END ! of program

Figure A2-2. Spring model source code

Figure A2-2 shows the ACSL program statements that represent the dynamics of the
mass when it is released. Note the alternate way of obtaining time by integrating a
constant one.
The runtime commands for this model are shown in Figure A2-3, the log file in Figure
A2-4, and the resulting plots in Figures A2-5, 6, and 7.
The communication interval is defined in the model code to be 0.02 seconds; with a
time limit of 4 seconds, 201 data points are logged and result in smooth plots. Since
the /NCIOUT switch is set to 20, only eleven lines of OUTPUT are listed, enough to
see that the program is executing and the results appear as expected.
The RANGE command tells you the maximum and minimum value of each variable
specified over the length of the run. /ALL specifies all variables on the PREPARE list.
This information can be used to check the validity of the results or plan plot scales, for
example.

SET TITLE = 'Spring Damping Example'


SPARE
SET TCWPRN=72 ! Force 3 column output width
OUTPUT/NICOUT=20 time,xdd,xd,x
PREPARE xdd,xd,time,x
START
RANGE/ALL ! List maximum and minimum values
PLOT/XAXIS=time ! Set time as x-axis for subsequent plots
PLOT x,xd ! Use automatic scaling
PLOT x/HI=1.0/LO=0.0,xd ! Force scales for X out of range
PLOT/XAXIS=xd x ! Phase plane plot
SPARE ! List execution time
QUIT

Figure A2-3. Spring example runtime commands

Page A-6 ACSL Reference Manual


A2. Spring A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10A 10-DEC-90 11:10:45 Page 1

SET TITLE = 'Spring Damping Example'


SPARE
Accumulated cp time 17.79000. Elapsed cp time 0.
SET TCWPRN=72 ! Force 3 column output width
OUTPUT/NCIOUT=20 time,xdd,xd,x
PREPARE xdd,xd,time,x
START
TIME 0. XDD 32.2000000 XD 0.
X 0.

TIME 0.40000000 XDD-19.3714000 XD 3.83669000


X 1.52486000

TIME 0.80000000 XDD-3.06642000 XD-4.32187000


X 1.18167000

TIME 1.20000000 XDD 18.4264000 XD 1.90302000


X 0.38969000

TIME 1.60000000 XDD-18.3866000 XD 1.19672000


X 1.54708000

TIME 2.00000000 XDD 6.46987000 XD-2.81891000


X 0.85545100

TIME 2.40000000 XDD 6.92303000 XD 2.25044000


X 0.73999000

TIME 2.80000000 XDD-12.7991000 XD-0.35627900


X 1.40461000

TIME 3.20000000 XDD 9.06683000 XD-1.33804000


X 0.74518200

TIME 3.60000000 XDD-0.32093100 XD 1.78262000


X 0.97431400

Time Limit
TIME 3.99200000 XDD-6.92517000 XD-0.91957400
X 1.23346000

RANGE/ALL ! List maximum and minimum values


XDD-27.0957000 32.2000000
XD-4.35500000 5.20222000
TIME 0. 3.99200000
X 0. 1.83607000
PLOT/XAXIS=time ! Set time as x-axis for subsequent plots
Drawing plot number 1
PLOT x,xd ! Use automatic scaling
Drawing plot number 2
PLOT x/HI=1.0/LO=0.0,xd ! Force scales for X out of range
Drawing plot number 3
PLOT/XAXIS=xd x ! Phase plane plot
Drawing plot number 4
SPARE ! List execution time
Accumulated cp time 24.44000. Elapsed cp time 6.650000
QUIT

Figure A2-4. Spring example runtime log

ACSL Reference Manual Page A-7


A. ACSL Example Programs A2. Spring

Figure A2-5. Spring time plot Figure A2-6. Spring plot with forced scale

The first PLOT command specifies the variable for the X axis. If we did not specify
this, ACSL would use the first item on the PREPARE list as the default (XDD in this
case). The X axis switches remain in effect until explicitly changed. The second PLOT
command produces the time plot in Figure A2-5, which shows the sinusoidal motion
and damping of X and XD.
The /HI and /LO switches on the third PLOT command force the scales for X out of
range as shown in Figure A2-6. This illustrates how interpolation is performed to find
the intersection points with the edge of the plot so that the slope at the boundaries is
correct. Sections of the curve that are off the plot area are not drawn.
Figure A2-7 is a phase plane plot of X against XD.

Figure A2-7. Spring phase plane plot

Page A-8 ACSL Reference Manual


A3. Control Loop A. ACSL Example Programs

3. Control Loop

The control loop program illustrates how ACSL macros are used to represent transfer
functions from a system block diagram. It also demonstrates the use of a runtime
procedure (PROCEDURE). The design is of a lead-lag controller for a second order
plant that has a measurement device containing a first order lag (real pole). Figure
A3-1 shows the system block diagram. Constants in the model are as follows:

T1 = 0.020 sec K1 = to be determined A = 0.012 sec2


T2 = 0.005 sec K2 = 0.5 B = 0.200 sec
T3 = 0.002 sec K3 = 1.0

The model code is shown in Figure A3-2. The communication interval (CINT) is
defined to be 5 msec, a step in input (TZ) is applied at 20 msec, and the transient is
allowed to run to the stop time (TSTP) of 499 msec or 100 recorded data points. The
transfer function operators REALPL, CMPXPL, and LEDLAG are embedded in the
expressions on the right side of the equal sign. This form of the macro invocation is
acceptable when the output is a single numeric quantity, and in fact such operators can
be nested to any depth desired. An alternate form of invoking the macros would be as
follows for the three lines calculating XM, X, and U, respectively:
REALPL(xm = ta3, k3*x, 0.0)
CMPXPL(x = a, b, k2*xp)
LEDLAG(u = ta1, ta2, k1*e, 0.0)

This standalone form of the macro invocation is sometimes preferable since it restricts
generation of dummy names (in the form Znnnnn). In changing to the standalone
form, the above takes advantage of the property of linear operators that pre- and
post-multiplication by scalars are equivalent.
In the runtime commands (Figure A3-3), the OUTPUT and PREPARE lists are
specified and a procedure GO defined. The commands between the PROCEDURE and
its matching END are saved and not executed. Then two runs are made using the
PROCEDURE as a command, the first run with K1 equal to 100.0 and the second with
K1 at 10.0. Each GO invokes the START and PLOT sequence saved in the
PROCEDURE. Figures A3-4 shows the log file resulting from the runtime commands,
and Figures A3-5 and A3-6 are the plots.

Figure A3-1. Control Loop Block Diagram

ACSL Reference Manual Page A-9


A. ACSL Example Programs A3. Control Loop

PROGRAM loop
!-----------------------communication interval
CINTERVAL cint = 0.005
!-----------------------output of first order lag is measurement
CONSTANT k3 = 1.0 , ta3 = 0.002
xm = k3*REALPL(ta3, x, 0.0)
!-----------------------forcing function
CONSTANT tz = 0.02
xc = STEP(tz)
!-----------------------error between reference and measured
e = xc - xm
!-----------------------controller output
CONSTANT k1 = 50.0 , ta1 = 0.020 , ta2 = 0.005
u = k1*LEDLAG(ta1, ta2, e)
!-----------------------define 2-nd order plant
CONSTANT k2 = 0.5 , a = 0.012 , b = 0.200
x = k2*CMPXPL(a, b, u)
!-----------------------specify termination condition
CONSTANT tstp = 0.499
TERMT(t.GE.tstp, 'Time Limit')
END ! of program

Figure A3-2. Control loop model code

SET TITLE = 'Control Loop Example'


SPARE
SET TCWPRN=72 ! Force 3 column output width
OUTPUT t,xc,e,u,x/NCIOUT=10
PREPARE t,xc,e,u,x,xm
PROCEDURE go
START
PLOT x,xc,xm/SAME,e ! Force same scales for command and
! measured - first variable is reference
END ! of procedure
! Make two runs and produce plots of each
SET k1=100.0 ; go ! High gain, plot one
SET k1=10.0 ; go ! Low gain, plot two
SPARE ! List execution time
QUIT

Figure A3-3. Control loop runtime commands

Page A-10 ACSL Reference Manual


A3. Control Loop A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10A 20-DEC-90 12:25:45 Page 1

SET TITLE = 'Control Loop Example'


SPARE
Accumulated cp time 30.31000. Elapsed cp time 0.
SET TCWPRN=72 ! Force 3 column output width
OUTPUT t,xc,e,u,x/NCIOUT=10
PREPARE t,xc,e,u,x,xm
PROCEDURE go
START
PLOT x,xc,xm/SAME,e ! Force same scales for command and
! measured - first variable is reference
END ! of procedure
! Make two runs and produce plots of each
SET k1=100.0 ; go ! High gain, plot one
START
T 0. XC 0. E 0.
U 0. X 0.

T 0.05000000 XC 1.00000000 E-0.34333400


U-78.7033000 X 1.36501000

T 0.10000000 XC 1.00000000 E 0.06227730


U 4.46694000 X 0.94377200

T 0.15000000 XC 1.00000000 E 0.01899680


U 2.65121000 X 0.98016900

T 0.20000000 XC 1.00000000 E 0.01921870


U 1.88171000 X 0.98078600

T 0.25000000 XC 1.00000000 E 0.01964500


U 1.96027000 X 0.98036300

T 0.30000000 XC 1.00000000 E 0.01960870


U 1.96161000 X 0.98039100

T 0.35000000 XC 1.00000000 E 0.01960740


U 1.96074000 X 0.98039300

T 0.40000000 XC 1.00000000 E 0.01960780


U 1.96077000 X 0.98039200

T 0.45000000 XC 1.00000000 E 0.01960780


U 1.96078000 X 0.98039200

Time Limit
T 0.49950000 XC 1.00000000 E 0.01960780
U 1.96078000 X 0.98039200

PLOT x,xc,xm/SAME,e ! Force same scales for command and


Drawing plot number 1
! measured - first variable is reference
SET k1=10.0 ; go ! Low gain, plot two
START
T 0. XC 0. E 0.
U 0. X 0.

T 0.05000000 XC 1.00000000 E 0.75738200


U 5.99485000 X 0.26580700

T 0.10000000 XC 1.00000000 E 0.23426900


U 1.07450000 X 0.78126900

Figure A3-4. Control loop log file

ACSL Reference Manual Page A-11


A. ACSL Example Programs A3. Control Loop

T 0.15000000 XC 1.00000000 E 0.02159260


U-0.03372380 X 0.98063500

T 0.20000000 XC 1.00000000 E 0.05584250


U 0.80529000 X 0.94062000

T 0.25000000 XC 1.00000000 E 0.14417800


U 1.67291000 X 0.85293700

T 0.30000000 XC 1.00000000 E 0.18782500


U 1.94275000 X 0.81151400

T 0.35000000 XC 1.00000000 E 0.18682100


U 1.83494000 X 0.81368300

T 0.40000000 XC 1.00000000 E 0.17240800


U 1.68318000 X 0.82811200

T 0.45000000 XC 1.00000000 E 0.16383700


U 1.62366000 X 0.83632400

Time Limit
T 0.49950000 XC 1.00000000 E 0.16309100
U 1.63467000 X 0.83684500

PLOT x,xc,xm/SAME,e ! Force same scales for command and


Drawing plot number 2
! measured - first variable is reference
SPARE ! List execution time
Accumulated cp time 38.68000. Elapsed cp time 8.370000
QUIT

Figure A3-4. Control loop log file (continued)

Figure A3-5. Control loop input step XC, Figure A3-6. Control loop input step,
output X, and measurement XM to same output, measurement, and error for K1 = 10
scales plus error E for K1 = 100

Page A-12 ACSL Reference Manual


A4. Pilot Ejection Study A. ACSL Example Programs

4. Pilot Ejection
Study

The pilot ejection example illustrates explicit program structure (explained in Chapter
3), the ACTION command (see Chapter 5), and the debug facility (described in detail
in Chapter 7). An IF-THEN-ELSE block is also used in the example.
The purpose of the pilot ejection study is to determine the trajectory of a pilot ejected
from a fighter aircraft in order to ascertain whether he will strike the vertical stabilizer
of the aircraft. Several combinations of aircraft speed and altitude are investigated
since the drag on the pilot, causing his relative horizontal motion with respect to the
aircraft, is a function of air density and velocity (squared).
The ejection system is devised so that it causes the pilot and his seat to travel along
rails at a specified exit velocity (VE) at an angle (θE) backward from vertical. The seat
becomes disengaged from the rails at Y = Y1. This first phase of the ejection is
illustrated in Figure A4-1.
Once the pilot and seat unit leaves the rails, it follows a ballistic trajectory which can
be determined; however, since it is the relative motion of the pilot with respect to the
aircraft (which is assumed to fly level at constant speed) that is important, the
equations are formulated to obtain this trajectory directly. This phase of the ejection is
shown in Figure A4-2.
The equations which govern the motion are stated as follows:
.
x = V cos θ − VA
.
y = V sin θ
.
V = 0 ; 0 ≤ y < y1
.
V = − D ⁄ m − g sin θ ; y ≥ y1
.
θ = 0 ; 0 ≤ y < y1
.
θ = − ( g cos θ ) ⁄ V ; y ≥ y1
2
D = ρ CD s V ⁄ 2

Figure A4-1. First Phase of Ejection

ACSL Reference Manual Page A-13


A. ACSL Example Programs A4. Pilot Ejection Study

Figure A4-2. Space Trajectories of Vehicle and Pilot

where D is drag, CD is the aerodynamic drag coefficient, m is the mass of the pilot and
seat, g is the acceleration of gravity, ρ is air density, and s is the effective
cross-sectional area of the pilot and seat. The following two cases are examined:

Case 1: VA = 900 ft ⁄ s
Case 2: VA = 500 ft ⁄ s

The air density for sea level is used for both the cases run in this example, but in a full
study, the effects of air density would also be examined.

ρ = 2.3769 x 10−3 slugs ⁄ ft3 (sea level)

The other constants are set as follows:

m = 7 slugs
g = 32.2 ft/s2
CD = 1
s = 10 ft2
y1 = 4 ft
θE = 15 deg (15/57.3 rad)
VE = 40 ft/sec

The initial values of V and θ (pilot's initial velocity vector at the moment of leaving
the cockpit rails) are calculated in the INITIAL section of the program (using the
names VIC and THIC) by the equations:

V (0) = 
√(VZ − VE sin θE )2 + ( VE cos θE)2

VE cos θE
θ (0) = tan−1
VA − VE sin θE

X(0) and Y(0) are zero. Initial conditions are calculated in the INITIAL section, which
is evaluated just once before the DERIVATIVE section is evaluated and time moves
forward. The initial condition table is transferred to the state table before the
DERIVATIVE section is evaluated.

Page A-14 ACSL Reference Manual


A4. Pilot Ejection Study A. ACSL Example Programs

PROGRAM ejection
INITIAL

!-----------------------ejection angle in radians from degrees


CONSTANT thedeg = 15.0 , degrad = 57.3
the = thedeg/degrad
!-----------------------seat initial velocity components
CONSTANT ve = 40.0 , va = 900.0
vx = va - ve*SIN(the)
vy = ve*COS(the)
!-----------------------total velocity and angle from horizontal
vic = SQRT(vx**2 + vy**2)
thic = ATAN2(vy, vx)

END ! of initial
DYNAMIC

!-----------------------communication interval
CINTERVAL cint = 0.01

DERIVATIVE

!-----------------------relative positions
x = INTEG(v*COS(th) - va, 0.0)
y = INTEG(v*SIN(th), 0.0)
!-----------------------space velocity and flight path angle
CONSTANT mass = 7.0, g = 32.2
v = INTEG(rail*(-d/mass - g*SIN(th)), vic)
th = INTEG(rail*(-g*COS(th)/v), thic)
!-----------------------compute drag
CONSTANT cd = 1.0, s = 10.0, ro = 0.0023769
d = 0.5*ro*cd*s*v**2
!-----------------------use if/then else for switch to keep seat
! constrained to guide rails.
CONSTANT y1 = 4.0
IF(y.LT.y1) THEN
rail = 0.0
ELSE
rail = 1.0
ENDIF

END ! of derivative
!-----------------------specify termination conditions
TERMT(x.LE.xmn, 'Distance Limit') ; CONSTANT xmn = -60.0
TERMT(y.GE.ymx, 'Height Limit') ; CONSTANT ymx = 30.0
TERMT(t.GE.tmx, 'Time Limit') ; CONSTANT tmx = 4.0

END ! of dynamic
END ! of program

Figure A4-3. Pilot ejection program

A run is terminated when any one of the following conditions occurs:

x ≤ -60 ft (pilot beyond vertical stabilizer)


y ≥ 30 ft (pilot well above 12 ft high tail)
t ≥ 4.0 sec

The program for this example is shown in Figure A4-3. The TERMT statements at the
end of the DYNAMIC section define the termination conditions. They are interrogated
every communication interval; as soon as one of the conditions becomes true, the stop
flag is set and control is handed back to the runtime executive.

ACSL Reference Manual Page A-15


A. ACSL Example Programs A4. Pilot Ejection Study

ACSL Runtime Exec Version 6 Level 10B 15-FEB-91 13:57:45 Page 1

SET TITLE = 'Pilot Ejection'


SPARE
Accumulated cp time 28.46000. Elapsed cp time 0.
SET TCWPRN=72,PCWPRN=80 ! Force 3 column output width
OUTPUT t,th,v,x,y,d/NCIOUT=5
PREPARE t,th,v,x,y
START
T 0. TH 0.04340250 V 890.487000
X 0. Y 0. D 9424.01000

T 0.05000000 TH 0.04340250 V 890.487000


X-0.51760200 Y 1.93186000 D 9424.01000

T 0.10000000 TH 0.04340250 V 890.487000


X-1.03521000 Y 3.86372000 D 9424.01000

T 0.15000000 TH 0.04167640 V 832.329000


X-2.92273000 Y 5.70253000 D 8233.24000

T 0.20000000 TH 0.03967530 V 777.340000


X-7.74561000 Y 7.33859000 D 7181.29000

T 0.25000000 TH 0.03753730 V 729.162000


X-15.1368000 Y 8.79211000 D 6318.71000

T 0.30000000 TH 0.03526240 V 686.604000


X-24.7875000 Y 10.0802000 D 5602.65000

T 0.35000000 TH 0.03285050 V 648.737000


X-36.4412000 Y 11.2170000 D 5001.71000

T 0.40000000 TH 0.03030150 V 614.827000


X-49.8830000 Y 12.2146000 D 4492.49000

Distance Limit
T 0.44000000 TH 0.02816380 V 590.149000
X-61.8006000 Y 12.9191000 D 4139.08000

PLOT/XAXIS=t, th, v, x, y ! Time histories


Drawing plot number 1
PLOT/XAXIS=x/XLO=xmn y ! Geometrical x vs.y
Drawing plot number 2

Figure A4-4. Pilot ejection log file (part 1)

The value of RAIL (either 0.0 or 1.0) is controlled within an IF-THEN-ELSE block
then used in the calculation of V and TH (θ).
At runtime, the following outputs are requested:

Print t, θ, V, X, Y, and D every 0.01 sec


Plot θ, V, X, and Y versus t
Plot X versus Y

The log file from running the model is shown in Figures A4-4 and A4-7, and the plots
are shown in Figures A4-5, A4-6, and A4-8. The runtime commands can be entered
interactively or from a command file. The method for using a command file depends
on your computer system; for further information, see ACSL Sim User's Guide.

Page A-16 ACSL Reference Manual


A4. Pilot Ejection Study A. ACSL Example Programs

Figure A4-5. Pilot ejection time plot Figure A4-6. Pilot ejection trajectory
VA = 900 ft/s

A title is established, SPARE gives the accumulated and elapsed cp time, and the
terminal and log file widths are set for narrow printout. Next, the OUTPUT and
PREPARE lists are defined and the first run is generated (with the START command)
using the default parameter values defined in the program (i.e., aircraft velocity of 900
ft/sec.). As the run progresses, OUTPUT values are listed every five communication
intervals (0.05 sec). The run stops at 0.44 seconds with the message Distance Limit
from the TERMT statement indicating that X has become more negative than the
minimum specified (-60 ft).
Figure A4-5 shows the time histories (i.e., where the X axis variable is T). Correlating
the curves with the printed OUTPUT data, we see that (from the top) X starts at zero
and decreases, θ starts at 0.0434 rad and decreases after 0.1 sec, V starts at 890 ft/s and
drops off after 0.1 sec, and Y starts at zero and increases.
Figure A4-6 is a trajectory plot. The X axis is X (the relative distance of the pilot
along the aircraft from the cockpit, negative towards the tail). At 60 ft., the pilot just
clears the 12 ft. high tail. Note that this PLOT command specifies /XLO = XMN or
-60 ft. so that the plot runs from this value to zero. If the XLO subcommand had not
been used, normal rounding with automatic scaling would have caused the scales to
run from -100 to zero, wasting 40% of the plotting area.
In Figure A4-7, the log file continues with a second run. This run is set up with a
debug printout generated with ACTION at the derivative evaluation where T is equal
to or greater than 0.1 so that we can see all the values in the model at the moment of
the ejection. The OUTPUT rate is reduced to every ten communication intervals or 0.1
sec. Changing the rate with /NCIOUT does not affect the list of variables to be output.
Not only is it not necessary to restate the OUTPUT list at this point, but doing so
would result in the variables being printed out twice each because the OUTPUT list is
cumulative. The aircraft speed is changed to 500 ft/sec and the model run again.

ACSL Reference Manual Page A-17


A. ACSL Example Programs A4. Pilot Ejection Study

ACSL Runtime Exec Version 6 Level 10B 15-FEB-91 13:57:55 Page 2


Pilot Ejection

! Set up for debug list of all variables when t = 0.1


ACTION/VARIABLE=0.1/VALUE=1/LOCATION=NDBUG
OUTPUT/NCIOUT=10 ! Same output list,lower rate
! List of commands on one line
SET va=500.0 ; START ; PLOT/XAXIS=x/XLO=xmn y
T 0. TH 0.07874500 V 491.170000
X 0. Y 0. D 2867.11000

T 0.10000000 TH 0.07874500 V 491.170000


X-1.03520000 Y 3.86372000 D 2867.11000

DEBUG ....Debug dump - System Variables. NDBUG is 1, block number 1


dump T 0.10100000 ZZTICG 0. CINT 0.01000000
ZZIERR F ZZNBLK 1 ZZICON 1
ZZSTFL F ZZFRFL T ZZICFL F
ZZRNFL F ZZJEFL F ZZNIST 4
ZZNAST 0 IALG 5 NSTP 10
MAXT 1.0000E+09 MINT 1.0000E-09

State Variables Derivatives Initial Conditions


TH 0.07874500 Z09993 0. THIC 0.07874500
V 491.170000 Z09994 0. VIC 491.170000
X-1.04555000 Z09998-10.3520000 Z09997 0.
Y 3.90236000 Z09996 38.6372000 Z09995 0.

Algebraic Variables

Common Block /ZZCOMU/


CD 1.00000000 D 2867.11000 DEGRAD 57.3000000
G 32.2000000 MASS 7.00000000 RAIL 0.
RO 0.00237690 S 10.0000000 THE 0.26178000
THEDEG 15.0000000 TMX 4.00000000 VA 500.000000
VE 40.0000000 VX 489.648000 VY 38.6372000
XMN-60.0000000 Y1 4.00000000 YMX 30.0000000
ZZSEED 55555555

T 0.20000000 TH 0.07220480 V 454.489000


X-3.86296000 Y 7.44086000 D 2454.87000

T 0.30000000 TH 0.06486210 V 421.727000


X-10.1960000 Y 10.4422000 D 2113.70000

T 0.40000000 TH 0.05696620 V 393.366000


X-19.5502000 Y 12.9250000 D 1838.97000

T 0.50000000 TH 0.04851700 V 368.580000


X-31.5330000 Y 14.9354000 D 1614.52000

T 0.60000000 TH 0.03951440 V 346.740000


X-45.8242000 Y 16.5115000 D 1428.86000

Distance Limit
T 0.69000000 TH 0.03093920 V 329.197000
X-60.4399000 Y 17.5845000 D 1287.93000

Drawing plot number 3


SPARE
Accumulated cp time 35.30000. Elapsed cp time 6.840000
QUIT

Figure A4-7. Pilot ejection log file (part 2)

Page A-18 ACSL Reference Manual


A4. Pilot Ejection Study A. ACSL Example Programs

Figure A4-8. Pilot ejection trajectory, VA = 500 ft/s

The ACTION command generates a debug output. The complete command is read as
follows: When the independent variable (/VARIABLE) becomes 0.1, take a value
(/VALUE) of 1 and store it into a location (/LOCATION) called NDBUG. The
printout following the START command begins with the OUTPUT listing at time
equal to 0.0 and 0.1 (note the reduced frequency) and then comes the DEBUG dump.
Note that NDBUG is 1 as specified by the ACTION command. Although we
requested the dump to be produced at 0.1 sec, the time is actually 0.101 sec. This
indicates that T was not 0.1 at the previous integration step, or else the dump would
have been produced then. Instead, because of the way digital computers add decimal
numbers, time was 0.0999999999999 (depending on the computer system and whether
model is run in single or double precision) at the previous step.
The debug dump comprises three sections: first, system variables (described in more
detail in Chapter 7); next, state variables with their associated derivatives and initial
conditions; and, finally, the algebraic variables by common block. /ZZCOMU/ is the
user single precision and integer common block. If any double precision variables are
used in the model, a double precision common block called /ZZCOMP/ appears. If any
character variables are used, there is a common block called /ZZCOMC/.
Since the ACTION command specified the system variable NDBUG to be 1, only one
debug list is written out and the run continues normally from that point with output
every 0.1 seconds. The trajectory plot of the second run, Figure A4-8, shows the pilot
now clearing the tail by 5 ft. at the lower velocity. Note that the level of detail in the
plot is not affected the lower rate of OUTPUT. Variables on the PREPARE list are
still logged (and plotted) at the communication interval (CINT); this program uses the
default of 0.01 sec. as can be seen in the debug listing.
This example illustrates how you can vary a parameter at runtime and compare the
results. You could continue the study by choosing one value for the velocity and
varying the air density to see its effect on the pilot clearing aircraft.

ACSL Reference Manual Page A-19


A. ACSL Example Programs A5. Temperature Distribution along a Radiating Fin

5. Temperature
Distribution along
a Radiating Fin

The radiating fin example illustrates the use of a loop from the TERMINAL section
back to the INITIAL section for generating a series of runs. The independent variable
is the distance along the fin (rather than time) and it is given the name X rather than
taking the default name of T.
The only practical way of rejecting heat from a power plant operating in outer space is
by thermal radiation. If the working fluid of the power plant passes through tubes, an
efficient radiating surface could be created by placing many tubes side by side. This
design would maintain the entire surface at the highest possible temperature. Such a
system, though, is highly vulnerable to being punctured by a meteor fragment or some
other particle, and this could lead to the loss of the vital working fluid.
A less efficient but also less vulnerable arrangement is shown in Figure A5-1. The
number of tubes has been reduced and the space between the tubes has been filled by a
fin of rectangular cross section. The temperature profile across the fin is to be
determined for various tube spacings, fin thicknesses, fin material, etc. The
temperature profile, in turn, can be used to calculate the efficiency of the radiating
system.
This example is a problem in static temperature distribution. Time is not a factor
because steady state conditions throughout the system are assumed.

5.1 Assumptions

Figure A5-2 shows two views of the geometry of the fin. In terms of this figure, the
pertinent assumptions are as follows:
1. Steady-state conditions have been established.
2. Heat is transferred out of the fin only by radiation through a nonabsorbing me-
dium.
3. Thermal properties of the material are constant.
4. There is no heat conduction in the Y direction.

Figure A5-1. A Radiating Surface Using Tubes and Fins

Page A-20 ACSL Reference Manual


A5. Temperature Distribution along a Radiating Fin A. ACSL Example Programs

Figure A5-2. Geometry of the Radiating Fin

5. Heat loss from the two exposed side edges is small enough to consider the
edges as being insulated.
6. Temperature is effectively constant across the fin thickness (2H) at all values
of X, which implies 2H << W, 2H << L.

These assumptions reduce the problem to mathematical formulation for


one-dimensional steady-state heat transfer under combined radiation and conduction.

5.2 Mathematical
Formulation

Consider the heat balance for an element strip shown in Figure A5-3 where the width
is W, half thickness is H, and length is ∆x. The local rate of heat conduction through
the cross-sectional area 2HW at position x is given by Fourier's equation to be

qx + ∆x = − K (2HW)
dT
dx | x + ∆x

where K is the thermal conductivity of the material. The rate of heat conduction out of
the segment is:

qx = − K (2HW)
dT
dx | x

The rate of heat lost by radiation is the difference, namely:

∆q = − K (2HW)  |x + ∆x 
dT dT
|x −
 dx dx 

ACSL Reference Manual Page A-21


A. ACSL Example Programs A5. Temperature Distribution along a Radiating Fin

Figure A5-3. Heat Balance for an Element of Radiating Fin

This condition can also be expressed by means of the Stephan-Boltzman law for heat
radiation, taking into account both the top and bottom surfaces of the element:

∆q = σ ε ( T 4 − Ts4 ) ( 2W∆x )

where:

σ = Stephan-Boltzman constant for the material


ε = emissivity of the material
T = temperature of the segment, in oR
Ts = temperature of the surroundings, in oR

The heat balance equation then becomes:

− K ( 2HW )   = σ ε ( T 4 − T 4 ) ( 2W∆x )
dT dT

dx |x + ∆x
s
dx
 |x

Dividing both sides by − K (2HW) ∆x and inverting the order on the left side gives:

1  dT dT  σε 4 4
 dx −  = KH ( T − Ts )
∆x  | x + ∆x dx |x

In the limit, as ∆x→0, the left side becomes the second derivative of T with respect to
x, so the final equation becomes:

d 2T σε
2
= ( T 4 − Ts4 )
dx KH

Page A-22 ACSL Reference Manual


A5. Temperature Distribution along a Radiating Fin A. ACSL Example Programs

5.3 Initial Conditions


and Parameters

Since the equation derived above is a second order differential equation, appropriate
initial conditions must be specified for the temperature and the temperature gradient at
x = 0. While the initial temperature (the temperature where the fin joins the tube) is
known, the initial temperature gradient is not known. However, it is clear from the
symmetry of the arrangement that the temperature gradient at the midpoint between
tubes where x = L is zero. Thus, the problem falls in the category of a two-point
boundary value problem that must satisfy these conditions:

T(0) = 2000 oR

dT
= 0
dx | x = L

The variables and constants and their appropriate units are as follows:
o
T = temperature R
x = distance ft
σ = 0.173x10-8 BTU/(hr)(ft2)(oR4)
ε = 0.9 -
K = 25 BTU/(hr)(ft2)(oR)
H = 0.00125 ft
L = 0.25 ft
o
Ts =0 R

Note that the temperature of the surroundings (Ts) has been taken to be absolute zero
for this example.

5.4 Solution

A solution is considered to be successful if:

[ dT ⁄ dx ] < 0.2 when x = L

The current run is terminated and a new run started by looping back from the
TERMINAL section to the INITIAL section if:

1. T exceeds its initial value by one percent or more


2. T becomes negative
3. [dT ⁄ dx ] > 0.2 when x = L

A new estimate of in the initial temperature gradient (DTDXZ) is computed using the
old value as follows:
DTDXZ(new) = DTDXZ(old) - 0.07*DTDX(x = L)

where DTDX(x = L) is the final value of the temperature gradient. One case is run for
this example with an initial temperature of 2000 oR and an estimated temperature
gradient of -20,000 oR/ft.
The listing of the model source code is shown in Figure A5-4. The program has a loop
from the TERMINAL to the INITIAL section. In the TERMINAL section, it checks
the final value of temperature slope; if the slope is not within the specified tolerance,
the program recycles to the INITIAL section (to the label L1) for another run with a

ACSL Reference Manual Page A-23


A. ACSL Example Programs A5. Temperature Distribution along a Radiating Fin

PROGRAM radiating fin

!-----------------------communication interval
CINTERVAL cint = 0.0025
!-----------------------off-set initial value to handle accumu-
! lated round off - change name from t to x
VARIABLE x = 1.0e-10

INITIAL

!-----------------------initial temp rate guess


CONSTANT dtdxz = -20000.0
!-----------------------note n is handled as an integer
INTEGER n
n = 0
l1..CONTINUE
n = n + 1 ! bump run count
CALL INITD ! clear event list

END ! of initial
!-----------------------note no dynamic section since not used
DERIVATIVE

!-----------------------integrate for temp rate and temperature


CONSTANT sg = 1.73e-9 , ep = 0.9
CONSTANT h = 0.00125 , k = 25.0
CONSTANT ts = 0.0
dtdx = INTEG(sg*ep*(t**4 - ts**4)/(k*h), dtdxz)
!-----------------------note t is now temperature not time
t = INTEG(dtdx, tz)
!-----------------------specify termination condition
CONSTANT l = 0.25 , tz = 2000.0
TERMT(x.GE.l .OR. t.GE.1.01*tz .OR. t.LT.0.0)

END ! of derivative

TERMINAL

!-----------------------force output at end of every sweep


CALL LOGD(.TRUE.)
!-----------------------if converged or too many tries
CONSTANT error = 0.2
IF((ABS(dtdx).GE.error) .AND. n.LE.10) THEN
!----------------------find new guess for initial temp rate
CONSTANT gain = 0.07
dtdxz = dtdxz - gain*dtdx
!----------------------try run again
GO TO l1
ENDIF

END ! of terminal

END ! of program

Figure A5-4. Radiating fin program

new value of initial slope. The independent variable is specified in the VARIABLE
statement to be X, and the initial condition (XZ) is set to 1.0E-10 to give it a lead on
the roundoff error.
Figure A5-5 is a listing of the log file.

Page A-24 ACSL Reference Manual


A5. Temperature Distribution along a Radiating Fin A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 1

SET TITLE = 'Radiating Fin Example'


SPARE
Accumulated cp time 118.5200. Elapsed cp time 0.
SET TCWPRN=72,PCWPRN=80 ! Force 3 column output width
OUTPUT/NCIOUT=20 x,t,n,dtdx,dtdxz
PREPARE x,dtdx,t,n,dtdxz
START ! Perform iteration
X 1.0000E-10 T 2000.00000 N 1
DTDX-20000.0000 DTDXZ-20000.0000

X 0.05000000 T 1655.09000 N 1
DTDX 3125.64000 DTDXZ-20000.0000

X 0.08400000 T 2022.13000 N 1
DTDX 20882.3000 DTDXZ-20000.0000

X 1.0000E-10 T 2000.00000 N 2
DTDX-21461.8000 DTDXZ-21461.8000

X 0.05000000 T 1548.18000 N 2
DTDX-347.340000 DTDXZ-21461.8000

X 0.10000000 T 1950.17000 N 2
DTDX 19621.8000 DTDXZ-21461.8000

X 0.10350000 T 2023.48000 N 2
DTDX 22336.7000 DTDXZ-21461.8000

X 1.0000E-10 T 2000.00000 N 3
DTDX-23025.3000 DTDXZ-23025.3000

X 0.05000000 T 1436.77000 N 3
DTDX-3799.77000 DTDXZ-23025.3000

X 0.10000000 T 1496.70000 N 3
DTDX 6488.72000 DTDXZ-23025.3000

X 0.13925000 T 2023.07000 N 3
DTDX 23828.8000 DTDXZ-23025.3000

X 1.0000E-10 T 2000.00000 N 4
DTDX-24693.3000 DTDXZ-24693.3000

X 0.05000000 T 1320.94000 N 4
DTDX-7222.55000 DTDXZ-24693.3000

X 0.10000000 T 1102.75000 N 4
DTDX-2124.58000 DTDXZ-24693.3000

X 0.15000000 T 1081.88000 N 4
DTDX 1246.12000 DTDXZ-24693.3000

X 0.20000000 T 1241.96000 N 4
DTDX 5559.13000 DTDXZ-24693.3000

Figure A5-5. Radiating fin log file (part 1)

ACSL Reference Manual Page A-25


A. ACSL Example Programs A5. Temperature Distribution along a Radiating Fin

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 2


Radiating Fin Example

X 0.25000000 T 1744.38000 N 4
DTDX 17143.4000 DTDXZ-24693.3000

X 0.25025000 T 1748.68000 N 4
DTDX 17259.3000 DTDXZ-24693.3000

X 1.0000E-10 T 2000.00000 N 5
DTDX-25901.5000 DTDXZ-25901.5000

X 0.05000000 T 1238.82000 N 5
DTDX-9554.59000 DTDXZ-25901.5000

X 0.10000000 T 855.500000 N 5
DTDX-6501.77000 DTDXZ-25901.5000

X 0.15000000 T 551.324000 N 5
DTDX-5844.27000 DTDXZ-25901.5000

X 0.20000000 T 262.112000 N 5
DTDX-5758.90000 DTDXZ-25901.5000

X 0.24575000 T-1.27562000 N 5
DTDX-5756.76000 DTDXZ-25901.5000

X 1.0000E-10 T 2000.00000 N 6
DTDX-25498.5000 DTDXZ-25498.5000

X 0.05000000 T 1266.05000 N 6
DTDX-8789.50000 DTDXZ-25498.5000

X 0.10000000 T 935.122000 N 6
DTDX-5165.11000 DTDXZ-25498.5000

X 0.15000000 T 711.010000 N 6
DTDX-4006.11000 DTDXZ-25498.5000

X 0.20000000 T 521.885000 N 6
DTDX-3633.05000 DTDXZ-25498.5000

X 0.25000000 T 343.205000 N 6
DTDX-3538.70000 DTDXZ-25498.5000

X 0.25025000 T 342.320000 N 6
DTDX-3538.53000 DTDXZ-25498.5000

X 1.0000E-10 T 2000.00000 N 7
DTDX-25250.8000 DTDXZ-25250.8000

X 0.05000000 T 1282.87000 N 7
DTDX-8312.99000 DTDXZ-25250.8000

X 0.10000000 T 985.412000 N 7
DTDX-4286.58000 DTDXZ-25250.8000

X 0.15000000 T 816.696000 N 7

Figure A5-5. Radiating fin log file (part 2)

Page A-26 ACSL Reference Manual


A5. Temperature Distribution along a Radiating Fin A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 3


Radiating Fin Example

DTDX-2664.22000 DTDXZ-25250.8000

X 0.20000000 T 706.275000 N 7
DTDX-1832.88000 DTDXZ-25250.8000

X 0.25000000 T 627.859000 N 7
DTDX-1342.21000 DTDXZ-25250.8000

X 0.25025000 T 627.523000 N 7
DTDX-1340.28000 DTDXZ-25250.8000

X 1.0000E-10 T 2000.00000 N 8
DTDX-25157.0000 DTDXZ-25157.0000

X 0.05000000 T 1289.26000 N 8
DTDX-8131.24000 DTDXZ-25157.0000

X 0.10000000 T 1004.75000 N 8
DTDX-3941.41000 DTDXZ-25157.0000

X 0.15000000 T 858.474000 N 8
DTDX-2102.45000 DTDXZ-25157.0000

X 0.20000000 T 782.803000 N 8
DTDX-992.930000 DTDXZ-25157.0000

X 0.25000000 T 755.061000 N 8
DTDX-137.438000 DTDXZ-25157.0000

X 0.25025000 T 755.027000 N 8
DTDX-133.389000 DTDXZ-25157.0000

X 1.0000E-10 T 2000.00000 N 9
DTDX-25147.7000 DTDXZ-25147.7000

X 0.05000000 T 1289.89000 N 9
DTDX-8113.11000 DTDXZ-25147.7000

X 0.10000000 T 1006.68000 N 9
DTDX-3906.67000 DTDXZ-25147.7000

X 0.15000000 T 862.689000 N 9
DTDX-2044.73000 DTDXZ-25147.7000

X 0.20000000 T 790.655000 N 9
DTDX-903.288000 DTDXZ-25147.7000

X 0.25000000 T 768.495000 N 9
DTDX-0.34978200 DTDXZ-25147.7000

X 0.25025000 T 768.495000 N 9
DTDX 3.99474000 DTDXZ-25147.7000

X 1.0000E-10 T 2000.00000 N 10
DTDX-25147.9000 DTDXZ-25147.9000

Figure A5-5. Radiating fin log file (part 3)

ACSL Reference Manual Page A-27


A. ACSL Example Programs A5. Temperature Distribution along a Radiating Fin

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 4


Radiating Fin Example

X 0.05000000 T 1289.87000 N 10
DTDX-8113.65000 DTDXZ-25147.9000

X 0.10000000 T 1006.62000 N 10
DTDX-3907.71000 DTDXZ-25147.9000

X 0.15000000 T 862.563000 N 10
DTDX-2046.46000 DTDXZ-25147.9000

X 0.20000000 T 790.419000 N 10
DTDX-905.987000 DTDXZ-25147.9000

X 0.25000000 T 768.091000 N 10
DTDX-4.50258000 DTDXZ-25147.9000

X 0.25025000 T 768.090000 N 10
DTDX-0.16719500 DTDXZ-25147.9000

X 0.25025000 T 768.090000 N 10
DTDX-0.16719500 DTDXZ-25147.9000

S FTSPLT=.T. ! Synchronize output with start of each swe


PRINT/NCIPRN=5 x,dtdx,t,n,dtdxz ! Demonstrate column print

Line X DTDX T N DTDXZ


0 1.0000E-10 -20000.0000 2000.00000 1 -20000.0000
5 0.01250000 -11950.2000 1803.78000 1 -20000.0000
10 0.02500000 -6205.17000 1691.85000 1 -20000.0000
15 0.03750000 -1436.42000 1644.65000 1 -20000.0000
20 0.05000000 3125.64000 1655.09000 1 -20000.0000
25 0.06250000 8146.51000 1724.67000 1 -20000.0000
30 0.07500000 14529.5000 1864.32000 1 -20000.0000
0 1.0000E-10 -21461.8000 2000.00000 2 -21461.8000
5 0.01250000 -13560.0000 1784.86000 2 -21461.8000
10 0.02500000 -8190.94000 1650.67000 2 -21461.8000
15 0.03750000 -4016.33000 1575.19000 2 -21461.8000
20 0.05000000 -347.340000 1548.18000 2 -21461.8000
25 0.06250000 3280.23000 1566.34000 2 -21461.8000
30 0.07500000 7313.52000 1631.86000 2 -21461.8000
35 0.08750000 12375.5000 1753.40000 2 -21461.8000
40 0.10000000 19621.8000 1950.17000 2 -21461.8000
0 1.0000E-10 -23025.3000 2000.00000 3 -23025.3000
5 0.01250000 -15278.6000 1764.64000 3 -23025.3000
10 0.02500000 -10289.2000 1606.79000 3 -23025.3000
15 0.03750000 -6681.27000 1501.74000 3 -23025.3000
20 0.05000000 -3799.77000 1436.77000 3 -23025.3000
25 0.06250000 -1278.37000 1405.26000 3 -23025.3000
30 0.07500000 1129.93000 1404.34000 3 -23025.3000
35 0.08750000 3638.00000 1433.92000 3 -23025.3000
40 0.10000000 6488.72000 1496.70000 3 -23025.3000
45 0.11250000 10037.6000 1599.01000 3 -23025.3000
50 0.12500000 14913.9000 1753.09000 3 -23025.3000
55 0.13750000 22426.0000 1982.62000 3 -23025.3000
0 1.0000E-10 -24693.3000 2000.00000 4 -24693.3000

Figure A5-5. Radiating fin log file (part 4)

Page A-28 ACSL Reference Manual


A5. Temperature Distribution along a Radiating Fin A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 5


Radiating Fin Example

Line X DTDX T N DTDXZ


5 0.01250000 -17108.4000 1743.07000 4 -24693.3000
10 0.02500000 -12499.3000 1560.15000 4 -24693.3000
15 0.03750000 -9424.86000 1424.29000 4 -24693.3000
20 0.05000000 -7222.55000 1320.94000 4 -24693.3000
25 0.06250000 -5550.13000 1241.54000 4 -24693.3000
30 0.07500000 -4214.40000 1180.79000 4 -24693.3000
35 0.08750000 -3097.99000 1135.27000 4 -24693.3000
40 0.10000000 -2124.58000 1102.75000 4 -24693.3000
45 0.11250000 -1240.93000 1081.79000 4 -24693.3000
50 0.12500000 -406.731000 1071.52000 4 -24693.3000
55 0.13750000 411.723000 1071.55000 4 -24693.3000
60 0.15000000 1246.12000 1081.88000 4 -24693.3000
65 0.16250000 2130.18000 1102.91000 4 -24693.3000
70 0.17500000 3104.29000 1135.51000 4 -24693.3000
75 0.18750000 4221.77000 1181.11000 4 -24693.3000
80 0.20000000 5559.13000 1241.96000 4 -24693.3000
85 0.21250000 7234.09000 1321.49000 4 -24693.3000
90 0.22500000 9440.46000 1425.01000 4 -24693.3000
95 0.23750000 12521.8000 1561.10000 4 -24693.3000
100 0.25000000 17143.4000 1744.38000 4 -24693.3000
0 1.0000E-10 -25901.5000 2000.00000 5 -25901.5000
5 0.01250000 -18431.5000 1727.46000 5 -25901.5000
10 0.02500000 -14082.7000 1526.48000 5 -25901.5000
15 0.03750000 -11352.8000 1368.75000 5 -25901.5000
20 0.05000000 -9554.59000 1238.82000 5 -25901.5000
25 0.06250000 -8333.95000 1127.50000 5 -25901.5000
30 0.07500000 -7491.48000 1028.91000 5 -25901.5000
35 0.08750000 -6906.54000 939.145000 5 -25901.5000
40 0.10000000 -6501.77000 855.500000 5 -25901.5000
45 0.11250000 -6225.01000 776.069000 5 -25901.5000
50 0.12500000 -6039.69000 699.495000 5 -25901.5000
55 0.13750000 -5919.29000 624.808000 5 -25901.5000
60 0.15000000 -5844.27000 551.324000 5 -25901.5000
65 0.16250000 -5800.05000 478.573000 5 -25901.5000
70 0.17500000 -5775.88000 406.240000 5 -25901.5000
75 0.18750000 -5763.97000 334.125000 5 -25901.5000
80 0.20000000 -5758.90000 262.112000 5 -25901.5000
85 0.21250000 -5757.19000 190.139000 5 -25901.5000
90 0.22500000 -5756.80000 118.177000 5 -25901.5000
95 0.23750000 -5756.76000 46.2177000 5 -25901.5000
0 1.0000E-10 -25498.5000 2000.00000 6 -25498.5000
5 0.01250000 -17990.4000 1732.67000 6 -25498.5000
10 0.02500000 -13556.1000 1537.70000 6 -25498.5000
15 0.03750000 -10715.0000 1387.23000 6 -25498.5000
20 0.05000000 -8789.50000 1266.05000 6 -25498.5000
25 0.06250000 -7431.22000 1165.14000 6 -25498.5000
30 0.07500000 -6445.11000 1078.73000 6 -25498.5000
35 0.08750000 -5714.34000 1002.96000 6 -25498.5000
40 0.10000000 -5165.11000 935.122000 6 -25498.5000
45 0.11250000 -4748.63000 873.280000 6 -25498.5000
50 0.12500000 -4431.42000 815.994000 6 -25498.5000
55 0.13750000 -4189.71000 762.181000 6 -25498.5000
60 0.15000000 -4006.11000 711.010000 6 -25498.5000

Figure A5-5. Radiating fin log file (part 5)

ACSL Reference Manual Page A-29


A. ACSL Example Programs A5. Temperature Distribution along a Radiating Fin

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 6


Radiating Fin Example

Line X DTDX T N DTDXZ


65 0.16250000 -3867.60000 661.841000 6 -25498.5000
70 0.17500000 -3764.19000 614.174000 6 -25498.5000
75 0.18750000 -3688.07000 567.622000 6 -25498.5000
80 0.20000000 -3633.05000 521.885000 6 -25498.5000
85 0.21250000 -3594.20000 476.729000 6 -25498.5000
90 0.22500000 -3567.53000 431.979000 6 -25498.5000
95 0.23750000 -3549.88000 387.503000 6 -25498.5000
100 0.25000000 -3538.70000 343.205000 6 -25498.5000
0 1.0000E-10 -25250.8000 2000.00000 7 -25250.8000
5 0.01250000 -17719.2000 1735.87000 7 -25250.8000
10 0.02500000 -13231.7000 1544.61000 7 -25250.8000
15 0.03750000 -10320.4000 1398.61000 7 -25250.8000
20 0.05000000 -8312.99000 1282.87000 7 -25250.8000
25 0.06250000 -6863.85000 1188.48000 7 -25250.8000
30 0.07500000 -5779.61000 1109.76000 7 -25250.8000
35 0.08750000 -4944.75000 1042.95000 7 -25250.8000
40 0.10000000 -4286.58000 985.412000 7 -25250.8000
45 0.11250000 -3757.37000 935.253000 7 -25250.8000
50 0.12500000 -3324.66000 891.077000 7 -25250.8000
55 0.13750000 -2965.72000 851.830000 7 -25250.8000
60 0.15000000 -2664.22000 816.696000 7 -25250.8000
65 0.16250000 -2408.15000 785.035000 7 -25250.8000
70 0.17500000 -2188.54000 756.340000 7 -25250.8000
75 0.18750000 -1998.55000 730.199000 7 -25250.8000
80 0.20000000 -1832.88000 706.275000 7 -25250.8000
85 0.21250000 -1687.39000 684.293000 7 -25250.8000
90 0.22500000 -1558.79000 664.020000 7 -25250.8000
95 0.23750000 -1444.44000 645.264000 7 -25250.8000
100 0.25000000 -1342.21000 627.859000 7 -25250.8000
0 1.0000E-10 -25157.0000 2000.00000 8 -25157.0000
5 0.01250000 -17616.4000 1737.08000 8 -25157.0000
10 0.02500000 -13108.7000 1547.22000 8 -25157.0000
15 0.03750000 -10170.4000 1402.92000 8 -25157.0000
20 0.05000000 -8131.24000 1289.26000 8 -25157.0000
25 0.06250000 -6646.37000 1197.35000 8 -25157.0000
30 0.07500000 -5522.88000 1121.60000 8 -25157.0000
35 0.08750000 -4645.43000 1058.26000 8 -25157.0000
40 0.10000000 -3941.41000 1004.75000 8 -25157.0000
45 0.11250000 -3363.11000 959.204000 8 -25157.0000
50 0.12500000 -2878.02000 920.280000 8 -25157.0000
55 0.13750000 -2463.30000 886.961000 8 -25157.0000
60 0.15000000 -2102.45000 858.474000 8 -25157.0000
65 0.16250000 -1783.26000 834.226000 8 -25157.0000
70 0.17500000 -1496.49000 813.758000 8 -25157.0000
75 0.18750000 -1234.94000 796.709000 8 -25157.0000
80 0.20000000 -992.930000 782.803000 8 -25157.0000
85 0.21250000 -765.814000 771.824000 8 -25157.0000
90 0.22500000 -549.706000 763.612000 8 -25157.0000
95 0.23750000 -341.249000 758.050000 8 -25157.0000
100 0.25000000 -137.438000 755.061000 8 -25157.0000
0 1.0000E-10 -25147.7000 2000.00000 9 -25147.7000
5 0.01250000 -17606.2000 1737.20000 9 -25147.7000
10 0.02500000 -13096.4000 1547.48000 9 -25147.7000

Figure A5-5. Radiating fin log file (part 6)

Page A-30 ACSL Reference Manual


A5. Temperature Distribution along a Radiating Fin A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 7


Radiating Fin Example

Line X DTDX T N DTDXZ


15 0.03750000 -10155.5000 1403.35000 9 -25147.7000
20 0.05000000 -8113.11000 1289.89000 9 -25147.7000
25 0.06250000 -6624.65000 1198.24000 9 -25147.7000
30 0.07500000 -5497.18000 1122.78000 9 -25147.7000
35 0.08750000 -4615.39000 1059.79000 9 -25147.7000
40 0.10000000 -3906.67000 1006.68000 9 -25147.7000
45 0.11250000 -3323.27000 961.603000 9 -25147.7000
50 0.12500000 -2832.68000 923.211000 9 -25147.7000
55 0.13750000 -2412.01000 890.495000 9 -25147.7000
60 0.15000000 -2044.73000 862.689000 9 -25147.7000
65 0.16250000 -1718.57000 839.206000 9 -25147.7000
70 0.17500000 -1424.21000 819.592000 9 -25147.7000
75 0.18750000 -1154.38000 803.499000 9 -25147.7000
80 0.20000000 -903.288000 790.655000 9 -25147.7000
85 0.21250000 -666.157000 780.858000 9 -25147.7000
90 0.22500000 -438.943000 773.960000 9 -25147.7000
95 0.23750000 -218.091000 769.858000 9 -25147.7000
100 0.25000000 -0.34978200 768.495000 9 -25147.7000
0 1.0000E-10 -25147.9000 2000.00000 10 -25147.9000
5 0.01250000 -17606.5000 1737.20000 10 -25147.9000
10 0.02500000 -13096.8000 1547.47000 10 -25147.9000
15 0.03750000 -10155.9000 1403.34000 10 -25147.9000
20 0.05000000 -8113.65000 1289.87000 10 -25147.9000
25 0.06250000 -6625.30000 1198.21000 10 -25147.9000
30 0.07500000 -5497.95000 1122.75000 10 -25147.9000
35 0.08750000 -4616.29000 1059.74000 10 -25147.9000
40 0.10000000 -3907.71000 1006.62000 10 -25147.9000
45 0.11250000 -3324.47000 961.531000 10 -25147.9000
50 0.12500000 -2834.04000 923.123000 10 -25147.9000
55 0.13750000 -2413.55000 890.389000 10 -25147.9000
60 0.15000000 -2046.46000 862.563000 10 -25147.9000
65 0.16250000 -1720.51000 839.057000 10 -25147.9000
70 0.17500000 -1426.38000 819.418000 10 -25147.9000
75 0.18750000 -1156.80000 803.295000 10 -25147.9000
80 0.20000000 -905.987000 790.419000 10 -25147.9000
85 0.21250000 -669.161000 780.587000 10 -25147.9000
90 0.22500000 -442.287000 773.649000 10 -25147.9000
95 0.23750000 -221.815000 769.503000 10 -25147.9000
100 0.25000000 -4.50258000 768.091000 10 -25147.9000
START ! Repeat last case of previous run
X 1.0000E-10 T 2000.00000 N 1
DTDX-25147.9000 DTDXZ-25147.9000

X 0.05000000 T 1289.87000 N 1
DTDX-8113.65000 DTDXZ-25147.9000

X 0.10000000 T 1006.62000 N 1
DTDX-3907.71000 DTDXZ-25147.9000

X 0.15000000 T 862.563000 N 1
DTDX-2046.46000 DTDXZ-25147.9000

X 0.20000000 T 790.419000 N 1

Figure A5-5. Radiating fin log file (part 7)

ACSL Reference Manual Page A-31


A. ACSL Example Programs A5. Temperature Distribution along a Radiating Fin

ACSL Runtime Exec Version 6 Level 10B 18-FEB-91 10:17:21 Page 8


Radiating Fin Example

DTDX-905.987000 DTDXZ-25147.9000

X 0.25000000 T 768.091000 N 1
DTDX-4.50258000 DTDXZ-25147.9000

X 0.25025000 T 768.090000 N 1
DTDX-0.16719500 DTDXZ-25147.9000

X 0.25025000 T 768.090000 N 1
DTDX-0.16719500 DTDXZ-25147.9000

PLOT/XHI=l,dtdx,t ! Plot converged profile. Use default xaxis


Drawing plot number 1
SPARE ! List execution time
Accumulated cp time 146.3200. Elapsed cp time 27.80000
QUIT

Figure A5-5. Radiating fin log file (part 8)

The initial value for temperature rate (DTDXZ) is a guess. It is given in a


CONSTANT statement so that different guesses can be tried at runtime. Because
DTDXZ is calculated later in the program (i.e., in the TERMINAL section), the
translator issues a warning:
dtdxz = dtdxz - gain*dtdx;
...Multiply defined symbol.... DTDXZ

This warning is issued any time a variable defined in a CONSTANT statement is also
defined in an assignment statement. In most situations, the results of such a procedure
will be in incorrect, or at least have the potential for being incorrect, but this is an
example of a case where it is the best solution. Giving the initial guess in an
assignment statement would not allow experimenting at runtime.
The warning message can be avoided by specifying NO WARNINGS when calling the
ACSL translator. This switch is handled differently for different computer systems.
See the document ACSL Sim User's Guide.
Subroutine LOGD is called in the TERMINAL section to force data logging at the end
of each loop and each run. This call also forces an OUTPUT operation, and with the
argument set to TRUE it resets the counter for /NCIOUT (number of communication
intervals per OUTPUT) so that the last value of the run is always listed.
This program has no DYNAMIC section. It is not necessary to include a DYNAMIC
section in a program when there is no code to be put in it. The communication interval
is still in effect and the data is still logged as though there were a DYNAMIC section
since ACSL automatically provides one to handle these operations.
The event list is cleared by calling utility subroutine INITD after looping back to the
INITIAL section. This subroutine is described in Appendix B. Its purpose is to remove
any events (such as the next communication interval) left over at the end of the
previous loop. In this program, the only event left on the list is the next
communication interval, which actually would not affect subsequent loops, but

Page A-32 ACSL Reference Manual


A5. Temperature Distribution along a Radiating Fin A. ACSL Example Programs

Figure A5-6. Radiating fin temperature profile and gradient

programs with DISCRETE sections and SCHEDULE statements would need the call
to INITD in order to work correctly.
The log file shows the runtime session beginning with a title definition. A SPARE
command gives the accumulated and elapsed cp time. Narrow printout on both the
interactive terminal and the log file is set with TCWPRN and PCWPRN. OUTPUT
and PREPARE lists are established, and the run is executed with START.
During the run, OUTPUT appears, showing that the first three iterations find that the
intermediate temperature is more than one percent greater than the starting value,
triggering the terminate (TERMT) condition. For the fourth and subsequent iterations,
the final value of X is 0.25, and now the final value of dT/dx is slowly reduced until at
iteration number ten the value is -0.153, well within the ERROR tolerance of 0.2.
Values for variables on the PREPARE list are logged on an intermediate file (raw run
record, or RRR) for printing and plotting after the run. On page 4 of the log file,
system symbol FTSPLT (flyback trace suppression) is set TRUE and and a PRINT
command issued. FTSPLT resynchronizes the line count to zero when the independent
variable (first variable on the PREPAR list) becomes more negative than its previous
value. PRINT produces the same information as OUTPUT, but in a more readable
form.
Once the iteration has converged, a second START (on page 7 of the log file) reruns
the last case, since the initial condition on temperature slope (DTDXZ) is still the
value from the converged iteration of the previous run. Rerunning the last case
overwrites the data in the intermediate file so that only one run is plotted, as shown in
Figure A5-6. The temperature gradient (DTDX) and temperature (T) are plotted
against distance (X) along the fin. It is often easier and more cost effective merely to
repeat the last run of an iteration rather than make complicated arrangements to save
each run separately before it is known that the convergence criteria have been
satisfied. Plotting after the first START command would have shown the parametric
set of curves as the iteration proceeded, since the RRR file is not rewound between
runs on cycling from TERMINAL to INITIAL sections. In this case, the cluster of
curves causes rather an cluttered plot and does not provide much information; only the
final profile is needed.

ACSL Reference Manual Page A-33


A. ACSL Example Programs A6. Aircraft Arresting Gear

6. Aircraft
Arresting Gear

The aircraft arresting gear example includes a function generator and input relays. It
illustrates line and strip plot capabilities. It also shows the use of standard FORTRAN
output statements within ACSL.
Figure A6-1 shows the geometry of the aircraft arresting gear system, which is
designed to halt a moving aircraft that would otherwise overrun the end of a runway.

Figure A6-1. Aircraft arresting gear system

Page A-34 ACSL Reference Manual


A6. Aircraft Arresting Gear A. ACSL Example Programs

It is similar in principle to the gear used on aircraft carriers. A plot of the "water
squeezer" damping function, f(y3), is also shown on the figure. The aims of the
simulation are to determine the range of aircraft weights and speeds that can be
accommodated without exceeding the working limits of the cables or the allowable
piston travel. Two cases involving different aircraft velocities are investigated.
The differential equations describing the acceleration of the three masses are:

d 2y3
m3 = f K2 − f D
dt 2

d 2y2
m2 = w f K1 − f K2
dt 2

d 2x
m1 = − 2 f K1 sin θ
dt 2

where the cable tension is given by:

k (y − 2y2) y1 > 2y2


f K1 =  1 1
0 y1 ≤ 2y2

k (y − y3 ) y2 > y3
f K2 =  2 2
0 y2 ≤ y3

Drag force from the water squeezer is given by:


2
 dy3 
f D = F( y3)  
 dt 
Geometrical constraints lead to:

y1 = √
x2 + h2 − h

x x
sin θ = =
h + y1

√x + h2
2

Constants used in the example are as follows:

m1 = 1400 slugs
m2 = 45.28 slugs
m3 = 20 slugs
k1 = 4550 lb/ft
k2 = 25,300 lb/ft
h = 125 ft

Initial conditions are given by:


.
y3(0) =0 y3(0) =0
.
y2(0) =0 y2(0) =0
.
x(0) = 200 ft/s (Run 1) x(0) =0
= 290 ft/s (Run 2)

ACSL Reference Manual Page A-35


A. ACSL Example Programs A6. Aircraft Arresting Gear

A function of one variable is used for the squeezer drag coefficient. The data points for
the function are shown in the plot of f(y3) in Figure A6-1 and in TABLE FY3 in the
listing of the model in Figure A6-2. Interpolation between points is linear. For this
function, sixteen breakpoints (15 segments) have been used. The degree of fit to a
given function can be adjusted by using more (or fewer) breakpoints as necessary.
This example is programmed in the explicit mode with INITIAL, DYNAMIC, and
DERIVATIVE sections being defined. Using explicit structure allows us to show the
use of standard FORTRAN output to write out information. In this program, the initial
speed and case number are printed out at the beginning of each run; i.e., in the
INITIAL section. Logical unit 9 in the WRITE statement refers to the PRN high
volume print unit (the log file). The DERIVATIVE section contains the descriptive
equations modeling the system.
Cables transmit only tensile forces, and account must be taken of the fact that when
the cable extension is negative, the force is zero. Expressing the force as proportional
to the simple extension k2(y2 − y3) is more representative of a spring. In the original
formulation of this problem, the function real switch operator RSW was used; i.e.,
fk2 = RSW(y2 .GE. y3, k2*(y2 - y3), 0.0)

RSW operates so that when the first argument is true, the second argument is returned;
if the first argument is false, then the third argument is returned. A more elegant way
of accomplishing the same thing is to use the FORTRAN function DIM that returns
the positive difference between the two arguments; if the difference is negative
(argument 1 minus argument 2), the result is zero. The force equation then becomes:
fk2= k2*DIM(y2, y3)

Note the choice of termination conditions. The TERMT statement stops the problem
after 10 seconds, or when X reaches 1000 ft.
The runtime log file is shown in Figure A6-3. The TITLE is set, the OUTPUT and
PREPARE lists are specified, SPEED is set, and the run is started.
The integration step size is set to take into account the small time constant associated
with the third mass (m3) and the nonlinearity of the function that makes the program
particularly susceptible to step size. The system becomes unstable if the step size is
increased to 4 msec. Using the default fixed step algorithm (IALG = 5), NSTP is set to
1 and the maximum step size (MAXT = 0.001) controls the integration step. The
advantage of this method is that MAXT and CINT can be controlled independently,
CINT need not be an even multiple of MAXT, and MAXT alone (rather than CINT
and NSTP together) controls the step size. CINTERVAL (with the variable named DL
in this program) controls the step size only if it is smaller than MAXT, since it is the
smaller of these two values which becomes the integration step size.
The second run illustrates two types of plots, CALPLT (line) and STRPLT (strip).
When system variable CALPLT is TRUE, the curves are all drawn in the same area
and the Y axes are side by side, as in Figure A6-5. A strip plot (STRPLT=.TRUE.) is
shown in Figure A6-6. Each curve occupies a separate slot, nominally two inches by
five inches, stacked from the bottom up in the order given. /XTAG adds a unit
specification to indpendent variable T on the X axis for both plots.
These plot show that the peak deceleration increases from about 100 ft/s2 (3 g's) to 150
ft/s2 (5 g's). A factor of even more interest is the force in the cable, since the cable will
snap if too much force is applied. As a follow-on exercise, plot FK2 for the two runs.

Page A-36 ACSL Reference Manual


A6. Aircraft Arresting Gear A. ACSL Example Programs

PROGRAM aircraft arresting gear

ncase = 0 ! done once at very beginning

INITIAL
INTEGER ncase
ncase = ncase + 1 ! bump case number
LINES(5) ! tell system about to print five lines
WRITE(9, 200) speed, ncase
200..FORMAT(//20x,'Aircraft speed - ',f6.2,' Run no. ',i3//)
END ! of initial
DYNAMIC
CINTERVAL dl = 0.10 ! communication interval
MAXTERVAL maxt = 0.001 ! integration step size
NSTEPS nstp = 1 ! decouple maxt from cinterval
DERIVATIVE
!-----------------------compute second derivatives
y3dd =(fk2 - fd)/m3 ; CONSTANT m3 = 20.0
y2dd =(2.0*fk1 - fk2)/m2 ; CONSTANT m2 = 45.28
xdd =-2.0*fk1*sth/m1 ; CONSTANT m1 = 140.0
!-----------------------integrate for first derivatives
y3d = INTEG(y3dd, 0.0)
y2d = INTEG(y2dd, 0.0)
xd = INTEG(xdd , speed) ; CONSTANT speed = 250.0
!-----------------------integrate for positions
y3 = INTEG(y3d, 0.0)
y2 = INTEG(y2d, 0.0)
x = INTEG(xd , 0.0)
!-----------------------cable tension becomes zero when slack
! can never go negative - so use positive
! difference function
fk1 = k1*DIM(y1, 2.0*y2) ; CONSTANT k1 = 4550.0
fk2 = k2*DIM(y2, y3) ; CONSTANT k2 = 25300.0
!-----------------------water squeezer drag.
table fy3, 1 , 16 &
/ -10.0 , 0.0 , 30.0 , 60.0 , 120.0 &
, 150.0 , 180.0 , 210.0 , 240.0 , 270.0 &
, 282.0 , 294.0 , 306.0 , 312.0 , 324.0 &
, 350.0 &
, 8.33 , 8.33 , 4.0 , 1.6 , 5.2 &
, 5.2 , 6.6 , 8.3 , 10.7 , 16.0 &
, 21.0 , 28.0 , 41.0 , 50.0 , 90.0 &
, 90.0 /
fd = fy3(y3)*y3d**2
!-----------------------geometrical relations
CONSTANT h = 125.0
y1 = SQRT(x**2 + h**2) - h
sth = x/(h + y1)
END ! of derivative
!-----------------------specify termination condition
TERMT(t.GE.tstp, 'Time Limit') ; CONSTANT tstp = 9.999
TERMT(x.GE.xmx, 'Position Limit') ; CONSTANT xmx = 1000.0
END ! of dynamic
END ! of program

Figure A6-2. Aircraft arresting gear program

ACSL Reference Manual Page A-37


A. ACSL Example Programs A6. Aircraft Arresting Gear

ACSL Runtime Exec Version 6 Level 10B 20-FEB-91 11:16:18 Page 1

SET TITLE = 'Aircraft Arresting Gear Example'


SPARE
Accumulated cp time 406.1000. Elapsed cp time 0.
SET TCWPRN=72 ! force 3 column output width
OUTPUT/NCIOUT=20 t, y3dd, y3d, y3, fd, y2dd, y2d, y2, fk2 &
, xdd, xd, x, fk1, y1
PREPARE t, x, xd, xdd
SET speed=200.0 ; START ; PLOT x, xd, xdd

Aircraft speed - 200.00 Run no. 1

T 0. Y3DD 0. Y3D 0.
Y3 0. FD 0. Y2DD 0.
Y2D 0. Y2 0. FK2 0.
XDD 0. XD 200.000000 X 0.
FK1 0. Y1 0.

T 2.00000000 Y3DD-18.0099000 Y3D 45.9393000


Y3 96.2946000 FD 7972.47000 Y2DD-18.8128000
Y2D 45.8335000 Y2 96.5955000 FK2 7612.27000
XDD-44.4254000 XD 99.1682000 X 293.417000
FK1 3380.22000 Y1 193.934000

T 4.00000000 Y3DD-6.57992000 Y3D 20.9752000


Y3 158.437000 FD 2461.01000 Y2DD-6.69082000
Y2D 20.9324000 Y2 158.529000 FK2 2329.41000
XDD-13.8845000 XD 43.5150000 X 424.248000
FK1 1013.22000 Y1 317.280000

T 6.00000000 Y3DD-2.88461000 Y3D 12.1193000


Y3 190.313000 FD 1055.24000 Y2DD-2.88286000
Y2D 12.1044000 Y2 190.353000 FK2 997.546000
XDD-6.00084000 XD 24.9457000 X 490.112000
FK1 433.505000 Y1 380.801000

T 8.00000000 Y3DD-1.46565000 Y3D 7.98094000


Y3 209.945000 FD 528.472000 Y2DD-1.44382000
Y2D 7.97485000 Y2 209.964000 FK2 499.159000
XDD-3.01584000 XD 16.3712000 X 530.447000
FK1 216.891000 Y1 419.976000

Time Limit
T 10.0000000 Y3DD-0.84401900 Y3D 5.73444000
Y3 223.460000 FD 308.346000 Y2DD-0.85578000
Y2D 5.73184000 Y2 223.472000 FK2 291.466000
XDD-1.76148000 XD 11.7405000 X 558.146000
FK1 126.358000 Y1 446.972000

Drawing plot number 1

Figure A6-3. Aircraft arresting gear log file (part 1)

Page A-38 ACSL Reference Manual


A6. Aircraft Arresting Gear A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 20-FEB-91 11:16:18 Page 2


Aircraft Arresting Gear Example

SET speed=290.0 ; START

Aircraft speed - 290.00 Run no. 2

T 0. Y3DD 0. Y3D 0.
Y3 0. FD 0. Y2DD 0.
Y2D 0. Y2 0. FK2 0.
XDD 0. XD 290.000000 X 0.
FK1 0. Y1 0.

T 2.00000000 Y3DD-27.0523000 Y3D 45.5412000


Y3 128.366000 FD 10784.8000 Y2DD-29.7800000
Y2D 44.9787000 Y2 128.771000 FK2 10243.8000
XDD-60.0685000 XD 93.2928000 X 362.577000
FK1 4447.66000 Y1 258.519000

T 4.00000000 Y3DD-6.47941000 Y3D 18.5077000


Y3 185.759000 FD 2372.52000 Y2DD-6.43700000
Y2D 18.4580000 Y2 185.847000 FK2 2242.94000
XDD-13.4908000 XD 38.0155000 X 480.930000
FK1 975.734000 Y1 371.909000

T 6.00000000 Y3DD-2.52881000 Y3D 10.3046000


Y3 213.274000 FD 909.146000 Y2DD-2.49377000
Y2D 10.2911000 Y2 213.308000 FK2 858.569000
XDD-5.18757000 XD 21.0975000 X 537.351000
FK1 372.826000 Y1 426.699000

T 8.00000000 Y3DD-1.24592000 Y3D 6.73013000


Y3 229.892000 FD 448.026000 Y2DD-1.23620000
Y2D 6.72517000 Y2 229.909000 FK2 423.108000
XDD-2.56178000 XD 13.7554000 X 571.344000
FK1 183.566000 Y1 459.858000

Time Limit
T 10.0000000 Y3DD-0.69317600 Y3D 4.84296000
Y3 241.289000 FD 256.301000 Y2DD-0.72364700
Y2D 4.84055000 Y2 241.299000 FK2 242.438000
XDD-1.46562000 XD 9.88800000 X 594.623000
FK1 104.836000 Y1 482.620000

SET STRPLT=.T.,PSFSPL=0.8 ! Turn on strip plots and scale for screen


PLOT/XTAG='(sec)' x,xd,xdd
Drawing plot number 2
SPARE ! List execution time
Accumulated cp time 469.0100. Elapsed cp time 62.91000
QUIT

Figure A6-3. Aircraft arresting gear log file (part 2)

ACSL Reference Manual Page A-39


A. ACSL Example Programs A6. Aircraft Arresting Gear

Figure A6-4. Displacement and its derivatives for SPEED of 200 ft/s

Figure A6-5. SPEED = 290 ft/s - line plot Figure A6-6. SPEED = 290 ft/s - strip plots

Page A-40 ACSL Reference Manual


A7. Aircraft Longitudinal Study A. ACSL Example Programs

7. Aircraft
Longitudinal
Study

The aircraft longitudinal study illustrates an iteration to establish correct initial


conditions (trim), the solution of an implicit loop, and the use of fixed versus variable
step integration algorithms.
The equations describing the motion of an aircraft in three degrees-of-freedom in a
longitudinal plane are as follows:
Velocity
.
mV = T cos α − D − W sin γ

where m is mass, V is longitudinal velocity, T is thrust, α is angle-of-attack, D is drag,


W is weight, γ is flight path angle, q is dynamic pressure, S is reference cross-sectional
area, ρ is air density, δ is fin deflection, and:

m = W / 32.2 slugs
D = qSCD lbs
q = 0.5 ρ V2 lbs/ft2
CD = CD0 + CDαα + CDδε |δε|

Flight Path
.
mV γ = L − W cos γ + T sin α
L = qSCL lbs _ . .
CL = CL0 + CLα α + CLδδε + (c ⁄ 2V ) (CLα. α + CLqθ)
_
where L is lift, c is the characteristic chord, and θ is pitch angle.

Pitch
..
Iy θ = M

where M is moment and:


_
M = qS cCM lbs
_ .
CM = CM0 + CMαα + CMδ δε + ( c ⁄ 2V ) (CMα. + CMqθ)

Angle of Attack
. . .
α = θ − γ

Position
.
h = V sin γ
.
x = V cos γ

ACSL Reference Manual Page A-41


A. ACSL Example Programs A7. Aircraft Longitudinal Study

Constants

T = 2,000 lb
Iy = 27x106 slug-ft2
ρ = 0.0023 slugs/ft3
S = 6,000 ft2
_W = 500,000 lb
c = 30 ft

Aerodynamic Coefficients

CD0 = 0.14
CDα = 0.63 /rad
CDδε = 0.003 /rad
C L0 = 1.1
C Lα = 5.2 /rad
CLδε = 0.36 /rad
CLα. =2 /rad/sec
C Lq = 5.5 /rad/sec
CM0 = -0.05
CMα = 0.2 /rad
CMδε = 1.4 /rad
CMα. =8 /rad/sec
CMq = 22 /rad/sec

Initial Conditions

V(0) = 200 ft/sec


h(0) = 1500 ft
θ(0) =0 rad

Values of θ(0), γ(0), and δε are to be computed so.. that the aircraft is. flying in a
.
trimmed condition; i.e., the angular acceleration θ, flight path rate γ, and longitudinal
acceleration V should all be zero. It is more usual to adjust throttle setting as thrust T
to maintain a given flight path angle rather than the other way around.
The program listing is shown in Figure A7-1. The iteration is mechanized by choosing
starting values in the INITIAL section for θ(0), γ(0), and δε (zero seems good enough).
In the DYNAMIC section, after the first evaluation of derivatives, a weighted mean
square error is calculated:
. .. .
E = V2 + (20 θ)2 + (100 γ)2

This error is checked on whether it is less than a maximum allowable error (0.1). If
not, the initial guess is corrected by:
.
γ (0) = γ (0) + 0.02 V
.
θ(0) = θ(0) − 1.0 γ
..
δε(0) = δε(0) + 2.0 θ

Page A-42 ACSL Reference Manual


A7. Aircraft Longitudinal Study A. ACSL Example Programs

A more precise (and faster) iteration would calculate the derivative of the error vector
(V, γ, θ) with respect to the control vector (γ, θ, δ), which would result in a
three-by-three Jacobian matrix (called J, for instance). The matrix J would then be
inverted and the new control vector given by:
. . ..
(γ, θ, δε)T = (γ, θ, δε)T − J−1 (V, γ, θ)T

However, the simple iteration given suffices for this fixed example.
Once convergence has been satisfied, the variable START is set FALSE and the error
check is never examined again. Note that in order to recompute the derivatives, the
program cycles from the DYNAMIC section back to the INITIAL section. The
integration routine is set up and derivatives calculated at the transition from INITIAL
into DYNAMIC.
Another feature illustrated in this example is the use of the IMPLC operator to
calculate angle-of-attack rate. Angle-of-attack rate is the difference between body rate
and flight path rate. Flight path rate depends on lift, which in turn depends on the
coefficient CL. This coefficient includes angle-of-attack rate, so an algebraic (implicit)
loop is formed. Such a loop is a problem for the sorting algorithm, but it can be solved
by including the IMPLC operator to calculate the angle-of-attack rate as follows:
. . .
α = IMPLC(γ + α − q, aldz)
. .
The residual is the difference between the sum of α and q and flight path
. rate γ, which
should be zero. The IMPLC operator adjusts the angle of attack rate α to make this so.
This iteration is time consuming and is performed at each derivative evaluation. In this
example, since the. equations are linear, it would be possible (and better) to solve
algebraically for α before writing the model
. equations. However, if CL is given in
functional form as a table (e.g., CL(α, α)), then the implicit operator is required.
The log file from a runtime session is shown in Figure A7-2. An OUTPUT list is
established to be output at every ten communication intervals; a similar set of variables
is specified in the PREPARE command for later printing and plotting. The START
command initiates the run and the iteration is reported (via a WRITE statement in the
program) in the next eight lines of output during which the error, ERR, is reduced
from 55.4 to 0.1. Then the run starts and the OUTPUT variables are written out every
0.5 seconds. At the end of the run (TMX = 6.49 seconds), two PRINT commands list
selected variables, the first at every four communication intervals (0.2 seconds) and
the second at every eight (0.4 seconds).
A strip plot is shown in Figure A7-3. The strip plot option is set up (STRPLT=.T.) at
the bottom of Page 3 of the log file. The plot scale factor reduces the plot to fit on the
screen (PSFSPL=0.3), the X axis length is increased (XINSPL=10.0), and the distance
between tick marks is increased (XTISPL=2.0). Reducing the overall plot size and
doubling XINSPL maintains the X axis length but reduces the strip width, allowing
seven variables to be stacked on one frame. The first PLOT command sets /XHI to a
value chosen in a CONSTANT statement; the second PLOT command actually draws
the picture. PLOT commands relating to the X axis remain in effect for subsequent
plots until explicitly changed. Automatic scaling would round the X axis scale so that
it runs from zero to ten, thus wasting 35% of the plot area. With our choice of /XHI,
the scales are marked in fractions rather than whole numbers, but this is the user's
option; we prefer maximum area utilization over even scales.

ACSL Reference Manual Page A-43


A. ACSL Example Programs A7. Aircraft Longitudinal Study

PROGRAM aircraft longitudinal stability study


INITIAL
!-----------------------need mass from weight in lbs
CONSTANT g = 32.2
aldz = qz
mass = w/g
!-----------------------set initial guess for initial conditions
gaz = 0.0 ! flight path angle
thz = 0.0 ! pitch angle
dlz = 0.0 ! fin deflection
!-----------------------start will be made true when iteration
! converges
LOGICAL start
start = .false.
i1: CONTINUE
END ! of initial
!-----------------------the transition from initial to dynamic
! transfers all initial conditions to the
! state variables and evaluates the code
! in the derivative section once
DYNAMIC
!-----------------------change name of independent variable
! to avoid name conflict
VARIABLE time = 0.0
!-----------------------communication interval
CINTERVAL cint = 0.05
DERIVATIVE
!-----------------------fin deflection is kicked to excite system
CONSTANT tz = 0.5
dle = 0.1*STEP(tz) + dlz
!------------------------angle of attack
al = th - ga
!-----------------------drag coefficient
CONSTANT cdz = 0.14 , cdal = 0.63 , cdde = 0.003
cd = cdz + cdal*al + cdde*ABS(dle)
!-----------------------lift coefficient
CONSTANT clz = 1.1 , clal = 5.2 , clde = 0.36
CONSTANT cb = 30.0 , clad = 2.0 , cltd = 5.5
cl = &
clz + clal*al + clde*dle + (cb/(2*v))*(clad*ald + cltd*q)
!-----------------------pitch moment coefficient
CONSTANT cmz = 0.05 , cmal =-0.2 , cmde =-1.4
CONSTANT cmad =-8.0 , cmtd =-22.0
cm = &
cmz + cmal*al + cmde*dle + (cb/(2*v))*(cmad*ald + cmtd*q)
!-----------------------dynamic pressure
CONSTANT ro = 2.3e-3 ! air density
qp = 0.5*ro*v**2
!-----------------------drag and lift
CONSTANT s = 6000.0 ! characteristic span
d = qp*s*cd ; l = qp*s*cl
!-----------------------pitching moment
m = qp*s*cb*cm

Figure A7-1. Aircraft longitudinal study program (part 1)

Page A-44 ACSL Reference Manual


A7. Aircraft Longitudinal Study A. ACSL Example Programs

!-----------------------flight path rate


CONSTANT w = 500000.0 , t = 2000.0
gad = (l - w*COS(ga) + t*SIN(al))/(mass*v)
!-----------------------longitudinal velocity rate
vd = (t*COS(al) - d - w*SIN(ga))/mass
!-----------------------need pitch rate derivative explicitly
! for iteration
CONSTANT iy = 27.0e6 ! pitch moment of inertia
qd = m/iy
!-----------------------implicit loop for angle of attach rate
! sum of flight path rate and angle of attack rate = pitch rate
ald = IMPLC(gad + ald - q, aldz)
!-----------------------pitch rate
CONSTANT qz = 0.0 ; q = INTVC(qd, qz)
!-----------------------pitch angle
th = INTEG(q, thz)
!-----------------------velocity
CONSTANT vz = 200.0 ; v = INTVC(vd, vz)
!-----------------------flight path angle
ga = INTVC(gad, gaz)
!-----------------------height
CONSTANT hz = 1500.0 ; h = INTEG(v*SIN(ga), hz)
!-----------------------horizontal distance travelled
CONSTANT xz = 0.0 ; x = INTEG(v*COS(ga), xz)
END ! of derivative
!-----------------------if iteration converged
if(start) GO TO d1
!-----------------------weighted error from trim
error = vd**2 + (20.0*qd)**2 + (100.0*gad)**2
!-----------------------if within tolerance
CONSTANT ermx = 0.1
start = error .LE. ermx
!-----------------------compute new trial values
CONSTANT k1 = 0.02 , k2 = -1.0 , k3 = 2.0
gaz = gaz + k1*vd
thz = thz + k2*gad
dlz = dlz + k3*qd
!-----------------------print iteration information by writing
! to a buffer and then displaying this string. It is given an
! initial value to prevent message about used but not defined
CHARACTER buffer*80; constant buffer = ' '
WRITE(buffer, 99) gaz, thz, dlz, error
CALL DISSTR(buffer)
99: FORMAT(' gaz ',e12.4,' thz ',e12.4,' dle ',e12.4,' err ',f10.1)
!-----------------------return to initial region to restart
! the integration algorithm
GO TO i1
d1: CONTINUE
!-----------------------express stopping criteria
CONSTANT tmx = 6.49
TERMT(time.GE.tmx, 'Time Limit')
END ! of dynamic
END ! of program

Figure A7-1. Aircraft longitudinal study program (part 2)

ACSL Reference Manual Page A-45


A. ACSL Example Programs A7. Aircraft Longitudinal Study

ACSL Runtime Exec Version 6 Level 10B 27-FEB-91 11:48:34 Page 1

SET TITLE = 'Longitudinal Aircraft Stability Study'


SPARE
Accumulated cp time 11.44000. Elapsed cp time 0.
S TCWPRN=80,PCWPRN=80 ! Force 3 column output width
OUTPUT/NCIOUT=10 time, m, q, vd, gad, dle, x, v, th, ga, al, ef, ald
PREPARE time, m, q, vd, gad, dle, v, th, ga, al
SET nstp = 10
START
gaz -0.4719E-01 thz 0.6241E-01 dle 0.7700E-02 err 44.5
gaz -0.8857E-01 thz 0.7434E-01 dle 0.1392E-01 err 5.7
gaz -0.1153E+00 thz 0.6129E-01 dle 0.1745E-01 err 3.5
gaz -0.1280E+00 thz 0.4143E-01 dle 0.1878E-01 err 4.3
gaz -0.1310E+00 thz 0.2455E-01 dle 0.1874E-01 err 2.9
gaz -0.1290E+00 thz 0.1397E-01 dle 0.1813E-01 err 1.1
gaz -0.1254E+00 thz 0.9211E-02 dle 0.1745E-01 err 0.3
gaz -0.1222E+00 thz 0.8352E-02 dle 0.1694E-01 err 0.0
TIME 0. M-3821.85000 Q 0.
VD 0.10212400 GAD-0.00105422 DLE 0.01693790
X 0. V 200.000000 TH 0.00835185
GA-0.12222800 AL 0.13058000 EF 0.
ALD 0.00105423

TIME 0.50000000 M-2106.67000 Q-5.3857E-05


VD 0.10956200 GAD-7.6518E-04 DLE 0.01693790
X 99.2640000 V 200.053000 TH 0.00833707
GA-0.12268000 AL 0.13101700 EF 0.
ALD 7.1134E-04

TIME 1.00000000 M-818848.000 Q-0.01804110


VD 0.14483600 GAD-8.2791E-04 DLE 0.11693800
X 198.557000 V 200.110000 TH 0.00356959
GA-0.12216600 AL 0.12573500 EF 0.
ALD-0.01721320

TIME 1.50000000 M-588024.000 Q-0.03094360


VD 0.31523900 GAD-0.00616469 DLE 0.11693800
X 297.882000 V 200.220000 TH-0.00885432
GA-0.12385800 AL 0.11500400 EF 0.
ALD-0.02477890

TIME 2.00000000 M-424769.000 Q-0.04023500


VD 0.60363600 GAD-0.01228010 DLE 0.11693800
X 397.249000 V 200.445000 TH-0.02677470
GA-0.12845700 AL 0.10168200 EF 0.
ALD-0.02795490

TIME 2.50000000 M-308552.000 Q-0.04696490


VD 0.99488200 GAD-0.01837100 DLE 0.11693800
X 496.689000 V 200.840000 TH-0.04866420
GA-0.13613300 AL 0.08746840 EF 0.
ALD-0.02859490

TIME 3.00000000 M-225198.000 Q-0.05186500


VD 1.47280000 GAD-0.02398200 DLE 0.11693800
X 596.251000 V 201.454000 TH-0.07343580

Figure A7-2. Aircraft longitudinal study log file (part 1)

Page A-46 ACSL Reference Manual


A7. Aircraft Longitudinal Study A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 27-FEB-91 11:48:34 Page 2


Longitudinal Aircraft Stability Study

GA-0.14674700 AL 0.07331110 EF 0.
ALD-0.02788300

TIME 3.50000000 M-164879.000 Q-0.05544720


VD 2.02151000 GAD-0.02888260 DLE 0.11693800
X 696.002000 V 202.325000 TH-0.10031000
GA-0.15999500 AL 0.05968500 EF 0.
ALD-0.02656460

TIME 4.00000000 M-120820.000 Q-0.05807150


VD 2.62617000 GAD-0.03298520 DLE 0.11693800
X 796.020000 V 203.485000 TH-0.12872400
GA-0.17549600 AL 0.04677210 EF 0.
ALD-0.02508630

TIME 4.50000000 M-88335.5000 Q-0.05999310


VD 3.27343000 GAD-0.03629170 DLE 0.11693800
X 896.391000 V 204.958000 TH-0.15826500
GA-0.19284800 AL 0.03458240 EF 0.
ALD-0.02370150

TIME 5.00000000 M-64181.2000 Q-0.06139440


VD 3.95168000 GAD-0.03885730 DLE 0.11693800
X 997.210000 V 206.763000 TH-0.18863100
GA-0.21166400 AL 0.02303340 EF 0.
ALD-0.02253710

TIME 5.50000000 M-46110.4000 Q-0.06240760


VD 4.65109000 GAD-0.04076760 DLE 0.11693800
X 1098.57000 V 208.913000 TH-0.21959500
GA-0.23159600 AL 0.01200050 EF 0.
ALD-0.02164000

TIME 6.00000000 M-32562.0000 Q-0.06313010


VD 5.36369000 GAD-0.04212250 DLE 0.11693800
X 1200.58000 V 211.417000 TH-0.25099000
GA-0.25233900 AL 0.00134915 EF 0.
ALD-0.02100760

Time Limit
TIME 6.50000000 M-22446.0000 Q-0.06363470
VD 6.08326000 GAD-0.04302590 DLE 0.11693800
X 1303.33000 V 214.278000 TH-0.28268900
GA-0.27364300 AL-0.00904608 EF 0.
ALD-0.02060880

! Make column print of selected variables from prepar list


PRINT/NCIPRN=4,time,m,q,vd,gad

Line TIME M Q VD GAD


0 0. -3821.85000 0. 0.10212400 -0.00105422
4 0.20000000 -3054.08000 -2.5393E-05 0.10544200 -9.2969E-04
8 0.40000000 -2397.99000 -4.5523E-05 0.10829700 -8.1730E-04
12 0.60000000 -1.0717E+06 -0.00412532 0.10163300 0.00200841
16 0.80000000 -936348.000 -0.01155060 0.11255400 8.1324E-04

Figure A7-2. Aircraft longitudinal study log file (part 2)

ACSL Reference Manual Page A-47


A. ACSL Example Programs A7. Aircraft Longitudinal Study

ACSL Runtime Exec Version 6 Level 10B 27-FEB-91 11:48:34 Page 3


Longitudinal Aircraft Stability Study

Line TIME M Q VD GAD


20 1.00000000 -818848.000 -0.01804110 0.14483600 -8.2791E-04
24 1.20000000 -716758.000 -0.02371970 0.19797000 -0.00279837
28 1.40000000 -627988.000 -0.02869260 0.27127400 -0.00500142
32 1.60000000 -550735.000 -0.03305160 0.36393400 -0.00735744
36 1.80000000 -483444.000 -0.03687620 0.47504600 -0.00980132
40 2.00000000 -424769.000 -0.04023500 0.60363600 -0.01228010
44 2.20000000 -373551.000 -0.04318750 0.74869300 -0.01475110
48 2.40000000 -328804.000 -0.04578510 0.90917900 -0.01718040
52 2.60000000 -289625.000 -0.04807230 1.08405000 -0.01954160
56 2.80000000 -255308.000 -0.05008770 1.27227000 -0.02181390
60 3.00000000 -225198.000 -0.05186500 1.47280000 -0.02398200
64 3.20000000 -198741.000 -0.05343300 1.68465000 -0.02603490
68 3.40000000 -175460.000 -0.05481710 1.90683000 -0.02796500
72 3.60000000 -154941.000 -0.05603920 2.13841000 -0.02976790
76 3.80000000 -136831.000 -0.05711850 2.37848000 -0.03144130
80 4.00000000 -120820.000 -0.05807150 2.62617000 -0.03298520
84 4.20000000 -106646.000 -0.05891290 2.88065000 -0.03440120
88 4.40000000 -94079.0000 -0.05965540 3.14116000 -0.03569200
92 4.60000000 -82922.3000 -0.06031020 3.40694000 -0.03686170
96 4.80000000 -73005.3000 -0.06088700 3.67733000 -0.03791500
100 5.00000000 -64181.2000 -0.06139440 3.95168000 -0.03885730
104 5.20000000 -56323.2000 -0.06184020 4.22939000 -0.03969470
108 5.40000000 -49320.7000 -0.06223100 4.50993000 -0.04043330
112 5.60000000 -43079.5000 -0.06257280 4.79278000 -0.04107970
116 5.80000000 -37516.9000 -0.06287090 5.07751000 -0.04164050
120 6.00000000 -32562.0000 -0.06313010 5.36369000 -0.04212250
124 6.20000000 -28152.1000 -0.06335460 5.65098000 -0.04253220
128 6.40000000 -24234.9000 -0.06354830 5.93903000 -0.04287640
PRINT/NCIPRN=8,time,dle,th,ga,al

Line TIME DLE TH GA AL


0 0. 0.01693790 0.00835185 -0.12222800 0.13058000
8 0.40000000 0.01693790 0.00834205 -0.12260100 0.13094300
16 0.80000000 0.11693800 0.00654326 -0.12217100 0.12871400
24 1.20000000 0.11693800 -6.1909E-04 -0.12252400 0.12190500
32 1.60000000 0.11693800 -0.01205520 -0.12453400 0.11247900
40 2.00000000 0.11693800 -0.02677470 -0.12845700 0.10168200
48 2.40000000 0.11693800 -0.04402600 -0.13435500 0.09032880
56 2.80000000 0.11693800 -0.06323690 -0.14216600 0.07892860
64 3.20000000 0.11693800 -0.08396890 -0.15175100 0.06778170
72 3.60000000 0.11693800 -0.10588500 -0.16292800 0.05704320
80 4.00000000 0.11693800 -0.12872400 -0.17549600 0.04677210
88 4.40000000 0.11693800 -0.15228300 -0.18924800 0.03696560
96 4.80000000 0.11693800 -0.17640100 -0.20398500 0.02758360
104 5.20000000 0.11693800 -0.20095500 -0.21952100 0.01856590
112 5.60000000 0.11693800 -0.22584400 -0.23568800 0.00984395
120 6.00000000 0.11693800 -0.25099000 -0.25233900 0.00134915
128 6.40000000 0.11693800 -0.27633000 -0.26934800 -0.00698215
S STRPLT=.T.,CALPLT=.F.,PSFSPL=0.3,XINSPL=10.0,XTISPL=2.0
PLOT/XHI=tmx ! Plot nothing - but establish full range for scale
Drawing plot number 1
PLOT th,al,ga,gad,q,m,dle
Drawing plot number 2

Figure A7-2. Aircraft longitudinal study log file (part 3)

Page A-48 ACSL Reference Manual


A7. Aircraft Longitudinal Study A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 27-FEB-91 1:48:34 Page 4


Longitudinal Aircraft Stability Study

! Change output list for time trial between rk4 and adams-moulton
OUTPUT/CLEAR time,cioitg,cssitg/NCIOUT=30
SPARE ; START ; SPARE
Accumulated cp time 24.19000. Elapsed cp time 12.75000
gaz -0.4719E-01 thz 0.6241E-01 dle 0.7700E-02 err 44.5
gaz -0.8857E-01 thz 0.7434E-01 dle 0.1392E-01 err 5.7
gaz -0.1153E+00 thz 0.6129E-01 dle 0.1745E-01 err 3.5
gaz -0.1280E+00 thz 0.4143E-01 dle 0.1878E-01 err 4.3
gaz -0.1310E+00 thz 0.2455E-01 dle 0.1874E-01 err 2.9
gaz -0.1290E+00 thz 0.1397E-01 dle 0.1813E-01 err 1.1
gaz -0.1254E+00 thz 0.9211E-02 dle 0.1745E-01 err 0.3
gaz -0.1222E+00 thz 0.8352E-02 dle 0.1694E-01 err 0.0
TIME 0. CIOITG 4 CSSITG 0.00500000
TIME 1.50000000 CIOITG 4 CSSITG 0.00500000
TIME 3.00000000 CIOITG 4 CSSITG 0.00500000
TIME 4.50000000 CIOITG 4 CSSITG 0.00500000
TIME 6.00000000 CIOITG 4 CSSITG 0.00500000
Time Limit
TIME 6.50000000 CIOITG 4 CSSITG 0.00500000
Accumulated cp time 30.68000. Elapsed cp time 6.490000
SET ialg = 1 ! Try adams-moulton integration
SPARE ; START ; SPARE
Accumulated cp time 30.74000. Elapsed cp time 0.060001
gaz -0.4719E-01 thz 0.6241E-01 dle 0.7700E-02 err 44.5
gaz -0.8857E-01 thz 0.7434E-01 dle 0.1392E-01 err 5.7
gaz -0.1153E+00 thz 0.6129E-01 dle 0.1745E-01 err 3.5
gaz -0.1280E+00 thz 0.4143E-01 dle 0.1878E-01 err 4.3
gaz -0.1310E+00 thz 0.2455E-01 dle 0.1874E-01 err 2.9
gaz -0.1290E+00 thz 0.1397E-01 dle 0.1813E-01 err 1.1
gaz -0.1254E+00 thz 0.9211E-02 dle 0.1745E-01 err 0.3
gaz -0.1222E+00 thz 0.8352E-02 dle 0.1694E-01 err 0.0
TIME 0. CIOITG 1 CSSITG 0.00500000
TIME 1.50000000 CIOITG 1 CSSITG 0.05000000
TIME 3.00000000 CIOITG 3 CSSITG 0.05000000
TIME 4.50000000 CIOITG 3 CSSITG 0.05000020
TIME 6.00000000 CIOITG 3 CSSITG 0.05000020
Time Limit
TIME 6.50000000 CIOITG 3 CSSITG 0.05000020
Count of times state controlled step size
Minus (-) means relative error always below absolute error
GA pc fail 0 err control 18-
H pc fail 0 err control 0
Q pc fail 0 err control 6-
TH pc fail 0 err control 99-
V pc fail 0 err control 0
X pc fail 0 err control 16
Accumulated cp time 32.49000. Elapsed cp time 1.750000
PRINT/NCIPRN=20 time,m,q,vd,gad

Line TIME M Q VD GAD


0 0. -3821.88000 0. 0.10212300 -0.00105422
20 1.00000000 -822255.000 -0.01786570 0.15172300 -9.4945E-04
40 2.00000000 -430787.000 -0.03991230 0.61984500 -0.01229880
60 3.00000000 -228140.000 -0.05170150 1.48509000 -0.02390130
80 4.00000000 -122287.000 -0.05798640 2.63490000 -0.03288610
100 5.00000000 -64935.0000 -0.06134890 3.95764000 -0.03877090
120 6.00000000 -32967.2000 -0.06310520 5.36772000 -0.04205790

Figure A7-2. Aircraft longitudinal study log file (part 4)

ACSL Reference Manual Page A-49


A. ACSL Example Programs A7. Aircraft Longitudinal Study

ACSL Runtime Exec Version 6 Level 10B 27-FEB-91 11:48:34 Page 5


Longitudinal Aircraft Stability Study

ANALYZE/FREEZE=x/JACOBIAN/EIGEN ! List jacobian and eigenvalues


Function evaluation not repeatable, row 3 (QD)
Row vector names
GA 1 H 2 Q 3
TH 4 V 5

Column vector names


GAD 1 Z09989 2 QD 3
Z09990 4 VD 5

Matrix elements - rows across, columns down


1 2 3 4 5
1 -0.5294010 0. 0.0493415 0.4893170 0.0011460
2 206.37500 0. 0. 0. -0.2704270
3 -0.0339586 0. -0.7297710 0.0260465 3.824E-05
4 0. 0. 1.0000200 0. 0.
5 -18.143700 0. 0. -12.860300 -0.0256390

Function evaluation not repeatable, row 3 (QD)


Complex eigenvalues in ascending order
REAL
1 0.01131900
2 0.
3 -0.10865800
4 -0.36606800
5 -0.82140400

SPARE ! List execution time


Accumulated cp time 33.32000. Elapsed cp time 0.830002
QUIT ! Note intermediate spare

Figure A7-2. Aircraft longitudinal study log file (part 5)

The sequence on Page 4 of the log file compares results from the standard
Runge-Kutta fourth order integration routine with those from the Adams-Moulton
variable order, variable step routine. The OUTPUT list is cleared (/CLEAR) and
reestablished as TIME, CIOITG (current integration order), and CSSITG (current step
size) to be printed out every thirty communication intervals. The SPARE ; START ;
SPARE sequence runs the simulation with the default algorithm (IALG = 5,
Runge-Kutta fourth order) and shows an elapsed central processor time of about 6.49
sec. Then IALG is changed to 1 (Adams-Moulton) and the program run again. The
integration order rises to four and the step size to the communication interval (0.05
sec), where it stops increasing. The current step size variable CSSITG shows the actual
step size the integration algorithm last used before the communication interval ended
and the data was logged. From the report at the end of the Adams-Moulton variable
step run, it can be deduced that θ (TH) was the controlling integrator; the minus sign
(-) indicates that the relative error never exceeded the absolute error specified. The
allowable error was therefore set at the default of 0.0001. The elapsed time for this run
is about 1.75 sec, so the Adams-Moulton integrator is nearly four times faster than the
Runge-Kutta in this example. Results of the Adams-Moulton run are printed out at one
second intervals for comparison with the same variables printed in the previous runs.
Agreement is within two or three decimal places.

Page A-50 ACSL Reference Manual


A7. Aircraft Longitudinal Study A. ACSL Example Programs

Figure A7-3. Aircraft longitudinal study plot

The ratio of execution for Runge-Kutta to Adams-Moulton may be misleading. The


artificially small step size (0.005 sec) chosen arbitrarily for the Runge-Kutta fourth
order algorithm unfairly penalizes the comparison. In actual tests with typical
nonlinear systems, the second order Runge-Kutta method (IALG=4) does best in terms
of cpu seconds per simulated second. The penalty is that the user must choose the step
size, normally by experimentation, but sometimes by familiarity with the model. As
mentioned above, a good rule of thumb is to make the integration step size (MAXT)
equal to the smallest time constant in the model. Of course, if the controlling time
constants change significantly, then the variable step algorithms are called for.
The use of the ANALYZE command is shown on Page 5 of the log file. The Jacobian
and its eigenvalues are printed out with the /JACOBIAN and /EIGEN switches. The
largest eigenvalue is 0.82 per second, which implies a rather slowly varying system
and in actual fact promises good results with integration step sizes the reciprocal of
this value or about one second, a further factor of twenty increase in solution speed. In
this case, the constant constraint on the step size is the data recording interval (CINT)
chosen to produce acceptable plots.

ACSL Reference Manual Page A-51


A. ACSL Example Programs A8. Physiological Benchmark

8. Physiological
Benchmark

A benchmark model called PHYSBE (physiological simulation benchmark


experiment)* demonstrates various techniques for solving simulation problems,
including macro expansion and concatenation.
The system models blood flow through a human body. The blood is driven by two
pumps; i.e., the right and left ventricles of the heart. Figure A8-1 shows the
interconnection of the various components of the system. Each component is
considered to be a large bag or balloon that can be filled with blood. The salient
characteristic of the components is that the more blood forced in, the higher the
pressure.
There are valves between the vena cava (VC) and the right ventricle (RV), the right
ventricle and the lungs (LN), the lungs and the left ventricle (LV), and the left
ventricle and the aorta (AO). These valves allow blood flow only in the forward
direction.
The blood is driven around the loop by changing the compliance of the right and left
ventricles as a function of time, thus modeling the squeezing of the blood in the
chambers by the heart muscle as it contracts and releases. Figure A8-2 shows this
reciprocal compliance as a function of time; the function is repeated every second as
the heart beats.

Figure A8-1. Interconnection of lumps to form blood distribution system

* McLeod, J., "PHYSBE: A Physiological Simulation Benchmark Experiment", SIMULATION 7 (1966)


pp. 324-329.

Page A-52 ACSL Reference Manual


A8. Physiological Benchmark A. ACSL Example Programs

Figure A8-2. Reciprocal compliance (pressure per unit volume) for PHYSBE heart chambers

Each component of the system is considered a lump which contains mass balance and
heat balance constraints. The model operates on the following assumptions:
1. Physical parameters of the system are linear.
2. Blood flow within each area is influenced only by:
a. inlet pressure
b. inflow resistance
c. compliance (volume/unit pressure)
d. outflow resistance
e. outlet pressure
3. There is no resistance to blood flow within components.
4. All endogenous heat will be absorbed by the blood and conducted by
the blood.
5. The specific heat of blood and all body components is unity.
6. Temperature change within the arteries, ventricles, and great veins is
negligible.
Figure A8-3 is a schematic representation of the mass and heat flow for any lump.
This structure is programmed in a macro (as seen in the program listing in Figure
A8-6), which is later invoked for each of the nine lumps in turn with the XX in the
equations (X in the macro definition) replaced by the appropriate two character
mnemonic. The equations for the macro are developed beginning with the input flow
rate, which is a function of the pressure differential and input resistance as follows:
fxxi = (pxxi - pxx)/rxxi

Pressure in the bag is volume divided by compliance:


pxx = vxx/cxx

Outlet flow rate is given by the pressure differential and output resistance:
fxxo = (pxx - pxxo)/rxxo

ACSL Reference Manual Page A-53


A. ACSL Example Programs A8. Physiological Benchmark

Figure A8-3. Lump definition - mass and enthalpy balance

The volume of blood is the mass flow rate integrated as follows:


T
vxx = ∫0 (fxxi - fxxo)dt + vxxz

Heat (enthalpy) flow in is:


qxxi = fxxi*txxi

Temperature is the total enthalpy in the lump divided by the mass:


txx = hxx/wxx

Heat flow out is:


qxxo = fxxo*txx

Heat dissipated to the surroundings is:


qxxd = k*axx*(txx - ta)

where K is the thermal transfer coefficient, AXX is area associated with the given
lump, and TA is the ambient temperature. The accumulated heat is:
T
hxx = ∫0 (qxxi - qxxo + qxxe - qxxd)dt + hxxz

The first line of the macro definition identifies the macro name (LUMP) and the
substitutable parameter (X) as follows:
MACRO lump(x)

This macro uses concatenation (indicated by &) in all of its assignment statements.
Concatenation allows one macro to be used for all the lump components with unique
names for each component. For example, input flow is expressed as follows in the
macro:
f&x&o = (p&x&i - p&x)/r&x&i

Page A-54 ACSL Reference Manual


A8. Physiological Benchmark A. ACSL Example Programs

lump("hd") ! head
RHDI = (PHDI - PHD)/RHDI
PHD = VHD/CHD
FHDO = (PHD - PHDO)/RHDO
VHD = INTEG(FHDI - FHDO, VHDZ)
QHDI = FHDI*THDI
THD = HHD/WHD
QHDO = FHDO*THD
QHDD = K*AHD*(THD - TA)
HHD = INTEG(QHDI - QHDO + QHDE - QHDD, HHDZ)
MACROEND

Figure A8-4. Macro invocation and expansion for HD (head) lump

which means F concatenated with the argument, concatenated with an O, etc. When
the macro is invoked to describe the head (designated by HD), quoting the letters HD
implies that it is a literal string (i.e., substitutable parameter) rather than a symbol or
an argument. The macro call is this case is:
lump("hd")

The expansion of the macro for this invocation is shown in Figure A8-4.
A second macro is required for the valves. The VALVE macro calculates resistance
(R) from outlet pressure (PO), inlet pressure (PI), and the open resistance of the valve
(RZ). If the valve is closed, the resistance rises to a large value (1020) to effectively
shut off flow. The macro header definition is as follows:
MACRO valve(r, po, pi, rz)

The names in the VALVE macro header are arguments. The action of the valve is
defined as follows:
r = rz po ≤ pi
r = 1020 po < pi

This is accomplished by an IF-THEN-ELSE block as follows:


MACRO valve(r, po, pi, rz)
IF(po .GT. pi) THEN
r = 1.0e20
ELSE
r = rz
ENDIF
MACRO END

An example of use of the VALVE macro is the following invocation to calculate


resistance into the right ventricle:
valve(rrvi = prv, pvc, rrvic)

which expands as shown in Figure A8-5. This expansion can be read as follows: the
input resistance to the right ventricle is RRVIZ if the pressure in the right ventricle
(PRV) is less than the pressure in the vena cava (PVC); otherwise, it is 1020 (to prevent
any backflow).
The constants necessary to specify the system behavior are defined in the program
listing (Figure A8-6). Since no heat flux constants were given in the problem

ACSL Reference Manual Page A-55


A. ACSL Example Programs A8. Physiological Benchmark

MACRO valve(r, po, pi, rz)


IF(po .GT. pi) THEN
r = 1.0E20
ELSE
r = rz
ENDIF
MACRO END

VALVE(rrvi = prv, pvc, rrviz)


IF(prv .GT. pvc) THEN
rrvi = 1.0E20
ELSE
rrvi = rrviz
ENDIF

Figure A8-5. VALVE macro and its expansion for inlet valve

definition, they are set to zero. The temperature equations therefore do not calculate
any significant quantities even though they are present. Since there is no feedback, the
temperature does not affect the system.
The first calculations in the DERIVATIVE section determine the compliance of the
ventricles (CRV and CLV), which drive the system that causes the heart to pump. The
reciprocal compliance (shown in Figure A8-2) is a function of time that repeats each
second. This code uses the IF-THEN-ELSE structure.
Next, the four valves are defined, one in and one out of the right and left ventricles.
The interconnections of each lump (Figure A8-1) define the inlet and outlet. For the
simple case of two elements in cascade, the outlet pressure is the effect of two
resistances connected between two pressure sources, depicted as follows:
pxx pxxo pyyi pyy
o___ΛΛΛΛ____o______o____ΛΛΛΛ____o
rxxo ryyi

pxxo = (pxx*ryyi + pyy*rxxo)/(ryyi + rxxo)


pyyi = pxxo

The aorta and vena cave are more difficult since the first feeds five other lumps and
the second receives flow from the five. Writing down the flow balance — equivalent
to Kirchoff's law — leads to the following for the aorta output pressure:
pao/raoo + phd/rhdi + par/rari + plg/rlgi + ptr/rtri
paoo = ____________________________________________________
1/rcvi + 1/rhdo + 1/raro + 1/rlgo + 1/rtro

and similarly for the vena cava inlet pressure:


pvc/rcvi + phd/rhdo + par/raro + plg/rlgo + prt/rtro
pvci = ____________________________________________________
1/rcvi + 1/rhdo + 1/raro + 1/rlgo + 1/rtro

The last statements in the DERIVATIVE section define each of the nine lumps by
invoking the LUMP macro with the appropriate two-character string.

Page A-56 ACSL Reference Manual


A8. Physiological Benchmark A. ACSL Example Programs

PROGRAM physbe
INITIAL
MACRO lump(x)
f&x&i =(p&x&i - p&x)/r&x&i
p&x = v&x/c&x
f&x&o =(p&x - p&x&o)/r&x&o
v&x = INTEG(f&x&i - f&x&o, v&x&z)
q&x&i = f&x&i*t&x&i
t&x = h&x/w&x
q&x&o = f&x&o *t&x
q&x&d = k*a&x*(t&x - ta)
h&x = INTEG(q&x&i - q&x&o + q&x&e - q&x&d, h&x&z)
MACRO END
MACRO valve(r, po, pi, rz)
IF(po.GT.pi) THEN
r = 1.0e20
ELSE
r = rz
ENDIF
MACRO END
CONSTANT raoi = 1.e-2 , raoo = 1.e-2 , cao = 1.01 , vaoz= 80.8
CONSTANT rari = 5.15 , raro = 10.0 , car = 4.25 , varz= 268.0
CONSTANT rhdi = 2.58 , rhdo = 5.0 , chd = 1.21 , vhdz= 68.0
CONSTANT rtri = 0.67 , rtro = 1.42 , ctr = 34.0 , vtrz= 2180.
CONSTANT rlgi = 2.58 , rlgo = 5.00 , clg = 11.1 , vlgz= 700.0
CONSTANT rvci = 1.e-2 , rvco = 1.e-2 , cvc = 250.0 , vvcz= 650.0
CONSTANT rlni = 1.e-2 , rlno = 0.1875, cln = 10.0 , vlnz= 200.0
CONSTANT rrviz= 0.0030, rrvoz= 0.0030
CONSTANT rlviz= 0.0275, rlvoz= 0.0060
CONSTANT vlvz = 319.0 , vrvz = 120.0
CONSTANT aao = 0.0 , wao = 1.0 , qaoe= 0.0 , haoz= 0.0
CONSTANT aar = 3670.0, war = 7000.0, qare = 0.0 , harz= 0.0
CONSTANT ahd = 1400.0, whd = 4500.0, qhde = 0.0 , hhdz= 0.0
CONSTANT atr = 6000.0, wtr = 53000., qtre = 0.0 , htrz= 0.0
CONSTANT alg = 7000.0, wlg = 18500., qlge = 0.0 , hlgz= 0.0
CONSTANT avc = 0.0 , wvc = 1.0 , qvce = 0.0 , hvcz= 0.0
CONSTANT arv = 0.0 , wrv = 600.0 , qrve = 0.0 , hrvz= 0.0
CONSTANT aln = 50000., wln = 1000.0, qlne = 0.0 , hlnz= 0.0
CONSTANT alv = 0.0 , wlv = 600.0 , qlve = 0.0 , hlvz= 0.0
CONSTANT k = 0.01 , ta = 0.0 , tstp = 3.99
CONSTANT tmx = 0.4 , tmn = 0.5, &
cimx = 0.428 , cimn = 0.0133
END ! of initial

Figure A8-6. Physiological benchmark program (part 1)

The DYNAMIC section code (interrogated every communication interval) follows the
end of the DERIVATIVE section and contains the termination condition (TERMT).
The program terminates when time exceeds TSTP. The default of TSTP is set at four
seconds so that the model will go through four cycles during a run.
Figure A8-7 shows the log file of a runtime session. Prior to the START, the
communication interval (CINT) is set to 0.02 sec, NSTP (number of integration steps
per communication interval) to 1, and the integration step size specified by the
maximum step size (MAXT) to be 0.01 sec. CINTERVAL, NSTEPS, and
MAXTERVAL are not specified in the program, but default names CINT, NSTP, and
MAXT can be accessed at runtime. Here we override the default values of 0.1, 10, and
1.0E10 so that CINT is the data logging rate and MAXT controls the integration step
size.

ACSL Reference Manual Page A-57


A. ACSL Example Programs A8. Physiological Benchmark

DYNAMIC
DERIVATIVE
tf = MOD(t, 1.0) ! Modulus repeats every second
!-----------------------compute triangular wave
IF(tf .LE. tmx) THEN
ci = (cimx - cimn)*tf/tmx + cimn
ELSE IF(tf .LE. tmn) THEN
ci = (cimx - cimn)*(tmn - tf)/(tmn - tmx) + cimn
ELSE
ci = cimn
ENDIF
!-----------------------right and left ventricle compliances
crv = 1.0/ci ; clv = crv
! valves in right and left ventricles
valve(rrvi = prv, pvc, rrviz)
valve(rrvo = pln, prv, rrvoz)
valve(rlvi = plv, pln, rlviz)
valve(rlvo = pao, plv, rlvoz)
!-----------------------define the interconnections
! vena cava feeds right ventricle
pvco =(pvc*rrvi + prv*rvco)/(rrvi + rvco)
prvi = pvco !right ventricle
trvi = tvc
!-----------------------right ventricle feeds lungs
prvo =(prv*rlni + pln*rrvo)/(rlni + rrvo)
plni = prvo !lung inputs
tlni = trv
!-----------------------lungs feed left ventricle
plno =(pln*rlvi + plv*rlno)/(rlvi + rlno)
plvi = plno !left ventricle inputs
tlvi = tln
!-----------------------left ventricle feeds aorta
plvo =(plv*raoi + pao*rlvo)/(raoi + rlvo)
paoi = plvo !aorta inputs
taoi = tlv
!-----------------------aorta feeds head,arms,legs and trunk
paoo =(pao/raoo + phd/rhdi + par/rari + plg/rlgi + ptr/rtri)&
/(1.0/raoo + 1.0/rhdi + 1.0/rari + 1.0/rlgi + 1.0/rtri)
phdi = paoo !head inputs
thdi = tao
pari = paoo !arms inputs
tari = tao
plgi = paoo !leg inputs
tlgi = tao
ptri = paoo !trunk inputs
ttri = tao
! vena cava is return from head,arms,legs and trunk
pvci =(pvc/rvci + phd/rhdo + par/raro + plg/rlgo + ptr/rtro)&
/(1.0/rvci + 1.0/rhdo + 1.0/raro + 1.0/rlgo + 1.0/rtro)
tvci =(thd*fhdo + tar*faro + tlg*flgo + ttr*ftro)/fvci
paro = pvci ; phdo = pvci ; plgo = pvci ; ptro = pvci
!-----------------------define each lump
lump("rv") !right ventricle
lump("ln") !lungs
lump("lv") !left ventricle
lump("ao") !aorta
lump("ar") !arms
lump("hd") !head
lump("tr") !trunk
lump("lg") !legs
lump("vc") !vena cava
END ! of derivative
TERMT(t.GE.tstp)
END ! of dynamic
END ! of program

Figure A8-6. Physiological benchmark program (part 2)

Page A-58 ACSL Reference Manual


A8. Physiological Benchmark A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 27-FEB-91 17:12:52 Page 1

SET TITLE='Physiological Simulation Benchmark Experiment (PHYSBE)'


SPARE
Accumulated cp time 88.19000. Elapsed cp time 0.
SET TCWPRN=72 ! force 3 column output width
PREPARE t,prv,pln,plv,pao,phd,ptr,par,plg,pvc,fvci &
,faoo,faro,fhdo,flgo,flno,flvo,frvo,ftro,fvco,crv,clv,ci
OUTPUT/NCIOUT=25 t, prv, pln, pao, phd
SET cint=0.02,nstp=1,maxt=0.010
START
T 0. PRV 1.59600000 PLN 20.0000000
PAO 80.0000000 PHD 56.1983000

T 0.50000000 PRV 0.85087600 PLN 25.4171000


PAO 100.881000 PHD 56.9120000

T 1.00000000 PRV 1.58568000 PLN 20.9539000


PAO 74.2732000 PHD 56.8335000

T 1.50000000 PRV 0.87361500 PLN 26.0932000


PAO 99.1535000 PHD 57.0085000

T 2.00000000 PRV 1.62192000 PLN 21.4780000


PAO 73.5419000 PHD 56.7580000

T 2.50000000 PRV 0.89439700 PLN 26.7112000


PAO 98.2354000 PHD 56.8378000

T 3.00000000 PRV 1.65475000 PLN 21.9627000


PAO 73.0300000 PHD 56.5338000

T 3.50000000 PRV 0.91349000 PLN 27.2809000


PAO 97.8142000 PHD 56.6051000

T 4.00000000 PRV 1.68449000 PLN 22.4132000


PAO 72.6692000 PHD 56.2999000

PRINT/NCIPRN=4,t,prv,pln,flvo,frvo

Line T PRV PLN FLVO FRVO


0 0. 1.59600000 20.0000000 -7.5757E-19 -1.8404E-19
4 0.08000000 11.5798000 19.8290000 -4.6118E-19 -8.2492E-20
8 0.16000000 21.4102000 19.9122000 -1.7011E-19 115.227000
12 0.24000000 25.9034000 21.9789000 267.249000 301.886000
16 0.32000000 26.8695000 24.0743000 287.502000 215.019000
20 0.40000000 27.3245000 25.4770000 279.166000 142.114000
24 0.48000000 6.10522000 25.5175000 -7.6891E-19 -1.9412E-19
28 0.56000000 0.96275900 24.8174000 -9.2132E-19 -2.3855E-19
32 0.64000000 1.10026000 24.0467000 -8.6294E-19 -2.2946E-19
36 0.72000000 1.22565000 23.3079000 -8.1456E-19 -2.2082E-19
40 0.80000000 1.34014000 22.5995000 -7.7440E-19 -2.1259E-19
44 0.88000000 1.44485000 21.9204000 -7.4098E-19 -2.0476E-19
48 0.96000000 1.54075000 21.2693000 -7.1310E-19 -1.9729E-19
52 1.04000000 6.55012000 20.7661000 -5.5885E-19 -1.4216E-19
56 1.12000000 16.4692000 20.7576000 -2.7776E-19 -4.2884E-20
60 1.20000000 24.8305000 21.4635000 1.19909000 259.001000

Figure A8-7. Physiological benchmark log file (part 1)

ACSL Reference Manual Page A-59


A. ACSL Example Programs A8. Physiological Benchmark

ACSL Runtime Exec Version 6 Level 10B 27-FEB-91 17:12:52 Page 2


Physiological Simulation Benchmark Experiment (PHYSBE)

Line T PRV PLN FLVO FRVO


64 1.28000000 27.2136000 23.7529000 281.516000 266.209000
68 1.36000000 27.8311000 25.5167000 276.736000 178.033000
72 1.44000000 17.0744000 26.2029000 -3.5744E-19 -9.1285E-20
76 1.52000000 0.91249900 25.8843000 -9.3898E-19 -2.4972E-19
80 1.60000000 1.05932000 25.0704000 -8.7719E-19 -2.4011E-19
84 1.68000000 1.19308000 24.2901000 -8.2599E-19 -2.3097E-19
88 1.76000000 1.31510000 23.5420000 -7.8350E-19 -2.2227E-19
92 1.84000000 1.42655000 22.8248000 -7.4816E-19 -2.1398E-19
96 1.92000000 1.52851000 22.1372000 -7.1871E-19 -2.0609E-19
100 2.00000000 1.62192000 21.4780000 -6.9409E-19 -1.9856E-19
104 2.08000000 11.7723000 21.2659000 -4.1456E-19 -9.4935E-20
108 2.16000000 21.9013000 21.2750000 -1.3855E-19 48.1771000
112 2.24000000 27.1105000 23.1554000 265.840000 304.237000
116 2.32000000 28.2364000 25.3151000 276.693000 224.717000
120 2.40000000 28.7275000 26.7861000 268.981000 149.335000
124 2.48000000 6.41881000 26.8273000 -7.4895E-19 -2.0408E-19
128 2.56000000 1.01032000 26.0731000 -8.9855E-19 -2.5063E-19
132 2.64000000 1.15277000 25.2532000 -8.4316E-19 -2.4100E-19
136 2.72000000 1.28260000 24.4671000 -7.9723E-19 -2.3185E-19
140 2.80000000 1.40106000 23.7135000 -7.5906E-19 -2.2312E-19
144 2.88000000 1.50931000 22.9909000 -7.2727E-19 -2.1482E-19
148 2.96000000 1.60837000 22.2982000 -7.0074E-19 -2.0690E-19
152 3.04000000 6.83498000 21.7533000 -5.4946E-19 -1.4918E-19
156 3.12000000 17.1855000 21.7380000 -2.7300E-19 -4.5525E-20
160 3.20000000 25.9476000 22.4578000 2.67410000 268.441000
164 3.28000000 28.4586000 24.8434000 277.109000 278.087000
168 3.36000000 29.1073000 26.6870000 272.466000 186.172000
172 3.44000000 17.8576000 27.4047000 -3.5268E-19 -9.5471E-20
176 3.52000000 0.95358700 27.0605000 -9.2636E-19 -2.6107E-19
180 3.60000000 1.10507000 26.2021000 -8.6562E-19 -2.5097E-19
184 3.68000000 1.24300000 25.3791000 -8.1528E-19 -2.4136E-19
188 3.76000000 1.36873000 24.5901000 -7.7349E-19 -2.3221E-19
192 3.84000000 1.48351000 23.8337000 -7.3873E-19 -2.2350E-19
196 3.92000000 1.58843000 23.1085000 -7.0974E-19 -2.1520E-19
200 4.00000000 1.68449000 22.4132000 -6.8550E-19 -2.0729E-19
S STRPLT=.T.,CALPLT=.F.,PSFSPL=0.8
PLOT frvo,pln,prv
Drawing plot number 1
S CALPLT=.T.,STRPLT=.F.
PLOT prv, pln
Drawing plot number 2
OUTPUT/CLEAR ! No output
PREPARE/CLEAR ! No data saved
SPARE ; START ; SPARE ! Measure raw computational speed
Accumulated cp time 97.25000. Elapsed cp time 9.060000
Accumulated cp time 100.2200. Elapsed cp time 2.970000
QUIT ! Note intermediate spare

Figure A8-7. Physiological benchmark log file (part 2)

Page A-60 ACSL Reference Manual


A8. Physiological Benchmark A. ACSL Example Programs

Figure A8-8. PHYSBE strip plot Figure A8-9. PHYSBE line plot —
right ventricle and lung pressure right ventricle and lung pressures
and right ventricle flow

After the START command initiates the run, the values of the variables on the
OUTPUT list are printed out every half second, since /NCIOUT (number of
communication intervals per OUTPUT) is 25.
After the simulation run has been completed, the PRINT command provides a more
detailed printout for two pressures (PRV and PLN) and two flows (FLVO and FRVO)
every four communication intervals (80 msec). Next, a strip plot of the right ventricle
flow and the lung and right ventricle pressures is obtained by setting STRPLT to
TRUE (Figure A8-8). Then STRPLT is set back to FALSE and a regular line plot
(CALPLT=.T.) is plotted (Figure A8-9).
The last action is to measure raw cpu speed by turning off all I/O functions (OUTPUT
/CLEAR and PREPAR /CLEAR) and running and timing the four seconds of
execution (SPARE ; START ; SPARE). This shows that a MicroVAX took 2.97 CPU
seconds to execute this example. This procedure for measuring cpu time is useful for
comparing the capabilities of different machines, for comparing the efficiency of
different integration algorithms for a particular program, or for monitoring a program's
load on the computer.

ACSL Reference Manual Page A-61


A. ACSL Example Programs A9. Phase and Gain

9. Phase and
Gain

The Phase and Gain example illustrates frequency response analysis of a nonlinear
system, the use of DERIVATIVE and DISCRETE sections, multiple INITIAL
sections, and plotting with a logarithmic scale.
The characteristics of the system are obtained by forcing the model with a sine wave
and determining the in-phase and quadrature components, from which gain and phase
are calculated. Changing frequency slowly allows successive points to be calculated
until, at the end of a single run, the complete Bode plot is generated.
This method is a relatively expensive way (i.e., in computer costs) to obtain frequency
response and is seldom justified for linear systems. For nonlinear plants, however, this
is the best method available, and it can be used to match hardware bench tests excited
by sinewave generators. The excitation amplitude must be chosen correctly and the
model must be in steady state while the measurements are taken. In a nonlinear plant,
the results change as the amplitude of the exciting sinewave is varied.
The plant used for this example is described by the following transfer function:

y 0.5 s + 1
= G(s) =
x 0.03 s2 + 0.1 s + 1

The program is listed in Figure A9-1. A DISCRETE block is established to repeat at


every cycle of a given frequency and to examine the in-phase and quadrature
components of a full cycle of integration. When the change in phase from cycle to
cycle has become small enough, the data point is recorded and the frequency changed
so that another point can be calculated.
Five INITIAL sections are placed throughout the program rather than one INITIAL
section at the beginning. This method has the advantage of keeping the INITIAL
calculations with related code in the dynamic part of the program, making reading and
understanding the program easier. The translator collects all the INITIAL sections and
places them in the INITIAL section of the compile file in the order given.
The first frequency W (rad/s) and phase FI (rad) are set in their respective INITIAL
sections. The frequency is started at a specified maximum value and then reduced
geometrically (so that the final logarithmic plot will have equally spaced points) by:
w = MAX(wmn, kw*w)

For this application, KW is defined to be 0.8 and the frequency sweep is from a
maximum value (WMX) of 100.0 down to a minimum value (WMN) of 1.0.
The plant is defined in the DERIVATIVE CONTINUE section. First the name for the
step size is defined (MAXTC) and set to 0.01. Constants for the frequency bounds
(WMN and WMX), the amplitude of the forcing function (XMAG), and the settling
time (TSETTL) are specified. Since the plant is linear, the value of XMAG has no
effect, but for a real nonlinear plant, this value should be chosen to match the plant
capability. The actual forcing function (X) is obtained from:
x = xmag*SIN(w*t + fi)

where FI is a parameter used to ensure continuity of X when the frequency W is


changed.

Page A-62 ACSL Reference Manual


A9. Phase and Gain A. ACSL Example Programs

PROGRAM phase and gain

!-----------------------compute phase and gain of a given


! transfer function by integrating over a complete cycle.
! continue to integrate until phase change from cycle to cycle
! is less than some preset minimum

CINTERVAL cint = 1.0


NSTEPS nstp = 1

PARAMETER (rmn = 1.0e-30 , rmx = 1.0e30)


PARAMETER (raddeg = 57.3 , pi = 3.14159)

DISCRETE

INTERVAL period = 0.0 ! indicate period will be calculated

!-----------------------change in in-phase and quadrature


! integrals over last cycle
dlp = p - pp
dlq = q - qp
!-----------------------if relative change too small for mach acc
CONSTANT epm = 1.0e-7
TERMT((dlp**2 + dlq**2)/(p**2 + q**2 + rmn) .LT. epm**2 &
, 'Change over one Cycle Too Small for Machine Accuracy')
!-----------------------save new integrals as previous
INITIAL
pp = 1.0
qp = 1.0
END ! of initial
pp = p
qp = q
!-----------------------calculate new phase and gain
pdgn = ATAN2(dlq, dlp + rmn)*raddeg
gdbn = 10.0*LOG10((dlp**2 + dlq**2 + rmn)*(w/(pi*xmag))**2)
!-----------------------if change in phase not small enough yet
CONSTANT epdg = 0.1
IF(ABS(pdgn - pdgp) .GT. epdg) GO TO skip1
!-----------------------ignore results until after settling time
IF(t .LT. tsettl) GO TO skip1
!-----------------------terminate on frequency sweep
TERMT(w .LE. wmn, 'Frequency Limit')
!-----------------------save value in separate name for plotting
INITIAL
pdg = 0.0
gdb = 0.0
wfr = wmx ! put first point at far right edge
END ! of initial
pdg = pdgn
gdb = gdbn
wfr = w
!-----------------------advance frequency geometrically
INITIAL; w = wmx; END
w = MAX(wmn, kw*w) ; CONSTANT kw = 0.8
!-----------------------calculate new phase for continuity
! of forcing function at new frequency
INITIAL; fi = 0.0; END
fi = fi + t*(wfr - w)
!-----------------------ensure previous phase set to force at
! least two cycles
pdgn = rmx
!-----------------------force a data logging action
CALL LOGD(.FALSE.)
skip1..CONTINUE

Figure A9-1. Phase and gain program (part 1)

ACSL Reference Manual Page A-63


A. ACSL Example Programs A9. Phase and Gain

!-----------------------reset previous phase for next time


INITIAL; pdgp = rmx; END
pdgp = pdgn
!-----------------------recalculate new period and step size
period = 2.0*pi/w
maxtc = MIN(period/nstpmn, maxtxz)
!-----------------------terminate on time limit
TERMT(t .GT. tstp, 'Time Limit') ; CONSTANT tstp = 10000.0

END ! of discrete

DERIVATIVE continue

MAXTERVAL maxtc = 0.010


CONSTANT wmn = 1.0 , wmx = 100.0
CONSTANT xmag = 1.0 , tsettl = 2.0

x = xmag*SIN(w*t + fi)

!-----------------------define model
REAL a(2), b(3)
CONSTANT a = 0.5, 1.0 , b = 0.03, 0.1, 1.0
CONSTANT maxtxz = 0.050 , nstpmn = 10.0
y = TRAN(1, 2, a, b, x)
!-----------------------integrate for in-phase and quadrature comp
p = INTEG(y*SIN(w*t + fi), 0.0)
q = INTEG(y*COS(w*t + fi), 0.0)

END ! of continuous section

END ! of program

Figure A9-1. Phase and gain program (part 2)

The model is defined by the transfer operator, TRAN, and numerator and denominator
polynomials. The numerator coefficients (A) are 0.5 and 1.0; the denominator
coefficients (B) are 0.03, 0.1, and 1.0. In addition, a maximum step size (MAXTXZ)
of 0.050 sec is chosen (conservatively) from the plant roots of (-1.5 ± j6) and a
minimum divisor (NSTPMN) of the period. This indicates that no matter how slow the
drive sine wave is, the calculation interval (MAXTC) will be no greater than
PERIOD/NSTPMN; as the frequency gets slower and slower, the step size does not
rise above MAXTXZ. MAXTC is calculated in the DISCRETE section as follows:
maxtc = MIN(period/nstpmn, maxtxz)

The output (Y) of the plant is obtained using the TRAN (general polynomial transfer
function) operator. TRAN takes arguments of the order of the numerator and
denominator, arrays of coefficients for the numerator and denominator, and the input.
In this program, the plant output is expressed as follows:
y = TRAN(1, 2, a, b, x)

The in-phase (P) and quadrature (Q) components of the output are obtained by
multiplying the output (Y) by sin(W*T + FI) and cos(W*T + FI) respectively and
integrating.

Page A-64 ACSL Reference Manual


A9. Phase and Gain A. ACSL Example Programs

The difference in the in-phase and quadrature components since the previous cycle are
calculated at the beginning of the DISCRETE section as follows:
dlp = p - pp
dlq = q - qp

Since PP and QP are initialized to large numbers, DLP and DLQ are large the first
time through.
PARAMETER statements set constants to be substituted at various points in the
program. The variable names do not appear in the program dictionary and the values
cannot be changed at runtime. The constant π (PI) and conversion factor radians per
degree (RADDEG) are conveniently set in a PARAMETER statement, as are a very
small (RMN) and a very large (RMX) number. RMX is used in logic for ignoring the
first cycle calculations, as described below. RMN is added to terms in several
equations to prevent the terms becoming zero (to avoid division by zero or a zero
argument to a logarithm function, for example).
The minimum and maximum frequencies for the frequency sweep (WMN and WMX)
however are set in CONSTANT statements so that they can be changed at runtime.
The program contains three termination (TERMT) statements. Each statement uses the
optional second argument, a character string in quotes, to generate a message when it
is activated. This message thus indicates which of the possible terminating conditions
actually stopped the program. The three terminating conditions in this program are
relative change too small for machine accuracy, frequency limit, and time limit.
The first termination condition checks for a frequency such that the attenuation is too
great for the machine precision. For 32 bit computers, the error criterion (EPM) should
probably be set to 0.0001, which still allows room for nearly 80 dB attenuation. If the
change from cycle to cycle in P and Q is less than the machine precision, the
increments are zero and the logarithm function fails further on when calculating the
gain (GDBN).
The second termination condition is a normal termination on the frequency sweep
being completed. This is the condition that usually stops the run.
The third termination condition is a backup of a time limit. This condition could be set
at runtime to a small number for an initial checkout run, for example.
Once the increments have been calculated, the current values of P and Q are saved to
become the previous values (PP and QP) during the next pass. The phase and gain
over the preceding cycle are calculated from:
phase = ATAN[∆Q/∆P]
gain = 10.0*LOG10[(∆P2 + ∆Q2)(w/π)2]

If the new phase differs from the previous phase by more than a specified amount
(nominally 0.1 degrees), then no data is saved. Similarly, if a settling time (TSETTL)
has not elapsed, another cycle is calculated. If both these tests have been passed, then
the phase, gain, and frequency are transferred to separately named variables (PDG,
GDB, and WFR) which are used for plotting.
The forcing function frequency (W) is decreased geometrically and the phase (FI)
adjusted to ensure a shorter settling time between frequency changes. The previous
phase measured is again set to a large number (RMX) so that the integration over the
first cycle will be rejected.

ACSL Reference Manual Page A-65


A. ACSL Example Programs A9. Phase and Gain

ACSL Runtime Exec Version 6 Level 10B 3-MAR-91 10:49:28 Page 1

SET TITLE='Phase and Gain of a Transfer Function'


SPARE
Accumulated cp time 10.94000. Elapsed cp time 0.
SET TCWPRN=72 ! Force output width to fit on page
OUTPUT wfr,gdb,pdg/NCIOUT=1000
PREPARE wfr,gdb,pdg,t,dlp,dlq
SET kw=0.9 ! Change geometric frequency multiplier
START
WFR 100.000000 GDB 0. PDG 0.
Frequency Limit
WFR 1.00000000 GDB 1.18776000 PDG 20.6806000
PLOT/XLOG/XLO=wmn & ! Logarithmic plots with nonzero start
,pdg/CHARACTER=' ' & ! Phase and make character plotted blank
& ! since problem is first point which is
& ! incorrect so shouldn-t be emphasised.
,gdb/CHARACTER=' ' ! Gain, same blank character
Drawing plot number 1
DISPLAY t
T 221.287000
SPARE ! List execution time
Accumulated cp time 29.04000. Elapsed cp time 18.10000
QUIT

Figure A9-2. Phase and gain log file

The final step at the end of each frequency calculation is to call the data logging
routine, LOGD, to force data logging. The communication interval (CINT) is set to 1.0
at the beginning of the program with the intent that this will produce no output beyond
the first one at time zero. All other output is obtained by means of LOGD, which is
called when the data for a new frequency point is being recorded.
All cases then proceed through the code after the label SKIP1. The previous phase
(PDGP) is set equal to the current phase (PDGN), and PERIOD and a new step size
for the continuous section are calculated. These last two calculations need to be done
only when the frequency changes, but they are placed here in order to handle the
initialization problem rather than repeat the code in the INITIAL section.
Figure A9-2 shows the log file of a runtime session. Note that the frequency multiplier
KW was changed to 0.9 from the nominal 0.8 in order to increase the point density to
23 per decade for smoother plots. The plot, shown in Figure A9-3, uses a logarithmic
scale on the X axis. A minimum for the logarithmic scale is specified symbolically by
using the contents of WMN as follows:
PLOT/XLOG/XLO=wmn, pdg,gdb

This plot was made in one simulation run with a sweep of the drive frequency.
Examination of the last value of time showed that it needed 221 seconds of simulated
time to complete the sweep, which explains why it is usually considered an expensive
picture to obtain. Individual transient studies would be over in three or four seconds,
whereas this run needs effectively sixty transient runs.
From an independent run with a listing of time (T) along with the frequency, phase,
and gain, it can be shown that the high frequency points can be obtained quickly. In
fact, it takes 35 seconds to sweep the frequency from 100 down to 10 radian/second
and a further 186 seconds to go from 10 down to 1 radian/second. The reason for this

Page A-66 ACSL Reference Manual


A9. Phase and Gain A. ACSL Example Programs

Figure A9-3. Nonlinear phase and gain plot

is that at least one cycle must be completed at each frequency, and at 1 radian/second
each measurement requires over six seconds.
One caveat for this type of program is in regard to errors caused by non-steady-state
operating conditions. At low attenuations, the drive signal dominates in the P and Q
integrators, but when the plant attenuation becomes high, the residual motion excited
by the start up transient or frequency switch can become important. An idea of the
magnitude of the effect can be obtained by looking at the irregularity in the phase plot
when the frequency is over 20 radians/second. The plot should theoretically be smooth
and monotonically negative as the phase asymptotically approaches -90 degrees. In
Figure A9-3, the phase at 72.9 radians/second is given as -87.8 degrees, but at the next
frequency point of 65.6 it has gone back to -89.3. This change of 1.5 degrees in the
wrong direction must be an artifact of the measurement implementation.
An empirical study of this phenomenon determined that better results are obtained
with more heavily damped systems (shorter settling times) and certainly when the
attenuation is relatively small. If problems occur, experimentation with the phase
change error parameter (EPDG) can help; another approach is to add a fixed settling
time after each frequency change so that the system has time to reach steady state
before the measurement is taken.
As a test of accuracy, the theoretical gain and phase was evaluated at five selected
frequency points; the comparison is listed in Table A9-1. Note the phase error of half a
degree at high frequencies. A second run was made with the allowable phase error
EPDG changed to 0.01 (from 0.1). This forced slightly longer settling times so that the
overall sweep time was 270 seconds (up from 221 seconds) and the measured phase at
a frequency of 90 rad/s was now -89.07 degrees (theoretical is -89.14 degrees). The
increased settling time was seen in the measurement at W = 100, for example, being
available at 2.51 sec (compared with 2.01) and the measurement at W = 90 being
produced at 3.84 seconds (compared with 2.29). At lower frequencies, the tighter
constraint had little effect since settling has occurred within the first cycle anyway.

ACSL Reference Manual Page A-67


A. ACSL Example Programs A9. Phase and Gain

Table A9-1. Comparison of measured and theoretical gain and phase

frequency measured theoretical measured theoretical


W gain gain phase phase
(rad/s) (dB) (dB) (deg) (deg)
90.00 -14.612 -14.617 -88.64 -89.14
31.38 -5.230 -5.232 -87.47 -87.37
10.94 5.916 5.920 -77.48 -77.47
3.09 7.484 7.484 33.67 33.67
1.00 1.188 1.188 20.68 20.68

The example above shows how to generate phase and gain plots for a nonlinear plant,
but the ANALYZE command is the most cost-effective way to evaluate a plant that
can be linearized. Figure A9-4 shows a program which is the previous program with
all the measurement code removed. This version is simply the transfer function with
input X+DLX and output Y.
The input to this version of the model is given as X+DLX since in most real systems
the input comes from somewhere else and so must be calculated. Potential control
inputs must be free; i.e., only defined in CONSTANT statements (usually to zero). In
this case, we can use the variable DLX.

PROGRAM phase and gain

!-----------------------compute phase and gain of a given


! transfer function. This model uses the model linearization
! features of ACSL to obtain a Bode plot from input (control)
! x to observable y.

CINTERVAL cint = 1.0


NSTEPS nstp = 1

DERIVATIVE continue

MAXTERVAL maxtc = 0.010

!-----------------------define model
REAL a(2), b(3)
CONSTANT a = 0.5, 1.0 , b = 0.03, 0.1, 1.0
CONSTANT x = 0 , dlx = 0
y = TRAN(1, 2, a, b, x + dlx)

END ! of continuous section

END ! of program

Figure A9-4. Linear phase and gain program

Page A-68 ACSL Reference Manual


A9. Phase and Gain A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 3-MAR-91 18:15:41 Page 1

set title='Linear Model for Frequency Response'


ANALYZE/CONTROL=dlx/OBSERV=y
States not initialized. Moving IC vector to STATE vector
ANALYZE/HERTZ=.F./FREQMN=1/FREQMX=100
ANALYZE/BODE
Number of poles is 2 - Number of zeros is 1
Drawing plot number 1

Figure A9-5. Log file for linear phase and gain

Runtime commands for this model, shown in Figure A9-5, define the control and
observable variables by:
ANALYZE/CONTROL=dlx/OBSERVE=y

The frequency sweep is by radians (not the default HERTZ). The frequency minimum
starts at the default of 1.0, but the frequency maximum is set as follows:
ANALYZE/HERTZ=.F./FREQMX=100

Finally, the Bode plot is generated, as shown in Figure A9-6, by:


ANALYZE/BODE

Note that the phase curve is smooth and monotonically negative at the higher
frequencies (i.e., W > 10).

Figure A9-6. Bode plot of linear phase and gain program

ACSL Reference Manual Page A-69


A. ACSL Example Programs A10. Missile Airframe

10. Missile
Airframe

The missile example demonstrates the use of vector operators and vector integration,
the use of double precision, the incorporation of FORTRAN subroutines, and the use
of FORTRAN library routines.
The program is a six degree-of-freedom model of an unguided ground-to-air missile
with transient responses to control surface deflections. For a full missile system, a
target, target sensor or seeker, guidance law, and autopilot would have to be added and
the aerodynamic and motor models expanded.
Each three-dimensional axis system (or reference frame) is given a letter; i.e., E for
earth (or inertial reference) and M for missile. (More frames would be added if target,
seeker, or other subsystems were modeled.) The axes (commonly referred to as X, Y,
and Z) for this model are numbered 1, 2, and 3 to facilitate using vector operators.
There are several possible systems of axis orientation. In this model, the second (Y)
axis points up, as is found commonly in models of ground launched missiles (such as
Hawk, Patriot). The other major school of thought orients the axes with the third (Z)
axis pointing down; this orientation is often used by engineers with a background in
airplane design. Models can use any system of axes, but all frames should be parallel
when the orientation angles are zero.
The earth (E) frame orients the E1 axis horizontal and downrange, E2 vertical up, and
E3 crossrange horizontal to the right, to form a right hand set. The origin of the frame
is normally on the ground, but since this model does not compensate the atmospheric
density table look-up for ground altitude, the origin is assumed to be at sea level. All
velocity and range vectors are assumed to be components in this frame unless
explicitly specified otherwise.
The missile frame (shown in Figures A10-1 and A10-2) comprises M1 out of the nose
along the center line, M2 along fin one (normally viewed vertically or up), and M3 out
to the right along fin two. (The designation down in the figures actually means into the
paper rather than physically down.) Variables in the missile frame have a suffix of M.
The reference frames are related to each other through Euler angles: ψ (yaw), θ
(pitch), and ϕ (roll). The sequence of rotations starting at the ground reference or E
frame is ψM (SIM) to the left about E2, θM (THM) up about the new three axis E3', and
finally ϕM (FIM) clockwise about the new one axis which should now be M1 to align
the two and three axes with M2 and M3. The control fin deflections are shown in
Figure A10-1 in their positive sense; i.e., trailing edge right for fins one and three,
trailing edge down for fins two and four.
Units in the model are in the English system; i.e., slug, foot, and second for units of
mass, length, and time, respectively. Angles are in radians.
It is important that all units be consistent and fundamental since many simulation
errors can be traced to unit misconceptions, either in the equations or in the constant
values. It is strongly recommended that non-basic units such as degrees or gees not be
used in the equations (use radians for angles and ft/s2 or m/s2 for acceleration).
Variables can be converted into auxiliary units in the DYNAMIC section for output.
The ACSL program is listed in Figure A10-3. Figure A10-4 lists a FORTRAN
subroutine called from the ACSL program.
The missile program is distributed in two versions — single precision and double
precision. The version shown here is double precision; i.e., in a form to be used with

Page A-70 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

Figure A10-1. Missile (M) frame and fin deflection direction

the global double precision translation mode. Double precision translation mode is
specified when calling ACSL from the computer operating system and so depends on
the computer system. See the document ACSL Sim User's Guide for more information.
For VAX systems, for example, a switch specifies double precision as follows:
ACSL/DOUBLE_PRECISION misdbl

For Unix systems, -x stands for extended precision:


acsl -x msldbl

The translator handles floating point variables as either single or double precision
(depending on the mode requested) unless REAL or DOUBLEPRECISION is
specified. In general, vectors and arrays should be dimensioned with DIMENSION

Figure A10-2. Missile (M) frame with pitch angle-of-attack

ACSL Reference Manual Page A-71


A. ACSL Example Programs A10. Missile Airframe

PROGRAM - missile airframe model

!-----------------------a generic missile airframe model is


! developed using vectors for all three dimensional quantities.
! this model will respond to fin deflections so representing the
! open loop airframe response and needs a seeker, autopilot,
! actuator, motor and target module in order to evaluate guidance
! effectiveness

DYNAMIC
CINTERVAL cint = 0.020
ALGORITHM ialg = 4
MAXTERVAL maxt = 0.010
NSTEPS nstp = 1

DERIVATIVE

!-----------------------environment module

!-----------------------velocity of sound - function of altitude


TABLE vsf, 1, 10 &
/ 0.0 , 1.0e4 , 2.0e4 , 3.0e4 , 4.0e4 &
, 5.0e4 , 6.0e4 , 7.0e4 , 8.0e4 , 9.0e4 &
, 1186.5 , 1077.4 , 1036.4 , 994.8 , 968.1 &
, 968.1 , 968.1 , 970.9 , 977.6 , 984.3 /
vs = vsf(rm(2))
!-----------------------log of atmospheric density
TABLE lro, 1, 10 &
/ 0.0 , 1.0e4 , 2.0e4 , 3.0e4 , 4.0e4 &
, 5.0e4 , 6.0e4 , 7.0e4 , 8.0e4 , 9.0e4 &
,-6.04191 ,-6.34502 ,-6.67084 ,-7.02346 ,-7.43995 &
,-7.91851 ,-8.39664 ,-8.87953 ,-9.36448 ,-9.87239/
!-----------------------calculate actual atmospheric density
ro = EXP(lro(rm(2)))

!-----------------------missile airframe module

!-----------------------define elements of stability derivative


! matrix. linear aerodata is assumed for simplicity in subroutine
! coeff. non-linear aerodata may be incorporated by rewriting
! this subroutine
COMMON/stabd/ a(30)
CONSTANT a = &
0.148 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 &
, 0.0 ,-0.26 , 0.0 , 0.0 , 0.0 ,-0.286 &
, 0.0 , 0.0 ,-0.26 , 0.0 , 0.286 , 0.0 &
, 0.0 , 0.528 , 0.0 , 0.0 , 0.0 , 2.0 &
, 0.0 , 0.0 , 0.528 , 0.0 ,-2.0 , 0.0
!-----------------------magnitude of missile velocity
REAL dot
mvm = SQRT(dot(vm, vm))
!-----------------------make *me* matrix from orientation angles
DOUBLEPRECISION me(9)
CALL mmk(me = fim, 1, thm, 3, sim, 2)
!-----------------------rotate velocity to missile frame
DOUBLEPRECISION vmm(3)
CALL vecrot(vmm = vm, me)
!-----------------------lateral and vertical angles of attack
al2 = ATAN(-vmm(3)/vmm(1))
al3 = ATAN( vmm(2)/vmm(1))

Figure A10-3. Missile airframe program (part 1)

Page A-72 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

!-----------------------mach number and dynamic pressure


mach = mvm/vs
q = 0.5*ro*mvm**2
!-----------------------fin deflections
DOUBLEPRECISION dl(4)
CONSTANT dl = 4*0.0
!-----------------------missile dimensional constants
CONSTANT b = 3.95 , cbar = 5.62
CONSTANT s = 13.9
!-----------------------roll damping - function of mach number
TABLE clp, 1, 5 &
/ 0.0 , 0.8 , 1.0 , 1.2 , 2.0 &
,-0.21 ,-0.21 ,-0.20 ,-0.19 ,-0.18 /
!-----------------------pitch damping - function of mach number
TABLE cmq, 1, 5 &
/ 0.0 , 0.8 , 1.0 , 1.2 , 2.0 &
,-3.8 ,-2.0 ,-1.5 ,-2.0 ,-2.1 /
!-----------------------calculate damping derivatives
PROCEDURAL(cd = mvm, mach, wm)
DIMENSION cd(3)
cd(1) = 0.5*clp(mach)*b*wm(1)/mvm
ccvv = 0.5*cmq(mach)*cbar/mvm
cd(2) = ccvv*wm(2)
cd(3) = ccvv*wm(3)
END ! of procedural
!-----------------------get moments and force aero coefficients
! and correct lateral moments for shift in center of gravity
! position
PROCEDURAL(c = al2, al3, dl, mach, dxcg)
DOUBLEPRECISION c(6)
CALL coeff(c = al2, al3, dl, mach)
CONSTANT dxref = 9.60
c(2) = c(2) - (dxcg - dxref)*c(6)/cbar
c(3) = c(3) + (dxcg - dxref)*c(5)/cbar
END ! of procedural
!-----------------------aerodynamic acceleration
PROCEDURAL(nm = q, c, mass, thrust)
DOUBLEPRECISION nm(3)
nm(1) =(q*s*c(4) + thrust)/mass
nm(2) = q*s*c(5)/mass
nm(3) = q*s*c(6)/mass
END ! of procedural
!-----------------------rotation rate derivatives
PROCEDURAL(wmd = q, c, cd, wm, ixx, iyy)
wmd(1) = q*s*b*(c(1) + cd(1))/ixx
wmd(2) = q*s*cbar*(c(2) + cd(2))/iyy + wm(1)*wm(3)
wmd(3) = q*s*cbar*(c(3) + cd(3))/iyy - wm(1)*wm(2)
END ! of procedural
!-----------------------rotate acceleration vector to earth frame
DOUBLEPRECISION nme(3)
CALL invrot(nme = nm, me)
!-----------------------calculate velocity derivatives in the
! earth frame - needs gravity adding in
PROCEDURAL(vmd = nme)
vmd(1) = nme(1)
vmd(2) = nme(2) - g ; CONSTANT g = 32.2
vmd(3) = nme(3)
END ! of procedural
!-----------------------yaw angle derivative
simd = (wm(2)*COS(fim) - wm(3)*SIN(fim))/COS(thm)

Figure A10-3. Missile airframe program (part 2)

ACSL Reference Manual Page A-73


A. ACSL Example Programs A10. Missile Airframe

!-----------------------integrate for all euler angles - note use


! of vector integrator for single element
CONSTANT simic = 0.0 , thmic = 0.0 , fimic = 0.0
sim = INTVC(simd, simic)
thm = INTEG(wm(2)*SIN(fim) + wm(3)*COS(fim), thmic)
fim = INTEG(wm(1) - simd*SIN(thm), fimic)
!-----------------------vector integrate for rotational velocity
DIMENSION wm(3), wmd(3), wmic(3)
wm = INTVC(wmd, wmic) ; CONSTANT wmic = 3*0.0
!-----------------------translational velocity
DIMENSION vm(3), vmd(3), vmic(3)
vm = INTVC(vmd, vmic) ; CONSTANT vmic = 2154.8, 2*0.0
!-----------------------translational position - note the deriv-
! ative vector cannot be a state vector (velocity) as well
DIMENSION rm(3), rmd(3), rmic(3)
CALL XFERBR(rmd = vm, 3)
rm = INTVC(rmd, rmic) ; CONSTANT rmic = 0.0, 10000.0, 0.0

!-----------------------motor module

!-----------------------simple version with zero thrust specifying


! a burnt or glide condition
CONSTANT thrust = 0.0 , mass = 8.77
CONSTANT ixx = 8.77 , iyy = 361.8
CONSTANT dxcg = 10.2

END ! of derivative

!-----------------------stop on elapsed time


CONSTANT tstp = 1.99
TERMT(t .GE. tstp, 'Time Limit')

END ! of dynamic

TERMINAL
!-----------------------set up in case dictionary desired
LOGICAL dictionary
CONSTANT dictionary = .false.
IF(dictionary) CALL LISTD(11)
END ! of terminal
END ! of program

Figure A10-3. Missile airframe program (part 3)

statements so that either mode can be used without editing the program. The ACSL
macro library, for example, contains two versions of most macros and uses the
appropriate version for the global precision in effect.
Many calls to subroutines need to have the precision specified. In the missile program,
the DOT function always returns a single precision result and so has to be defined by a
REAL statement. The subroutines from the geometrical subroutine library handle
either, depending on how the variables are defined. When considering the precision of
variables, check particularly any calls to subroutines.
The program controls are specified at the beginning of the DYNAMIC section. These
system variables (communication interval, integration algorithm, maximum

Page A-74 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

SUBROUTINE coeff(al2, al3, dl, mach, c)


c-----------------------------computes six aerodynamic coefficients -
c three moments, c(1), c(2) and c(3), and three forces, c(4), c(5)
c and c(6). moments are about axes centred at the reference point
c and must be corrected for centre of gravity shift.
c
c inputs
c
c al2 angle of attack about *m2* - positive wind from left
c al3 angle of attack about *m3* - positive wind from above
c dl array of four fin deflections
c mach mach number (real)
c
c outputs
c
c c array of six aerodynamic coefficients
c
c-@@--------------------------double/single
DOUBLEPRECISION dl(4), c(6), al2, al3, mach
c
c-----------------------------separate user common (real)
COMMON/stabd/ a(6,5)
c
c-----------------------------compute equivalent control surface defl-
c ections from the four surface angles
dla = 0.25*(dl(3) + dl(4) - dl(1) - dl(2))
dly = 0.50*(dl(1) + dl(3))
dlz = 0.50*(dl(2) + dl(4))
c-----------------------------compute each moment assuming it is linear
c in each of the arguments
DO 110 j = 1, 6
c(j) = a(j,1)*dla + a(j,2)*dly + a(j,3)*dlz + a(j,4)*al2
. + a(j,5)*al3
110 CONTINUE
RETURN
c
END

Figure A10-4. Subroutine called from missile program

integration step size, and number of integration steps per communcation interval) and
their default names and values are listed in Chapter 1. Each variable is also explained
in greater detail in Chapter 4. The second order Runge-Kutta integration algorithm is
chosen. Setting NSTP to 1 and using MAXT to control the integration step size is
recommended for most models.
The DERIVATIVE section is split up into logically connected code sequences or
modules (e.g., environment, airframe, motor). Modules help in documenting the
simulation and in checking out individual code sequences, since they can be removed
and assigned to various team members for verification. Since the ACSL translator
sorts the code, you do not have to be concerned with the order of statements for
computation. You can also use INCLUDE statements (see Chapter 4) to bring various
modules into a complex model such as this.
The environment model comprises tables for the velocity of sound (for Mach number
calculation) and air density (for dynamic pressure calculation) as a function of altitude.

ACSL Reference Manual Page A-75


A. ACSL Example Programs A10. Missile Airframe

The missile airframe module is the largest in the program. It begins with a definition
of common block STABD (stability derivative). The common block also appears in
subroutine COEFF, which is called later in the module, where aerodynamic
coefficients are determined. User common blocks allow sharing variables without
naming them as arguments in the call.
The FORTRAN subroutine COEFF is appended to the end of the ACSL program. The
first line of the subroutine comes immediately after the ACSL program END
statement, with no intervening comments or blank lines. Subroutines appended to an
ACSL program are transferred by the translator directly to the beginning of the
FORTRAN compile file. The translator does not check the subroutine for errors; that
is done by the FORTRAN compiler.
Subroutines can also be accessed from libraries. Several subroutines from a library of
three-dimensional geometric subroutines (available from Mitchell & Gauthier
Associates) are called to handle functions such as generating a direction cosine matrix
and rotating vectors using the direction cosine matrix. Libraries are made available by
specifying them in the call to ACSL from the operating system and so depends on the
computer system. See the document ACSL Sim User's Guide for more information.
Matrix A contains the stability derivative coefficients that determine the aerodynamic
characteristics. The COMMON statement in the ACSL program establishes the matrix
as having 30 elements; the COMMON statement in the COEFF subroutine dimensions
the matrix to be 6 by 5. A CONSTANT statement in the ACSL program fills in the
stability derivative values.
VM, the three-component vector for velocity in the E frame, and DOT, an external
(library) function for finding a dot product, are used to calculate the magnitude of the
missile velocity as follows:
mvm = SQRT(DOT(vm, vm))

The next step is to form the direction cosine matrix ME, which is a three by three
matrix for transforming vectors expressed in the E frame to components in the M
frame. The direction cosine matrix is calculated from the three angles ψM, θM, and ϕM.
Subroutine MMK (matrix make) from the geometrical subroutine library creates the
matrix, which transforms vectors between two axis systems connected by a rotation A
about the NA axis, rotation B about the NB axis, and rotation C about the NC axis.
The general FORTRAN call to this routine is as follows::
CALL mmk(a, na, b, nb, c, nc, m)

The ACSL call is expressed as follows:


CALL mmk(me = fim, 1, thm, 3, sim, 2)

Using the equal sign rather than a comma after the first argument tells the ACSL sorter
that ME is an output of the routine. The translator, in producing the FORTRAN code,
changes the order of the arguments so that the outputs are on the right and ME
coincides with M of the previous call.
The direction cosine matrix is then used to obtain components of the missile velocity
vector in the M frame from:

VM(M) = [ME] VM(E)

The subroutine VECROT (vector rotation) does this rotation and is called in the
program as follows:

Page A-76 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

CALL vecrot(vmm = vm, me)

where again the order of the arguments is inverted by the translator so that the actual
FORTRAN call is:
CALL vecrot(vm, me, vmm)

A corresponding subroutine INVROT (inverse rotation), used later in the program,


inverts a vector (NM, for example) from the M frame into the E frame:

NME = [ME]−1 NM

with code in the form:


CALL invrot(nme = nm, me)

Lateral and vertical angles-of-attack are calculated next. The lateral angle-of-attack α2
(AL2) is the angle between M1 and the projection of the velocity vector on to the
M1/M3 plane and is positive for a positive rotation from M1 to the wind vector about
M2 (wind from left). Vertical angle-of-attack α3 (AL3) is the angle between M1 and
the projection of the velocity vector on the M1/M2 plane and is positive for a positive
rotation from M1 to the wind vector about M3 (wind from above). See Figure A10-2.
The angle-of-attack equations are expressed (in radians) in terms of the missile
velocity vector components as follows:

 −VM(M3) 
α2 = tan−1  
(M1)
 VM 

 VM(M2) 
α3 = tan−1 
(M1) 
 VM 
Atmospheric density ρ (RO, with units of slug/ft3), is taken from table LRO (log of ρ)
in the environment module. Using the log function for the density reduces the dynamic
range of the function, making the straight line interpolation over 10 kft increments
more accurate. Air density is a function of height, which is the component of the
missile range along E2 (i.e., RM(2)):

ρ = EXP[LRO(RM(2))]

Dynamic pressure (in lb/ft2) is calculated from air density and the magnitude of the
missile velocity (MVM in the program) as follows:

ρV2
Q =
2

Mach number is calculated from the missile velocity and the velocity of sound (from
table VSF in the environment model as a function of the missile's altitude) as follows:

V
MACH =
VSF(RM(2))

Dimensionless damping coefficients are obtained from normalized spin rates. The
missile spin rate is expressed as a three component vector WM giving the rates as
components resolved along the M1, M2, and M3 axes. In conventional aerodynamic
terminology, L, M, and N refer to roll, pitch, and yaw axes and P, Q, and R refer to the
roll, pitch, and yaw rates. In the model, the rates are named WM(1), WM(2), and

ACSL Reference Manual Page A-77


A. ACSL Example Programs A10. Missile Airframe

_ operations are convenient. The characteristic span is b and the


WM(3) so that vector
reference chord is c. With Clp and Cmq taken from tables as a function of Mach number,
the damping coefficient components (CD) of the total moment coefficients are now
calculated as follows:

CD(1) = Clp(MACH) ∗ pb ⁄ 2V

CD(2) = Cmq(MACH) ∗ qc ⁄ 2V

CD(3) = Cmq(MACH) ∗ rc ⁄ 2V

From the symmetry of the missile, the pitch and yaw damping derivatives are assumed
to be identical, so Cmq is used in place of the usual Cnr in the yaw direction, making a
third coefficient table unnecessary.
The translator objects if a variable name appears on the left side of more than one
equation, so the calculation of the various elements of arrays are placed in
PROCEDURAL blocks. The list in the header informs the translator of the outputs
(listed before the equal sign) and inputs (listed after the equal sign) so that it can place
the block appropriately during the sorting process.
The aerodynamic coefficients (three moment and three force) are calculated in
subroutine COEFF. They are evaluated as functions of the two angles-of-attack (α2
and α3), four fin deflections (δ1 through δ4), and Mach number; i.e., seven variables in
all. One of the objects of this example is to study the effect of various techniques in
evaluating aerodynamic coefficients, from full nonlinear tables of data to simple linear
stability derivatives. For the case shown, simple linear stability derivatives are
embedded in the (A) matrix passed to the COEFF by means of the common block
STABD. This (A) matrix is a five by six array with components:

 Clδa Clδy Clδz Clα2 Clα3 


 Cm Cmδy Cmδz Cmα2 Cmα3 
 δa

 Cnδa Cnδy Cnδz Cnα2 Cnα3 
A ≡ 
C Cxδy Cxδz Cxα2 Cxα3 
 xδa 
 Cyδa Cyδy Cyδz Cyα2 Cyα3 
 Cz Czδy Czδz Czα2 Czα3 
 δa 

The effective roll, yaw, and pitch fin control deflections (δa, δy, and δz) are calculated
in the subroutine from the equations:

− δ1 − δ2 + δ3 + δ4
δa =
4

δ1 + δ3
δy =
2

δ2 + δ4
δz =
2

The subroutine returns the six component vector C having the following elements:

Page A-78 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

C(1) rolling moment coefficient, about M1


C(2) moment coefficient about M2
C(3) moment coefficient about M3
C(4) force coefficient along M1
C(5) force coefficient along M2
C(6) force coefficient along M3

Aerodynamic acceleration N(M) is the acceleration produced by aerodynamic forces; it


exludes gravity (which is introduced in the equations for translational acceleration)
and is the quantity which is read by any on-board accelerometers. The component in
the forward direction includes the thrust of the propulsion system.

N(M1) = (qsCx + THRUST) ⁄ MASS


N(M2) = qsCy ⁄ MASS
N(M3) = qsCz ⁄ MASS

The rotational accelerations have gyroscopic terms in the equations when applied to a
normal spinning rigid body. The equations of motion of a conventional aircraft have
the following form (neglecting Ixz):
.
Ixp = QsbC
_ l + (Iy − Iz) qr
.
Iyq = QscCm + (Iz − Ix) rp

However, for an axisymmetrical missile, the lateral moments of inertia are equal; i.e.,

Iz = Iy

In addition, the long thin shape assures that the roll moment of inertia is small; i.e.,

Ix << Iy

The equations for missile rotational acceleration can thus be expressed:


.
Ixp = Qsb
_ [Cl + Clp(pb _⁄ 2V) ]
.
Iyq = Qsc
_ [Cm + Cmq(qc
_ ⁄ 2V) ] + Iypr
.
Iyr = Qsc [Cn + Cmq(rc ⁄ 2V) ] − Iypq

The aerodynamic accelerations are rotated from the missile frame (M) to the earth
frame (E) using the inverse rotation subroutine INVROT. The transformation can be
expressed mathematically as follows:

NM(E) = [ME]−1 NM(M)

With the aerodynamic acceleration in the inertial frame, gravity (g) is added to get
translational acceleration (i.e., the velocity derivative). This is the preferred reference
frame for integrating the translational states.
.
VM(E1) = NM(E1)
.
VM(E2) = NM(E2) − g
.
VM(E3) = NM(E3)
.
The angular rate derivative ψM is obtained from the standard gimbal equation by:

ACSL Reference Manual Page A-79


A. ACSL Example Programs A10. Missile Airframe

. q cos ϕM − r sin ϕM
ψM =
cos θM

The three rotational angles are obtained by integrating their respective rates:
.
ψM = INTVC(ψM, ψMIC)
θM = INTEG(q sin ϕM + r cos ϕM, θMIC)
.
ϕM = INTEG(p − ψM sin θM, ϕMIC)

The INTVC operator requires the derivative to be given as a variable name, which
saves an assignment statement in translation. INTEG is used when the derivative is an
expression or a state. The translator then generates a name (in the form Z0nnnn) for
the derivative. In this example, the INTEG operator is . used for θM and ϕM, saving two
assignment statements in the model code; however, ψM is calculated separately so that
it can be part of the expression for the derivative of ϕM and thus the INTVC operator
can be used for ψM.
The vectors for missile angular spin and the translational velocity are integrated from
the respective accelerations by the two statements:
wm = INTVC(wmd, wmic)
vm = INTVC(vmd, vmic)

The next step is to integrate translational velocity to range. We cannot use the name
VM for the derivative of RM since the same name cannot be both a state and a
derivative. The reason is that such a duplication causes a conflict in storage in the state
table assignment. So the three elements of VM are first transferred by the XFERBR
(transfer block) utility to a range derivative vector (RMD), and then RMD is integrated
with the vector integrator.
CALL XFERBR(rmd = vm, 3)
rm = INTVC(rmd, rmic)

The last section of the program describes the motor module with zero thrust and
constant mass and inertias. For a real system, the motor model would compute thrust
as a function of time from motor ignition. It would also vary mass, inertia, and center
of gravity position, all of which significantly affect flight characteristics.
Figure A10-5 is the log file of a runtime session. The TITLE is set, the printout is
limited to an 80-column width, and a PREPARE list is defined. Fin deflections of
-0.01 radians are specified for fins two and four, which results in motion in the vertical
plane; i.e., the missile nose tends to go up. The run is executed with the START
command.
The message Time Limit is generated by the optional comment argument of the
TERMT operator in the program. It indicates that the run terminated on T (time)
becoming greater than the value of constant TSTP.
Figure A10-6 shows a strip plot of several model variables. To generate this plot, the
strip plot option (STRPLT) is set true, the default line plot option (CALPLT) is turned
off, and the plot scale factor (PSFSPL) is set. The X axis (XINSPL) is set longer than
the default and the grid set further apart (XTISPL). The PLOT command then
generates the plot, with the named variables appearing from the bottom up.
PRINT/ALL generates a columnar list of the values, over the course of the run, of all
the variables listed in the PREPARE command. Specifying NCIPRN reduces the
number of lines printed; i.e., only every fifth line is printed in this case.

Page A-80 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 5-MAR-91 16:28:55 Page 1

SET TITLE='Missile Longitudinal Dynamics'


SPARE
Accumulated cp time 18.72000. Elapsed cp time 0.
SET PCWPRN=80 ! Force narrow printout
PREPARE t,nm,wm,al2,al3,vm,sim,thm,fim,mach,q
SET dl(2)=-0.01,dl(4)=-0.01,TITLE(41)='Step in Fin',' Nominal CG'
START
Time Limit
SET STRPLT=.T.,CALPLT=.F.,PSFSPL=0.5,XINSPL=10.0,XTISPL=2.0
PLOT nm(2),wm(3),al3,vm(2),thm
Drawing plot number 1
PRINT/NCIPRN=5/ALL

Line T NM(1) NM(2) NM(3) WM(1) WM(2)


0 0. 0. -18.4739000 0. 0. 0.
5 0.10000000 0. 75.7595000 0. 0. 0.
10 0.20000000 0. 112.717000 0. 0. 0.
15 0.30000000 0. 68.1165000 0. 0. 0.
20 0.40000000 0. 57.5482000 0. 0. 0.
25 0.50000000 0. 77.8265000 0. 0. 0.
30 0.60000000 0. 79.9538000 0. 0. 0.
35 0.70000000 0. 71.0253000 0. 0. 0.
40 0.80000000 0. 71.1397000 0. 0. 0.
45 0.90000000 0. 74.9205000 0. 0. 0.
50 1.00000000 0. 74.4090000 0. 0. 0.
55 1.10000000 0. 72.8277000 0. 0. 0.
60 1.20000000 0. 73.2024000 0. 0. 0.
65 1.30000000 0. 73.8059000 0. 0. 0.
70 1.40000000 0. 73.5450000 0. 0. 0.
75 1.50000000 0. 73.2836000 0. 0. 0.
80 1.60000000 0. 73.3898000 0. 0. 0.
85 1.70000000 0. 73.4521000 0. 0. 0.
90 1.80000000 0. 73.3600000 0. 0. 0.
95 1.90000000 0. 73.3023000 0. 0. 0.
100 2.00000000 0. 73.3046000 0. 0. 0.

Line WM(3) AL2 AL3 VM(1) VM(2) VM(3)


0 0. 0. 0. 2154.80000 0. 0.
5 0.09665400 0. -0.00729433 2154.79000 -0.92543800 0.
10 0.01834670 0. -0.01015610 2154.67000 6.38481000 0.
15 -0.01375680 0. -0.00670389 2154.55000 12.3191000 0.
20 0.02345740 0. -0.00588607 2154.48000 14.8958000 0.
25 0.03280950 0. -0.00745698 2154.38000 18.4523000 0.
30 0.01580990 0. -0.00762268 2154.24000 23.3268000 0.
35 0.01379480 0. -0.00693207 2154.10000 27.6266000 0.
40 0.02128740 0. -0.00694193 2153.96000 31.4283000 0.
45 0.02126790 0. -0.00723605 2153.79000 35.5313000 0.
50 0.01805950 0. -0.00719772 2153.60000 39.8092000 0.
55 0.01843110 0. -0.00707651 2153.41000 43.9353000 0.
60 0.01974970 0. -0.00710705 2153.20000 48.0009000 0.
65 0.01942760 0. -0.00715547 2152.98000 52.1351000 0.
70 0.01888920 0. -0.00713694 2152.74000 56.2835000 0.
75 0.01907650 0. -0.00711848 2152.49000 60.3971000 0.
80 0.01927220 0. -0.00712865 2152.22000 64.5044000 0.
85 0.01915570 0. -0.00713552 2151.94000 68.6229000 0.
90 0.01907050 0. -0.00713053 2151.65000 72.7381000 0.
95 0.01911440 0. -0.00712830 2151.34000 76.8440000 0.
100 0.01912960 0. -0.00713084 2151.02000 80.9472000 0.

Figure A10-5. Missile example log file (part 1)

ACSL Reference Manual Page A-81


A. ACSL Example Programs A10. Missile Airframe

ACSL Runtime Exec Version 6 Level 10B 5-MAR-91 16:28:55 Page 2


Missile Longitudinal Dynamics Step in Fin Nominal CG

Line SIM THM FIM MACH Q


0 0. 0. 0. 2.00000000 4075.46000
5 0. 0.00686485 0. 1.99999000 4075.43000
10 0. 0.01311930 0. 1.99989000 4075.00000
15 0. 0.01242150 0. 1.99981000 4074.52000
20 0. 0.01279980 0. 1.99977000 4074.13000
25 0. 0.01602180 0. 1.99972000 4073.64000
30 0. 0.01845050 0. 1.99965000 4073.01000
35 0. 0.01975650 0. 1.99958000 4072.32000
40 0. 0.02153190 0. 1.99952000 4071.58000
45 0. 0.02373160 0. 1.99945000 4070.75000
50 0. 0.02568060 0. 1.99937000 4069.83000
55 0. 0.02747630 0. 1.99930000 4068.84000
60 0. 0.02939620 0. 1.99922000 4067.78000
65 0. 0.03136610 0. 1.99914000 4066.64000
70 0. 0.03327600 0. 1.99906000 4065.41000
75 0. 0.03517030 0. 1.99897000 4064.11000
80 0. 0.03709070 0. 1.99889000 4062.74000
85 0. 0.03901350 0. 1.99880000 4061.28000
90 0. 0.04092340 0. 1.99870000 4059.75000
95 0. 0.04283220 0. 1.99861000 4058.14000
100 0. 0.04474510 0. 1.99851000 4056.46000
ANALYZE/FREEZE=rm,vm,fim/TRIM/JACOBIAN/EIGEN
Jacobian evaluated. Condition number is 0.37250500
Row vector names
SIM 1 THM 2 WM(1) 3
WM(2) 4 WM(3) 5

Column vector names


SIMD 1 Z09982 2 WMD(1) 3
WMD(2) 4 WMD(3) 5

Matrix elements - rows across, columns down


1 2 3 4 5
1 0. 0. 0. 1.0000300 0.
2 0. 0. 0. 0. 1.0000000
3 0. 0. -4.2094100 0. 0.
4 -276.73200 0. 0. -2.4097800 0.
5 0. -276.72600 0. 0. -2.4097800

Complex eigenvalues in ascending order


REAL IMAGINARY FREQUENCY DAMPING
1 -4.20941000
2 -1.20489000 +/-16.5914000 16.63510 0.072431
4 -1.20489000 +/-16.5918000 16.63550 0.072429

REINIT
S tstp=0.0,NDBUG=1
START

....Debug dump - System Variables. NDBUG is 1, block number 1


T 0. ZZTICG 0. CINT 0.02000000
ZZIERR F ZZNBLK 1 ZZICON 1
ZZSTFL F ZZFRFL T ZZICFL T
ZZRNFL T ZZJEFL F ZZNIST 12
ZZNAST 0 IALG 4 NSTP 1
MAXT 0.01000000 MINT 1.0000D-09

Figure A10-5. Missile example log file (part 2)

Page A-82 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 5-MAR-91 16:28:55 Page 3


Missile Longitudinal Dynamics Step in Fin Nominal CG

State Variables Derivatives Initial Conditions


FIM 0. Z09981 0. FIMIC 0.
RM(1) 0. RMD(1) 2154.80000 RMIC(1) 0.
RM(2) 10000.0000 RMD(2) 0. RMIC(2) 10000.0000
RM(3) 0. RMD(3) 0. RMIC(3) 0.
SIM 0. SIMD 0. SIMIC 0.
THM 0.00729676 Z09982 0. THMIC 0.00729676
VM(1) 2154.80000 VMD(1)-0.55302695 VMIC(1) 2154.80000
VM(2) 0. VMD(2) 43.5894257 VMIC(2) 0.
VM(3) 0. VMD(3) 0. VMIC(3) 0.
WM(1) 0. WMD(1) 0. WMIC(1) 0.
WM(2) 0. WMD(2) 0. WMIC(2) 0.
WM(3) 0. WMD(3)-2.9816D-08 WMIC(3) 0.

Algebraic Variables

Common Block /ZZCOMU/


DICTIONARY F ZZSEED 55555555
Common Block /ZZCOMP/
AL2 0. AL3-0.00729676 B 3.95000000
C 0. 0. -3.3884D-11
0. 0.01173352 0.
CBAR 5.62000000 CCVV-0.00273854 CD 0.
0. 0. CLP-0.21000000
-0.21000000 -0.20000000 -0.19000000
-0.18000000 0. 0.80000000
1.00000000 1.20000000 2.00000000
Z09989-0.21000000 -0.21000000 -0.20000000
-0.19000000 -0.18000000 Z09990 0.
0.80000000 1.00000000 1.20000000
2.00000000 CMQ-3.80000000 -2.00000000
-1.50000000 -2.00000000 -2.10000000
0. 0.80000000 1.00000000
1.20000000 2.00000000 Z09987-3.80000000
-2.00000000 -1.50000000 -2.00000000
-2.10000000 Z09988 0. 0.80000000
1.00000000 1.20000000 2.00000000
DL 0. -0.01000000 0.
-0.01000000 DXCG 10.2000000 DXREF 9.60000000
G 32.2000000 IXX 8.77000000 IYY 361.800000
LRO(20) 90000.0000 Z09993-6.04191000 -6.34502000
-6.67084000 -7.02346000 -7.43995000
-7.91851000 -8.39664000 -8.87953000
-9.36448000 -9.87239000 Z09994 0.
10000.0000 20000.0000 30000.0000
40000.0000 50000.0000 60000.0000
70000.0000 80000.0000 90000.0000
MACH 2.00000005 MASS 8.77000000 ME 0.99997336
-0.00729669 0. 0.00729669
0.99997336 0. 0.
0. 1.00000000 MVM 2154.80005
NM 0. 75.7914451 0.
NME-0.55302695 75.7894257 0.
Q 4075.46140 RO 0.00175547 S 13.9000000
THRUST 0. TSTP 0. VMM 2154.74259
-15.7229152 0. VS 1077.40000

Figure A10-5. Missile example log file (part 3)

ACSL Reference Manual Page A-83


A. ACSL Example Programs A10. Missile Airframe

ACSL Runtime Exec Version 6 Level 10B 5-MAR-91 16:28:55 Page 4


Missile Longitudinal Dynamics Step in Fin Nominal CG

VSF(20) 90000.0000 Z09997 1186.50000 1077.40000


1036.40000 994.800000 968.100000
968.100000 968.100000 970.900000
977.600000 984.300000 Z09998 0.
10000.0000 20000.0000 30000.0000
40000.0000 50000.0000 60000.0000
70000.0000 80000.0000 90000.0000
Z09983 0. Z09984-2.10000001 Z09985 0.
Z09986-0.18000000 Z09991 0. Z09992-6.34502000
Z09995 0. Z09996 1077.40000
Common Block /STABD/
A(30) 0.

Time Limit
ANALYZE/CLEAR ! Release frozen states
ANALYZE/JACOBIAN/EIGEN
Row vector names
FIM 1 RM(1) 2 RM(2) 3
RM(3) 4 SIM 5 THM 6
VM(1) 7 VM(2) 8 VM(3) 9
WM(1) 10 WM(2) 11 WM(3) 12

Column vector names


Z09981 1 RMD(1) 2 RMD(2) 3
RMD(3) 4 SIMD 5 Z09982 6
VMD(1) 7 VMD(2) 8 VMD(3) 9
WMD(1) 10 WMD(2) 11 WMD(3) 12

Matrix elements - rows across, columns down


1 2 3 4 5
1 0. 0. 0. 0. 0.
2 0. 0. 0. 0. 0.
3 0. 0. 0. 0. 0.
4 0. 0. 0. 0. 0.
5 0. 0. 0. 0. 0.
6 0. 0. 0. 0. 0.
7 0. 0. 1.739E-05 0. 0.
8 0. 0. -0.0023833 0. 0.
9 -18.475500 0. 0. 0. -12918.600
10 0. 0. 0. 0. 0.
11 -2.0192300 0. 0. 0. -276.73200
12 0. 0. 9.376E-13 0. 0.
6 7 8 9 10
1 0. 0. 0. 0. 1.0000000
2 0. 1.0000000 0. 0. 0.
3 0. 0. 1.0000000 0. 0.
4 0. 0. 0. 1.0000000 0.
5 0. 0. 0. 0. 0.
6 0. 0. 0. 0. 0.
7 -170.05400 -5.132E-04 0.0437463 0. 0.
8 12917.900 0.0703363 -5.9952000 0. 0.
9 0. 0. 0. -5.9955200 0.
10 0. 0. 0. 0. -4.2094100
11 0. 0. 0. -0.1284260 0.
12 -276.72600 -2.767E-11 0.1284220 0. 0.

Figure A10-5. Missile example log file (part 4)

Page A-84 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 5-MAR-91 16:28:55 Page 5


Missile Longitudinal Dynamics Step in Fin Nominal CG

11 12
1 -0.0072969 0.
2 0. 0.
3 0. 0.
4 0. 0.
5 1.0000300 0.
6 0. 1.0000000
7 0. 0.
8 0. 0.
9 0. 0.
10 0. 0.
11 -2.4097800 0.
12 0. -2.4097800

Complex eigenvalues in ascending order


REAL IMAGINARY FREQUENCY DAMPING
1 2.5909E-12
2 0.
3 0.
4 -2.9009E-18
5 -4.9658E-17
6 -3.1157E-04 +/-0.06794360 0.067944 0.004586
8 -4.20941000
9 -4.20243000 +/-16.5380000 17.06360 0.246281
11 -4.20265000 +/-16.5382000 17.06380 0.246291

S dxref=10.7,TITLE(53)='Aft CG '
S thmic=0.0,tstp=1.99
START
Time Limit
PLOT nm(2),wm(3),al3,vm(2),thm
Drawing plot number 2
ANALYZE/VECTORS=.T./EIGEN
Complex eigenvalues in ascending order
REAL IMAGINARY FREQUENCY DAMPING
1 1.4193E-05
2 8.5494E-08
3 0.
4 0.
5 -1.0868E-11
6 -1.1200E-04 +/-0.03939890 0.039399 0.002843
8 -4.20852000
9 -4.20153000 +/-24.8543000 25.20700 0.166681
11 -4.20160000 +/-24.8544000 25.20700 0.166684

Complex eigenvectors
1 2 3
1 0. 0. -2.125E-13 0. 0. 0.
2 1.0000000 0. 0. 0. 0. 0.
3 4.046E-04 0. 0. 0. 0. 0.
4 0. 0. -1.0000000 0. 1.0000000 0.
5 0. 0. 3.968E-11 0. 0. 0.
6 -5.976E-12 0. 0. 0. 0. 0.
7 1.419E-05 0. 0. 0. 0. 0.
8 5.742E-09 0. 0. 0. 0. 0.
9 0. 0. -8.549E-08 0. 0. 0.
10 0. 0. 0. 0. 0. 0.
11 0. 0. -1.459E-16 0. 0. 0.
12 -8.482E-17 0. 0. 0. 0. 0.

Figure A10-5. Missile example log file (part 5)

ACSL Reference Manual Page A-85


A. ACSL Example Programs A10. Missile Airframe

ACSL Runtime Exec Version 6 Level 10B 5-MAR-91 16:28:55 Page 6


Missile Longitudinal Dynamics Step in Fin Aft CG

4 5 6
1 0. 0. -2.698E-17 0. 0. 0.
2 1.0000000 0. 0. 0. 0.3663980-0.0418422
3 0. 0. 0. 0. -0.1145630-0.9215900
4 0. 0. 1.0000000 0. 0. 0.
5 0. 0. 5.044E-15 0. 0. 0.
6 0. 0. 0. 0. 1.686E-05-2.058E-06
7 0. 0. 0. 0. 0.0016075 0.0144403
8 0. 0. 0. 0. 0.0363224-0.0044104
9 0. 0. -1.087E-11 0. 0. 0.
10 0. 0. 0. 0. 0. 0.
11 0. 0. -1.895E-20 0. 0. 0.
12 0. 0. 0. 0. 7.921E-08 6.644E-07
7 8 9
1 0. 0. -0.1075760 0. 0. 0.
2 0.3663980 0.0418422 0. 0. 2.312E-04-2.098E-04
3 -0.1145630 0.9215900 0. 0. -0.0312990 0.0242473
4 0. 0. -0.2046220 0. 0. 0.
5 0. 0. 3.477E-05 0. 0. 0.
6 1.686E-05 2.058E-06 0. 0. 0.0016279-0.0010289
7 0.0016075-0.0144403 0. 0. 0.0042420 0.0066275
8 0.0363224 0.0044104 0. 0. -0.4711460-0.8797900
9 0. 0. 0.8611550 0. 0. 0.
10 0. 0. 0.4527350 0. 0. 0.
11 0. 0. -2.219E-04 0. 0. 0.
12 7.921E-08-6.644E-07 0. 0. 0.0187338 0.0447837
10 11 12
1 0. 0. 8.940E-06-5.138E-06 8.940E-06 5.138E-06
2 2.312E-04 2.098E-04 0. 0. 0. 0.
3 -0.0312990-0.0242473 0. 0. 0. 0.
4 0. 0. -0.0360518 0.0163680 -0.0360518-0.0163680
5 0. 0. -0.0016697 9.597E-04 -0.0016697-9.597E-04
6 0.0016279 0.0010289 0. 0. 0. 0.
7 0.0042420-0.0066275 0. 0. 0. 0.
8 -0.4711460 0.8797900 0. 0. 0. 0.
9 0. 0. 0.5582920 0.8272740 0.5582920-0.8272740
10 0. 0. 0. 0. 0. 0.
11 0. 0. 0.0308676 0.0374668 0.0308676-0.0374668
12 0.0187338-0.0447837 0. 0. 0. 0.

SPARE ! List execution time


Accumulated cp time 36.16000. Elapsed cp time 17.44000
QUIT

Figure A10-5. Missile example log file (part 6)

The ANALYZE command is used to find a trim condition and evaluate the Jacobian
and the eigenvalues. To find the trim condition, seven state variables (RM, VM, and
FIM) are frozen, leaving five to be varied. The missile position is frozen so that the
matrix will be invertible, and the velocity and roll angle are the conditions for trim.
ANALYZE/JACOBIAN/EIGEN produces the row and column vector names, the
matrix elements, and the complex eigenvalues in ascending order. The matrix is the
[A] matrix, with various states frozen and no controls or observables defined. The
eigenvectors show a real pole at -4.21 and double complex poles at -1.2±16.6.

Page A-86 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

Figure A10-6. Missile plots with nominal CG

In order to see the trim condition, the state variables are transferred back to the initial
conditions by REINIT. A debug dump is generated from one pass through the code by
setting the stop time to zero and NDBUG to one. The START command produces the
debug listing.
The next ANALYZE command evaluates the Jacobian of the full twelve by twelve
state matrix with corresponding eigenvalues.
The last exercise is to move the center of gravity to the rear (i.e., reference point
forward), which models a launch or unburned motor condition. The plot of the
response is shown in Figure A10-7 with the matching eigenvalues listed on page 5 of
the log file. Note that the response is more oscillatory and the dominant roots have
become more unstable.

ACSL Reference Manual Page A-87


A. ACSL Example Programs A10. Missile Airframe

Figure A10-7. Missile plots with CG moved aft

Figure A10-8 shows a dictionary listing. This output is obtained by calling subroutine
LISTD from the program. A dictionary file contains the variable names (starting in
column 1) and definitions (starting in column 11). The following statements appear in
the TERMINAL section:
LOGICAL dictionary
CONSTANT dictionary = .FALSE.
IF(dictionary) CALL LISTD(11)

At runtime, DICTIONARY is set to TRUE and the START command issued. The
output appears in the log file with values inserted between names and definitions. For
arrays, type and size are given. Askterisks for THMD indicate that there is no variable
by that name in the program. ZZSEED and S (at the end of the listing) were not found
in the dictionary file. See Appendix B for more details on LISTD.

Page A-88 ACSL Reference Manual


A10. Missile Airframe A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 12-MAR-91 14:41:07 Page 2


Missile Longitudinal Dynamics Step in Fin Nominal CG

A real((30)) Array of aerodynamic stability derivatives


AL2 0. Angle of attack about M2, positive wind from above (rad)
AL3-0.00713084 Angle of attack about M3, positive wind from right (rad)
B 3.95000000 Characteristic span (ft)
C dble((6)) Array of aerodynamic coefficients
CBAR 5.62000000 Characteristic chord (ft)
CCVV-0.00274116 Chord over velocity (sec)
CD dble((3)) Damping derivative - dimensionless moment derivatives
CINT 0.02000000 Communication interval (sec)
CLP dble((10)) Roll damping coefficient
CMQ dble((10)) Pitch and yaw damping coefficient
DL dble((4)) Fin deflection (rad)
DXCG 10.2000000 Center of gravity position, positive to rear (ft)
DXREF 9.60000000 Aerodynamic reference point, positive to rear (ft)
FIM 0. Roll angle of missile in M frame (rad)
FIMIC 0. Initial condition of FIM
G 32.2000000 Acceleration of gravity (ft/s**2)
IALG 4 Integration algorithm (integer)
IXX 8.77000000 Roll inertia (slug-ft**2)
IYY 361.800000 Lateral inertia (slug-ft**2)
LRO dble((20)) Log of atmospheric density
MACH 1.99851014 Mach number
MASS 8.77000000 Missile mass (slug)
MAXT 0.01000000 Maximum integration step size (sec)
ME dble((9)) Direction cosine matrix between E frame and M frame
MINT 1.0000D-09 Minimum integration step size (sec)
MVM 2152.54590 Magnitude of VM (ft/s)
NM dble((3)) Aerodynamic acceleration vector of missile (ft/s**2)
NME dble((3)) NM vector expressed in E frame (ft/s**2)
NSTP 1 Number of steps per communication interval (integer)
Q 4056.45841 Dynamic pressure (lb/ft**2)
RM dble((3)) Range vector of missile (ft)
RMD dble((3)) Derivative of RM (ft/s)
RMIC dble((3)) Initial condition of RM (ft)
RO 0.00175094 Atmospheric density (slug/ft**3)
SIM 0. Yaw angle of missile (rad)
SIMD 0. Derivative of SIM (rad/s)
SIMIC 0. Initial condition of SIM (rad)
T 2.00000000 Independent variable, time (sec)
THM 0.04474506 Pitch angle of missile (rad)
THMD ****** Derivative of THM (rad/s)
THMIC 0. Initial condition of THM (rad)
THRUST 0. Thrust from propulsion system (lb)
TSTP 1.99000000 Stopping time for simulation runs (sec)
VM dble((3)) Velocity of missile (ft/s)
VMD dble((3)) Acceleration of missile (ft/s**2)
VMIC dble((3)) Initial condition of VM (ft/s)
VMM dble((3)) VM vector expressed in M frame (ft/s)
VS 1077.07529 Velocity of sound (ft/s)
VSF dble((20)) Name of table for VS as function of Mach
WM dble((3)) Spin rate vector of missile (rad/s)
WMD dble((3)) Derivative of WM (rad/s**2)
WMIC dble((3)) Initial condition of WM (rad/s)
ZZSEED 55555555 *
S 13.9000000 *

Figure A10-8. Missile example dictionary output from subroutine LISTD

ACSL Reference Manual Page A-89


A. ACSL Example Programs A11. Discrete Sampled Compensator

11. Discrete
Sampled
Compensator

In this example, a digitial control computer interacts with a continuous plant. A


DISCRETE section is used in modeling the sampled data system. The system block
diagram is shown in Figure A11-1. The plant is represented by a transfer function:

1
s(s + 1)

This system can be visualized as a water level control problem where the valve
controlling the flow into the tank has a one second time constant. An instantaneous
level measurement (X) is assumed; it is compared with a desired (control) level (XC),
and the error is sampled every tenth of a second. A digital controller is to take the
samples of level error E and output a command U to the valve, thus closing the loop.
This control is taken to be a linear combination of the current error (En), the previous
error (En-1), and the previous control (Un-1). Expressed in Z-transform notation, this is:

U a0 − a1z−1
=
E 1 − b1z−1

In terms of equivalent lead/lag network, the a and b coefficients above can be written
as follows, which gives steady state gain of one and reduces to a zero order hold when
the lead and lag time constants are equal:

TLED −Ts ( 1 ⁄ TLAG − 1 ⁄ TLED)


a0 = e
TLAG

TLED −Ts ⁄ TLAG


a1 = e
TLAG

b1 = e −Ts ⁄ TLAG

Figure A11-1. Discrete control system block diagram

Page A-90 ACSL Reference Manual


A11. Discrete Sampled Compensator A. ACSL Example Programs

The program to represent this plant and control system is shown in Figure A11-2. An
INITIAL, a DERIVATIVE, and two DISCRETE sections are used.
In the INITIAL section, the coefficients of the digital filter are calculated so that the
controller response can be thought of in terms of equivalent lead/lag time constants.
The constants for these equations are found later in the program. TSAMP, for example,
is found in the INTERVAL statement in DISCRETE section ADC. TLED and TLAG
are specified in a CONSTANT statement just before the calculation of UC, which uses
them in the LEDLAG operator. CONSTANT statements can be placed anywhere in
the program; we recommend placing them near equations where they are used or else
in a block where all constants are specified so that they can be found easily.
Also in the INITIAL section, the discrete control (UD) and the previous error (EP) are
initialized to zero. These are effectively system state variables (i.e., since they are
needed before they are calculated) even though they are not obtained, as most states
are, by integration.
The continuous section is given a name (DERIVATIVE CONTINUOUS). Naming the
section is optional. The plant is modeled by the one line:
x = INTEG(REALPL(tad, ku*u), 0.0)

The control (U) is selected to take either the discrete value (UD) or that produced by a
continuous lead-lag compensator (UC) based on a switch DISCRETE; i.e.,
u = RSW(discrete, ud, uc)

The logical DISCRETE is set by a CONSTANT statement and is therefore accessible


at runtime for switching between the effect of the discrete or the continuous controller.
When DISCRETE is TRUE, the controller is discrete; when FALSE, continuous.
Integration step size for the continuous section is 0.02 seconds, specified both by the
communication interval (CINT) and by MAXT. The reason such a comparatively short
step is used is to record data during the sampling so that the discrete hold (sample
interval 0.1 sec) can be seen on the plots. With five data points logged for every
sample, the corners of the control (U) can be clearly seen in the plots. If the
communication interval had been increased to 0.1 seconds or more, the straight lines
drawn between points would have masked the sampling action, though the simulation
would still behave the same internally. Another method of squaring the corners, also
implemented in this example, is to call the LOGD subroutine to log data at the
beginning and end of the DISCRETE sections.
In the DISCRETE ADC section, the step size is controlled by the INTERVAL
statement, which specifies the name of the controlling variable as TSAMP and a value
of 0.1 seconds. The code executes once at time T zero and then once every 0.1 seconds
thereafter. A new control is calculated, but hidden from the continuous section, based
on the previous control, previous error, and current error as follows:
udp = b1*ud + a0*ep - a1*ep

The current error is transferred to the previous error by the statement:


ep = e

With the use of the DISCRETE section, the continuous section is guaranteed to step
up to the sample time, when the DISCRETE section code is executed, so the value of
current error (E) used is that actually at the sample time. The new value of control is
effectively calculated instantaneously, but since the control computer action is to be
modeled, the change in actual control used (UD) must be delayed by the calculation
time DELAYTIME. This is implemented with a SCHEDULE statement as follows:

ACSL Reference Manual Page A-91


A. ACSL Example Programs A11. Discrete Sampled Compensator

PROGRAM discrete sampled compensator


!-----------------------models a continuous plant with either a
! continuous or discrete feed back controller wrapped around it.
! plant can be visualised as a level controller using valve
! with single lag time constant (= 1 second)

INITIAL
CINTERVAL cint = 0.02
NSTEPS nstp = 1
MAXTERVAL maxt = 0.020
!-----------------------calculate z transform controller gains
b1 = EXP(-tsamp/tlag)
a0 = tled*EXP(-tsamp*(1.0/tlag - 1.0/tled))/tlag
a1 = tled*EXP(-tsamp/tlag)/tlag
!-----------------------initialise pseudo state variables
ud = 0.0
ep = 0.0
END ! of initial

DERIVATIVE continuous
!-----------------------plant model
CONSTANT ku = 5.0 , tad = 1.0
x = INTEG(REALPL(tad, ku*u), 0.0)
!-----------------------continuous control action
CONSTANT tled = 0.5 , tlag = 0.5
uc = LEDLAG(tled, tlag, e)
!-----------------------error signal
CONSTANT xc = 1.0
e = xc - x
!-----------------------choose discrete or continuous control
LOGICAL discrete
CONSTANT discrete = .TRUE.
u = RSW(discrete, ud, uc)
!-----------------------terminate on time limit
CONSTANT tstp = 4.9
TERMT(t .GE. tstp, 'Time Limit')
END ! of continuous section

discrete adc
INTERVAL tsamp = 0.1
!-----------------------discrete control is linear combination of
! prev control, prev error and current err
! use prime to hide output from continuous
udp = b1*ud + a0*e - a1*ep
!-----------------------current error becomes previous error
ep = e
!-----------------------schedule the *dac* block for output
! after a simulated compute delay
CONSTANT DelayTime = 0.0
SCHEDULE dac .AT. t + DelayTime
!-----------------------record data
CALL LOGD(.FALSE.)
END ! of adc section

DISCRETE dac
!-----------------------record data at corner before change
CALL LOGD(.FALSE.)
!-----------------------make control value available to continuous
ud = udp
!-----------------------record data at corner after change
CALL LOGD(.FALSE.)
END ! of dac section

END ! of program

Figure A11-2. Discrete sampled compensator program

Page A-92 ACSL Reference Manual


A11. Discrete Sampled Compensator A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 14-MAR-91 16:00:39 Page 1

SET TITLE='Discrete Sampled Controller'


SPARE
Accumulated cp time 32.69000. Elapsed cp time 0.
PREPARE t,u,ud,x,e,udp
OUTPUT/NCIOUT=50 t,u,x
START
T 0. U 0. X 0.
T 0. U 0. X 0.
T 0.60000000 U 0.50326300 X 0.66837700
T 1.24000000 U-0.50654800 X 1.53218000
T 1.88000000 U-0.41542200 X 1.34435000
T 2.50000000 U 0.15728100 X 0.77153900
T 3.10000000 U 0.32884700 X 0.70015700
T 3.74000000 U-0.02579170 X 1.04731000
T 4.38000000 U-0.20214400 X 1.19847000
Time Limit
T 4.92000000 U-0.06463310 X 1.05753000
SET PCWPRN=80 ! Narrow printer page
PRINT/NCIPRN=10/ALL ! Column print of all saved variables

Line T U UD X E UDP
0 0. 0. 0. 0. 1.00000000 1.00000000
10 0.10000000 1.00000000 0.97581300 0.02418710 0.97581300 0.97581300
20 0.24000000 0.90693100 0.90693100 0.13173600 0.86826400 0.90693100
30 0.38000000 0.79984000 0.79984000 0.30805200 0.69194800 0.79984000
40 0.50000000 0.66237800 0.66237800 0.49673700 0.50326300 0.50326300
50 0.60000000 0.50326300 0.33162300 0.66837700 0.33162300 0.33162300
60 0.74000000 0.15652200 0.15652200 0.91257600 0.08742450 0.15652200
70 0.88000000 -0.01346050 -0.01346050 1.14047000 -0.14047200 -0.01346050
80 1.00000000 -0.17060300 -0.17060300 1.30835000 -0.30835000 -0.30835000
90 1.10000000 -0.30835000 -0.42153900 1.42154000 -0.42153900 -0.42153900
100 1.24000000 -0.50654800 -0.50654800 1.53218000 -0.53217800 -0.50654800
110 1.38000000 -0.56135300 -0.56135300 1.58310000 -0.58309700 -0.56135300
120 1.50000000 -0.58551600 -0.58551600 1.58008000 -0.58008400 -0.58008400
130 1.60000000 -0.58008400 -0.54744100 1.54744000 -0.54744100 -0.54744100
140 1.74000000 -0.49109300 -0.49109300 1.46287000 -0.46287000 -0.49109300
150 1.88000000 -0.41542200 -0.41542200 1.34435000 -0.34434900 -0.41542200
160 2.00000000 -0.32541600 -0.32541600 1.22639000 -0.22638500 -0.22638600
170 2.10000000 -0.22638600 -0.12369100 1.12369000 -0.12369000 -0.12369100
180 2.24000000 -0.02248060 -0.02248060 0.98346600 0.01653440 -0.02248060
190 2.38000000 0.07253550 0.07253550 0.85871000 0.14129000 0.07253550
200 2.50000000 0.15728100 0.15728100 0.77153900 0.22846100 0.22846100
210 2.60000000 0.22846100 0.28366200 0.71633800 0.28366200 0.28366200
220 2.74000000 0.32140400 0.32140400 0.66852700 0.33147300 0.32140400
230 2.88000000 0.34114500 0.34114500 0.65581400 0.34418600 0.34114500
240 3.00000000 0.34323700 0.34323700 0.67115300 0.32884700 0.32884700
250 3.10000000 0.32884700 0.29984300 0.70015700 0.29984300 0.29984300
260 3.24000000 0.25865400 0.25865400 0.76061400 0.23938600 0.25865400
270 3.38000000 0.20811300 0.20811300 0.83696500 0.16303500 0.20811300
280 3.50000000 0.15129800 0.15129800 0.90863900 0.09136110 0.09136110
290 3.60000000 0.09136110 0.03137870 0.96862100 0.03137870 0.03137870
300 3.74000000 -0.02579170 -0.02579170 1.04731000 -0.04730710 -0.02579170
310 3.88000000 -0.07763200 -0.07763200 1.11383000 -0.11383200 -0.07763200
320 4.00000000 -0.12205800 -0.12205800 1.15749000 -0.15748800 -0.15748800
330 4.10000000 -0.15748800 -0.18288200 1.18288000 -0.18288200 -0.18288200
340 4.24000000 -0.19775100 -0.19775100 1.20075000 -0.20075200 -0.19775100
350 4.38000000 -0.20214400 -0.20214400 1.19847000 -0.19846800 -0.20214400
360 4.50000000 -0.19660400 -0.19660400 1.18211000 -0.18210600 -0.18210600
370 4.60000000 -0.18210600 -0.15998500 1.15998000 -0.15998400 -0.15998500
380 4.74000000 -0.13183800 -0.13183800 1.11928000 -0.11928200 -0.13183800
390 4.88000000 -0.09943870 -0.09943870 1.07171000 -0.07171230 -0.09943870

Figure A11-3. Discrete sampled compensator log file (part 1)

ACSL Reference Manual Page A-93


A. ACSL Example Programs A11. Discrete Sampled Compensator

ACSL Runtime Exec Version 6 Level 10B 14-MAR-91 16:00:39 Page 2


Discrete Sampled Controller

PLOT x,ud ! Line plot


Drawing plot number 1
SET tled=2.5,tlag=0.5 ! Five to one lead/lag ratio
SET ku=1.0 ! Reduce proportional gain
START
T 0. U 0. X 0.
T 0. U 0. X 0.
T 0.60000000 U 0.88902800 X 0.46543400
T 1.24000000 U-0.84162500 X 0.93225100
T 1.88000000 U-0.33489500 X 0.97242200
T 2.50000000 U 0.10986600 X 0.90739600
T 3.10000000 U 0.13093300 X 0.89910700
T 3.74000000 U 0.01873850 X 0.92664500
T 4.38000000 U-0.00932653 X 0.94825300
Time Limit
T 4.92000000 U 0.00200705 X 0.95680900
PRINT/ALL ! Keep same interval of every tenth point

Line T U UD X E UDP
0 0. 0. 0. 0. 1.00000000 4.26072000
10 0.10000000 4.26072000 3.56763000 0.02061090 0.97938900 3.56763000
20 0.24000000 2.84662000 2.84662000 0.10639900 0.89360100 2.84662000
30 0.38000000 2.13983000 2.13983000 0.23408200 0.76591800 2.13983000
40 0.50000000 1.47961000 1.47961000 0.35929600 0.64070400 0.88902800
50 0.60000000 0.88902800 0.38268900 0.46543400 0.53456500 0.38268900
60 0.74000000 -0.03217460 -0.03217460 0.60624200 0.39375800 -0.03217460
70 0.88000000 -0.35447400 -0.35447400 0.72892700 0.27107300 -0.35447400
80 1.00000000 -0.58800000 -0.58800000 0.81536700 0.18463200 -0.74018400
90 1.10000000 -0.74018400 -0.82093700 0.87305100 0.12694900 -0.82093700
100 1.24000000 -0.84162500 -0.84162500 0.93225100 0.06774940 -0.84162500
110 1.38000000 -0.81418000 -0.81418000 0.96850200 0.03149810 -0.81418000
120 1.50000000 -0.75038300 -0.75038300 0.98412200 0.01587750 -0.66130100
130 1.60000000 -0.66130100 -0.55689000 0.98837400 0.01162590 -0.55689000
140 1.74000000 -0.44573100 -0.44573100 0.98428400 0.01571600 -0.44573100
150 1.88000000 -0.33489500 -0.33489500 0.97242200 0.02757840 -0.33489500
160 2.00000000 -0.22991700 -0.22991700 0.95894300 0.04105670 -0.13484200
170 2.10000000 -0.13484200 -0.05234860 0.94692800 0.05307150 -0.05234860
180 2.24000000 0.01609370 0.01609370 0.93070200 0.06929800 0.01609370
190 2.38000000 0.07003930 0.07003930 0.91675000 0.08324980 0.07003930
200 2.50000000 0.10986600 0.10986600 0.90739600 0.09260420 0.13658100
210 2.60000000 0.13658100 0.15163400 0.90168300 0.09831670 0.15163400
220 2.74000000 0.15674700 0.15674700 0.89688800 0.10311200 0.15674700
230 2.88000000 0.15377600 0.15377600 0.89555300 0.10444700 0.15377600
240 3.00000000 0.14458000 0.14458000 0.89676100 0.10323800 0.13093300
250 3.10000000 0.13093300 0.11445200 0.89910700 0.10089300 0.11445200
260 3.24000000 0.09654840 0.09654840 0.90391900 0.09608100 0.09654840
270 3.38000000 0.07840290 0.07840290 0.90989200 0.09010800 0.07840290
280 3.50000000 0.06095420 0.06095420 0.91547600 0.08452410 0.04490550
290 3.60000000 0.04490550 0.03073870 0.92020500 0.07979540 0.03073870
300 3.74000000 0.01873850 0.01873850 0.92664500 0.07335470 0.01873850
310 3.88000000 0.00902000 0.00902000 0.93261100 0.06738920 0.00902000
320 4.00000000 0.00156000 0.00156000 0.93720900 0.06279060 -0.00377259
330 4.10000000 -0.00377259 -0.00718673 0.94063300 0.05936680 -0.00718673
340 4.24000000 -0.00894266 -0.00894266 0.94479300 0.05520650 -0.00894266
350 4.38000000 -0.00932653 -0.00932653 0.94825300 0.05174660 -0.00932653
360 4.50000000 -0.00863191 -0.00863191 0.95072400 0.04927580 -0.00714196
370 4.60000000 -0.00714196 -0.00511904 0.95248500 0.04751460 -0.00511904
380 4.74000000 -0.00279531 -0.00279531 0.95458100 0.04541880 -0.00279531
390 4.88000000 -3.6688E-04 -3.6688E-04 0.95634900 0.04365080 -3.6688E-04

Figure A11-3. Discrete sampled compensator log file (part 2)

Page A-94 ACSL Reference Manual


A11. Discrete Sampled Compensator A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 14-MAR-91 16:00:39 Page 3


Discrete Sampled Controller

PLOT x,ud ! Line plot


Drawing plot number 2
SET NRWITG=.T.,FTSPLT=.T.,SYMCPL=.T. ! Accumulate next run
SET delaytime=0.099, NPCCPL=50 ! Extend compute time
START
T 0. U 0. X 0.
T 0. U 0. X 0.
T 0.64000000 U 1.17811000 X 0.41961600
T 1.28000000 U-1.01981000 X 0.98924100
T 1.89900000 U-0.69416200 X 1.03943000
T 2.50000000 U 0.19284100 X 0.91137900
T 3.14000000 U 0.25626200 X 0.87461200
T 3.78000000 U 0.03929200 X 0.92314200
T 4.39900000 U-0.05678210 X 0.95873100
Time Limit
T 4.92000000 U-0.02159760 X 0.96481000
SET TITLE(41)='Effect of computation delay'
PLOT x/CHAR=1 ! Parametric plot of the two runs
Drawing plot number 3
SPARE ! List execution time
Accumulated cp time 45.45000. Elapsed cp time 12.76000
QUIT

Figure A11-3. Discrete sampled compensator log file (part 3)

SCHEDULE dac .AT. t + DelayTime

This causes the DAC block to execute at the current time T plus DELAYTIME time
units later, where the discrete control value is changed to the previously calculated
value by:
ud = udp

Figure A11-3 shows the log file of a runtime session. The first run (executed by the
START command) is followed by a column PRINT of the numeric values and a line
plot of the baseline response. Next the OUTPUT list is CLEARed and another run is
made, with an equivalent lead/lag ratio of 5:1 and a reduction of the loop gain from 5.0
to 1.0. Lastly, the response after introducing a computation delay is obtained, using the
same values of lead/lag time constants and gain, by setting the calculation time DLTC
to 0.099 sec.

ACSL Reference Manual Page A-95


A. ACSL Example Programs A11. Discrete Sampled Compensator

Figure A11-4. Discrete sampled compensator control and level, baseline case

Figure A11-5. Discrete sampled compensator, reduced loop gain, 5:1 lead/lag ratio

Figure A11-6. Discrete sampled compensator comparison using 0.1 sec computational delay

Page A-96 ACSL Reference Manual


A12. Aspirin Dosage Evaluation A. ACSL Example Programs

12. Aspirin
Dosage Evaluation

This model follows mathematically the aspirin concentration level in the blood stream
of a person taking variable doses at various preset times. A similar program could be
used to determine the concentration of any drug which has an exponential decay.
The example shows how discontinuities can be introduced into the simulation state
variables without having to recompute the values of the output of integrators, a matter
that has to be left to the integration routine. In fact, there are no true discontinuities in
the physical world and one should really consider the dynamics of the ingestion
process; i.e., the passage of the drug through the stomach wall, or, if injected, the
velocity of the hypodermic piston. These effects, however, are approximated in most
simulations as discontinuities if their time of action is short compared with the overall
period of interest.
The basic equation in the model is the exponential decay (rate of change) proportional
to the concentration (C) by the constant of proportionality (rate R) as follows:

dC
= − RC
dt

Since the concentration can change suddenly as doses are taken, a term indicating the
total dose must be added. The concentration can now be expressed as an integral
equation as follows:

C = ∫ − RC dt + Σ Di
In the program, this is written as follows:
blood = INTEG(-rate*blood, 0.0) + total

where BLOOD is the concentration in grains and TOTAL contains the sum of the doses
up until the current time.
Figure A12-1 lists the program. Two arrays are defined: DOSETIME for the time of
the dose, and DOSE for the actual dose at the corresponding time. The size of the
arrays is set with a PARAMETER statement, which allows both arrays to be
dimensioned in one place. An integer index INDEX is used to advance through the
arrays. The arrays are preset so that a large dose of five tablets (25 grains) is given
initially and the time between the first and second doses is two hours. The remaining
doses are for three tablets (15 grains) each. Four hours is the usual time between doses,
but eight hours elapses between the fourth and fifth doses. The last effective dose is at
thirty hours.
In the INITIAL section, INDEX and TOTAL are initialized; INDEX is started at one to
access the initial dose time, and TOTAL (effectively a state variable) is set to zero.
In the DERIVATIVE section, the BLOOD and URINE levels are calculated, URINE
being the total amount excreted. The URINE rate is the opposite of the rate for
BLOOD; i.e., what is removed from the bloodstream appears directly in the urine.
An IF-THEN construct determines when more aspirin is added to the total. The current
dose time TDOS(INDEX) is tested against the independent variable, time T. If it is not
yet time for a dose, the calculations are bypassed. If the dose time has been equalled or
exceeded, the dose is added to the total by the statement:

ACSL Reference Manual Page A-97


A. ACSL Example Programs A12. Aspirin Dosage Evaluation

PROGRAM aspirin dosage test

!-----------------------follows concentration of drug in body


! given a dosage history. uses exponential elimination rate
! with fixed time constant

!-----------------------define types and array dimensions


INTEGER index
PARAMETER (indexmax = 9)
DIMENSION dose(indexmax) , DoseTime(indexmax)
!-----------------------define preset constant values
CONSTANT dose = 25.0 , 15.0 , 15.0 &
, 15.0 , 15.0 , 15.0 &
, 15.0 , 15.0 , 0.0
CONSTANT DoseTime = 0.0 , 2.0 , 6.0 &
, 10.0 , 18.0 , 22.0 &
, 26.0 , 30.0 , 99.0
!-------------define communication interval and integration step
CINTERVAL cint = 0.5
MAXTERVAL maxt = 0.05
NSTEPS nstp = 1
INITIAL
!-----------------------start with first dose, none present
! at beginning
index = 1
total = 0.0
END ! of initial
DYNAMIC
DERIVATIVE
!-----------------------amount left in blood stream
CONSTANT rate = 0.14
blood = INTEG(-rate*blood, 0.0) + total
!-----------------------total amount excreted as urine
urine = INTEG( rate*blood, 0.0)
!-----------------------if time for dose
IF(t .GE. DoseTime(index)) THEN
!----------------------add new dose to total
total = total + dose(index)
!----------------------get set for next dose
index = index + 1
!----------------------and stop when given last dose
TERMT(index .GT. indexmax, 'Index Limit')
ENDIF

END ! of derivative
!-----------------------stop on time limit
CONSTANT tstop = 49.0
TERMT(t .GE. tstop, 'Time Limit')
END ! of dynamic
END ! of program

Figure A12-1. Aspirin dosage program

total = total + dose(index)

and then the index is incremented by one, ready for the next dose.

Page A-98 ACSL Reference Manual


A12. Aspirin Dosage Evaluation A. ACSL Example Programs

In writing this type of simulation model, there is an inclination to change the state
variable itself, as, for example, in the following statements:
blood = INTEG(-rate*blood, 0.0)
blood = blood + dose(index)

This operation, however, is illegal since the value in the state variable BLOOD is only
a temporary copy of the actual state variable, which is saved internally by the
integration routine. (See Chapter 4 SCHEDULE for a way to change state variables
directly.) Note that if the BLOOD integration statement is converted to the expression
form as follows:
blood = -INTEG(rate*blood, 0.0)

BLOOD is no longer a state variable, but simply the negative of the actual state
variable (the output of the INTEG operator) which is given a generated name in the
form Z0nnnn.
When TOTAL is added to the integration (as in the example model), a similar
transformation occurs so that BLOOD is no longer a state variable; but in this case,
TOTAL can be manipulated in such a way that the answer is correct.
Figure A12-2 shows the log file of a runtime session. After the START command, a
column PRINT is obtained to list numeric values. The PLOT command produces the
plot in Figures A12-3. The plot command reads as follows:
PLOT total/TAG = '+ urine', urine/SAME/OVER, blood

The tag string is used to add an extra label on the TOTAL axis, /SAME ensures
identical scales for both TOTAL and URINE, and /OVER suppresses the now
redundant axis for URINE. BLOOD is then plotted separately with its own scale.
A second run is executed with RATE changed to 0.28. The plot is shown in Figure
A12-4. Comparing the two plots you can see that the higher decay rate has reduced the
average blood level concentration.
The discontinuities introduced into TOTAL violate the restrictions on the state
variables placed by most integration algorithms; i.e., that the derivatives shall be
continuous and differentiable. In practice, fixed step size algorithms step over these
discontinuities very well with only minor differences in the calculated solutions when
the step size changes. In the code, no attempt is made to synchronize the discontinuity
with the integration step, so it can occur at any of the derivative evaluations that make
up the step. This means that the particular step containing the discontinuity will be in
error, but the answers will be slipped only a fraction of a step length. It is this
requirement that dictates the integration step size. From the decay rate of the aspirin
(0.14 or 0.28), step sizes of two or three hours would do quite well in integrating the
differential equations. However, uncertainty in dose times of this much is too large an
error. In the model, the step size is set (via MAXT) to 0.05 hr (3 minutes) to reduce the
uncertainty, which now seems tolerable in light of what is being simulated.
If a finer time scale is required, the SCHEDULE operator can be used to determine the
time of each event exactly; then much larger steps can be used in integrating the
continuous part of the model. For example, the following statement would find the
events more accurately:
SCHEDULE .XP. t - dosetime(index)

In this method, T is adjusted so that it just crosses the threshold set up in the dose time
table. This approach saves computer time but requires a somewhat more complex
program.

ACSL Reference Manual Page A-99


A. ACSL Example Programs A12. Aspirin Dosage Evaluation

ACSL Runtime Exec Version 6 Level 10B 16-MAR-91 18:10:30 Page 1

SET TITLE = 'Aspirin Dosage Test'


SPARE
Accumulated cp time 19.19000. Elapsed cp time 0.
S TCWPRN=72 ! Force 3 column output width
PREPARE t, blood, urine, total, index
START
Time Limit
PRINT/NCIPRN=5/ALL

Line T BLOOD URINE TOTAL INDEX


0 0. 25.0000000 0. 25.0000000 2
5 2.50000000 31.6031000 8.39689000 40.0000000 3
10 5.00000000 22.2703000 17.7297000 40.0000000 3
15 7.50000000 27.8382000 27.1618000 55.0000000 4
20 10.0000000 34.5998000 35.4002000 70.0000000 5
25 12.5000000 24.3820000 45.6180000 70.0000000 5
30 15.0000000 17.1817000 52.8183000 70.0000000 5
35 17.5000000 12.1078000 57.8922000 70.0000000 5
40 20.0000000 19.8689000 65.1310000 85.0000000 6
45 22.5000000 27.9873000 72.0127000 100.000000 7
50 25.0000000 19.7223000 80.2777000 100.000000 7
55 27.5000000 26.0569000 88.9431000 115.000000 8
60 30.0000000 33.3620000 96.6380000 130.000000 9
65 32.5000000 23.5098000 106.490000 130.000000 9
70 35.0000000 16.5671000 113.433000 130.000000 9
75 37.5000000 11.6746000 118.325000 130.000000 9
80 40.0000000 8.22696000 121.773000 130.000000 9
85 42.5000000 5.79744000 124.203000 130.000000 9
90 45.0000000 4.08539000 125.915000 130.000000 9
95 47.5000000 2.87892000 127.121000 130.000000 9
PLOT total/TAG='+ urine', urine/SAME/OVER, blood
Drawing plot number 1
DISPLAY rate, dosetime, dose
RATE 0.14000000 DOSETIME 0. 2.00000000
6.00000000 10.0000000 18.0000000
22.0000000 26.0000000 30.0000000
99.0000000 DOSE 25.0000000 15.0000000
15.0000000 15.0000000 15.0000000
15.0000000 15.0000000 15.0000000
0.
SET rate=0.28, TITLE(41)='Rate = 0.28'
START
Time Limit
PLOT total, urine/SAME, blood
Drawing plot number 2
DISPLAY rate, dosetime, dose
RATE 0.28000000 DOSETIME 0. 2.00000000
6.00000000 10.0000000 18.0000000
22.0000000 26.0000000 30.0000000
99.0000000 DOSE 25.0000000 15.0000000
15.0000000 15.0000000 15.0000000
15.0000000 15.0000000 15.0000000
0.
SPARE ! List execution time
Accumulated cp time 24.93000. Elapsed cp time 5.740000
QUIT

Figure A12-2. Aspirin dosage log file

Page A-100 ACSL Reference Manual


A12. Aspirin Dosage Evaluation A. ACSL Example Programs

Figure A12-3. Aspirin dosage plots for RATE = 0.14

Figure A12-4. Aspirin dosage plots for RATE = 0.28

ACSL Reference Manual Page A-101


A. ACSL Example Programs A13. Block on a Rough Surface

13. Block on a
Rough Surface

This example demonstrates use of the SCHEDULE statement to find a series of state
events.
The model is a mass (or block) resting on a rough surface, attached by a spring to a
point that can be moved, thus applying a force to the block via the compression or
extension of the spring. Figure A13-1 is a diagram showing the positive directions.
The deflection of the mass is XB and the forcing function is the deflection of the end of
the spring XF. Units are kilogram, meter, and second for mass, length, and time,
respectively.
A sinusoidal forcing function exercises the model. The block is assumed to start at
rest. Motion begins only when the deflection of the spring applies a force equal to the
Coulomb friction breakout force. At this point, the block starts to move and accelerate.
Eventually the driving point reverses velocity due to the sine wave motion now
extending the spring and causing the block to decelerate. When the block velocity
across the table crosses zero, friction grabs the block until the spring has been
extended enough to again exceed the breakout force in the other direction. The process
repeats, the block alternately sticking and unsticking at each half cycle of the forcing
sine wave.
This limit cycle is observed many times in practice when friction surfaces slow
moving bodies. This configuration has been used to study the juddering (stick-slide)
that occurs as an airplane comes to a stop. In this case, the undercarriage is the spring
and the brake lining is the rough surface. At some critical velocity, the brake shoe
starts to stick and unstick, which can cause significant vibration.
It is possible to choose parameters for the spring constant, amplitude, mass, and
friction level so that the block never moves or never stops once started. For this
example, however, a middle path with sticking and unsticking is chosen.

Figure A13-1. Diagram of block on a rough surface

Page A-102 ACSL Reference Manual


A13. Block on a Rough Surface A. ACSL Example Programs

Figure A13-2 lists the program. The forcing function deflection of the spring is given
by the equation:
xf = xfa*SIN(2*pi*freqf*t)

where XFA is the amplitude of the deflection (nominally 0.05 m) and FREQF is the
frequency of the oscillation (nominally 0.4 Hz).
The sum of the forces acting on the block (excluding Coulomb friction) results from
spring deflection and viscous damping as follows:
sumfb = ksp*(xf - xb) + kbvd*xbd

The force due to Coulomb friction depends on whether the block is sliding or not.
When the block is stuck, the Coulomb friction force exactly cancels all the other
forces; when the block is sliding, the Coulomb friction force has a constant value
equal to the sliding friction value (a little less than the breakout force) in a direction
opposite to that of the velocity. The force on the block due to Coulomb friction can be
expressed as follows:
fbcf = RSW(stukb, -sumfb, fbsf)

where FBSF is the constant sliding friction force; at breakout time, FBSF is given the
correct sign to oppose the direction of the block velocity. RSW (real switch) is a
function which returns the second argument if the first argument is TRUE; otherwise,
it returns the third argument.
The acceleration of the block is the sum of all the forces (including Coulomb friction)
divided by the mass; i.e,
xbdd = (sumfb + fbcf)/mb

and the velocity and position are successive integrals of this acceleration.
A zero crossing function to define the events of unsticking and sticking is required.
When the block is stuck, the force applied to it must exceed a breakout value before
the block starts to move. When the block is sliding, it must be tested for sticking when
the velocity crosses zero; i.e., if the force acting on the body is less than the breakout
force required to drag the velocity through zero, the block sticks. A function FIB is
defined as follows:
fib = RSW(stukb, ABS(sumfb) - kbbf, xbd)

This function is then specified to the zero crossing finder as a state event as follows:
SCHEDULE stick .XZ. fib

This statement schedules the execution of the DISCRETE section STICK immediately
after the zero crossing. The logical STUKB is determined in this DISCRETE section is
as follows:
stukb = .NOT.stukb .AND. ABS(sumfb) .LT. kbbf

The first part of the statement (STUKB=.NOT.STUKB) acts as a toggle; i.e., when
STUKB is FALSE, it becomes TRUE; if TRUE, it becomes FALSE. The second
clause ensures that if the sum of the forces exceeds the breakout force, the expression
is FALSE, thus ensuring that STUKB is also FALSE.
The sliding friction either opposes the applied force (if the block is now unstuck) or it
is zero (if the block is stuck):
fbsf = RSW(stukb, 0.0, SIGN(kbsf, -sumfb))

ACSL Reference Manual Page A-103


A. ACSL Example Programs A13. Block on a Rough Surface

PROGRAM - friction test

!-----------------------models a block sliding on a rough


! surface under the action of a force applied through a
! spring. the spring force must exceed a breakout coulomb
! friction force in order to start to move. once it starts
! to move the frictional force has a value equal to the
! sliding friction in a direction opposing the motion

!-----------------------define simulation environment


CINTERVAL cint = 0.020
ALGORITHM ialg = 4
MAXTERVAL maxt = 0.050
MINTERVAL mint = 1.0e-6
NSTEPS nstp = 1
!-----------------------define global constants
PARAMETER (pi = 3.14159 )

INITIAL

!-----------------------give the states the initial cond values


RESET("NOEVAL")

END ! of initial

DERIVATIVE
!-----------------------forcing function is displacement of
! free end of spring attached to body
CONSTANT xfa = 0.05 , freqf = 0.40
xf = xfa*SIN(2.0*pi*freqf*t)
!-----------------------sum of forces on body excluding friction
CONSTANT ksp = 100.0 , kbvd = -0.50
sumfb = ksp*(xf - xb) + kbvd*xbd
!-----------------------force due to coulomb friction exactly
! cancels other forces when stuck
fbcf = RSW(stukb, -sumfb, fbsf)
!-----------------------acceleration of body
CONSTANT mb = 1.0
xbdd = (sumfb + fbcf)/mb
!-----------------------integrate for velocity and position
xbd = INTVC(xbdd, xbdic) ; CONSTANT xbdic = 0.0
xb = INTEG(xbd, xbic) ; CONSTANT xbic = 0.0
!-----------------------define *phi* function for stick/unstick
fib = RSW(stukb, ABS(sumfb) - kbbf, xbd)
!-----------------------schedule the execution of the discrete
! block *stick* on a zero crossing
SCHEDULE stick .XZ. fib
!-----------------------specify termination condition
TERMT(t .GE. tstp, 'Time Limit') ; CONSTANT tstp = 4.99

END ! of derivative

Figure A13-2. Block on a rough surface program (part 1)

The sliding friction value has been calculated in the DISCRETE section deliberately
so that the value is continuous (actually constant) within the continuous
DERIVATIVE section. An alternate way of describing the situation, and the first
method tried in this case, was to define the Coulomb force FBCF by the statement:
fbcf = RSW(stukb, -sumfb, SIGN(kbsf, -xbd))

Page A-104 ACSL Reference Manual


A13. Block on a Rough Surface A. ACSL Example Programs

DISCRETE stick

!-----------------------handle coulomb friction

!-----------------------initialise stuck flags


INITIAL
LOGICAL stukb
stukb = xbd .EQ. 0.0
END ! of initial
!-----------------------stuck flag toggles unless force exceeds
! breakout force on crossing zero
CONSTANT kbbf = 2.50
stukb = .NOT.stukb .AND. ABS(sumfb) .LT. kbbf
!-----------------------sliding friction opposes applied force
CONSTANT kbsf = 2.00
fbsf = RSW(stukb, 0.0, SIGN(kbsf, -sumfb))
!-----------------------reset velocity to exactly zero. you must
! know *xbd* is a state variable for this
xbd = 0.0
!-----------------------record status
CALL LOGD(.TRUE.)
!-----------------------define debug dump flag and condition
LOGICAL dump ; CONSTANT dump = .FALSE.
IF(DUMP) CALL DEBUG

END ! of discrete

END ! of program

Figure A13-2. Block on a rough surface program (part 2)

In this situation, when the block is sliding (STUKB=.FALSE.), the Coulomb force
reverses sign discontinuously in response to the sign of velocity XBD. This
discontinuity affects the accuracy of the integration step when the velocity just crosses
zero. It is better to keep the model continuous even though the Coulomb friction
appears to increase the velocity on the far side; this is an unrealistic condition, but one
which occurs only for the single integration step that just crosses the velocity equal
zero surface. The event finder penetrates the event an insignificant amount and then
applies the discontinuity in the DISCRETE section that handles the event.
The next step in the program (an important one) adjusts the velocity so that it is
exactly zero when the block unsticks. When the block is about to stick, the zero
crossing used is the velocity, and this must cross to a small nonzero value (about
1.0E-7 in this case). If on unsticking and reverting to velocity crossing control the
block continues with the same sign of acceleration, the velocity increases and
presumably sometime in the future returns to zero. However, if during the period of
sticking, the acceleration changes sign and the velocity tries to return back though
zero, another event-finding sequence is triggered and the event is handled when the
velocity is just slightly on the other side of zero. The applied force presumably still
exceeds the breakout force, keeping the body unstuck, but there is an overhead to the
zero-finding operation.
The solution to avoiding extraneous zero finding operations is to set the velocity
exactly to zero. Since an exact zero is neutral as far as the zero crossing finder is
concerned, the velocity must integrate away from zero and then return. The direction
of the acceleration at the point of unsticking is then of no concern.

ACSL Reference Manual Page A-105


A. ACSL Example Programs A13. Block on a Rough Surface

Setting the velocity to exactly zero is possible only because it is known to be a state
variable. This is the one situation in which state variables can be changed
discontinuously. At a state event, all state variable values are retrieved from internal
tables maintained by the integration algorithms, stored in the appropriate slot
accessible to the model code, and then the DISCRETE sections designated as handlers
for the event(s) are executed in turn. After all the handler sections have been executed,
the states are then stored away and are ready for the next integration step.
Initializing the model is handled by a RESET statement in the INITIAL section at the
beginning of the program plus an INITIAL region embedded in the DISCRETE
section. The code embedded in the DISCRETE section establishes the stuck/unstuck
condition depending on whether the velocity is zero or not. (This code is moved by the
translator to the end of the explicit INITIAL section before evaluation.) To determine
the value of the velocity XBD (a state), we invoke the RESET operator, which moves
all the initial condition values into the state vector. (The argument "NOEVAL"
indicates that no evaluation of the derivatives is requested.) The states can then be
referenced by name.
The transfer of initial conditions to states normally takes place only on leaving the
INITIAL section. If the RESET operator had not been used, the code in the INITIAL
section would have had to refer to the initial condition name XBDIC rather than the
state name XBD.
The DISCRETE section ends with a call to LOGD and an optional DEBUG dump.
The call to LOGD forces OUTPUT so you can see what is occurring during the run,
and it also saves the PREPARE list variables so that any subsequent plots follow the
sharp corners produced by the discontinuities.
Figure A13-3 shows the log file of a runtime session. PREPARE and OUTPUT lists
are defined, then a START command begins the simulation. Integrations proceed with
the block stuck until 0.22 seconds, at which time the event is activated with a value of
0.12587100; i.e., the spring force has exceeded the breakout force (KBBF = 2.50
Newtons) by this amount. The event finder backs up to 0.2 seconds and a value of
-0.09123350, showing that a zero crossing has really occurred. The window is now
quickly narrowed until it is below the threshold of MINT (1.0E-6 in this program) of
the current time, at which point the event is noted as having occurred at 0.20833400
seconds, which is the most positive edge of the window.
The block continues to slide (STUKB=.FALSE.) until the event is next activated at
0.64 seconds with a negative value of -0.01860610. Since STUKB is FALSE, the
event is now defined by velocity crossing zero. The velocity has increased to a positive
peak of just over 0.17 m/sec (as shown in the column PRINT output on page 6 of the
log file) and then decreased until, at the 0.64 second point, the value is negative and
the event finder is again activated. As before, the integration system backs up to 0.62
seconds and in four iterations establishes 0.62794300 seconds as the event time and
-7.2364E-7 (m/sec), just below zero, as the event value.
This sequence continues, with the block alternately sliding and sticking, until the
stopping time of 4.99 seconds is exceeded. The message Time Limit, generated by the
optional second argument in the TERMT statement, confirms that the run terminated
as expected on the stopping time.
The event description output is fairly extensive and so is considered to be high
volume. It is sent to the PRN logical unit but does not appear on the DIS (low volume)
unit, which is usually a terminal. To display the high volume output at a terminal, set
HVDPRN (high volume display) to TRUE. If you would like to suppress all event
description information, set WEDITG (write event descriptor) to FALSE.

Page A-106 ACSL Reference Manual


A13. Block on a Rough Surface A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 1

S TITLE='Spring Forced Body Sliding with Friction'


SPARE
Accumulated cp time 84.91000. Elapsed cp time 0.
SET TCWPRN=72,PCWPRN=80 ! Force narrow output width
PREPARE t,xf,xb,xbd,xbdd,sumfb,fbcf,fib,stukb
OUTPUT/NCIOUT=10 t,xf,xb,stukb
START
T 0. XF 0. XB 0.
STUKB T

T 0.20000000 XF 0.02408770 XB 0.
STUKB T

Event number 1 activated at 0.22000000 with value 0.12587100

Event number 1
Window between -1.0000E+37 and 0.22000000
Currently at 0.20000000 with value -0.09123350

Event number 1
Window between 0.20000000 and 0.22000000
Currently at 0.20840500 with value 7.7343E-04

Event number 1
Window between 0.20000000 and 0.20840500
Currently at 0.20833400 with value 4.5300E-06

Event number 1
Window between 0.20000000 and 0.20833400
Currently at 0.20833300 with value -1.1921E-06

Event number 1
Window between 0.20833400 and 0.20833400
Currently at 0.20833400 with value 4.5300E-06
Event occurred at 0.20833400
Event 1 with expression value 4.5300E-06 serviced with block 2
T 0.20833400 XF 0.02500000 XB 0.
STUKB F

T 0.40000000 XF 0.04221640 XB 0.01608330


STUKB F

T 0.60000000 XF 0.04990130 XB 0.04473480


STUKB F

Event number 1 activated at 0.64000000 with value -0.01860610

Event number 1
Window between -1.0000E+37 and 0.64000000
Currently at 0.62000000 with value 0.01220850

Event number 1
Window between 0.62000000 and 0.64000000
Currently at 0.62792400 with value 2.8173E-05

Event number 1
Window between 0.62792400 and 0.64000000
Currently at 0.62794200 with value 1.0245E-08

Event number 1
Window between 0.62794200 and 0.64000000
Currently at 0.62794300 with value -7.2364E-07

Figure A13-3. Block on rough surface log file (part 1)

ACSL Reference Manual Page A-107


A. ACSL Example Programs A13. Block on a Rough Surface

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 2


Spring Forced Body Sliding with Friction

Event number 1
Window between 0.62794200 and 0.62794200
Currently at 0.62794300 with value -7.2364E-07

Event occurred at 0.62794300


Event 1 with expression value-7.2364E-07 serviced with block 2
T 0.62794300 XF 0.04999860 XB 0.04534030
STUKB T

T 0.82000000 XF 0.04411460 XB 0.04534030


STUKB T

T 1.02000000 XF 0.02731980 XB 0.04534030


STUKB T

Event number 1 activated at 1.10000000 with value 0.19339600

Event number 1
Window between -1.0000E+37 and 1.10000000
Currently at 1.08000000 with value -0.03785850

Event number 1
Window between 1.08000000 and 1.10000000
Currently at 1.08327000 with value -3.4261E-04

Event number 1
Window between 1.08327000 and 1.10000000
Currently at 1.08330000 with value -7.1526E-07

Event number 1
Window between 1.08330000 and 1.10000000
Currently at 1.08330000 with value 6.9141E-06

Event number 1
Window between 1.08330000 and 1.08330000
Currently at 1.08330000 with value 6.9141E-06
Event occurred at 1.08330000
Event 1 with expression value 6.9141E-06 serviced with block 2
T 1.08330000 XF 0.02034020 XB 0.04534030
STUKB F

T 1.28000000 XF-0.00376620 XB 0.02627380


STUKB F

T 1.48000000 XF-0.02731960 XB-0.01868640


STUKB F

Event number 1 activated at 1.62000000 with value 0.00856440


Event number 1
Window between -1.0000E+37 and 1.62000000
Currently at 1.60000000 with value -0.01092700

Event number 1
Window between 1.60000000 and 1.62000000
Currently at 1.61121000 with value 3.5397E-04

Event number 1
Window between 1.60000000 and 1.61121000
Currently at 1.61085000 with value -7.4878E-07

Figure A13-3. Block on rough surface log file (part 2)

Page A-108 ACSL Reference Manual


A13. Block on a Rough Surface A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 3


Spring Forced Body Sliding with Friction

Event number 1
Window between 1.61085000 and 1.61121000
Currently at 1.61085000 with value 5.7742E-08

Event number 1
Window between 1.61085000 and 1.61085000
Currently at 1.61085000 with value 5.7742E-08
Event occurred at 1.61085000
Event 1 with expression value 5.7742E-08 serviced with block 2
T 1.61085000 XF-0.03937990 XB-0.02900120
STUKB T

T 1.80000000 XF-0.04911430 XB-0.02900120


STUKB T

T 2.00000000 XF-0.04755290 XB-0.02900120


STUKB T

T 2.20000000 XF-0.03422750 XB-0.02900120


STUKB T

T 2.40000000 XF-0.01243470 XB-0.02900120


STUKB T

Event number 1 activated at 2.48000000 with value 0.14887300

Event number 1
Window between -1.0000E+37 and 2.48000000
Currently at 2.46000000 with value -0.10171200

Event number 1
Window between 2.46000000 and 2.48000000
Currently at 2.46812000 with value -1.1802E-04

Event number 1
Window between 2.46812000 and 2.48000000
Currently at 2.46813000 with value 3.0994E-06

Event number 1
Window between 2.46812000 and 2.46813000
Currently at 2.46813000 with value -1.3590E-05

Event number 1
Window between 2.46813000 and 2.46813000
Currently at 2.46813000 with value 3.0994E-06
Event occurred at 2.46813000
Event 1 with expression value 3.0994E-06 serviced with block 2
T 2.46813000 XF-0.00400121 XB-0.02900120
STUKB F

T 2.66000000 XF 0.01956840 XB-0.01044060


STUKB F

T 2.86000000 XF 0.03931420 XB 0.03281440


STUKB F

Figure A13-3. Block on rough surface log file (part 3)

ACSL Reference Manual Page A-109


A. ACSL Example Programs A13. Block on a Rough Surface

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 4


Spring Forced Body Sliding with Friction

Event number 1 activated at 2.96000000 with value -0.00971345

Event number 1
Window between -1.0000E+37 and 2.96000000
Currently at 2.94000000 with value 0.01862030

Event number 1
Window between 2.94000000 and 2.96000000
Currently at 2.95314000 with value -1.8871E-04

Event number 1
Window between 2.94000000 and 2.95314000
Currently at 2.95301000 with value 1.8626E-09

Event number 1
Window between 2.95301000 and 2.95314000
Currently at 2.95301000 with value -2.0117E-06

Event number 1
Window between 2.95301000 and 2.95301000
Currently at 2.95301000 with value -2.0117E-06
Event occurred at 2.95301000
Event 1 with expression value-2.0117E-06 serviced with block 2
T 2.95301000 XF 0.04540100 XB 0.03931570
STUKB T

T 3.14000000 XF 0.04996450 XB 0.03931570


STUKB T

T 3.34000000 XF 0.04287650 XB 0.03931570


STUKB T

T 3.54000000 XF 0.02518150 XB 0.03931570


STUKB T

Event number 1 activated at 3.64000000 with value 0.06677440

Event number 1
Window between -1.0000E+37 and 3.64000000
Currently at 3.62000000 with value -0.17318300
Event number 1
Window between 3.62000000 and 3.64000000
Currently at 3.63443000 with value -3.7169E-04

Event number 1
Window between 3.63443000 and 3.64000000
Currently at 3.63447000 with value -1.6689E-06

Event number 1
Window between 3.63447000 and 3.64000000
Currently at 3.63447000 with value 2.1219E-05

Event number 1
Window between 3.63447000 and 3.63447000
Currently at 3.63447000 with value 2.1219E-05
Event occurred at 3.63447000
Event 1 with expression value 2.1219E-05 serviced with block 2

Figure A13-3. Block on rough surface log file (part 4)

Page A-110 ACSL Reference Manual


A13. Block on a Rough Surface A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 5


Spring Forced Body Sliding with Friction

T 3.63447000 XF 0.01431550 XB 0.03931570


STUKB F

T 3.82000000 XF-0.00875077 XB 0.02219980


STUKB F

T 4.02000000 XF-0.03138420 XB-0.02306740


STUKB F

Event number 1 activated at 4.16000000 with value 0.01793890

Event number 1
Window between -1.0000E+37 and 4.16000000
Currently at 4.14000000 with value -0.00445883

Event number 1
Window between 4.14000000 and 4.16000000
Currently at 4.14398000 with value 2.2127E-04

Event number 1
Window between 4.14000000 and 4.14398000
Currently at 4.14379000 with value 2.4103E-06

Event number 1
Window between 4.14000000 and 4.14379000
Currently at 4.14379000 with value 1.8906E-07

Event number 1
Window between 4.14000000 and 4.14379000
Currently at 4.14379000 with value -2.0224E-06

Event number 1
Window between 4.14379000 and 4.14379000
Currently at 4.14379000 with value 1.8906E-07
Event occurred at 4.14379000
Event 1 with expression value 1.8906E-07 serviced with block 2
T 4.14379000 XF-0.04179300 XB-0.03341160
STUKB T

T 4.34000000 XF-0.04980660 XB-0.03341160


STUKB T

T 4.54000000 XF-0.04576230 XB-0.03341160


STUKB T

T 4.74000000 XF-0.03039690 XB-0.03341160


STUKB T

Event number 1 activated at 4.94000000 with value 0.08997040

Event number 1
Window between -1.0000E+37 and 4.94000000
Currently at 4.92000000 with value -0.15745000

Event number 1
Window between 4.92000000 and 4.94000000
Currently at 4.93273000 with value -2.5225E-04

Figure A13-3. Block on rough surface log file (part 5)

ACSL Reference Manual Page A-111


A. ACSL Example Programs A13. Block on a Rough Surface

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 6


Spring Forced Body Sliding with Friction

Event number 1
Window between 4.93273000 and 4.94000000
Currently at 4.93275000 with value 1.4305E-06

Event number 1
Window between 4.93273000 and 4.93275000
Currently at 4.93274000 with value -2.6703E-05

Event number 1
Window between 4.93275000 and 4.93275000
Currently at 4.93275000 with value 1.4305E-06
Event occurred at 4.93275000
Event 1 with expression value 1.4305E-06 serviced with block 2
T 4.93275000 XF-0.00841154 XB-0.03341160
STUKB F

Time Limit
T 5.00000000 XF-5.0704E-07 XB-0.03175430
STUKB F

PRINT/NCIPRN=5/ALL

Line T XF XB XBD XBDD SUMFB


0 0. 0. 0. 0. 0. 0.
5 0.10000000 0.01243450 0. 0. 0. 1.24345000
10 0.20000000 0.02408770 0. 0. 0. 2.40877000
15 0.28000000 0.03235280 0.00181926 0.05813630 1.02428000 3.02428000
20 0.38000000 0.04081690 0.01281130 0.15637500 0.72237900 2.72238000
25 0.48000000 0.04671640 0.03037580 0.17337400 -0.45262700 1.54737000
30 0.58000000 0.04968060 0.04357050 0.07246580 -1.42523000 0.57476800
35 0.66000000 0.04980670 0.04534030 0. 0. 0.44663800
40 0.76000000 0.04714960 0.04534030 0. 0. 0.18092500
45 0.86000000 0.04152980 0.04534030 0. 0. -0.38104600
50 0.96000000 0.03330070 0.04534030 0. 0. -1.20396000
55 1.06000000 0.02297910 0.04534030 0. 0. -2.23612000
60 1.14000000 0.01364770 0.04424790 -0.04495110 -1.03755000 -3.03755000
65 1.24000000 0.00125665 0.03382300 -0.16630400 -1.17348000 -3.17348000
70 1.34000000 -0.01121340 0.01244810 -0.24428100 -0.24400900 -2.24401000
75 1.44000000 -0.02297890 -0.01120710 -0.20725900 0.92645800 -1.07354000
80 1.54000000 -0.03330050 -0.02617820 -0.08453230 1.33004000 -0.66995700
85 1.62000000 -0.04007820 -0.02900120 0. 0. -1.10770000
90 1.72000000 -0.04625380 -0.02900120 0. 0. -1.72526000
95 1.82000000 -0.04952300 -0.02900120 0. 0. -2.05218000
100 1.92000000 -0.04968060 -0.02900120 0. 0. -2.06793000
105 2.02000000 -0.04671650 -0.02900120 0. 0. -1.77153000
110 2.12000000 -0.04081710 -0.02900120 0. 0. -1.18159000
115 2.22000000 -0.03235300 -0.02900120 0. 0. -0.33517500
120 2.32000000 -0.02185600 -0.02900120 0. 0. 0.71452100
125 2.42000000 -0.00998576 -0.02900120 0. 0. 1.90155000
130 2.50000000 -2.5352E-07 -0.02870160 0.02195290 0.85915500 2.85915000
135 2.60000000 0.01243420 -0.02100150 0.13992400 1.27361000 3.27361000
140 2.70000000 0.02408740 -0.00149632 0.23508400 0.44083100 2.44083000
145 2.80000000 0.03422710 0.02206160 0.21160400 -0.88924700 1.11075000
150 2.90000000 0.04221620 0.03724060 0.07974090 -1.54231000 0.45769100
155 2.98000000 0.04671630 0.03931570 0. 0. 0.74006100
160 3.08000000 0.04968050 0.03931570 0. 0. 1.03648000
165 3.18000000 0.04952310 0.03931570 0. 0. 1.02074000
170 3.28000000 0.04625400 0.03931570 0. 0. 0.69382800
175 3.38000000 0.04007860 0.03931570 0. 0. 0.07628540

Figure A13-3. Block on rough surface log file (part 6)

Page A-112 ACSL Reference Manual


A13. Block on a Rough Surface A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 7


Spring Forced Body Sliding with Friction

Line T XF XB XBD XBDD SUMFB


180 3.48000000 0.03138490 0.03931570 0. 0. -0.79308600
185 3.58000000 0.02071920 0.03931570 0. 0. -1.85966000
190 3.66000000 0.01121390 0.03913620 -0.01655160 -0.78395700 -2.78396000
195 3.76000000 -0.00125610 0.03226010 -0.13045200 -1.28639000 -3.28639000
200 3.86000000 -0.01364720 0.01341340 -0.23388900 -0.58911900 -2.58912000
205 3.96000000 -0.02518080 -0.01090990 -0.22912500 0.68747100 -1.31253000
210 4.06000000 -0.03513220 -0.02877580 -0.11450300 1.42162000 -0.57838300
215 4.14379000 -0.04179300 -0.03341160 0. 1.16186000 -0.83814200
220 4.24000000 -0.04714940 -0.03341160 0. 0. -1.37378000
225 4.34000000 -0.04980660 -0.03341160 0. 0. -1.63951000
230 4.44000000 -0.04933440 -0.03341160 0. 0. -1.59228000
235 4.54000000 -0.04576230 -0.03341160 0. 0. -1.23507000
240 4.64000000 -0.03931480 -0.03341160 0. 0. -0.59032000
245 4.74000000 -0.03039690 -0.03341160 0. 0. 0.30146100
250 4.84000000 -0.01956920 -0.03341160 0. 0. 1.38424000
255 4.93275000 -0.00841154 -0.03341160 0. 0. 2.50000000

Line FBCF FIB STUKB


0 0. -2.50000000 T
5 -1.24345000 -1.25655000 T
10 -2.40877000 -0.09123350 T
15 -2.00000000 0.05813630 F
20 -2.00000000 0.15637500 F
25 -2.00000000 0.17337400 F
30 -2.00000000 0.07246580 F
35 -0.44663800 -2.05336000 T
40 -0.18092500 -2.31908000 T
45 0.38104600 -2.11895000 T
50 1.20396000 -1.29604000 T
55 2.23612000 -0.26387900 T
60 2.00000000 -0.04495110 F
65 2.00000000 -0.16630400 F
70 2.00000000 -0.24428100 F
75 2.00000000 -0.20725900 F
80 2.00000000 -0.08453230 F
85 1.10770000 -1.39230000 T
90 1.72526000 -0.77474500 T
95 2.05218000 -0.44782000 T
100 2.06793000 -0.43206600 T
105 1.77153000 -0.72847200 T
110 1.18159000 -1.31841000 T
115 0.33517500 -2.16482000 T
120 -0.71452100 -1.78548000 T
125 -1.90155000 -0.59845200 T
130 -2.00000000 0.02195290 F
135 -2.00000000 0.13992400 F
140 -2.00000000 0.23508400 F
145 -2.00000000 0.21160400 F
150 -2.00000000 0.07974090 F
155 -0.74006100 -1.75994000 T
160 -1.03648000 -1.46352000 T
165 -1.02074000 -1.47926000 T
170 -0.69382800 -1.80617000 T
175 -0.07628540 -2.42371000 T
180 0.79308600 -1.70691000 T
185 1.85966000 -0.64034400 T
190 2.00000000 -0.01655160 F
195 2.00000000 -0.13045200 F
200 2.00000000 -0.23388900 F

Figure A13-3. Block on rough surface log file (part 7)

ACSL Reference Manual Page A-113


A. ACSL Example Programs A13. Block on a Rough Surface

ACSL Runtime Exec Version 6 Level 10B 17-MAR-91 07:15:53 Page 8


Spring Forced Body Sliding with Friction

Line FBCF FIB STUKB


205 2.00000000 -0.22912500 F
210 2.00000000 -0.11450300 F
215 2.00000000 1.8906E-07 T
220 1.37378000 -1.12622000 T
225 1.63951000 -0.86049200 T
230 1.59228000 -0.90771700 T
235 1.23507000 -1.26493000 T
240 0.59032000 -1.90968000 T
245 -0.30146100 -2.19854000 T
250 -1.38424000 -1.11576000 T
255 -2.50000000 1.4305E-06 F
S STRPLT=.T.,CALPLT=.F.
S PSFSPL=0.5,XINSPL=10
PLOT/XTAG='(sec)'
Drawing plot number 1
PLOT fib,xb,xbd,xbdd,fbcf
Drawing plot number 2
S CALPLT=.T.,STRPLT=.F.,PSFCPL=0.60
PLOT xb/TAG='body position (m)' &
, xf/TAG='forcing deflection (m)'/TYPE=100
Drawing plot number 3
SET TITLE(41)='events occur at zero crossings'
PLOT fib/TAG='- phi function'/TYPE=00/CHAR='*' Drawing plot number 4
SPARE
Accumulated cp time 96.26000. Elapsed cp time 11.35000
QUIT

Figure A13-3. Block on rough surface log file (part 8)

Data is printed at the end of the run by PRINT/ALL. The volume of output is reduced
by printing only every fifth line that was logged (/NCIPRN=5). Note that the first
three lines occur at times 0.0, 0.1, and 0.2, but the fourth line is at 0.28 because of the
extra data point logged at the event time around 0.208 seconds. The output reduction
factor is applied to every data record on the PREPARE list that is saved, irrespective
of the means by which it is placed on the file. In this case, each record is read and
every fifth one printed. Another shift is seen between lines 30 and 35 where time T is
0.58 and 0.66 seconds, respectively. Occasionally the round values of T are replaced
by all digits as at line 215 where the output line happens to coincide with a LOGD call
at the event time.
The PRINT output includes the logical variable STUKB, which alternates between
TRUE (T) and FALSE (F).
Figure A13-4 shows several variables in strip plot form. The first line is the force due
to Coulomb friction, and the discontinuities can be clearly seen where the breakout
force (KBBF=2.5 Newtons) jumps to the sliding force (KBSF=2.0 Newtons).
Figure A13-5 shows the block position XB and the forcing deflection XF against time
in a line plot (CALPLT=.TRUE.). Figure A13-6 shows the zero crossing function FIB.
When this function crosses or touches the zero line, an event occurs. The sharp
discontinuities in slope in the lower part of the curve are due to the action of the
absolute value operator as the friction force reverses sign. The smooth curves between
zero crossings are velocity, so the units of FIB change from Newtons to m/sec at
different regions in state space.

Page A-114 ACSL Reference Manual


A13. Block on a Rough Surface A. ACSL Example Programs

Figure A13-4. Block on rough surface, selected variables

Figure A13-5. Block and spring deflection Figure A13-6. Zero crossing function

ACSL Reference Manual Page A-115


A. ACSL Example Programs A14. Linear analysis example

14. Linear
analysis example

The linear analysis operations are applied to a system made up from a third order plant
with a compensator as shown in the block diagram in Figure A14-1. This example is
taken from Truxal's Control System Synthesis pp. 259-266[7]. It shows how to add
control inputs and obtain both open loop and closed loop frequency responses,
including Bode and root locus plots. The ACSL program is listed in Figure A14-2.
As the block diagram shows, the feedback path is completed through an unknown gain
K and added constant terms EZ and UZ in the forward path. These terms are initialized
to zero but used as control inputs in addition to the reference R so that the open loop
response can be determined for either the complete system, the plant alone, or the
compensator alone by selecting the appropriate input/output pair and changing the
gain K. For instance, the open loop transfer function over the complete controller/plant
cascaded system is from EZ to Y with the gain K set to zero. The plant alone is from
UZ to Y with K also set to zero. The full closed loop is from R to Y with K nonzero.
In fact, the same closed loop response, except for a gain factor, can also be obtained
fron EZ to Y with K nonzero.
Figure A14-3 lists the log file from a runtime session. The open loop response is
obtained first. The loop gain K is set to zero, a title is specified, and the line type for
the second curve on subsequent Bode plots is set to be dotted. A START command
moves values into the state variables. The model stopping time (TSTP) is zero, so the
run terminates as soon as the code has been evaluated at time zero.
SET k=0, TITLE(41)='Open Loop Response', SLTFPL=100
START

Next we check the eigenvalues of the system:


ANALYZE /EIGEN

The output from this command shows the real and imaginary roots, the frequency, and
the damping.
Complex eigenvalues in ascending order
REAL IMAGINARY FREQUENCY DAMPING
1 0.
2 -1.60142000 +/-0.99707700 1.886460 0.848905
4 -8.00000000
5 -20.0000000

Figure A14-1. Linear analysis example block diagram

Page A-116 ACSL Reference Manual


A14. Linear analysis example A. ACSL Example Programs

PROGRAM test bode

!-----------------------control analysis example taken from


! control system synthesis by truxal pp 259-266

! plant model

! 1.0
! ----------------------
! s*(s**2 + 3.2s + 3.56)

! compensator model

! k*(s + 1)**2
! --------------
! (s + 8)*(s + 20)

! find the value of k to give reasonable closed loop response

!-----------------------define acsl system variables


ALGORITHM ialg = 3
MAXTERVAL maxt = 0.05
CINTERVAL cint = 0.10
NSTEPS nstp = 1

!-----------------------define model related parameters


CONSTANT p1 = 8.0, p2 = 20.0, z1 = 1.0, z2 = 1.0, r = 0.0 &
, a2 = 0.281, a1 = 0.900, k = 0.0, kt = 1.0, tstp = 0.0
!-----------------------define dummy control inputs
CONSTANT ez = 0.0, uz = 0.0

!-----------------------plant
y = CMPXPL(a2, a1, a2*INTEG(u + uz, 0.0))
!-----------------------controller/compensator
u = LEDLAG(1.0/z1, 1.0/p1, LEDLAG(1.0/z2, 1.0/p2 &
, (k*e + kt*ez)*z1*z2/(p1*p2)))
!-----------------------error term
e = r - y

TERMT(t .GE. tstp, 'Time Limit')

END

Figure A14-2. Linear analysis example program

We then establish a list of control variables (R, EZ, and UZ) and observable variables
(Y and U), and turn on /LIST so that details of the /ZEROS and /BODE operations are
written out in the log file. To get the complete system open loop response Y/EZ,
designate the control index (CINDEX) as 2 and the observable index (OINDEX) as 1
(its default):
ANALYZE /CONTROL=r,ez,uz/OBSERVE=y,u/LIST=.T.
ANALYZE /CINDEX=2

The poles and zeros are extracted with the /ZEROS command:
ANALYZE /ZEROS
Number of poles is 5 - Number of zeros is 2
Fractional gain is 1.00000000 with an exponent of 0
Complex zeros in ascending order
REAL
1 -1.00000000
2 -1.00000000

ACSL Reference Manual Page A-117


A. ACSL Example Programs A14. Linear analysis example

ACSL Runtime Exec Version 6 Level 10B 18-MAR-91 16:56:06 Page 1

SET TITLE='Frequency Response/Root Locus Example'


PREPARE t,y,u,e
OUTPUT/NCIOUT=50 t,y,e
SET k=0,TITLE(41)='Open Loop Response',SLTFPL=100
START ! Give states values
T 0. Y 0. E 0.
ANALYZE /EIGEN ! List Eigen vales
Complex eigenvalues in ascending order
REAL IMAGINARY FREQUENCY DAMPING
1 0.
2 -1.60142000 +/-0.99707700 1.886460 0.848905
4 -8.00000000
5 -20.0000000

ANALYZE /CONTROL=r,ez,uz/OBSERVE=y,u/LIST=.T.
ANALYZE /CINDEX=2
ANALYZE /ZEROS
Number of poles is 5 - Number of zeros is 2
Fractional gain is 1.00000000 with an exponent of 0
Complex zeros in ascending order
REAL
1 -1.00000000
2 -1.00000000

ANALYZE /HERTZ=.F./FREQMN=0.1/FREQMX=1000.0
ANALYZE /BODE
Number of poles is 5 - Number of zeros is 2
Fractional gain is 1.00000000 with an exponent of 0
Complex zeros in ascending order
REAL
1 -1.00000000
2 -1.00000000

Frequency Phase (deg) Gain (db)


0.10000000 -84.7386000 -35.0334000
0.20000000 -79.7027000 -40.8348000
0.30000000 -75.0915000 -44.0078000
0.37500000 -72.0066000 -45.6125000
0.46875000 -68.6767000 -47.0652000
0.58593800 -65.4018000 -48.3206000
0.73242200 -62.7065000 -49.3439000
0.91552700 -61.3450000 -50.1347000
1.37329000 -64.9686000 -51.2312000
1.54495000 -67.8517000 -51.5756000
1.73807000 -71.5338000 -51.9827000
1.95533000 -75.9104000 -52.4761000
2.19975000 -80.8424000 -53.0713000
2.47472000 -86.1841000 -53.7750000
2.78405000 -91.8088000 -54.5862000
2.95806000 -94.7826000 -55.0440000
3.14294000 -97.7978000 -55.5277000
3.33937000 -100.848000 -56.0365000
3.54808000 -103.930000 -56.5693000
3.76984000 -107.040000 -57.1254000
4.00545000 -110.179000 -57.7041000
4.25579000 -113.345000 -58.3049000
4.52178000 -116.541000 -58.9275000
4.80439000 -119.766000 -59.5719000
5.10466000 -123.022000 -60.2381000

Figure A14-3. Frequency analysis log file (part 1)

Page A-118 ACSL Reference Manual


A14. Linear analysis example A. ACSL Example Programs

ACSL Runtime Exec Version 6 Level 10B 18-MAR-91 16:56:06 Page 2


Frequency Response/Root Locus Example Open Loop Response

5.42371000 -126.309000 -60.9262000


5.76269000 -129.627000 -61.6366000
6.12285000 -132.976000 -62.3697000
6.50553000 -136.355000 -63.1258000
6.91213000 -139.762000 -63.9055000
7.34414000 -143.195000 -64.7093000
7.80315000 -146.652000 -65.5376000
8.29084000 -150.128000 -66.3909000
8.80902000 -153.620000 -67.2697000
9.35958000 -157.123000 -68.1741000
9.94456000 -160.633000 -69.1047000
10.5661000 -164.144000 -70.0616000
11.2265000 -167.652000 -71.0449000
11.9281000 -171.150000 -72.0549000
12.6736000 -174.633000 -73.0915000
13.4657000 -178.094000 -74.1547000
14.3074000 -181.529000 -75.2444000
15.2016000 -184.930000 -76.3603000
16.1517000 -188.293000 -77.5023000
17.1611000 -191.610000 -78.6699000
18.2337000 -194.876000 -79.8627000
19.3733000 -198.085000 -81.0802000
20.5841000 -201.231000 -82.3219000
21.8707000 -204.309000 -83.5869000
23.2376000 -207.314000 -84.8746000
24.6899000 -210.242000 -86.1841000
26.2330000 -213.088000 -87.5144000
27.8726000 -215.849000 -88.8647000
29.6146000 -218.521000 -90.2338000
31.4656000 -221.102000 -91.6209000
33.4322000 -223.591000 -93.0247000
35.5217000 -225.985000 -94.4443000
37.7418000 -228.285000 -95.8786000
40.1006000 -230.491000 -97.3264000
42.6069000 -232.602000 -98.7868000
45.2698000 -234.620000 -100.259000
48.0992000 -236.546000 -101.742000
51.1054000 -238.381000 -103.234000
54.2995000 -240.129000 -104.735000
57.6932000 -241.791000 -106.245000
61.2990000 -243.370000 -107.761000
65.1302000 -244.868000 -109.285000
69.2009000 -246.289000 -110.814000
77.8510000 -248.840000 -113.800000
87.5824000 -251.131000 -116.802000
98.5302000 -253.184000 -119.819000
110.846000 -255.022000 -122.845000
124.702000 -256.665000 -125.881000
140.290000 -258.131000 -128.923000
157.826000 -259.439000 -131.971000
197.283000 -261.540000 -137.757000
246.604000 -263.226000 -143.553000
308.254000 -264.578000 -149.356000
462.382000 -266.383000 -159.909000
693.572000 -267.588000 -170.470000
1000.00000 -268.327000 -180.002000
Drawing plot number 1

Figure A14-3. Frequency analysis log file (part 2)

ACSL Reference Manual Page A-119


A. ACSL Example Programs A14. Linear analysis example

ACSL Runtime Exec Version 6 Level 10B 18-MAR-91 16:56:06 Page 3


Frequency Response/Root Locus Example Open Loop Response

ANALYZE /REALMN=-10/REALMX=0.0/IMAGMN=-10/IMAGMX=10
ANALYZE /LIST=.F./ROOTLOCUS
Number of poles is 5 - Number of zeros is 2
Drawing plot number 2
SET k=1438,TITLE(41)='Closed Loop Response'
ANALYZE /ZEROS/EIGEN
Number of poles is 5 - Number of zeros is 2
Fractional gain is 10.0000000 with an exponent of -1
Complex zeros in ascending order
REAL
1 -1.00000000
2 -1.00000000

Complex eigenvalues in ascending order


REAL IMAGINARY FREQUENCY DAMPING
1 -0.65055100
2 -1.35087000
3 -2.62156000 +/-7.83751000 8.264330 0.317214
5 -23.9583000

ANALYZE /CINDEX=1/BODE
Number of poles is 5 - Number of zeros is 2
Drawing plot number 3
SET DTCFPL=.T.,YINFPL=6,PSFFPL=0.9
ANALYZE /bode
Number of poles is 5 - Number of zeros is 2
Drawing plot number 4
QUIT

Figure A14-3. Frequency analysis log file (part 3)

A frequency sweep from 0.1 to 1000 rad/s by setting the units with /HERTZ and
minimum and maximum frequencies. The resulting Bode plot for the open loop
system is shown in Figure A14-4 with phase as a solid line and gain dotted.
ANALYZE /HERTZ=.F./FREQMN=0.1/FREQMX=1000
ANALYZE /BODE

The log file shows a long list of frequency values and corresponding phase and gain
points as the frequency is swept from /FREQMN to /FREQMX. This output results
from /LIST being set to TRUE. It can be eliminated by setting /LIST to FALSE prior
to invoking /BODE.
Figure A14-5 is a root locus plot of the open loop system obtained by the following
commands setting the plot scales and turning off /LIST:
ANALYZE /IMAGMN=-10/IMAGMX=10/REALMN=-10/REALMX=0.0
ANALYZE /LIST=.F./ROOTLOC

If the boundaries of the plot are not specified, the area will be sized from the poles
(-20 to zero on the real axis) and -1 to +1 on the imaginary axis, resulting in a
somewhat distorted view. Note the scales chosen for this plot have a real axis extent of
10 and an imaginary axis of 20, so angles still cannot be read accurately.
The loci from the two complex poles at -1.6+/-j meet at the real axis at -2.869 and then
break away again at 3.83 to finally leave towards the asymptotic slopes of +/-60
degrees. Truxal on page 260 shows no breakaway points!

Page A-120 ACSL Reference Manual


A14. Linear analysis example A. ACSL Example Programs

Figure A14-4. Open loop Bode plot Figure A14-5. Open loop root locus plot

If /LIST had been true, position, gain, and step length would have been printed out
during the locus tracking.
For the control system, Truxal picks a loop gain of 1438, which corresponds to
principal roots of 2.62+/-j7.83. This corresponds to a damping of 0.316 at an angle of
71 degrees (arctan 3). These can be tested by setting the value of K to 1438 and then
asking for the eigenvalues (which confirm the gain calculation) with the commands:
SET k=1438
ANALYZE /EIGEN

The closed loop Bode plot is obtained by changing the control to R, leaving the gain K
at 1438, as follows:
SET TITLE(41)='Closed Loop Response'
ANALYZE CINDEX=1/BODE

Figure A14-6 is the closed loop Bode plot. Again, gain is shown dotted. To see the
other form of Bode plots, the system symbol DTCFPL (draw two curves) is set TRUE,
the nominal Y axis length is changed to six, and a plot scale factor (PSFFPL) of 0.9 is
specified so that the plot fits on the screen for monitoring purposes; i.e.,
SET DTCFPL=.T.,YINFPL=6,PSFFPL=0.9
ANALYZE /BODE

The control system can be checked by running the model and plotting a time history of
the plant dynamics. The program stopping time is set to 4.99 sec, K to 1438, and R to
1 (to excite the system).
In the linear analysis, when time is not a consideration and thus no integrations are
being calculated, the Euler integration routine (IALG = 3) is adequate. For runs over
time, however, one of the Runge-Kutta routines is preferred. A communication
interval of 0.1 results in a ragged plot (i.e., not enough data points are being logged),
so CINT in reduced to 0.01. Figure A14-8 is the plot resulting from the following
commands:
SET tstp=4.99,k=1438,r=1,ialg=4,cint=0.01
SET TITLE(41)='Time response with K=1438, R=1'

ACSL Reference Manual Page A-121


A. ACSL Example Programs A14. Linear analysis example

Figure A14-6. Closed loop Bode plot Figure A14-7. Bode plot with separate axes

Figure A14-8. Time plot of linear analysis example

Page A-122 ACSL Reference Manual


A15. Tank with Boiling Benzene A. ACSL Example Programs

15. Tank with


Boiling Benzene

This model, as shown in Figure A15-1, represents the dynamics of a boiling liquid
where the inlet flow rate is controlled through a PI controller and the outlet flow rate is
set to oscillate slowly to force the system. In practice, the outlet vapor flow would be
controlled by the requirement of the downstream component or unit operation.
This example demonstrates how the vapor/liquid equilibrium can be modeled as a
differential-algebraic system using the implicit operators IMPLC and IMPVC. The
parameters in the model are taken to represent benzene.

15.1 Equations

The equations describing the behavior inside the tank are derived from conservation of
mass and conservation of enthalpy. The total mass (units of Kg) in the tank is obtained
by integrating the difference between the inlet mass flow rate and the outlet vapor
mass flow rate.

mTOTAL =
∫(f IN − fOUT ) dt

Enthalpy The total enthalpy (units of kJ) is similarly obtained by integrating the difference
between what is carried in in the liquid stream and what is carried out by the vapor
stream and adding what heat is supplied from an external source.

hTOTAL =
∫(f IN cL TIN − fOUT ( cL TL + lHEAT ) + q ) dt

Figure A15-1. Boiling vessel

ACSL Reference Manual Page A-123


A. ACSL Example Programs A15. Tank with Boiling Benzene

Here cL is the specific heat of both liquid and vapor, TIN (°C) is the inlet liquid
temperature , TL is the temperature inside the tank, lHEAT (kJ/kg) is the latent heat of
vaporization and q (kJ/sec) is the heat flux from external sources – assumed constant
here. We assume one temperature TL for both liquid and vapor phases inside the tank
and have to evaluate the enthalpy of the liquid and vapor phases separately.

hL = mL cL TL
hV = mV ( cL TL + lHEAT )

Now the total enthalpy can also be written down as the sum of these two separate
enthalpies.

hTOTAL = hL + hV

Tank temperature We can use this relationship to solve for the tank temperature TL. Since the
temperature occurs only linearly, we could solve directly for this:

hTOTAL − mV lHEAT
TL =
( mL + mV ) cL

However, we intend to use the ACSL implicit operator to find the tank temperature by
expressing the fact that the difference between total enthalpy and the sum of liquid and
vapor enthalpies should be zero.

RESIDUAL = hTOTAL − ( hV + hL ) = 0

Nonlinear functions The real requirement for an equation solver comes when the relationship is nonlinear.
In this case the liquid and vapor specific heats should be considered to be different and
nonlinear functions of temperature.

Vapor pressure The mass balance equation is a little more complicated and leads to a nonlinear
equation due to the exponential variation of vapor pressure with temperature. The
vapor pressure above the liquid can be calculated using the Antoine equation.

pV = exp ( a − b ⁄ ( c + TL ) )

Making a somewhat broad assumption about the perfect gas law, we get:

vV pV = mV r ( T0 + TL )

where vV (m3) is the volume of the vapor phase, mV (kg) is the mass of the vapor, r is
the gas constant in units per kilogram (rather than per mole), and T0 is the 0 degree
Centigrade value in Kelvin (273.16 °K).

Constraint Since density (dV) in the vapor is given by:

dV = mV ⁄ vV

we can write the constraint equation:

pV − dV r ( T0 + TL ) = 0

Page A-124 ACSL Reference Manual


A15. Tank with Boiling Benzene A. ACSL Example Programs

We use this to adjust the mass in the vapor mV until the constraint on pressure is
satisfied. Note that we can't just solve the above for mV since mV appears in the vapor
enthalpy equation that determines temperature and pV depends in a nonlinear fashion
on temperature.

Controller The other equations in the model are concerned with the level controller and outlet
valve flow. The level controller is implemented as a PI (proportional plus integral)
control action as follows:

c1P = cG ( mLIC − mL )


c1P
c1I = dt
tI
fIN = c1P + c1I

The names C1P and C1I are used because the name CL is already the specific heat of the
liquid. Here we assume that cG contains the tank area as well as the proportional gain
constant since the error term is developed in terms of the difference between initial
liquid mass (mLIC started at a mass such that the liquid occupied half the tank volume)
and current liquid mass, mL. The integral action is obtained by integrating the
proportional action after dividing by the reset time constant, ti. These two flow
commands are assumed to be met exactly by the inlet flow controller so that we can
obtain the inlet flow by summing them. In actual practice, the controller dynamics and,
in particular, valve travel limits should be considered in any realistic simulation.

Outlet flow rate The outlet flow rate is considered to be just a valve, the opening of which follows a
sine wave. The valve position is given by:

xV = xVZ + xVA sin ( xVW t )

The flow through the valve depends on this opening and the square root of the
pressure drop from the tank internal pressure pV to the downstream of outlet pressure,
pOUT, assumed here to be constant.

fOUT = kV xV √

pV |( pV − pOUT )| SGN ( pV − pOUT )

15.2 ACSL program

Figure A15-2 lists the program that contains the equations of the previous section.

Program control At the beginning of the program, ACSL system constants are specified. These set the
communication interval (CINT) to half a second and the integration algorithm (IALG)
to second order Runge-Kutta (4).

Model constants Next comes the physical parameters and initial conditions. We want to establish a
steady state condition here by setting an inlet flow rate (17.5 kg/sec) and vessel
pressure (pVIC = 4.7 bars). From this we calculate the other initial conditions, leading
up to total mass and total enthalpy.

ACSL Reference Manual Page A-125


A. ACSL Example Programs A15. Tank with Boiling Benzene

program boiler (constants represent benzene)

!------------------------ACSL system constants


cinterval cint = 0.5 ! communication interval
maxterval maxt = 0.5 ! maximum step size
algorithm ialg = 4 ! second order rk algorithm
nsteps nstp = 1 ! no influence from cint
!------------------------model constants
constant finic = 17.5 ! inlet flow of liquid (kg/s)
constant tin = 75.0 ! inlet temperature (deg C)
constant dl = 874.0 ! density of liquid (kg/m**3)
constant mwt = 78.0 ! molecular weight
constant lheat = 387 0 ! latent heat of vaporization (
constant cl = 1.26 ! specific heat of liquid
constant vol = 10.0 ! vessel size (m**3)
constant pout = 2.0 ! pressure (bars)
constant a = 9.2807 ! vapor pressure constants
constant b = 2788.51 !
constant c = 220.79 !
constant ti = 500.0 ! controller data (sec)
constant cg = 0.005 !
constant pvic = 4.7 ! initial pressure in vessel (bars)
constant tzero = 273.16 ! zero cintigrade in kelvin
constant xvz = 0.7 ! manual valve position
constant xva = 0.3 ! valve amplitude
constant xvw = 0.5 ! valve frequency (rad/sec)

initial

!-----------------------gas constant (1/kg)


r = 8.314/mwt
!-----------------------initial temperature (deg C)
tlic = b/(a - log(pvic)) - c
!-----------------------heat flux (kJ/sec)
q = finic*(cl*(tlic - tin) + lheat)
!-----------------------liquid and vapor volumes (m**3)
volv = vol/2.0
voll = vol - volv
!-----------------------liquid and vapor masses (kg)
mlic = dl*voll
mvic = pvic*volv/(r*(tlic + tzero))
!-----------------------internal liquid and vapor enthalpies (kJ)
hlic = mlic*cl*tlic
hvic = mvic*(cl*tlic + lheat)
htic = hlic + hvic
mtic = mlic + mvic
!-----------------------valve data
kv = finic/(xvz*sqrt(pvic*(pvic - pout)))

end
derivative

!-----------------------valve opening as drive to system


xv = xvz + xva*sin(xvw*t)
!-----------------------total mass holdup of vessel contents (kg)
mtotal = integ(fin - fout, mtic)
!-----------------------total enthalpy of vessel contents (kJ)
htotal = integ(fin*cl*tin + q - fout*(cl*tl + lheat), htic)
!-----------------------level controller on liquid stream
c1p = cg*(mlic - ml)
c1i = integ(c1p/ti, finic)
fin = c1i + c1p
!-----------------------vapor valve - manual
fout = kv*xv*sign(sqrt(abs(pv*(pv - pout))), pv - pout)

Figure A15-2. ACSL program of boiler (part 1)

Page A-126 ACSL Reference Manual


A15. Tank with Boiling Benzene A. ACSL Example Programs

!-----------------------liquid and vapor enthalpies (kJ)


hl = ml*cl*tl
hv = mv*(cl*tl + lheat)
!-----------------------liquid mass and vapor volume (m**3)
ml = mtotal - mv
volv = vol - ml/dl
!-----------------------vapor density (kg/m**3)
dv = mv/volv
!-----------------------vapor pressure (bars)
pv = exp(a - b/(c + tl))
!-----------------------equilibrium vapor mass obtained by
! adjusting the mass of vapor until the pressure due to the
! contained mass matches the liquid vapor pressure
residmv = pv - dv*r*(tl + tzero)
mv = implc(residmv, mvic)
!-----------------------equilibrium liquid temperature adjusts
! the temperature until the sum of the liquid and vapor enthalpies
! match the total enthalpy in the system
residtl = htotal - hl - hv
tl = implc(residtl, tlic)
!-----------------------stopping condition
constant tstp = 99.99
termt(t .ge. tstp, 'Stopped on time')

end ! of derivative
end ! of program

Figure 2. ACSL program of boiler (part 2)

Vessel temperature First we can calculate the vessel temperature, knowing the pressure, by inverting the
vapor pressure equation.

TLIC = b ⁄ ( a − log ( pVIC ) ) − c

Heat input Knowing this temperature, we now can calculate how much heat has to be added to the
inlet specified flow rate in order to turn it all into vapor.

q = fINIC ( cL ( TLIC − TIN ) + lHEAT )

Initial volumes We divide the tank into two halves for the initial liquid and vapor volumes:

volv = vol ⁄ 2
voll = vol − volv

Liquid density The density of the liquid is assumed fixed (dL) so the mass of liquid is:

mLIC = dL volv

Vapor mass Knowing the vapor pressure, volume and the gas law, vapor mass is then given by:

mVIC = pVIC volv ⁄ ( r (TLIC − TZERO ) )

ACSL Reference Manual Page A-127


A. ACSL Example Programs A15. Tank with Boiling Benzene

Enthalpy Knowing the masses and temperatures, enthalpies can be written:

hLIC = mLIC cL tLIC


hVIC = mVIC+ ( cL tLIC + lHEAT )

Remember one kilogram of vapor holds the enthalpy due to its temperature and also
the latent heat of vaporization (or how it got to be vapor).

Total enthalpy Finally we have the total enthalpy, which is needed for the initial condition on the
integrator:

hTIC = hLIC + hVIC

Total mass The total mass required similarly for the initial condition on the mass integrator.

mTIC = mLIC + mVIC

Outlet value The last thing in the INITIAL section is the calculation of the outlet valve coefficient,
coefficient kV. Since we know that the vapor flow rate in steady state must match the inlet flow
rate (kg/sec), we calculate a valve coefficient to give us this known flow rate at the
pressure inside the vessel.

kV = fINIC ⁄ ( xvz √

pVIC |( pVIC − pOUT )| )

In practice, the valve opening should be calculated but since we don't know which size
valve to use yet, we may as well calculate a nominal valve coefficient desired at the
nominal valve opening of xvz (70%).

DERIVATIVE The code in the DERIVATIVE section follows the equations of the previous section.
The only thing of note is the specification of the implicit constraints. We first specify
the residual for the vapor mass adjuster by:
residmv = pv - dv*r*(tl + tzero)

Residual The implicit operator drives this residual to zero.

mv = IMPLC(residmv, mvic)

There is no need to calculate the residual specifically since the first argument of the
IMPLC operator can be an expression. The previous two statements could have been
combined into:
mv = IMPLC(pv - dv*r*(tl - tzero), mvic)

In this form, however, there is no variable name for the residual so it is not available
for plotting. We want the residual to have a name so we can show that it really is kept
close to zero.

Liquid temperature Similarly, the liquid temperature is obtained from:


residtl = htotal - hl - hv
tl = IMPLC(residtl, tlic)

Page A-128 ACSL Reference Manual


A15. Tank with Boiling Benzene A. ACSL Example Programs

Steady state Our problem with calculating a steady state condition is that we don't know what
numbers to use for total mass and total enthalpy. These are the integrators, but if we
say we want to start with an operating pressure of 4.7 bars and an inlet flow rate of
17.4 kg/sec, we don't have much hope of finding the initial conditions mTIC and hTIC
except by the calculations just outlined in the INITIAL section.
There is another way, though, that uses the ACSL trim (or steady state finder). The
idea is to adjust the state variables until the derivatives go to zero, this being defined as
steady state. In this example, we have three integrators: one for total mass, one for
total enthalpy, and one for the PI controller. Since this controller determines inlet flow
rate that we want to fix, we freeze this integrator so it won't be adjusted. The following
runtime command finds the steady state condition.
ACSL> ANALYZE /FREEZE=cli /TRIM

This adjusts the total enthalpy and total mass until the rates go to zero. Unfortunately,
in doing this, the liquid mass itself is adjusted so that the PI controller has a
proportional component since mL isn't equal to mLIC.

Controls and The way around this is to recognize that we also need to adjust the heat flux to achieve
observables a steady state. By adding this as a /CONTROL, we make it adjustable. At the same
time we must specify a matching /OBSERVE variable to be driven to zero. This value
should be the error term in the PI controller or its equivalent, c1P, which is
proportional to the difference between mL and mLIC. The sequence of runtime
commands now is:
ACSL> ANALYZE /FREEZE=cli /CONTROL=q /OBSERVE=c1p
ACSL> ANALYZE /TRIM

This finds a steady state operating point of vapor mass 0.53 kg and tank temperature
139.8 °C.

15.3 Results

Figure A15-3 plots the results of a sample run and Figure A15-4 lists the output.

System symbols First we set the title to identify the simulation. Next we set system variables NPBPRN
(no page break) and DCVPRN (display changed value). NPBPRN ensures that no
page headers appear in the log file, making it easier to fit the listing into a document.
DCVPRN, set to TRUE, says to display both the original value as well as the new
value when anything is changed by a runtime SET statement.

Data recording The next two statements establish the data recording conditions during the simulation
run. PREPARE/ALL places all the calculated variables (those on the left hand side of
an equal sign) on the prepare list. For the OUTPUT statement we choose time (T) and
all the variables starting with RESID – the wild card specification matches the
residuals for the mass of vapor (RESIDMV) and the liquid temperature (RESIDTL).

Stop time Next we change the stop time from 99.99 seconds to 19.99 seconds. Because
DCVPRN is set to true, both the old and the new values of TSTP are written out and
we can see clearly the consequences of the SET statement.

ACSL Reference Manual Page A-129


A. ACSL Example Programs A15. Tank with Boiling Benzene

Figure A15-3. Valve position, vessel pressure, and vapor flow of boiler

Execute run Finally we get to actually run the simulation with a START command. The OUTPUT
variables are listed every communication interval of 0.5 seconds. (To conserve space,
part of the listing has been deleted with a text editor.) The output shows that the
residuals are in the range 1.0e-7 to 1.0e-12 (the model has been translated with global
double precision) even though the nominal allowable errors are set to the normal
1.0e-4 or 0.01%. Remember that the allowed error gives the minimum distance the
two unknowns MV and TL are from their true solutions, not on the value of the
residual!

Plot After the run, we plot the valve opening XV, pressure PV, and outlet flow rate FOUT
as shown in Figure A15-3. As the valve opens, the flow rises but cools off the contents
of the tank, reducing the vapor pressure, so that the flow out starts to turn down before
the peak valve opening.

Steady state The next section in the log file after the PLOT command demonstrates the use of the
TRIM action to find a steady state. Since ANALYZE/TRIM starts by moving the
initial condition vector onto the state vector, the system will automatically be in
equilibrium. We went to great trouble in the INITIAL section to calculate these steady
state values and they remain in the initial condition vector. In order to give the TRIM
routine something to work on, we change the initial condition on total enthalpy, HTIC,
and also on the total mass MTIC. Total enthalpy for equilibrium was 771939.693 and
is changed to 700,000 kJ; total mass was 4370.53388 and is changed to 4000 kg. We
set the condition to hold the control integrator constant (/FREEZE=C1I) and add heat
flux Q as a control variable and proportional error as an observable (to be driven to
zero) by:
ACSL> ANALYZE /CONTROL=Q /OBSERVE=C1P

Page A-130 ACSL Reference Manual


A15. Tank with Boiling Benzene A. ACSL Example Programs

The internal workings of the TRIM action are made visible for this listing by adding
/LIST=.T. at the end.

Now with the stage set, the following:


ACSL> ANALYZE /TRIM

starts to adjust the five unfrozen states and controls to drive the derivatives and
observables to zero. Note that the algebraic variables are added to the list of state
variables so that there is one big vector of five quantities to be driven to zero. In this,
the residuals act just like derivatives.
After five iterations, the steady state has been found. A DISPLAY/ALL shows this
steady state with the derivatives and residuals between 8.0e-4 and 1.0e-8. The
important quantities are the last four states (the first one C1I is frozen) and the
proportional error C1P. (The dump has been edited to remove extraneous variables.)

set npbprn=.t. ! no page break


set title='Pressure/flow in boiling vessel'
set dcvprn=.t. ! display changed variables
prepare/all ! save all calculated variables
output t,resid* ! short output list of time and all residuals
set tstp=19.99 ! shorten run time (note old value before change)
TSTP (Old value) 99.9900000 (New value) 19.9900000
start
Jacobian evaluated. Condition number is 0.41422100
T 0. RESIDMV 1.3323D-15 RESIDTL-2.8422D-12
T 0.50000000 RESIDMV 6.0075D-08 RESIDTL-1.9393D-08
T 1.00000000 RESIDMV 6.7200D-07 RESIDTL-2.3933D-07
T 1.50000000 RESIDMV 1.8011D-08 RESIDTL-6.4011D-09
T 2.00000000 RESIDMV 5.5301D-09 RESIDTL-1.4060D-09
...
T 17.5000000 RESIDMV 1.3378D-12 RESIDTL 5.2580D-12
T 18.0000000 RESIDMV-7.1240D-09 RESIDTL 2.0156D-09
T 18.5000000 RESIDMV-2.0547D-07 RESIDTL 6.7839D-08
T 19.0000000 RESIDMV-1.1178D-06 RESIDTL 3.7453D-07
T 19.5000000 RESIDMV 4.0182D-08 RESIDTL-1.4378D-08
Stopped on time
T 20.0000000 RESIDMV 1.6492D-08 RESIDTL-8.1371D-09
plot xv/tag='valve position',pv/tag='vessel pressure (bars)' &
,fout/tag='vapor flow out (kg/sec)'
Drawing plot number 1
set htic=700000 ! give the trim finder something to
HTIC (Old value) 771939.693 (New value) 700000.000
set mtic=4000 ! work on by making ic values nonsteady state
MTIC (Old value) 4370.53388 (New value) 4000.00000
analyze/freeze=c1i/control=q/observe=c1p/list=.t.
analyze/trim ! find the steady state condition
Jacobian evaluated. Condition number is 0.41422400
Jacobian evaluated. Condition number is 0.28882100

State vector - iteration number 1


HTOTAL 700000.000 MTOTAL 4000.00000 MV 0.56444100
TL 138.455000 Q 69153.9000

Derivative vector - residual is 0.00430496 previous 1.0000E+37


Scaled residual is 69735.6000 previous 1.0000E+37
Z99996 2980.55000 Z99998 2.53914000 Z99992 3.8910E-12
Z99990-2.3306E-12 C1P 1.85282000

Newton step 71379.6000 steep desc step 1598.72000 mu 0

Figure A15-4. Boiler log file (part 1)

ACSL Reference Manual Page A-131


A. ACSL Example Programs A15. Tank with Boiling Benzene

State vector - iteration number 2


HTOTAL 771379.000 MTOTAL 4370.54000 MV 0.53503300
TL 139.815000 Q 69153.0000

Derivative vector - residual is 4.53907000 previous 1.0000E+37


Scaled residual is 330.909000 previous 69735.6000
Z99996-27.2037000 Z99998-0.00643281 Z99992-0.00905089
Z99990-634.645000 C1P-3.4106E-15

Newton step 567.771000 steep desc step 83.7361000 mu 0

State vector - iteration number 3


HTOTAL 771946.000 MTOTAL 4370.53000 MV 0.53377100
TL 139.802000 Q 69153.9000

Derivative vector - residual is 0.06221710 previous 4.53907000


Scaled residual is 4.74315000 previous 330.909000
Z99996 0.62842300 Z99998 1.4860E-04 Z99992 9.1727E-04
Z99990 8.69736000 C1P 5.6843E-16

Newton step 6.69005000 steep desc step 1.16632000 mu 0

State vector - iteration number 4


HTOTAL 771940.000 MTOTAL 4370.53000 MV 0.53388600
TL 139.802000 Q 69153.9000

Derivative vector - residual is 4.6269E-04 previous 0.06221710


Scaled residual is 0.04924880 previous 4.74315000
Z99996-0.00544570 Z99998-1.2877E-06 Z99992-7.1310E-05
Z99990-0.06391410 C1P 0.

Newton step 0.01510290 steep desc step 0.00955796 mu 0

State vector - iteration number 5


HTOTAL 771940.000 MTOTAL 4370.53000 MV 0.53387700
TL 139.802000 Q 69153.9000

Derivative vector - residual is 8.4072E-06 previous 4.6269E-04


Scaled residual is 0.00293479 previous 0.04924880
Z99996 6.9028E-05 Z99998 1.6323E-08 Z99992 6.0603E-06
Z99990 8.1466E-04 C1P 0.

display/all ! show the steady state condition


T 0. ZZTICG 0. CINT 0.50000000
...

State Variables Derivatives Initial Conditions


C1I 17.5000000 Z99994 0. FINIC 17.5000000
HTOTAL 771939.691 Z99996 6.9028D-05 HTIC 700000.000
MTOTAL 4370.53388 Z99998 1.6323D-08 MTIC 4000.00000
MV 0.53387730 Z99992 6.0603D-06 MVIC 0.53387799
TL 139.802321 Z99990 8.1466D-04 TLIC 139.802321

Algebraic Variables

Common Block /ZZCOMP/


A 9.28070000 B 2788.51000 C1P 0.
C 220.790000 CG 0.00500000 CL 1.26000000
...
XV 0.70000000 XVA 0.30000000 XVW 0.50000000
XVZ 0.70000000

Figure A15-4. Boiler log file (part 2)

Page A-132 ACSL Reference Manual


B. General Purpose Utilities

General purpose subroutines from the system library are described in this appendix.

B.1 AGET–,
APUT–

FORM: AGETR(x = 'string') AGETR('string', x)


AGETI(n = 'string') AGETI('string', n)
AGETL(l = 'string') AGETL('string', l)
AGETD(d = 'string') AGETD('string', d)
AGETC(c = 'string') AGETC('string', c)

APUTR('string', x)
APUTI('string', n)
APUTL('string', l)
APUTD('string', d)
APUTC('string', c)

where R indicates real (single precision), I integer, L logical, D double precision, and
C character. The two forms of each call are equivalent. The equal sign indicates that
the item on left of it is the output of the routine; the item on the right, the input.
Subroutines AGET– and APUT– obtain the values from or put values into a variable
array in either the user or system dictionary. They are useful in FORTRAN
subroutines to obtain or return isolated values not passed through the calling sequence
and are the only way to access values from the system dictionary.
For the AGET– subroutines, the variable to be filled must have sufficient space to
receive the entire array. No check is made that this condition has been fulfilled.
For the APUT– subroutines, the size of the dictionary variable denoted by string is
known, so the exact amount of data needed to fill this variable is extracted. This may
be more than is intended, however, since the APUT– routine just copies successive
words until the size count is satisfied. The dictionary names placed in string can be
in any case since the string is converted to uppercase before looking in the dictionary.
Trailing blanks are ignored.
A typical reason for using this procedure is to access the computer system date and
time in the TITLE array for plot titles. Reference the whole 480 characters of TITLE
and make the call in the TERMINAL section so it is executed only once per run.
CHARACTER mytitle*480, today*10, now*9
CALL AGETC(mytitle = 'TITLE')
CALL DATE(today)
CALL TIME(now)
mytitle(20:40) = today//now
CALL APUTC('TITLE', mytitle)

Note that these functions require a full dictionary search and if placed in a loop
executed every integration step use an excessive amount of computer time.

ACSL Reference Manual Page B-1


B. General Purpose Utilities B.2 DEBUG

B.2 DEBUG
FORM: CALL DEBUG

A call to this routine produces a debug dump of all variables, excluding arrays greater
than MALPRN (maximum array limit for print), on the print (PRN) unit. If HVDPRN
(high volume display) is set TRUE, the dump also appears on the display (DIS) unit.
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, DISCRETE, and
Jacobian evaluation; for example:
ACSL> SET NDBUG=20
ACSL> START

While useful as a checkout tool, with large programs this approach can result in an
overwhelming amount of output. 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 that sorted sections of a program are not always translated in the order given; a
look at the resulting FORTRAN listing will show the order of execution and the
placement of the DEBUG call.
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, a useful set of data. Putting the call on a logical switch as follows allows
you to suppress the listing when you don't want it, such as during interactive runs.
LOGICAL dump
CONSTANT dump = .TRUE.
IF(dump) CALL DEBUG

B.3 DISSTR

FORM: CHARACTER buffer*nn


CONSTANT buffer = ' '
WRITE(buffer, label) a
CALL DISSTR(buffer)
label: FORMAT(format)

In window environments (Microsoft Windows, X windows, etc) it is not possible to


use Fortran WRITE and PRINT statements to write to screen, so the DISSTR (display
string) utility is provided. Three of the examples (ACRFTS, ARESTG, and TESTER)
under ACSL for Windows use the utility.
DISSTR writes to both the runtime window and the log file.
To use DISSTR, an internal file is declared as a character buffer with enough space to
write a message (*80 for an 80-column line, for example). The information is written
to the buffer in a WRITE statement, with the buffer name where a logical unit would

Page B-2 ACSL Reference Manual


B.5 INTEG B. General Purpose Utilities

normally be. A Fortran FORMAT statement follows the usual rules, except for a
restriction on using a slash (/) for a line feed because it overflows the buffer; generate
blanks in the output with further calls to DISSTR. (The format can be incorporated
into the WRITE statement; see a Fortran programmer's manual for details.) Finally, a
call to DISSTR(buffer) prints the buffer.
For further information on writing to internal files, see a Fortran programmer's manual
or the ANSI standard reference book.
Following is an example, taken from the ARESTG model, to illustrate the procedure.
!-----------------------write the message to a buffer so that it
! can then be displayed as a string. It is given an initial value
! to prevent the message about used but not defined
CHARACTER buffer*80; CONSTANT buffer = ' '
WRITE(buffer, 200) speed, ncase
CALL DISSTR(' ') ! write two blank lines
CALL DISSTR(' ')
CALL DISSTR(buffer) ! write the message
CALL DISSTR(' ') ! write two blank lines
CALL DISSTR(' ')
200: FORMAT(20x,'Aircraft speed - ',f6.2,' Run no. ',i3)

B.4 INITD

FORM: CALL INITD

A call to INITD clears the event list. This is useful for parametric runs which loop
from TERMINAL to INITIAL and contain DISCRETE sections. If the event list is not
cleared before looping back, multiple loops add events to the event list and produce
erroneous multiple executions of events.
The event list cannot be cleared automatically by ACSL at the end of a run in case the
user next commands a CONTINUE. CONTINUE skips over the INITIAL section and
expects to continue with everything unchanged. The automatic initialization by ACSL
in the INITIAL section takes place before the INITIAL section user code in order to
allow the use of SCHEDULE within the INITIAL section. The event list is thus
cleared automatically when the INITIAL section is executed in response to the
START command, but not when a program loops back from the TERMINAL section.
A call to INITD handles this loop situation. See the program in Appendix A on
Temperature Distribution Along a Radiating Fin for an example using this utility.

B.5 INTEG

In order to provide flexibility in trying new and improved integration algorithms, the
INTEG subroutine is available for incorporating a user written routine. Setting
IALG=7 transfers control to the INTEG routine at the beginning of every integration
step. In order to write an effective INTEG routine, familiarity with the ACSL runtime
routines ZZNITS, ZZNITA, ZZINTG, ZZRKIN, and INTEGZ(NST) is essential.

ACSL Reference Manual Page B-3


B. General Purpose Utilities B.6 LISTD

B.6 LISTD
FORM: CALL LISTD(unit)

The list dictionary call provides a listing of the user dictionary and current variable
values along with any explanation of the variables supplied on the named file. Used
mainly for reports, it requires preparing a dictionary file with variable names and
definitions. The argument unit is an integer constant or a variable defining a
FORTRAN file unit number containing the definitions. The file should be configured
as follows:
column 1-9 variable name, left justified
column 10 optional continuation indicator in sequence 0, 1, 2, 3, etc.
column 11-80 definition
Because column 10 is reserved for continuation characters, only names up to nine
characters long can be handled by the current version of LISTD.
Invocation of the call is in the INITIAL or TERMINAL section, usually on a switch as
follows:
LOGICAL list
INTEGER unit
CONSTANT list = .FALSE. , unit = 11
IF(list) CALL LISTD(unit)

At the START runtime command, the dictionary is read from unit file (11 in the
example). On some systems (VAX, IBM mainframe, for example), the unit is
associated with a file prior to entering the runtime session. On VAX systems, the
ASSIGN command relates the file to a FORTRAN logical unit number as follows:
$ ASSIGN model.DCT FOR011

On other systems (Unix, for example) you are prompted for a file name. In Windows,
the Open browser appears. See the document How to Run ACSL or ACSL User's
Guide to determine the appropriate method of handling the unit number on your
system.
The dictionary is terminated by a blank name field or an end-of file. When a definition
must be continued beyond column eighty, a non-blank character in column ten results
in the name field being ignored and just the continued definition being listed out.
Repeat the name on each continuation line, numbering the lines 0, 1, 2, 3, etc. in
column ten. Now a standard sort on columns one through ten produces an alphabetical
order with the continuation lines in their correct places. Note that zero is used in the
first line of a continuation sequence and acts just like a blank. The reason for using a
zero is that in some computer systems blanks collate after numbers rather than before.
ACSL issues a message if a variable name in the dictionary file is not found (if a name
is misspelled, for instance). Duplicate names also result in an error message. If the
name is in the program but the value is undefined, asterisks appear in the value
column. For arrays, the type and size of the array is given, rather than all the values in
the array; for example, REAL(3).
The dictionary listing appears on the high volume print unit PRN, the log file of the
runtime session. If system symbol HVDPRN has been set TRUE, the listing also
appears on the screen during an interactive session. The log file can be read and/or
accessed with an editor to update the dictionary file for subsequent runs.
See the Missile Airframe example in Appendix A for an example using LISTD.

Page B-4 ACSL Reference Manual


B.9 WEM B. General Purpose Utilities

B.7 RSTART
FORM: CALL RSTART(blockname, newstep)

where blockname refers to a DERIVATIVE section (which must have been given a
name) and newstep is an integration step size. A call to the RSTART routine restarts
the step size and history of the variable step, variable order integration algorithms
(IALG = 1 or 2); it has no effect on the fixed-step Runge-Kutta algorithms (IALG = 3,
4, or 5) and also cannot be used with the Runge-Kutta-Fehlberg algorithms (IALG = 8
or 9). The call is usually used within a DISCRETE section that may be changing
conditions discontinuously, thus invalidating the history data used by the integration
routine in the continuous section.
It should never actually be necessary to use RSTART since the variable step
algorithms control the step to satisfy an error criterion, but RSTART can help reduce
the amount of work done by the integration routine if a drastic change in step size is
known to be necessary.

B.8 SETI, SETR

FORM: CALL SETI(iv, ia, n)


CALL SETR(rv, ra, n)

where the value of expression iv or rv is set into n locations of array ia or ra; n is


an integer variable, i indicates type INTEGER, and r indicates floating point (REAL
or DOUBLEPRECISION depending on the mode chosen at translation).
The SET– subroutines are provided primarily to initialize arrays and set all elements to
a given value. A complete array may be set, for example:
CALL SETR(k*a, array, iset)

or only a portion of an array:


CALL SETR(0.0, arr(5), 3)

in which case zeros are placed in the fifth, sixth, and seventh elements of array ARR.
No check is made to see whether these elements actually exist.

B.9 WEM

FORM: CALL WEM('character string')

The WEM (write error message) utility write a message to both the print (PRN) and
display (DIS) logical units.

ACSL Reference Manual Page B-5


B. General Purpose Utilities B.10 XFERBR, XFERBI

B.10 XFERBR,
XFERBI

FORM: CALL XFERBR(y = x, n)


CALL XFERBI(j = i, n)

where x and y are floating point arrays of the same length, i and j are integer arrays
of the same length, and n is an integer specifying the number of elements in the arrays.
If n is a variable, it must be declared as an INTEGER.
The XFERB– (transfer block) subroutines move arrays from one place to another
without requiring DO loops. The n elements in array x are moved into array y. No
check is made to see whether these elements actually exist.
XFERBR is single or double precision, depending on its arguments.
XFERB– might be used, for example, to transfer the three elements VM(1), VM(2),
and VM(3) into the first three elements of the array RMD as follows:
CALL XFERBR(rmd = vm, 3)

Page B-6 ACSL Reference Manual


C. ACSL System Symbols

C.1 Introduction

Many system constants can be set at runtime with the SET command to control
printing, plotting, and integration. In order for a symbol to be accessed at runtime, the
name must not have been used in the program code.
Each system symbol is listed below along with its type, default value, and description.
The value set by the user must agree with the symbol in type; i.e., integer into integer,
logical into logical, floating point or integer into floating point, and character into
character. Plot units are either inches or double centimeters.
The first three characters of the symbols describe the action. The last three characters
describe the symbol group as follows:
- PLT plots in general
- PPL printer plots
- CPL continuous plots
- SPL strip plots
- FPL frequency plots
- PRN printed outputs
- ITG integration control
The symbols are listed below by group. An additional category describes miscel-
laneous symbols (logical units, title, etc.).

C.2 Plots in general


ALCPLT LOGICAL Automatic line color. Increments through the available colors (1, 2, 3, etc.) for each
TRUE curve on the plot. The mapping of the color numbers to actual colors depends on the
plot device. The default on VAX systems is FALSE.

CALPLT LOGICAL Continuous plots on the PLT unit when TRUE, as opposed to strip format (see
TRUE STRPLT).

DEFPLT LOGICAL Defer plots. The current plot is not drawn immediately so that subsequent plots can be
FALSE collected for the same plot. For example, this feature can be used to plot trajectories of
both missile and target on the same grid with the following commands:
SET DEFPLT=.TRUE.
PLOT /XAXIS=rm1, rm3
SET DEFPLT=.FALSE.
PLOT /XAXIS=rt1, rt3

The first PLOT command plots the missile trajectories with the X axis RM1. Then the
deferred plot restriction is lifted and the second PLOT plots the target trajectory RT2
versus RT1 and produces the output. One set of axes is drawn, with scales for the
variables plotted when DEFPLT is returned to FALSE. Be sure that the scales for all
the curves are the same, since it is not possible to tell from the plot if they are not.

ACSL Reference Manual Page C-1


C. ACSL System Symbols C.2 Plots in general

DEVPLT INTEGER Select plotting device driver for line or strip plots. The devices available at a particular
1 site can be specified by the system manager. See the document ACSL Sim User's
Guide for further information. The default list is as follows:
1 Standard graphic device for system
2 Neutral plot file (ASCII move/draw format)
3 Tektronix
4 Hewlett-Packard graphics language (HPGL)
5 Postscript
6 X-windows XplotDriver
7 LaserJet
8-9 reserved for future implementations
10... machine-specific devices; e.g., Regis for VAX, EGA for PC, etc.

DSCPLT CHARACTER Default starting character for symbols on plots. Printable characters are specified by an
'A' integer represenation; for example, 49 for '1', 65 for 'A', 97 for 'a'. Centered
symbols are specified by an integer corresponding to the table in section C.4; SET
DSCPLT=1 results in an octagon for the default symbol.

DPNPLT LOGICAL Draw plot number. A vertical text string containing a plot number (sequential from the
TRUE start of the session) and the date and time at which the session was initiated is drawn at
the right of the plot image when DPNPLT is TRUE.

FTSPLT LOGICAL Flyback trace suppression. If a number of parametric runs have been made (either
FALSE when NRWITG is TRUE or by cycling between the INITIAL and TERMINAL
sections), they can be plotted on one plot. If FTSPLT is TRUE, plotting is suppressed
and the plot symbol incremented on flyback. This eliminates a line running from the
end of one curve to the beginning of the next one and increments symbols and/or
colors for each curve (if they have activated).
The flyback is determined from the first variable on the PREPARE list. When the
difference between successive values becomes more negative than its previous value,
it is assumed that a new run has started. The independent variable is normally
specified first on the PREPARE list.

GLTPLT INTEGER Grid line type. The type is specified by three integer digits ijk, where i is the line style
000 (0 solid, 1 dashed, and 2 dotted), j is extra width, and k is the device-specific color.

NPPPLT INTEGER Number of plots per page when invoking the PLOT /ALL command.
3

PPOPLT LOGICAL Portrait plot orientation. When TRUE, plots are rotated counterclockwise ninety
FALSE degrees. This option is normally used only with hardcopy devices such as Postscript or
Hewlett-Packard pen plotters; it is not appropriate for screen plots. Rotating plots
generally results in the X axis being along the longer side of the page.

PRNPLT LOGICAL Printer (character) plots on high volume print device when TRUE. These plots are
FALSE generated by printing characters for the data points to form the curve. They are not to
be confused with continuous or strip plots being sent to a dot matrix or other printer.

STRPLT LOGICAL Strip plots on the PLT unit when TRUE. Strip plots are normally drawn with one
FALSE variable per axis, and they are stacked from the bottom up in the order given on the
PLOT command line.

TBRPLT INTEGER Baud rate of the line plot device, normally needed only for old Tektronix plotters.
100

Page C-2 ACSL Reference Manual


C.4 Continuous plots C. ACSL System Symbols

XZPPLT REAL X axis zero point; i.e., the X coordinate of the plot origin in plot units to the right of
0.0 the lower left corner of the page. This variable is used with YZPPLT to position plots
on such applications as pen plotters. It remains in effect until explicitly changed.

YZPPLT REAL Y axis zero point; i.e., the Y coordinate of the plot origin in plot units from the bottom
0.0 of the lower left corner of the page. This variable is used with XZPPLT to position
plots on such applications as pen plotters. It remains in effect until explicitly changed.

C.3 Printer plots

NGXPPL INTEGER Number of points between grid lines in the X direction for printer plots. The default is
20 a grid every twenty printer lines.

NGYPPL INTEGER Number of points between grid lines in the Y direction for printer plots. The default is
10 a grid every ten printer columns.

NPCPPL INTEGER Number of points per character plotted on printer plots. This feature can be used for
1 placing time ticks on a phase plane plot; for example, with the following commands:
SET DEFPLT=.TRUE.
PLOT /XAXIS=x, y
SET DEFPLT=FALSE, NPCPPL=10
PLOT /XAXIS=x, y /CHARACTER='*'

The first PLOT plots Y against X using values recorded every communication inter-
val, but the output is deferred. The plot frequency is changed and the second plot is
plotted over the first, but with a different character, which thus flags every tenth point.

NPXPPL INTEGER Number of points in the X direction for printer plots. The default results in rectangular
100 plots; for square plots, set NPXPPL to six tenths of NPYPPL.

NPYPPL INTEGER Number of points in the Y direction for printer plots. For narrow terminals, the default
100 is reduced to fifty.

C.4 Continuous plots

CALCPL LOGICAL Color axis line for continuous plots; i.e., the Y axis is drawn with the color matching
TRUE the curve. The default for VAX systems is FALSE.

GRDCPL LOGICAL Draw grid lines from each tick mark on the continuous plot axes when TRUE. See
TRUE GLTPLT for options on type of line.

LINCPL LOGICAL Draw lines between data points on continuous plots when TRUE. If FALSE, only the
TRUE characters at the data points appear. Note that if both SYMCPL and LINCPL are
FALSE, no curve is drawn.

LTCCPL INTEGER Line length of TITLE in characters for continuous plots. This variable can be set to up
40 to the maximum number of characters for the complete title (480). The number of
characters in TITLE (NCTPRN, default 120) should be at least as large as LTCCPL.

ACSL Reference Manual Page C-3


C. ACSL System Symbols C.4 Continuous plots

LTFCPL LOGICAL Line type fragment for continuous plots. When TRUE, a one-inch sample of the plot
FALSE curve is drawn, with the same color, width, and style, just to the right of the name
string on the Y axis. If symbols are drawn on the curve, then the symbol is drawn in
the center of this line fragment.

NPCCPL INTEGER Number of points per character on continuous plots; i.e., a symbol is written every
10 NPCCPL points. This is useful for placing time ticks on phase plane plots.

PSFCPL REAL Plot scale factor for continuous plots. The overall size of the plot, including axes and
1.0 lettering, can be made smaller or larger by changing this factor.

SATCPL LOGICAL Suppress axis text on continuous plots. This feature allows the axes and tick marks to
FALSE be drawn but suppresses all numbers and labels, which is useful for speeding the
drawing in repetitive (usually draft or diagnostic) plots.

SYMCPL LOGICAL Plot symbols on the curve for continuous plots. Characters are specified with the
FALSE /CHARACTER switch. Characters are centered over the data points and correspond to
the normal FORTRAN letters and digits. The default characters start with A and cycle
through the alphabet and digits and then back through the alphabet, etc. Special
symbols are available using unquoted integers between 1 and 13 as follows:
The characters cycle through the special symbols when any one of the symbols is
specified. NPCCPL controls the number of data points between symbols.

TTLCPL LOGICAL Title on continuous plots. The content of the TITLE array is written at the top of each
TRUE plot. The default format is three lines of forty characters each. The number of
characters in the title is specified by NCTPRN and the line length of the title by
LTCCPL. The TITLE array is searched backwards from TITLE(NCTPRN) until a
non-blank character is found, thus eliminating blank lines. The title on a plot never
intrudes into the plot area.

XCICPL REAL X axis cross position (in plot units) on continous plots. This is the position on the X
0.0 axis where an extra Y axis is positioned. Only the axis is drawn in the plot area; the
text remains at the side, outside the plot area. If XCICPL is specified by a negative
number, the extra Y axis will be placed where X has a value of zero, if possible.

XINCPL REAL X axis length in plot units for continuous plots.


5.0

XTICPL REAL X axis tick increment (i.e., the distance between tick marks) in plot units for
1.0 continuous plots.

YCICPL REAL Y axis cross position (in plot units) on continuous plots. This is the position on the Y
0.0 axis where an extra X axis is drawn. Normally the X axis is at the bottom of the Y
axis, but an extra axis can be placed in the plot area. The text remains at the bottom,
outside the plot area. If YCICPL is specified by a negative number, the extra axis will
be placed where Y has a value of zero, if possible.

YINCPL REAL Y axis length in plot units for continuous plots.


5.0

Page C-4 ACSL Reference Manual


C.5 Strip plots C. ACSL System Symbols

YTICPL REAL Y axis tick increment (i.e., the distance between tick marks) in plot units for
1.0 continuous plots.

C.5 Strip plots

CALSPL LOGICAL Color axis line for strip plots; i.e., the Y axis is drawn with the color matching the
TRUE corresponding curve. The default on VAX systems is FALSE.

GRDSPL LOGICAL Draw grid lines from each tick mark on the strip plot axes when TRUE. See GLTPLT
TRUE for options on type of line.

LINSPL LOGICAL Draw lines between data points on strip plots when TRUE. If FALSE, only the
TRUE characters at the data points appear. Note that if both SYMSPL and LINSPL are
FALSE, no curve is drawn.

LTCSPL INTEGER Line length of title in characters for strip plots. This variable can be set to up to the
40 maximum number of characters for the complete title (480). The number of characters
in TITLE (NCTPRN, default 120) should be at least as large as LTCSPL.

LTFSPL LOGICAL Line type fragment for strip plots. When TRUE, a one-inch sample of the plot curve is
FALSE drawn, with the same color, width, and style, just to the right of the name string on the
Y axis. If symbols are drawn on the curve, then the symbol is drawn in the center of
this line fragment.

NPCSPL INTEGER Number of points per character on strip plots; i.e., a symbol is written every NPCSPL
10 points plotted.

PSFSPL REAL Plot scale factor for the strip plots. The overall size of the plot, including axes and
1.0 lettering, can be made smaller or larger by changing this factor.

SATSPL LOGICAL Suppress axis text on strip plots. This feature allows the axes and tick marks to be
FALSE drawn but suppresses all numbers and labels, which is useful for speeding the drawing
of repetitive (usually draft or diagnostic) plots.

SYMSPL LOGICAL Plot symbols on the curve on strip plots. The symbols are the same as those listed
FALSE under SYMCPL.

TTLSPL LOGICAL Title on strip plots. The contents of the TITLE array is written at the top of each plot.
TRUE The default format is three line of forty characters each. The number of characters in
the title is specified by NCTPRN and the line length of the title by LTCSPL. The
TITLE array is searched backwards from TITLE(NCTPRN) until a non-blank
character is found, thus eliminating blank lines. The title on a plot never intrudes into
the plot area.

XCISPL REAL X axis cross position (in plot units) on strip plots. This is the position on the X axis
0.0 where an extra Y axis is positioned. Only the axis is drawn in the plot area; the text
remains at the side, outside the plot area. If XCICPL is specified by a negative
number, the extra Y axis is placed where X has a value of zero, if possible.

XINSPL REAL X axis length in plot units for strip plots.


5.0

XTISPL REAL X axis tick increment (i.e., the distance between tick marks) in plot units for strip plots.
1.0

ACSL Reference Manual Page C-5


C. ACSL System Symbols C.6 Frequency plots

YASSPL REAL Y axis separation between successive strip plot axes stacked vertically.
0.5

YCISPL REAL Y axis cross position (in plot units) on strip plots. This is the position on the Y axis
1.0 where an extra X axis is drawn. Normally the X axis is at the bottom of the Y axis, but
an extra axis can be placed in the plot area. The text remains at the bottom, outside the
plot area. If YCISPL is specified by a negative number, the extra axis will be placed
where Y has a value of zero, if possible.

YINSPL REAL Y axis length in plot units for strip plots.


2.0

YTISPL REAL Y axis tick increment (i.e., the distance between tick marks) in plot units for strip plots.
1.0

C.6 Frequency plots

DFXFPL REAL Maximum phase change allowed during frequency sweep.


0.1

DTCFPL LOGICAL Draw two separate curves (i.e., stacked plots) for Bode plots.
FALSE

DWNFPL REAL Minimum multiplier to next frequency during frequency sweep. Read as delta omega
1.01 minimum. It must be greater than 1.0.

DWXFPL REAL Maximum multiplier to next frequency during frequency sweep. Read as delta omega
2.0 maximum. It must be greater than 1.0.

EMNFPL INTEGER Exponent minimum for marking of decade ticks on frequency and root locus plots.
-9

EMXFPL INTEGER Exponent maximum for marking of decade ticks on frequency and root locus plots.
9

EPDFPL REAL Distance tolerance for root locus curve. Zero signifies use of a tenth of the minimum
0.0 step size (SSNFPL). Read as epsilon distance.

EPFFPL REAL First stage of root locus convergence to this phase error in radians. Read as epsilon
0.1 phase.

FLTFPL INTEGER First line (i.e., phase curve) type can be changed on Bode plots to affect line style,
000 thickness, and color on some plot devices (see GLTPLT). Applies to first curve on
Bode plots, only line on all other frequency plots.

GRDFPL LOGICAL Draw grid on plot for frequency plots.


TRUE

LTCFPL INTEGER Line length of title in characters for frequency plots. This variable can be set to up to
40 the maximum number of characters for the complete title (480). The number of
characters in TITLE (NCTPRN, default 120) should at least as large as LTCCPL.

Page C-6 ACSL Reference Manual


C.6 Frequency plots C. ACSL System Symbols

NEDFPL INTEGER Number of edge divisions for test of root locus entry.
100

NESFPL LOGICAL No exponent symbols are written to identify decade ticks on frequency or root locus
FALSE plots. In complex cases, the exponents may interfere with the plot curves.

PSFFPL REAL Plot scale factor for frequency plots. The overall size of the plot, including axis and
1.0 lettering, can be made smaller or larger by changing this factor.

SATFPL LOGICAL Suppress axis text on frequency plots. This feature allows the axes and tick marks to
FALSE be drawn but suppresses all numbers and labels, which is useful for speeding the
drawing in repetitive plots.

SLTFPL INTEGER Second line (i.e., gain curve) type for Bode plots can affect line type, thickness, and
000 color on some plot devices (see GLTPLT).

SSNFPL REAL Step size minimum for root locus plots. Specifying zero signifies use of 0.4% of the
0.0 maximum step size (SSXFPL).

SSXFPL REAL Step size maximum for root locus plots. Specifying zero signifies using 5% of the
0.0 diagonal distance across the plot in the complex plane.

TKHFPL REAL Tick height for frequency or root locus plots. Decade points are marked by double
0.070 height ticks centered about the curve.

TTLFPL LOGICAL Draw title on frequency plots (see TTLCPL).


TRUE

XCIFPL REAL X axis cross position (in plot units) on frequency plots. The negative default value
-1.0 forces an extra Y axis to be positioned at the X axis zero, if possible (see XCICPL).

XINFPL REAL X axis length in plot units for frequency plots.


5.0

XTIFPL REAL X axis tick increment (i.e., the distance between tick marks) in plot units for frequency
1.0 plots.

YASFPL REAL Y axis separation between two Bode plots (phase and gain) when DTCFPL is TRUE
0.5 so that the phase and gain curves are drawn on two separate stacked plot areas.

YCIFPL REAL Y axis cross position (in plot units) on frequency plots. The negative default value
-1.0 forces an extra X axis to be positioned at the Y axis zero, if possible (see YCICPL).

YINFPL REAL Y axis length in plot units for frequency plots.


5.0

YTIFPL REAL Y axis tick increment (i.e., the distance between tick marks) in plot units for frequency
1.0 plots.

ACSL Reference Manual Page C-7


C. ACSL System Symbols C.7 Print data

C.7 Print data


DCVPRN LOGICAL Display changed variable. When set TRUE, both the old and new values of all
FALSE variables are listed as they are changed by a SET command.

HVDPRN LOGICAL High volume data to display unit. Normally, high volume data is written only to the
TRUE PRN unit; if HVDPRN is TRUE and the DIS unit is different from the PRN unit, the
high volume data (e.g., output from PRINT, DEBUG, etc.) is written to both units.

MALPRN INTEGER Maximum array length in DEBUG listing. Arrays longer than MALPRN are
10 suppressed in the DEBUG output. The last element in the array is listed to show that
the array is present and to indicate the array length.

NCTPRN INTEGER Number of characters in TITLE array. The TITLE can be set to up to 480 characters.
120

NPBPRN LOGICAL No page break during printout; i.e., no top-of-form headers to print (log) file.
FALSE

PCWPRN INTEGER Printer character width. Controls the width of the output in the print log file. If the
132 printer available has a narrow carriage, set PCWPRN to 80. PCWPRN is analogous to
TCWPRN, which controls terminal character width. When HVDPRN is TRUE,
TCWPRN controls the print log file width.

TCWPRN INTEGER Terminal character width; i.e., the line width of data written on the display (DIS)
80 logical unit. For batch oriented machines such as CDC, the default is changed to 132.
TCWPRN is analogous to PCWPRN, which controls the printer character width.
When HVDPRN is TRUE, TCWPRN controls the print log file width.

C.8 Integration control

CIOITG INTEGER Current integration order of variable order integration routines (IALG = 1 or 2). This
... variable is calculated by the program and may be OUTPUT or PREPAREd so that the
integration order can be monitored.

CJVITG LOGICAL Check Jacobian validity. A report is issued if the Jacobian is considered invalid.
TRUE

CSSITG REAL Current step size taken by the integration routine. This variable is calculated by the
... program and may be OUTPUT or PREPAREd so that the actual integration step size
can be monitored.

DPSITG LOGICAL Double precision states; i.e., when TRUE, the state variables are accumulated in
TRUE double precision. The default is FALSE on 64 bit computers.

ECSITG LOGICAL Errors based on current state. Determines whether the allowed errors for the variable
FALSE step integration routines are based on current state values TRUE or on the largest
values of the states so far.

FDEITG LOGICAL First derivative evaluation ensured to be on state trajectory. This is done automatically
FALSE for Runge-Kutta algorithms, but requires an extra calculation for the variable order
routines (IALG = 1 or 2). It is useful when examining debug dumps to know that the
state variable is on the state space trajectory when the first flag (ZZFRFL) is TRUE.

Page C-8 ACSL Reference Manual


C.9 Miscellaneous C. ACSL System Symbols

MXOITG INTEGER Maximum order of the integration algorithm may be specified between 1 and 6 when
6 using the variable order, variable step integration routines (IALG = 1 or 2).

NRWITG LOGICAL No rewind. When this flag is TRUE, the RRR (raw run record) data file (i.e., the file
FALSE containing the values logged for all the variables on the PREPARE list) is not rewound
at the beginning of a START or CONTIN command (the normal procedure). This
feature enables accumulation of data from sequential runs, which then can be printed
and/or plotted at the end of all the runs.

NXEITG LOGICAL No extra evaluations are calculated before each communication interval when this flag
FALSE is TRUE. It applies to all integration algorithms.

TJNITG REAL Threshold for flagging Jacobian nonlinearities; 1.0 effectively turns it off. In order to
0.2 see the results, CJVITG should be TRUE.

TSMITG LOGICAL Two sided matrix evaluation for the stiff integration algorithm (IALG = 2) to evaluate
FALSE the linearized state transition matrix. If the state equation is dx ⁄ dt = F(x), then the two
sided matrix is obtained from F(x+dx) and F(x−dx); the single sided matrix from F(x)
and F(x−dx). While the two sided matrix is more accurate than the single sided, it
requires twice as long to evaluate the complete matrix.

WEDITG LOGICAL Write event description when using the SCHEDULE operator for state events. This
TRUE data can be suppressed by setting WEDITG to FALSE..

WESITG LOGICAL Write error summary for variable order, variable step integration routines (IALG = 1
TRUE or 2). All the states, along with the count of the number of times each state controlled
the integration step size, are listed at the end the run. This data may be suppressed by
setting WESITG to FALSE.

WNDITG LOGICAL Write normal data during integration; i.e., basic information about the integration
FALSE process (slightly different for each integration algorithm) so that it can be followed.

WXDITG LOGICAL Write extra data during integration; i.e., Jacobian matrix, which is not written out
FALSE when WNDITG is TRUE because it can be very high volume depending on the
number of state variables.

C.9 Miscellaneous

CMD INTEGER Logical unit from which runtime commands are read. The allowed values depend on
4 the computer system and the installation. Generally, the command file is read from
unit 4, then control switches to the keyboard (unit 5).

DIS INTEGER Logical unit on which display data is written, including output from DISPLAY,
6 RANGE, and OUTPUT commands. The allowed values depend on the computer
system and the installation.

NDBUG INTEGER Number of debug dumps to be printed out. When NDBUG is greater than zero, a
0 debug dump is listed at each derivative evaluation and NDBUG is decremented by one
until NDBUG becomes zero.

PLT INTEGER Logical unit for line plot output (when CALPLT or STRPLT is TRUE). The allowed
6 values depend on the computer system and the installation.

ACSL Reference Manual Page C-9


C. ACSL System Symbols C.9 Miscellaneous

PRN INTEGER Logical unit on which high volume data is written. All data written on unit DIS is
9 echoed on unit PRN if DIS and PRN are different. In addition, printer plots, PRINT
command output, debug dumps, and most ANALYZE output are written only on this
file unless HVDPRN has been set TRUE. The allowed values depend on the computer
system and the installation.
To prevent data from accumulating on the log file, set PRN=DIS.

RRR INTEGER Logical unit on which intermediate data (raw run record) is written. The allowed
8 values depend on the computer system and the installation.

SAVE INTEGER The ACSL system uses logical unit 3 for SAVE and RESTORE operations. This
3 logical unit should be avoided by users.

TITLE CHARACTER The TITLE array is a text string enclosed in quotes. It can be up to 480 characters
blank long. The title is printed at the top of each plot and each page of printout.
SET TITLE='Missile Longitudinal Dynamics'

The default layout for the title on plots is three lines of 40 characters per line. On any
plot header, the TITLE array is searched backwards from TITLE(NCTPRN) until a
non-blank character is found; thus, blank lines are eliminated. System symbols
NCTPRN (number of characters in TITLE), LTCCPL, LTCSPL, and LTCFPL (length
of TITLE in characters for continuous, strip, and frequency plots, respectively) are
used to control the title format.
It is not necessary to always start at the beginning of the TITLE array. Any character
in the array can be specified as the starting point; for example, to specify data starting
on the second and third lines on a plot title:
SET TITLE(41)='Step in Fin'
SET TITLE(81)='Nominal CG'

This is useful when some parts of the title remain the same from run to run while
others change with varying parameters.
The entire array can be cleared by using two single quotation marks enclosing a blank
(there must be blank between the quotes) as follows:
SET TITLE=120*' '

Page C-10 ACSL Reference Manual


D. ACSL Error Messages
The ACSL error messages (from both translator and runtime executive) are given
below in alphabetical order.
See also Chapter 7 for explanations of ACSL debug dumps and of messages from
variable step integration algorithms and Jacobian evaluations.

.... NAME already defined


This error occurs in using the LISTD function to process a set of dictionary
definitions. It results when the same variable name has appeared previously and is
often caused by omitting continuation digits from column ten (10) in long definitions.

.... NAME(ddd) is an array and must be accessed by specific element


An X axis variable was specified that was an array. The X axis must be a single
variable and so should be specified as an array element using parentheses –
/XAXIS=va(2,3) rather than /XAXIS=va, for example.

.... NAME is a scalar, not an array


An array reference was used although the variable NAME is a scalar.

"NAME" passed to AGETC is of wrong type


"NAME" passed to AGETD is of wrong type
"NAME" passed to AGETI is of wrong type
"NAME" passed to AGETL is of wrong type
"NAME" passed to AGETR is of wrong type
"NAME" passed to APUTC is of wrong type
"NAME" passed to APUTD is of wrong type
"NAME" passed to APUTI is of wrong type
"NAME" passed to APUTL is of wrong type
"NAME" passed to APUTR is of wrong type
After AGETi or APUTi looked up "NAME" in the dictionary, it determined that it
was not of the correct type and so refused to perform the copy operation.

AGET has been replaced at level 10 with separate routines as follows


AGETR - real
AGETI - integer
AGETL - logical
AGETD - double
AGETC - character
The use of AGET from an ACSL Level 9 model should be changed to use one of the
routines with a specific type. The reason for this is the different lengths of the
arguments. Real, integer, and logical are normally the same size, but double is twice as
long and character may be any length.

ACSL Reference Manual Page D-1


D. ACSL Error Messages AGETC can-t find "NAME".

AGETC can-t find "NAME".


AGETD can-t find "NAME".
AGETI can-t find "NAME".
AGETL can-t find "NAME".
AGETR can-t find "NAME".
The argument to AGETi identified by "NAME" is not in either the user program
dictionary or in the ACSL system dictionary.

APUT has been replaced at level 10 with separate routines as follows


APUTR - real
APUTI - integer
APUTL - logical
APUTD - double
APUTF - character
The use of APUT from an ACSL Level 9 model should be changed to use one of the
routines with a specific type. The reason for this is the different lengths of the
arguments. Real, integer, and logical are normally the same size, but double is twice as
long and character may be any length.

APUTC can-t find "NAME".


APUTD can-t find "NAME".
APUTI can-t find "NAME".
APUTL can-t find "NAME".
APUTR can-t find "NAME".
The argument to APUTi identified by "NAME" is not in either the user model
dictionary or in the ACSL system dictionary.

Argument NAME doesn-t match any keyword


The argument NAME that is to be used as a substitutable parameter in the
PROCEDURE invocation at runtime doesn't match any keyword used in the
definition. To list the valid keywords, type:
DISPLAY/PROCEDURE=procedname

Argument NAME is given no value and has no default value


The argument NAME in the PROCEDURAL definition has no default value and is not
specified in the PROCEDURE invocation. To list argument keywords and default
values, type:
DISPLAY/PROCEDURE=procedname

Argument NAME is not defined in procedure definition header.


Replaced by null string
The variable NAME has been marked by an ampersand (&) for substitution but does
not appear in the PROCEDURE header. Check the variable names in the header.

Argument number N cannot be positional after a keyword has been used


Once a keyword substitution argument has been given, all the following arguments in
the PROCEDURE invocation must be by keyword substitution, not position.

Page D-2 ACSL Reference Manual


Bad break data count D. ACSL Error Messages

Argument number N doesn-t match the procedure definition


The PROCEDURE definition has fewer arguments than are used in the invocation. To
check the PROCEDURE definition, type:
DISPLAY/PROCEDURE=procedname

Array element NAME must be a scalar


A symbolic array element name corresponds to a dimensional array. Array elements
must be either integer literal constants (1, 3, 12, for example) or scalar variable names
that contain an integer. For the following statement:
SET A(I,J,3) = 12.5

I and J must have been declared as integers in the program since the default is for
every variable to be of floating point type.

Array element NAME must be integer type


The array element NAME must be declared as a INTEGER within the program If a
variable is not specifically typed, it will be the default REAL or DOUBLE
PRECISION, depending on the global translation mode.

At least two output variables are needed in order to plot during run
When plotting during a run, at least two variables must be specified in the OUTPUT
list. The first variable on the list is the X axis variable; all other variables are
considered Y axis variables.

Attempt to close standard output (or logical unit number N) ignored


The PLOT/CLOSE command closes the unit associated with the ACSL system symbol
PLT. If this is six (or equal to DIS), the request is ignored.

Attempt to free an already free block in call to "ZZHDIS"


An internal system error. Please report to your systems staff with documentation.

Axis scales incorrect for log plots on NAME


This error occurs when logarithmic scale values are specified to be either negative or
zero. Logarithmic scales must all be positive. ACSL's automatic scaling chooses a low
value for logarithmic scales which is the power of ten below the lowest value of the
variable being plotted; e.g., if the variable to be plotted has a lowest value of 0.07,
automatic scaling chooses a low value of 0.01. If a negative or zero scale is forced
because of the data, you can override the automatic scale with /LO to force a positive
(greater than zero) scale.

Bad break data count


The number of arguments specified in the TABLE statement is not 1, 2, or 3, or else
the number of breakpoint integers given does not correspond with the number of
arguments.

ACSL Reference Manual Page D-3


D. ACSL Error Messages Bad function data count

Bad function data count


The number of data items (i.e., items between slashes) in the TABLE statement does
not add up to the total length expected; the total should be the product of the
dimensions plus the sum of the dimensions.

Buffer is not empty on call to zzrcsb: system error


Please report to systems staff with documentation.

Buffer overflow from "ZZGRXM". System error


This error occurs when the line buffer used for transmitting graphics commands
overflows. Report to systems staff with documentation.

Can only release state. Variable is NAME


The variable specified to be released by NAME is not a state variable. Only state
variables can be specified in the ANALYZE/RELEASE subcommand.

Cannot interface to MATLAB


An error ocurred when attempting to start MATLAB. Test that MATLAB can be
started from the command line from your current directory and the current
environment. The current directory must be writeable since a file acsl_matlab.tmp is
written with all the simulation data to be passed.

Can-t find array element in NAME


A reference has been made to a particular array element that does not exist or has
already been deleted by a preceding ANALYZE /FREEZE command.

Can-t define a procedure within another procedure


Within a PROCEDURE definition, another definition (i.e., PROCEDURE keyword) is
illegal. PROCEDUREs can contain invocations of other PROCEDUREs to an
unlimited nesting level.

Can-t find breakaway angle


The iteration to find the angle of the locus leaving the breakaway point has failed. Try
reducing the step size. If the ANALYZE /LIST flag is TRUE, the breakaway point is
identified on the high volume output unit prior to this message.

Can-t find data block name NAME


The /DATA block NAME must be defined in a DATA statement before being invoked
for plotting.

Can-t find NAME


The NAME does not appear in the dictionary. The message may be in response to SET,
DISPLAY, OUTPUT, PREPARE or various other runtime commands. With
RESTORE, a name was given to restore but could not be found on the file. Check the
state of the model when the SAVE file was made and whether the SAVE command
had a reduced set of names. If no names are given on the save command, all variables
in the model are saved.

Page D-4 ACSL Reference Manual


Conflicting data types D. ACSL Error Messages

Can-t find the ACSL_ROOT path in order to pick up the ACSL help file
The ACSL home directory is needed in order to pick up the location of help files (and
other support routines). When invoked via the executable file name, it is difficult on a
Unix system to find the home directory. We look for a specific name 'acsl'
command on the $PATH, but sometimes the command has been changed (acsl10
versus acsl11 for instance). If this message occurs, use the -r switch on the acsl
command – or whatever is in use as an equivalent – to run the model. Another way is
to define an environment variable ACSL_ROOT that specifies the home acsl tree.

Can-t group poles correctly. System error


The algorithm for grouping the poles to define a multiple effective pole has failed.
Report to systems staff with documentation.

Can-t satisfy error criterion for state number N in block N


The integration algorithm has decided it needs to take a step smaller then MINT to
keep the largest error within bound. The run terminates unless ERRTAG has been
specified. If you have specified the name of an error flag with the ERRTAG
command, the value of this flag is changed to TRUE (from its preset of FALSE) and
the run continues.

Can-t use a character variable NAME in list


It is not possible to PREPARE character variables. The file can only hold floating
point, integer, or logical variable values.

Can-t use a character variable NAME in list


In defining a data command a variable was use which was CHARACTER type.
CHARACTER type variables cannot be added to the PREPARE list and so cannot be
plotted.

Communication interval negative or zero


The communication interval (default name CINT) can not be either negative or zero.
The value of the variable is tested immediately after leaving the DYNAMIC section
code, when control is first transferred to the integration control subroutine ZZINTG.

Condition of Jacobian too low to proceed


A condition number is evaluated for the matrix when inverting the Jacobian during the
TRIM process; the message is produced if this condition number when added to unity
still gives unity. The results depend on machine precision; for example, on a VAX the
condition is approximately 1.0E-7, and on a CDC about 1.0E-13.

Conflicting data types


The variable indicated in the error message is being used in a way that conflicts with
an earlier usage. This error sometimes results from neglecting to specify the variable
type (e.g., LOGICAL). Some examples of common incorrect usage include:
1) A label as a variable
2) A variable in two different type declarations
3) State or initial condition variables in logical or integer type statements
4) Duplicate initial condition variable names in separate INTEG statements
5) Duplicate name for derivative and state in separate INTVC statements

ACSL Reference Manual Page D-5


D. ACSL Error Messages Conflicting label NAME

Conflicting label NAME


The item indicated in the error message is either a variable being used as a statement
label or else a previously defined label.

Control index of N is outside control vector size of N


The /CINDEX parameter value is pointing to a position outside the list of control
variables. Either define a control variable (if none exists) or reset the control index to
within range (default is 1).

Control list length of N is not equal to observable list length of N


Overall state matrix must be square
In attempting to trim, the number of adjustable variables (i.e., unfrozen states) plus the
number of controls must equal the number of variables to be driven to zero (i.e., the
derivatives of the unfrozen states plus the number of observables).

Convergence to local minima. Residual is N


This error occurs during TRIM when the incremental state movements are all less than
the allowable errors per state and the derivatives have still not been forced to zero. The
situation can result if MU becomes large. One solution is to reduce /FRACPM (default
1.0) or remove the test entirely by setting /FRACPM to zero.

CTRL-C linkage not implemented


On some sytems there is no linkage to the CTRL-C program.

Data definition not terminated prior to end


Data definitions must be terminated with an END statement. The end-of-file was
encountered in reading in a data definition without seeing the terminating END.

Data item missing on command line


A data item is expected and the command line ends. This message would be produced,
for example, if the data items 5 or 20 were left off the following input lines:
SET a = 5
OUTPUT/NCIOUT = 20

Data list has N items and must be an integer multiple of argument count N
The data values given in a DATA block definition must be an integer multiplier of the
number of names in the block. These are usually time histories and every named
variable must have the same number of data points.

Data list must terminate with "END"


An end-of-file was found on the command input file before the END statement that
must terminate a DATA definition.

Page D-6 ACSL Reference Manual


End of input. No file to return to, stopping D. ACSL Error Messages

Data values restored into scalar model variable


Too many values have been RESTOREd into the named program variable, either too
many array elements or a file variable that is an array with the same name as a pro-
gram variable that is a scalar. This message implies that the program may have been
changed since the file was SAVEd and the RESTORE operation may not be valid.

Derivative function evaluation not repeatable for row number N


The state was changed, probably by direct assignment, during the evaluation of the
Jacobian for the Gear's stiff integration algorithm. Each state is perturbed in turn, first
plus, then minus, then plus again. If the perturbed state value is not identical at both
derivative evaluations with the positive perturbation, this message is produced.

Derivative no. N not calculated


The nth derivative in the state vector is not calculated in the initial evaluation of the
DERIVATIVE section. This is determined by setting all derivatives to a particular
number before the evaluation, then checking to see if they have changed during the
evaluation. This message generally indicates that a derivative calculation is being
skipped over. The derivatives are listed in order in DEBUG and DISPLAY/ALL
listings.

Dimension list exceeds 128 integers: System error


Please report to systems staff with documentation.

Dimension number N shouldn-t exceed N


The dimension number N in a array reference is larger than the definition. For
example, if A is declared by:
DIMENSION a(5, 6, 7)

and the reference is:


SET a(4, 12, 1) = 5

then this message is produced since the 12 exceeds the second dimension size of 6.

Dimensions already set


The statement indicated attempts to define the dimensions of a previously
dimensioned array.

End of command file encountered


An end-of-file has been sensed on the file identified by logical unit CMD. The file is
closed and control reverts to the previous file in use.

End of input. No file to return to, stopping


An end-of-file was encountered on the input stream and no file was available to switch
to. It could be a batch mode run so there is no interactive terminal to which control can
be transferred.

ACSL Reference Manual Page D-7


D. ACSL Error Messages Equivalence error

Equivalence error
This error is usually caused by not realizing the special place occupied by the first
variable in the EQUIVALENCE list, which is used, in the ACSL sense, as a primary
variable. This variable must always appear first on the list for any subsequent
EQUIVALENCE statements into the same array. Another cause is equivalencing the
same secondary variable to two different primary variables. System variables such as
CINT or MAXT, and state, derivative, and initial condition variables must be given as
primary variables.

Error after NAME


Some sort of syntax error has been determined after NAME appears in the command
statement. Trying to specify variables with the incorrect type (integer NCIOUT by a
real number, /CHARACTER as a logical, for instance) is a common cause of this error.

Error assigning SYS$OUTPUT


This error occurs when assigning a channel for SYS$OUTPUT inside subroutine
ZZGRXM, which transmits graphics characters for plots.

Error during plot data output


This error occurs inside subroutine ZZGRXM when transmitting graphics commands
to the plotter.

Error in data following file variable NAME


Check the value corresponding to the variable NAME in the text file the RESTORE is
reading.

Error in dimension after file variable NAME


Check the dimension used for variable NAME in the text file the RESTORE is reading.

Error in dimension following NAME


The dimension is incorrect for variable NAME.

Error in eigen analysis routine. Error number is N


An error was made in trying to determine the eigenvalues of the Jacobian matrix. The
number gives the eigenvalue at which the QR iteration in the EISPACK routine HQR
or HQR2 fails.

Error in using or specifying increment after NAME


The actual increment value is valid only after a name defined as a /CONTROL
variable and it must be a floating point (or integer) variable. Specifying /INC after
/OBSERVE produces this message.

Error in zero finder routine. Error number is N


The QZ algorithm failed to converge in evaluating the numerator polynomial roots.
Generate the elements of the A, B, C, D matrices with the /JACOBIAN subcommand
and check the results for reasonableness.

Page D-8 ACSL Reference Manual


Errors after NAME D. ACSL Error Messages

Error listing variable NAME


The dimension is not compatible with model dimensions of NAME(i,j,...)
The list routine has been passed a dimension value that is incompatible with the
dimensions of the variable specified in the program.

Error number N in eigen analysis routine


The eigenvalue finder has reported an error at the nth eigenvalue. This is normally a
failure to converge in the EISPACK routines HQRZ or HQR2 (See Matrix Eigensys-
tem Routines - EISPACK Guide by B.T.Smith et al, Springer-Verlag, New York 1976)

Error reading from binary file number N


The read of the RRR file has failed. he RRR file is the file written to during a
simulation run of all the values of the variables in the prepare list and then this data is
read back with any subsequent PLOT, PRINT, and RANGE commands.

Error reading line from file FILENAME (IOSTAT = nnn) *****


In attempting to restore data, an error was encountered. Consult the local Fortran
documentation for the meaning of the IOSTAT integer listed. It is at the target
statement label for the error jump that the IOSTAT value (ios) is listed. The read
statement is of the form:
read(lunscr, end=530, err=995, iostat=ios) (b(j), j = jpmn, jpmx)

Error reading line from file NAME


The RESTORE command fails in reading the next (which may be the first) line of the
file although the OPEN was successful.

Error return from DASSL integrator: idid = aaaa


The following list the possible values for the parameter:
idid= 1 --
the step was completed successfully
idid=-6 --
the error test failed repeatedly
idid=-7 --
the corrector could not converge
idid=-8 --
the iteration matrix is singular
idid=-9 --
the corrector could not converge.
There were repeated error test failures on this step.
idid=-10-- the corrector could not converge because ires was equal
to minus one
idid=-11-- ires equal to -2 was encountered, and control is being
returned to the calling program

Error writing to binary file number I


An error has shown up in writing out the RRR file that is recording all the simulation
as the model continues. Check that there is sufficient disk space to accomodate the
file. Check the current size of the file (default name model.rrr).

Errors after NAME


An error occurred after the string NAME. Check for correct switch value (e.g.
/XHI=3.0) or data type. This message comes after the complete line has been analyzed
for correct syntax and is a semantic error.

ACSL Reference Manual Page D-9


D. ACSL Error Messages Event list can only be written on a binary file.

Event list can only be written on a binary file.


/NOBINARY changed to /BINARY
A request was made to write the event list (i.e., SAVE/EVENTS) which requires that
the SAVE file be written in binary mode.

Event restoration requested but but no event list saved on file FILENAME
The restore command was requested via /EVENTS but there were no events recorded
in the save file. Go back to the save command and add the /EVENTS switch to ensure
that the current event list is added to the file data.

Event vanished. Last value assumed to be zero crossing time


A zero crossing event has been signalled, but all three points evaluated are now on the
same side of zero. This error can occur if the derivatives are not pure functions (i.e.,
not repeatable) of the state variables.

File name must be quoted now


The file name for the Jacobian matrices must be a quoted string. At previous levels
(9B and below), the file name had to be an unquoted string. Now use, for example:
ANALYZE/JACOBIAN='jacobfile1'

The number of characters allowed for the file name is machine-dependant.

File name should be quoted


This error occurs when using the SAVE/RESTORE commands. The argument for the
SAVE/RESTORE commands should be a valid file name in quotes; e.g.,
SAVE/FILE='file1.sav'

Valid file names start with a letter and follow with letters or digits. The number of
characters in a file name is machine-dependent.

File not found NAME


The named INCLUDE file does not exist.

File variable NAME exceeds dimension of model variable


The variable NAME in the RESTORE file has larger dimensions or more dimensions
than the same variable name defined in the model. This usually results from saving a
model condition and then trying to load back a data file from a previous version of the
program. Note that any change to the program code usually changes all the ACSL
internal variable assignments (those with the form Znnnnn).

Function evaluation not repeatable, row N


See Chapter 7 for discussion of this informational message.

Help not available


On some systems, the ACSL help system is not available.

Page D-10 ACSL Reference Manual


Illegal ic dimension D. ACSL Error Messages

HP Laser plot driver not available. Change DEVPLT


On some machines, the HP laser driver is impossible to implement.

IGET has been replaced at level 10 with separate routines as follows:


AGETR - real
AGETI - integer
AGETL - logical
AGETD - double
AGETF - character
See AGET.

Illegal algorithm number I. Algorithm changed back to default


The integration algorithm (default name IALG) number of value I is not allowed. The
algorithm is changed back to the default of Runge-Kutta fourth order (IALG=5).

Illegal block combination


An ACSL block delimiter (PROGRAM, INITIAL, END, etc.) was encountered out of
sequence.

Illegal command word


This error occurs when the command word starting the statement is neither a standard
ACSL runtime command nor a PROCEDURE name established by the user. Check
the spelling and any abbreviation used. Try spelling out the command completely.

Illegal data in discrete


The specification of algorithm (IALG), maximum step size (MAXT), or number of
steps per communication interval (NSTP) within a DISCRETE section is illegal.

Illegal data type following NAME


This error occurs when the characters following NAME do not agree with the type of
name; i.e., REAL, DOUBLEPRECISION, LOGICAL, INTEGER, CHARACTER.

Illegal derivative definition


Derivative arrays are allowed only in INTVC statements (i.e., not in INTEG
statements).

Illegal handle value of N in call to "ZZCHDM". System error


Illegal handle value of N in call to "ZZHDIS". System error
Illegal handle value of N in call to "ZZSHE". System error
Illegal handle value of N in call to "ZZVHE". System error
This message results from a system error in the ACSL translator. Report to systems
staff with documentation.

Illegal ic dimension
Initial conditions may not be dimensioned when they are used in INTEG statements.
When they are used in INTVC statements, the dimensions must match the dimensions
of the state and derivative variables.

ACSL Reference Manual Page D-11


D. ACSL Error Messages Illegal integration statement

Illegal integration statement


The syntax of the INTEG statement does not match the required syntax. INTEG has
two arguments (derivative and initial condition). The following statement, for
example, would produce this message:
Y = INTEG(A, B, C)

The initial condition may be an expression only if it is entirely enclosed in


parentheses. The derivative in an INTVC statement must be a variable name; it cannot
be an expression.

Illegal use of STANDVAL


Attempt to specify STANDVAL for a name that is not a macro parameter.

Incompatible "PREPARE" list size


Data file written with N variables. Current list has N
The PREPARE list has been changed between the previous START or CONTINUE
that wrote the RRR file and the current list that is being used to read the RRR file now.
Either respecify the PREPARE list (PREPARE/CLEAR removes the previous list) or
issue a START command, which writes over the old RRR file and makes a new one
consistent with the current PREPARE list.

Incorrect dimensions for MATLAB variable NAME


On returning to an ACSL run from a MATLAB sequence, the variable NAME to be
restored into ACSL was found to have different dimensions. This error is usually
produced by a recalculation of NAME within MATLAB in such a way that it given a
different dimension. It had the correct dimension on entry to MATLAB since this was
set from the ACSL model dictionary.

Independent variable changed in Jacobian evaluation NAME


This error occurs when a state has been modified in the DERIVATIVE section used to
calculate the Jacobian. Since the Jacobian evaluator uses numerical perturbation of the
unfrozen states, any other modification invalidates the calculation.

Independent variable value N changed in Jacobian evaluation


The unfrozen states and control variables are considered one long vector. This
message points to the nth element in the vector as having its value calculated. Use
dummy inputs to summing junctions that can be defined in CONSTANT statements as
named /CONTROL variables.

Index of N is outside dimension of M for variable NAME


An array element from the RESTOREd file is outside the current dimension of the
program variable. This message implies that the program may have been changed
since the file was SAVEd and the RESTORE operation may not be valid.

Page D-12 ACSL Reference Manual


Integration step size negative or zero D. ACSL Error Messages

Index of I is outside limits of scalar variable NAME


In restoring data from a file, a variable has been found defined on the file as an array,
but in the current model it is a scalar. Check changes that have been made to the model
between the time when the data was SAVEd and the current attempt to RESTORE.

Input dimension to "ZZOFST" is undefined: System error


Please report to systems staff with documentation.

Insufficient area for DELAY function


This error occurs when the array length specified in a DELAY function is too small to
accommodate all the data points needed, usually when the run goes through a region
requiring a very small step size. Each integration step saves a data point, so memory
requirements can become quite large.

Insufficient characters given to identify NAME


The ACSL runtime command or switch cannot be identified uniquely by the string
NAME. Provide more characters.

Insufficient data
This error occurs when a statement terminates while still awaiting data.

Insufficient region for translation


This error is caused by insufficient available memory for ACSL to attempt translation.
It is always fatal. Consult the document ACSL Sim User's Guide for the procedure to
increase memory size.

INTEG not in sort block


Integration statements must be in a sorted block (i.e., an implicit program or else a
DERIVATIVE section of an explicit program) rather than the INITIAL, DYNAMIC,
or TERMINAL section. See Chapter 3 further details on program structure. The error
is usually caused by an END mismatch that terminates a block inadvertently, but may
also be caused by an integration statement inside a PROCEDURAL block nested to
level two or higher. Derivative values can be calculated inside PROCEDURAL
blocks, but then should be integrated outside the blocks.

Integer is too big for machine. Using N


This error occurs when a literal integer exceeds the value of the machine register. On
CDC machines this, is 281474976710655; on VAX machines, it is 2147483647.

Integration step size negative or zero


The actual step size used by the integration routine has become negative or zero. The
step size is obtained by taking the minimum of the time left to an event, the maximum
step (MAXT), and the communication interval (CINT) divided by NSTP.

ACSL Reference Manual Page D-13


D. ACSL Error Messages Invalid DISCRETE block N referred to in event no. I

Invalid DISCRETE block N referred to in event no. I


The variable name identifying the DISCRETE section has been changed in some way
so that its value in memory, which should be an integer between one and the number
of DERIVATIVE and DISCRETE sections, is outside this range or else is associated
with a block that is not a DISCRETE section (e.g., may be a DERIVATIVE section).
DISCRETE sections are identified by an ALGORITHM of zero.

Jacobian determinant zero, can-t trim


This error occurs when the /TRIM subcommand of ANALYZE finds that the Jacobian
has a zero determinant and so the Newton-Raphson iteration cannot proceed. The
solution is to FREEZE appropriate states prior to invoking /TRIM.

Jacobian evaluated. Condition number is N


The condition of the Jacobian is effectively null; i.e., almost singular and so cannot be
inverted. The condition is calculated where 1+ε/50 is just distinguishable from 1.0.

Jacobian nonlinear measure for row M and column N is X


See Chapter 7 for discussion of this informational message.

License manager failure


An attempt was made to communicate with the license manager checkout process
which is run as a child of the model. This message is produced if the process is killed
accidentally.

Line plot library not loaded


This error occurs when line (continuous) plots (PLOT with CALPLT=.TRUE. or
STRPLT=.TRUE.) are requested without instructing the loader or link-edit program to
attach the appropriate device driver. See the ACSL Sim User's Guide document for a
list of devices available and the system commands required.

Linear analysis routine not included


This error occurs when the runtime command ANALYZE is invoked without ensuring
that the appropriate routines are present. On some machines, the default is to omit the
routines that handle the ANALYZE command in order to save memory and load time.
See the ACSL Sim User's Guide document for the systems commands required to
instruct the loader or link-editor to link in the appropriate modules.

Linkage not implemented


Linkage to the control analysis program is not implemented on this computer.

List doesn-t contain NAME


This error occurs with ANALYZE, when one of the subcommands is searching for a
variable on a list. Some of the subcommands search only selected lists; for instance,
FREEZE applies only to state variables and so cannot locate any variable not a state.

Logical unit n is not open


An attempt was made to close a file that was not open.

Page D-14 ACSL Reference Manual


Multiply defined symbol D. ACSL Error Messages

Logical unit number must be greater than zero less than I


A logical unit number was used that is outside the range of logical unit numbers for
this particular system. Try the FILE command, which eliminates the need for logical
unit numbers to be specified.

Macro argument error


This error occurs when attempting to invoke a macro, as the result of an error in the
macro definition of the arguments, such as there being no computed argument or more
computed arguments than listed in the macro definition header.

Macro not defined


This error occurs when attempting to use a macro that has not been defined. The
syntax of the statement indicates a macro is being called, but the macro is not found in
the macro file.

Macro statement order error


This error occurs during macro expansion. No standard value has been set for an
unspecified macro argument, or else an attempt has been made to use the dimensions
of an undimensioned argument.

Macro termination error


The MACRO END statement is missing from the macro definition.

MATLAB variable NAME has imaginary part


In reading variables in from MATLAB, it has been found that one of the ACSL
variables now has an imaginary part. This error can occur only by recalculating the
variable within MATLAB.

Merror/Xerror on non-state variable


XERROR and MERROR apply only to state variables. For your variable name in a
macro operator such as REALPL to be considered a state, the operator must be
invoked in the standalone form; for example:
REALPL(st = p, x, ic)

Missing derivative statement


An INTEG statement is missing for some element of a state array.

Model variable NAME has no dimensions


A variable NAME restored from a file has dimensions, whereas the program variable
does not. This error is usually caused by a change in program code after the previous
SAVE command.

Multiply defined symbol


The error occurs in a sorted program or section. The named variable has previously
been assigned a value. The problem is often with an array, since the sorting procedure
does not distinguish between different elements of an array. A PROCEDURAL block
may be used to handle different elements of an array in different statements.

ACSL Reference Manual Page D-15


D. ACSL Error Messages Name NAME already in dictionary

Name NAME already in dictionary


This error occurs in using utility BLDDCT to extend to the ACSL dictionary, when an
attempt is made to add a name already present in the dictionary.

Name for PROCEDURE not given or illegal


This error occurs in a runtime PROCEDURE definition if the name of the
PROCEDURE has been omitted or is not of the correct form (i.e., alphanumeric
characters starting with a letter).

Name or element NAME not on OUTPUT list


One of the commands accessing the OUTPUT list (START, CONTINUE) contains a
variable name not included in the original OUTPUT command. This error usually
occurs when specifying plot scales and line styles.

Name or element NAME not on PREPARE list


One of the commands accessing data on the PREPARE list (PLOT, PRINT, RANGE,
etc.) contains a variable name or array element not included in the original PREPARE
list; the following sequence, for example, produces this error message.
PREPARE Y(2), Y(3)
PLOT Y(1)

Need a name first


This error occurs when modifiers to plot variables precede the name of the variable.
Since Y axis plot modifiers apply to the variable name immediately to the left on the
command line, the name must appear first. The following, for example, is incorrect:
PLOT /LO=0, /HI=5, Y1

This message also appears if modifiers apply to a variable that has been left off the
PREPARE list.

Negative delay value of R


The DELAY operator has been asked to provide a negative delay time, a physical
impossibility. Check the program; there could be flow reversal in a pipe model.

No active block to modify with NAME


The qualifiers /LO, /HI, /TYPE, and /CHARACTER need to have a name or active
block defined first since they qualify variable names to their left.

No assigned variable defined


Attempt to perform arithmetic operation (MACRO INCREMENT, DECREMENT,
etc.) on an assigned variable before specifying the assigned variable with MACRO
ASSIGN.

No equation depends on variable N


A state or control variable N (considering unfrozen states and controls as one
contiguous vector) has no influence on any state derivative or observable, resulting in
a zero column in the A, B, C, D matrix group. The name of the state or control

Page D-16 ACSL Reference Manual


No right sibling D. ACSL Error Messages

variable can be found from the ANALYZE/JACOBIAN operation, which lists the
states and control vectors by name separately.

No free logical unit available between N and N


The file command has run out of logical unit numbers to open. The remedy is to close
some of the open files.

No match for ACSL_PLT plot device NAME


Permissible devices are the following:
1 Standard graphic device for system
2 Neutral plot file (ASCII move/draw format)
3 Tektronix
4 Hewlett-Packard graphics language (HPGL)
5 Postscript
6 X-windows, XplotDriver
7 LaserJet

The enviroment variable ACSL_PLOT has been set to an unknown plot device.
Change the value to one on the list. (See subroutine zzdraw.f for the origin of this list)

No match in file for model variable NAME


A variable appears in the model that does not appear in the file from which the
RESTORE is reading. This is a warning since the program may have changed since
the file was created. This error is normally the result of restoring a file that was made
by selectively saving only a limited number of variables.

No match in model for file variable NAME


A variable appears in the RESTORE file that does not exist in the current program.
This usually indicates an old model, and the RESTORE operation may not be valid.

No more table space, max length used is I


The runtime table space manager has run out of space and the run must be aborted.
This error is frequently associated with using the stiff integration algorithm or
invoking /EIGEN analysis or /TRIM, all of which require 2N**2 words, where N is
the number of the state variables. See the document ACSL Sim User's Guide for the
mechanism to increase runtime table space.

No residual depends on variable NAME


In attempting to iterate to solve the for the algebraic variables defined by IMPLC and
IMPVC statements, a singular Jacobian has been found and in analyzing the Jacobian,
the simple problem has surfaced that a complete column is zero. This means that the
corresponding algebraic variable cannot influence the residual and so the algebraic
constraint cannot be solved.

No right sibling
This is an internal ACSL system error during syntax analysis. Report to systems staff
with documentation.

ACSL Reference Manual Page D-17


D. ACSL Error Messages No space in character dictionary for adding NAME

No space in character dictionary for adding NAME


No space in dimension dictionary for adding NAME
No space in integer dictionary for adding NAME
These errors occurs in attempting to extend the user dictionary with BLDDCT. The
common block space designated for the dictionary has been filled and no more names
can be added.

No table space left


This error occurs when there is insufficient field length for ACSL to continue running,
and it is always fatal. It is usually caused by the use of a large number of variables in a
large program, but can also be caused by arithmetic loops encountered in statement
sorting. Any such arithmetic loop should be eliminated. An increase in field length of
10K should be more than sufficient in most cases where the cause is simply a large
number of variables. See the document ACSL Sim User's Guide for instructions on
increasing table space. On most systems, a switch on the ACSL invocation is used to
increase table space; on the PC, it can be changed under an Options menu.

No user supplied integration routine


This error occurs when an attempt is made to use the integration algorithm seven
(IALG=7) without supplying a user subroutine INTEG to handle the integration.

No value item follows NAME


In the invocation of a PROCEDURE, a keyword has been used but no value item has
been specified to substitute for the keyword. To list the keywords, type:
DISPLAY/PROCEDURE=procedname

No variable affects residual NAME


Similar to the No residual depends on variable above, but corresponds to a zero row
in the Jacobian whereby the residual value is not affected by any of the algebraic
variables.

No variables printed. Use "PRINT/ALL" for everything


PRINT needs at least one name to produce a listing. Use PRINT/ALL to list every
variable on the RRR file (i.e., specified on the PREPARE list).

Not allowed in common block


System variables (CINT, IALG, MAXT, etc.) cannot be named in a user-defined
common block.

Not enough table space in blank common


The scratch table manager has run out of space. In some machines (PCs for example)
this space is fixed because of machine architecture; in others (VAX, CDC, SUN, IBM
mainframe) it can be changed by an option to the ACSL invocation (see ACSL Sim
User's Guide); and in still others (Apollo, SEL) it can be changed only by systems
personnel.

Page D-18 ACSL Reference Manual


Procedure NAME is called recursively - ignored D. ACSL Error Messages

Not in PROCEDURE definition - use QUIT to finish


The END statement at runtime terminates only PROCEDURE definitions, while QUIT
terminates the ACSL runtime session. The message is produced if END is used in
place of QUIT or if there is a syntax error in the preceding PROCEDURE statement.

Numerator greater than denominator


This message refers to the TRAN (transfer function) operator, in which the order of
the numerator must not be greater than that of the denominator.

Observable index of I is outside observable vector size of I


The /OINDEX parameter value is pointing to a position outside the list of observable
variables. Either define an observable variable (if none exists) or reset the observable
index to within range (default is 1).

Out of sequence setup for common block ZZCOMa


The number of common blocks has changed, which implies is mismatch of ACSL
levels between the translated model and the current library.

Outside table limit


This message results from a system error in the ACSL translator. Report to systems
staff with documentation.

Outside table limit in "ZZGETD": System error


Outside table limit in "ZZSTE": System error
Outside table limit in "ZZVTE": System error
Outside table limit in "ZZVTER": System error
This message results from a system error in the ACSL translator. Report to systems
staff with documentation.

Parameter already defined NAME


The listed NAME has appeared in the program prior to this PARAMETER statement. A
variable must be defined in a PARAMETER statement before it is used in the
program. The translator does not sort PARAMETER statements.

Parameter not found


This error occurs when attempting to assign a standard value (MACRO STANDVAL)
to a variable other than one of the main arguments in a MACRO definition.

Premature end of file


An end-of-file was encountered on the translator input file before the logical end of the
program was found. This implies an incomplete program or a missing END statement.

Procedure NAME is called recursively - ignored


The PROCEDURE NAME contains a reference to itself and resulted in an illegal
recursive expansion on invocation.

ACSL Reference Manual Page D-19


D. ACSL Error Messages Procedure definition not terminated prior to end of information on input stream

Procedure definition not terminated prior to end of information on input


stream
In collecting the PROCEDURE definition text, an end-of-file was encountered instead
of a terminating END statement.

Procedure ended incorrectly


An ACSL delimiter other than END has been found inside a PROCEDURAL block.

Procedure name NAME must be simple identifier


The request to list a PROCEDURE text must have the PROCEDURE name defined as
a simple identifier (i.e. no parentheses following).

Re-computing a constant
See: Warning: Re-computing a constant.

Re-computing state variable NAME


(1) A state variable previously defined in an INTEG or INTVC statement has been
assigned a value in another statement in the same DERIVATIVE section, which is
illegal. Defining a new value for a state variable is valid only in a DISCRETE section.
(2) The message may be produced if a state is set with a CONSTANT statement as
well as in INTEG or INTVC, sometimes done to initialize states for calculations in the
INITIAL section. Recommended alternatives are to use the initial conditions (usually
properly set with CONSTANT statements) or the RESET operator (see Chapter 4).
From level 10F, RESET('NOEVAL') is done automatically; i.e., the initial condition
table is moved to the state table before the INITIAL section is executed.

Reference made to non-state variable NAME


This error occurs when an attempt is made to specify error tolerances with XERROR
or MERROR for a variable that is not a state. The names of all the state variables are
listed in the debug output.

Reference out of limit of array NAME


This error occurs when an array element outside the declared size of the array is
referenced. In the runtime SET command, sequential data items are set into succeeding
slots of an array, and each item is checked to make sure the array bound is not
exceeded. For example, if A is an array of size 5, the following command will produce
the error message since the last value is to be stored in A(6):
SET A(3) = 1.5, 2.5, 5.0, 6.0

Reference outside heap block N. Reference is N


This message results from a system error in the ACSL translator. Report to systems
staff with documentation.

Restoring entire array for NAME


The array element following NAME is in error in some way, so the entire array is
RESTOREd instead of possible individual elements.

Page D-20 ACSL Reference Manual


SORT not permitted here D. ACSL Error Messages

RGET has been replaced at level 10 with separate routines as follows


AGETR - real
AGETI - integer
AGETL - logical
AGETD - double
AGETC - character
See AGET.

RSTART can-t find block no. I


The RSTART utility (see Appendix B) was called with an invalid block number; i.e., a
number that does not correspond to a DERIVATIVE section number.

Saving entire array for NAME


The array element following NAME is in error in some way, so the entire array is
SAVEd instead of any individual elements.

Scales incorrect for log plots on NAME


This error occurs when logarithmic scale values are specified to be either negative or
zero. Logarithmic scales must all be positive. ACSL's automatic scaling chooses a low
value for logarithmic scales that is the power of ten below the lowest value of the
variable being plotted; e.g., if the variable to be plotted has a lowest value of 0.07,
automatic scaling chooses a low value of 0.01. If a negative or zero scale is forced
because of the data, you can override the automatic scale with /LO to force a positive
(greater than zero) scale.

Scratch logical unit I already in use. Restore aborted


An INQUIRE showed the scratch logical unit to be already open. As a general rule,
use file logical unit numbers of only ten or higher to avoid conflict with ACSL logical
unit numbers.

SET has been replaced at level 10 with separate routines as follows


SETR - real or double
SETI - integer
The SET operator in program code must now specify either floating point or integer
type.

Singular matrix for algebraic states


The variables defined using the implicit algebraic operators IMPLC and IMPVC are
connected via a Jacobian that is singular and so it is impossible to iterate to solve for
the condition that will drive the residual to zero.

Skipping array NAME(i, j, ...) with more than two dimensions


MATLAB can only handle arrays of up to two dimensions. If in the transfer of data, a
simulation model variable is encountered with three or more dimensions, then this
variable is skipped and will not be visible in MATLAB.

SORT not permitted here


SORT cannot be specified in a PROCEDURAL or IF-THEN-ELSE block.

ACSL Reference Manual Page D-21


D. ACSL Error Messages "START" must follow a "REINIT" operation. Stopped

"START" must follow a "REINIT" operation. Stopped


After a REINIT, a START rather than a CONTINUE must follow so that
reinitialization can occur for non-integration state variables.

State changed in Jacobian evaluation, state VAR


The state was changed, probably by a direct assignment, during the evaluation of the
Jacobian. Each state is perturbed in turn, first plus, then minus, then plus again. If the
perturbed state value is not identical at both derivative evaluations with the positive
perturbation, this message is produced.

Statement is in between sections


The statement appears after the END of one section (INITIAL, DYNAMIC,
DERIVATIVE, etc.) but before the beginning of another.

Step size too large. State - N


This error occurs when a zero determinant is found in trying to invert the matrix (I +
hA) in the stiff integration algorithm. This should never happen, but if it does, it can be
fixed by reducing the allowable step size (through MAXTERVAL).

Stuck at breakaway point X, Y


The iteration to find a breakaway point within the root locus has failed. Reduce the
maximum step with system symbol SSXFPL.

Stuck in middle of step at X, Y


The root locus finder is unable to complete a step with the current value of minimum
step. Reduce the value of SSNFPL and/or SSXFPL and/or modify the phase error
condition EPFFPL and the step tolerance EPDFPL.

Symbol used but not defined NAME


The listed variable NAME never appears on the left side of an equal sign. See the
section on "Externally defined variables" in Chapter 8 for a way of suppressing these
messages when variables are defined in Fortran subroutines.

Syntax error ....


The statement containing the syntax error is listed in the error message, then repeated
with a line of asterisks underneath it. The asterisks stop where the first syntax error
occurs. Note that only the first error in a line is pointed out, so a careful check of the
remainder of the statement is advisable. Syntax error messages may be produced both
at translation and at runtime. Following is an example of a syntax error with its
asterisk indicator:
X = Y ++ Y
*******

Page D-22 ACSL Reference Manual


The dimension N is not compatible with max model dimension(s) of N D. ACSL Error Messages

Syntax error in input line


The RESTORE file in text (ASCII) mode has a line in error. Each line should contain
a name followed by an equal sign followed by a value. The incorrect line is printed
after the error message.

Table already defined


The table name has already been used in another context prior to the current table
definition, as either a simple variable, another TABLE definition, or in an assignment
statement. TABLE functions must be defined before their first use since otherwise the
translator cannot distinguish them as TABLE functions rather than normal Fortran
functions.

Table definition error


The number of breakpoints specified for the table does not correspond to the number
actually listed.

Tag too long after NAME


This error occurs when a /TAG string on a PLOT command has more characters than
can be drawn on the plot. The actual number allowed depends on machine type, but all
machines accept 20-character strings.

Terminated by zero gain


The gain through the ANALYZE transfer function must be non-zero for the frequency
response and root locus finder to work. Generate the A, B, C, D matrices with the
/JACOBIAN subcommand and check them for the source of the zero gain.

The /CLOSE switch must be alone on the PLOT command


The /CLOSE switch closes the PLT unit number so that it can be spooled to a file. If a
Y axis variable is listed, this could cause a plot to be written to the same file thereby
erasing the data before it can be moved. On VAX/VMS systems with version
numbers, this doesn't happen, but all other systems write over any existing plot file,
thereby destroying the old version.

The array NAME must have a specific element selected


In the definition of a DATA block, each channel must be associated with a specific
variable name and dimension. For example, if A is an array, use A(3,5,7) as a specific
element, not the generic A that normally stands for all its elements.

The command length of N exceeds the length allowed for the system buffer of N
characters
The SYSTEM command can take only a limited number of characters in a buffer. Use
SYSTEM with no operating system command argument in order to spawn off a
subprocess so you can enter an unlimited number of commands.

The dimension N is not compatible with max model dimension(s) of N


An array reference is not compatible with that defined in the program. For example, if
an array is dimensioned (3,7,2) in the program, a reference to (2,3,4) would produce
the error message since the last dimension of 4 exceeds the specified value of 2.

ACSL Reference Manual Page D-23


D. ACSL Error Messages The dimension is not compatible with model dimension(s) of N

The dimension is not compatible with model dimension(s) of N


An array reference is not compatible with that defined in the program. For example, if
an array is dimensioned (3,7,2) in the program, a reference to (2,3,4) would produce
the error message since the last dimension of 4 exceeds the specified value of 2.

The /FILE switch must be followed by a character string


File names must be given in single quotes. If a name is given unquoted, ACSL tries to
look in the model dictionary or the system dictionary for the name as a variable.

The input variable has N dimensions and should have N


The array reference has a different number of dimensions than that specified in the
program. For example, if variable A(3,4,5) is defined in the program, the following
runtime command results in this message:
SET A(2,2) = 3.0

The model translated as double precision cannot be used with the single
precision runtime system. Use ".../DOUBLE" switch
A program has been translated as double precision, but the double precision library has
not been specified at link time. Computer systems differ in the specification of
translation mode on the command line. VAX/VMS systems use
/DOUBLE_PRECISION; Unix systems use -x (extended precision). See ACSL Sim
User's Guide.

The model translated as single precision cannot be used with the double
precision runtime system. Use ".../NODOUBLE" switch
A program has been translated as single precision, but the double precision library has
been specified at link time. Computer systems differ in the specification of translation
mode on the command line. The default is single precision. VAX/VMS systems
specify double precision with /DOUBLE_PRECISION; Unix systems use -x
(extended precision). See the ACSL Sim User's Guide.

The model variable is a scalar


A reference has been made to an array, but the variable has been defined as a scalar in
the program.

The type of file to close must be defined first


The /CLOSE switch must be applied to a specific type of file as in :
FILE/RRRFILE='myrrr'/CLOSE

The variable NAME must have the same type as the state vector
Since the control variable is adjoined to the state vector, it must have the same type
(i.e., single or double precision). This error message is usually produced when
specifying a single precision control or observable when the model had been translated
in global double precision (forcing the type of the state variables) or vice versa.

The variable should have a dimension


A reference has been made to a scalar, but the variable has been defined as an array in
the program. Check the variable name in a DEBUG list.

Page D-24 ACSL Reference Manual


Type conflict on store into NAME D. ACSL Error Messages

The wild card NAME is illegal in plot command


Wild card names (X??, for example) cannot be used to access variables for plotting.

Time schedule error. Block number N is not discrete


The block pointed to by a SCHEDULE .AT. is not a DISCRETE block. Only
DISCRETE blocks can handle SCHEDULEd events. Blocks (i.e., DERIVATIVE and
DISCRETE sections) are numbered in their order of appearance in the program code.

Too close to pole at X, Y


The locus has come within a minimum step of a pole when it is travelling towards a
zero. Reduce the maximum step with system symbol SSXFPL.

Too many characters


The name indicated contains more than 32 characters and has been truncated by the
translator. Translation continues with the truncated version of the name.

Too many deriv/discrete sections


The number of DERIVATIVE and DISCRETE section in any given program is
limited to approximately the number of bits in a computer word, usually about 30.

Too many digits


The number being processed has too many digits for the accuracy of the machine.

Too many ENDs


This error occurs when statements remain on the input file after the final END of the
ACSL program. The remaining statements are listed but not processed. This implies
that too many END statements were included in the program, statements were
misplaced, or Fortran routines are included incorrectly. If Fortran routines are included
at the end of the ACSL program, the very next statement after the last ACSL END
statement must start with SUBROUTINE, FUNCTION, INTEGER FUNCTION, etc.,
as explained in Section 1.5. No blank or comment lines are allowed between the
ACSL END and the first Fortran function statement, and no tabs are allowed in the
first Fortran line.

Too many iterations, can-t converge


This error occurs when ANALYZE /TRIM fails to converge within the specified
number of iterations. Possible solutions are to increase the number of iterations
(NITRMX), reduce the convergence criterion (RMSEMX), or decrease the step
(FRACDL). REINIT can be used to retain any gains obtained with the current iteration.

Type conflict on store into NAME


This error occurs when data does not agree with the predetermined type (i.e., REAL,
DOUBLEPRECISION, INTEGER, LOGICAL, or CHARACTER) of NAME. Logical
data can be only .TRUE. (.T.) or .FALSE. (.F.). Integers may be stored into floating
point, but all other combinations are illegal.

ACSL Reference Manual Page D-25


D. ACSL Error Messages Unable to open file NAME

Unable to open file NAME


The named file is not present or is busy. The message implies that the OPEN failed on
a SAVE or RESTORE command.

Unknown operation at switch /SWITCH


This message usually means that the switch is followed by a data item when it is not
needed; for example:
PLOT/ALL=5

or else it is a switch that takes a data item but one is not provided; for example:
PRINT/NCIPRN

Unknown record structure on "RRR" file


The record structure on the RRR (raw run record) file is not recognized, usually
because some other type of file has been referenced. The first record must contain a
four-integer group written via the runtime START command using a PREPARE list
set prior to the START. This message can results from a call to LOGD in an INITIAL
section because the RRR file is not set up until the end of the INITIAL section.

Unsortable statement block


An arithmetic loop has been encountered during sorting and is listed below the
message. The loop may be the result of a simple spelling or PROCEDURAL header
error or a missing state equation, or the program may contain an algebraic loop which
can be broken by the use of mathematics, PROCEDURAL blocks, or (in certain
circumstances) the IMPL operator. See Chapter 3.

Use write extra information flag to replace the call to WRITG


The use of CALL WRITG to list integration data has been superseded by setting write
flags to switch on different levels of data (see WNDITG and WXDITG)

Value of "DEVPLT" is N and corresponds to no device.


Permissible devices are the following:
You have specified a plot device driver with ACSL system symbol DEVPLT (device
for plots) that is not defined at your installation. An installation can have its own set of
plot devices. See your systems manager. The message is generated in library
subroutine ZZDRAW.

Variable already released. Name is NAME


The state variable name is not frozen at the time an ANALYZE /RELEASE command
is issued.

Variable not dimensioned


The variable indicated in the error message is being used as an array without being
declared as such by a DIMENSION or other such typing statement.

Page D-26 ACSL Reference Manual


You must define at least one control variable D. ACSL Error Messages

VPUT has been replaced at level 10 with separate routines as follows


APUTR - real
APUTI - integer
APUTL - logical
APUTD - double
APUTF - character
See APUT.

Warning: Re-computing a constant


A variable defined in a CONSTANT statement is also calculated in an assignment
statement. Although some situations may warrant use of this practice (see the
Radiating Fin example in Appendix A), in general it is an error and so a warning
message is produced and translation continues. The message can be suppressed by the
/NOWARNING (VAX) or -w (Unix) switch at the ACSL invocation, or from the
Options/Translator dialog box on the PC.
If a variable is to be initialized, an assignment statement in the INITIAL section
(rather than a CONSTANT statement) should be used. Two runs, one after the other in
the same runtime session, show if all variables are initialized correctly.
In some situations involving equivalencing of elements of arrays, the XFERBa utilities
(see Appendix B) can be used instead of EQUIVALENCE to avoid this message.

Wrong dimensions
This error occurs when attempting to use an array with more than six subscripts (the
maximum allowed in ACSL).

X-axis variable NAME is not in data block NAME


In order for any points to be plotted with the PLOT/DATA command, one of channels
in the DATA block must correspond to the X axis variable name. Check the definition
of the DATA block.

XFERB has been replaced at level 10 with separate routines as follows


XFERBR - real or double
XFERBI - integer
The transfer block routine now must specify either floating point or integer type.

Xwindows plot driver not available. Change DEVPLT


On PC systems, the X Windows plot system is not available.

Y-axis variable NAME is not in data block


When a /DATA switch is attached to a particular Y axis variable, then this variable
must be one of the channels defined in the DATA block. Check the definition on the
DATA block.

You must define at least one control variable


At least one control variable must be defined for the ANALYZE transfer function
evaluation.

ACSL Reference Manual Page D-27


D. ACSL Error Messages You must define at least one observable variable

You must define at least one observable variable


At least one observable variable must be defined for the ANALYZE transfer function
evaluation.

Zero determinant for stiff algorithm, block N


A zero determinant was found for the iterator for the Gear integrator. This should
never happen since as the step size decreases, the iterator matrix becomes closer and
closer to a unit diagonal matrix – a long way from being singular.

Zero row for equation number N


A derivative or observable is not affected by any state or control, which results in a
zero row in the A,B,C,D matrix group. The derivative or observable variable can be
noted in the listing obtained from the ANALYZE/JACOBIAN command, which lists
the derivative and observable vectors by name separately.

Page D-28 ACSL Reference Manual


E. References

1. Akima, Hiroshi, "A method of univariate interpolation that has the accuracy of a
third-degree polynomial", ACSM transations on Mathematical Software, Volume 17
Number 3, September 1991, pp. 341-366.

2. Brenan, E.E., Campbell, S.L., and Petzold, L.R., Numerical Solution of Initial Value
Problems in Differential Algebraic Equations, North-Holland, 1989.

3. Gear, C. William, Numerical Initial Value Problems in Ordinary Differential


Equations, c1971, Prentice-Hall, New Jersey, pp. 150 et seq.

4. Gear, C. William, "The Simultaneous Numerical Solution of Differential Equations,"


IEEE Transactions, Circuit Theory CT-19, 1971, pp. 89-95.

5. McLeod, J., "PHYSBE: A Physiological Simulation Benchmark Experiment",


Simulation 7 (1966), pp. 324-329

6. Nordsieck, A., "On the Numerical Integration of Ordinary Differential Equations",


Math. Comp. 16 (1962), pp. 22-49.

7. Park, Stephen K. and Miller, Keith W., "Random Number Generators: Good ones are
hard to find", Communications of the ACM, Volume 31 Number 10, October 1988.

8. Technical Committee on Continuous System Simulation Languages, Simulation


Councils, Inc. (SCi), "The SCi Continuous System Simulation Language", Simulation
9 (December 1967), pp. 281-303.

9. Truxal, John G., Automatic Feedback Control System Synthesis, McGraw-Hill, 1955,
pp. 259-266.

ACSL Reference Manual Page E-1


E. References

Page E-2 ACSL Reference Manual


Index

algebraic variables 7-6


Special characters ALGORITHM 4-5 - 4-9
See also integration algorithms
multiple DERIVATIVE sections 4-26
! comment with ACTION 5-3
program 4-16 ALL
runtime 5-20 DISPLAY switch 5-24
; separator OUTPUT switch 5-31
program 4-80 PLOT switch 5-38
runtime 5-52 PREPARE switch 5-43
$ common blocks 1-6 PRINT switch 5-43
$ environment variables 4-45 RANGE switch 5-48
& concatenation in macros 6-2 ALOG 4-10
& continuation ANALYZE 5-4 - 5-19, A-51, A-69, A-129
program 4-19 AND 2-6
runtime 5-20 ANINT 4-10
* format 4-51 application techniques 8-1 - 8-14
* multiplication 2-5 APUT B-1
* wild card 5-56 arguments
** exponentiation 2-5 literal constants 4-94
+ addition 2-5 macro 6-2
- subtraction 2-5 PROCEDURAL 4-65
/ division 2-5 PROCEDURE 5-46
/ switch on runtime commands 5-1 RESET 4-70
: label separator 2-4, 4-20 single or double precision 4-94
= equal sign 4-1 arithmetic macro directives 6-7
? wild card 5-56 arithmetic operators 2-5
arrays
debug dumps 7-2
in sorted sections 4-65
A integrating 4-50
names to avoid 4-29
order 2-3
abbreviating runtime commands 5-1 plotting 5-38
ABS 4-4 PRINT 5-43
absolute value 4-4 program control variables 4-26, 4-32, 4-58, 7-6
accuracy runtime display 5-24
loss with large bias 7-19 - 7-20 runtime references 5-56
ACOS 4-4 runtime SET 5-52
ACSL Math 4-88, 5-29 subscripts 2-3
ACTION 5-2 - 5-3, A-19 transferring data B-6
debugging 7-3 ASIN 4-11
AGET B-1 aspirin dosage example A-97 - A-101
AINT 4-4 assignment statements 4-11
aircraft arresting gear example A-34 - A-40 arithmetic 4-11
aircraft example A-41 - A-51 character 4-11
ALCPLT C-1 logical 4-11
algebraic loops ATAN 4-12
breaking with PROCEDURAL 4-65 ATAN2 4-12
determined during sorting 3-5
diagnosing 3-6
one-line 3-4

ACSL Reference Manual Page I-1


Index B-C

CLOSE
B PLOT switch 5-38
program statement 4-16
CMD 5-26, C-9
backlash 4-13 specifying new file 5-27
band-limited white noise 4-62 CMDFILE FILE switch 5-26
batch mode A-2 CMPXPL 4-16
BCKLSH 4-12 coding procedure 1-4
beating 4-49 COLOR 5-36
BINARY 5-51 command file A-2
blank lines 1-4 commands, runtime 5-1 - 5-56
with continuations (&) 4-19 comment (!)
block IF 4-41 program 4-16
block on a rough surface example A-102 - A-115 runtime 5-20
BODE A-120 with continuation (&) 4-19
Bode plots with separator (;) 4-80
linear analysis 5-12 COMMON 4-17, A-76
nonlinear systems 8-2 common blocks 4-17
BODE, ANALYZE switch 5-12 DEBUG printout 7-6
BOUND 4-13 Fortran subroutines 1-6
comparison with LIMINT 4-53 common logarithm 4-55
boundary value example A-23 communication interval
breakpoints in TABLE 4-86 See CINTERVAL
concatenation (&) 6-2, 6-12
CONSTANT 4-18
comparison with assignment statement 4-18
placement in program 3-5
constants 2-1 - 2-2
DISPLAY switch 5-24
in PROCEDURAL header 4-65
C continuation (&)
program 4-19
runtime 5-20
C subroutines 8-11 - 8-12 with comment 4-17
CALCPL C-3 CONTINUE
CALL 4-13 labeled statements 2-4, 4-20
CALPLT C-1 MACRO 6-7
CALSPL C-5 runtime command 5-21
Cartesian coordinates 4-66, 4-71 with DO loop 4-32
case sensitivity A-1 with REINIT 5-50
CHARACTER 4-93 continuous
default for plots C-2 system symbols C-3 - C-4
in COMMON blocks 4-17 control
OUTPUT switch 5-32 runtime executive 5-1
PLOT switch 5-36 transfer with IF 4-40
START switch 5-55 control loop example A-9 - A-12
with SET 5-2 CONTROL, ANALYZE switch 5-5, A-129
character constants 2-2 controls
character expressions 2-7 linear analysis 5-5, 7-17, A-91, A-117
CINDEX 5-14 COS 4-20
CINTERVAL 4-14 - 4-15, 4-33, A-36 Coulomb friction A-103
calculating in program 4-14 counters 3-4
integration step size calculation 4-6 cpu time 5-54, A-61
strobe effect 4-49 CSSITG C-8
CIOITG C-8
CJVITG C-8
CLEAR
ACTION switch 5-3
ANALYZE switch 5-7
OUTPUT switch 5-31
PREPARE switch 5-42

Page I-2 ACSL Reference Manual


D-E Index

DISCRETE 3-2, 4-30 - 4-31, A-91


D data logging 4-56
executed by SCHEDULE 4-72
INTERVAL 4-49
DASSL 4-8 synchronizing 8-13 - 8-14
DATA discrete sampled compensator example A-90 - A-96
PLOT switch 5-38 DISFILE FILE switch 5-26
runtime definition 5-22 - 5-23 DISPLAY
SMOOTH 4-81 ANALYZE switch 5-16
USEDBV 4-96 runtime command 5-24 - 5-25
data logging 4-14, 4-33, 5-42 DISSTR B-2
forcing 4-55, 5-31 DO loop 4-32
data type operators not allowed 4-2
runtime commands 5-2, 5-52 sorted sections 4-33
DBLE 4-20 documentation 8-3
DBLINT 4-21 dot product A-74
DCVPRN 5-53, A-129, C-8 macro 6-11
DEAD zone operator 4-22 double precision A-70
DEBUG A-17, B-2 constants 2-2
debugging 7-1 - 7-20 conversion to 4-20
summary output 8-3 selecting global 4-3
system symbols 7-5 DOUBLEPRECISION 4-93
with LOGD 4-56 DPNPLT C-2
without system debugger 7-3 DPSITG C-8
default DSCPLT C-2
MACRO 6-10 DTCFPL 5-13, C-6
DEFPLT C-1 dummy variables 2-1
DEGREE 5-14 derivatives 7-6
DELAY with TABLE 4-88
ANALYZE switch 5-14 DWNFPL 5-12, C-6
DELSC 4-24 DWXFPL 5-12, C-6
DELVC 4-25 DYNAMIC 3-2, 4-33, 4-45
HISTORY 4-39
program operator 4-22 - 4-23
scalar 4-24
vectors 4-25
delay, computational A-95 E
DELSC 4-24
DELVC 4-25
DERIVATIVE 3-1, 4-25 - 4-27 ECSITG C-8
in place of PROGRAM statement 4-66 EIGEN 5-8
derivatives 4-47, 4-50, 7-6 eigenvalues 5-8, A-86, A-116
calculation with RESET 4-70 eignevectors 5-8
DERIVT 4-28 EMNFPL 5-13, 5-15, C-6
DEVPLT C-2 EMXFPL 5-13, 5-15, C-6
DFXFPL C-6 END
dictionary DATA definition 5-22
AGET, APUT B-1 DERIVATIVE definition 4-25
system 5-24, B-1 DISCRETE definition 4-30
user A-88, B-4 DYNAMIC definition 4-33
differential algebraic system solver 4-8 INITIAL definition 4-45
digital controller A-90 PROCEDURAL definition 4-64
DIM 4-28, A-36 PROGRAM definition 4-66
DIMENSION 4-29, 4-93, A-74 program statement 4-34
direction cosine matrix A-76 runtime command 5-26
DIS 5-26, C-9 TERMINAL definition 4-89
high volume data C-8 environment variables 4-45
discontinuities EPDFPL 5-12, 5-15, C-6
handling with DISCRETE 4-78 EPFFPL 5-15, C-6
handling with Runge-Kutta-Fehlberg 4-8 EQ 2-6
handling with SCHEDULE 4-73 equal sign (=) 4-1
resulting from approximations A-97 subroutine calls 4-14

ACSL Reference Manual Page I-3


Index F-F

EQUIVALENCE 4-34 explicit program structure 3-1 - 3-6


EQV 2-6 explicit structure A-13
ERR CONTROL 7-7 expressions
error character 2-7
absolute 4-59 definition 2-5 - 2-8
absolute vs. relative 7-7 logical 2-6
allowable 4-59 relational 2-6
allowable during integration 5-30 extrapolation in tables 4-86
allowable in trim 5-10
predicted 4-59
relative 4-59, 5-30
summary for variable step integration 4-9
error messages D-1 - D-28
F
Jacobian evaluation 5-6, 7-16 - 7-18
errors
compilation 7-2 FCNSW 4-36
DO loops 4-33 FDEITG C-8
link 7-2 feedback
translation 7-1 control example A-116
ERRTAG 4-35, 4-59 DELAY operator 4-23
event description 4-73 FILE
event list 4-27, 4-76 PRINT switch 5-44
clearing A-32, B-3 file handling
DISCRETE sections 4-30 CLOSE PLOT switch 5-38
restoring 5-50 CLOSE program statement 4-16
saving 5-52 FILE runtime command 5-26 - 5-27
events INQUIRE 4-46
comparison of state and time 4-74 macro file 4-71
RESTORE switch 5-50 OPEN 4-62
SAVE switch 5-52 runtime command file 5-1
example flag
discontinuity with event finder 4-79 first step during integration 7-6
PID controller 4-28 SCHEDULE 4-72
examples A-1 - A-132 stop A-15
aircraft A-41 terminating run 3-2
aircraft arresting gear A-34 floating point number
aspirin dosage A-97 definition 2-2
block on a rough surface (friction) A-102 FLOGSC 5-14
bouncing ball 4-77 flow square root 4-83
concatenation 6-12 FLTFPL 5-13, C-6
control loop A-9 FORMAT 4-37
discrete sampled compensator A-90 FORTRAN I/O 4-51
frequency response 5-19 SAVE file 5-50
limit cycle A-1 FORTRAN
linear analysis 5-17, A-116 common blocks 4-17, A-76
missile A-70 comparison with ACSL 2-1, 4-94
nonlinear frequency response A-62 FORMAT 4-37
physiological benchmark A-52 functions 4-1 - 4-98
pilot ejection A-13 generic vs. non-generic 4-1
plotting 5-39 input/output 4-51, A-36
plotting measured data 5-22 logical unit 4-16, 4-62
spring damper A-5 subroutine library A-70
state events A-102 FRACDL 5-9
steady state A-20 FRACPM 5-10
tank with boiling benzene A-123 FREEZE 5-6, A-129
temperature along radiating fin A-20 FREQMN 5-12
EXIT FREQMX 5-12
MACRO 6-8 frequency plots
runtime command 5-26 system symbols C-6 - C-7
EXP exponential 4-36 frequency response 5-11, 5-19, A-62
EXPF exponential function 4-36 frequency sweep 5-11 - 5-12, A-65
friction example A-102 - A-115

Page I-4 ACSL Reference Manual


G-I Index

FSQRT 4-83
FTSPLT 5-38, C-2 I
function switch operator 4-36

I (infinity) 7-7
I/O 4-51
IALG
See ALGORITHM
ICS 5-51
IF 4-40 - 4-41
MACRO 6-8
G with SCHEDULE 4-75
IF-THEN-ELSE 4-40 - 4-41, A-16, A-55
IHI
GAINDB 5-14 PRINT switch 5-44
GAINMN 5-14 RANGE switch 5-48
GAINMX 5-14 ILO
GAUSI 4-37 PRINT switch 5-44
GAUSS 4-38 RANGE switch 5-48
GE 2-6 IMAGMN 5-14
GLOGSC 5-14 IMAGMX 5-14
GLTPLT C-2 IMPLC 4-42 - 4-43, A-123
GO TO 4-38 implicit integration 4-42
MACRO 6-8 implicit structure 3-1
Graphic Modeller 1-1 impulse 8-4
GRDCPL C-3 IMPVC 4-44, A-123
GRDFPL C-6 INC 5-7
GRDSPL C-5 INCLUDE 4-17, 4-45
GT 2-6 independent variable 4-97, A-20
DATA definition 5-22
driving PULSE 4-67
OUTPUT list 5-30
plotting 5-33, A-8
PREPARE list 5-42
TABLE definition 4-85
infinity 7-7
INITD 8-1, B-3
H INITIAL 3-2, 4-45
in macro 6-2
INCLUDE 4-45
multiple sections 3-6, 4-46, A-62
HARM harmonic drive function 4-39
initial conditions 4-50, 7-6
HELP 5-28
CONTINUE 5-21
HERTZ 5-12, 5-14
debugging 7-2
HI
independent variable 4-97
PLOT switch 5-35
INTEG 4-47
HISTORY 4-39
negative value 4-97
HVDPRN A-106, C-8
reinitialize 5-49
hysteresis 4-13
trim 5-11
initialization
DISCRETE section 4-49
of controls 4-31
of counters 4-18
of states 3-2, 5-4
of variables in block IF 4-41
INQUIRE 4-46
INT integerization function 4-46
INTEG 4-47 - 4-48
integer 4-93
definition 2-1
dividing by 2-5
switch 4-57

ACSL Reference Manual Page I-5


Index J-L

integration
basis of simulation 1-2 K
control 4-6
data during process C-9
description of procedure 4-6, 4-47 Kirchoff's Law 4-42
DISCRETE sections 4-31
double limited operator 4-21
error summary C-9
first evaluation each step 7-6
implicit 4-42
limiting 4-53
system symbols C-8
vector 4-50, A-70
integration algorithms 4-5 - 4-9
Adams-Moulton 4-7, A-50
change during run 4-6 L
comparison of efficiency 4-10, A-51
fixed step 4-6, 4-58
Gear's stiff 4-8 labels 4-38
Runge-Kutta 4-6, A-50 definition 2-4
Runge-Kutta-Fehlberg 4-8 with macro expansions 2-4
user-supplied routine B-3 with TABLE references 4-88
variable step 4-7 language elements 2-1 - 2-8
variable step summary message 7-7, A-50 LE 2-6
integration step size lead-lag compensator 4-51
adjusting to CINT 4-14 LEDLAG 4-51
affected by events 4-27 LIMINT 4-52 - 4-53
calculated by ACSL 4-6, 4-58 limit
choosing 4-9, 4-27, 4-92, 7-4, A-36 integrator 4-53
limiting 4-58 number of sections 4-32
restarting B-5 second integral 4-21
variable step 4-27 variables 4-13
with PULSE 4-67 limit cycle example A-1 - A-4, A-102
interactive runtime A-2 LINCPL C-3
interpolation LINEAR 4-54
LINEAR 4-54 linear analysis 5-4 - 5-19
plot boundaries A-8 See also ANALYZE
SMOOTH 4-81 - 4-82 linear analysis example A-116 - A-122
TABLE 4-86 LINES 4-54
INTERVAL 4-49, A-91 LINPACK 4-95
strobe effect 4-49 LINSPL C-5
INTVC 4-50, A-80 LIST
INVNYQ 5-13 ANALYZE switch A-117
iterating for solution A-33 LIST, ANALYZE switch 5-16
IVAR LISTD A-88, B-4
PRINT switch 5-44 lists
RANGE switch 5-48 ANALYZE 5-5
LO
PLOT switch 5-35
LOCATION 5-3
J LOG
natural logarithm function 4-55
PLOT switch 5-35
LOG10 4-55
Jacobian matrix 5-8, A-86
LOGD 4-55, 5-31, A-32, A-91, A-106
dimensions 5-5
LOGICAL 4-93
during integration C-9
logical constants 2-2
formation 5-5
logical expressions 2-6
JACOBIAN, ANALYZE switch 5-8, A-51
logical IF 4-40
job processing 1-2
logical operators 2-6
logical switch 4-57

Page I-6 ACSL Reference Manual


M-N Index

logical unit MINTERVAL 4-35, 4-58 - 4-59


CLOSE program statement 4-16 containing INTERVAL 4-49
CMD C-9 missile airframe example A-70 - A-89
DIS C-9 missile example
FORTRAN I/O 4-51 terminating at intercept 8-6
INQUIRE 4-46 MOD modulus function 4-60
OPEN 4-62 Monte Carlo 8-9
PLT 5-38, C-9 multiple DERIVATIVE 4-25
PRN 5-43, A-106, C-10 multiply defined symbol 4-65
RRR C-10 MUMAX 5-9
loop from TERMINAL to INITIAL 8-1, A-20 MXOITG C-9
LSW 4-57
LT 2-6
LTCCPL C-3
LTCFPL C-6
LTCSPL C-5
LTFCPL C-4 N
LTFSPL C-5
LU decomposition 4-95
lump mass A-53 names 2-1
conflict 4-33
generated 2-1, 4-47
reserved 1-5, 4-29
M underscore 2-3
NaN (not a number) 7-7
NCIOUT 5-31, A-17
macros 6-1 - 6-18 NCIPRN 5-44
CMPXPL 4-16 NCTPRN C-8
comparison with subroutines 6-1 NDBUG 7-2, A-87, C-9
concatenation 6-12, A-53 NE 2-6
DBLINT 4-21 nearest integer 4-60
definition header 6-4 - 6-5 nearest whole number 4-10
definitions 6-4 NEDFPL 5-15, C-7
directive statements 6-6 - 6-10 NEQV 2-6
GAUSS, GAUSI 4-37 NESFPL 5-13, C-7
HISTORY 4-40 nesting
invocation 6-17 - 6-18 INCLUDE 4-45
operators 4-3 PROCEDURE 5-45
placement of definitions 6-1 sections 3-6
PTR 4-66 Newton step 5-9
REALPL 4-69 NGXPPL C-3
saving definitions 4-71 NGYPPL C-3
TABLE 4-86 NICHOLS 5-13
TRAN 4-91 NINT 4-60
MALPRN C-8 NITRMX 5-10
matrix operations 8-7 - 8-8 NOBINARY 5-51
See also Jacobian matrix NOHEADER
macro definitions 6-13 PRINT switch 5-45
MAX 4-57 noise 4-62
MAXTERVAL 4-6, 4-58, A-36 nonlinearity 7-17
mean nonrepeatability 7-16
GAUSS 4-38 NOT 2-6
OU 4-62 NOXLOG 5-34
memory operators NPBPLT C-2
in block IF 4-41 NPBPRN A-129
not allowed in PROCEDURAL 4-2, 4-65 NPCCPL C-4
MERROR NPCPPL C-3
program statement 4-59 NPCSPL C-5
runtime command 5-30 NPXPPL C-3
MIN 4-60 NPYPPL C-3
MINC 5-7 NRWITG C-9

ACSL Reference Manual Page I-7


Index O-P

NSTEPS 4-61 PID controller 4-28


array 4-61 pilot ejection example A-13 - A-19
fixed step algorithms 4-6, 4-61 PLOT 5-33 - 5-41
variable step algorithms 4-9, 4-61 START switch 5-55
NXEITG 4-27, C-9 X axis switches 5-34, A-8
NYQUIST 5-13 Y axis switches 5-35
plot drivers C-2
plots
arrays 8-10
automatic scaling 5-33
O continuous (line) A-36, C-3 - C-4
deferred C-1
during run 5-32
obserables A-117 frequency C-6 - C-7
observables logarithmic A-62
Jacobian matrix 7-17 logarithmic scales 5-42
OBSERVE 5-5, A-129 pause between 5-32
OINDEX 5-15 phase plane 5-34, A-4, A-8
OPEN 4-62 scales A-8
operating system commands 5-55 spooling 5-38
operators strip A-36, C-5
arithmetic 2-5 system symbols C-1 - C-10
logical 2-6 title C-10
precision 4-3 trajectory A-17
relational 2-6 PLT 5-26, C-9
standalone form 4-3 PLTFILE FILE switch 5-26
OR 2-6 polar coordinates 4-66, 4-71
OU Ornstein-Uhlenbeck function 4-62 positive difference function 4-28
OUTPUT 5-30 - 5-31, A-3 PPOPLT C-2
with LOGD 4-56 precision
OVER 5-39, A-99 operators 4-3
selecting global 4-3
specifying in program 4-3
PREPARE 5-42, A-4
P plots 5-33
preset
derivatives 3-6
PAGE 4-63 variables 3-6, 7-2
PARAMETER 4-64, A-65, A-97 variables in user common blocks 4-17
with DIMENSION 4-29 PRINT 4-51, A-43
parameter sweep MACRO 6-9
plotting averages 8-9 runtime command 5-43 - 5-44
procedure 8-1 system symbols C-8
parentheses 2-5 window 5-44
paths 4-45 printer plots C-3
PAUSE 5-32 PRN 5-26, C-10
PC PRNFILE FILE switch 5-26
PLOT specifications 5-37 PRNPLT C-2
SYSTEM 5-56 PROCEDURAL 4-64 - 4-65, A-78
PC FAIL 7-7 comparison with block IF 4-41
PCWPRN C-8 equal sign in definition 4-2
perturbation operators not allowed 4-2
controls 5-7 sorting 4-65
states 7-16 variables defined in subroutine 8-5
phase and gain example A-62 - A-69 PROCEDURE 5-45 - 5-46
phase plane plots DISPLAY switch 5-25
See plots, phase plane example A-9
PHASMN 5-15 PROGRAM 4-66
PHASMX 5-15 program control
physiological benchmark example A-52 - A-61 transfer between sections 3-2
PI controller A-123 - A-132 program flow 3-1 - 3-3

Page I-8 ACSL Reference Manual


Q-S Index

program statements 4-1 - 4-98 RRR 5-26, C-10


promotion of integers 2-2, 2-5 multiple files 5-27
PSFCPL C-4 RRRFILE FILE switch 5-26
PSFFPL C-8 RSTART B-5
PSFSPL C-5 RSW 4-57, A-103
PTR 4-66 RTP 4-71
PULSE 4-67 RUN
PLOT switch 5-39
PRINT switch 5-44
RANGE switch 5-49
runtime commands 5-1 - 5-56
abbreviating 5-1
Q user-supplied subroutine A-3

QNTZR quantizer function 4-67


QUIT 5-47
quotation marks 5-1

SAME 5-39, A-99


R sampled data
macro 6-11
SATCPL C-4
R (NaN) 7-7 SATFPL C-7
RAMP 4-68 SATSPL C-5
random number generator 4-96 SAVE 5-51
GAUSS 4-38 program statement 4-71
OU 4-62 SCALE 4-72
seed 4-37 SCHEDULE 4-72 - 4-79
RANGE 5-48, A-6 activation of DISCRETE 4-49
READ 4-51 finding limit 4-21, 4-53
REAL 4-69, 4-93 finding missile intercept 8-7
real switch 4-57 state events 4-76
REALMN 5-15 time events 4-75
REALMX 5-15 sections
REALPL 4-69 DERIVATIVE 3-2, 4-25 - 4-27
rectangular coordinates 4-66, 4-71 DISCRETE 3-2, 4-30 - 4-31
REDEFINE (MACRO) 6-9 DYNAMIC 3-2, 4-33
REINIT 5-49, A-87 INITIAL 3-2, 4-45
trim initial conditions 5-11 nesting 3-6
RELABEL (MACRO) 6-9 TERMINAL 3-2, 4-89
relational expressions 2-6 seed for random number generators 4-37
relational operators 2-6 separator (;)
RELEASE 5-6 program 4-80
RESCALE runtime 5-52
CONTINUE 5-21 with block IF 4-41
START switch 5-55 SET
RESET 4-70, A-106 filling TABLE data 4-88
residual 4-42 runtime command 5-52 - 5-53, C-8
resolution of quantizer 4-67 SETI, SETR utilities B-5
response SGN 4-80
closed loop 5-20, A-121 SIGN 4-80
open loop 5-19, A-116 SIN 4-81
RESTORE 5-50 single precision
CONTINUE 5-21 conversion to 4-69
RMSEMX 5-10 SLTFPL 5-13, C-7
RMX 5-14, 5-44 SMOOTH 4-81 - 4-82
root locus 5-15, A-120 SORT program statement 4-83

ACSL Reference Manual Page I-9


Index T-T

sorting 3-4 - 3-5, 4-49, 4-64 switches


multiple sections 3-6 evaluation in DISCRETE 4-78
non-sorted sections 4-83 integer 4-57
SPARE 5-54, A-3 logical 4-57
spring real 4-57
mass-spring-damper A-5 - A-8 runtime command 5-1
SQRT 4-83 symbols
SSNFPL 5-15, C-7 on plot curve (CHARACTER) 5-36, C-2
SSQRT 4-83 runtime data 5-2
SSXFPL 5-15 SYMCPL C-4
standalone form 4-3, A-9 SYMSPL C-5
standard deviation SYSTEM 5-55
GAUSS 4-38 system symbols C-1 - C-10
OU 4-62 continuous plots C-3 - C-4
STANDVAL (MACRO) 6-10 debug printout 7-5
START 5-54 equivalencing 4-34
state events 4-76 frequency plots C-6 - C-7
implementation 4-77 integration control C-8
state variables 4-47, 7-6 logical units C-9 - C-10
access during run 4-31, A-105 plots in general C-1 - C-2
in common blocks 4-17 print data C-8
in PROCEDURAL header 4-65 printer plots C-3
initialize 3-2 program control 1-5
initialized 4-70 strip plots C-5
STATES typing 4-94
RESTORE switch 5-50
SAVE switch 5-51
STATUS, ANALYZE switch 5-16
steady state
See TRIM
T
steepest descent step 5-9
STEP program statement 4-84
step response 8-4 TABLE 4-85 - 4-87
STOP flag 3-2 accessing function 4-85
strip plots definition 4-85
system symbols C-5 tabs 1-6
strobe effect 4-30, 4-49 TAG 5-36
STRPLT C-2 TAN 4-88
structure tank with boiling benzene example A-123 - A-132
explicit 3-1 - 3-6 TBRPLT C-2
implicit 3-1 TCWPRN C-8
See also sections temperature distribution example A-20 - A-33
STYLE 5-37 TERMINAL 3-2, 4-89
subcommands in macros 6-2
See switches INCLUDE 4-45
subroutines multiple sections 3-6
C 8-11 - 8-12 terminating a run 3-2, A-2
calling from ACSL 4-13 missile intercept 8-6
calls requiring PROCEDURAL 4-65 several conditions A-65
common blocks 4-17 terminating condition 4-89, A-15
filling TABLE data 4-87 finding with SCHEDULE 4-80
Fortran 1-6 TERMT 3-2, 4-89
user-supplied runtime 5-54, A-3 time
subscripts backwards 8-8
definition 2-3 time constant
substitution complex pole transfer function 4-16
macro 6-3 first order lag 4-69
lead-lag compensator 4-52
OU 4-62
time events 4-75
TIMES 5-48
TITLE 5-46, 5-53, C-10

Page I-10 ACSL Reference Manual


U-X Index

TJNITG C-9
TKHFPL 5-15, C-7 W
TRAN 4-90 - 4-91
transfer function A-90
example A-9 warning message 4-19, A-32
first order lag 4-69 WEDITG A-106, C-9
higher order 4-91 WESITG C-9
lead-lag 4-51 white noise 4-62
second order 4-16 width
Z polynomials 4-92 output to terminal A-1
transfer operator A-64 print file 5-43, A-1
translation process 4-48 WIDTH PLOT switch 5-37
TRANZ 4-92 wild cards
TRIM A-42, A-86, A-129 DISPLAY 5-24
ANALYZE switch 5-8 OUTPUT list 5-31
truncation 4-4 PREPARE list 5-42
TSMITG C-9 PRINT list 5-43
TTLCPL C-4 RANGE list 5-48
TTLFPL C-7 RESTORE list 5-50
TTLSPL C-5 runtime 5-56
type 4-93 - 4-95 runtime commands 5-20
common blocks 4-17 window
definition in ACSL 2-3 finding state event 4-78
OUTPUT switch 5-32 WNDITG C-9
PLOT switch 5-36 WRITE 4-51
runtime data 5-2 to screen B-2
START switch 5-55 WRITEPREPARE 5-29
WXDITG C-9

U
X
undefined numbers 7-7
underscore 2-3 XAXIS 5-34
UNIF 4-96 XCICPL C-4
UNIFI 4-37 XCIFPL C-7
unit conversions 4-33 XCISPL C-5
USEDBV 4-96 XERROR
utilities B-1 - B-6 program statement 4-59
runtime command 5-30
XFERBI B-6
XFERBR 4-50, A-80, B-6
XHI 5-34
V XINC 5-7
XINCPL C-4
XINFPL C-7
VALUE 5-3 XINSPL C-5
valves A-52, A-90 XLO 5-34
VARIABLE XLOG 5-34
ACTION switch 5-3 XTAG 5-35
DISPLAY switch 5-24 XTICPL C-4
program statement 4-97 XTIFPL C-7
variables XTISPL C-5
definition 2-3 XZPPLT C-3
See also names
vector integration 4-50
vector rotation A-76
VECTORS 5-8
VERSION
DISPLAY switch 5-26

ACSL Reference Manual Page I-11


Index Y-Z

YASFPL C-7
YASSPL C-6
YCICPL C-4
YCIFPL C-7
YCISPL C-6
YINCPL C-4
YINFPL C-7
YINSPL C-6
YTICPL C-5
YTIFPL C-7
YTISPL C-6
YZPPLT C-3

zero crossing function A-103


ZEROS 5-16, A-117
ZZFRFL 7-6

Page I-12 ACSL Reference Manual

You might also like