Speckhart_A_Guide_to_Using_CSMP_1976 Speckhart A Guide To Using CSMP 1976

Speckhart_A_Guide_to_Using_CSMP_1976 Speckhart_A_Guide_to_Using_CSMP_1976

User Manual: Speckhart_A_Guide_to_Using_CSMP_1976

Open the PDF directly: View PDF PDF.
Page Count: 338

DownloadSpeckhart_A_Guide_to_Using_CSMP_1976 Speckhart A Guide To Using CSMP 1976
Open PDF In BrowserView PDF
t 2-8

1t~O\.rt

'n IAt
0.0
~
oc oo t..

oo~

00 '""
t.2 0CO £

0. 0
0.0
0.0
0.0

rt:~o ur
-'- -- -- -'
1111
I

TRIANGLE

00
00

II I I
I I
J-~~~~~~~~~~~~~~~~~~~~~~~~~~O~O!
1

II

II

0000011001000000000010000000000000010000000000"0000100 0 0110 0 0 0 0 0 0 0 0 0 0 0 00000011000
12 l 4 S' "

91QIIIZI3141$1&ll\8192DZI2223Z4Z5262121t9303\323134353&3131J9'Q41(2434445«41(849505152SJS4SS~51S8596D616Z&3i46S"616B'9IDlIJt131'1S1&11181910

11111111111111111111111111111111111111111111111111111111111111111111111111111111
2 2 2 2 212 2 2 2 2 2 2 2 2 21212 2 2 2 2 2 2 2 2 2 2 2 2 2 212 2 2 2 2 2 Z 1212 2 2 2 2 222221122222222222222222222222
3313331331333333313313333333113333313333333131333 3133 33 3 33 3 3 31133 3 3 3 33 33 3 3 3 313 3 3

4444444444444444444444444444444144444444444444444 44 4414444 44 4 4 444 44 4 4 4 4 4 44414 4 44
555515551555555555555555555555555155555555555511515555 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 515 5 5 5 5 5
6661666666666616666666666616 6 6 6 6 6 6 6 6 6 6 6 616 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 616 6 6 616 6 6 6 6 6 6 6 6 6 6 6 6666
11111/1/1111111111111111111111111111111111111111111111711111111/1111111 1-1 11111/1

88888888888 C8 818 818 818 8 8 8 81B 818 8 8 8 818 8 8 818 818 8 8 8 8 818 8 8 8 8 8 818 818 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 8
999999999999 S ~ 9 9 9 9 9 9 9 9 9 919 9 9 9 9 9 9 9 919 9 919 9 9 9 9 9 9 9 9 9 9 9! 9 9 9 9 9 9 9999999999999919999999
123" 5 6 1 8

51~~!~151S111819202122Zl242SZ62128Z93Q3IS2~3H3S363139394D414l4SU4$46414849S0S1S25354rS56515S$9&061S261&4G5B56168S91DlIl2J31415167JJlTJ811

Fig.2.1 Computer cards printed with examples of CSMP statements.

in the computer card deck to add additional lines of spacing in the listing of the
program.
Structure of CSMP

The solution of most problems does not require a detailed understanding of
the structure of CSMP. However, in complicated simulations where it is required
to control the order of the execution of the program, an understanding of the structure of the CSMP program is necessary.
Basically the CSMP program can be divided into three segments:
INITIAL
DYNAMIC
TERMINAL

Ch. 2

Fundamentals of System/360 CSMP

11

Each of the three segments can be further divided by repeated use of sort and nosort
sections. The program simulation statements are contained in the body of these
sections. A diagram showing the basic structure of a CSMP program is shown in
Fig. 2.2.
Sections
Sort or Nosort

Segments

INITIAL

~

DYNAMIC

~

TERMINAL

~

Simulation
statements

.......-----Statements
Section ----:;;;..-.---Statements
Section

=Statements
Statements

Section

oc::::::::::::: Statements
Statements

_______ Statements
Section ---=-~---Statements
Section

=-Statements
- - - - - - Statements

Section - -.....~=-----Statements
---Statements

section

Section
Section

~ Statements
---=-=-----Statements

~

Statements

- - - Statements
____
Statements
---- Statements

Fig. 2.2 Structure of the CSMP program.

The following paragraphs give a description of the INITIAL, DYNAMIC,
and TERMINAL segments and explain their application. It should be noted that
the three segments must appear in the order presented and each segment can be
used only once.
Initial Segment

The Initial segment is the first to appear in the program. It is used exclusively
for calculations that need to be performed only once. The use of the Initial segment
can reduce computer time since all statements listed in this segment will be executed
only: once. All calculations for initial conditions must be included in this segment. It
is not always necessary or even desirable to use the Initial segment, consequently,
this segment is optional. To specify the use of the Initial segment, a card must be
inserted with the label INITIAL at the beginning of the segment.

12

Fundamentals of Systemj360 CSMP

Ch. 2

Dynamic Segment
The CSMP program uses an iterative procedure for problem solution. Since
iterations only occur in the Dynamic segment, all simulation statements that are
used to describe the dynamic response must be included in this seguent. In effect,
the Dynamic segment can be thought of as a subprogram that is executed at each
iteration step. The Dynamic segment can be specified by two methods as listed
below.
1. If the Initial segment is not specified, the Dynamic segment is automatically
incorporated into the program. No labeling is necessary.
2. If the Initial segment is specified, a card with the label DYNAMIC must
precede the statements in the Dynamic segment.

Terminal Segment
The Terminal segment is the last of the three segments and is used for those
calculations that should be performed at the completion of the simulation. This
segment is optional and is only executed when a statement with the label TERMINAL is placed after the Dynamic segment.

Sort and Nosort Sections
One of the most important and valuable features of the CSMP program is
the sorting capability. The sorting feature chooses the correct order for the execution of the structure statements. This means that in a section where the statements
are sorted (called a sort section), the order in which the statements are placed in
the program deck has absolutely no effect on the order of statement execution.
The sort section cannot be used for all types of operations. For example, the following FORTRAN conditional logic and branching statements, which control
the order of execution, obviously conflict with the CSMP sorting procedure.
IF(X.GTA.5) GO TO 6
GO TO 7
6 IF(Y) 3, 4, 5

Consequently, these types of FORTRAN statements cannot be used in a sort
section. An expression such as

x

=

X

+

1.0

in which the same variable appears on both sides of the equal sign is another type
of operation that cannot be used in a sort section. Also excluded from sort sections
are FORTRAN WRITE and FORMAT instructions such as the following:
WRITE(6, 100) X, Y, Z
100 FORMAT(3F30.5)

In nosort sections, no sorting is performed and therefore all statements are exe-

Ch. 2

Fundamentals of System/360 CSMP

13

cuted in the exact order in which they appear in the program. FORTRAN conditionallogic and branching and all other similar statements that specify a particular
order of control must be included in a nosort section.
All statements in the Initial and Dynamic segments not labeled by a NOSORT
card are automatically placed in sort sections while statements in the Terminal
segment are automatically placed in a nosort section. To specify a change in
section in any of the three segments, the use of a separate card with either a SORT
or NOSOR T label is required. An example of a particular CSMP program having
a complex structure is illustrated in Fig. 2.3.
In this example the first group of statements in the Initial segment are automatically sorted up to the point where the NOSORT statement is included. After
the NOSORT card, all remaining statements in the Initial segment are contained
in a nosort section. The first NOSORT label in the Dynamic segment places the
first group of statements in a nosort section. The next group of statements after
the SORT label are sorted. A NOSORT label then changes the last group of statements in the Dynamic segment back to a nosort section. In the Terminal segment,
INITIAL

All statements in the Initial
segment are only executed
at the beginning of the run.

: :: : : :: } Statements are sorted.
NOSORT
: : : : : :: } Statements are not sorted and executed in
...... .
the order in which they appear.
DYNAMIC
NOSORT
Statements are not sorted and executed in
} the order in which they appear.
SORT

Statements in the Dynamic
segment are executed at
each integration step.

} Statements are sorted.
NOSORT
: : : : : :: } Statements are not sorted and executed in
.,. ....
the order in which they appear.
TERMINAL

Statements in the Terminal
segment are only executed
at the end of the run.

}

Statements are not sorted and executed in
the order in which they appear.

SORT
} Statements are sorted.

Fig. 2.3 Example of a CSMP program having a complex structure.

14

Fundamentals of System/36D CSMP

Ch. 2

the first group of statements are automatically placed in a nosort section. The
following SORT label changes the last group of statements to a sort section.
Note that when a section contains both sort and nosort segments, the segments will be executed in the order they appear.
Solving Problems with CSMP
The following eleven example problems illustrate the use of CSMP to simulate
a wide range of engineering and mathematical problems. By studying the examples
and working the problems at the end of the chapter, the reader will have a good
working knowledge of CSMP.
Example 2.1 Spring-Mass-Damper System

Some of the very basic concepts of CSMP can be illustrated by simulating the motion
of the linear spring-mass-damper system that is shown in Fig. 2.4.

.I ~

~~I

K ...........----~,.....-----...,i
M
C
)
(~

= 0) = 1.0
X(t=O)=O.O
M = 1.5 slugs
C = 4.0 lb-sec/ft.
O/~W&'///;::!>~~&.
K = 150 lb/ft.

1------1

x(t

Fig. 2.4 Spring-mass-damper system.

Applying Newton's second law leads directly to the following second-order equation
of motion.
d 2X

dX

M dt 2 +C{ft+KX=O

(2.1)

When dealing with differential equations higher than first-order, it is helpful to reduce all
equations to a set of first-order expressions. For some problems, this can require a major
effort. However, for Eq. 2.1, it is only necessary to introduce new symbols and rearrange
variables.
Let
VEL

=~~

ACC

=

(velocity)

and
d(VEL)
dt

(acceleration)

The resulting two first-order equations for velocity and acceleration along with the
initial conditions are:
dX = VEL

(2.2)

dt

d(~;L)

=

-(C*VEL

+ K*X)/M

Initial conditions: X(t = 0) = 1.0, VEL(t = 0) = 0.0

(2.3)

Ch.2

Fundamentals of System/360 CSMP

15

With this brief explanation, a CSMP program containing only the basic features
needed to numerically solve Eqs. (2.2) and (2.3) is shown in Fig. 2.5. In this example
program it is not necessary to specify the Initial, Dynamic, or Terminal segments. All
statements are automatically placed in the Dynamic segment and sorted. Thus the order
in which the structure statements are arranged in the deck has no effect on the execution
of the program. The first two statements of the program are comment cards and are
identified by an asterisk in the first column. As previously mentioned, comment cards do
not affect the execution of the program. The third card is a CONSTANT statement used
to assign values to variables.

*
*

M = MASS,
C = DAMPING CONST&NT,
K = SPRING CONSTANT, X = DISPLACEMENT
VEL = VELOCITY, ACC = ACCELERATION, XO = INITIAL DISPLACEMENT
CONSTANT M = 1.5. C = 4.0, K = 150.0. XO = 1.0
ACC = (-K*X - C*VEl)/M
X

=

VEL

INTGRllXC,VEL~

=

INTGRLlO.O,ACC)
VEL, Ace
TITlE
SIMULATICN OF A SPRING-MASS-DAMPER SYSTEM
TIMER FINTI" = 2.0, PRDEL = 0.C5
END
STOP
ENDJOB
PRINT X,

CONSTANT M = 1.5, C = 4.0, K = 150.0, XO = 1.0
The fourth card is an ordinary FORTRAN statement used to calculate the
acceleration (ACC). Statements 5 and 6 use a special mathematical function
(INTGRL) that is unique to CSMP. The INTGRL statement represents the mathematical function of integration as defined by Table 2.1.
Table 2.1
Formulation for Integration

Y

IC

Mathematical Function
y=

S: Xdt +

Ie

= INTGRL(IC, X)
=

YeO)

Equivalent Laplace transform
X(S)--->-I

4
5
6

12

CONSTANT. The word CONSTANT must be the first label on the card
and must be followed by at least one blank space. Otherwise, after this first blank
space, blanks are not considered. Successive variables can be set equal to constants (both real and integer) by putting the variable name on the left side of the
equal sign. A comma following a numeric value permits another assignment.
Notice that a comma should not be placed after the last number. A CONSTANT
statement must be continued to following cards by the use of three consecutive
periods( ... ). The format of the CONSTANT card used in this example is

Definition: Integration

2

3

7
8
9
10
11

Fig. 2.5 Program for simulating spring-mass-damper system.

CSMP Form

1

! 1--->-

Y(s)

16

Fundamentals of System/360 CSMP

Ch. 2

In the definition presented in Table 2.1, the integration is with respect to the
independent variable t. The symbol TIME is a reserved word in the CSMP program and is used to represent the independent variable. The integrand can be an
algebraic expression, but the initial condition (IC) of the INTGRL function must
be a constant or symbol. If the INTGRL function is included as part of a statement,
it must be the rightmost part of the expression.
Allowed

Y
Y
Y

=
=

=

Not Allowed

INTGRL(7.0, X-Z)
10.0 + INTGRL(Q,X)
3.0*INTGRL(Q,X)

Y
Y
Y

= INTGRL(3.0 + 4.0, X-Z)
= INTGRL(Q,X) + 10.0
= INTGRL(Q,X)*3.0

INTGRL is only one of several mathematical functions available to the
CSMP user. A listing and a definition for all functions are contained in Appendix I.
The fifth and sixth statements of Fig. 2.5 represent the integration of Eqs
(2.2) and (2.3). In statement 5, the velocity VEL is integrated to obtain the displacement X with the initial condition of XO. In the same manner, the sixth statement will perform the integration of the acceleration ACC to obtain the velocity
VEL with the initial velocity equal to zero. The seventh card is a PRINT statement
which has the following general definition.
PRINT. The PRINT card is used to specify the variables that will be printed
at each specific interval during the simulation. All variables following the PRINT
label plus the independent variable TIME will be printed and correctly labeled.
A comma must be inserted between successive variable names and at least one
blank space must follow the PRINT label. The PRINT label should appear only
once in the program. If more than one PRINT statement is included, only the last
will be executed. If necessary, three periods ( ... ) can be used to continue to following cards. An example of the PRINT statement is:
PRINT X, VEL, ACC

A column format is automatically used for output when there are less than
nine dependent variables printed. An example of this is shown in Fig. 2.6 which
is the output of the program of Fig. 2.5. Up to forty-nine dependent variables can
be printed. When more than eight are specified, an equation-form output format
is used as shown in Fig. 2.7. Notice that the output for both Figs. 2.6 and 2.7 is
E-format with five significant digits. The user has no other choice of output format
when using the CSMP PRINT statement. The eighth card in the program is a
TITLE statement.
TITLE. The TITLE card allows the user to specify a heading that will appear
at the top of each page of printed output. At least one blank space must follow the
label TITLE and the first character must be a number or an alphabetic letter.
Continuation to successive cards is not permitted, but up to five TITLE cards can

17

Fundamentals of Systemj360 CSMP

Ch. 2

SIMULATION OF A
TIM E

SPRING-~ASS-CAMPER

RKS

INTEGRATION

Ace

VEL

X

0.0
i.OOOOE 00
5. OOOuE -u2
8.8283E-01
1.OOOuE-Ol
5.7793E-01
1.500ul::-01
1.7863E-01
2.0000E-0l -2.1l17E-01
2.~000E-ul -5.0491E-01
3.00 OOE -01 -6.4574E-Ol
3.5000E-Ol -6.20'18E-Ol
4. OOOuE -01 -4.5698E-01
4.S000E-01 -2.C871E-01
5.0000E-01
5.6407E-02
~. 500uE-Ol
2.755lE-01
I).OOUOE-01 4.0411E-Ol
6.500uE-Ol
4.24041:-01.
7.0000E-Ol
3.4430E-01
7 .5000E -0 1
1.9559E-Ol
8.0000E-Ol
2.0609E-02
8.5000E-Ol -1.3725F-Ol
9. QOaOE-Ol -2.4395E-Ol
9.5000E-Ol -2.8142E-Ol
1.0000E 00 - 2 • 4<; 71 E- 0 1
1.050uE 00 -1.6472E:-01
i • .i.OOOE 00 -5.258'1E-02
1.1500E: 00 5.7602E-02
1.2000E 00
1.4084E-01
1.2500t: 00
1.8140E-01
1 • .j0 JuE 00
1.7533E-01.
1.J500E OU
1.29831:-01
1.4000E 00 6.0245E-02
1.45001: 00 -1. 4458E -02
1.5000E 00 -l.6524E-02
1.550uE 00 -i.1330E-Ol
J..6000E 00 -1.1952f-01
1.6500E: 00 -9.757H-02
1. lOOOE 00 -5.5995E-02
1.1500E 00 -6.7754E-03
1.bOOOE 00 3.7855E-02
1.8S00E 00
6.8238E-02
1.90uuE 00
7.9l88E-02
1.9500E 00 7.0622E-02
2.0000E 00 4.6938E-02

SYSTEM

0.0
-4.4884E
-1.38181:
-8.2319E
-7.C8391:
-4.4556E
-1.1340E
2.0328E
4.3385E
5.362CE
5.0288E

00
CO
00
00
00
00
00
00
00
00
3.5845~ 00
1.4990E 00
-6.6<;88E-01
-2.4145E 00
-3.3879E 00
-3.46331= 00
-2.7355!: 00
-1.471.6E 00
-2.E1COE-C2
1.24l7F. 00
2.0683 E 00
2.3178E 00
2.C048E 00
1.2714E 00
3.3817E-Ol
-5.5613E-01
-1.2113E 00
-1.5071 E 00
-1.42C6E 00
-i.CInE 00
-4.3434E-Ol
1.110eE-Ol
6. 1160E-0 1
9.5046E-01.
S.7661E-OI.
7.7575 E-Ol
4.2210'::-01
1.5851E-02
-3.4333E-01
-5.18«;8E-Ol

-1.0000E C2
-1.6313E 01
-3.8093E 01
4.0884E 00
4.0068E ot
6.2313E C1
6.7598E 01
5.6617F 01
3.41.29E 01
6.5125E 00
-1.9051E Cl
-3.7109E 01
-4.4409E 01
-4.0618E 01
-2.7991E 01
-1.0524E 01
7.1746E 00
2.1020E 01
2. 8319~ C1
2.8217E 01
2.1.660E 01.
1.0957E 01
-C;.2178E-Ol
-1.1106E 01
-1.7474E 01
-1.9042E 0 I.
-1.6050E 01
-9.7523E 00
-2.0055E CC
5.2340E 00
1.0310E 01
1.2489E 01
1.1480E 01.
7.9662E 00
3.0650E 00
-1..9269E CO
-5.8542E 00
-7.9494E 00
-7.9611E CO
-6.1466E 00
- 3. 149qE 00

Fig. 2.6 Column-type output for spring-mass-damper system.
51 MP

C SMP
T TMf

0.0

X
R

E1
T1MF

1.2500E 01

X
R

E1
TIME

2.5000E 01

X
R

E1
T1MF.

3.7500E 01

X
k

E1
TIMF

5. OOOOE 01

X
R

E1

1.0000E 03
1.0000E 00
1.aOOOE 03

y
V

Tl

2. 2 ~:d 5E 03
4.4376E-01
1.6onE 02

Y
V

5.07tHE 03
1.9692E-01
1.9531E 02

y
V

1.1443E 04
8.7390E-02
2.9722E 02

Y
V

2.5786E 04
3.8180E-02
5.0561E 02

Y
V

Tl

Tl

Tl

Tl

1.0000E 06
0.0
5.0000E 02

00

5.0782E 00
1.186t!E 01
5.1250E 02

T
00

2.5787E 07
2.4423E 01
5.2500E 02

T
00

1.3094E 08
3.1l11E 01
5.3750E 02

T
DO

6.6494E 08
4.9768E 01
5.5000E 02

Z

T
UD

l
T

Z

Z

l

INTEGRATION
4.5176E-05
0.0
1.0000E 09

Q

= -1.2535E 02
= 5.2665E 00
= 1.1444E 10

Q

w

2.8169E 04
7.9347E 08

AB

= -3.3524E 06

= -4.0781E 02
= 4.8094E 00
= 1.3095E 11

(,)

AS

= 1.2695E 05
= 1.6ll7E 10
= - 5. 0577E 07

= -1.0443E 03
= 3.2431E 00
= 1.4984E 12

AB

= 4.2911E 05
= 1.8414E 11
= -4.4347E 08

= -2.478bE 03

IJ

=
=

Fig. 2.7 Example of equation-type output.

1.9300E 00
1.1l4bE 13

w
AB

w

w

AS

0.0
0.0
0.0

= 1.2893E 06
= 1.6623E 12
= -3.1809E 09

18

. Ch. 2

Fundamentals of System/360 CSMP

be used. Each TITLE card provides one line of heading on each page of output.
An example of a TITLE statement is
TITLE SIMULATION OF A SPRING-MASS-DAMPER SYSTEM
The ninth card is called a TIMER statement.
TIMER. The TIMER card is used to specify the variables that control the
run-time, print increment, integration interval (step-size), and minimum allowable
integration interval. In Fig. 2.5, only two TIMER variables are used, FINTIM,
and PRDEL. An example of the TIMER statement is
TIMER FINTIM = 2.5, PRDEL = 0.05

i

i

At least one blank '----A comma must
separate listings
space must follow
the label TIMER
FINTIM. FINTIM is a symbol that appears on the TIMER card and determines the value of TIME (independent variable) at which the run is terminated.
FINTIM is set equal to the desired simulation time. and must be included on the
TIMER card.
PRDEL. This TIMER variable controls the increment for the output of the
PRINT statement. If the value for PRDEL is not specified, it is automatically set
equal to FINTIMjlOO. If a value of OUTDEL is also included on a TIMER
card, the output increment of the PRINT statement can change. At this point,
there is no need to explain the relationship between PRDEL and OUTDEL, since
it will be covered later in this chapter.
The three other variables that can appear on the TIMER card are defined
below. A detailed explanation is included in Example 2.2 and in Chap. 3.
OUTDEL. Print increment for the print-plot output
DELT. Integration interval
DELMIN. Minimum integration interval
The format for specifying the above variables on a TIMER card is similar to
a CONSTANT card. At least one blank must follow the label TIMER, and successive listings of variables must be separated by commas. The order in which the
variables are listed on the TIMER card is not important.
The last three statements (END; STOP, and ENDJOB) must be included to
signify the end of the program. These cards must appear in the order shown in
Fig. 2.5 and the ENDJOB statement must begin in the first column. For more
complicated simulations, the END, STOP, and ENDJOB cards can be used to
control the execution of the program. A detailed explanation will follow when
advanced topics are considered in Chap. 3. For most simulations the user needs
only to use these cards to signify the end of the program.
Example 2.2 Simulation of a Block Diagram

The previous example illustrated one of the principal attributes of CSMP, the solution of a differential equation. Another important application is determining the response

Ch.2

19

Fundamentals of System/36D CSMP

of a system that is modeled as a block diagram. Block diagram representation of a system
is often used in control system analysis and design. However, the concept of a block
diagram is not restricted to control systems alone. In fact, this application extends to such
areas as physiology, transportation, energy conservation, and economics.
The basic premise of the block diagram, or signal-flow graph, stems from the application of Laplace transforms or operator notation. For example, a system might be represented by the second-order, linear, time-invariant differential equation

d~~}t) + A d~~t) + Bx(t) =

ku(t)

(2.4)

If dx (O)/dt = x(O) = 0, application of Laplace transforms yields

Xes)
U(s)

=

K

(2.5)

+ As + B

S2

In the sense of the block diagram, the above relationship can be represented by the configuration shown in Fig. 2.8.

I

U(s) ) s2+As+B
K

X(s)
I----~)

Fig. 2.8 Block diagram representation

of a second-order differential equation.

Laplace transforms and block diagrams offer the convenience of analyzing a system
without the necessity of working directly with the system equations. In effect, the Laplace
transform changes a linear differential equation to an algebraic expression.
Suppose we consider the simplified schematic diagram of a position control system
shown in Fig. 2.9. Neglecting viscous friction and the electrical time-constant of the motor,
this position control system can also be represented by the block diagram of Fig. 2.10.
Generally, the block diagram is much easier to work with than the schematic.
As an example, suppose the parameters in Fig. 2.10 have the values of Km = 4,
R

D.C. motor

r------ -l Output

R
R

Summing
amplifier

Gain

Power
amplifier

:
I

(8 0

)

~---,.

I
I

I
I

IMechanical
Error pick-off

Input

-~~--~~-----<

I linkage

I
I
I
I

h

Fig. 2.9 Simplified schematic diagram of a position control sys-

tem.

20

Ch.2

Fundamentals of System/360 CSMP
Lumped
parameter
gain

D.C. motor

+

Fig. 2.10 Block diagram of the position control system.

Kl = 1.5625, and a = 2. We desire to simulate the response of the system to a unit-step
input.
To solve this problem, we first restructure the system diagram so that it is compatible
to CSMP modeling. A suitable diagram for this purpose is presented in Fig. 2.11.
Two basic dynamic blocks are present in this representation and can be broken out
as separate entities as follows:

X2'1

(~ ~ 1) 1__X_l~)

~

Block A

{- I OUTPUT,
BlockB

There is no real significance attached to the order of the blocks, block A could have
appeared as the block nearest the output and preceded by block B. The arrangement of the
blocks, for linear systems, is a matter of user preference. The symbols Xl, X2, X3,
ERROR, etc., are intermediate variables. They could have been designated by other
symbols up to six characters in length. It is normally desirable to use variable names
which describe physical variables in the problem. A significant point that should be made
is that each block must have an input and an output variable. For example, X2 is the
input and Xl is the output for block A; whereas, Xl is the input and OUTPUT is the
output of block B.
Blocks A and B have special meaning in CSMP. In a sense they are represented as
subprograms and can be executed by simple statements. The mathematical functional
relationship for block A is shown in Table 2.2. The 1/s term (integration) was previously
discussed in Example 2.1.
Table 2.2
Formulation for First Order Lag

General Form
Definition:

1ST ORDER LAG

(Real pole)
Y

=

IC

=

REALPL(IC, P, X)
YeO)

Function

pdY +Y=X
dt

Laplace form: Ps
Xes)

~

1

+1
yes)

)~I---~)

Ch.2

21

Fundamentals of System/36D CSMP

INPUT
(8;)
t

Fig.2.11 A CSMP representation of the system in Fig. 2.10.

I

•

These formulations help explain why the original system was subdivided as given in Fig.
2.11. Note that the general form for REALPL is l/(Ps + 1). This means that when we
encounter terms of the form l/(s + a) we must divide the numerator and denominator by
a. This changes the form to (l/a)/(s/a + 1) and the (l/a) term in the numerator can either
be associated with another constant or represented by a single block as follows.

A program listing for the CSMP simulation of this problem is presented in Fig. 2.12.t
For convenience, the CSMP block representation corresponding to this program is
*
*

CSMP PROGRAM FeR 'EXA~PLE 2 - ALOCK DIAGRAM OF SECOND ORDER SYSTEM
NOTE THAT THE ASTERISK IN COLUMN ONE SIGNIFIES A COMMENT STATEMENT

TITLE PRINTED LISTING OF "OUTPUT" (SIMULATION) AND "OUTEXT" (ANALYTICAL'
* THE TITLE IS ALWAYS GJV~N AT THE TOP OF THE "PRINTED LISTING" PAGE(SI
INPUT
STEP(O.O'
ERROP
INPUT - OUTPUT
OUTPUT
INTGRL(0.0,X1I
Xl
REAlPL(0.0,l.0/2.0,X2)
X2
2.0*X3
X3
1.5625*ERROR
* THE FOLLOWING ST~TEMENTS ARE NOT PART OF THE CSMP SIMULATION. THEY
*ARE USED TG CALCULATE THE EXACT SOLUTION OF "OUTPUT" FOR COMPARISON
OUTEXT = 1.0 - (EXP(-WN*lETA*TIMt)t/SQRT(l.O - lETA*lETA})* •••
SIN(WN*SQRT(l.O -ZETA*ZETA)*TIME + THETA)
WN
= 2.5
ZETA
= 0.4
THETA
= ATAN(SQRT(l.O - lETA*ZETA)/ZETA)
* END OF SPECIAL CALCULATION SFCTION FOR "OUTPUT" COMPARISON
TlMERFINTlM = 5.2, OUTDEL = 0.16, PRDEL = 0.04
PRTPLT OUTPUT(ERRORI, ERROP(,0.51
PRINT OUTPUT, OUTEXT
LABEL STEP RESPONSE FOR SECOND nRDE~ SYSTEM
END
STOP
ENDJOB
Fig. 2.12 CSMP listing for Example 2.2.

tThe symbol OUTPUT cannot be used in a CSMP III program since it is a reserve word
that has a special meaning. To run this program on CSMP III, the symbol, OUTPUT, must
be replaced by another symbol.

22

Fundamentals of System/360 CSMP

INPUT
(9;)

Ch. 2

+_l_HIJ
a
ERROR

1

(s/a + 1)

s

Fig. 2.13 Programming block diagram for Example 2.2.

OUTPUT
(9 0

)

I

repeated in Fig. 2.13. One can easily relate the input-output variables of the blocks in
Fig. 2.13 to the statements given in the program listing. Since the arrangement of the cards
is not unique, one may start with any block and proceed to describe the system.
Several new terms have been introduced in this problem that were not used in Example 2.1. These terms include PRTPLT, OUTDEL, STEP and LABEL. A general definition
of these terms will be given before examining the computer output for Example 2.2.
PRTPLT. An example of a PRTPLT output is given in Fig. 2.14. PRTPLT
statements are used to specify those variables that the user desires to be printerplotted. Continuation cards are not allowed, but up to ten separate PRTPLT
statements containing 100 variables can be used. A card giving a typical PRTPLT
request might appear as
PRTPLT Xl, OUTPUT, ERROR
In this case, separate printer plots will be made for Xl, OUTPUT, and ERROR.
Another useful feature of the PRTPLT request is the capability of printing up to
a maximum of three additional problem variables on the same page as the printerplotted variable. These additional variables appear on the far right side of the page
in column format. The statement
PRTPLT X1(ERROR, OUTPUT), X2, OUTPUT
means that separate printer plots will be made for Xl, X2, and OUTPUT. In addition, the values of ERROR and OUTPUT will be printed on the right side of the
pages that give the printer-plot of XI.
The range and scale ofa printer~plotted variable can be controlled as follows:
PRTPLT
PRTPLT
PRTPLT
PRTPLT

SIGX(0.2, 3.0)
SIGX(, 4.0)
SIGX(-1.2,)
SIGX(O.4" XOUT)

statement
statement
statement
statement

(1)
(2)
(3)
(4)

The information given by each statement is:
Statement (1)-The printer-plot of SIGX will not show values less than 0.2
or greater than 3.0. Consequently, the scale of the printer-plot will be adjusted
for a maximum of 3.0 and a minimum of 0.2.
Statement (2)-The printer-plot of SIGX does not have a specified lower
bound but the upper bound is 4.0.

ST~P

qESP~NSE

FOR SECONr CPDEP
~If>iIMU~

PAGE

SYSTE~

OUTPUT VERSUS TIME

0.0

TI

~f

0.0
1.60001:-01
3.2000F-Ol
4.8COJE-0}
6.4CCOE-Ol
8.0COO'=-01
9.6000'=-01
1.12eOI: 00
1.2800E 00
1.4400E 00
1.6COO~ 00
1.1600~

00
1.9200E 00
2.08001: 00
2.2400F 00
2.4CCOE 00
2.56COE 00
2.7200F 00
2.88eOE 00
3.040Cf. 00
3.2000!.= 00
3.3600E 00
3.5200E 00
1.6800= 00
3.8400E 00
4.0000= 00
4.16001: 00
4.3200'= 00
4.48001? 00
4.6400E 00
4.g000E 00
4.9600E 00
5.12eOE 00
5.2000r: 00

~

MAXIMUM
1.2531E 00

OUTPUT
0.0
1.1172~-02

2. 48~51=- 01
4.1856;:-01
7.1618[-01
9.2708E-OI
1.0901f 00
1.1963E 00
1.2468': 00
1.2502E 00
1.2189= 00
I. let 5~ 00
l.lObOE 00
1.0478': 00
9.9900f-Ol
9.6313£-01
Q.430£'=-01
Q.3568E-Ol
9.3904=-01
Q.4971E-01
'1.6426':-01
9.19t5E-01
9.~358E-Ol

1.0046':= 00
1. all <:1= 00

1.0156;: 00
1.0162E 00
1.0J451;' 00
1.0112= 00
1. 0014~ 00

1.00)6'=' CO

1.000'3E CO
9.9792E-01
9.9707E-Ol

I
+
--+

---------+
-------------------+
----------------------------+
------------------------------------+
-------------------------------------------+
-----------------------------------------------+

----------~--------------------------------------+
------------------------------------------------~+

------------------------------------------------+
----------------------------------------------+
--------------------------------------------+
-----------------------------------------+
---------------------------------------+
--------------------------------------+
-------------------------------------+
-------------------------------------+
-------------------------------------+
-------------------------------------+
-------------------------------------~+
---------------------------------------+
---------------------------------------+
---------------------------------------~+

----------------------------------------+
----------------------------------------+
----------------------------------------+
----------------------------------------+
----------------------------------------+
----------------------------------------+
----------------------------------------+
---------------------------------------+
---------------------------------------+
---------------------------------------+
Fig. 2.14 Printer-plot for step response of Example 2.2.

f.RR'JR

1.0000E 00
9.28831=-01
7.5l65E-01
5.2t44f-01
2.8382F.-Ol
7.2920E-02
-9.0071E-02
- t. 962 6E" - 0 1
-2.4684F.-Ol
-2.5023F.-Ol
-2.1BR7E-Ol
-1.6653E-Ol
-1.0602;:-01
-4.1760f.-02
1.00ISE-03
3.6Z13E-02
5.6994{=-02
6.4324f-02
6.0Q6':3':-02
5.02-86E-02
3. 5139~-02
2.0'346F-02
6.4203F-03
-4.5576E-03
-1.l91lF.-02
-1.564!E-02
-1.6236E-02
-1.4412F-02
-1.1236E-02
-7.3662E-03
-3.5t>10E-03
- 3. ,_ 316E - 04
2.0832E-03
2.92'BF-03

24

Ch.2

Fundamentals of System/360 CSMP

Statement (3)-SIGX will not have printer-plotted values less than -1.2.
The upper bound is unspecified.
Statement (4)-The printer-plot of SIGX has a lower bound of 0.4 and the
upper bound unspecified. Also, XOUT will be listed on the right side of the SIGX
printer-plot. Finally, printer-plots can only be made using the independent variable (usually TIME) along the abscissa and the requested dependent variable as
the ordinate. In other words, it is not possible to plot two dependent variables
simultaneously as in a phase-plane plot.
OUTDEL. OUTDEL controls the output increment of the independent variable for printer-plots. If printer-plot points are desired every 0.04 time-units, we
use OUTDEL = 0.04. The OUTDEL specification is included on the TIMER
card. A typical example of an OUTDEL assignment is
TIMER FINTIM

=

10.0, OUTDEL

=

0.02

If printer-plots are requested but OUTDEL is not specified, the program will use

an OUTDEL = PRDEL. If PRDEL is not given in the program, OUTDEL is
set to FINTIMjlOO. When OUTDEL and PRDEL are both specified, the smaller
of the two will be adjusted to be a submultiple of the larger. A useful guide in
selecting the OUTDEL interval is that each page of OUTPUT will contain fifty
lines. Thus, if the user desires the printer-plot to be contained on one page only,
the OUTDEL value should be OUTDEL = FINTIMj50. In general, the OUTDEL selection, based on the number of pages for the plot, is given by OUTDEL =
FINTIMj(50 x number of output pages).
STEP. STEP is one of several signal sources available in CSMP. This particular signal provides a unit-step forcing-function and is described in Table 2.3.
Table 2.3
Formulation for a Unit Step Signal

Function

General Form
Definition:

Unit-step input

or forcing
function.

y= 0 t < T
Y=1 t>T

~
.O

Y

=

STEP(T)

Y

T

t

A unit-step input applied at t = 0 is expressed by
XIN

= STEP(O.O)

If the input forcing-function is a step of weight 3 applied at t

is written as
XIN

= 3.0*STEP(2.4)

=

2.4, the expression

Ch. 2

Fundamentals of Systemj360 CSMP

25

LABEL. LABEL cards are used for placing an open-format title or heading
at the top of each page of printer-plotted output. The first non-blank character
following LABEL must be alphabetic or numeric. After the first non-blank
character, special symbols (=, /, *, etc.) may be used within the heading. As with
PRTPLT cards, continuation cards are not permitted, but up to ten LABEL
cards may be used for each simulation. Consider the following illustration.
PRTPLT ROVER, SIGMA
LABEL RESPONSE OF SYSTEM MODEL - PROBLEM I
PRTPLT Xl
LABEL STATE Xl WITH INITIAL CONDITION X2 = 2.0

Since the first LABEL statement is associated with the first PRTPLT statement,
the second with the second, and so on, the heading, RESPONSE OF SYSTEM
MODEL-PROBLEM 1, will appear at the top of each page of printer-plotted
output for the variables ROVER and SIGMA. The printer-plot of Xl will have
a heading of STATE Xl WITH INITIAL CONDITION X2 = 2.0. If the number
of PRTPLT cards exceeds the number of LABEL cards, the excess print-plots
will not have headings.
Refer to Fig. 2.12 and consider the following portion of the listing:
TIMER FINTIM = 8.0, OUTDEL = 0.16, PRDEL = 0.04
PRTPLT OUTPUT (ERROR), ERROR (, 0.5)
LABEL STEP RESPONSE FOR SECOND ORDER SYSTEM
PRINT OUTPUT, OUTEXT

The TIMER card gives the information that the simulation will run for 8.0 sec,
printer-plotted output will occur every 0.16 sec, and printed output every 0.04 sec.
We note that with a FINTIM of 8.0 and OUTDEL of 0.16, there will be one page
for each printer-plotted variable (number of pages = FINTIM/(OUTDEL *50).
The PRTPLT card specifies printer plots for OUTPUT and ERROR. The
plot for OUTPUT will have ERROR given in tabular form at the right side of the
page. The plot of ERROR will have an upper bound of 0.5. The heading, STEP
RESPONSE FOR SECOND ORDER SYSTEM will appear at the top of each
page of printer-plotted output. The printer-plot for OUTPUT is given in Fig. 2.14
while Fig. 2.15 shows the plot for ERROR.
The PRINT card designates that OUTPUT and OUTEXT will be printed
out. As indicated in the program listing of Fig. 2.12, the exact analytical solution
(OUTEXT) is calculated. Notice also in Fig. 2.16 the very close agreement between
the CSMP numerical solution (OUTPUT) and the exact analytical solution. This
is an indication of the accuracy that can be expected.
Example 2.3 Solution of the Van der Pol Equation

This example illustrates the ease of solving a nonlinear differential equation for
various parameter values. The particular example is the well-known Van der Pol equation,
which is shown below with the selected initial conditions.

26

Ch.2

Fundamentals of System/360 CSMP

STEP RESPONSE FOR SECOND CROfR

SYSTE~

PAGE

MINIMUM
TtH
0.0
1.6000E-01
3.2000E-01
4. 8COO~-01
6.4000E-OI
8.0000E-Ol
9.6000E-01
1.1200E 00
1.l800E 00
1.4400E 00
1.6000E 00
1.76COE 00
1.9200E 00
2.0800E 00
2.2400E 00
2.4000E 00
2.5600E 00
2.7200E 00
2.8800E 00
3.0400E 00
3.2000E 00
3.3600E 00
3.5200E 00
3.b800E 00
3.8400: 00
4.0000E 00
4.1600E 00
4.3200E 00
4.4800E 00
4.6400':: 00
4.8000£ 00
4.9600E 00
5.1200E 00
5.2000E 00

VER SUS TIME

ERROR

7. 5it 5E-Ol
5.2144E-01
2.8382E-01
1.2920E-02
-9.00112-02
-1.9626E-01
-2.4684E-01
-2.5023E-Ol
-2.1381E-Ol
-1.6653E-Ol
-1.0602E-01
-4.1160E-02
1.0018::-03
3.6273E-02
5.6984E-02
6.4324E-02
6.0963E-02
5.0286E-02
3.573QE-02
2.0346E-02
6.4203E-03
-4.5576E-C3
-1.1911E-02
-1.5641E-02
-1.6236E-02
-1.44nE-02
-1.1236E-02
-1.3662E-03
-3.5610E-03
-3.1316E-04
2.0832E-03
2.9293E-03

MAXIMUM
5.0000E-01

-2. 'BnE-Ol
ERROR
J
1.0000E 00
9.2883::-01

I

--------------------------------------------------*
--------------------------------------------------*
--------------------------------------------------*
::::::::::::::::::::::::::::::::::::--------------,*
---------------------+
----------+
---+
I
Note that the plotted value of
ERROR does not exceed the
specified value of 0.5

+
+

::~ __ +

I

---------+
-------------+
----------------+
-------------------+
--------------------+
---------------------+
--------------------+
--------------------+
-------------------+
------------------+
-----------------+
----------------+
----------------+
---------------+
---------------+
---------------+
----------------+
----------------+
----------------+
----------------+
----------------+
-----------------+

Fig. 2.15 System error response for Example 2.2.

x + £(X2 -

I)X

+X

=

X(O)

= 2.0

0

(2.6)

X(O) = 0.0

A helpful first step is to change the second-order differential equation to an equivalent
set of first-order equations, easily accomplished as
(2.7)

X=XD
X= XDD

= -£(X2 -l)XD - X

(2.8)

The program for solving Eqs. (2.7) and (2.8) is straight forward, as shown in Fig.
2.17. An ordinary FORTRAN statement is used to calculate xnD and two INTGRL
functions are used to integrate XDD and XD to obtain XD and X, respectively.
In this example the following PARAMETER card is used to make a sequence of
simulation runs for five different values of the constant E.
PARAMETER E

=

(0.05, 0.5, 2.0, 10.0, 50.0)

One separate run is made for each value of E. Figs. 2.18 and 2.19 show the printer-plot
outputs for E = 2.0 and E = 50.0. Note that the parameter value E is listed at the beginning of each plot and on each page of PRINT output.

Ch.2

Fundamentals of Systemj360 CSMP
PRI~TED

LISTING OF "QUTPUT"

(SIMULATI~NI

27

AND "OUTEXT" (ANALYTICAL»

r------- CSMP Solution

1
TIME
0.0
4.0000E-OZ
8.0000E-OZ
1.2000E-Ol
1.6000!:-01
2.00001.:-01
2.4000'=-01
Z.BOOOE-Ot
3.2000E-Ol
3.6000E-Ol
4.0000E-01
4.4000"=-01
4.8000E-01
5.20COE-Ol
5.6000E-Ol
6.00001:-01
6.4000'=-01
6.8000E-Ol
7.2000E-Ol
1.60COE-Ol
a.OOOOE-OI
8.40COE-01
A. 9000E-Ol
9.2000E-Ol
9.60COE-OI
1.0000'= 00
1.0400E 00
l.oaOOE 00
1.1200E 00
1.1600!: 00
1.2000E 00
1.2400E 00
1.28 co;: 00
1.3200E 00
1.3600E 00
1.4000E 00
1.4400': 00
1.48COE 00
l.5l00E 00
1.5600'= 00
1.60COE 00
1.6400E 00

OUTPUT
0.0
4.8652E-03
1.8912E-02
4.1300E-02
7.1172E-02
1.0767E-Ol
1.4992E-Ol
1.9710E-01
2.4835E-Ol
3.0288E-Ol
3.5991E-Ol
4.181lE-01
4.7856E-Ol
5.3aa2E-01
5.98 88E- 0\
6.5817E-Ol
7.1b"8E-Ol
7.7246E-Ol
8.2660E-Ol
8.7824E-0l
9.2708E-Ol
9.7286E-01
1.0154E 00
1.0545E 00
1.0901E 00
1.l220E 00
1.1504E 00
1.1751E 00
1.1963f 00
1.2139E 00
1.2281E 00
1.2390E 00
I.Z468E 00
1. 251 7~ 00
1.2537E 00
1.2532E 00
1.L502E 00
1.245lE 00
1.2380E 00
1.2292E 00
1.21891: 00
1.2072E 00

r

Analytical Solution

(lUTEXT
4.7684f-07
4.8663E-03
1.89131:-02
4. 1300E-02
7.1172E-02
1.0767E-01
1.49nE-01
1.9710[-01
2.4A35f-Ol
3.0288E-01
3.599H-01
4.1871E-Ol
4.1856£-01
5.3883E-01
5. g888E-01
6.5817E-O'1.
1.l619E-01
7.7247E-Ol
B.2660E-Ol
S.7824E-Ol
9.2708E-01
9.72P7f-Ol
1.0154E 00
1.0545E 00
1.0901 E 00
1.1221E 00
1.1504= 00
1.1751'=' 00
1.~.0010 OJ
2 .500v E OJ
,.7~OJE

0.1

J.OOOuE 00
OJ
3.5JOJE OJ
3.7:>OuE OU
4.vOOOE JO
4.2jJO~ 00
".500ve OV
4.75vve OJ
5.0QQOE 00
:>.250J1: 00
>.5uuJE UO
5.7,OOE OU
o.OOOOE uJ
b.2 SOve 00
b.500uE 00
o.7500E 00
7.0000t OJ
1.2~Oue 00
1.5000E 00
1.nOOE 00
iI.OOOJE OJ
8.2S00E OU
1i;5 QuJE .10
8.150010 00
9.000UE uO
9.2500E 00
9.50vOE Ou
9.750uE OJ
1 .0uOO E \)1
3.2~00t:

PAGE
VERSUS TIME

MAXIMUM

~ 5.0000E 01
2.0174E 00
- 2. Cl c; 7" 00
I
XD
I
0.0
2.0000= 0C
- ------- ---- --- ---------------------------------- +
1.9967t 00
-1.3368E-02
---- ---- ---- --- ----- ------------ ---- ----------- --+
-1.3156E-02
1.9934= CC
1.'1900E 00
-1.3320E-02
1.9B6t>E OC
-1.3462E-02
--- - - --- ---- --- -------- - --- - ---- ----------------- +
-1.3293E-02
1.9833= OC
1.9799E CO
-1.3544E-02
-1.3564E-02
1.9765E OC
- -- - - --- -- -- - -- -- ------- -------- ---- ----------- --+
-1.3620E-02
1.97311' 00
1.9(,96E 00
-1.3643E-02
-1.3l08E-02
1.9662E DC
-1.3156E-02
1.96281' CO
-1.3802E-02
1.9S93E CC
1.9S59E 00
-1.3831E-02
-1.3Bl0E-02
1.9524E 00
-1.3918E-02
1.9489" CC
-1.3961E-02
1.9454E 00
- --- ---- ---- ----------- ------------------------ --+
-1.3978E-02
1.9419E OC
-1.4058E-02
1.9384E 00
1.9349E,)0
-1.4013E-02
-1.4147E-02
1.9313<: OC
--------- ---- ----------- -------- ---------------- +
-1.4190E-02
1.927IlE 00
-------- ---------------- ---------------- -------1.lt235E-02
1.9242~ OC
-- ---- -- - - -- ------ -------------- ---------------- +
-1.4125E-02
1.9206E 00
1.9171E CO
-1.lt331E-02
-1.4322E-02
1.9135= OC
-1.4426E-02
1.9099~ 00
-1.4474E-02
1.9062E CC
1.9026;: 00
-1.4523E-02
-1.4512E-02
1.8990E 00
-1.4552E-02
1.8953= OC
-- - - - --- - --- --- -- ------ -- ---- --- -------- -------- +
-1.46l2E-02
1.891 7E 00
-1.4677E-02
1. 88BO~ CC
-1.4140E;"02
1.8843E 00
-1.4809E-02
1.BBObE CO
- -- ------- -------- ----- ------------------------- +
-1.4879E-02
1. B769E OC
-1.4893E-02
1.BBIE CO
-1.4968E-02
1.B694E CO
-1.5030E-02
1.Bb56E 00
-1.5072E-02
1.B618E 00
-------- - --- --- - -------------------------------- +
-1.5145E-02
1.B58H: OC
----~-------------------------------------------+

X

TI ME

29

---- -------- -------------------------------------+
-------------------------------------------------+

-------------------------------------------------+
------ --------- ----------------------------------+

---- ---- -----------------------------------------+
-------------------------------------------------+
---- ---------------------------------------------+
--------------- ----------------------------------+
-------- ------- ----------------------------------+
-------------------------------------------------+
------------ -------------------- -----------------+

----------.--------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
------------------------------------------------+

-.

------------------------------------------------+
-------- -- --------------------------------------+
--- ---------------------------------------------+
------------------------------------------------+
------------------------------------------------+
------------------------------------------------+
------------------------------------------------+

------------------------------------------------+
------------------------------------------------+
------------ ------------------------------------+

------------------------------------------------+
------------------------------------------------+
------------------------------------------------+
------------------------------------------------+

XDD
-2.0000E 00
-2.5845E-04
-3.7365E-02
-1.8501E-02
-3.1214E-03
-3 .. 3574E-02
-2.1t862E-03
-5.3825E-03
-2.9l64E-03
-5.4636E-03
-1.8091E-03
-8.8120E-04
-1.8l81E-04
-2.0018E-03
-2.4099E-03
-1.6050E-03
-1.5526E-03
-5.2lt52E-03
-2.2030E-01t
-It.2686E-03
-2.8l06E-04
-4.9400E-04
-5.8210E-04
-2.1666E-02
-2.6l03E-04
-7.7343E-03
-2.0nOE-04
-2.0504E-04
-2.050ltE-04
-1.9346E-03
-9.2669E-03
-2.1172E-04
-6.0024E-03
~.5366E-03

-2.4033E-03
-2.2888E-04
-5.0983E-03
-2.4109E-03
-1.5574E-03
-3.0l08E-03
-1.0271E-03

Fig. 2.19 Printer-plot output for solution of Van der Pol equation

E = 50.

of variable name, equal sign, and numerical assignment. Additional assignments
are made on the same card by placing a comma after the numerical value. Any
number of assignments may appear on a card. Up to eight continuation cards are
allowable by using three consecutive periods at the end of the card. Valid applications are
PARAMETER AX = 6.0, MW = 2.0, TAU = 1.0, ...
RHO = 0.1, GAMMA = 6.2E - 03
PARAM EDGE = 3.2, START = 6.4, LAST = -0.5
lNCON lCXl = 0.115, lCX2 = 0.0
CONST ALPHA = 1.35, BETA = -6.134
CONSTANT X = 5.6, Y = -45.78

where all of these cards are used in the same program. The results of the simulation would have been unchanged by using
CONSTANT AX = 6.0, MW = 2.0, TAU = 1.0, .. .
RHO = 0.1, GAMMA = 6.2E - 03, lCXl = 0.115, .. .
lCX2 = 0.0, ALPHA = 1.35, BETA = -6.134, ...
X = 5.6, Y = -45.78, EDGE = 3.2, START = 6.4, ...
LAST = -0.5

30

Ch.2

Fundamentals of Systemj360 CSMP

In the above, CONSTANT could be replaced by either INCON or PARAMETER.
Calculations are not allowed in a data statement. An example of an invalid
statement is shown below.
CONSTANT X = 5.8, Y = 4.2/3.14
LIllegaloperation
As illustrated in Example 2.3, an attractive feature of these data statements
is their capability of making sequential runs. A typical statement is
INCON ICX1 = (0.0, 2.0, -1.2, 6.0), ICX2 = 2.3
The program will make four simulation runs in which leXl is assigned the values
appearing in the parentheses in the order given from left to right. The value of
ICX2 = 2.3 is used for each run. As a slight modification one may use
PARAMETER ICX1 = (0.0, 3*0.2, 1.4, 2*2.0)
which will result in seven simulation runs with the values of ICXl being 0.0, 0.2,
0.4, 0.6, 1.4, 2.0, 4.0. A maximum of fifty runs can be made in any sequence.
Only one variable can be used to make sequential runs. Examples of invalid
data statements which attempt to make sequential runs using two variables for
two different programs are
PARAMETER X = (2.0, 5.0, 9.0), Y
CONSTANT X = (2.0, 5.0, 9.0)
PARAMETER Y = (3.0,4.0, 7.0)
Example 2.4

=

(3.0,4.0, 7.0)

Transient Temperature Response

In some simulations it is necessary to use functional relationships that are contained
in tabular or graphic form. Fig. 2.20 shows an example of a graphic relationship between
3

2
y

x
Fig. 2.20 Graphic relationship between X and Y.

Ch.2

Fundamentals of System/360 CSMP

31

X and Y that can be represented by using a FUNCTION statement. Points on the curve
of Fig. 2.20 are entered on a FUNCTION card as illustrated below.

r--Independent variable(X)
~

1

~

1

L

FUNCTION F = (0.5,1.0), (1.0, 2.0), (2.0, 2.5), (2.75, 2.25), (3.5, 1.5)
t
t
t
t
j
Function name
LDependent variable (Y)

L

The symbol F represents the chosen name of this particular function but any other
valid symbol can be used. The independent variable for each point is always listed first
starting with the smallest algebraic value. This variable must monotonically increase to
assure that the slope is neither infinite nor the function muItivalued. Increment size of the
independent variable may be unequal as shown in the above example. Parentheses can be
used to group the coordinates of each point but are not required. Commas must separate
all numbers. The list of values can be extended to additional cards by the use of three
consecutive periods (... ). There are no specific restrictions on the number of points per
function.
The two types of statements which use the data contained on the previous FUNCTION card are
Y
Y

=
=

AFGEN(F, X)
NLFGEN(F, X)

where Y is the dependent variable (ordinate) and X is the independent variable (abscissa).
The AFGEN statement provides linear interpolation between consecutive data
points. In effect, the curve is represented by a series of straight-line segments. The more
closely spaced the points, the more accurate the representation of the function.
NLFGEN uses a Lagrange quadratic interpolation between points. Consequently,
the NLFGEN element cannot accurately represent functions containing abrupt changes.
An example of this is shown by Fig. 2.21.
Notice that the error in using the NLFGEN statement is greatest where the data points
are widely separated and where the curve changes abruptly.
Both AFGEN and NLFGEN functions can be treated as ordinary variables and,
consequently, included as part of structure statements. An example is
Z

=

3.5*AFGEN(F, X)/(3.8 - NLFGEN(L, TIME»

If the value of the input variable is outside the specified range of the function, a
diagnostic message is printed and the simulation proceeds without interruption. The
value returned by AFGEN or NLFGEN is either the first or last dependent variable in
the FUNCTION statement. For example, if the input value of X in the graphical relationship of Fig. 2.20 were 4.0, the output would be 1.5. In a similar manner, the output would
be 1.0 for all input values less than 0.5.
This example illustrates the simulation of the transient temperature response of a
small hot copper cylinder which is quenched in water. Special emphasis is placed on the
use of the FUNCTION statement in conjunction with the AFGEN function.

32

Ch.2

Fundamentals of System/360 CSMP

NLFGEN
AFGEN

o

Data points

Ind~pendent

variable

/

" --.""" /

/

/

/

Fig.2.21 Comparison of curve fit using AFGEN and NLFGEN
functions.

Figure 2.22 defines the physical setup of the problem.
Applying the basic law of heat conduction and assuming uniform cylinder temperature
and constant water temperature yields
TDOT = T = H*AREA*(TA - T)/(RO*C*V)
T
where

=

S: Tdt + TINITL

(2.9)
(2.10)

T

=

temperature of cylinder

TA

=

temperature of water, 530 R

TINITL

=

initial temperature of cylinder, 19600 R

AREA

=

surface area of cylinder

RO

=

density of copper, 559 Ib/ft

C

=

specific heat of copper, 0.0915 Btu/lb-oR

0

=

n(D2/2

+ DL)

3

V

=

volume of cylinder

D

=

diameter of cylinder, 0.02 ft

L

=

length of cylinder, 0.1 ft

H

=

overall heat transfer coefficient, a function of temperature as shown
in Table 2.4.

=

n D2L/4

Data for the heat transfer coefficient is taken from Table 2.4 and entered into the
program on a FUNCTION statement called HBOIL.

Ch.2

--1

r-

Fundamentals of System/360 CSMP
D

= 0.02

33

ft

Copper CYlinder:UT
Temperature = T

L

0

Initial temperature = I 960 R

=0.1

~

ft

Fig. 2.22 Schematic showing the quench-

ing of a hot copper cylinder in water.
Table 2.4
Boiling Heat Transfer Coefficient as a Function
of Temperature

Temperature

Heat Transfer Coefficient

COR)

(Btu/ft 2 -hr-OR)

672.1
673.0
687.0
702.0
737.0
822.0
1082
1672
2672

114

278
667
3680
13200

3680
880
880
1140

Notice that this program contains all three segments: Initial, Dynamic, and Terminal.
The use of the three segments is not required for this particular program, but is included
in order to show a logical classification of the structure statements. The Initial segment
contains both the FUNCTION statement and the CONSTANT card which are used to
specify the parameters of the system, Since the calculations used to determine AREA and
V are only required once, they are included in the Initial segment.
In the Dynamic segment, an AFGEN statement is used to specify H, a FORTRAN
type statement is used to calculate TOOT, and the INTGRL function is used to integrate TOOT to obtain T.

34

Ch. 2

Fundamentals of System/360 CSMP

The run is terminated either by reaching the finish time (FINTIM) or by the control
of the FINISH card.
FINISH. The FINISH label allows the user to terminate a run prior to the
time as specified by FINTIM. A run can be ended when any dependent variable
first crosses or reaches a given bound. In the program of Fig. 2.23, the run will
terminate when T reaches or crosses the value of 682°R, or when TIME reaches
FINTIM. If more than one FINISH card is included, only the last card is considered. A single FINISH statement can contain a maximum of ten terminating
conditions. Continuation to successive cards is permitted.
LAREL
QUENCHING OF A HOT COPPER CYL INUER
INITIAL
CONSTANT RO : 559.0. C : 0.0915. TA : 530.0, L = 0.1, 0 : 0.02 ••••
TINITL : 1960.0. PI : 3.14159
* THE FOLLOWING VALUES LISTED ON THE FUNCTION CARD ARE THE HEAT TRANSFER
* COEFFICIENT AS A FUNCTION OF TEMPERATURE
FUNCTION HBOIL = (672.1.114.0),(673.0.278.0).(681.0.661.0),
(702.Q.36aO.O),(137.0,13200.0J,(U22.0,3680.0),
(1082.0.~80.0),{1672.0,880.0),(2h12.0.1140.0)

AREA: PI*(D*0/2.0 + D*Lt
V : PI*D*D*L/4.0
DYNAMIC
H : AFGEN(HBOIL.T)
TDOT : H*AREA*(TA - TJ/(RO*C*V)
T = INTGRL(TINITl,TDOT)
TER~I NAL
TIMER FINTIM = 0.006, OUT DEL = 0.00001
FINISH T = 682.0
PRTPLT T (H)
END
STOP
END JOB

Fig. 2.23 Program to calculate the transient temperature of a
copper cylinder.

The FINISH statement
FINISH X

t

I

=

-3.0, Y

=

z

i'--_ _---.
I

At least one blank
space after the label
Finish

A comma must separate
all listings

shows two conditions for ending the run. The first condition (X = - 3.0) will
terminate the run when X first reaches or crosses - 3.0. The second requirement
(Y = Z) will end the simulation when Y = Z, or when Y - Z first changes sign.
The run will be terminated when either of the conditions are met.
Since the FINISH conditions are checked at each integration interval, the
run may be terminated at a time that is not a multiple of PRDEL or OUTDEL.
If this happens, printing will occur at the time when the FINISH condition is met.
Figure 2.24 shows the PRTPLT output for the time history of the temperature

Ch. 2

PAGE

OUFNCHING OF A HOT COPPER CYLINDER
MINIMU~

TIM!:
0.0
1.0000E-0,)
2.0000'::-05
3.0000E-0')
4.0000F-05
!) .()OOOE-05
6.0000~-05

1.0000E-05
A.001)0~-05

9.0000E-05
1.00,10F-04
1.1000E-04
1.2000E-04
1.,1}001:-04
1.4000'::-04
1.50001"-04
1.6000E-04
1.7000E-04
1.80001=-04
1.9000F-04
2.0QOOE-04
2.100I'lF-04
2.2000E-04
2.3000E-04
2.4000':-04
2.5000E-04
2. (.OO()F - 04
2.7000':-04
2.6000E-04
7..9000E-{'I4
3.00001=-04
3.1 OOOE- 04
3.2000F.-04
3.3000F-04
3.400'1E-04
3.5000E-04
3.6000F-04
3.7000E-04

35

Fundamentals of System/360 CSMP

T

VHSlJS TIME

6.7907E 02
I

T
1.~oOOr:

03

1.9029E 03
1.84d9E 03
1.1918E 03
1.1493E 03
1.10BE 03
1.6590F 03
1.b116E 03
1.~172F. 03
1.5383E 03
1.5009E 03
1.46481: 03
1.4301E 03
1.3961E 03
1.364~E 03
1.3335E 03
1.3036E 03
l.2149E 03
1.2472E 03

1.2206E 03
1.1949E 03
1.11021: 03
1.14bSE 03
1.123bE
1.10lSE
l.oe02E
1.0Sb6E
1.0279E
9.9394E
9.5509E
9.121bE
H.b658E
6.2011E
7.3674'C
6.9375E
b.8613E
b.8224F
6.7907E

03
03
03
03
03

02
02

02
02

02
02
02

MAXIMUM
1.9600E 03
I

-------------------------------------------------+
-----------------------------------------------+
---------------------------------------------+
-----------------------------~-------------+
-----------------------------------------+
---------------------------------------+
--------------------------------------+
------------------------------------+
-----------------------------------+
---------------------------------+
--------------------------------+
------------------------------+
-----------------------------+
----------------------------+
--------------------------+
-------------------------+
------------------------+
-----------------------+
----------------------+
---------------------+
------~~------------+

-------------------+
------------------+
-----------------+
----------------+
---------------+
--------------+
-------------+
------------+
----------+
---------+
-------+
-----+
--+
+

02

+

02
02

+

+

Fig.2.24 Printer-plot output for temperature of copper cylinder.

of the copper cylinder. Notice that the FINISH card controlled the termination
of the program at TIME = 0.00037 hr.
Example 2.5

Three-Stage Saturn Vehicle

For some types of simulations it is necessary to use conditional branching statements
to control the sequence of calculations. An example of this type problem is the simulated
launch of a three-stage Saturn rocket in which each stage requires different equations to
describe the physical parameters. The FORTRAN IF statement can readily be used to
insure that calculations are performed in proper order.
Figure 2.25 gives the significant system parameters and also shows the forces acting
on the vehicle.
Applying Newton's second law and neglecting all minor effects and disturbances,
the equations of motion for a rocket traveling in a radial direction from the center of

H

9.5488E 02

9.4003E
9.2599E
9.1270E
9.0010E
~.8814E

8.80aOE
8.80aOE
8.80aOE
8.8000E
8.S000E
8.8000E
8.80aOE
a.8000E
8.aoaOE
8.BoaOE
8.80aOE
a.8000E
8.BOOOE
8.8000E
8.BOOOE
8.S000E
8.8000E
a.8000E
8.8000E
d.9888E
1.1537E
1.4629E
1.8283E
2.2468E
2.7090E
3.1999E
3.89l7E

1.3130E
2.02HE
6.4290E
5.3413E
4.4664E

02
02
02
02
02
02
a2
02
02
02
02
02
02
a2
02
02
a2
02
02
02
02
02
02
02
02
03
03
03
03
03
03
03
04
03
02
02
02

36

Fundamentals of Systemj360 CSMP

Ch. 2

the earth are

mY = rhVo - mg - !pCaAV2

(2.11)

and
ALT

S: Vdt

=

(2.12)

Program Symbols
(Fig. 2.26)
where

m = mass of total rocket in slugs
V

=

Y=

VEL

acceleration in ft/sec 2

ACC

rh = mass flow rate of propellant in slug/sec (constant for each stage)

Va

=

outflow velocity of propellant relative to
rocket in ft/sec

g = acceleration of gravity which is giyen by
g =

r6

ALT

MASS

velocity in ft/sec

MDOT
VOUT

G

32.17[r +rALTT
6

=

radius of earth in feet

RADERH

=

altitude of rocket in feet

ALT

p = density of air in slug/ft 3

RO

An approximate value of p is given by the

p = 0.00238 e-ALT/24000
CaA = cross-sectional area of the rocket times the drag
coefficient in ft2

DRAG

While Eqs. (2.11) and (2.12) are valid for each stage, the parameters m, rh, Va' and
CaA will change for each burn.
Figure 2.26 shows the CSMP program listing for the simulation of the launch. All
three segments (Initial, Dynamic, Terminal) are included in this program. The use of the
three segments is good programming practice since it separates the different types of
program statements.
The Initial segment is used to specify the constants in the program and makes a onetime calculation to find the radius of the earth RADERH in feet.
Since the parameters in Eq. (2.11) depend on the particular burn stage, FORTRAN
IF statements are utilized to transfer control to the appropriate group of structure statements. To allow the use of logic branching statements, the· first part of the Dynamic
segment is changed to a no sort section.
By examining the program structure, one can make the following observations.
If the flight time TIME is less than the burn time of the first stage BURNT1, control
is transferred to statement 1. The instantaneous mass MASS of the total moving rocket is
calculated and the appropriate values for the propellant-mass-flow rate MDOT, dragcoefficient times cross-sectional area DRAG, and propellant-outflow velocity VOUT for
the first stage are specified. Control is then transferred to statement 3 which is a FOR-

Ch.2

Fundamentals of System/360 CSMP

CSMP
Symbols
MASS3
VOUT3
FLOW3
BURNT3
DRAG3

Third stage
Initial mass = 8137 slugs
Outflow velocity = 15250 ft/sec
Mass flow rate = 14.75 slugs/sec
Burn time = 479 sec
Drag coefficient times crosssectional area = 360 sq ft

37

Drag fPCdAV2

Grar=mg
MASS2
VOUT2
FLOW2
BURNT2
DRAG2

Second stage
Initial mass = 32205 slugs
Outflow velocity = 13805 ft/sec
Mass flow rate = 81.49 slugs/sec
Burn time = 359 sec
Drag coefficient times crosssectional area = 460 sq ft

MASSI
VOUTl
FLOWI
BURNTl
DRAG 1

First stage
Initial mass = 148820 slugs
Outflow velocity = 8060 ft/sec
Mass flow rate = 930 slugs/sec
Burn time = 150 sec
Drag coefficient times crosssectional area = 510 sq ft

Fig. 2.25 Saturn three-stage rocket.

TRAN CONTINUE statement. After the CONTINUE statement, the Dynamic segment
is changed to a sort section. Calculations are then made for acceleration of gravity G,
density of air RO, and acceleration of the rocket ACC. INTGRL statements are used to
find the velocity VEL and altitude of the rocket ALT. The final two statements in the
Dynamic segment are used to calculate the velocity in miles per hour MPH and the
altitude in miles MILES. Control is then transferred back to the beginning of the Dynamic segment where the iterative procedure is repeated.
The final portion of the Dynamic segment was changed to a sort section to eliminate
the possibility of having calculations performed in the wrong order.
The value of FINTIM is set equal to the total burn time of all three stages and will
consequently terminate the program at the end of the third-stage burn.

38

Fundamentals of System/360 CSMP

Ch. 2

LABEL
SIMULATION OF THE LAUNCH OF A SATURN V THREE STAGE ROCKET
INITIAL
CONSTANT MASSl = 148820.0, MASSZ = 32205.0, MASS3 = 8131.0,
FLOWl = 930.0, FLOW2 :: 81.49, FLOW3 :: 14.15, VOUTt = 8060.0,
YOUTZ:: 13805.0. VOUT3 = 15250.0. DRAGl = 510.0. DRAG2 = 460.0, •••
DRAG3 = 360.0. BURNT! = 150.0, BURNTZ = 359.0
RADERH = 3960.0*5280.0
DYNAMIC
NOSORT
IF(TIME.LE.BURNTIJ GO TO 1
IF(TIME.lT.(BURNTl + BURNT2Jt GO TO 2
* CALCULATIONS FOR THIRD STAGE
MASS
MASS3 - FLOW3*(TIME - BURNT1 - BURNT2J
MOOT = FLOW3
DRAG = DRAG3
YOUT :: VOUT3
GO TO 3
* CALCULATIONS FOR FIRST STAGE
1 MASS
MASSl + MASS2 + MASS3 - fLOW1*TIME
MOOT :: FLOWl
DRAG = DRAGl
YOUT :: VOUT 1
GO TO 3
* CALCULATIONS FOR SECOND STAGE
Z MASS
MASSZ + MASS3 - FLOW2*(TIME - BURNTlt
MOOT :: fLOWZ
DRAG = DRAGZ
YOUT = YOUTZ
3 CONTI NUE
SORT
G :: 32.11*I(RADERH/(RADERH + AlT)t**Z)
GRAVITY
RO = 0.00Z3S*EXP(-AlT/Z4000.0)
OENSITY
ACC
(MDOT*VOUT - MASS*G - 0.5*ORAG*RO*VEL*VELJ/MASS
YEL = INTGRL(O.O,ACC)
ALT = INTGRLIO.O.VEl)
MPH:: VEl*60.0/88.0
MILES = AlT/5Z80.0
TERMINAL
TIMER FINTIM = 988.0, PRDEl :: 4.0, OUTOEl :: 20.0
PRINT MILES. MPH, ACC,G, RO
PRTPLT MPH (MILES,ACe)
* THE FOLLOWING FOUR STATEMENTS ARE USED TO MAKE CALCULATIONS AFTER THE
* RUN IS COMPLETED AND TO PRINT THE RESUlTS.
FEET = ~ILES*5280.0
WEIGHT = MASS*32.17
100 FORMAT(2E20.5)
WRITE(6,100) FEET,-WEIGHT
END
STOP
END JOB

Fig. 2.26 Program to simulate the launch of a Saturn rocket.
Ordinary FORTRAN FORMAT and WRITE statements can be used in nosort
sections. An example of this is shown by the last two statements in the Terminal segment.
Since the statements in the Terminal segment are only executed at the end of the program, the final altitude in feet FEET and the final earth-weight of the rocket WEIGHT
can be calculated and will be the last output of the program. A detailed discussion of the
use of FORTRAN output statements is included in Chap. 3 in the section on data output.
The PRTPLT output showing the vehicle velocity profile is given in Fig. 2.27.

Ch.2

Fundamentals of System/360 CSMP

SIMULATION OF THE

LAUNCH OF A SATURN V THREE STAGE ROCKET
MINIMUM

MPH

PAGE
MAXIMUM

VERSUS TIME

2.ftZ30E 04
I

0.0
TIME
0.0
2.0000E
4.0000E
6.0000E
8.0000E
1.0000e:
1.2000E
I.4OOOF.
1.600,01';
I.OOOOE
2.0000;;
;>.2000"
2.4000"
2.6000<;
2.80001';
3.00MI'
3.2000"
3.4000E
3.6000!'
J.8000E
4.00001'
4.2000",
4.4000F;
4.6000"
4.AOOI)F;
5.0000E
';.20001;
';.4000 c
5.6001)"
5.8000;:
6.0000r:
6.21')00<:
6.40001'
6.60001:
6.801)0E
7.aoool'
7.2000 c
7.4000E
7.60001'
7.bOOI')E
A. 0000 c
8.;>000F.
8.4001)F;
8.60)1)1'
A.8001)1;
9.0000E
9.201)'1<:
9.4000~

MPh

0.0
01
01
01
01
02
02
02
02
02
02
02
02
02
02
02
02
07.
1')2
07,
02
02
07.
02
0;>
07
1')2
02
07
02
02
02
02
02
02
07.
02
02
07

02
02
02
02
02
02
07
02
02

9.6000F 02
Q.80DO!' 02
9.i\SOOc 02

1.~966E

3.2111E
5.8673E
'I. 52'17F
1.4688E
2.2062E
3.2793E
3~9871E

3.9603E
3.9556E
3.9743E
4.0184E
4.01198E
4ol'l12E
4.325<'E
4.49551:
4.7062E
4.9621!'
5.2694E
5.6356E
6.0701E
6.51!48E
7.1'155!'
7.92311:
8.7'169E
'1.2739"
9.B85E
9.4258E
9.536SE
'I.672flE
9.1l352E
1.0026E
1.024bE
1.0!;OOE
1.078aE
lol1l5E
1.141l4E
1.lYOOE
1.236H"
1.2b9'>E
1.34YlE
1.416!>E
1.4'130~

1.,)8071'
l.bS ItlF
1.799!lE
1.'1397E
2.1092F
2.J214E
2.4230E

02
02
02
02
03
03
03
03
03
03
1)3
03
03
OJ
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
04
04
04
04
04
04
04
04
04
04
1)4
04
04
04
04
04
04
04
04

39

-+

-+

---+

----+
-------- ..

--------+

---------+
---------+
----------+
---------- +

-----------+
------------ +

-------------+
--------------+
---------------- +
------------------+
--- ----- -----------+

------------ -------+
-------------------+

-------------------+
-------------------+
--------------------+
------------------'-- +
---------------------+
---------------------+
----------------------+
----------------------+
-----------------------+
--------- --- ---- ---- -----+

--------------------------+
---------------------------+

-----------------------------+
--- --------- ------------------ +

-------------------------------+

----------------------------------+
--- ----------- ------ ---- -------- ----- +
----------- ------------ -------- -------- ----- ------------ ---- -------------------+
-----------------------------------------------+
---------------------------- ---------------------+

--.

MILES

Ace

0.0
1.4564E 00
3.3361E-Ol 1.1664E 01
1.55't9E 00 1.6553E 01
4.0380E 00 2.Z716E 01
1l.2590E 00 3.160 IE 01
1.4902E 01 4.4911E 01
2.4987E 01 6.4539E 01
4.0030E 01 9.5564E 01
6.1211E 01 -2.1380E 00
8.3283E 01 -1.1131E 00
1.0526E 02 4.9306E-Ol
1.2728E 02 2.2805E 00
1.4947E 02 4.2094E 00
1.7198E 02 6.3042E 00
1.9496E 02 8.5945E 00
2.1860E 02 1.1U6E 01
2.4309E 02 1.3913E 01
2.6863E 02 1.7042E 01
2.9546E 02 2.0571E 01
3.2386E ~2 2.4594E 01
3.541ZE 02 Z.9229E 01
3.8660E 02 3.4639E 01
4.2171E 02 4.1048E 01
4.5994E 02 4.8776E 01
5.0187E 02 5.8299E 01
5.4824E 02 7.0350E 01
5.9908E 02 3.9352E 00
6.5077E 02 5.5599E 00
1.0288E 02 1.2573E 00
7.5554E 02 9.0401E 00
8.0889E 02 1.0922E 01
a.o307E 02 1.2920E 01
9.1822E 02 1.5053E 01
9.7452E 02 1.7344E 01
1.0321E 03 1.9819E 01
1.0912E 03 2.2512E 01
l.l521E 03 2.5462E 01
1.21'48E 03 2.8719E 01
1.2797E 03 3.2347E 01
1.3471E 03 3.6425E 01
1.4173E 03 4.1058E 01
1.4905E 03 4.b38oE 01
1.5673E 03 5.2598E 01
1.6481E 03 5.995tjE 01
1.1334E 03 6.8849E 01
1.8240E 03 1.9841E 01
1.920oE 03 9.3828E 01
2.0243E 03 1.1230E 02
2.1366E 03 1.3793E 02
2.2595E 03 1.1602E 02
2.3122E 03
1.9705E 02

Fig. 2.27 Printer-plot output for launch of Saturn rocket.

Example 2.6 Control System with Compensation
A problem often encountered by the control engineer is to compensate a system so
that both dynamic and steady state design specifications are met. This problem illustrates
how a simple compensator can be added to a system in order to improve the transient
response to a unit-step input while increasing the static-loop gain.
Consider the closed-loop configuration in Fig. 2.28. The system step response with a
loop gain of 300/24 and without compensation is given in Fig. 2.29. We note that the
response has excessive oscillation and a peak overshoot of 89 %.
The system requirements are to increase the static-loop gain to 300/12 and design a
compensator so that the overshoot for a step input is approximately 20 % and the time to
the first peak is equal to or less than 1 sec.

INPUT

OUTPUT

'+
s(s

+ 2) (s + 12)

Fig.2.28 Uncompensated system diagram for Example 2.6.
STEP R!=SPON5E FOR

Ui~CC~PENSATFD

MINIMUM

SYSHM -

~XAMPL=

OUTPUT

PAGE

~.6
VE~5US

TIME

TJ ME
0.0
6.0000::-02
1.2000::-01
1.8000E-01
2 .4000~-01

3.00COE-01
3.6000~-01

4.2000E-01
4.8000E-01
5.4000E-Ol
6.00f)Of-01
6.6COOE-01
7.2000E-Ol
7.80COE-Ol
8.4COOE-Ol
<:1.00001:-01
9.6000E-Ol
1.0200E 00
1.0800E 00
1.1400E 00
1.2000 c 00
1.2600E 00
1.3200E 00
1.3800E 00
1.440017 00
1.5COOF 00
1.5600E 00
1.6200E 00
1.6800E 00
1.7400E 00
1.8000E 00
1.13600E 00
1.9200~ 00
1.9800E 00
2.0400E 00
2.1000:: 00
2.1600:: 00
2.2200~ 00
2.2 tlOOF 00
2.~400E 00
2.4000F. 00
2.46CCE 00
2.521)0E 00
2.5800E 00
2.6400:: 00
2.7CCOE CO
2.7600E 00
2.8200E 00
2.8800E 00
2.9400E 00
3.0000E 00

I

OUTPUT

0.0
8. 8246E- 03
5.8440E-02

1.6470E-OJ
3.2761E-Ol
5.378ZE-Ol
7.8032E-Ol
1.0368E 00
i.2876E 00
1. 5136~ 00
1.6977E r)0
1.8261E 00
1.8894'= 00
1.8834E 00
1.809-.E 00
1.6735E

co

1.4P71E 00
1.26 4 9:: 00
1.0245'= 00
7.8462E-C1
5.6374':- 01
3.7874E-Ol
2.4353E-Ol
1.6805E-Ol
1.5754E-Ol
2.1215E-01
3.2703E-Ol
4.92 70E -01
6.9587E-Ol
9.2048E-Ol
1.14QOE GO
1.3637E 00
1.54f..2E 00
1.6886= 00
1.7744:; 00
] .79961:: 00
1.1628~ 00
1.6675E 00
1.5211r; 00

1.3370E CC
1.1282E 00
9.1155E-Ol
7. 0391E -01

5.2118E-Ol
3.1723£:-01
2.8279[-01
2. 4464~-Ol
2.6518f-Ol
3.4222E-Ol

4.69'6E-01
6.3599c-Ol

+

+
-+

----+
--------+
--------------+
--------------------+
---------------------------+
----------------------------------+
----------------------------------------+
----------~---------------------------------+
------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-----------------------------------------------+
--------------------------------------------+
---------------------------------------+
---------------------------------+
---------------------------+
--------------------+
--------------+
----------+
------+
----+
----+
-----+
--------+
-------------+
------------------+
------------------------+
------------------------------+
------------------------------------+
----------------------------------------+
--------------------------------------------+
----------------------------------------------+
-----------------------------------------------+
----------------------------------------------+
--------------------------------------------+
----------------------------------------+
-----------------------------------+
-----------------~-----------+
------------------------+
------------------+
-------------+
---------+
-------+
------+
-------+
---------+
------------+
----------------+

Fig.2.29 Uncompensated system step response for Example 2-6.
40

MAXIMUM

1.8894[ 00

0.0

Ch. 2

Fundamentals of System/360 CSMP

41

Using classical design procedures, one can define a proposed compensator with a
transfer function given by
(lead)

_

Gis) -

(lag)

+ 2.2)(s + 0.2)
(s + 8.0)(s + 0.0275)
(s

(2.13)

The diagram in Fig. 2.30 includes this compensator as well as a block arrangement
suitable for CSMP simulation. Figure 2.31 gives the program listing using the variable
names as specified in Fig. 2.30. When compared with Example 2.2, one notes that the
essential difference is the addition of the compensator, Gis). The CSMP statement and
formulation for a simple zero and pole (taken together) are summarized in Table 2.5.

Table 2.5
Formulation for a Lead-Lag Structure

General Form

Function

Definition: Pole-zero (often
called lead-lag
compensator)
Y = LEDLAG('t'b't'2'X)

• "t'lS
"t'2
S

Laplace form.
Xes)

)

+ 11
+

"t'lS+11~
+1

"t'2S

Fig. 2.30 Diagram for programming compensated system of
Example 2.6.

From a practical point of view, the LEDLAG formulation (as illustrated in this example)
can be used for either a lead or lag compensator as defined in classical control theory.
The step response of the system with the compensator is shown in Fig. 2.32. We see
that the problem specifications are met. One important reason for employing CSMP for
a problem of this nature is that the graphic methods used in designing compensators do
not generally yield a convenient method for determining the system step response. This is
particularly true for higher-order systems.

42

Fundamentals of System/360 CSMP

Ch. 2

INPUT :: S-TEP( O. 0»
ERROR = INPUT - OUTPUT
X8
300.0*ERROR
X7
{O.2/0.0275t*XB
X6
LEDlAG(I.0/0.2,1.0/0.0275,X7t
X5 - (Z.2/8.0t*X6
X4 :: L:DLAGlI.0/2.2,l.C/8.0,X5J
X3
(1.0/24.0)*X4
X2
REALPlCO.0,1.0/2.0,X3t
Xl
R~ALPl(0.O,l.O/12.0,X2'
OUTPUT:: INTGRL(O.O,Xlt
TIMER FINTIM :: 6.0, aUTOEl :: 0.12
PRl'PLT OUTPUT
LABEL
RESPJNSE FOR COMPENSATED SYSTEM - EXAMPLE 2-6

END
STOP
ENDJOB

Fig.2.31 CSMP program listing for Example 2.6.
RESPONSE FOR COMPENSATED SYSTEM - EXAMPLE 2-6

MINIMUP04

PAGE

OUTPUT VERSUS TIME

0.0

Tt "E
0.0
1.2000E-Ol
2.4000E-Ol
3.6CCOE-Ol
4.8000F-Ol
6.0000E-OI
1.2000E-Ol
8.4000E-OI
9. bCCOE-Ol
1.0BOOE 00
1.2000E 00
1.3200E 00
1.4400~ 00
1.56COE 00
1.6 eOOE 00
1.8000E 00
1.9200E 00
2.0400E 00
i.1600E 00
2.2 eCOE 00
2.4000E 00
2.52COE 00
2.b400E 00
2.7l:COE 00
2.8eOOE 00
3.0000E 00
3.1200E 00
3.2400E 00

OUTPUT
0.0
4.9649E-02
~.4100E-OI

5.1065E-Ol
7.7689E-Ol
9. S866E-Ol
1.1266E 00
1.1941E 00
1.2068= 00
1.J846E 00
1.14581.: 00
1.1045E 00
1.0691E 00
1.0436E 00
1.0283E 00
1.0216E 00
1.0209E 00
1.0235E OC
1.0274E 00
1.0309E 00
1.0335E 00
1.0348E 00
1.0349E 00
1.0342E 00
1.0330E 00
1.0315E 00
1.0301E 00
1.02B8E 00

1

MAXIMUM
l.l068E 00
I

+
--+

---------+
---------------------+
--------------------------------+
----------------------------------------+

----~-----------------------------------------+

-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-----------------------------------------------+
---------------------------------------------+
--------------------------------------------+
-------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------~

------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------~
------------------------------------------+
------------------------------------------+
------------------------------------------+

Fig. 2.32 Compensated system step response for Example 2.6.

Example 2.7 RLC Circuit Problem
The purpose of this example is to illustrate how CSMP can be used to simulate an
electric circuit. A series RLC circuit is given in Fig. 2.33. Suppose it is desired to find the
voltage across the capacitor in response to a pulse-train input of unit amplitude. There

Ch.2

Fundamentals of System/360 CSMP

R

43

L

1.0

Ililem
[
T

R = 60 ohms
L = 1.0 Hn
C

2T

= 100 ~fd

T= 0.18

Fig. 2.33 Series RLC circuit.

are several approaches that can be used to determine the solution. Three methods will be
considered here.

Method l-Transfer Function.
expressed as:

The transfer function between eo(t) and ein(t) can be
1

Eo(s)
Ein(S)

rc

=

2

S

(2.14)

+ (R)
+_1
L S LC

This can easily be simulated by CSMP provided we know the nature of the roots of the
characteristic equation. Two possibilities exist in that the roots can either be real or complex. If the roots are real we can solve the problem by applying REALPL twice. A function (CMPXPL) which requires only one program statement can be used for either real or
complex roots. The solution using this function will be presented later in this example.

Method 2-State Variable Representation.
for the previous circuit.
eiit)

=

Ri(t)
i(t)

=

The following equations can be written

+ L d~~) + eo(t)
C

~; (t)

(2.15)
(2.16)

Rearranging yields

. (t) _ i(t)
eo - C
let)

(2.17)

= _ eoCt) _ Ri(t) + ein(t)
L

L

L

(2.18)

These last two equations form a state-variable representation of the system where the
states are eoCt) and i (t).

Method 3-Direct Circuit Application.
circuit, yields
eiit)

Kirchoff's law, applied directly to the RLC

= Ri(t) + L d~~t) +

~

f:

i(t) dt

(2.19)

A "graphical" representation for the solution of this equation is given later.
Pulse Train Generation. The input voltage given in Fig. 2.33 is a train of square waves
which can be generated by using two standard CSMP functions. These two functions are
IMPULS and PULSE and are defined in Tables 2.6 and 2.7.

44

Fundamentals of System/360 CSMP

Ch. 2

Table 2.6
Formulation for an Impulse Generatort

Description
Y

Function

°for  1; the roots are real and unequal (overdamped)
c; < 1; the roots are complex (underdamped)
Comparing coefficients in Eqs. (2.20) and (2.21) gives
OJ n

c;

= ,.jljLC

(2.22)

R
2,.jLjC

(2.23)

=

Using the values of R, L, and C from Fig. 2.33 results in
OJ n

=

100.0,

c; =

0.3

(2.24)

which implies that the system has complex roots. Complex roots can be directly simulated
by using the function defined in the Table 2.8, provided the roots are in the denominator
of the transfer function. Roots in the denominator of a transfer function are called poles
and thus for this case we refer to these roots as complex poles.
Table 2.8

Formulation for Complex Palest

Function

General Form
Definition: Complex poles
Y = CMPXPL(ICl,IC2",OJ m X)
ICI = YeO)
IC2 = YeO)
For any value of ,

yet) + 2C;OJn y(t) + OJ;y(t) = x(t)
Equivalent Laplace form

y

8'

+2C;~"s +00; I~

tThe poles are not required to be complex to use CMPXPL. As noted in the table any value
of , is acceptable and thus the function can also be used when the poles are real.

46

Ch.2

Fundamentals of System/360 CSMP

A diagram giving a block arrangement for simulating Eq. (2.20) is given in Fig. 2.34. The
actual program listing of the simulation statements is given directly below the diagram
in Fig. 2.35.

E~
IILC

S2

I
+ (R/L)s + IILC

I EOUT •

Fig. 2.34 Simulation diagram for RLC circuit (Method
solution).

*

FXAMPLE PRCBLEM FOR RLC NETWORK - EXAMPLE 2-1

PARAM L = 1.0, C = 0.0001, R = 60.0
TRIG = IMPULS(0.O,0.36}
EIN = PULSEtO.18,TRIG)
X = EIN*(l.O'(L*C»)
EOUT
CMPXPl(0.O,0.0,R/C2.0*SQRTCL/C)},SQRT(1.O/CL*C)),X)

=

FINTIM = 0.4, OLTDEL = 0.008
PRTPLT EOUTtEINI
LABEL PULSE TRAI~ RESPONSE ACROSS CAPACITOR OF RLC NETWORK
PRTPLT EIN
LABEL PLOT SHOWING T~E PULSE TRAIN TO RLC NETWORK
END
STOP
ENDJOB
Tl~ER

Fig. 2.35 Program
solution).

listing

for

RLC

circuit

(Method

For convenience, the circuit parameter values are listed on a PARAMETER card.
This gives the added flexibility of changing the circuit values without repunching several
problem statement cards.
The voltage response across the capacitor is shown by the printer-plot of Fig. 2.36
which gives the response for a time increment involving two input pulses.
Solution by Method 2. The program listing for the solution of Eqs. (2.17) and (2.18) is
given in Fig. 2.37. An advantage of using this approach is that one is not required to
determine the form of the roots for the circuit characteristic equation. Formulating the
problem in this manner has the added advantage of giving the solution for the current in
the circuit. This current response is given in Fig. 2.38.

The voltage eO P 2

y

=

X -

P l ; for x

< Pl

Using the force characteristics shown on Fig. 2.51, the following DEADSP function
can be used to simulate the contact force between gear teeth.
F

=

KG*DEADSP( -0.1, 0.1, RhTHETAI - R2*THETA2)

where RhTHETAI - R2*THETA2 = relative movement between gear teeth.
The equations for the angular accelerations of the gears and flywheel are:

cOl

=

WDI

=

(T*SIN(W*TIME) - RhF)/1l

cO 2 = WD2 = (R2*F + K*(THETA3 - THETA2))/12
c03 = WD3 = K*(THETA2 - THETA3)/13

(2.26)
(2.27)
(2.28)

In the program of Fig. 2.52, the angular accelerations are calculated by ordinary
FORTRAN statements. INTGRL functions are used to integrate angular accelerations
and velocities to obtain angular velocities and angular displacements, respectively. All
initial conditions are assumed to be zero.
It is often desirable to know the maximum and minimum values of variables during a
run. The RANGE statement can be used for this purpose. In this example, it is used to
list the maximums and minimums for 10 variables.

Ch. 2

59

Fundamentals of System/360 CSMP
I1 = 0.4 Ib-sec 2 -in.
R 1 = radius = 5.0 in.

/3

= 0.8 lb-sec 2 -in.

12 = 0.0 llb-sec 2 -in.
R2 = 1.0 in.

THETA3

}

THETA2
Gear 2

Fig.2.50

Schematic of gear train system.

Force
between
gear teeth

Slope =
200000lb/in.

Relative
movement between
gear teeth

Backlash (0.2 in.)

Fig.2.51

Backlash in gear teeth.

RANGE. The RANGE card allows the user to obtain both the maximum
and minimum values of specified variables that occur during the run. Included
with the maximum and minimum values are the times at which the values occurred.
The times of maximum and minimum do not necessarily occur at a multiple of
PRDEL or OUTDEL. An example of the output from the RANGE statement
for this problem is shown in Fig. 2.53.
RANGE F, WDI, WD2, WD3, WI, W2, W3, THETAI, THETA2, THETA3

60

Ch.2

Fundamentals of Systemj360 CSMP

TITLE
SIMULATION OF THE DYNAMICS OF A GEAR TRAIN CONTAINING BACKLASH
CONSTANT
11 = O.~, 12 = 0.01, 13 = 0.8, R1 = 5.0, R2 = 1.0,
KG = 200000.0, K = 4000.0, T
100.0, W = 20.0
F = KG
OEADSP(-O.l, 0.1, Rl*THETAl - R2*THETA2)
WOl = (T
SIN(W*TIME) - Rl * FJ/Il
W02 = (R2
F + K * (THETA3 - THETA2))/I2
W03
K
(THETA2 - THETA3)/I3
Wl = INTGRL(O.O, WD1)
W2 = INTGRUO.O, WD2)
W3 = INTGRL(O.O, WD1)
THETAl = INTGRL(O.O, W1J
THETA2
INTGRL(O.O, W2)
THETA3 = INTGRL(O.O, w3)
PRINT f, WOl, W02, W03, WI, W2, W3, THETAI, THETA2, THETA3
RANGE F. WOlf WDl, WD3, WL, W2, W3, THETAl, THETA2, THETA3
TIMER FINTIM = 0.5. PRDEL = 0.005
END
STOP
ENDJOB

=

*

*
*
= *
=

Fig. 2.52 Program for gear train simulation.
PROBLEM DURA lION 0.0
VARIABLE
F

WDl
WD2
W03
WI
W2
W3

THETA 1
THET A2
THETA3

MINIMUM
-9.2400E 02
-1.1534E 04
-9.2923E 04
-1.7390E 02
-3.0321E 00
-l.8832E 01
-2.1485E-Ol
0.0
-4.2604E-03
0.0

TIME
2.7134E-OI
4.l30lE-01
2.1l34E-Ol
2.2181E-Ol
2.1984E-Ol
3.6290E-Ol
1.1375E-01
0.0
3.7164E-02
0.0

TO

5.0000E-Ol

MAXIMUM
9.4ll0E 02
l.136lE 04
8.8692E 04
1.8759E 02
3.253lE 00
2.0539E 01
2.7382E 00
l.3119E-01
6.5328E-Ol
6.3820E-Ol

Tl~E

4.130lE-Ol
2.7134E-Ol
4.1301E-Ol
3.8948E-Ol
3.874lE-Ol
1.8764E-Ol
4.6904E-Ol
4.5464E-Ol
4.9929E-01
5.0000E-01

Fig. 2.53 Example of output from a range statement.

Only one RANGE statement can be used, but this statement can contain up to
100 variables by using continuation cards.
Since more than eight variables are requested in the PRINT statement, the
"equations format" as shown in Fig. 2.54 is automatically selected. Two TITLE
cards are used to obtain two lines of heading on each page of output.
Example 2.10 Beam Deflection Problem
There exists a large class of engineering problems where it is necessary to use a trial
and error solution. Two-point boundary-value problems generally fall within this class.
The CSMP program has a feature for handling this type of problem and can be illustrated
with the following cantilever-beam example.
This problem can be simply stated: find the deflection and stress of a thin steel cantilever beam of varying thickness with a 30 lb weight hung on the end. Figure 2.55 gives the
basic configuration of the problem along with beam measurements.
The thin tapered beam will have a large deflection and consequently a large slope.
For this reason, the exact equation for the radius of curvature is used in the following
differential equation for beam deflection.

SIMULATION OF THE OYNAM ICS OF A GEAR TRAIN CONTAlNI NG BACKLASH
TIME

z

0.0

.

RKS

INTEGRATION

F
Wl
'"
THETA2:

0.0
0.0
0.0

WDl
"
W2
THETA3 ..

0.0
0.0
0.0

WDZ
lil

:

0.0
0.0

WD3
THETA1-

0.0
0.0

.

0.0
0.0

WD3
THETA1-

0.0
1.0411E-04

~

TIME

5.0000E-03

s
F
wl
THETA2z

..

0.0
6.2448E-02
0.0

c
WDl
:
W2
THET A3z

2.4958E 01
0.0
0.0

WD2
w3

TIME

1.0000E-02

F
Wl
THETA2s

0.0
2.4911E-Ol
0.0

WDl
"
W2
=
THET A3 ..

4.9661E 01
0.0
0.0

WC2
W3

s

0.0
0.0

WD3
THETAlz

0.0
8.3166E-04

0.0
5.58Z9E-Ol
0.0

WOl
112
"
THET A3"

1.3880E OL
0.0
0.0

WC2
W3

-

0.0
0.0

WD3
THETA1:

0.0
Z.1999E-03

0.0
9.8613E-Ol
0.0

WDl
W2
"
THET A3a

9.1354E 01
0.0
0.0

WDZ
w3

0.0
0.0

WD3
THETA 1-

0.0
6.6135E-03

'"

0.0
1.5302E 00
0.0

WDl
W2
"
THETA3-

1.L986E OZ
0.0
0.0

WD2
W3

0.0
0.0

WD3
'"
THETA1:

0.0
1.Z859E-02

c

0.0
5.1468E-Ol
8.8591E-03

WDl
W2
THETA3"

1.4116E OZ
1.1544E 01
4.1982E-06

WDZ
W3

:

-3.542ZE 03
1.6510E-02

WD3
"
THETA 1'"

4.4Z11E 01
2.0949E-02

WDl
1.6105E 02
W2
- -4.0249E 00
1.1l90E-03
THETA3"

1102
113

" -6.7610E 03
4.3920E-Ol

WD3
=
THETAl=

8.451ZE 01
2.1422E-02

TIME

z

1.5000E-02

s
F
Wl
'"
THETA2z

TIME

..

2.0000E-OZ

F

...

W1
THETA2=
TIME

"

TIME

2.5000E-02

F

Wl
"
THETAZ·
3.0000E-OZ

F

Wl
THETA2=

.

.
"

TIME

.

3.5000E-OZ

F
= 0.0
Wl
'" -9.4938E-Ol
THETAZ ..
1.8021E-OZ

TIME

"

4.0000E-02

F
0.0
.. -1.2125E 00
W1
1.651ZE-03
THETA2'"

WDl
WZ
THET A3=

1.1934E OZ
4.6252E 00
3.512.3E-03

IIDZ
W3

=

TIME

s

4.5000E-02

F
0.0
" -3.3311E-Ol
Wl
..
THETA2=
1.6850E-03

WDl
1.9583E 02
.. -3.6696E 00
WZ
THET A3" 6.0281E-03

1102
W3

.. -6.6252E 02
" 5.5Z24E-Ol

TIME

'"

5.0000E-02

.

=

z -9.6052E 00
WD3
THETA1=
1.5125E-02

WD3
THETA1"

1103
" -6.9464E 00
THETA1=
1.Z511E-02

2.1037E 02
4.1011E 00
8.5669E-03

WDZ
W3

5.5512E 02
4.4153E-Ol

Wl
THETA2=

"

0.0
1.1664E 00
1.2151E-02

WDl
2.2280E OZ
WZ
- -3.1386E 00
THET 0=
1.1037E-02

WDZ
W3

.. -4.4811E 02
5.5310E-Ol

.

WD3
THETA1=

5.6014E 00
1.8613E-02

WD2
113

: -8.3114E 03
1.3139E-Ol

WD3
THETA1·

1.0397E OZ
2.3806E-02

WD2
113

.. -3.2118E 03
1.0940E 00

z
WD3
THETA 1"

4.0141E 01
2.1541E-02

z

.

5.5000E-02

TIME

"

6.0000E-02

F
wl
"
THETA2=

0.0
9.2847E-Ol
3.4127E-02

WDl
2.3301E 02
.. -2.6537E 00
112
THET A3z
1.3933E-02

TIME

:

6.5000E-02

z
F
0.0
z -1.2541E-Ol
Wl
THETA2=· 2.6512E-02

WDl
2.4089E 02
WZ
: -8.4676E 00
THETA3:
1.8542E-02

F

.
.

Fig. 2.54 Output from gear train simulation.

(2.29)

Symbols program
(Fig. 2.56)

=

bending moment in beam

E

=

Young's Modulus (30 x 106psi)

I

=

Moment of inertia

where M

=

n- wt

w = width of beam (1.0 in)

FORCE*(LO - X)
3

E
I

WIDTH

t =

thickness of beam

T

=

deflection of beam

Y

y

t

= slope of beam

ddx2y = EI
M[l + (ddxy )2]3/2
2

8.2815E 00
1.1615E-OZ

THETA3~

.

TIME

1.6842E 02
4.4856E-Ol

0.0
6.8258E-Ol
1.171bE-03

F

Wl
THETAZ=

WDl
WZ

z

YP
YPP
61

62

Ch.2

Fundamentals of System/360 CSMP

~------------------------------------------30----------~

~----------------------20----------~
~-------10------~

in.

0.3 in.

0.15 in.

0.1 in.

L
I·
Fig. 2.55 Cantilever beam.

Notice that in Eq. (2.29), the independent variable X is the position in the horizontal
direction. This is the first example in which the independent variable has not been time
(TIME). This detail can easily be handled by renaming the independent variable using the
control statement RENAME. A listing of the program in Fig. 2.56 shows an application
of this statement.

RANAME. The RENAME statement can be used to change the symbol
for any of the six reserved names (DELT, DELMIN, FINTIM, OUTDEL,
PRDEL, and TIME), as shown below:
RENAME TIME = X

In this example, the symbol X will be used in place of the reserve word TIME.
The independent variable listed in all PRINT and PRTPLT outputs will be the
variable X. Successive renaming on the same card must be separated by a comma.
No continuation cards (oo.) are allowed with RENAME; however, several RENAME cards may be used.
The only requirement for the location of the RENAME card is that it must
be placed before the TIMER statement.

Ch. 2

Fundamentals of System/360 CSMP

63

LABEL

LARGE DEFLECTION OF A CANTILEVER BEAM
RENAME TI ME = X
INITIAL
CONSTANT L= 30.0, WIDTH = 1.0,E = 10.OE6, FORCE = 30.0, LO = 26.0
FUNCTION THICK = (0.0,0.4),(10.0,0.3),(20.0,0.15),(30.0,0.1J
DYliAMIC
C = SQRT(l.O + yp*vP)
XA = INTGRL(O.O.C)
T = NLFGEN(T~ICK,XA)
I = WIDTH*T*T*T/12.0
YPP = FORCE*(LO:" X)*C*C*C/(E*n
YP = INTGRL(O.O,VPP)
Y = INTGRL(O.O,VP)
STRESS = FORCE*(LO - X)*T/(2.0*It
TERMINAL
TIMER FINTIM = 30.0
FINISH XA = L
IF(ABS(X - Le).LT.0.3) GO TO 1
LO = LO + 0.2*(X - LO)
CALL RERUN
1 CJNTINUE
~

*

THE FOLLOWING END CARD RESETS THE INITIAL CONDITIONS AND INITIATES
ANOTHER RUN LSING A VALU~ OF OUTDEL = 0.6.

END

TIMER OUTDEL = 0.6
PFlTPLT Y (STRESS,XA,VP)

eND
STOP
ENDJQB
Fig. 2.56 Program for deflection of cantilever beam.

Since the beam is curved, the X coordinate is not equal to the distance as
measured along the center line of the beam. The distance from the base along the
beam is given by
XA

I:

=

[1.0

/
+ (CZ) 2J 2dx

(2.30)

CSMP statements for the above expression are
C
XA

=
=

SQRT(1.0 + yP*YP)
INTGRL(O.O, C)

The value of XA must be used as the argument of the nonlinear function-generator
statement to calculate the thickness of the beam.
T

=

NLFGEN(THICK, XA)

Since the beam is curved in its final deflected shape, the exact horizontal LO
position of the end of the beam is not known. An initial estimate of 26 in. is made
on a CONSTANT card. With this initial estimate the values of y, dyjdx, d 2 yjdx2
and stress are calculated as
2

d y2 = YPP = FORCE*(LO - X)*C*C*Cj(E*I)
dx
dy
dx

=

2

IX dx
d y dx =
0

2

YP

= INTGRL(O •0, YPP)

(2.31)
(2.32)

64

Fundamentals of System/360 CSMP

Y
(J

=

Xd

f Ix
0

dx

Ch. 2

= Y = INTGRL(O.O, YP)

= ';; = STRESS = FORCE*(LO - X)*T/(2.0*I)

(2.33)
(2.34)

The calculations in the Dynamic segment continue until the distance -integrated along the beam XA is equal to the total length L. At this point the first run
is terminated by the following FINISH statement:
FINISH XA

=

L

The FINISH statement terminates a run when the variable XA reaches
or first crosses the specified bound L. At this point the actual horizontal position of the end of the beam X is compared with the first estimate LO. If the
first estimate for the horizontal location of the end of the beam is not sufficiently
close (less than 0.3 in.) to the calculated value, additional runs will be required until
this criterion is satisfied. The CALL RERUN feature is used to solve this trial and
error problem.
CALL RERUN. The CALL RERUN statement must be placed in the Terminal segment to recycle the program through additional runs with new parameters. All constants used in succeeding runs will have the same values as specified
in the Initial segment unless otherwise specified in the Terminal segment. The
program listing of Fig. 2.56 illustrates the use of the CALL RERUN statement.
After the first run is terminated by the FINISH statement, the difference
between the actual horizontal position of the end of the beam X is compared with
the initial guess LO. If the absolute difference is greater than or equal to 0.3 in.,
a new estimate for LO is calculated and, the CALL RERUN statement will recycle
the program using the new estimate for LO and all other constants as specified
in the Initial segment.
Successive runs will occur until the absolute difference between the actual
horizontal position and the estimate is within the desired range. When this occurs,
the FORTRAN IF statement will transfer the execution to the CONTINUE
statement which bypasses the CALL RERUN card.
In this example, the CONTINUE card is used as a FORTRAN statement.
If the statement number were not included, the CONTINUE card would have
been executed as a CSMP statement. A detailed explanation of the CSMP CONTINUE card is given in Chap. 3.
Notice that there is no output statement before the first END card. This
means that there will be no output until the final run is completed. If output is
desired at the end of each iterative run, PRINT, or PRTPLT statements should
be placed before the first END card. The first END card is used after a CALL
RERUN statement to reset the independent variable X to zero, and to initiate
another run. The use of the END statement for making multiple runs is covered
in Chap. 3. The PRTPLT output for the final run is shown in Fig. 2.57.
One of the most important statements for trial and error solution is the algo-

Ch.2

Fundamentals of System/360 CSMP

LARGe DEFLECTION OF A CAHILEVER BEAM

PAGE

MINIMUM
0.0

x

VERSUS X

MAXIMUM
1.2606E 01
I

y

0.0
b.OOOOE-Ol
1.2000E 00
1.BOOOE OJ
2.4000E OJ
3.0000E 00
3.bOOOt: OJ
1t.2000E OU
It.aOUOE 00
5.4000E 00
6.0000E 00
lI.bOOOE 00
7.200uE 00
7.S000E 00
8.4000E 00
9.001l0E 110
9.bOJOE 00
1.0200E 01
1.081l1lE 01
1.140ilE 01
•• 2000E 01
1.2biluE III
l.3200E 01
1.3SIlOE 01
1.4400E 01
1.~000E 01
1.560;);: 01
1.b200E ill
1.bSOOE 01
1.7ltOOE 01
1.1l000E 01
1.lIo00E 01
1.9200E 01
1.9800E 01
2.0400E Ol
2.J.000E 01
2.1bOOE 01
2.2200E 01
l.2800i: 01
.!. .34JJE 01
l.4000E OJ.
2.lt600E 01
l.520JiO 01
2.51100E 01

0.0
2.6519E-03
1.0687E-02
2.4228E-02
4.3402E-02
6.8342E-02
9.9186E-02
1.3608E-01
1.7918E-Ol
2.2863E-Ol
2.8461 E-O 1
3.4l28E-Ol
4.1684E-Ol
4.9346E-Ol
5.7736E-Ol
6.6 874E-0 1
7.6782E-Ol
8.7484E-Ol
9.9010E-01
1.114CE CC
1. 24 70E 00
1.38C;7E 00
1.5427E OC
1.7061E 00
1.8825E 00
2.07L1E 00
2.2731E 00
2.4916E 00
2.7267E 00
2.9810E 00
3.2574E 00
3.5595E 00
3.8924E 00
4.2630E 00
4.6l85E 00
5.1462E 00
5.6757E 00
6.2791E 00
6.9728E 00
7.7780E 00
8.7224E 00
9.8371E 00
1.1142E 01
1.2b06E 01

65

+
-+
-+

-+

---+

----+
-----+
------+

--------+

---------+
---------+
----------+
-----------+

------------+

--------------+
---------------+

----------------+
------------------+

--------------------+
----------------------+
------------------------+

---------------------------i·
------------------------------+

----------------------------------+
---------------------------------------+
---- ---- ---- ----- -------- ------------ -------+
-------------------------------------------------+

STRESS

2.9250E
2.9452E
2.9653E
2.9852E
3.0048E
3.0243E
3.0434E
3.0622E
3.0806E
3.0985E
3.1159E
3.1326E
3.1486E
3.1638E
3.1780E
3ol912E
3.2031E
3.2277E
3.2751E
3.3Z79E
3.3866E
3.4520E
3.5249E
3.6066E
3.6984E
3.8019E
3.9194E
4.0538E
4.2089E
4.3898E
4.601tlE
4.8625E
5.1818E
5.2945E
5.2539E
5.1556E
4.9863E
4.1302E
4.3680E
3.8772E
3.2331E
2.4161E
1.4345E
3.6008E

04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
03

XA
0.0
.6.0001E-Ol
1.2001E 00
1.8002E 00
2.4005E 00
3.0010E 00
3.6018E 00
4.2030E 00
4.8045E 00
5.4066E 00
6.0092E 00
6.6124E 00
7.2164E 00
1.8213E 00
8.4212E 00
9.03HE 00
9.6422E 00
1.0252E 01
1.0863E 01
1.1415E 01
1.2090E 01
1.2107E 01
1.3326E 01
1.3948E 01
1.4513E 01
1.5202E 01
1.5835E 01
1.6414E 01
1.1118E 01
1.7710E 01
1.8430E 01
1.9102E 01
1.9188E 01
2.0494E 01
2.1224E 01
2.1984E 01
2.2185E 01
2.3636E 01
2.4553f!! 61
2.555JE 01
2.66?1E 01
2.1943E 01
2.9319E 01
3.0961E 01

Fig.2.S7 PRTPLT output for deflection of beam.

rithm used in the terminal segment to recalculate LO. The calculation that was
used in this example is
LO = LO

+ O.2*(X -

LO)

(2.35)

This statement is not meant to be the optimum algorithm for calculating the
new estimate for LO. It is only a calculation that yielded desired results. Extreme
care should be used in choosing algorithms for recalculating new estimates of
parameters. These calculations can affect not only the number of iterative runs
but can often make the difference between a convergent or divergent solution.
Example 2.11

Stress Analysis of Cam-Follower System

In all of the previous examples, some form of numerical integration was performed.
This example illustrates the use of CSMP to make a sequence of calculations where no
integration is conducted. Other computer languages such as FORTRAN and BASIC
could be used for this particular type of problem but CSMP has the advantage of particular capabilities such as FUNCTION and PRTPLT.
The problem is to calculate the contact stress between a cam and roller-follower at
2° cam increments. A schematic of the physical system is shown in Fig. 2.58.

YP

0.0
8.8725E-03
1.1945E-02
2.1226E-02
3.6124E-02
4.6448E-02
5.6408E-02
6.6615E-02
1.7019E-02
8.1813E-02
9.882<1E-02
1.1014E-Ol
1.2176E-01
1.33nE-Ol
1.4600E-01
1.5865E-Ol
1.7168E-01
1.8513E-Ol
1.9919E-Ol
2.1399E-Ol
2.2962E-Ol
2.4622 E-Ol
2.6391E-Ol
2.8289E-Ol
3.0331E-Ol
3.2562E-Ol
3.5001E-Ol
3.1698E-Ol
4.0n1E-Ol
4.4142E-Ol
4.8093E-Ol
5.2152E-Ol
5.8402E-Ol
6.5323E-Ol
1.3310E-Ol
8.2803E-Ol
9.4020E-Ol
1.0151E 00
1.2422E 00
1.4495E 00
1.1015E 00
2.0141E 00
2.3261E 00
2.5201E 00

66

Fundamentals of System/360 CSMP

Ch. 2

~ Spring

K

RF

constant

= 150 Ib/in.

t

Radius follower

Y (lift)

~---Follower

~---Cam

(1 in. thick)

Fig.2.58 Schematic of cam-follower system.

The stress is a function of the angular position of the cam, consequently, the independent variable is THETA. The first statement of the program of Fig. 2.59 uses the
RENAME card to change the symbol for the independent variable from TIME to
THETA.
The maximum compressive contact stress for a 1 in. thick steel cam and roller-follower
is given by the Hertz formula.
STRESS

=

2291J F(~*~:F) (psi)

where R = radius of curvature of cam profile at the
point of contact (in.)
RF = radius of roller-follower (in.)
F

=

radial load (lb)

(2.36)

Ch.2

Fundamentals of System/360 CSMP

67

TIME = THETA
CALCULATION OF CONTRACT STRtSS BETWEEN CAM AND FOLLOWER
CONSTANT RF = 0.15, K = 150.0, YI = 0.2'5
FUNCTION LIFT =(0.0,0.01,(30.0,0.09371,(60.0,0.315), (90.0,0.15) •••
,(120.0,1.125),(150.0.1.406),(180.0,1.5),(210.0,1.5),
(240.0.1.351),(270.0.0.9H18),(300.0,0.375),(330.0,0.1433),
(360.0,0.01
FUNCTION RADCUV = 10.0,2.0),(30.U,2.4),(60.0,2.5),(90.0,2.75), •••
(120.0,3.01,(150.0,3.3),(180.0,3.51,(210.0,3.51,(240.0,2.95),
1270.0,2.8),(300.0,2.6),1330.0,2.5),(360.0,2.01
V = NLFGEN(LIFT,THETAI
F = K*( Y + VI.
R = ~LFGEN(RADCUV,THETAI
STRESS = 2291.0*SQRTIF*IR + RF)/(R*RFII
PRTPLT STRESS (F,R,Y)
TIMER FINTIM
360.0, OUTDEL
7.0
RF~AME

LAB=L

=

END
ST1P

=

ENOJ08

Fig. 2.59 Program to calculate contact stress between cam and
follower.

The radius of curvature of the cam surface is measured from the drawing of the cam
at 30° increments and this information is included in the following FUNCTION statement.
FUNCTION RADCUV = (0.0,2,0),(30.0,2.4),(60.0,2.5),(90.0,2.75),
(120.0,3.0),(150.0,3.3),(180.0,3.5),(210.0,3.5),(240.0,2.95),
(270.0,2.8),(300.0,2.6),(330.0,2.5),(360.0,2.0)
To simplify the calculation of force, the cam is assumed to be rotating at a speed
where the inertial forces can be neglected. A static analysis which neglects the pressure
angle yields the following expression for the force between the cam and follower.
F= K(Y + YI)

where Y

=

(2.37)

lift of follower

YI = initial compression of spring

The lift Y is also a function of THETA and is measured from the drawing at 30°
increments. This information is included in the following FUNCTION statement.
FUNCTION LIFT = (0.0,0.0),(30.0,0.0937),(60.0,0.375),(90.0,0.75),
(120.0,1.125),(150.0,1.406),(180.0,1.5),(210.0,1.5),
(240.0, 1.357),(270.0,0.9818),(300.0,0. 375),(330.0,0.1433),
Since both the radius of curvature of the cam and the lift are represented by smooth
curves, the NLFGEN function-generating element is used to calculate values for Rand
y.

The TIMER card controls the increment and range of calculations. In this example,
FINTIM was set equal to 360.0 which corresponds to a cam rotation of one revolution.
A value of OUTDEL = 2.0 forces the calculations to be performed and print-plotted at
2° increments. One page of the printer-plot output is shown in Fig. 2.60. Note the maximum and minimum values for the print-plot variable STRESS are always included in the
PRTPLT output.

68
CALCULAT I Clt-l OF

Fundamentals of System/360 CSMP
cm. TRAC T

STRESS BETWEE r- CAM AND FOLLOWEr<.

MIN IMUM
1.899bE 04
THETA
0.0
7.00001"
4. OOOOF
b.OOOOE
8.00001'
1.0000E
1.;>00OE
1.4000E
1.bOOOE
1.8000E
2.0000!:
2.2000E
2.4000"
?bOOOf:'
?BOOOE
3.0000F.
"'I.;>OOOE
3.4000F.
3.bOOOF
3. fl OOOE
4.0000E
4.2000E
4.4000E
4.bOOOE
4.8000 F
5.00001'
5.;>000E
5.4000F
5.bOO';"
5.BOOOE
b.OOOO F
6.2000E
6.4000E
6.bOOO F
6.8000E
7.0000E
7.2000E
7.4000F
7.bOOOE
7.8000E
8.00001:
8.l000E
8.4000E
8.6000r:
8.80001'
9.0000E
9.2000E
9.4000E
9.bOOOE
9.8000E
l.OOOOE

00
Or)
00
00
01
01
CJl
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01.
01
01
01
01
01
01
01
02

STRESS
1.B99bE
1.9197E
1.939bE
1.9592E
1.9785E
1.9915E
2.01b3E
2.0349E
2.0533E
2.0714E
2.0894E
2.101lE
?124bE
2.1420E
2.1591E
2.11blE
2.21491:
2.255bE
2.2981E
2.3423E
2.3S8LE
2.4355E
2.4844E
2.5341E
2.58b3E
2.b391E
2.6932E
2.7484E
2.8047E
2.8b21E
2.9205E
2.'l700E
3.0194E
3.0b88E
3.1181E
3.1b14E
3.216bE
3.2b57E
3.3147E
3.3636E
3.4124E
3.4612E
3.5098E
3.5584E
3.60b1!E
3.6552E
3.6982E
3.7406E
3.7825E
3.8238E
3.8647E

Ch. 2
PAGE
~AXIMUM

STRESS VERSUS THETA

4.7359E 04

I

04
04
04
34
1)4
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04
04

I

---+
----+
-----+

--------+
---------+
----------+
-----------+
------------+
-------------+
-------------+
--------------+
---------------+
---------------- +
-----------------+
------------------+
-------------------+
--------------------+
-------- -------------+
----------------------+
-----------------------+
------------------------ +
----------------------- +
-------------------------+
--------------------------+
------------------------ ---+
----------------------------+
----------------------------+
------------------------------+
------------------------------+
-----------------------------+
-----------------------------+
-----------------------------+
------------------------------+

------------------------------+

F
3.7500E
3.8437E
3.9374E
4.0311E
4.1248E
4.2185E
4.3122E
4.4059E
4.49'l6E
4.5'l33E
4.b870E
4.7B07E
4.8744E
4.'l681E
5.0618E
5.1555E
5.3492E
5.5555E
5.7743E
6.0055E
6.24'l3E
6.5056E
6.7744E
7.0557E
7.34'l5E
7.6558E
7.'l746E
8.3060E
8.6498E
9.0061E
9.3750E
'l.70b3E
1.0044E
1.0388E
1.0738E
1.1094E
1.1456E
1.1825E
1.2200E
1.2581E
1.2969E
1.3363E
1.3763E
1.416'lE
1.4581E
1.5000E
1.5375E
1.5750E
1.6l25E
1.6500E
1.6875E

01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02

R
2.0000E
2.0267E
2.0533E
2.0BOOE
2.10b7E
2.1333E
2.1600E
2.1bb7E
2.2133E
2.2400E
2.2667E
2. 2'l33E
2.3200E
2.3467E
2.3133E
2.4000E
2.41bOE
2.4307E
2.4440E
2.4560E
2 .46b 7E
2.47bOE
2.41l40E
2.4'l07E
2.4960E
2.5000E·
2.5027E
2.5040E
2.5040E
2.5027E
2.5000E
2.5120E
2.5247E
2.5380E
2.5520E
2.5667E
2.5820E
2.5'l80E
2.6147E
2.6320E
2.6500E
2. b68 7E
2.b880E
2.1.080E
2.7287E
2.7500E
2.7667E
2.7833E
2.8000E
2.8167E
2.8333E

y

00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00

0.0
6.2467E-Ol
1.2493E-02
1.8740E-02
2.4987E-C2
3.1233E-02
3.1480E-02
4.3727E-02
4.9973E-02
5.6220E-02
6.2467E-02
6.8713E-02
7.4'l60E-02
8.1207E-02
8.7453E-C2
9.HOOE-02
1.0662E-Ol
1.2037E-Ol
1.34'l5E-01
1.503 7E-0 1
1.6662E-01
1.8371E-01
2.0163E-01
2.2038E-Ol
2.3997E-Ol
2.603'lE-01
2.8164E-0 1
3.0373E-Ol
3.2665E-Ol
3.5041E-01
3. 7500E-0 1
3.9708E-Ol
4.1'l5'lE-01
4.4250E-Ol
4.6584E-01
4.8'l59E-01
5.1376E-Ol
5.3834E-Ol
5.6334E-Ol
5.8876E-01
6.145'lE-01
6.4084E-Ol
6.6750E-01
6.'l459E-01
7.2208E-01
7.5000E-01
7.7500E-Ol
8.0000E-01
8.2500E-01
8.5000E-Ol
8.7500E-Ol

Fig. 2.60 Printer-plot output for contact stress.

REFERENCES
1. System/360 Continuous System Modeling Program User's Manual GH20-0367-4,
Program Number 360A-CX-16X, IBM Data Processing Division, White Plains, N.Y.
2. System/360 Continuous System Modeling Program, Operations Guide, Program Number 360A-CX-16X, IBM Data Processing Division, White Plains, N.Y.
3. Continuous System Modeling Program III (CSMP III) Operations Guide, Program
Number 5734-XS9, SH19-7002-1, IBM Data Processing Division, White Plains,
N.Y.
4. MCCRACKEN, DANIEL D., A Guide To Fortran IV Programming 2nd ed. New York:
John Wiley and Sons, Inc.

Ch.2

Fundamentals of System/360 CSMP

69

PROBLEMS
1 Write a CSMP program for solving the following nonlinear differential equation:
d 2x
dt 2

+ 25(1.0 + 0.1x 2)x =

0

subject to the initial conditions,
x(O) = 3.0

X(O)

= 0.0

Answer:t
x(t)

= 2.9531 at TIME = 1.0

2 A high-temperature oven is heated by an electrical element supplying 12,000 BTU/hr.
The heat loss from the oven by convection and radiation is calculated to be the
following.
qloss = 2 x 10- S(T! - T!) + 8.0(To - To) BTU/hr
If the initial temperature is 5300 R (700 P), determine the oven temperature at 0.05 hr,

0.1 hr, 0.3 hr, and 0.5 hr. The differential equation for this transient heat transfer
problem is
CtTo =
Ct

qsupplied -

qloss

= thermal capacitance, 24 BTU;oR
Oven

/

I'\.

~

C;

V

/

qsupplied

qloss

•

"\
To = Oven temperature
Ta = Outside temperature
0
Ta = 530 R

Fig. P2.2

Answer:

At TIME = 0.5 hr, To = 723.6°R

t Answers are given to the problems at particular discrete times. If the programs are written
correctly then the solutions should agree at the designated value of TIME.

10

3

Ch. 2

Fundamentals of System/360 CSMP

Given the system shown in Fig. P2.3, if the input is a unit-step (STEP(O.O», write a
program to find the printer-plot of the output. Use a FINTIM of 1.3 and an OUTDEL of 0.026.
INPUT +

1
s(s

OUTPUT

+ 6)

Fig. P2.3

Answer:

Output = 0.81395 at TIME = 0.364
4 The period of vibration of a pendulum for small angles is

2nlf·
Using the capability of a PARAMETER card to make sequential runs, compare the
periods of oscillation of a pendulum which has initial angles of 5°,20°,45°, 90°, and
135°. The equation of motion for the pendulum is

LO + g sin (8) =

m

=mass

0

Fig. P2.4

Answer:

5°
20°
45°
90°
135°

period
period
period
period
period

=
=
=
=
=

6.286"" Ljg
6.331"" Ljg
6.534"" Ljg
7.416,vrrg
9.600,.jIJg

Ch.2

Fundamental of Systemsj360 CSMP

11

5 A system is represented by the vector differential equation,

x=

Ax

+ bu

in which

A

=[ ~

1
-10

o

-16

~J b=[~J

u

= unit-step

16

-2

Use CSMP to find Xl(t), X2(t), and X3(t).
Answer:

At TIME = 1.9: Xl(t) = 0.793
6 The differential equation for the motion of the base of an unbalanced electric motor
is shown below.
Mx + ex + kx = mero 2 sin (rot)
=

0.1 Ib-sec 2/in

e

=

1.2 lb-sec/in

k

= 800 lb/in

M

me = 0.009 Ib-sec 2

Assuming the system is initially at rest, find the time-history of the motion of the
base. The motor speed increases according to the following formula.
ro = 12On(1 - e- t / 4 )
Unbalanced electric motor

Fig. P2.6

Answer:

When ro

=

90 rad/sec, x

=

0.067 in.

7 The system diagram of a process having time delay is shown in Fig. P-2.7
Find the unit-step response of the system. Compare your results with those given in
Fig. 2.14 which is the step response of the system above without delay. Use
FINTIM = 8.0, and OUTDEL = 0.16.

72

Fundamentals of System/360 CSMP

Ch. 2
C(s)

Fig. P2.7

Answer:
Using N

= 20 in the DELAY Function gives e(t) = 1.4116 at TIME = 1.44

8 Determine the time-history for the water level in each of the three tanks. Initially
the water level in all tanks is 10ft. The cross-sectional areas of the tanks are shown
below.
Ai = 4 ft2
A2

=

8 fP

A3

=

12 ft2

The general equation describing the height of water is

A/Ii

= qin -

qout

The flow through an orifice is given below.
q

=

=wIII \

Aorifice,j2gliH

~i" = 0.5 ft'lsec
1------.------1

Orifice area

=0.001

ft2

Orifice area = 0.002 ft2

Orifice area

Fig. P2.8

Answer:
At TIME

= 50 sec:

= 10.11 ft
H2 = 12.95 ft

Hi

H3

=

9.76 ft

=0.003 ft2

Ch. 2

Fundamentals of System/360 CSMP

73

9 A space vehicle is reentering the earth's atmosphere. In the position shown, the
vehicle is 200,000 ft from the surface of the earth and the speed is 25,000 mph. The
aerodynamic drag is:
!total =

0.5ACd PV 2

where A = cross sectional area of vehicle = 80 ft2
= drag coefficient = 0.55
P = 0.00238 e-h/24000 (slug/ftJ)

Cd

h = altitude in feet

The equations of motion in cylindrical coordinates are shown below.
m(r -

m(r8

r 82)

mg

= idrag radial -

+ 2f8) = - idrag tangential

(a) Using this information, how fast does the vehicle strike the earth? (b) What is the
total distance traveled by the vehicle? Hint: s
dissipated in aerodynamic drag? Hint: Energy

=

=

S: v dt (c) How much energy is

S: force ~; dt

,

Space vehicle

m

= mass = 80 slugs

80~

V

Fig. P2.9

Answer:
(a) 224 ft/sec (b) 779,000 ft (c) 5.43

X 10 10

ft-Ib

10 The block diagram of a system containing amplifier saturation is given in Fig. P2.10.
Use the function generator Y = LIMIT(PbP2,X) given in Appendix I to find the
response of the system if r(t) = R(s) = 3.5u(t) where u(t) is a unit-step starting at
t = 0. Select FINTIM = 4.0, OUTDEL = 0.08, and obtain the printer-plot output
of c(t).

74

Ch. 2

Fundamentals of System/360 CSMP

R(s)

v-- ~~--~_S_(S_+ 2)_(_S_+_1_0)~

+

6

g

~

__

Amplifier
with
saturation

k= 30

_ _ _ _ _ _..JtC--- _ _ _ _ _ _

-

1.5k

Characteristics of amplifier
Fig. P2.10

Answer:

At TIME = 1.28 c(t) = 5.2106
11 To test the impact characteristics of neoprene, a 36.6 lb weight is dropped on a
doughnut-shaped specimen. The velocity at impact is 52.7 in/sec. The acceleration of
the weight was measured to be the following:
Time
(sec)

o
0.002
0.003
0.004
0.005
0.006
0.007
0.008
0.01
0.012
0.015

Acceleration
(g's)

1g

=

386 in/sec 2

o
-13.0
-23.0
-32.0
-35.0
-34.0
-33.0
-24.0
-11.0

o
1.0

Using the AFGEN function to represent data taken from this test, determine
the time-history of the velocity and displacement of the top surface of the neoprene.
Also determine the energy absorbed by the neoprene.

Ch.2

Fundamentals of System/360 CSMP

15

Accelerometer·

36.61b
weight
I

~%
I

Neoprene

I

Fig. P2.11

Answer:

at TIME

=

0.0075 sees

displacement

=

0.208 in.

velocity

=

-15.0 in/sec

12 An automobile passes over a triangular bump at a speed of 20 ft/sec. Determine the
maximum pitch and vertical motion of the center of gravity. Neglect the deflection
of the tires and the effects of the unsprung mass. The automobile has the following
parameters.

Weight = 4200 lb
Spring constants
Damping coefficients
Pitch moment of inertia

=

front: 120 lb/in., rear: 180 lb/in.

= front: 10 lb-sec/in., rear: 12.0 lb-sec/in.
=

40,000 Ib-sec 2/in.

F~==:J V:

5"

t

t

20 ft/sec

65" {
Fig. P2.12

Hint:

Ijj

=

1: torques due to springs and shock absorbers about center of
gravity

my

=

1: forces due to spring and shock absorbers.

Answer:
Ymax

= 2.09 in.;

Bmax

= 1.84

0

76

Ch.2

Fundamentals of System/360 CSMP

13 Same as the above problem, except the shock absorbers are more realistically represented by having different linear damping coefficients in the compression and rebound
directions.

Damping coefficients

=

front: compression 6.0 lb-sec/in.; rebound
14.0Ib-sec/in.
rear: compression 8.0 lb-sec/in.; rebound
18.0Ib-sec/in.

Answer:
Ymax

= 1.588 in., ()max = 1.395°

14 A block diagram model of a position control system with tachometer feedback is
given in Fig. P2.14.

R(s)

('(s)

INPUT

OUTPUT

---""'I KTs 1 - - - - - '
Tachometer
Fig. P2.14

Let R(s) correspond to a unit-step [i.e., INPUT = STEP(O.O)] and find e(t) for values
of KT = 0.1, 1.5, 4.0. Use the PARAMETER card for running multiple values of
K T • Specify FINTIM = 5.0, and OUTDEL = 0.1 for the printer-plot of the output.
Also specify that ERROR and INPUT are listed on the same page which gives the
printer-plot of the output. Use a LABEL card with your choice of wording for the
title of the printer-plot output.
Answer:
e(t)

=

1.2329

at TIME

=

0.7

KT

=

e(t)

= 1.0468
= 0.9919

at TIME

=

0.9

KT

= 1.5

at TIME

=

1.9

KT

=

e(t)

1.0
4.0

15 The following Blasius equation is a transformed equation describing the laminar

boundary layer on a flat plate.
d 3I
d113

d 2I

+ d112 I = 0

Based on previous experience, the following boundary conditions will yield a
satisfactory solution.
1(11

dl
= 0) = dl1(l1
= 0) = 0

dl

dl1(l1

=

3)

=

2

Ch. 2

Fundamentals of System/360 CSMP

11

Using a trial and error solution determine the value of

d 2f

d1'/2 (1'/

= 0)

Answer:

~~~ (1'/ = 0) =

1.328

16 Solve the following set of differential equations.
3Xl
Xl

+ X2 + Sit + 10Xl
+ 4X2 + 2SX2 + 4x~

where

Xl(O)

= 10
=

+ e- t

0

= X2(0) = 0

Answer:

At TIME

=

1.0

Xl

= 1.276

17 The diagram below represents an experimentally measured water temperature
increase in a steam generating boiler due to a step input of fuel. The fuel is natural

200

190

G:'

'LQ)
I-<

.a

180

(1:f

I-<
Q)

0..

E

~-

170

1601--_ _-~

2

4

6

8

10

12

Time (minutes)

Fig. P2.17

14

16

18

20

18

Ch. 2

Fundamentals of System/360 CSMP

gas and the step input level is 10,000 ft3/hr. The heat content of the gas is approximately 1000 Btu/fP. A proposed model for matching the temperature increase (over
the range t = 0 to t = 19 min) due to the step input of fuel is given by
T(s)

K 2 f-7: d S

U(s) = s(l

+ 't'lS)(l + 't'2S)

where T has units of of, K2 has units of °F/ft3, U(input) is in ft 3/min, and 't'a, 't'b 't'2
have units of minutes. Use CSMP to assist you in determining appropriate values
for K 2 , 't'a, 't'b and't'2'
Answers:

K2 = 0.04 °F/ft 3, 't'a = 4 min, 't'1 = 2 min, 't'2 = 5 min
18 A red hot cylindrical piece of iron is brought from a heat treating furnace and is
allowed to cool in still air. Energy is removed from the piece by both convection and
radiation. Assuming the iron remains at a uniform temperature, the following
equation can be used to describe the transient temperature.

mc~; =
where: Ta = 545°R,
A = 3.01 ftz,

hA(Ta - T)

+ AfO'(T!

- T4)

= 161.7 Ibm, c = 0.13 Btu-IbmrR
h = 0.18(T - T a )o.33 Btu/ft2-hr (assuming turbulence

m

flow over piece)
f = 0.95,

0'

= 0.1714

X

10- 8 Btu/hr-ft2-oR4

Use the FINISH card to determine how long it takes for the piece to cool from
19100 R to 1300oR .

1. .~f---- 20"-----i·~1

I (. J~. _______T~) T,

= Ambient temperature

Fig. P2.tS

Answer:

0.378 hours
19 The following equations describe the angular recoil of a hand gun. The assumption
is made that the gun is loosely held so that no external moment is applied to the gun.
The restraining force vector passes through the center of mass. The parameters for a
38 caliber pistol are shown below.

Bullet weight = w = 0.0207 pounds
Moment of inertia about center of mass
d

=

1= 0.0105 Ib-in.-sec 2

= 0.9 inches

Cross-sectional area of bullet = A = 0.1 in. 2
Find the angular recoil of the hand gun and muzzle velocity for the following
description of barrel pressure.

Ch. 2

Fundamentals of Systemj360 CSMP

Id

2

()
2

=dAP

19

~ d 2 x =PA
386 dt 2

r=~'\=d~:-::====+'.~

dt

P = Pressure

,-.

.r;;

3~

5000

o
x (inches)

Fig. P2.19

Answer:

At x = 3.962 in., () = 0.018212 radians,
and x = 12600 in./sec
Closed form solution:

() = xwd/(386I)
20 An automobile engine has a stroke of 3.70 in. and a connecting rod length of 5.84 in.
as shown in Fig. P2.20. The following is an expression for the exact acceleration of the
piston for a constant engine speed.

L = 5.84"

r = 3.70"
2

Fig~

P2.20

80

Ch.2

Fundamentals of System/360 CSMP

a

=

-00 2 [R

cos 8

+ ~4 (L2 _

+ R2 (L2 -

R2 sin 2 8)-1/2 cos 28

R2 sin2 8)-3/2 sin2 28]

Use the above equation to calculate the acceleration of the piston for an engine
speed of 4800 rpm (00 = 1601t rad/sec) at three degree increments during one complete revolution of the crankshaft.

Answer:
a max = 3.355 x lOs in/sec 2 at 141 0
0
amin = -6.155 x lOs in/sec 2 at 0

3
ADVANCED FEATURES
OF CSMP

The preceding chapter introduced the basic concepts and features that allow
the reader to begin using CSMP. In this chapter, additional programming capabilities are described which permit considerable flexibility in the simulation of complex systems. The presentation is divided into five distinct areas: integration
methods, data statements, translation control statements, data output, and subprograms. Each section is essentially a separate entity and consequently the
material can be covered in any order.
Since integration is normally a pivotal point in most simulations, the first
section concentrates on the various numerical integration routines available in
CSMP.
Integration Methods

One of the most attractive features of CSMP is that the user seldom needs to
become involved in specifying either the type or any of the details of the numerical
integration method. For those who wish to specify the integration technique, there
are five fixed-step and two variable-step methods available. CSMP III provides
two additional techniques which are described in Chap. 5. If none of the seven
methods are suitable, the user can supply his own integration subroutine. The
following paragraphs describe the relative advantages and disadvantages of variable and fixed-step integration methods, error requirements, and give guidelines
for choosing the best integration method.

81

82

Ch.3

Advanced Features of CSMP

Variable-Step Integration Methods
When the integration method is not specified, a variable-step Runge-Kutta
method (CSMP name: RKS) is automatically used. This method is generally a
good choice for most problems and is used in the example problems-in Chap. 2. It
is a sophisticated method that has the advantage of automatically adjusting the
time increment of integration to meet the demands of the dynamic conditions of
the simulation. Thus, the user is virtually assured a satisfactory solution.
The second variable-step integration technique is the fifth-order, predictorcorrector, Milne method (MILNE). This method is specified by including the
following CSMP statement in the program.
METHOD MILNE

The MILNE method is similar to the RKS integration technique in that it
uses rather sophisticated numerical algorithms and adjusts the step-size to meet
changing conditions. MILNE integration has essentially the same advantages and
disadvantages as the RKS technique. Generally, one will not know prior to the
run which integration method will give the best simulation results. While the RKS
method may give best results for one problem, the MILNE method may perform
best for another type of problem.
Both methods have the disadvantage of sometimes using an extremely small
integration step-size which results in excessive computer time. The step-size is
controlled by algorithms which provide estimates of integration error.

Integration Error Requirements
In both variable-step methods, the absolute value of the estimated integration
error (ABSERR) and the relative magnitude of the estimated error (RELERR)
are compared with user-specified error-bounds. The step-size is then adjusted to
meet the desired error criteria. The error limit of the absolute error dominates for
large values of integrator output while the relative error is more important for
small values of output. A detailed mathematical description of all integration
methods and error criteria is contained in Appendix III.
If error-bounds are not specified, a value of 0.0001 is automatically used for
both the absolute and relative errors for all RKS and MILNE integration. The user
can specify either or both the relative and absolute errors for each integrator by
using the RELERR and ABSERR statements. Examples of both statements are
shown below.
RELERR X
ABSERR X

=
=

0.0002, Y
0.0003, Y

=
=

5.0E-5, Z
7.5E-5

=

0.0005

The first statement sets the relative error for the X, Y, and Z integrators to
the values shown. In the second statement, the absolute errors for only the X and
Y integrators are changed as indicated.
The use of the RELERR and ABSERR cards enables the user to specify the

Ch. 3

Advanced Features of CSMP

83

allowable error for each separate integrator which, in effect, governs the size of the
integration step. Computer time can be more efficiently used since step-size and
computer time are directly related.
It is quite difficult to determine the exact quantitative effect that the relative
and absolute errors have on step-size and solution accuracy. In order to show the
relationship of error-bound to solution accuracy for one particular problem, the
following second-order linear equation is solved using the variable-step RungeKutta method for values of relative and absolute error that ranged from 0.00005
to 0.1. The particular problem is the harmonic oscillator,

y + 4n 2y

=

0

(3.1)

with initial conditions of yeO) = 1.0, yeO) = 0
A plot of the exact solution for yet) is given in Fig. 3.1. To illustrate the effect
of ABSERR and RELERR error bounds, the exact solution is compared to the
Runge-Kutta numerical solution.

y

Or---------~~--------~------------~------------~--

- 1

Fig.3.1 Plot of the exact solution of y(t)
= 1, y(O) = O.

+ 41T2y(t) =

0, with

y(O)

Table 3.1 contains a summary of the average absolute difference between the
exact solution and numerical solution as a function of error-bound. The number
of integration steps is also listed. The information in this table should not be
directly applied to all problems but it does illustrate how error-bounds affect the
accuracy of solution for one particular problem. Round-off errors in the numerical
calculations limit the maximum accuracy of the solution. Consequently, the solution error cannot be expected to continue to become smaller indefinitely for increasingly smaller values of error-bound.
In some problems the error-bounds and the dynamics of the simulation do
not control the integration step-size. Since the solution must be calculated at each
output interval the integration step-size must be equal to or less than the magnitude
of either PRDEL or OUTDEL. This means that for small output-intervals the
step-size is determined by the print interval. For this condition the error-bound
has no effect on the step size. In the numerical solution ofEq. (3.1), which generated
the data contained in Table 3.1, the print interval was made sufficiently large to
not affect the integration step-size.

84

Ch.3

Advanced Features of CSMP
Table 3.1
Solution Error of Eq. (3.1) Using RKS as a Function of
ABSERR and RELERR.

Error-bound
ABSERR
and
RELERR

Average Absolute
Difference between
Numerical and Exact
Solutions

Number of
Integration
Steps

x
x
x
x
x
x
x
x
x
x
x

29
23
23
20
20
18
17
17
17
15
15

5.48
7.06
7.95
1.01
8.87
5.88
4.89
4.89
4.89
1.69
1.69

0.00005
0.0001
0.0002
0.0005
0.001
0.002
0.004
0.005
0.01
0.02
0.1

10- 6
10- 5
10- 5
10- 4
10- 5
10- 4
10- 4
10- 4
10- 4
10- 3
10- 3

As previously stated, it is not necessary to specify the integration step-size
for either the RKS or MILNE integration methods. The first integration step is
automatically set equal to io of PRDEL or OUTDEL, whichever is smaller. If
the user wishes to use a different value for the first step-size, this can be accomplished by specifying a value for DELT on the timer card. The definition of the
DELT specification is as follows:
DELT. The value of DELT is the integration interval or step-size of the independent variable. If DELT is specified, it is automatically adjusted if necessary to be a
submultiple of PRDEL or OUTDEL. If neither PRDEL or OUTDEL has been
specified, DELT is adjusted to be a submultiple of FINTIMjIOO. When DELT is
not specified, the first integration step is io of the smaller value of PRDEL or
OUTDEL. For either of the variable-step integration methods there is no need to
specify a value for DELT unless the user feels that the first step-size (io of smaller
value of PRDEL or OUTDEL) is too large. When using a fixed-step integration
method, the value of DELT should be carefully selected. Guidelines for choosing
a value are discussed later.
For some problems, the error requirements and the dynamics of the solution
may demand an extremely small step-size. A lower limit can be placed on the
integration step-size by specifying a value for DELMIN on the timer card.
DELMIN. The value assigned to DELMIN on the timer card specifies the
minimum allowable integration interval for the variable-step integration methods.
If DELMIN is not specified, it is taken as FINTIM X 10- 7 • The following timer
card shows a typical application where DELMIN is included.
TIMER FINTIM

=

8.0,

PRDEL

=

0.2,

DELMIN

= 2.0E-8

Ch. 3

Advanced Features of CSMP

85

If either of the variable-step integration methods attempts to use a value of DELT
smaller than DELMIN, the run is terminated at that point with the appropriate
message.

Fixed-Step Integration Methods
There are five fixed-interval integration techniques ranging from the sophisticated Runge-Kutta to an extremely simple rectangular integration. A listing of the
five fixed-step methods in the order of decreasing complexity is given below.
Summary of Fixed-Step Integration Methods

CSMPName

RKSFX
SIMP
TRAPZ
ADAMS
RECT

Method

Fourth-order Runge-Kutta with
fixed interval
Simpson's Rule integration
Trapezoidal integration
Adams-Second Order
Rectangular integration

The integration technique is specified by the use of the METHOD card with
the appropriate CSMP integration name. An example of specifying the trapezoidal
method is shown below.
METHOD TRAPZ
Since these methods all use a fixed-integration interval, the value of DELT
should be carefully chosen. Information for choosing a value for DELT is discussed
in the following section.

Choosing the Integration Method
When specifying an integration method one must be concerned with obtaining
sufficient accuracy without using excessive computing time. Generally, the selection of the best integration is an extremely complex decision. For problems that
are not extremely complex or do not require a large amount of computer time,
either the variable-step Runge-Kutta or Milne methods are probably the best
choice. The error-bound can be specified to meet the desired accuracy and the
step-size is then automatically adjusted to the changing dynamic conditions of the
problem.
The solution of Eq. (3.l) by both the Milne and the variable-step RungeKutta methods were compared to the exact solution given in Fig. 3.1. The stepsizes on the first set of runs were entirely controlled by the default error-bound of
0.0001. In the second set of runs the error-bounds were not changed, but 100 lines
of output were specified. From the results shown in Table 3.2, notice that the

86

Ch.3

Advanced Features of CSMP

Table 3.2
Comparison of Numerical Solutions Using The VariableStep Milne and Runge-Kutta Methods

Integration
Method

A verage Absolute
Difference between Number of
Numerical and Exact Integration
Solutions of Eq. 3.1
Steps

First set of runs,
default error bound
of 0.0001,
2 lines of output

Variable-step
Runge-Kutta

7.06 x 10- 5

23

Milne

1.08 x 10- 5

58

Second set of runs,
default error bound
of 0.0001,
100 lines of output

Variable-step
Runge-Kutta

4.86 x 10- 6

104

Milne

6.56 x 10- 6

112

smaller output interval of the second set of runs forced the integration step-size
to be smaller and consequently reduced the error.
For certain types of problems, fixed-step integration methods may give better
results. The following is a listing of three situations where fixed-step methods
should be considered.
1. In some types of problems where sudden changes or discontinuities occur,
the variable-step methods may demand an integration step which is smaller
than the minimum allowed (DELMIN). If this occurs the run is terminated
at that point. The user then has the choice of increasing the error requirements (RELERR and ABSERR), decreasing DELMIN, or using one of
the fixed-step methods.
2. If the output interval is very small, the maximum step-size is constrained
by the output and there is no need to use a sophisticated, time-consuming
integration technique. For this situation a simple fixed-step method should
be used.

3. When using elements such as IMPULS (Example 2.7) which involve critical
time-sequencing relationships, it is good practice to use a fixed-step method
that is a submultiple of the desired pulse interval.
The big problem in using a fixed-step method is choosing the proper integration step-size. DELT should be chosen such that it is sufficiently small to insure
an accurate solution and not too small to result in excessive run time. There is no
exact procedure for determining the proper step-size prior to making a simulation run. The dynamic response of the system determines the necessary step size.

Advanced Features of CSMP

Ch. 3

81

The faster the response, the smaller should be the integration interval. It is advisable
to make the first choice of DELT sufficiently small to ensure an accurate solution.
The step-size is probably too large if a smaller integration interval results in a
significantly different answer.
In order to provide an estimate on how integration error is affected by stepsize, the numerical solution of Eq. (3.1) was compared with the exact solution
shown in Fig. 3.1. This was done for all five fixed-step integration methods using
a step-size that ranged from 10 to 10,000 integration steps per cycle of the cosine
function. The average absolute difference between the exact solution and the numerical solution is plotted in Fig. 3.2 as a function of step-size for the five integration
methods.
10- 1

10- 2

Average
absolute
error

10- 3

10- 4

10- 5

__________~__________~________~
0.0001
0.001
0.01
0.1

DELT

10,000

Steps/period

10-6~

1000

100

10

Fig. 3.2 Average absolute error as a function of step-size and integration method.

88

Advanced Features of CSMP

Ch. 3

The results shown in Fig. 3.2 are only intended to show the relative accuracy
of the various methods as a function of step-size. The curves also illustrate that a
small integration interval does not necessarily give the greatest accuracy. If the
frequency content of the solution can be estimated, Fig. 3.2 can be helpful in
estimating the appropriate step-size.
As previously mentioned, the various integration methods are greatly different
in complexity and consequently require different amounts of computing time. In
order to provide an estimate on computing time for the five fixed-step methods, a
program was run in which 10,000 integration steps were performed. The computer
time required for only the numerical integration, using an IBM 360 Model 65
computer, is listed below.
Method

Time in Seconds

RKSFX
SIMP
TRAPZ
ADAMS
RECT

3.578
2.513
1.647
1.198
0.982

In many problems the most time-consuming portion of the simulation is not
the result of the numerical integration, but is due to the calculations required at
each integration step. The numb~r of times that all statements in the Dynamic
segment are executed for each integration step depends upon the method. Table
3.3 contains this information for all seven methods.
If the problem requires a large number of calculations for each integration
step, a savings in computer time may result if a smaller step-size is used in conjunction with a less sophisticated integration method.
Table 3.3

Integration
Method

RKSFX &RKS
SIMP
MILNE
TRAPZ
ADAMS
RECT

Number of Times that all
Statements in the Dynamic
Segment are Executed for
Each Integration Step
4
3
2
2
1

1

Ch. 3

Advanced Features of CSMP

89

The Variable KEEP

The CSMP variable KEEP is used to indicate when the numerical technique
has reached the end of an integration step. KEEP is set equal to 1 when a valid
integration step has been completed. For intermediate steps and for trial steps of
the variable-step methods, KEEP equals O. The KEEP variable was used in programs which calculated the average absolute error between the numerical and
exact solution of Eq. (3.1).
An example of a program using Simpson's integration rule with a step-size of
0.001 seconds is shown in Fig. 3.3.
TITLE PROGRAM TO CALCULATE THE AVERAGE ABSOLUTE ERROR OF EQUATION 3.1
INITIAL
CONSTANT PI = 3.14159, SUM = 0.0, COUNT = 0.0
OYNAfo41C
*

*
*

THE FOLLOWING 3 CARDS ARE USED T~ SOLVE EQUATION 3.1, WHEREYOO = StCOND DERIVATIVE OF Y WITH RESPECT TO TIME
YO = FIRST DERIVATIVE OF Y WITH RESPECT TO TIME

YOO = -4.0*PI*PI*Y
YO = INTGRL(O.O, YOO)
Y = INTGRL(l.O, YO)
*

TH~

FOLLOWING NOSORT SECTION IS REQUIRED TO USE THE "IF" STATEMENT

NOSORT
*

KEEP IS EQUAL TO 1 WHEN THE END OF A VALID INTEGRATION STEP IS REACHED

IF(KEEP. EQ .1) GO TO 1
GO TO 2
1 SUM = SUM + ABS(Y - COS(2.0*PI*TIME»
COUNT = COUNT + 1.0
AAER = SUM/COUNT
2 CONTINUE
TERMINAL
Tl~ER
FINTIM = 1.0, PRDEL
0.1, DELT
METHO~
SIMP
PRINT y, SUM, COUNT, AAER
eND
STOP
ENOJOB

0.001

Fig.3.3 Program to calculate the average absolute error ofEq. 3.1.

In the program of Fig. 3.3, the variable KEEP was used to indicate when a
valid integration step was reached. When KEEP equals 1, the variable SUM
increases by the absolute difference between the numerical solution Y and the
exact solution, cos(2.0*n*TIME). Also the number of valid integration steps is
recorded by the variable COUNT. The quotient, SUM/COUNT is equal to the
average absolute error AAER.
Table 3.3 shows that for Simpson's integration, statements in the Dynamic
segment are executed three times at each integration step. This means that KEEP
is equal to 1 every third time the program cycles through the Dynamic segment.

90

Advanced Features of CSMP

Ch. 3

Changing Integration Technique and
Output Interval During a Run

CSMP offers the user the flexibility of changing integration methods, stepsize, error requirements, and output-interval during a simulation run. The CSMP
CONTINUE statement is used for this purpose. (In CSMP III, the END CONTINUE is used.) A brief description of the CONTINUE statement.follows, while
a detailed explanation is included in this chapter in the section on translation
control statements.
A problem which illustrates the need to change step-size and output-interval
is the simulation of the impact of two railroad freight cars. A small step-size is
required during impact period because of the high forces and rapidly changing
conditions. A much larger step-size and output-interval can be used for the postimpact motion.
Example 3.1

In this example it is desired to calculate the forces, accelerations, and deflections
during the impact of two railroad cars. The motion after impact is also desired. Car number one is moving from left to right with a velocity of 8 ft/sec. It strikes and is coupled to a
second car that is initially stationary. The impact first occurs at t = O. The couplers are
assumed to be connected to both cars by a linear-spring and damper. A constant rollingresistance force opposing motion is also included. Figure 3.4 illustrates the simplified
problem and gives the appropriate parameters.

Initial velocity

= 8 ft/sec
Car no. 2

Car no. 1

SOUt&.fEIUI

CB&Q

Weights:
WI = 140,000 lb
W2 = 95,000 lb
Rolling resistance:
Car no. 1 = 600 lb
Car no. 2 = 400 lb

c = 18,000 lb-sec/ft
Coupler
Fig. 3.4 Impacting freight cars.

Advanced Features of CSMP

Ch. 3

91

Using Newton's second law, the equations describing the motion of the two freight
cars are derived as follows.
FORCE

=

K*(X2 - Xl)/2.0

+ C*(V2 -

Vl)/2.0

VI

= [FORCE - 600.0*SIGN(Vl)]/Wl/32.17

V2

=

[-FORCE - 400.0*SIGN(V2)]/W2/32.17

(3.2)
(3.3)
(3.4)

Symbols Used in CSMP
Program of Fig. 3.5

FORCE
K
C

ACCI & ACC2
VI &V2
Xl &X2
WI &W2

Force between cars.
Spring constant of coupler spring, 3.5 x 10 5 lb/ft.
Damping constant of coupler, 18,000 lb-sec/ft.
Accelerations of cars 1 & 2, respectively.
Velocities of cars 1 & 2, respectively.
Displacements of cars 1 & 2, respectively.
Weights of cars 1 & 2, respectively.

Prior to running the program, it was estimated that the impact would occur in less
than 1.0 sec. Therefore, FINTIM on the first TIMER card was set equal to 1.0 and the
output-interval was chosen to be 0.02. For the post-impact motion FINTIM was set equal
to 21.0 with an output-interval of 2.0. For illustration purposes, the fixed-step RungeTITLE SIMULATION OF THE IMPACT OF TWO RAILRCAD CARS.
THE OuTPUT
TITLE
INTERVAL AND INTEGR~TION TECHNIQUE ARE CHANGED DURING THE RUN.
CONSTANT K = 3.5E5. C = 18000.0, Wl = 140000.0, W2 = 95000.0
FORCE = K*(X2 - XlI/Z.O + C*IVZ - VlI/l.O
ACCl = IFORCE - 600.0*SIGN(1.0,Vl)t/(Wl/32.l7)
ACCZ = I-FORCE - 400*SIGN(l.O,V2)t/(w2/32.l1)
VI
INTGRL(S.O.ACClJ
V2 = INTGRL(0.0,ACC2)
Xl = INTGRLlO.O,Vl)
X2 = INTGRLIO.0.V2)
DEFLCT = Xl - X2
PRINT FORCE, ACC1, ACC2, Vl, V2, Xl, X2, DEFLCT
METHOD RKSFX
TIMER FINTIM = 1.0, PRDEL = 0.025, DELT = 0.0005

*

*
*

THE FOLLOWING CONTINUE CARD ALLOWS THE OUTPUT INTERVAL AND THE
INTEGRATION TECHNIQUE TO BE CHANGED DURING THE RUN.
THE CHANGES ARE MADE
AFTER 1.0 SECONDS, WHICH IS THE FINTIM TIME ON THE ABOVE TIMER CARD.

CONTINUE
~E THOD MILNE
RELERR Vl = 0.0005, V2 = J.0005, Xl
ABSERR Vl = 0.0005, V2 = 0.0005, Xl
TIMER FINTIM = 21.0. PROEL = 2.0
END
STQP
ENDJOB

Fig. 3.5

cars.

0.0005, X2
0.0005, X2

0.0005
0.0005

Program for the simulation of the impact of two freight

92

Ch.3

Advanced Features of CSMP

Kutta method (RKSFX) with a step-size of DELT = 0.0005 sec was used for the impact
period and the variable-step Milne (MILNE) method was used for the motion after
impact. Also for illustration purposes, the relative and absolute errors for all integrators
of the Milne integration were set equal to 0.0005.
The program for simulating this system is shown in Fig. 3.5. One notes the use of the
CONTINUE card to change the output-interval and integration technique. The CONTINUE card permits these changes without resetting the independent variable TIME.
The output for this simulation is contained in Figs. 3.6 and 3.7.
SIMULATION OF THE IMPACT OF TWO RAILROAD CARS.
THE OUTPUT
INTERVAL 4ND INTEGRATION TECHNIQUE AR E CHANGED OUR I NG THE RUN.
TIME
0.0
2.50001" -02
'5.0000E-02
7.5000E-02
1.0000E-Ol
1.7500E-Ol
1. 5000E -01
1.7500E-Ol
2.00001"-01
2.2500F-Ol
2.5000E-Ol
2.1S00E-Ol
3.0000E-Ol
3.25001:- 01
3.5000E-01
3.7500F.-Ol
4.0000F.-Ol
4.2500E-01
4.5000E-Ol
4.7500E-01
'5.0000E-Ol
5.25 OOE- 01
5.5000E-Ol
'5.75001:-01
6.0000E-Ol
6.2500F-Ol
6.5000E-Ol
b.7500E-01
7.0000E-Ol
7.2500E-Ol
7.5000E-Ol
7.7S00E-Ol
8.0000E-Ol
8.25 OOF -01
8.S000F-Ol
8.7500E-Ol
9.0000E-Ol
9.2500E-01
9.5000E-Ol
9.7500E-Ot
1.0000F 00

fORCE
-7.2000E
-9.3825E
-1.07 SSE
-1.1344E
-1.1201E
-1.0ft25E
-9.1367E
-7.H2ftE
-5.5740E
-3.5798E
-1.617lE
2.0343E
1.7936E
3.0889E
4.0ft93E
4.6593E
4.9257E
4.8741E
4.545SE
3.9929E
3.1746E
2.4525E
1.S867E
7.3274E
-6.1086E
-7.560IlE
-1.3231E
-1.1463E
-2.0169E
-2.1378E
-2.1201E
-1.98llE
-1.1442E
-1.4342E
-1.0781E
-7.0223E
-3.306bE
1.5599E
3.1927E
5.6803E
7.5395E

04
04
05
05
05
05
Olt
Oft
Oft
04
04
03
Oft
04
04
04
04
04
04
04
04
04
04
03
02
03
04
04
04
04
04
04
04
04
04
03
03
02
03
03
03

ACCI
-1.b682E
-2.1b97E
-2.4859E
-2.6205E
-2.5876E
-2.ft093E
-2.1133E
-1.730BE

01
01
01
01
01
01
01
01
-1.2~46E 01
-8.3637E 00
-3.S538E 00
3.2957E-Ol
3.9837E 00
6.9599E 00
9.1668E 00
1.0569E 01
1.1181E 01
1.1062E 01
1.030SE 01
9.0312E 00
7.3867E 00
5.4916E 00
3.50801: 00
1.5459E 00
-2.1824E-Ol
-1.8752E 00
-3.1796E 00
-4.1507E 00
-4.7723E 00
-5.0502E 00
-5.0095E 00
-4.6907E 00
-4. 1458E 00
-3.4334E 00
-2.6153E 00
-1.7515E 00
-8.9769E-Ol
-1.0203E-Ol
5.9577E-Ot
1.1674E 00
1.5946E 00

ACC2
2.4Ut6E 01
3.1631E 01
3.629!>E 01
3.8279E 01
3.7795E 01
3.5167E 01
3.0804E 01
2.5169E 01
1.8740E 01
1.1987E 01
5.3407E 00
-8.2431E-Ol
-6.2093E 00
-1.0595E 01
-1.3848E 01
-i.5913E 01
-1.6815E 01
-1.6641E 01
-1.5529E 01
-1.3657E 01
-1.122'tE 01
-8.4404E 00
-5.5084E 00
-2.6167E 00
7.1402E-02
2.4249E 00
4.3471E 00
5. 7782E 00
6.6943E 00
1.1038E 00
7.0438E 00
b. 5740E 00
5. 1709E 00
4.72UE 00
3.5155E 00
2.2425E 00
9.8428E-Ol
-1.S1128E-Ot
-1.2166E 00
-2.0590E 00
-2.688bE 00

VI
8.0000E
7.5164E
6.9306E
6.2886E
5.{>343E
5.0069E
4. ft3 94E
3.9574E
3.5784E
3.3119E
3.1596E
3.1164E
3.1716E
3.3099E
3.51nE
3.7614E
4.0349E
4.3143E
4.5826E
4.8254E
5.0313E
5.1927E
5.3053 E
5.3682E
5.3837E
5.3562E
5.2923E
5.1999E
5.0871E
4.9642 E
4.8378E
4.1l60E
4.b05tE
4.5100E
4.4342E
4.3796E
4.3465E
4. 3342E
4.3406E
4.3629E
4.3971E

00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00

RKSFX

V2
0.0
7.0417E-01
1.5590E 00
2.4966E 00
3.4523E 00
4.3684E 00
5.19blE 00
5.8979E 00
6.ft479E 00
6.8322E 00
7.0481E 00
7.1032E 00
7.0134E 00
6.8010E 00
6.4930E 00
6.U85E 00
5.7070E 00
5.2867E 00
4.8828E 00
4.5166E 00
4.2046E 00
3.9582 E 00
3.7837E 00
3.b824E 00
3.6512 E 00
3.6832E 00
3.7688E 00
3.8964E 00
4.0533E 00
4.22b8E 00
4.4045E 00
4.5755E 00
4.7304E 00
4.8620E 00
4.9651E 00
5.0371E 00
5.0773E 00
5.0870E 00
5.0691E 00
5.0211E 00
4.9b79E 00

INTEGRAT ION

Xl
0.0
1.9422E-Ol
3.7497E-Ol
5.4027E-01
6.8929E-01
8.2221E-Ol
9.40llE-01
1.0449E 00
1.1388E 00
l . l l 47E 00
1.30531: 00
1.3835E 00
1.4619E 00
1.5428E 00
1.6279E 00
1.7l87E 00
1.8161E 00
1.92 05E 00
2.0311E 00
2.1494E 00
2.2126E 00
2.4005E 00
2. ';)18E 00
2.6653E 00
2.1998E 00
2.9341E 00
3.0672E 00
3.1984E 00
3.3270E 00
3.4521E 00
3.5752E 00
3.6945E 00
3.6110E 00
3.9249E 00
4.036bE 00
4.14c>1E 00
4.2557E 00
4.3642E 00
4.4125E 00
4.58llE 00
4.6907E 00

X2
0.0
8.411lE-03
3.6464E-02
8.7054E-02
1.b 144E-Ol
2.5933E-Ol
3.7912E-Ol
5.1808E-Ol
6.7274E-Ol
8.3909E-Ol
1.0129E 00
1.1901E 00
1.3668E 00
t.5397E 00
1.7060E 00
1.8638E 00
2.0116E 00
2.1490E 00
2.2160E 00
2.3934E 00
2.5023E 00
2.6041E 00
2.7007E 00
2.1939E 00
2.8854E 00
2.9769E 00
3.0699E 00
3.1657E 00
3.2650E 00
3.3684E 00
3.4763E 00
3.5885E 00
3.7049E: 00
3.8248E 00
3.9417E 00
4.0728E 00
4.1992E 00
4.3263E 00
4.4533E 00
4.5195E 00
4.7045E 00

OEFLCT
0.0
1.8580E-Ol
3.3850E~01

4.53UE-01
5.2785E-Ol
5.6288E-Ol
5.6102E-Ol
5.2680E-Ol
4.6609E-Ol
3.8560E-Ol
2.9239E-Ol
1.9341E-Ol
9.5084E-02
3.0394E-03
-7.8133E-02
-1.450lE-01
-1.9547E-Ol
-2.28 51E-Ol
-2.4432E-Ol
-2.4405E-01
-2.2964E-Ol
-2.0363E-Ol
-1.6892E-01
-1.2857E-Ol
-8.5610E-02
-4.2837E-02
-2.1l32E-03
3.2749E-02
6.2055E-02
8.4238E-02
9.88b1E-02
1.0600E-Ol
t.0611E-01
1.0005E-01
8.8911E-02
7.3943E-02
5.6479E-02
3.7826E-02
1.9222E-02
1.7319E-03
-1.3760E-02

Fig. 3.6 Motion of railroad cars during impact.

THE OUTPUT
SIMULATION OF THE IMPACT OF TWO RAILROAD CARS.
INTERV4L AND INTEGRATION TECHNICUE ARE CHANGED DURI NG THE RUN.
TIME
1.0000E
3.0000E
5.0000F
7.0000E
'1.0000E
.I.IOOOE
1.3000E
1.5000E
1.7000E
1.9000E
2.1000E

FORCE
00
00
00
00
00
01
01
01
01
01
01

7.~395E

11.11 18E:
-1.'t982E
-2.8289E
-2.2b76E:
-3.8365E
-5.8007E
-8.7971E:
-3.4298E
4.4059f
-1.9237E

03
01
02
02
02
01
02
02
02
02
02

ACCI
1. 59't6E 00
-1.1922E-Ot
-1.7230E-Ol
-2.0288E-Ol
-1.8998E-Ol
-1.46b9E-01
-2.7UbE-01
-3.4002E-Ol
- 2.1668E-Ol
-3.6630E-02
-1.8208E-01

ACC2
-.1.6886E: 00
-1.6294E-Ol
-8.ft720E-02
-3.96!>8E-02
-5.8663£-02
-1.2246E-Ol
b.0978E-02
1.6244E-Ol
-1.9308E-02
-2.8465E-Ol
-7.0309E-02

VI
4.3971E
4.3517E
4.0830E
3.81S2E
3.5452E
3.2848E
2.9512E
2.7154E
2.4556E
2.1b39E
1.8984E

00
00
00
00
00
00
00
00
00
00
00

V2
4.9679E
4.3583E
4.0768E
3.7941E
3.5146E
3.2209E
3.03511:
2.7052E
2.4107E
2.1b31E
1.8770E

MI LNE

00
00
00
00
00
00
00
00
00
00
00

Xl
4.6907E
1.3679E
2.2113E
2.9999E
3.7338E
4.4127E
5.0315E
5.6069E
6.1215E
6.5814E
6.9867E

Fig. 3.7 Post-impact motion of railroad cars.

I NT EGRA TI ON

00
01
01
01
01
01
01
01
01
01
01

X2
4.7045E
1.3619E
2.2113E
2.9999E
3.7338E
4.4130E
5.0367E
5.6065E
6.1215E
6.5817E
b.9867E

00
01
01
01
01
01
01
01
01
01
01

DEFLCT
-1.3760E-02
-1.2207E-04
5.3406E-04
5.3406E-04
-2.7466E-04
-3.0670E-03
7.6294E-03
4.5013E-03
-3.5095E-04
-2.5635E-03
0.0

Ch. 3

Advanced Features of CSMP

93

In summary, choosing the best integration method is quite complicated, both
from a theoretical and a practical point of view. No absolute set of guidelines can
be written that will insure the optimum method is used for all problems. The
user should be prepared to experiment in order to obtain the best method with
regard to run-time and accuracy. It should be emphasized that either of the variablestep integration methods using the default error-bounds will give satisfactory solutions for the vast majority of problems. The additional computing time that may
result when using this approach is usually considerably less expensive than the
time the user would spend in choosing an optimum method. However, for complicated problems that will require a large amount of computing time, the user
can justify spending time in deciding which method will give the best results.

User-Supplied Integration Method
In the event that none of these seven integration methods satisfies the user's
requirements, an additional centralized integration method can be added to CSMP.
The complete integration routine is entered into the program as a FORTRAN
subroutine named CENTRL. The method is specified using the statement,
METHOD CENTRL
Example 3.2
To illustrate a program that employs a user-supplied integration technique, the
following linear, first-order differential equation will be solved.
d(CASH) = INTRST*CASH
dt

(3.5)

Initial condition: CASH(t = 0) = $1000.
Equation (3.5) governs the present value of a bank account where the money is
continuously compounded. This method of compounding is used by many banks and
savings and loan associations. The initial amount in the account is $1,000.00.
CASH

=

present value of bank account

INTRST

=

yearly interest rate

t

=

0.065 (6.5 %)

= time in years

The user supplied integration method is the CSMP Simpson method. Note that the
only reason for using the CENTRL integration feature in this problem is to demonstrate
its use.
Figure 3.8 shows a listing of the entire program. The comment cards are supplied to
assist the reader to interpret the program. The IBM System Manual(1) as well as the
section on subprograms should be used as a reference for this procedure. Most of the
information contained in Fig. 3.8 was taken from the IBM System Manual.
Figure 3.9 gives the output for the program for a time period of 50 years. The accuracy
of the numerical integration can be compared with Eq. (3.6) which is the analytical solution to Eq. (3.5).
CASH = 1000eO.065t
(3.6)

94

Advanced Features of CSMP

Ch. 3

*
*
*

PROGRAM TO ILLUSTRATE THE METHOD OF PROVIDING A USER-SUPPLIED
INTfr.RATION TECHNIQUE TO THE PROGRAM.
IN THIS EXAMPLE, THE CSMP
SIMPSON METHOD IS USED.
LABEL HISTORY OF SlOOO BANK ACCOUNT, 6.5 CONTINUOUSLY COMPUND INTEREST
RENAME TIME = YEARS
CONSTANT INTRST = 0.065
CASH
INTGRL(lOOO.O, INTRST*CASH j
TIMER FINTIM = 50.0. OUTDEL = 1.0, DELT
0.05
PRTPLT CASH
MFTHOn CENTRL
ENO
ST,)P
THE FOLLOWING IS THE FORTRAN SUBROUTIN~ "CENTRL"
C
SUBROUTINE CENTRL
TH~ FOLLOwING 2 COMMON AND 5 EQUIVALENCE CARDS ARE REQUIRED FOR ALL
C
INT~GPATION METHODS.
C
CO~MON DOUMl(b4) .C(8000),NALARM,KPOINT,DDUM2(16),RANGE(400),H,KEEP
CQMMON DDUM3(1214),IFLAG(SO),FAM(50),NOINTG,NOSYMB,SYMB(1)
EQUIVALENCE (IFLAG(16),ISTEP),(IFlAGl19),DTIME),(IFLAG(40),ISTORE)
FOUIVALENCE (IFLAGl18),ISTARTJ,(IFLAG(10),IFIRST)
~QUIVALENCE (C(l),TIME).(C(Z),DELT),(C(3.,DELMIN)
EQUIVALENCE (C(4),FINTIM),lC(5),PRDEL),(C{6),OUTOEL.
EOUIVALENCE (ODUM3(49Z),TNEXTJ,(DDUMZ(10),KREL),(DDUM2l11),KABS)
NOINTG IS THE NUMBER OF INTEGRATORS
c
C IS THE DYNAMIC STORAGE ARRAY FOR THE EXECUTION PHASE
C
H IS THE HIGHEST FREQUENCY OUTPUT SAMPLE RATE
C
DELT HAS BEEN MOCIFIED TO BE A SUBMULTIPLE OF H
C
TNEXT IS THE TIME OF THE NEXT OUTPUT POINT
C
C
C
C
C

STAR T OF PROGRAM
IF CENTRL IS AN ERROR TESTING INTEGRATION METHOD, SET NALARM TO
ONE WHEN ERROR TEST FAILS IN ORDER TO STOP RUN.
ISTART IS SET TO ZERO BY AN END OR CONTIN CARD TO START THE CASE
ISTEP IS SET TO ZERO TO INITIALIZE STATUS
ISTEP=O
ISTORE IS THE NUMBER OF LOCATIONS USED IN THE C ARRAY
ISTORE=KPOINT+3*NOINTG
GO TO 3000

c
c
c

C

2000

CO~TINUE

C
C
C

FOR SPECIAL INTEGRATION, USER ~UST INSERT HIS CODING HERE
AT THIS POINT VALUES ARE AVAILABLE FOR TIME lERO.(Y,YDOT,YIC)
INTEGRATOR OUTPUTS ARE LOCATED IN C(N+6) FOR N=l TO NOINTG
INTEGRATOR INPUTS ARE LOCATED IN C(N+6+NOINTGI FOR N=l TO NOINTG
INTEGRATOR INITIAL CONDITIONS IN C(N+6+2NOINTGJ FOR N=l TO NOINTG

C
C
C

HISTOR! OF OUTPUTS ~UST BE STORED IN USER
UPPER LOCAT IONS OF C ARRAY

C
C

DI~ENSIONED

ARRAY OR

C

C
C

C
C

c

EXAMPLE FOR K HI STORY POINTS (REPLACE ARGUMENTS WITH CONSTANTS)
DIMENSION CHYS(K,ll
EQUIVALENCE(C(8000-300*K+l) ,CHYS(l)
IN THf SIMPSON INTEGRATION METHOD, THERE ARE 3 HISTORY POINTS,
K
EQUIVALENCE (C(7101I, CHYS(ll)
DIMENSION CHYSl3,l),CY(1)
THF. FOLLOWING IS THE CSMP SIMPSON INTEGRATION METHOD.
~QUIVALENCE (C(7),CY(11)
FQUIVAlENCE(DlJU~2( 13) ,HAST)

C

C
C
C
C

HISTORY IS STOREC AS FOLLOWS
CHYS(J,I)=PAST VALUES AS REQUIRED
WHERE J VARIES FROM 1 TO K HISTORY POINTS AND
WHERE I VARIES FROM 301-NOINTG TP 300

C

Fig. 3.8 Program illustrating the use of CENTRL.

3

Advanced Features of CSMP

Ch. 3

95

00 2010 II=l.NOINTG
1=301-II
J=r-.JOINTG+ll
CHYSll.IJ=CY(II)
CHY S ( 2. I ) =C Y( J)

2010 Cv ( It) =.5 *0 Fl T *c Y ( J ) + CY ( I I )
OTIME=OTIME+l.
JI~E=DTIME*.5*OElT+TlAST

2020

2030
2040
C

3000
C

c
4000

ISTART=l
KEEP=O
tALL UPDATE
DO 207.0 IJ=l.NOINTG
1=301-11
J=NClINTG+II
CHYSI3.1)=CYIJI
CY I I I »= • 5 *D El T*c YI J j+ Cv I I I )
OT! ME=OTlME+l.
TIME=OTIME*.5*DELT+TLAST
CALL UPDATE
on 2030 IJ=l.NOINTG
1=301-1 I
J=NOINTG+I1
CY(II)=CHYS(1.I)+.5*OElT*(CHYSI2.1)+4.*CHYSI3,I)+CYIJ) )/3.
CONTINUE
KEEP IS SET TO IDENTIFY POINT TO STORE
KFEP ;: 1
CALL UPDATE
CO"lTI NUE
STATUS CHECKS FOR VARIABLE RANGES A~D OUTPUT TIMES
CAL l ST ATUS
IFIRST IS SET TO 4 TO INDICATE THE END OF A CASE
IFIIFIRST-4)2000.4000.4000
RETURN
END

ENOJOB

Fig.3.8 (Continued)

Data Statements
Three of the most useful and commonly used data statements are CONSTANT, PARAMETER, and INCON. These three statements are completely
equivalent in CSMP and they were previously defined and used in Chap. 2. It
should be pointed out that these data statements cannot be used for assigning
values to subscripted variables. As in FORTRAN, subscripted variables require
special consideration. Following are descriptions of how data statements using
subscripted variables are used in CSMP programs.

Subscripted Variables
Subscripted variables provide a procedure for handling large arrays of related
data as are frequently found in systems represented by simultaneous equations.
Any valid symbol, except those which start with the letters I, J, K, L, M, or N,

HISTORY OF S1000 BANK ACCOUNT. 6.5 CONTINUOUSLY COMPOUND INTERST
MINIMUM

CASH

PAGE

VERSUS YEARS

1.0000E 03

CASH

YEARS
0.0
1.0000E
2.0000E
3,.0000E
4.0000E
5. OOOOE
b.OOOOE
7.0000E
8.0000E
9.0000E
1. OOOOE
1.1000E
1.2 OOOE
1.3000E
1.4000E
1.5000E
1.6000E
1.1000F.
1.8000E
1.9000E
2. OOOOE
2.10001:

2.2000E
2.3000E
2.4000E
2.5000E
2.6000E
2.1000r::
l.8000E
2.9000E
3.0000E
3.1000F.
3 •. 2000E
3.3000E
3.4000E
3.5000E
3.6000E
3.1000E
3.8000E
3.9000E
4.0000E
4.1000E
4.2000E
4.3000E
4.4000E
4.5000E
4.60001=
4.1000E
4.8000E
4.9000E
5. OOOOE

00
'00
00
00
00
00
00
00
00
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01

1.0000E
1.0672E
1.13BBE
1.2l53E
1.2969E
1.3840E
1.4110E
1.5762 E
1.6820E
1.1950E
1.9155E
2.0441E
2.1814E
2.3279E
2.4S43E
2.b511E
2.829lE
3.0191E
3.2219E
3.4383E
3.6692E
3.9156E
4.1785E
4.4~91E

4.7586E
5.0781E
5.4191E
5.7830E
6.1714E
6.5858E
7.0280E
7.5000E
8.0036E
8.,411E
9.1l47E
9.7268E
1.0380E
1.1077E
1.1821E
1.2615E
1.3462E
1.4,366E
1.5331E
1.6360E
1.14,9E
i.B632E
1.9883E
2.1218E
2.264.3E
2.4164E
2.5186E

I
+

fo'AXIMUM
2.5786E 04
I

03
03

+

03

+

03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
04
04
04
04
04
04
04
04
04
04
04

+
+
+

----+
----+
-----+
-----+
------+
------+
-------+
--------+
--------+
---------+
----------+
-----------+
------------+
-------------+
--------------+
---------------+
-------------.---+
-----------------+
------------------+
--------------------+
---------------------+
-----------------------+
-------------------------+
--------------------------+
-------------.---------------+
------------------------------+
---------------------------------+
----------------------------------+
--------------------------------------+

04
04
04

------------------------------------------+
----------------------------------------------+
-------------------------------------------------+

04

+
-+
-+

-+
-+
--+
--+
--+

--+
---+

---+

----+

---------------------.-------------------+

Fig. 3.9 Output for program of Fig. 3.8.

96

1

Ch. 3

Advanced Features of CSMP

97

may be subscripted. Examples of both valid and invalid subscripted variables are:
Valid

Invalid

A(3)
COUNT(5,7,6)
ZP123(7,2,8)

JP(8)
ABCDEFG(4,2)
4X(9)

(Invalid first symbol)
(Excessive characters)
(First character cannot be a number)

As in FORTRAN, it is necessary to specify the following information before
using subscripted variables.
1. What variables are subscripted.
2. How many subscripts there are for each subscripted variable.
3. The maximum size for each subscript.
This information can be specified by using either the DIMENSION or STORAGE statements.
DIMENSION Statement
Subscripted variables larger than one dimensional arrays [e.g. X(3, 5) Y(3, 7, 5)]
must be listed on a DIMENSION card. The DIMENSION statement is handled
exactly as in FORTRAN with the exception being that a virgule (j) must appear
in the first column. The virgule indicates that the DIMENSION instruction is a
FORTRAN specification statement (discussed below). An example of a valid
statement is shown below.
Statement must
begin after
column 6

(At least one blank space

~DIMENSION X(20), Y(4, 10), A(4, 4, 4)
" - Virgule in column 1
~ ~ommas between

/

all listings

The compiler will assign 20 spaces to the one-dimensional array named X,
40(4 X 10) spaces to the two-dimensional array Y, and 64 (4 X 4 X 4) sp~ces to
the three-dimensional array A. The user should not attempt to use' a subscript
larger than the maximum size as specified in the DIMENSION statement. Also,
subscripts must never be smaller than 1. This means that negative numbers and
zero cannot be used as subscripts. A seven-dimensional array, which is the limit
of FORTRAN IV (Level G), is the largest that can be used in a CSMP program.
The DIMENSION statement should be placed at the beginning of the program
since it must appear before any subscripted variables are used.

98

Advanced Features of CSMP

Ch. 3

FORTRAN Specification Cards
Cards containing a virgule (/) in column 1 are called FORTRAN specification
cards. These cards are treated exactly as FORTRAN statements and consequently
must follow a somewhat different format than usual CSMP statements. The following rules must be followed when using FORTRAN specification cards.

1. All FORTRAN specification cards must contain a virgule (j) in column 1.
2. Statements must be contained in columns 7-72.
3. A maximum of 10 FORTRAN specification cards are permitted in any
one program.
4. Continuation cards are permitted and must contain a nonzero character
in column 6 and a virgule in column 1.
The following DIMENSION statement illustrates the continuation of a FORTRAN specification instruction.
/
/

DIMENSION X(9), Y(8), Z(7, 8, 8),
1
Q(6,6), RT(3, 3, 3, 3)
"-- {NOnzero character in column 6
for all continuation cards
Virgule in column 1 for all cards of
{ FORTRAN specification statements

~

STORAGE Statement
One-dimensional arrays [e.g. X(5), Y(78)] can be handled by using the CSMP
STORAGE statement. This card is used similarly to the DIMENSION statement,
the exceptions being that it can only be used for one-dimensional arrays and that
it is not a FORTRAN specification card. An example of a valid statement is
, - - At least one blank space is necessary
STORAGE Z(90), Y(75), X(5)
The symbols following the STORAGE label represent subscripted variables
with the appropriate number of storage locations contained within parentheses.
A STORAGE statement may be continued to additional cards by using either
three consecutive periods or multiple STORAGE cards. All STORAGE statements should be placed at the beginning of the program since they must appear
before any subscripted variables are used. DIMENSION and STORAGE statements may be used in the same program.
Subscripted variables are subject to certain restrictions in CSMP programs.
Special care must be taken to observe the following rules.

Ch. 3

Advanced Features of CSMP

99

All subscripted variables must be declared in either a DIMENSION or
STORAGE statement.
2 Subscripted variables cannot appear to the left of an equal sign except in
a no sort section or within a PROCEDURE function. The use and definition of a PROCEDURE function is covered later in this chapter. Examples
of statements that are only allowed in nosort sections or in PROCEDURE
functions are:
Y(5)
Y(l)

=

SIN(3.0*TIME)

= 3.14159*Q(3)

Examples of statements allowed in all sections of the program are:
Z
Q
P

=
=
=

4.0*X(4) + COS(Y(2»
AFGEN(ABC, X(6»
INTGRL(S.7, Y(3»

3 The output of an INTGRL function cannot be a subscripted variable.
Thus, the following statement type is not allowed anywhere in the program.
X(2)

=

INTGRL(2.3, Y)

4 Subscripted variables cannot be used in PRINT or PRTPLT statements.
(This is not the case in CSMP III). In order to obtain a PRINT or PRTPLT
output of subscripted variables, it is first necessary to set the dimensioned
variables equal to non subscripted variables. This is illustrated in following
examples.

Assigning Values to Subscripted
Variables
There are three convenient methods for assigning values to subscripted variables.
The CSMP "TABLE" statement.
2 The FORTRAN "DATA" statement.
3 The FORTRAN "READ" statement.
A description of the use of these three statements along with a method of declaring
variables as integers follows.
TABLE Statement: Subscripted variables that are listed on a STORAGE
card may be assigned values using the TABLE statement. This is a CSMP data
statement which allows values to be assigned to one-dimensional subscripted variables. The use of the TABLE card is similar to the other data statements (CONSTANT, PARAMETER, and INCON) the exception being that the TABLE

100

Advanced Features of CSMP

Ch. 3

statement can only be used for one-dimensional subscripted variables. In addition
to the usual way of assigning values, the K*n form can be used to assign K consecutive variables the value n. The following is an example of a valid statement.
TABLE X(I) = 22.56, X(9) = -0.891, X(3 - 6) = 4*6.74, Y(I) = 3.14

In the above example X(1), X(9), and Y(1) are assigned the values shown. X(3),
X(4), X(5), and X(6) are all set equal to 6.74. All variables contained in a TABLE
statement must be listed on a STORAGE card. TABLE statements may be continued to additional cards by using either three consecutive periods or multiple
TABLE statements may be used.
DATA Statement: The FORTRAN DATA statement provides an additional
means for assigning values to subscripted variables. The DATA card is a FORTRAN specification statement and must contain a virgule in column 1. Only subscripted variables should appear on a DATA card and these variables must be
listed in a DIMENSION statement. Subscripted variables that are listed in a
FORTRAN EQUIVALENCE statement must not appear on a DATA card. An
example of a DATA and appropriate DIMENSION statement is

1

DIMENSION Y(3, 2)
DATA Y/6*3.141

1

The above DATA statement assigns a value of 3.14 to all six variables of the twodimensional array.
The order in which numerical values are assigned to a two-dimensional array
is illustrated by the following statements.

1

DIMENSION Y(3, 2)
DATA Y/7.45, 2*5.89, -4.32, 2*3.331

1

These statements will assign the numerical values of
Y(I, 1)
Y(2, 1)
Y(3, 1)

=
=
=

7.45
5.89
5.89

Y(1,2)
Y(2, 2)
Y(3, 2)

=
=
=

-4.32
3.33
3.33

A single DATA statement can also be used to assign values to more than one
subscripted variable. For example,

1
1

DIMENSION X(3, 2, 2), Y(2)
DATA X/4*4.27, -7.16, 3*12.81, 4*0.71/, Y/2*87.31

The above card assigns the values,
X(I, 1,
X(2, 1,
X(3, 1"
Y(1) =

1) = 4.27
1) = 4.27
1) = 4.27
87.3

X(I, 2,
X(2, 2,
X(3, 2,
Y(2) =

1) = 4.27

1) = -7.16
1) = 12.81
87.3

X(I, 1,2)
X(2, 1,2)
X(3, 1,2)

=
=
=

12.81
12.81
0.71

X(1, 2, 2)
X(2, 2, 2)
X(3, 2,2)

=
=
=

0.71
0.71
0.71

A more comprehensive description of DATA statements can be found in many
books on FORTRAN. (2-5)

Ch. 3

Advanced Features of CSMP

101

FIXED Statement: When using subscripted variables, it is often necessary to
use variables as integers for such purposes as indexing. Variables are specified as
integers by the use of the FIXED statement. This instruction allows the user to
declare selected variables as integers (fixed-point numbers). As previously stated,
all variables in CSMP are automatically treated as real numbers (floating-point)
unless otherwise specified. Consequently, any valid symbol that is to be treated as
an integer must be included on a FIXED card. The following is an example of a
valid FIXED statement.
FIXED I, A, Y6, J

~At least one blank space

Continuation cards (... ) or multiple FIXED cards may be used if necessary.
It should be remembered that integer variables cannot be used in either
PRINT or PRTPLT statements. If the output of an integer variable is desired, it
should first be set equal to a real variable. The following two statements could be
used to print the value of the integer variable I.
Z = I (This statement must be in the Dynamic segment.)
PRINT Z

READ Statement: The convenience and flexibility of the FORTRAN statement, READ (5, XYZ) can be used in CSMP programs to assign values to variables. The READ card must appear in a nosort section. It is usually placed in the
Initial segment since this segment is only executed once at the beginning of the
simulation. However, the READ statement can also be included in a nosort section
of the Dynamic segment. The user should be aware that all statements in the
Dynamic segment are executed from one to four times for each integration step.
The exact number of executions depends upon the integration method and is given
in Table 3.3. When using a READ instruction for nonsubscripted variables, the
variable must appear somewhere else in the program before it can be included in
a PRINT or PRTPLT statement.
A FORTRAN FORMAT statement must be used in conjunction with a
READ card. The FORMAT card specifies the form in which numerical values
are listed on data cards. The FORMAT card must be contained in a nosort section
and any continuation cards must have a $ in card column 6. A detailed explanation
on the use of READ and FORMAT statements can be found in books on FORTRAN.(2-SJ
Numerical values used with the READ statements are contained on data
cards. These cards must be placed between the labels DATA and ENDDATA.
The DATA card must immediately follow the END card. The ENDDATA label
follows the last data card and it must be punched in card columns 1-7. In CSMP
III, the labels INPUT and ENDINPUT are used in place of DATA and ENDDATA. It should be noted that this DATA card is a CSMP statement and is
different from the FORTRAN DATA statement that was previously described.
Portions of three programs which use READ and FIXED statements are shown
below.

INITIAL
STORAGE X(4)
FIXED J
NOSORT
100 FORMAT(2F10.0)
READ(5,100) (X(J), J
DYNAMIC

:

=

1,4)

} Statements defining the run.

END
DATA
19.
9.
ENDDATA
STOP
ENDJOB

24.
47.

INITIAL
DIMENSION Y(2, 3)
FIXED K, J
NOSORT
50 FORMAT(3F14.2)
READ(5, 50)«Y(K, J), J = 1,3), K
DYNAMIC

:

=

1,2)

} Statements defining the run.

END
DATA
13.42
0.78
ENDDATA
STOP
ENDJOB

-67.80
3.34

3.56
32.56

INITIAL
NOSORT
READ(5,999) P, Q, R, S
999 FORMAT(4E12.3)
DYNAMIC

:

} Statements defining the run.

END
DATA
0.543E4
ENDDATA
STOP
ENDJOB
102

0.400E7

0.643E-4

0.484E3

Ch.3

Advanced Features of CSMP

103

Specification Form of INTGRL
Statement

To facilitate the integration of subscripted variables, the specification or array
form of the INTGRL statement can be used. This form of the INTGRL statement
allows the use of subscripted variables as inputs, outputs, and initial conditions.
The general form of the statement is
ZE

where

INTGRL(XOE, XE, N)

=

ZE

=

output of the integration

XOE

=

initial condition

XE

=

integrand

N

=

number of elements in the integrator array, N must be a
literal integer constant

In order to use the above specification form of the INTGRL statement for an
array of 20 in S/360 CSMP, the program must begin with DIMENSION and
EQUIVALENCE cards.

/
/

DIMENSION X(20),XO(20),Z(20)
EQUIVALENCE (XE,X(1)), (XOE,XO(l)), (ZE,Z(l))

The above cards are not required when using CSMP III. See Chap. 5 for a
detailed explanation and examples.
It is not permissible to use a STORAGE card to declare the subscripted variables that appear in the array form of INTGRL statements.
In conjunction with the above DIMENSION and EQUIVALENCE statements, the expression
ZE

=

INTGRL(XOE,XE,20)

will integrate 20 variables, namely
Z(l)

=

Z(2)

=

S: X(l) dt + XO(l)
S: X(2) dt + XO(2)

Z(20)

=

S: X(20) dt + XO(20)

An example illustrating the use of subscripted variables with the specification
form of the INTGRL statement is the following transient heat transfer problem.

104

Advanced Features of CSMP

Ch. 3

Duct

Air flow

Tungsten heating rod

Fig.3.10 Cross-section of tungsten heating rod in duct.

Example 3.3
Consider air flowing in a duct across a tungsten heating element. As electric current
supplies energy at a uniform rate per unit-volume to the wire, energy is being removed
from the circular heating element by radiation, convection, and conduction. The problem
is to find the transient temperature distribution along the rod after the current is turned on.
The temperature distribution of the rod is described by a partial differential equation
having time and distance as the independent variables. Since partial differential equations
cannot be directly solved using CSMP, a common method of solution is to divide the
tungsten element into a number of small equal-sized elements. Each element is assumed to
qradiation

=ES(T4 (i)

- TA 4 )As

qconvection

= H(T (i) -

T A)A s

qradiation qconvection

1

T(i - 1)

1

qconduction

=KAc(T(i) -T(i+ l))/L

T(i)

~----L

qconduction

= KAc (T (i -

=----'..---.-

DIA

1) - T(i))/L

L=O.lft
DIA = 0.01 ft
Ac = cross-sectional area =~ (DIAl2

As
TA
T(i)

= surface area = 1T·L·DIA

=air temperature, = 530

0

R

= temperature of i th element

Fig. 3.11

Heat flow from ith element.

Ch. 3

Advanced Features of CSMP

105

have a uniform temperature. This method transforms a continuous system into a lumped
system which is represented by a set of ordinary differential equations. The accuracy of
the simulation improves as the element size decreases.
In this example~ the heating element is divided into 20 equal-sized elements~ each 0.1
ft long and 0.01 ft in diameter. The elements are sequentially numbered left to right.
Figure 3.11 shows the heat flow for the ith element. An energy balance on this element
yields the following equation.

d~?)

[K.AC(T(i - 1) - 2.0T(i)

=

+ T(i + 1»/L

- ES·AS(T(i)4 - TA4) - H·AS(T(i) - TA)

+ QELEC·AC·L]/(RO·C·AC·L)
where

T(i)

(3.7)

= temperature of ith element, oR

K

=

thermal conductivity, 94.0 Btu/hr-ft-oR

AC

=

cross-sectional area of tungsten rod, f12

ES

=

Stefan-Boltzmann constant times surface
8.5 x 10- 10 Btu/hr-ft2-oR4

TA

=

air temperatures in duct, 5300 R

H

=

heat transfer coefficient for forced
25.0 Btu/hr-ft2-oR

emissivity~

convection~

AS

=

surface area of element, ft 2

RO

=

density of tungsten, 1208 Ibm/ft 3

C

=

specific heat of tungsten, 0.032 Btu/lbmoR

QELEC

=

electrical energy supplied per unit-volume,
6.0 x 10 6 (Btu/hr-ft3)

In the first equation of the array (i = 1)~ the T(i - 1) term must be set equal to the
temperature of the left wall. In the same manner, the T(i + 1) term of the last equation
(i = 20) must be set equal to the temperature of the right side wall.
The program for simulating this system is shown in Fig. 3.12.
There are several points which should be discussed regarding the program.
1. Note that it is necessary to use the DIMENSION and EQUIVALENCE statements to specify the subscripted variables used with the specification form of the
INTGRL statement. These relationships are given below.
Subscripted variables

EQUIVALENCE variables

T(i) = temperature of ith

TE

element
TI(i) = initial temperature
of ith element

TIE

TD(i)

=

d~~i)

TDE

106

Ch.3

Advanced Features of CSMP

TITLE
THE USE OF SUBSCRIPTED VAPIABLES TO SOLVE A HEAT TRANSfER
TI TLI:
PROBLEM
INITIAL
I
UI~ENSICN
T(20). ll(20), TO(20)
I
EyLlIVALENCE (TF,T(U), (TIE,TlCU ), (TOE, TOCl) )
FIXED 1
CONSTANT RO = 1208.0, C = 0.032, K = 94.0, H = 25.0, ES = 8.5E-IO •••
, OIA = 0.01, L = 0.1, TA = 530.0, THALL = 530.G. QElEC = 6.0E6
AC = 3.14159*OIA*0IA/4.0
AS = 3.1415Q*OIA*L
NOSORT
00 2 1 = 1,20
2 TI(I) = 530.0
DYNAMIC
NOSORT
TO{I) = (K*AC*(TWAll - 2.0*T(I) + T(2»)/L - ES*AS*CTCl)**4
TA**4J - H*AS*U(U - TA) + QElEC*AC*U/(RO*C*AC*U
TO(20) = (K*~C*(T(19) - 2.0*T(20) + TWAll)/L - ES*AS*{T(20)**4 TA**4) - H*AS*(TI20) - TA) + OElEC*AC*l)/lRO*C*AC*ll
DO 1 I = 2,19
TOll) = (K*AC*(T(I-l) - 2.0*T(II + T(I+l')/L. - ES*AS*CTCIl**4 TA**4) - H*AS*ITlI) - TA) + QElEC*AC*l)/(RO*C*AC*L)
SORT
*
*

THE FOLLOWING IS THE SPECIFICATION fORM OF THE INTGRL STATEMENT.
USED TO INTEGRATE ARRAYS.

TE
*

*

*

IT IS

= INTGRl(TIE,TOE,20)

SUBSCRIPTED VARIABLES CAN NOT BE INCLUDED IN PRINT OR PRTPlT STATEMENTS.
CONSEQUENTLY, IT IS NECESSARY TO INTRODUCE THE FOllOWI~G FOUR VARIABLES
FOR OUTPUT PURPOSES.
TI = Ttl)
= 1(5'
no = TelO)
T11 = 1(17)

T5

PRINT Tl, T5. TIO, T17
FINTIM = 0.018,

TI~ER

PROEL

0.0006

END
STOP
END JOB

Fig. 3.12 Program to simulate temperature of tungsten rod.

2 The last portion of the Initial segment is changed to a no sort section to allow a DO
loop to be used to set all values of initial temperatures TI(i) equal to 530o R. All
calculations for initial conditions that are used in INTGRL statements must be
performed in the Initial segment. Because TI(i) must be declared in a DIMENSION
statement and not in a STORAGE statement, a TABLE card cannot be used to
initialize the values of TI(i). Also, since TI(i) is contained in an EQUIVALENCE
statement, a DATA card cannot be used to specify the initial values for TI(i).
3 The first portion of the Dynamic segment is changed to a no sort section to allow
subscripted variables to appear on the left-hand side of the equal sign and also
to permit the use of the DO loop.
4 If the INTGRL statement were written as
TE

=

INTGRL(530.0, TDE,20)

only the first term of the array T(l) would have the initial value of 530.0. All of the

Ch. 3

Advanced Features of CSMP

107

remaining terms would have initial value of zero. For this reason it is necessary to
include the array TI(i) for nonzero initial conditions.
5 Since subscripted variables cannot be used in S/360 CSMP PRINT or PRTPLT
statements, it is necessary to set all subscripted variables desired as output equal
to nonsubscripted variables. In this example, the subscripted variables T(1), T(5),
T(lO), and T(17) are set equal to new variables for output purposes.
The resulting output for this simulation is shown in Fig. 3.13.
THE USE Of SUBSCRIPTED VARIABLES TO SOLVE A HEAT TRANSFER

RKS

PROfnEM

TIME
0.0
6. QOOOE - 04
i.7000E-03
1.HOOOE-03
2.4000E - 03
1.0000F-03
3. 6000F. - 03
4.2000E-03
4.bOOOF-03
5. 4000E: - 03

b.OOOOE-03
6. 6000E - 03
7.2000E-03
7. !:IOOOF -03
8. /i-000E - 03
9.0000F-03
9. oOOOE: - 03
1.02 ODE - 02
1.0800F.-02
1.1400f-02
1. 2000F- 02
1.2600E-02
1.32 OOf - 02
1.3800E-02
1.4400E-02
1.5000F-02
1.5600E-02
1.62 OOE- 02
1.6800E-02
1. 7400F -02
1.BOOO£-02

Tl
5.3000E
6.10S3E:
6.7098E
7. I 705E
7.S261E'
1.d03SE
8.0216E
8.1944f
8.3320E:
8.4421E
8.5305E
B. 6018 E
8.6593E
8.7059E
8.7437f
8.7745E
8.7994E
8.8198E
8.8364E
8.8500E
8. 8611E:
a.870iE
8.8775E:
8.8836E
8.888bE
8.8927E
8.89t>OE
8.8988E
8.90 lUE
8.902QE
8.9044E

02
02
02
02
02
02
02
02
02
02
02
02
02
02

02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02

T5
5.3000E
6.101 OE
6.8947E
7.518SE
8.0478E
8.49bOE
8.8747E
9.1939E
9.4626E
9.68a2E
9.8775E
1.0036E
1.0168E
1.0279E
1.03 HE
1.044BF
1.0512E
1.0566E
1.ObIOE
1.0647E
1.061SE
1.0703E
1.0724E
1.0742E
1.0756E
1.0768E
1.0778E
1.07B7E
i.0794E
1.0199E
1.0804E

HO
02
02
02
02
02
02
02
02
02
02
02
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03

5.3000E
b.1610E
6.8941E
1.5185E
8.0419E
3.4963E
8.8752E
9.1950E
9.4b43E
9.6908E
9.8811E
1.0041E
1.0175E
1.0287E
1.0380E
1.0459E
1.0524E
1.0519E
1.0625E
i.0663E
1.0695E
i.0721E
1.0743E
1.0762E
1.0717E
1.0790E
I.OBOIE
1.0810E
1.OB17E
1.0824E
1.0829E

02
02
02
02
02
02
02
02
02
02
02
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03

H1
5.3000E
6.1610E
6.894bE
7.5i82E
8.0469E
8.4939E
8.8109E
9.1879E
9.4538E
9.6765 E
9.8624E
1.0018E
1.0147E
1.0254E
1.0343E
1.0417E
1.0479E
1.0530E
1.0512E
1.0607E
1.0636E
1.0660E
1.0680E
1. Ub~6E
i.07l0E
1.072lE
1.0130E
1.0738E
1.0744E
1.0750E
1.0754E

02
02
02
02
02
02
02
02
02
02
02
03
03
03
03

03
03
03
03
03
03

03
03
03
03
03
03
03
03
03
03

Fig. 3.13 Output of program of Fig. 3.12.

The specification form of the INTGRL statement cannot be used for direct doubleintegration of arrays. For example, an acceleration array which is integrated into a velocity array cannot be directly integrated into a displacement array. The following example
illustrates the correct procedure for performing double-integration of arrays.
Example 3.4
Consider the system of Fig. 3.14 which shows five uncoupled spring-mass units. The
entire mass assembly is moving to the right with a common velocity of 50 ft/sec. The base
strikes and then sticks to an immovable rigid surface. The problem is to find the resulting
motion of all five masses after impact.

INTEGRA TlON

108

Ch.3

Advanced Features of CSMP

Base

~X(1)
Weight (1)

~X(2)
Weight (2)

'~X(3)
Weight (3)

~X(4)
Weight (4)
Immovable
rigid surface

~X(5)
Weight (5)

Initial velocity of all masses

= 50 ft/sec

Fig.3.14 Spring-mass system.

Using Newton's second law, the acceleration of the ith mass can be written as
.

-STIFF(i)*X(i)

A(l) = WEIGHT(i)j32.17

(3.8)

where STIFF(i) is the stiffness of the spring connected to the ith mass.
The program for calculating the system dynamics is shown in Fig. 3.15.
In the program, WEIGHT(i) and STIFF(i) are declared as subscripted variables by
a STORAGE statement. This allows a TABLE card to be used to specify the values for
WEIGHT(i) and STIFF(i).
Note that the entire Dynamic segment is changed to a no sort section. This assures
that all statements will be executed in the exact order in which they appear in the program.
The acceleration array A(J) is calculated and then integrated to obtain the velocity array
V(J). It is not permissible to directly integrate this velocity array to obtain the displacement array. An intermediate array must be set equal to the velocity array. This is accomplished by the program statements
DO 2 J = 1,5
2 VI(J) = V(J)

Ch.3

Advanced Features of CSMP

109

TITLE PROGRAM TO CALCULATE THE DYNAMICS OF A MECHANICAL SYSTEM USING
TITLE SUBSC~IPTED VARIABLES.
INITIAL
I
DIMENSION XIS), VIS), A(S), V1IS), YELIIS)
I
EOUIVALENCE I XE, XIU I, (VE, VB) ), (AE, A(l) )
I
1 , IV1E, V1(1) ), (YELlE, VELI(1) )
STORAGe WEIGHT(S), STIFF(S)
TABLE WEIGHT(1-2) = 2*13.6, WEIGHT(3) = 18.9, WEIGHT(4-S)
2*11.5, •••
STIFF(ll = 13S.0, STlFF(2-3) = 2*180.0, HIFF(4-5) = 2*320.0
FIXED J
NOSORT
DO 3 J = 1,5
3 VELI (J) = 50.0
DYNAMIC
NOSrtRT
DO 1 J = l, S
1 A(J) = -STIFF(J)*XIJI/CWEIGHTCJ)/32.17)
VE = INTGRLIVELIE,AE,S)

*
*
*
*

CSMP DOES NOT PERMIT DIRECT DOUBLE INTEGRATION OF ARRAYS WHEN USING THE
SPECIFICATION FORM OF THE INT&~l STATEMENT.
CONSEQUENTLY, THE FOLLOWING
TWOSTATE~ENTS ARE USED TO GENERATE THE ARRAY V1(JI WHICH CAN BE
INTEGRATED TO FIND XIJ).

DO 2 J = l, S
2 Vl(JI = VIJI
XE

=

INT~RL(O.O,VIE,S)

Xl=XllI

X2
X3

=
=

X(21
X(3)

X4 = X(41
X~
XIS)
HRM INAL

TIMER FINTIM
0.6, PRDEL
PRINT Xl. X2. X3. X4. XS

0.02

END

STOP
ENDJ::JB

Fig. 3.15 Program to simulate the dynamics of five masses.

The VI(J) array can now be integrated to obtain the displacement array. Since the
VI(i) array is used in the specification form of an INTGRL statement, it must be included
in the EQUIVALENCE statement. The output for this program is given in Fig. 3.16.
OVERLAY Statement

The FUNCTION statement which was defined in Example 2.4 is considered
a data statement. It is used for specifying pairs of x-y coordinates for the function
generating elements AFGEN and NLFGEN. When making more than one run,
the OVERLAY statement can be used to change previously specified x-y values
contained in FUNCTION statements. An example of an OVERLAY card is
OVERLAY TORQUE

=

0.0,4.5 , 3.0,7.8 , 6.0,11.9 , 10.0,19.0

In this example, the FUNCTION defined as TORQUE will take on the new
x-y values for the second run as given in the OVERLAY statement.

The format for an OVERLAY statement is the same as for a FUNCTION
card with the following exceptions.

110

Advanced Features of CSMP

Ch.3

PROGRAM TO CALCULATE THE DYNAMICS OF A MECHAN ICAL SYSTEM USING
SUBSCRIPTED VARIABLES.
TIME
0.0
2.0000E-02
4.0000E-02
6.0000E-02
8.000017-02
1. OOOOF.- 01
1.2000F-Ol
1.4000E-01
1. 6000F- 01
1.8000E-01
2.0000E-01
2.2000F.-01
2.4000E-Ol
2. 6000F.- 01
2 .8000E- 01
3.0000['-01
3.2000E-Ol
3.4000E-Ol
3. 6000E- 01
3 .8000E- 01
4.0000E-Ol
4.2000E-Ol
4.4000E-01
4.6000E-01
4. 8000E- 01
5 .OOOOF-O L
5.2000~-OL

').4000E-01
5 .6000E-0 1
'). 800CE - 01
6.0000E-01

Xl
0.0
9.7884E-01
1.8HOE 00
2.4573E 00
2.7701E 00
2.7329E 00
2.3502E 00
1.6705E 00
7.7975E-Ol
- 2 • 095 8E - 0 1
-1.1724E 00
-1.9871E 00
-2.5506E 00
-2.7918E 00
-2.6802E 00
-2.2299E 00
-1.4977E 00
-5. 7630E-0 1
4.1 796E-0 L
1.3~94E 00
2.1290E 00
2.6296E 00
2.7978E 00
2.o125E 00
2.0970E 00
1.3165E 00
3.6959E-Ol
-6.2400E-01
-1.5387E 00
-2.2590E 00
-2.6'B8E 00

X2
0.0
9.1l85E-01
1.7805E 00
2.2902E 00
2.4154E 00
2.1350E 00
1.4961E 00
6.0608E-Ol
-3.8576E-01
-1.3128E 00
-2.0194E 00
-2.3870E 00
-2.3538E 00
-1.9253E 00
- 1.1736E 00
-2.248 7E -01
7.6164E-Ol
1.6203E 00
2.2068E 00
2.4229E 00
2.2321E 00
1.6665E 00
8. 2117E - 0 L
-1.6207E-01
-1.liS1E 00
-i.8864E 00
-2.3380E 00
-2.3970E 00
- 2.0535E 00
-1.3653E 00
- 4. 4 717E - 0 1

X3
0.0
9.7970E-01
1.8405E 00
2.47U1E 00
2.8l51E 00
2.8106E: 00
2.4651E 00
1.820n 00
9.5533F-01
-2.5886E:-02
-1.0040E 00
-1.8602E 00
-2.4909E 00
-2.8194E 00
-2.8058E 00
-2.4520E 00
-1.8006E 00
-9.3091E-01
5.1754E-02
1.0281E 00
1.879bE 00
2.5034F. 00
2.8234E 00
2.8008E 00
2.4386F 00
1.7805f 00
9.0639~-01

-7.7623E-02
-1.0522E 00
-1.8992F. JO
-2.5158E 00

X4
0.0
9.413I:1E-Ol
1.5550E 00
1.6293 E 00
1.136I:1E 00
2.4938E-Ol
-7.2470E-01
-1.4469E 00
-1.6664E 00
-1.3069E 00
-4.9J20E-01
4.91fs1E-Ol
1.3059E 00
1.6663 E 00
1.4476E 00
7.2596E- 01
-2.4791E-01
-1.1356E 00
-1.62 SBE 00
-1.5559E 00
-9.4239E-01
-1.4542E-03
9.3996E-01
1.5548E 00
1.62'13E 00
1.l311E 00
2.5082E-01
-7.2322E-01
-1.4459E 00
-1.6663 EOO
-1.3075 E 00

RKS

INTEGRATION

X5
0.0
9.4138E-OI
1.5556E 00
1.6293 E 00
1. U68E 00
2.4938E-Ol
-7.2470E-01
-1.4469E 00
-1.6664E 00
-1.3069E 00
-4.9320E-Ol
4.9181 E-01
1.3059E 00
1.6663E 00
1.4476 E 00
7.2596E-Ol
-2.4791E-01
-1.1356E 00
-1.6288E 00
-1.5559E 00
-9.4239E-01
-1.4542E-03
9.3996 E-01
1.5548E 00
1.6293E 00
1.13 77E 00
2.508lE-01
-7.2322 E- 0 1
-1.4459E 00
-1.6663E 00
-1.3075E 00

Fig. 3.16 Output from program of Fig. 3.15.

1 The label OVERLAY is used in place of the label FUNCTION.
2 The number of x-y data pairs in an OVERLAY statement must not be

more than the number of x-y pairs in the original FUNCTION statement.
3 Parentheses must not be used in OVERLAY statements to separate pairs

of data.
A simple example which illustrates the use of an OVERLAY statement is the
problem of calculating the volumetric flow of blood pumped by the human heart
for two different pressure profiles.
Example 3.5

Figure 3.17 shows two time-histories of ventricular pressure in the human heart.
Profile No. 1 represents a strong heart beat while profile No. 2 corresponds to a more
average heart. An expression which approximates the flow rate of blood pumped by the
heart is
FLOW

P

=

575.0

(3.9)

Ch.3

Advanced Features of CSMP

111

200

1"'---""\

,
,

160

'v Pressure profile no. 1
\

I

\

I

Pressure profile no. 2

I

I

I

,
I
I

IJ

40

o

0.2

0.6

0.4

0.8

Time in seconds

Fig.3.17 Time-history of pressure in pumping chamber of the
human heart.
where FLOW = volumetric flow rate in I/sec
P

=

ventricular pressure in mm-Hg

A single integration of FLOW with respect to time yields the total amount of blood that
has flowed from the heart during one beat.
VOLUME =

S: FLOW dt

(3.10)

Figure 3.18 shows the program for solving for the total flow for both pressure profiles.
Data representing the first time-history of pressure is entered on the FUNCTION card
with the label PRESS. The OVERLAY statement contains the data for the second pressure profile used for the function PRESS in the second run. Figure 3.19 contains the
PRTPLT output resulting from the first pressure profile and Fig. 3.20 shows the output
for the second time-history of pressure. Notice in the program of Fig. 3.18 that the
OVERLAY statement appears immediately after the first END card. The END card
permits the simulation to accept new data and control statements for another run. Note
also that the END card sets the independent variable (TIME) to zero and resets all
initial conditions. A detailed discussion on the use of the END statement is contained in
the following section on translation control statements.

112

Ch. 3

Advanced Features of CSMP

LABEL BLOOO FLOW PROBLEM TO ILLUSTRATE THE USE OF AN OVERLAY STATEMENT.
FUNCTION PRESS
(0.0,8.0),(0.05,12.0',(0.1,21.0),(0.15,80.0),
(0.2,140.01,(0.25,174.0),(0.28,178.0),(0.3,117.0),(0.32,176.0),

=

(0.35,115.0),(0.4,165.0),(0.45,138.0),(0.5,86.0),(0.55~19.0),

(0.6,3.0),(0.62,3.5),(0.64,4.0),(0.61,5.0),(0.7,6.0),(0.8,8.0)
P
NLFGENCPRESS,TtME)
FLOW =- P/515.0
VOLUME = tNTGRL(O.O,FLOW)
PRTPLT VOLUME CP,FLOW)
TIMER FINTIM
0.8, OUTOEL =- 0.04

=

=

•
•
•

THE FOLLOWING ENO CARO RESETS THE INITIAL CONOITIONS, RESETS TIME TO ZERO,
PREVIOUSLY OEflNEO FUNCTION TO THE VALUES SHOWN.
ANOTHER RUN.
THE OVERLAY STATEfoilENT CHANGES THE OATA CONTAINEO IN THE
ENO
OVERLAY PRESS = 0.0,5.0, 0.05,8.0, 0.1,18.0, 0.15,63.0, 0.2,100.0, •••
0.25,120.0, 0.3,124.0, 0.35,124.0, 0.4,120.0, 0.5,65.0, 0.54,6.0, •••
0.56,4.0, 0.58,2.0, 0.59,2.0. 0.61,2.2, 0.65,2.5, 0.7,3.0, 0.8,5.0
ENO
STOP
ENOJ08

Fig. 3.18 Program to calculate blood flow and to illustrate the use
of an OVERLAY statement.

8LOOD flOW PR08LEM TO ILLUSTRATE THE USE OF AN nVERLAY STATEMENT.
VOLUME VERSUS TJ ME

MINIMUM

0.0
4-.0000E-02
8.0000E-02
l.2000E-Ol
l.6000E-01
2.0000E-Ol
2.4-000E-Ol
2.8000E-Ol
3.2000E-Ol
3.6000E-Ol
4-.0000E-Ol
4-.4-000E-Ol
4-.8000E-Ol
5.2000E-Ol
5.6000E-Ol
6.00ODE-Ol
6.4-000E-Ol
6.8000E-Ol
7.2000E-Ol
7.6000E-Ol
8.0000E-Ol

MAXIMUM

1.05l4E-01

0.0
TIME

PAGE

I

VOLUME

0.0
6.6l82E-04
1.61161E-03
3.2800E-03
1.8047E-03
1.5868E-02
2.6722E-02
3. 8947E-02
5.126BE-02
6.3458E-02
7.5282E-02
8.6l20E-02
9.5085E-02
1.0107E-01
1.0342E-01
l.03l4E-Ol
1.039BE-01
l.0430E-01
1.041lE-01
1.0520E-Ol
1.0514E-Ol

+
+
+

-+

---+
-------+

------------+
-----------------------+
-----------------------------+
----------------------------------+
----------------------------------------+
-----------------------------------------+
-----------------------------------------------+
-----------------------------------------------+
-------------------------------------------------+
-----------------------------------------------+
------------------------------------------------+
-----------------------------------------------+
------------------------------------------------+
-------------------------------------------------+
------------------ +

P
B.OOOOE
1.1200E
1.68001"
3.86001"
9.19201'
1.4000E
1.6928E
i.1800E
1.7600E
1.1383~

1.6500E
1.4476E
1.0980E
6.1000E
1.1120E
3.0000E
4.0000E
5.3333E
6.5641E
7.4461E
8.0000E

FLOW

00
01
01
01
01
02
02
02
02
02
02
02
02
01
01
00
00
00
00
00
00

1.3913E-02
1.9478E-02
2.9211E-02
6.l130E-02
1.5986E-Ol
2.4348F-Ol
2.9440E-Ol
3.0951E-01
3.0609E-Ol
3.0232E-Ol
2.86961"-01
2.5176E-Ol
1.909'6E-Ol
1.0609E-01
2.0383E-02
5.2lnE-03
6.9565E-03
9. 2754E-03
1.1416E-02
1.2950E-02
1.3913E-02

Fig. 3.19 Blood flow for pressure-pulse.

Translation Control Statements

Translation control statements specify how structure statements are to be
treated. They also are used for run control purposes. For example, the INITIAL,
DYNAMIC, and TERMINAL statements, which were defined in Chap. 2, are
translation control statements. They specify how groups of structure statements
are to be handled. The END and CONTINUE statements, which have previously

Ch. 3

Advanced Features of CSMP

BLOOD FLOW PROBLEM TO ILLUSTRATE THF USE OF A.. OVERLAV STATEME~T.

PAGE

VOLUME VERSUS TIME
TIME

0.0
4.DOOOE-02
8.0000E-02
1.2000E-01
1.f»000E-01
2.0000E-Ol
2.ltOOOE-01
2.8000E-01
3.2000E-01
3.f»000E-01
4. DOODE-01
4.4000E-Ol
1t.8000E-Ot
5.2000E-Ol
5.~DOOE-Ol

6.0000E-01
6.ItOOOE-01
6.8000E-Ol
7.2000E-Ol
7.6000E-Dl
8.0000E-Ol

0.0
·1t.3130E-0'o
1.tOlt2E-03
2.4927E-03
6.0B95E-03
1.2068E-02
1.9692E-02
2.8155E-02
3.6804E-02
It.5ltlt5E-02
5.3930E-02
6.1833E-02
6.8379E-02
7.2734E-02
7.3638E-02
7.3812E-02
7.3971E-02
7.ltt51E-02
7.4361E-02
7.4615E-02
1.'o928E-02

MAXIMUM

7.49281"-02
I

VOLUME

+
+

113

-+

----+
--------+
-------------+
------------------+
------------------------+
------------------------ ------+
-----------------------------------+
-----------------------------------------+
---------------------------------------------+
------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
----------------------------------------.---------+

P

5.00001"
7.'o000E
1.3160E
3.1800E
7.1040~

1.0000E
1.17361;
1.2432E
1.24480:
1.2352E
1.20001;
1.0552E
8.10131:'
3.814'3~

4.0000E
2.0661E
2.43151'
2.7833E
3.29331"
4.04001'
5.0000F

FLOW

00
00
01
01
01
02
02
02
07
02
02
02
01
01
00
00
00
00
00
00
00

8.6951E-03
1.28701"-02
2.28811'-02
5. 5301tE-02
1.23551'-01
1.7391E-Ol
2.041010-01
2.1621E-Ol
2.16'091'-01
2.14B2F.-Ol
2.08701'-01
1.8'351E-Ol
1.40B9E-Ol
6.6336'0-02
6.9564E-03
3.59421'-03
4.239H:-03
4.8406E-03
5.7215"'-03
1.02611'-03
8.69561'-03

Fig. 3.20 Blood flow for pressure-pulse.

been used and briefly described, can be used for run-control purposes and consequently are also translation control statements.
This section is concerned with the following six statements and how they can
be used for changing data and output statements for sequential runs, resetting
integration methods and error requirements, and other special features pertaining
to run control techniques.
END
RESET
CONTINUE
STOP
ENDJOB
ENDJOB STACK

END
The END card must appear at least once in every program. For programs
where control and data statements are not changed and only one run is desired,
the END card simply appears immediately after the last structural statement.
All examples in Chap. 2, with the exception of Example 2.10, illustrated this use
of the END statement.
The END card can be used to permit the simulation to accept new data and
control statements for sequential runs as illustrated in this chapter in the program
of Fig. 3.18. When the END card is not followed immediately by a STOP card,
another run is automatically initiated incorporating the changes that follow the
END card. At the start of the new run, the initial conditions are automatically
reset and the independent variable (TIME) is set to zero. The following simple
example program illustrates how this is accomplished.

114

Ch.3

Advanced Features of CSMP

INCON YO

Y

=

=

2.0

INTGRL(YO, V)

END
INCON YO
END
STOP
ENDJOB

=

7.5

In the above example, the initial value for Y in the first run is 2.0. For the
second run the initial value of Y is 7.5.
Example 3.6
Several important points can be illustrated by incorporating an extra END card in
the program in Fig. 3.3. Figure 3.21 shows this program where an END card has been
added to provide one additional run. The first run of the program is identical to the original program in Fig. 3.3. In the second run, the integration method, output, and timer
variables are changed as specified by the cards following the first END statement.
Note that SUM and COUNT are set equal to zero for the second run. This is necessary even though these variables were originally set equal to zero in the Initial segment.
If they are not reset to zero, the final values of SUM and COUNT in the first run will be
used as the starting values in the second run.
For the variables that appear on the TIMER card, it is only necessary to specify
changes. In this problem, DELT is the only timer variable that changes for the second
run.
The two pages of output from the program in Fig. 3.21 is shown in Fig. 3.22.
All changes that were made for the second run, in the previous example, nullified the
corresponding instruction specified in the first run. Not all statements, however, will
cancel previous instructions. The following is a list of the statements that when used for an
additional run will completely nullify the corresponding instructions of previous runs.
FINISH
METHOD
PREPARE
PRINT
TITLE
The following is a list of five additive instructions. These statements do not nullify previous
ones, but simply provide additional instructions.
ABSERR & RELERR
LABEL
PRTPLT
RANGE

Ch. 3

Advanced Features of CSMP

115

TITLE PROGRAM TO CALCULATE THE AV~R~GE ABSOLUTE ERROR OF EQUATION 3.1
INIT I AL
CONSTANT PI = 3.14159, SUM
0.0, COUNT = 0.0
DYNAMIC
•
•
*

THE FuLLOWING 3 CARDS ARE USED TO SOLVE EQUATION 3.1, WHEREYOO = SECOND DERIVATIVE OF Y WITH RESPECT TO TIME
YO = Fl~ST DERIVATIVE OF Y WITH RESPECT TO TIME

YUD = -4.0*PI*PI*Y
YO = INTGRLlO.O, YDO)
Y = INTGRL(1.0, YO)
TiE FOLLOWING NOSORT SECTION IS REQUIRED TO USE THE "IF" STATEMENT

•

NOSORT
•

KEEP IS EQUAL TO 1 WHEN THE END OF A VALID INTEGRATION STEP IS REACHED

IFlKEEP. EQ .1) GO TO 1
GO TJ 2
1 SUM = SUM + ABS(Y - COS(2.0*PI*TI~E))
COUNT = COUNT + 1.0
AA~R = SUM/COUNT
2 CONTINUE
TERMINAL
TIME~
FINTIM = 1.0, PRDEL
0.1, QELT
METHOD SIMP
~RINT
Y, SUM, COUNT, AAER
*
*

*
END

0.001

THE FuLLUWING "END" CARD RESETS THE INITIAL CONDITIONS A~D SETS THE
I~DEPENDENT VARIABLE (TIME' TO ZERO AND INITIATES ANOTHER RUN USI~G THE
CHANGE~ THAT FOLLOW 7HE END CARD.
PRINT 'i, YO, YDD, SUM, COUNT, AAER
TIMER DELT = 0.004
CONSTANT SUM = 0.0, COUNT = 0.0
ME THOD TRAPl

END
STJP
ENDJOB

Fig. 3.21 Program to illustrate the use of END statement.

PROGRAM TO CALCULATE THE AVERAGE ABSOLUTE ERROR OF EQUATION 3.1
TIME

0.0
1. OOOOE- 01
2 .OOOOF- 01
3.0000E-Ol
4.0000E-Ol
5.0000E-Ol
6.0000E-Ol
7.0000E-Ol
8.0000E-Ol
9.0000F-Ol
1.OOOOE 00

y

1.0000E 00
8. 0902E-0 1
3.0902E-Ol
-3.0901E-Ol
- 8. 0900 E- 01
-9.9997E-Ol
-8.0899E-Ol
-3.0900E-OL
3.0900E-0 L
8. 0891.E-0 1
9.9994E-Ol

SUM
0.0
1.38l6E-04
4.0048E-04
5.8232E-04
1.7282E-03
4.180LE-03
7.4814E-03
l.0343E-02
1.1399E-02
1.3523E-02
l.8603E-02

COUNT
1.00OOE
1.OLOOE
2.0100E
3.0l00E
4.0100E
5.0l00E
6.0100E
7.0l00E
8.0l00E
9.0l00E
l.OOlOE

00
02
02
02
02
02
02
02
02
02
OJ

AAER
0.0
L.3bBOE-06
1.9925E-06
1.9346E-06
4.3098E-06
8.3434E-06
1.2448E-05
1.4755E-05
1.42J1E-05
1.5009E-05
1.8585E-05

Fig. 3.22 Output of program of Fig. 3.21.

SIMP

INTEGRA TlON

116

Ch.3

Advanced Features of CSMP

PROGRAM TO CALCULATE THE AVERAGE ABSOLUTE ERROR OF EQUATION 3.1
TIME
0.0
1. OOOOE - 01
2.0000F.-Ol
3.0000E-Ol
4.0000E-Ol
5.00aOE-01
6.0000E-Ol
7.0000E-Ol
8.0000E-Ol
9.0000E-Ol
l.OOOOE 00

Y

YOO

YO

1.0000E 00
8.0898E-Ol
3.0889E-Ol
-3.0920E-Ol
-8.09l7E-01
-1.0000E 00
-8.0879E-Ol
-3.0859E-Ol
3.0951E-Ol
8.0936E-Ol
l.OOOOE 00

0.0
-3.6935E 00
-5.9159E 00
-5.9753E 00
-J.6918E 00
2.0339F-03
3.6951E 00
5.9765E 00
5.9746E 00
3.6902E 00
~4.0638E-OJ

-3.9478E
-3.1937E
-1.Z195E
1.2207E
3.1945E
3.9478E
J.19JOE
1.2182E
-1.2219F
-3.1952f
-3.9478E

01
01
01
01
01
01
01
01
01
01
01

SUM
0.0
3.4213E-04
2.3815E-03
6.4546E-03
1.0940E-02
1.2990E-02
1.5985E-02
2.4672 E-02
3.6836E-02
4.1795E-02
5.2229E-02

COUNT
1.0000E
2.6000E
5.1000E
7.6000E
1.0l00e
1.2600E
1.5100E
1.7600E
2.01 DOE
2.2600E
2.5100E

TRAPl
00
01
01
01
02
02
02
02
02
02
02

INTEGRATION

AAER
0.0
I.J159E-05
4.6813E-OS
8.4929E-05
1.0832E-04
1.0309E-04
1.0586E-Q4
1.40l8E-04
1.8326E-Q4
2.1148E-04
2.0808E-Q4

Fig. 3.22 (Continued)

As an example, consider a program having the following structure.

Main body of program

TIMER FINTIM = 4.0, OUTDEL = 0.1, PRDEL = 0.2
PRINT A, B, C
PRTPLTX
PRTPLT Y
RANGE X
ABSERR X = 0.001, Y = 0.003
LABEL OUTPUT OF "X" INTEGRATOR
LABEL OUTPUT OF "Y" INTEGRATOR
END

Control statements
for first run

Control statements
for second run

l

~Jl~,z

ABSERR Z = 0.0004, Y = 0.005
LABEL OUTPUT OF "Z" INTEGRATOR
END
STOP
ENDJOB

For the first run of the above example program, the following occurs:
1 A, B, and C are printed at the interval specified on the timer card.
2 A printer-plot of the variable X will be made with the heading: OUTPUT OF "X"
INTEGRATOR.
3 A printer-plot of the variable Y will be made with the heading: OUTPUT OF "Y"
INTEGRATOR.
.
4 The maximum and minimum values of X are listed by the RANGE statement.

Ch. 3

Advanced Features of CSMP

111

5 Absolute errors of 0.001 and 0.003 will be used for the X and Y integrators,
respectively.
For the second run, the following occurs:
1 The variable C is printed at the interval specified on the only timer card.
2 As in the first run, printer-plots will be made for X and Y with the same headings.
3 An additional printer-plot of the variable Z will be made with the heading: OUTPUT OF "Z" INTEGRATOR.
4 The maximum and minimum values of X, Y, and Z are listed by the RANGE

statements.
5 Absolute errors of 0.001,0.005, and 0.0004 will be used for the X, Y, and Z integrators, respectively.
In this example PRTPLT, LABEL, RANGE, and ABSERR are the additive
statements.
It may be necessary in some simulations to eliminate certain control statements in going from one run to another. For this purpose the RESET card should
be used.
RESET

This statement allows the user to nullify certain control instructions used in
previous runs.
The RESET card can be used for the following statements.
ABSERR & RELERR
FINISH
LABEL
PREPARE
PRINT
PRTPLT
RANGE
The RESET card should be placed immediately after the END or CONTINUE
card to insure its proper use. RESET PRTPLT will nullify all previous PRTPLT
and LABEL instructions. RESET LABEL nullifies only LABEL statements. A
card containing only RESET on it will nullify all previous LABEL, PRTPLT,
PREPARE, PRINT, and RANGE instructions.
A TITLE statement cannot be nullified by using a RESET card. The use of a
TITLE instruction after an END or CONTINUE card will nullify the previous
TITLE card.
The following example illustrates the use of the END and RESET statements
along with the multiple run capability of a PARAMETER card. This example
also shows the use of a CSMP random number generator.

118

Ch.3

Advanced Features of CSMP

Example 3.7
Random number signal sources can be very useful in simulating problems associated
with many fields, including Industrial Engineering. An example of a typical problem
involves determining the random distribution of the stiffness of a coil spring that is manufactured in high volume. The wire diameter and inside diameter of the spring are random
variables that can best be described by a Gaussian distribution having a mean and standard deviation. The stiffness of a coil spring which is shown in Fig. 3.23 depends on the
wire size and inside diameter of the coil as expressed by
K

---,..--. ={=

r-

DI

=

G*DW 4
8(DI + DW)3N

DW = Wire diameter

-1

DI = inside diameter of spring

where

(3.11)

Fig. 3.23 Coil spring.

G

= modulus of elasticity for steel in shear = 11,500,000 psi

N

=

DW
DI

number of active coils

=

10

= diameter of wire
=

inside diameter of spring coil

In addition, the following program parameter definitions are used.
MEANI
SIGMAI

= mean inside diameter of spring
=

=

1.000 in.

standard deviation of inside diameter of spring: 0.001, 0.002,
and 0.005 in.

MEANW

= mean wire diameter = 0.100 in.

SIGMAW

=

standard deviation of wire diameter: 0.00033, 0.0006, 0.0015 in.

Since there are three different standard deviations for both the wire size and inside
spring diameter, a total of nine runs will be required to simulate all combinations.
CSMP has signal sources which provide random numbers from two distributions.
These are the Gaussian and the uniform distributions. For the Gaussian distribution, the
statement
x = GAUSS(N, M, S)

Ch. 3

119

Advanced Features of CSMP

gives a signal having a normal distribution
where N

=

any odd integer (used as a seed value); in CSMP III use any integer

M

=

mean value

S = standard deviation
Only at each valid integration step (when KEEP = 1) does the GAUSS signal source
provide a number. It is not activated during trial or immediate integration steps.
A uniform random number distribution between 0 and 1 can be provided by the
following RNDGEN function.

x

=

RNDGEN(N)

where N is any odd integer which is also used as a seed value. When using two or more
random-number signal sources, each statement should use a different seed value.
Using the GAUSS signal source, the following CSMP statements can be used to
describe the random numbers representing the wire and inside spring diameters.
DW = GAUSS(1, MEANW, SIGMAW)
DI = GAUSS(3, MEANI, SIGMAI)
The standard deviation of the stiffness can be expressed by the following formula.
(3.12)
where K j

=

stiffness of ith spring

n = number of springs in sample

Using the above expressions for the random variables DW and DI, and Eq. (3.12) for
the standard deviation of the spring stiffness, a program for simulating production runs
for all nine combinations of standard deviations of wire and inside diameters is shown in
Fig. 3.24. Note the method used in this program to reset COUNT, SUMK, and SUMK2
to zero. This procedure should be used when using the mUltiple-run capability of a
PARAMETER card. The output for the very last run (SIGNAW = 0.0015, SIGMAI
= 0.005), which involves a simulation of 3000, springs, is given in Fig. 3.25.

CONTINUE
The CONTINUE card can be used to change data or control statements
without resetting initial conditions or the independent variable (TIME). It is used
in place of the END card. When the program encounters a CONTINUE statement, it will accept the changes in control and data statements that follow this
card. The program will then continue from the point where the previous run was
ended. The CONTINUE statement provides, in effect, an interrupt point where
changes in control and data statements can be made. The program in Fig. 3.5
illustrates the use of the CONTINUE card to change integration methods, integration error requirements, and timer variables during the run.
In CSMP III, the END CONTINUE label is used in place of CONTINUE.
When using the CONTINUE card, the following rules must be followed.

120

Advanced Features of CSMP

Ch.3

TITLE PROGRAM TO SIMULATE THE VARIANCE IN THE STIFFNESS IN THE HIGH
TITLE VOLUME PRODUCTION OF A COIL SPRING.
RENAME TIME a NUMBER
PARAMETER SIGMAW = (0.00033, 0.0006, 0.0015)
CONSTANT COUNT = 0.0, SUMK • 0.0. SUMKl • 0.0. MEANW • 0.1,
MEANI = 1.0, SIGMAI = 0.001, N = 10.0, G : 11.5E6
OW = GAUSS(l, MEANW, SIGMAW)
01 = GAUSS(l, MEANI, SIGMAI)
K = G*(DW*.4)/(S.0*((DW + DI)*.3'.N)
NOSORT
•
*

THE FOLLOWING 5 CARDS ARE USED TO RESET COUNT, SUMK, AND SUMK2 TO ZERO
AT THE BEGINNING OF EACH RUN.

IF(NUMBER.NE.O.O) GO TO 2
COUNT = 0.0
SUMK • 0.0
SUMK2 = 0.0
2 CONTINUE
IF(KEEP.NE.1' GO TO 1
COUNT • COUNT + 1.0
SUMK = SUMK + K
SUMK2 = SUMK2 + K*K
*
*

THE FOLLOWING "IF" STATEMENT IS USED TO AVOID DIVIDING BY ZERO
IN THE CALCULATION OF THE STANDARD DEVIATION (SIGMAK)

IF(COUNT.LT. (PRDEL - 2.0) ) GO TO 1
SIGMAK = SQRT((COUNT*SUMK2 - SUMK*SUMK)/(COUNT*(COUNT - 1.0)))
MEANK = SUMK/COUNT
1 CONTINUE
PRINT SIGMAK, MEANK
RANGE K, OW, 01, SIGMAK, MEANK
TIMER FINTIM = 5000.0, DELT = 1.0, PRDEL = 100.0
METHOD RECT
END
RESET RANGE
RANGE K, OW, 01
CONSTANT SIGMAI = 0.002
TIMER FINTIM = 3000.0, PRDEL = 200.0
PRINT SIGMAK, MEANK, K, OW, 01
END
CONSTANT SIGMAI = 0.005
END
STOP
ENDJOB

Fig. 3.24 Program to simulate the production of a coil spring.

1 The multiple run capability of the PARAMETER, CONSTANT, or
INCON statements must not be used in a run where a CONTINUE card
is used.
2 A program containing a TERMINAL segment should not be used with a
CONTINUE statement.
3 A new value for FINTIM should be specified on a timer card for every use
of a CONTINUE card. If a CONTINUE statement is initiated by a FINISH
card, the output (PRDEL and OUTDEL) will be incremented from the
time at which the FINISH condition was encountered.
4 The FORTRAN CONTINUE statement is distinguished from the CSMP
CONTINUE card by a statement number. Figure 3.24 illustrates the use

PROGRAM TO SIMULATE THE VARIANCE IN THE STIFFNESS IN THE HIGH
VOLUME PRODUCTION OF A COIL SPRING.
NUMBER
0.0
2.0000E
4.0000E
6.0000E
a.OOOOE
1.0000E
1.Z0DOE
1.4000E
l.6000E
1.8000E
2.0000E
2.200m:
2.4000E
2.bOOOE
2.8DDDE
3.0000E

02
02
02
02
03
03
03
03
03
03
03
03
03
03
03

SIGMAK
3.0245E-Ol
b.1l6SE-Ol
6.4029E-Ol
6.4b03E-0 1
6. 3315E-0 1
6.3632E-0 1
b.2593E-0 1
6.2863E-Ol
6.3020E:-Ol
6.2993E-0 1
6.2875E-Ol
6.2451E-Ol
6.2795E-0 1
6.2814E-Ol
6.2734E-Ol
6.2547E-Ol

MEANK
1.0196E
1.0836E
1.0804E
1.0787E
1.0a04E
1.0797E
1.0797E
1.0797E
1.0H8E
1.oa04E
1.0804E
1.08llE
1.0al0E
1.080SE
1.OB05E
1.0804E

OW

K

01
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01

9.3799E
1.0007E
1.1095E
1.2347E
1.l378E
1.1053E
1.0664E
1.1533E
1.0704E
1.0S89E
1.1122E
1.0604E
1.0789E
1.0583E
1.0528E
1.0589E

00
01
01
01
01
01
01
01
01
01
01
01
01
01
01
01

9.5150E-02
9.7a35E-02
1.0075E-Ol
1.0324E-01
1.0165E-01
1.0133E-Ol
1.0010E-Ol
1.0183E-01
9.9853E-02
9.9512E-02
1.0015E-Ol
9.9617E-02
1.0025E-Ol
9.9897E-02
9.9399E-02
9.9600E-02

INTGRL NOT USED

01
9.8383E-Ol
9.9a05E-01
1.0003E 00
9.9448E-Ol
1.0033E 00
1.0095E 00
1.0061E 00
1.000lE 00
1.0013 E 00
l.0006E 00
9.9135E-Ol
1.0015E 00
1.0038E 00
1.OOblE 00
1.00llE 00
1.001SE 00

Range Output
PROBLEM DURATION 0.0
VARI ABLE
K

OW
OI

MINIMUM
8.6505E 00
9.4510E-02
9. 7930E-0 1

NUMBER
3.8300E 02
3.!nOOE 02
2.0200E 02

TO

3.0000E 03

MAXIMUM
1.2991E 01
1.0530E-Ol
1.0220E 00

Print Output
Fig. 3.25

"'"

~

"'"

Output of Fig. 3.24 for last run.

NUMBER
2.4l00E 03
1.6S00E 02
5.65COE 02

SIG~AW=

1.5000E-03

122

Ch.3

Advanced Features of CSMP

of the FORTRAN CONTINUE card. It can only be used in a nosort section or within a PROCEDURE function with a statement number.
An example of a complicated program which makes use of several END,
RESET, and CSMP CONTINUE statements follows.

Main body of program

CONSTANT Q = -13.5; R = 9.0, S = 11.0
LABEL PRINTER-PLOT OF "X"
PRTPLT X
TIMER FINTIM = 1.0, OUTDEL = 0.02
CONTINUE
RESET PRTPLT
2nd portion
TIMER FINTIM = 1.1, DELT = 0.0005, PRDEL = 0.001
of 1st run
METHOD ADAMS
CONSTANT Q = -17.0, R = 8.0
PRINT X, Y
CONTINUE
TIMER FINTIM· = 2.4, PRDEL = 0.02
3rd portion
METHOD RKS
of 1st run
PRTPLT Y
LABEL Y = DISTANCE
CONTINUE
4th portion {RELERR Z = 0.00002
of 1st run
TIMER FINTIM = 3.8
FINISH Y = 100.0
END
2nd, 3rd, &
RESET
4th runs
PARAMETER S = (12.0, 12.3, 12.7)
PRTPLT X,Y
TIMER FINTIM = 2.0
FINISH Y = 126.0
END
STOP
ENDJOB
1st portion
of 1st run

!
1

!

The above example program makes two complete runs. In the first run, the
CONTINUE card is used three times to make changes in parameters, output, and
integration method. The following is a summary of the first run.
1 The first portion of the first run, which ends at FINTIM
following parameters and timer variables.

=

1.0, uses the

Ch. 3

Advanced Features of CSMP

123

Q = -13.5
R =9.0
S = 11.0
OUTDEL = 0.02

A printer-plot of the variable X is made with the following heading: PRINTER-PLOT OF "X". Since the integration method is not specified, the
variable-step Runge-Kutta method is used.
2 The second portion of the first run terminates at FINTIM = 1.1. The
following parameters and timer variables are changed to the values shown.
Q = -17.0
R = 8.0
DELT = 0.0005
PRDEL = 0.001

Adams integration is used. The RESET PRTPLT card nullifies the previous PRTPLT and LABEL statements and the only output is given by the
PRINT X, Y statement.
3 The third portion of the first run ends at FINTIM = 2.4. There are no
changes in parameter values and the integration method is changed back
to variable-step Runge-Kutta (RKS). The output includes the previous
PRINT X,Y statement and the additional PRTPLT Y card with the following heading: Y = DISTANCE.
4 For the fourth and last portion of the first run, the run will terminate at a
time of 3.8, or when the variable Y first reaches the value of 100.0. The
relative error for the Z integrator is changed from the usual value of 0.0001
to 0.00002. All PRINT and PRTPLT outputs remain the same as in the
third portion.
The first END card indicates the completion of the first run. All initial conditions
are reset to the original values and the independent variable (TIME) is set to zero.
The multiple run capability of a PARAMETER card is used to make three additional runs using the specified values of the parameter S. Note that because of the
use of the multiple run PARAMETER card, a CONTINUE statement cannot be
used in this portion of the program. The RESET card nullifies the previous
PRTPLT, RELERR, LABEL, PRINT, and FINISH statements. Consequently,
the only output will be printer-plots of the variables X and Y. The output interval
will be the value of OUTDEL as specified in the first portion of the first run. The
STOP and ENDJOB cards have been used without explanation in all programs.
Their use is described as follows.
STOP

The STOP card must follow the last END card to signify the completion of
the last run. It is also used to separate any user-supplied FORTRAN subprogram
from the CSMP program. All subprograms must follow the STOP card.

124

AdvancedFeatures of CSMP

Ch. 3

ENDJOB

This card is used to signify the end of a job. In"all previous programs, which
have not included FORTRAN subroutines, the ENDJOB statement follows the
STOP card. When FORTRAN subroutines are used, the ENDJOB must follow
them. This is illustrated in the section in this chapter on subprograms. ENDJOB
is one of five statements that must begin in card column 1. The other statements
are: COMMON, COMMON MEN, ENDDATA, and ENDJOB STACK.
ENDJOB STACK

This statement, when used in place of the ENDJOB card, allows another
CSMP job to directly follow. However, most computer installations prohibit the
practice of "stacking runs". It is recommended that the user check with the computer installation before using the ENDJOB STACK statement. The ENDJOB
label must begin in card column 1 and STACK must begin in column 9. A blank
card should follow the ENDJOB STACK card.

Data Output
The majority of CSMP output is ordinarily handled by the five output statements: PRINT, PRTPLT, RANGE, TITLE, and LABEL. The user, however,
has a wide range of other methods for printing data. These include the use of
FORTRAN output statements, a DEBUG subroutine that provides output of all
variables, a PREPARE statement that is used to allow plotting of variables on
offline X-Y plotters, and a DECK statement that returns a punched deck of the
program. CSMP III provides additional output capabilities that are covered in
Chap. 5. This section describes the use of the four types of output that are available in both S/360 CSMP and CSMP III.
FORTRAN Output

The entire output capability of FORTRAN, with the exception of the PUNCH
instruction, is available to the CSMP user. This includes the use of FORTRAN
WRITE, PRINT, and FORMAT statements. Methods of using these output
instructions are similar to those in FORTRAN. The primary restriction is that all
FORTRAN output statements must be contained in no sort sections or in PROCEDURE functions. A summary of general rules follows later in this section.
The reader should refer to specialized texts on FORTRAN, because of the generality and complexity of FORTRAN output statements.<2-S)
It is not obvious when it is desirable or necessary to use FORTRAN output
capabilities. Some typical situations are listed as follows.
1 It may be necessary to print values from either the Initial or Terminal
segments. These values would be printed only one time at the beginning or

Ch. 3

Advanced Features of CSMP

125

end of the run. CSMP PRINT or PRTPLT statements cannot be used for
this purpose. Consequently, the only choice is to use FORTRAN output
statements.
2 Subscripted variables and integers cannot be used in PRINT and PRTPLT
statements in S/360 CSMP. FORTRAN output statements can be used for
these types of variables.
3 A maximum of fifty variables (including TIME) can be included in a S/360
CSMP PRINT statement. Essentially any number of variables can be
incorporated in FORTRAN output statements.
4 The user has no control over output format when using PRINT and
PRTPLT statements. Conversely, the format flexibility of FORTRAN
offers considerable freedom in the style of output data.
5 CSMP PRINT and PRTPLT statements are executed at regular intervals
as specified on the TIMER card. With the proper use of FORTRAN logical
control and output statements, it is possible to have output at any point
and at any interval during the run.
6 Since integration must be performed at each PRINT and PRTPLT interval,
CSMP output statements usually affect the integration interval of variablestep methods. FORTRAN output instructions do not affect the integration
step-size and as a result FORTRAN WRITE statements can be used to
monitor each step in variable-step integration.
Statements in the Initial and Terminal segments are executed only once during
a run. Consequently, FORTRAN output instructions can be utilized in these two
segments with no special consideration other than being used in no sort sections or
PROCEDURE functions. However, when FORTRAN output statements are used
in the Dynamic segment, special care must be used. For example, depending upon
the integration method, FORTRAN output instructions are executed up to four
times for each integration step (see Table 3.3) and for each trial integration step if
a variable step method is used. To provide FORTRAN output only at the end of
valid integration steps, the following type of statement is recommended.
IF(KEEP. EQ. 1) WRITE(6,lOO) X,Y,Z

The above will print the values of X,Y, and Z using FORMAT number 100 at
each valid integration step.
The following is a summary of some general rules for using FORTRAN
output statements.
1 All FORTRAN output and FORMAT statements must be in no sort sections or PROCEDURE functions.
2 Continuation cards used with FORTRAN output and FORMAT statements must contain a $ in card column 6.

126

Ch. 3

Advanced Features of CSMP

3 FORTRAN output instructions in the Initial and Terminal segments are
executed only one time. Statements in the Dynamic segment are printed up
to four times for each integration step. It is recommended that the following
use of the IF statement be employed to provide output only at the end of
valid integration steps.
IF(KEEP. EQ. 1) WRITE(6,100) X, Y, Z

4 The FORTRAN PRINT statement can be used in a CSMP program as
part of a logical IF statement. For example, the following FORTRAN
PRINT statement is valid.
IF(TIME. GT. 1.9) PRINT 100, X, Y, Z
The following PRINT instruction cannot be used.
PRINT 100, X, Y, Z

It should be pointed out that the FORTRAN PRINT statement offers no
advantages over the FORTRAN WRITE instruction. For this reason, it
is recommended that the FORTRAN PRINT statement not be used.
5 FORTRAN FORMAT instructions can be located in any nosort section
or procedure function of the program. The most logical location is in a
nosort section of the Initial segment.

6 The FORTRAN PUNCH instruction cannot be used in a CSMP program.
If punched output on data cards is desired, the user should employ a FORTRAN WRITE statement. In a FORTRAN program, the following statement provides punch output.
WRITE(7,100) X, Y, Z
The above statement is not valid in a CSMP program. Unit number 7 is a
work data set used by the CSMP system. The user should specify in JCL
cards that another unit number be set in reserve for punched output. This
unit number is then used in the WRITE instruction to provide punched
output.
The following orbital mechanics problem is used to illustrate the use of
FORTRAN output statements in all three segments.
Example 3.8
This problem involves the two-dimensional motion of a space vehicle in an orbit
that passes over both the North and South Poles. In the initial condition, the vehicle is in
a circular orbit at an altitude of 300,000 m. At the start of the simulation, rockets on the
space vehicle are ignited for 120 sec which provide a thrust in the tangential direction. At
the end of the 120 sec rocket burn, the only force acting on the vehicle is gravity.
To eliminate the problem of programming the effect of variable vehicle mass, it is
assumed that the thrust of the rockets provides a constant acceleration of 4.905 m/sec 2
(0.5 g). A cylindrical coordinate system, as shown in Fig. 3.26, is ideally suited to describe
the two-dimensional motion.

Ch. 3

127

Advanced Features of CSMP
~Tangential direction

;L~

! \ s p a c e vehicle

e

~---,

---+---=---f-

~+---+---1
REARTH

= 6.373 x 106 m

Fig. 3.26 Cylindrical coordinates of a space vehicle in a polar
orbit.

The nonlinear equation set is

rro 2

;: =

OJ

=

(3.13)

g

-

(A - 2fro)

(3.14)

r

(3.15)

Program symbols

where

r

=

e=

radius from center of earth, m

R

angular position, deg

ANGLE

ro = angular velocity, radians/sec

OMEGA

g = acceleration of gravity,

G

3.983 x 10 14 /r 2 , m/sec 2
A = acceleration resulting from rocket thrust, m/sec 2

A

=

4.905

A =0

TIME

<

A

120.0 sec

TIME> 120.0 sec

The program, shown in Fig. 3.27, which simulates the motion of the space vehicle is
divided into the three segments. In the Initial segment the initial radius RO and initial
angular velocity OMEGAO are calculated. The angular velocity of a satellite in a circular
orbit is given by Eq. (3.16).
OMEGAO

=,.ff

(rad/sec)

(3.16)

Note that a FORTRAN WRITE statement is used with an appropriate FORMAT
card to print the velocity in the circular orbit in mph. A WRITE instruction is also included in the Initial segment to provide a heading for output from the Dynamic segment.
In the Dynamic segment, a logical IF statement is used in the first nosort section to
assign the proper value of A. A sort section is then used to calculate;: (RDD) and OJ

128

Advanced Features of CSMP

LABEL

Ch. 3

PROGRAM TO CALCULATE THE ORBIT Of SATELLITE.

INIT~AL

CONSTANT REARTH = 6.373E6, C = 3.983El4, ALTO 3 300000.0
RO= REARTH • ALTO
G = C/CRO*ROJ
OMEGAO = SQRTCG/RO)
VEL = OHEGAO*RO
MPH = VEL/O.44704
NOSORT
100 FORHATI1H1,26HINITIAL VELOCITY IN HPH • .FlO.O)
101 FORMAT(4E28.6)
102 fORMATIZFZ5.2)
103 FORMATI1H1,12X,21HFINAL VELOCITY IN HPH,7X,23HFlNAL ALTITUDE IN HI
$LES)
104 FORMATC/,16X,'ALTITUDE IN METERS',lOX,'ANGLE IN DEGREES',12X,'VELO
$CITY IN METERS/SEC',6X,'TIME IN SECONDS'.
WRITEI6,100) MPH
WRITEC 6,104')
DYNAMIC
NOSORT
A = 0.0
IFITIME.LE.1Z0.0) A = 4.905
SORT
G = CII R*R)
ROD = R*OMEGA*OMEGA - G
OMEGAO = CA - Z.O*RO*OHEGAJ/R
RO = INTbRLCO.O,ROO)
R = INTGRLIRO,RoJ
OMEGA
INTGRLCOMEGAO,OMEGAO)
ANGLE = (180.0/3.14159)*INTGRLCO.0,OMEGA)
NOSORT
ALT = R - REARTH
VEL = SQRT(RO*Ro + (R*OMEGAJ**Z'
IFCTIME.GT.1Z0.0' GO TO 1
IF(KEEP.EQ.l) WRITE(6,101) ALT, ANGLE. VEL, TIME
1 CONTINUE
HRMINAL
T1MER FINTIM = 9500.0, OUTDEL = 120.0
ABSERR R = 1.0
FINISH ANGLE = 360.0
PRTPLT ALT (ANGLE, VEL, G)
MPH = VEL/0.44704
MILES = ALT/1609.344
WR ITE( 6, 103)
WRITE(6,l02) MPH, MILES
END
STOP
ENDJOB

Fig. 3.27 Program to simulate the motion of a space vehicle and

to demonstrate the use of FORTRAN output statements.
(OMEGAD) and integrations are performed to calculate f (RD), r, OJ (OMEGA), and
() (THETA). The Dynamic section is changed back to a no sort section to allow the use of
a FORTRAN WRITE statement. The WRITE statement is executed at each valid integration step during the first 120.0 sec of the simulation. This WRITE statement does not
affect the step-size of the variable interval integration methods. Notice that the value of
OUTDEL is equal to 120.0. This means an integration step must be performed at TIME
= 120.0 sec which insures the program will simulate the total burn of the rockets. Also
note that the allowable absolute error for the R integrator is increased to 1.0. The default
absolute error of 0.0001 provides tighter control than necessary for very large output of
the R integrator.
The output from the FORTRAN WRITE and FORMAT instructions is given in
Fig. 3.28.

Advanced Features of CSMP

Ch. 3.
~

129

FORTRAN output from initial segment

INITIAL VE:LOCITY Ir. MPH = 17282. /
ALTITUDE IN METERS

ANGLE IN DEGREES

V~LDCITY

O.300000E
O.300000F
0.3000LUE
O.30U273E
U.303325f

0.0
0.498699E
0.150320E
0.354051E
0.826137E

O.772577E
O.116255E
0.183610E
O.798296E
O.t)31070E

***SlMULATIO~

06
06
06
06
06

HALTED...

ANGLE

FINAL VELOCITY IN MPH
186')0.59

=

00
01
01
01

3.b59~E

02

IN METERS/SEC
04l
04
04
04
04

\
5

TI ME I N SECONDS
0.0
O.150000E
0.225000E
O.525000E
O.120000E

Output from Dynamic Segment

FINAL ALTITUDE IN MILES
1 8 7 • 03 """"""---

01
02
02
03

Output from Terminal Segment

Fig 3.28 Output from FORTRAN statements in Fig. 3.27.

Note that the first two lines of Fig. 3.28 were initiated in the Initial segment. The
following five lines which describe the motion during the 120.0 sec rocket burn period
were printed by the WRITE statement in the Dynamic segment. Since all integration steps
are printed and the FORTRAN WRITE statement does not affect the integration step size
of the variable-step Runge-Kutta method, the progress of the numerical integration can
be monitored. Note that the first integration step is 7.5 sec which is r\i of the output
interval. In the second step the integration interval is increased to 15.0 sec, and for the
third step the interval is 30.0 sees. For the fourth and last integration step during the
rocket burn, a step size of 67.5 sec is used. The final velocity and altitude which was
printed from the Terminal segment is shown in the last two lines of Fig. 3.28.
The time-history of the altitude is shown by the PRTPLT output of Fig. 3.29.
Note that the FORTRAN output statements had absolutely no effect on the PRTPLT
output. This is not the case if both FORTRAN WRITE and PRINT statements are used
in the Dynamic segment of the same program. FORTRAN and PRINT output statements are printed in the order in which they are generated. Consequently, FORTRAN and
PRINT outputs are mixed together and can be confusing to read. Consider the example of
using the following PRINT statement used with a PRDEL of 15.0 in the program of
Fig. 3.27.
PRINT ALT, ANGLE, VEL, G
The portion of the mixed output is shown in Fig. 3.30.

DEBUG Subroutine

It is often useful when developing or checking out new programs to know the
values of all variables. The DEBUG subroutine can be used for this purpose. It will
print the current values of all non subscripted variables at each successive integration step. Any diagnostic messages that may appear are printed at the point where
they occur. The subroutine is called by the following statement.
CALL DEBUG(N, T)

130

Advanced Features of CSMP

PAGE

PROGR AM TO CALCULATE THE ORtllT OF SATELLITE.

TIME
0.0
1.2000E
2.4000E
3.6000E
4.8000E
6.00001'
7.2000E
8.4000E
9.6000E
1.0800':;
1.2000E
1.32001;
1.4400E
1.5600::
1. bAOOE
1.8000E
1.9200E
2.0400E
2.1600E
2.2600E
2.4000E
2.520aE
2.6400E
2.7600E
2.8600E
3.0000E
3.1200E
3.2400E
3.3600E
3.4800E
3.6000E
3. 7200E
3.8400E
3.9600E
4.0800E
4.2000E
4.32 ODE
4.4400E
4.5600E
4.6800F.
4.8000E
4.9200E
5.0400E
5.1600E
5.2800E
5.4000E
5.5200E
5.6400E
5.7600E
5.8800E
6.0000E
6.1200E
6.2400E
6.3600E
6.4800E
6.6000E
6.7200E
6.6400E
6.9600E
7.0800E
7.2000E

Mlt.IMUM
3.0000E 05
I

02
02
02
02
02
02
02
02
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03'
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03

ALT
3.0000E 05
3.0:;33E 05
3.'3B7E 05
3.6495~ 05
4.2542E 05
5.0360E 05
5.9773t:. 05
7.0538E 05
B.2429E 05
9.5208E 05
1.0864E 06
1.2251E 06
1.3662E 06
1.5077E 06
1.6479E 06
1.7d54E 06
1.9189E 06
2.0472E 06
2.1693E 06
2.2643E 06
2.3916E 06
2.49')4E 06
2.5802E 06
2.6606E 06
2.7313E 06
2.79181': 06
2.8419E 06
2.8816E 06
2.9105E 06
2.9285E 06
2.9358E 06
2.9320E 06
2.9174E 06
2.8920E 06
2.8558E 06
2.8090E 06
2.7518E 06
2.0844E 06
2.6070E 06
2.5202E 06
2.4242E 06
2.3196E 06
2.2070E 06
2.0870E 06
1.9606E 06
1.8287E 06
1.692':>E 06
1.5528E 06
1.4115E 06
1.270LE 06
1.1304E 06
9.9439E 05
8.6422E 05
7.4218E 05
6.3063E 05
5.3193E 05
4.4835E 05
3.619bE 05
3.3449E 05
3.0725E 05
3.0099E 05

ALl

Ch.3

VERSUS TIME

MAXIMUM
2.9358E 06
I

---------+
------------ +
--------------+
------- ---------- +
--------------------+
:..---------------------+
-------------------------+
----------------------------+
--- - ------- --------- ---- - - - - - - +
--------------------------------+
----------------------------------+
------------------------ -------------+
---------------------------------------+
-----------------------------------------+
-------- ---------------------------------+
--------------------------------------------+
--- -------------------------------------------+
-----------------------------------------------+
-----------------------------------------------+
--- ---- -----------------------------------------+
---------------------------------------------+
-------------------------------------------------+
----------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
------------------------------------------------+
--- --------------------------------------------+
---------------------------------~---------+

--------------------------------------------+
-----------------------------------------+
-----------------------------------------+
----------------------------------------+
--------------------------------------+
------------------------------------ +
--------------------------------+
-----------------------------+
--- -------------------------+
--------------------------+
-----------------------+
--.. ------------------+
------------------ +
---------------+
-------------+
----------+
--------+
----+
--+

ANGLE
0.0
8.2614E
1.6823E
2.5306E
3.3662E
4.1849E
4.9834E
5.7590E
6.5101E
7.2360E
7.9362E
8.6113E
9.2620E
9.8892E
1.0494E
1.1079E
1.1645E
1.l193E
1.2724E
1.3242E
1.3746E
1.4238E
1.4720E
1.5193E
1.5658E
1.6117E
1.6570E
1.7018E
1.7463E
1.7906E
1.8348E
1.8790E
1.9Z32E
1.9677E
2.0124E
2.0575E
2.1032E
2.1495E
2.1965E
2.2444E
2.2933E
2.3433E
2.3946E
2.4473E
2.50l6E
2.5575E
2.6154E
2.6752E
2.7372E
2.8015E
2.8682E
2.9374E
3.0092E
3.0835E
3.1603E
3.2395E
3.3207E
3.4038E
3.4883E
3.5737E
3.6595E

00
01
01
01
01
01
01
01
01
01
01
01
01
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02

VEL
7.7258E
8.3107E
8.3132E
8. <'695E
8.2057E
8.1240E
8.02721:
7.9182E
7.7999E
7.6752E
7.5465E
7.416;;E
7.2862E
7.1583E
7.0338E
6.9137E
6.7991E
6.6906E
6.5888E
6.4941E
6.4066E
6.3272E
6.2556E
6.1919E
6.1364E
6.0892E
o.0502E
6.0195E
5.9972E
5.9833E
5.9777E
5.9806E
5.9918E
6.0114E
6.0394E
b.0757E
6.1203E
6.1732E
6.2342E
6.3033E
6.3804E
6.4652E
6.5576E
6.6571E
6.7636E
6.8763E
6.9947E
7.1179E
7.2449E
7.3744E
7.504aE
7.6343E
7.7606E
7.8813E
7.9936E
8.0946E
a.1815E
8.2513E
8.3017E
8. 3309E
tl.3376E

03
03
03
03
03
03
03
03
03
03
03
03
(H

03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03
03

G
8.9447E
8.9357E
8. 8dl OE
8. 7730E
8.6177E
8.4227E
8.1969E
7.9495E
7.6890E
7.4230E
7.1580E
6. B991E
6.6499E
6.4133E
6.1910E
5.9840E
5.7929E
5.6177E
5.4583E
5. 3142E
5.1850E
5.0"100E
4.9688E
4.8807E
4.8053E
4.74201':
4.6905E
4.6504E
4.6215E
4.6036E
4.5964E
4.6001E
4.6146E
4.6400E
4.6764E
4.7242E
4.7837E
4.8551E
4.9391E
5.0361E
5. 1466E
5.2712E
5.4105E
5.5649E
5.7350E
5.9211E
6.1230E
6.3405E
6.5727E
6.8182E
7.0744E
7.3380E
7.6044E
7. 867!tE
8.1201E
8.3539E
8.5598E
8.7289E
8.8529E
8.9253E
8.9420E

Fig. 3.29 PRTPLT output for the program of Fig. 3.27.

N is equal to the number of outputs. An output, which includes a listing of the
values of all variables, is printed for all trial and intermediate integration steps as
well as for valid steps. N must be an integer constant. The output will begin at
TIME = T or at the first integration step after TIME = T.
The DEBUG subroutine can only be called from no sort sections or PROCEDURE functions. It is recommended that DEBUG be called at the end of the
Dynamic section. This insures that all computations of the dynamic simulation
are completed before DEBUG is called. DEBUG may not be called from the Ter-

00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00

CSMP

RKS

TIME
0.0

1.5000E 01
3.0000E 01
4.5000E 01
6.0000E 01
1.5000E 01
9.0000E 01
1.0500E 02
1.2000E
1.3500E
1.5000E
1.6500E
1.8000E
1.9500E
2.1000E
2.2500E
2.4000E
Z.5500E
2.1000E
2.8500E

02
02
02
02
02
02
02
02
02
02
02
02

ALT
3.0000E 05
0.300000E
0.300000E
0.300000E
0.300005E
3.0001E 05
0.300049E
3.0005E' 05
0.300171E
3.00l7E 05
0.300409E
3.0041E 05
, 0.300803E
3.0080E 05
0.301393E
3.0139E 05
0.302219E
3.0222E 05
0.303321E
3.033ZE 05
3.0474E 05
3.0647E 05
3.0852E 05
3.1089E 05
3.1358E 05
3.1658E 05
3.1990E 05
3.2353E 05
3.2741E 05
3.3112E 05
3.3628E 05

ANGLE
0.0
06
06
06
06
9.9977E-Ol
06
2.0090E 00
06
3.0277E 00
06
4.0558E 00
06
5.0933E 00
06
6.1401E 00
06
7.1961E 00
06
8.2614E 00
9.3317E 00
1.0402E 01
1.1471E 01
1.2539E 01
1.3601E 01
1.4674E 01
1.5740E 01
1.6804E 01
1.7868E 01
1.8930E 01
1.9991E 01

VEL
G
7.7258E 03 8.9lt47E
0.622078E-Ol
O. 186 734E 00
0.436232E 00
O.999766E 00
7.7993E 03 8.9lt46E
0.200900E 01
7.8728E 03 8.9445E
0.302769E 01
7.9463E 03 8.9lt42E
0.4055HE 01
8.0196E 03 8.9436E
0.509327E 01
8.0927E 03 8.9425E
0.b14008E 01
8.1656E 03 8.9lt09E
0.1l9613E 01
8.2383E 03 8.9387E
O. 826135E 01
8.3107E 03 8.9358E
8.3153E 03 8.9320E
8.3134E 03 8.9273E
8.3112E 03 8.9218E
8.3087E 03 8.9155E
8.3058E 03 8.9084E
8.3026E 03 8.9004E
8.2990E 03 8.8915E
8.2951E 03 8.8"819E
8.2909E 03 8.8715E
8.2863E 03 8.8602E
8.Z814E 03 8.8482E

INTEGRATION

00
0.773036E
0.773956E
0.775795E
0.779932E

04
04
04
04

00
01
01
02

00
0.787284E 04

0.300000E 02

0.7946"28E 04

0.450000E 02

0.801958E 04

0.600000E 02

0.80927lE 04

0.750000E 02

0.816564E 04

0.900000E 02

0.823830E 04

0.105000E 03

0.831068E 04

0.120000E 03

00
00
00
00
00
00
00
00
00
00
OO~
00
00
00
Output
00
00
00
00

\

Output from FORTRAN Statements

from PRINT Statement'

Fig. 3.30 Example of mixed FORTRAN and CSMP output.

"'"
"''""

0.937500E
0.281250E
0.656250E
0.150000E

132

Advanced Features of CSMP

Ch. 3

minal segment since this segment is not executed until the end of the run. Logical
control instructions can be used with DEBUG but they should not be used to
"branch around" the CALL DEBUG statement at TIME = O. The DEBUG
subroutine can be used several times in one program.
Figure 3.31 shows a DEBUG statement added to the program of Example 3.8,
which simulated the motion of a space vehicle. To simplify the program, all
FORTRAN output statements are removed.
LABEL PROGRAM TO CALCULATE THE ORBIT OF SATELLITE USING CALL DEBUG
INITIAL
CONSTANT REARTH = 6.313E6. C = 3.983E14, ALTO = 300000.0
RO = REARTH + ALTO
G = C/(RO*RO)
OMEGAO = SQRT(G/RO)
DYNAMIC
NOSORT
A = 0.0
IFITIME.LE.1Z0.0) A = 4.905
SORT
G = C/IR*R)
ROD = R*OMEGA*OMEGA - G
OMEGAO = IA - 2.0*RO*OMEGA'/R
RD = INTGRLCO.O,ROD'
R = INTGRLCRO,RD)
OMEGA = INTGRLtOMEGAO,OMEGAD)
ANGLE = (180.013.14159 )*1 NTGRLC 0.0, OMEGA)
NOSORT
ALT = R - REARTH
VEL = SQRTCRO*RD + (R*OMEGA)**Z)
*
*
*

THE FOLLOWING DEBUG STATEMENT WILL PRINT THE VALUE OF ALL VARIABLES USEO
IN THE PROGRAM FOR 4 ITERATIONS.
THE OUTPUT WILL START AT TIME: 1600,
OR ON THE FIRST INTEGRATION STEP AFTER TIME = 1600.

CALL DEBUG(4,1600.0)
TERMINAL
TIMER FINTIM \ 9500.0; OUT DEL
ABSERR R = 1.0
FINISH ANGLE = 360.0
PRTPLT ALT (ANGLE. VEL, G)
END
STOP
ENOJOB

= 120.0

Fig. 3.31 Program to illustrate the use of CALL DEBUG.

The DEBUG output is shown in Fig. 3.32. Note that the first output occurred
at TIME = 1620.0 which is the first integration step after TIME = 1600.0. Since
KEEP was equal to 0 in all four DEBUG printings, none of the outputs represent
a valid integration step. The six-digit symbols beginning with ZZ are generated by
the CSMP program.
PREPARE

If the user's computer installation has offline plotting facilities, data generated
by CSMP programs can be plotted on offline X-Y plotters. The PREPARE statement allows the user to specify up to forty-nine variables for offline plotting pur-

Ch. 3

Advanced Features of CSMP

RKS

CSMP

133

INTEGRATION

DEBUG OUTPUT
KEEP- 0
TIME"
1.b200E 03
DELT ..
OUTDELll0005"
ll0009"
llOOOb=
G
..
VEL
..

1.2000E 02
1.2000E 02
1.7793E 00
8.88l0E-04
0.0
b.3003E 00
7.0955E 03

DEUuN= 9.5000E-04
RD
"1.lb93E 03
ROD
= -1.4011E-0 1
ll0002= 0.0
REARTH= b.3730E Ob
A
= 0.0
ll0007 a
0.0

FINTIM"
R
ll0008"
RO
C
ANGLE =

9.4800E
7.95l0E
1.1727E
b.b730E
3.9829E
1.0195E

03
Ob
03
Ob
14
02

PROEL = 0.0
OMEGA = 8.8021E-04
OMEGAD= -2.5890E-07
OMEGAO=
1.1578E-03
ALTO "
3.0000E 05
AL T
..
1.57aOE Ob

DEBUG OUTPUT
KEEP" 0
DELT =
= 1. b200E 03
OUTDEL=
llOO05"
HOO09"
llOOOb"
G
VEL

1.2000E 02
1.20DOE 02
1.7793E 00
8.8021E-04
0.0
b.3002E 00
7.0955E 03

DEUIIN= 9.5000E-04
RO
1.lb93E 03
.. -1.40l2E-Ol
ROD
llOO02= 0.0
REARTH= b.3730E 06
0.0
A
ZZOO07 .. 0.0

FINTIM=
R
"
llOO08"
RO

9.4800E
1.95l0E
1.lb93E
b.b130E
3.9829E
1.0195E

03
Ob
03
Ob
14
02

PRDEL = o. a
OMEGA =
8.8020E-04
OMEGAO= -2.5889E-07
OMEGAO=
1.1578E-03
AL TO
"
3. OOODE 05
ALT
"
1.578DE 06

DEBUG OUTPUT
KEEP" 0
= 1.b500E 03
OELT
OUTOEL=
llOO05llOO09=
lZOO06"
G
VEL
"

1.2000E 02
1.2000E 02
1.8051E 00
8.8020E-04
0.0
6.2450E 00
1.0641E 03

DELMIN= 9.5000E-04
,. 1.1651E 03
RO
.. -1.b642E-01
ROD
ZZOO02= 0.0
REARTH= 6.3730E 06
A
= 0.0
ZZOO01= 0.0

FINTIM=
R
llOO08=
RO

9.4800E
7.98blE
1.lb93E
6.6130E
3.9829E
1.0346E

03
Ob
03
06
14
02

PRDEL = 0.0
OMEGA = 8.7244E-D4
OMEGAD= -2.5456E-07
OMEGAO=
1.1578E-03
ALTO
"
3.0000E 05
AL T
= 1.o131E 06

1.2000E 02
1.2000E 02
1.8055E 00
8.1244E-04
0.0
6.2452E 00
1.0b49E 03

OEL'41N= 9.5000E-04
a
1.lb43E 03
RO
= -1.649IE-Ol
ROD
l10002= 0.0
REARTH= 6.3730E Ob
A
" 0.0
ZlOO07= 0.0

FINTIM=
R
llOO08=
RO

9.4800E
7.9860E
1.165lE
6.6130E
3.9829E
1.0344E

03
06
03
06
14
02

PRDEL = O. a
OMEGA = 8.7257E-04
OMEGAD= -2. 5443E-07
OMEGAO=
1.1578E-03
AL TO
3. OOOOE 05
ALT
..
1.b130E Ob

TIME

.

TIME

TIME

.

DEBUG OUTPUT
0
,. 1.6500E 03 KEEP=
DELT
OUTDEL=
llOO05=
lZOOO9=
ZlOO06=
G
=
VEL
"

***SIMULATION HAL TED***

ANGLE

..

C
ANGLE =

..

C
ANGLE ..

C
ANGLE =

3.6595E 02

Fig.3.32 DEBUG output form program of Fig. 3.31.

poses. Its use for preparing the variables X, Y, and Z for plotting is illustrated
below.
PREPARE X, Y, Z

Using the PREPARE card is similar to using the PRINT statement; the similarities are listed below.
The CSMP continuation device C... ) may be used for continuation of the
PREPARE statement to additional cards.
2 Only one PREPARE statement should be used.
3 The independent variable TIME is automatically included.
4 The heading contained in TITLE statements is specified in the data set
generated by the PREPARE card and is available to the X-Yplottin~ programs.
5 The output interval is specified by the timer variable OUTDEL. Note, the
output interval for the PRINT statement is PRDEL.
The data from the PREPARE card is generated on the I/O device specified
as number 15. Depending upon the computer operating system, this data will
either be stored on a disk-storage device or on magnetic tape.

134

Advanced Features of CSMP

Ch.3

The simulation of the dynamic response of a pneumatic piston-cylinder system illustrates the use of the PREPARE statement.
Example 3.9

A common engineering problem involves simulating the response of a piston driven
by pressurized air flowing into a cylinder. This is a reasonably complex problem since it
involves the fluid- and thermodynamics of a compressible fluid. Figure 3.33 shows a
drawing of the system where air is flowing at a subsonic velocity through a small orifice
to the cylinder.
Cross-sectional area

= 0.4 ft2

Weight

= 280 lb

•
Open to atmosphere
Area of orifice
0.0008 ft2

=

= pressure
T = temperature
V= volume

P

PI supply pressure

Fig. 3.33 Piston cylinder system.

The mass flow rate for subsonic velocity of an ideal gas, without losses, through an
orifice is
rh

=

C[(J)2IY-

where C

=

(~ry+1)/Yr/2

A 1P l,j(1'

~girRTl

(3.17)
(3.18)

An energ~ balance on the air in the adiabatic cylinder yields the following expression
for the time rate of change of cylinder air temperature.

. (-P1 X + rhCpTl -

T

=

cvm

rhcvT)

(3.19)

T(O) = To

The volume inside the cylinder is
V=Vo +A·X

(3.20)

Assuming thermodynamic equilibrium, the perfect gas law can be used to solve for
the cylinder pressure.
P=

m·R·T

V

(3.21)

Advanced Features of CSMP

Ch. 3

135

Newton's second law can be used to calculate the acceleration of the piston

X = A(P - Po)

(3.22)

WEIGHT/g c

Symbols Used in
Program of Fig. 3.34

where

area of orifice, 0.0008 ftz

A1

=

P1

= supply pressure,

Tl

R

=

Al

3900.0 lbf/ft 2

PI
0

temperature of incoming air, 560 R

Tl

= gas constant, 53.35 ft-Ibf/lbm-oR

R

X = movement of piston, ft

X

I' = ratio of specific heats, 1.4
A

GAMMA

= area of piston, 0.4 ft2

A

Cp =

specific heat of air at constant
pressure, 0.24 Btu/Ibm-oR

CP

Cv =

specific heat of air at constant
volume, 0.171 Btu/Ibm-oR

CV

= initial temperature of air in cylinder, 530 R
Po = atmospheric pressure, 2116.8 Ibf/ft 3
Mo = initial mass of air in cylinder
0

To

Vo

=

initial volume of cylinder, 0.06 ftJ

gc = 32.17 Ibm-ft/lbf-sec 2

WEIGHT

=

weight of piston and attached mass,
280.0 Ibm

J = 778 ft-Ibf/Btu

TO
PO
MO
VO

GC
WEIGHT
J

Equations (3.17), (3.19), and (3.22) are contained in the program of Fig. 3.34 and are
integrated to determine the response.
The PREPARE card in the program of Fig. 3.34 is used to generate a data set for the
offline plotting of the variables X, XD, and XDD.
Once the data set is generated, the user must supply a program to interface directly
with the plotter. In this example the velocity XD and acceleration XDD are plotted as a
function of displacement X. The interfacing program that was used at the University of
Tennessee for a CALCOMP 763 plotter is shown in Fig. 3.35. It should be noted that
each computer installation will require its own interfacing program.
Figure 3.36 shows the PRINT output from the program of Fig. 3.34. Figure 3.37 is
the resulting offline X-Y plot.

DECK
In simulation studies it is often necessary to make several runs from the same
program changing only parameters and output statements. Computer time can be

136

Advanced Features of CSMP

Ch.3

li'HTIAL
PROGRAM Ta STUDY THE DYNAMICS OF A PNEUM~TIC PISTON-CYLINDER
TITLE ANO TO IlLUST~ATE THE USE 8F THE PRFPARE STATEMENT.
CONSTANT Pl = 3900.0, T1 = 560.0, At ~ 0.0008, PO = 2116.8,
TO = 530.0. VO = 0.06. A = 0.4, WEIGHT = 280.0, CP = 0.24,
CV = 0.111, R = 53.35, J = 778.0, GA~~A = 1.4, GC = 32.11
MO = PO*VO/(R*TOI
C = A1*Pl*SQRT(2.0*GC*GAM~A/(R*T1*(GAMMA - l~a)11
TITL~

OYNA~IC

MD = C*SQRT«P/Pll**(2.0/GAMMAI - (P/P1J**«GAMMA + 1.OJ/GAMMA ••
V = VO + A*X
TO = (-P*A*XD/J + ~D*CP*T1 - MO*CV*TJ/(M*CV'
P = M*R*T/V
XOO = (P - PO,*A/(WEIGHT/GCJ
M = INTGRl(~C.MO)
T = INTG~l(TO,TOI
XD = INTGRl(O.O,XODJ
X = INTGRl(C.C,XDI
PRINT X, XD, XDD, T, TO, M, MD, P
FINISH X = 1.0
TIMER FINTI~ = 5.0, PRD:L = 0.01. QUTDEl = 0.005

*

THE FOlLOWIN~ PREPARE CARD IS USED TO GENERATE A DATA SET THAT
CAN BE USED FeR QFF LINE PLOTTING Of THE VARIABLES X, XO, AND XOO.

*

PREPARE

X, XD, xeD

cNU

:iTJP
i:NDJOB

Fig. 3.34 Program to simulate the response of a pneumatic piston
cylinder system and to illustrate the use of the PREPARE statement.

saved in this situation by making a punched card deck of the translated CSMP
program. An understanding of the inner workings of the CSMP program is obviously not necessary for successfully programming. However, the following brief
description of the CSMP program will enable the reader to better understand the
advantages of using a translated punched deck. For the reader who is interested in
more detail, the CSMP System Manual(!) is recommended.
Once the user's program is read into the computer, the CSMP program begins
to build the subroutine UPDATE. This is called the translation phase. In generating
UPDATE, three primary tasks are accomplished.
1 The statements in the sort sections are placed in the proper order.
2 The proper transfer of control for the various segments and sections is
established.
3 Common statements are established to make the proper variables available
between UPDATE and the CSMP modules.
In the next step, the FORTRAN G compiler is invoked and the linkage editor
then links UPDATE with the various CSMP execution modules. Control is then
passed to MAIN which is the main or calling program. During the execution of the
program, MAIN calls the appropriate subroutine to perform the necessary opera-

Ch.3

Advanced Features of CSMP

131

EXEC FJPTGCLG.GOREG=96K
IIFJRT.SVSIN DO *
DIMENSION IBUF(bb4)
[) I MEN S ION TIM E ( lOu 0) • x ( lOu 0' , v I 1 00 0' ,Z ( 1 0 0) ,X DO T( 1
DI~fNSION ICODl(20',ICODEl(20'
DO 5 I = 1,11
READ (8.80' DUMMY
5
CONTINUE
80 FORMAT (A4)
READ (5.60) ICODE
READ (5.60) ICODEl
60 FORMAT I 20A4 )
NOPTS = 110
DO 10 I = 1.NOPTS
READ (8.END=20) TIMEII),XII),YII),ZIU
10 CONTINUE
20 CALL PLOTS (IBUF.664,60.0)
CALL Z IPOFF
YAXIS = 9.0
XAXIS = 10.0
DO 100 J = 1,3
NPTS = NOPTS
NPTS = NPTS I J
NST = NPTS * J +1
NOEL = NPTS * J + J + 1
CALL SCALE ITIME.XAXIS,NPTS,J'
CALL SCALE IX,XAXIS,NPTS,J)
CALL SCALE IV,YAXIS,NPTS,J'
CALL SCALE (Z,YAXIS,NPTS,J)
CALL SYMBOL (7.0,9.03,0.14,10,0.0,-1)
CALL SYMBOL (7.5,9.0,O.14,ICODE,O.O,80)
CALL SYMBOL (7.0,8.7,0.14,01,0.0,-1)
CALL SYMBOL (7.5,8.b4,0.14,ICODE1,0.0,80)
CALL AXIS (-0.75,0.O,3HXDD,+3,YAXIS,90.0,ZINST),ZINDEl))
CALL AXIS (0.O.O.0.2HXD.+2.YAXIS.90.0,Y(NST).V(NDEl))
CALL AXIS (O.O,O.O,lHX,-l,XAXIS,O.O,XINST),XCNDEL))
CALL FLINE (X,Y.NPTS,J,+1,10)
CALL FlINE (X.Z,NPTS,J,+1,01)
CALL PLOT (15.0,0.0,-3'
100 CONTINUE
CALL PLOT (0.0.0.0,999)
NSTOP = NOPTS
WRITE (6,63) ITIMEIL),XIl),Yll),ZCl),l=1,NSTOP)
63 FORMAT (lH .4(E14.6.5X))
STOP
END
IIGO.PLOTTAPE DO SYSCUT=P
II GO. fT 08 FOOL
DO OS N=PlOTT ER, DC B= (R ECFM= VS, lRECL=2 55, BlKS I IE=2550) ,
II
UNIT=2400,DISP=(OlD,KEEP),LABEL=I,SL"IN),VOL=SER=002330
IIGO.SYSIN DO *
XD I VELOC ITY)
XDD (ACCELERATION)
II

°

°°°,

1*

Fig.3.35 Program used at The University of Tennessee to interface between the data set generated by the PREPARE card and a
CALCOMP 763 plotter.

tion; integration, printing, plotting, initialization, etc. This total operation of the
CSMP program is quite complicated. A strong background in all areas of programming is required if the process is to be understood.
When the label DECK is included in a program with the appropriate JCL
(job control language) cards, a punched card deck is made. The deck includes the
CSMP subroutine UPDATE and all user-supplied subroutines, a listing of sym-

138

Advanced Features of CSMP

Ch. 3
RKS

PRO"RAM TJ STUDY THE DYNAMICS OF A PNEUMATIC PISTON-CYlINDER
AND TO ILLUSTRATE THE USE OF THE PREPA~E STATEMENT.
TIME
0.0
1.500u£:-1)2
3.0000E-Ol
ft.5000E-v2
6.0000E-Ol
7.500uE-Ol
9. OOOOE -Ol
l. O:'Ouc-u 1
1.2000E-Ol
1.3500E-Ol
1.500uE-Ol
1.6500e-il1
1.8000E-vl
1.9500E-v1
2.1000E;-ill
l.l500E-Jl
2. 'tOOOE-01
2.!J500E-01
1..7000E-vl
2.8500E-vl
3. OOOOE -vl
3.1~OOE-Ol

3.3000c;-1.I1
3.ft500E-v1
3.6000c;-vl
3.15001:-1.11
3.9000E-Ol
4.0'00E-Ol
4.2JOOE-Ol
't.351lIlE-,)J.

X
0.0
1.Z.369E-03
9.lft45E-03
2.1946E-02
5.1628E-02
9.6383E-02
1.4161E-"01
1.9114E-Ol
2.ftl8lE-01
2.9520E-Ol
3.4115E-01
3.9183E:-01
4.4661E-Ol
4.'l326E-01
5.3738E-01
5.1895E-Ol
6.1196f-Ol
6.54521:-01
6.8819E-Ol
7. ?102E-Ot
1.5146E-Ol
1.1l043E-Ol
11.011271'-01
8.3530E-Ol
8.6189E-Ol
8.8835E-Ol
9.1501E-Ol
9.421bE-01
9.7006E-Ol
9.98931'-01

***S1MULATlON HALTED***
4.}815E-01

1.00631' 00

XO
C.O
2.ft369E-Ol
8. fIl53E -01
1.6260<: 00
2.3086E 00
l. elS8E 00
3.1876E 00
3.3905E 00
3.ft1l34E 00
3.4886E 00
3.428'lE 00
3.3225<: 00
~. 1842E 00
3. 02 51E 00
2.8568E 00
2.6852E 00
2.~175E 00
2.~5eSE· co
2.2138E 00
2. OA57E 00
1.9710!: 00
1. 88C;Cl" 00
1. e252E 00
1.78350:: 00
1.164510 00
1.1673E 00
1.19061= 00
1. a323E 00
1.8902E 00
1.9616E 00
X

=

1.Cl813!: 00

XDD
-1.0098E-Oft
3.126ftE 01
4.90ne 01
4.9603E 01
4.0511E 01
l.8966E 01
1.8H3E 01
9.6998E 00
2.9908E 00
-2.0441E 00
-5.1l83E 00
-8.3020!: 00
-1.0010E 01
-1.1009E 01
-1.1430E 01
-1.lH6F 01
-1.0930E 01
-1.0165E 01
-9.14151' 00
- 7.916 7E 00
-6.5430E 00
-5.0102E 00
- 3. 5463E 00
-2.01101' 00
-5.25ft6E-Ol
8.8864E-Ol
2.1899E CO
3.3486E CO
4.3415E 00
5.1'H9E 00

T
5.3000E
5.7555E
5.9341F
5.9023E
5.1696E
5.6118<:
5.ft841F
5.3812F.
1).3063E
5.2'>591:
5.2254F.
5.2107!:
5.20841:
5.2160E
5.2314!:
5.25HE
"i .21851;
5.3071':
"i.33911'0
5.3718!:
5.405010
5.4378F
5.469710
5.4999E
5.5280'"
5.5534E
5.57&01=
5.5953E
5.6112E
5.6231E

I NTEGR AT I aN

TO
02
02
02
02
Ol
02
02
02
Ol
02
02
02
02
02
02
02
02
02
02
02
02
02
02
02
Ol
02
02
02
02
02

3.4142~-02

MD
1.001lE-02
6.ft301E-02
5.5621"-02
1).5241E-02
6.C393E-02
6.5095E-02
6.194ljE-02
b.9372F-02
6.9953E-02
1.0l02E-02
1.0057F-02
6.99481"-02
6.9841E-02
6.976510-02
6.9731E-02
6.97351:'-07.
6.9112E-02
6.9830E-02
6.9899E-02
6.99681'-02
1.002910-02
7.0074£-02
7.00<)9E.,.02
7.0107.F-02
7.00R3E'-02
7.0045E-02
6.9993E-02
6.9<)33F-02
6.<)a72E-02
6.9814"-07

2.1168F 0)
2.1971<: 03
3.18j3" 03
~.1961E 03
2.9983E 03
2.1471" 03
2.511>4!: 03
2.3219" 03
2. UIl9E 03
2.0123E 03
1.9924E 03
1.9362" Ol
1.8990E 03
1.8172': 03
1.8681 e 03
1.86<)3!: O~
1.8190" 03
1.89560:: 0'\
1.9119!: 03
1.9445F. 03
1.9144'" 03
2.0065E 03
2.03<)6<: 03
2.01291" 03
2.1054E 03
7.136110 03
2.1645'" 03
7.1897E 03
2.2113E 03
7.2289r 03

3.4403F.-02

6.98011'-02

2.2327" 03

03
03
02
02
03
02
Ol
02
02
02
02
01
01
01
02
02
02
07
02
02
02
02
02
02
07
02
02
02
01
01

ft.ft918E-0)
5.5101E-03
6.ft049E-03
1.2246E-03
8.0899E-03
9.0332E-03
1.0033E-02
1.106I)E-02
1.lllGE-02
1.3161E-02
1.4212(-02
1.5262E-02
1.6311F-02
1. 7358E -02
1.8404E-02
1.9450E-02
2 .04961'-02
7. • 1 5'-3 E-02
2.2591f-02
2.36ftOE-02
2.46901'-02
2.5741E-02
2.67<)21:-02
2 ~7843E-O?
2.BR95F-02
2.9946E-02
3.0996[-02
3.20461'-02
3.3094E-02

6.6527E 01

3.9930E
2.08HE
3.7ft45E
-6.6606E
-1.01ZZE
-9.1l91E
-7.91591:
-5.9082E
-4.1l09E
-2.6475E
-1.4616':
-5.3236E
2.0588E
1.8645E
1.239b!'
1.5a11E
1.84150::
2.0311E
2.1419E
2.2051E
2.2086E
2.1637E
2.0755E
1.94900::
1.7898E
1.6039E
1.39150::
1.1172E
9.4911E
7.2167E

1.0063E 00
5.32481; 00

5.6263E 02

Fig. 3.36 PRINT output from the simulation of the piston
cylinder system.

boIs used in the execution phase, and all data, execution, and output statements.
When the translated deck is used for initiating a run, generating the subroutine
UPDATE is not necessary and consequently, computer time is saved.
Any of the data, execution, and output control statements can be changed in
the translated deck. Minor modifications can even be made in the structure statements of the translated punched deck. A complete discussion of the use of translated decks is included in the CSMP System Manual. (1)
Figure 3.38 shows the deck statement inserted in the program of Example 3.9.
A listing of the resulting punched card deck is shown in Fig. 3.39. Included in this
listing are the JCL cards that are required at The University of Tennessee's computing center to make additional runs.
Additional runs can be made by changing the data, execution, and output
control statements that appear at the end of the punched deck. It is suggested
that the user contact the computer installation to determine the required JCL
cards.
User Defined Functions and Subroutines

Functions most often encountered in digital simulations have been programmed as a fundamental part of CSMP. Several of these functional blocks were

Ch. 3

Advanced Features of CSMP
)!(

0
0

o

0

co

ui

en

Ul

0
0

139

XO (VELOCITY)
XDD (ACCELERATI~N)

0

N

ai

en

~

0
0

0
 0

0 otherwise

By combining the above statements, one can write a procedure function for
ing EFLOW as follows.

generat~

Advanced Features of CSMP

Ch. 3

161

PROCEDURE
EFLOW = EFORM(EWIDTH, EPERID)
ETRIG = IMPULS(O.O, EPERID)
ERAND = RNDGEN(3)
EDENSE = AFGEN(ENORM, TIME)
ESIG = EDENSE - ERAND
ESINK = AND(ESIG, ETRIG)
EFLOW = PULSE(EWIDTH, ESINK)
END PRO
The value of EDENSE is determined by using the linear interpolater, AFGEN, where
the function is defined by the data of Fig. 3.51. Thus,
FUNCTION
ENORM = (0.0,0.2),(0.5,0.25),(1.0,0.34), ...
(1.5,0.46),(2.0,0.5),(2.5,0.45),(3.0,0.42),(3.5,0.43), ...
(4.0,0.48),(4.5,0.58)
Use of the AFGEN was previously explained in Chap. 1. At this point in the simulation
development the user should write a short program and verify that EFORM is correctly
generated. A short program for this purpose is given in Fig. 3.52 and the resulting output
is presented in Fig. 3.53.

= (O.0,0.21,(.5,.251,(1.,.34),(1.5,.46},(2.,.51, •••
( 2. 5,. 45) , C3. ,. 42 I , ( 3. 5 , • 43 I ,C 4. ,. 4 8 ) , ( 4. 5 , • 5 8 » , ( 5. , • 6 6 I

FUNGTION ENORM
PARAM EWIDTH

= 0.01,

EPERID

= 0.02

*.***.****************************************************************

*
*
*

*
*

NOTE ON THE FOLLOWING PROCEDURE TRANSLATION CONTROL CARD
THAT ALL VARIABLES REQUESTfD FOR PRINTING MUST BE LISTED AS
OUTPUTS OF THE PROCEDURE FUNCTION

*

***************************************.******************************
PROCEDURE ETRIG, EO~NSE, ERAND, ESIG, EFLOW
ETRIG = I~PUlS(O.O, EPERI~I
ERAND = RNDGEN(3)
EDENSE = AFGEN(ENCRM, TIME)
ESIG = EDE~SE - ERA~D
fSINK
ANOCESIG, ETRIGI
EFlOW = PUlSE(EWIOTH,ESINK)
ENDPRQ

= EFORM(EWIDTH,EPERID'

TIMER FINTIM = 0.2, PRDEL = 0.002, DELT = 0.002
PRINT ETRIG, EDENSE, ERAND, ESIG, EFlCW
TITLE 1*******
TEST FOR RANDOM PULSE GENERATOR END
STOP
ENDJOB

EXAMPLE 3-13

******

Fig. 3.52 Program for testing the random generation of a string of
cars.

Having developed a reasonable representation of traffic flow, attention is next
directed to the problem of determining (a) how many cars have approached the light; (b)
how many cars have passed under the light; and (c) how many cars are waiting at any
given instant of time. The total number of cars approaching the light can be determined by
integrating the traffic flow and dividing by the width of a car pulse. This can be deter-

TEST FOR RANDOM PULSE GEIliERATOR -

1····**·
TIME
0.0
2.0000E-03
4.00COE-03
6.0000E-03
8.0000E-03
1. 00COE-02
1.2000E-02
1.40COE-02
1.6000E-02
1.8000E-02
2.00COE-02
2.2000E-02
2.4000E-C2
2.6000E-02
2.80COE-02
3.00COE-02
3.2000E-02
3.4000E-02
3.60COE-02
3.8000E-02
4.0000E-02
4.2000E-02
4.4000E-02
4.60COE-02
4.8000E-02
5.0000E-02
5.2000E-02
5.40COE-02
5.6000E-02
5.8000E-02
6.0000E-02
6.2000E-02
6.4000E-02
6.6000E-02
6. BOOOE-02
7.COOOE-02
7.2000E-02
7.4000E-02
1.6000E-02
1.80COE-02
8.0000E-02
B.20COE-02
8.4000E-02
8.bOOO-E-02
8.8000E-02
9.0000E-02
9.2000E-02
C;.4000E-02
C;.bOOOE-02
Q.8000E-02
1.0000E-01
1.0200E-Ol
1.04COE-01
1.0600E-Ol
1.0800E-Ol

ETRIG
1. OOOOE
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
l.OOOOF
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1.0000E
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1.0000E
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1.0000E
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1.0000E
0.0
0.0
0.0
0.0

00

00

00

00

00

00

ECE NS F.
2.COOOE-01
2. 0020E -01
2.0040E-Ol
2.0060E-Ol
2. OOBOE-Ol
2.0100E-Ol
2.0120E-01
2.0140E-Ol
2. 01bOE-01
2.0180E-Ol
2.0200E-01
2.0220E-C1
2. 0240E-01
2. Ol60E-01
2.0280E-Ol
2.0300E-Ol
2.0320E-Ol
2.0340E-01
2.0360E-Ol
2.0380E-Ol
2.0400E-Ol
2.0420E-01
2. 0440E-01
2.0460E-Ol
2.0480E-01
2.0500E-01
2.0520E-01
2. 0540E- 01
2.0560E-Ol
2.05S0E-Ol
2.0600E-Ol
2.0620E-01
2.0640'=-01
2.0660E-Ol
2.0680f-Ol
2.0700E-Ol
2.0720E-Ol
2.0740E-0l
2.C760E-Ol
2.0780E-Ol
2.0800E-Ol
2.0820E-Ol
2.0840E-Ol
2.C860E-Ol
2.0880E-Ol
2. C900E-01
2.0920E-Ol
2.0940E-01
2. 0960E-Ol
2.0980E-Ol
2. 1000E-Ol
2.1020E-Ol
2.1040E-01
2.1060E-01
2.1080E-Ol

EXAMPl'= 3-13 ******

ERAND
9.1557E-05
5.4933E-04
2.4720E-03
9.8878E-03
3.7079E-02
1.?348E-Ol
4.6720E-C1
6.0182E-01
4.0612E-01
2.0407E-02
4.6132E-01
6.2025E-01
5.1562E-01
5.1l50E-01
4.2840E-01
9.6687E-Ol
9.4563E-01
9.7195E-Ol
3.2096E-01
1.7823E-01
1.8079E-01
4.8062E-01
2.5t-64E-01
2.1430E-0,1
9.7600E-Ol
9.2129E-01
7.7977E-01
3.3299E-01
9.8003E-01
8.8322E-01
4.7910E-Ol
9.2562E-01
2.4180E-Ol
1.2020E-01
5.4501E-Ol
1.8827E-Ol
2.2458E-Ol
6.5301E-Ol
8.9688E-Cl
5.0414E-0,1
9.5295E-01
1.8040E-01
5.0590E-01
4.1118E-Ol
9.1757E-01
7.9938E-Ol
5.3812E-Ol
3.432IE-02
3.62 a2E-Ol
8.6803E-Ol
9.4281 E-Ol
8.4457E-Ol
5.8216E-Ol
6.91 76E-01
l.lU6E-Ol

ES IG
1.9991E-01
1.9965E-Ol
1.9793E-Ol
1.ClO1lE-Ol
1.6372E-01
6.1515E-02
-2.6600E-01
-4.0042E-01
-2.0452E-01
1.8139E-Ol
-2.6532E-01
-4.1805'=-01
-3.1322E-01
-3.0890E-01
-2.2560E-01
-1.6381E-Ol
-7.4244E-Ol
-1.6855E-Ol
-1 • 1 13 6 E- 01
2.5567E-02
2.3215E-02
-2.7642E-01
-5.2244E-02
-9.6995E-03
-1.7120E-01
- 7. 222 9E - 01
-5.7457E-01
-1.2759E-Ol
-7 .1443E- 01
-6.7742E-Ol
-2.1310E-Ol
-7.1942E-Ol
-3.5397E-02
8.6404E-02
-3.3821E-01
1.8127E-02
-1.7379E-02
-4.4561E-01
-6.8928E-Ol
-2.9634E-Ol
-1.4495E-01
2. 7796E- 02
-2.9750E-OI
-2.0318E-Ol
-1.0871E-01
-5.9038E-Ol
-3.2892E-Ol
1.7508E-01
-1.5322E-Ol
-6.5823E-Ol
-7.3281E-Ol
-6.3431E-01
-3.717bE-Ol
-6.8116E-O,1
9.9635E-Ol

Fig. 3.53 The printer-plotted output from the program of a random pulse generator.

162

EFLOW
1.0000E
l.OOOOE
l.OOOOE
1.0000E
1. OOOOE
1.000eE
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
1. OOOOE
1.0000E
1.0000E
1.0000E
1.0000E
1.0000E
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

00
00
00
00
00
00

00
00
00
00
00
00

Ch.3

163

Advanced Features of CSMP

mined using the INTG RL function as
ELEFT = INTGRL(O.O, EFLOW)
ETOTAL = ELEFT/EWIDTH
where ETOTAL is the total traffic arriving from the east.
For simplicity, the state of the light is assumed to be either green or red with amber
ignored. The number of cars passing under the light can now be determined using the
mode integrator function whose characteristics are given in Table 3.4.
Table 3.4

Mode Integrator Function
(7SlkfJP Stater.nent
Y

= MODINT(IC, Xl, X2, X3)

lkfather.natical Equivalent
yet)

=

f

yet)
yet)

=
=

IC
last output

X3(t)

dt

+ Ie

Xl

> 0, any

X2

< 0, X2 >
Xl < 0,X2 :::;:;
Xl

°°

The input signal X3 should be the actual traffic passing under the light with Xl the state
of the light. Thus, if Xl is greater than zero (the light is green), yet) increases by integrating
X 3 • When the light changes to red, Xl equals zero and yet) holds the last output value.
Any non-positive number for X 2 can be used. Expressing this in program variables gives
ERIGHT
EPASED
where EWLITE

=

=
=

MODINT(O.O, EWLITE, -1.0, EWX2)
ERIGHT/EWIDTH

state of the east-west light

EWX2 = the pulses passing under the light
EPASED = the total number of cars passed through the light
The traffic backed-up at any time on the east side is given by
EBAKUP = ELEFT - ERIGHT
EWAlT = EBAKUP/EWIDTH
where EWAlT is the actual traffic backed up or waiting on the east side.
The excitation signal, EWX2, must take the following into account. When the light
changes from red to green, traffic will not move instantaneously. We assume the flow
linearly increases with time up to the limit of maximum through-put. Once the maximum
flow is reached, the excitation will remain at this level until EBAKUP reaches zero. Once
EBAKUP reaches zero, EWX2 should be changed to EFLOW. Suppose we assume that
after 8 car units have passed under the light, EWX2 reaches the maximum value of
EWIDTH/EPERID.
A program which combines the generation of random traffic with traffic volumn in
the east to west direction is given in Fig. 3.54. The correct state of EWX2 is determined by
the procedure function EWX3 except for testing the state of EBAKUP. Logically, this
test should also be made in the EWX3 procedure function but in attempting to do so an
algebraic loop will be formed between ERIGHT, EBAKUP, and EWX3. This algebraic
loop is avoided by testing the state of EBAKUP in a NOSORT segment.

164

Advanced Features of CSMP

Ch. 3

FUNCTION ENORM = (0.0,0.2),(.5,.25.,(1.,.341,(1.5,.46),(2.,.51, •••
e 2. 5,. 45. ,( 3. ,. 42) , ( 3. 5 , • 43 t , (4. ,.48 I , ( 4. 5 , .58 1 , ( 5. , .66 1
PARAM EWIOTH = 0.012, EPERIO = 0.024, CYCLE = 1.0, EBAKUP = 0.0
LITRIG = IMPULS (O.O,CYCLEI
EWLITE = PULSE(CYClE/2.0,LITRIGI
ETRIG = IMPULSeO.O, EPERIOI
PROCEOURE EFLCW = EFOR~(ETRIGI
fRANO = RNOGEN(3)
EDENSE = AFGEN(ENOR~, TIMEI
ESIG = EOE~SE - ERANO
ESINK
ANOCESIG, ETRIG)
EFLOW = PUlSE(EWIDTH,ESINK.
ENOPRO
NOSDRT
IF(EBAKUP.GT.O.OI EWX2 = fWX3
IF(EBAKUP.Lf.O.OI EWX2 =EFLOW
SORT
ELEFT = INTGRL(O.O,EFLOW'
ERIGHT = MODINT(0.0,EWLITE,-1.O,EWX2'
E8AKUP = ELEFT-ERIGHT
PROCEDURE EWX3 = GENRALlEWlITE,EFLOW,CYClE,EWIOTH,EPERIDI
IF(TIME.lT.(CYClE/2.0») GO TO 19
IF(EWlITE.EQ.O.Ot GO TO 21
IFeEPASLT.EQ.O.O) CLOTIM = TIME
EDELT = TI~E - OlOTIM
IFIEOELT.GE.(S.O*EPERIDt) GO TO 23
EWX3 = «EWIOTH)/(8.0*(EP~RIO**2)))*EOELT
EPASl T = EWLITE
GO TO 27
21
EWX3 = 0.0
EPASlT = 0.0
GO TO 27
19
EPASLT = 0.0
IF(EWLITE.GT.O.O' EWX3
~FLOW
If{EWLITE.GE.O.O) EWX3
0.0
GO TO 27
EWX3 = EWIOTH/EPERID
23
27
CONTINUE
ENOPRO
ETOTAL = ELEFT/EWIOTH
EPASEC = EPIGHT/EWIDTH
EWAlT = EOAKUP/EwIDTH
TIMER FINTIM = 1.0, DUTOEL = 0.02, PROEL = 0.02
PRTPLT ETOTAL, EPASEO, EW4IT
LABEL TEST FaR TRAFFIC MaDEL - EXA~PLE 3-13
END
STOP
ENOJ08

Fig. 3.54 Traffic simulation program for east to west traffic.

This same basic model applies to west-east, north-south, and south-north traffic and
in a natural way invites the use of macro functions.
A simpler program could have been written to illustrate the use of the procedure
function. However, most meaningful real-world simulations require combinations of

Advanced Features of CSMP

Ch. 3

165

several CSMP features. The intention here has been to show how the procedure function
can typically be used as an element in a more comprehensive simulation.

Fortran Subprograms

There are two forms of subprograms that can be used in CSMP programs,
FORTRAN function and subroutine. The function subprogram can be used whenever the output is a single variable. A subroutine must always be used when there
are multiple outputs.
The MACRO and PROCEDURE functions essentially serve the same purpose
as subprograms and are generally preferred. However, subprograms do have
certain advantages not found in the macro and procedure functions. The following
is a listing of the most important advantages.
~

1 FORTRAN subprograms that are stored in the computer's system library
can be called directly by CSMP programs.
2 The statements of a subprogram are not processed by the CSMP translator.

Consequently, larger models can be developed by using subprograms.
3 Subprograms used in CSMP programs are compatible in FORTRAN programs. Therefore, subprograms can be interchanged between CSMP and
FORTRAN programs.
General Guidelines

The rules for writing a subprogram for the use in a CSMP program are exactly
the same as for a FORTRAN program. If needed, the reader should refer to specialized texts on FORTRAN(2-S) for a complete discussion on this topic. Implementation of subprograms in CSMP is somewhat different than in FORTRAN.
Special considerations that must be followed are outlined by the following general
rules.
1 All subprograms must follow the STOP card and furthermore, the last subprogram must be terminated by the ENDJOB card.
2 The following CSMP functional elements cannot be used in subprograms:

INTGRL, DERIV, DELAY, ZHOLD, IMPL, MODINT, REALPL,
LEDLAG, CMPXPL, HSTRSS, STEP, IMPULS, PULSE, RAMP,
SINE, GAUSS, RNDGEN, and any user-defined macro function.
3 A FORTRAN function subprogram can be invoked in all segments and
sections of a CSMP program. This includes invocations in macro and procedure functions. Using input variables P, Q, and R, a statement for calling
the function XYZ is

x

=

XYZ(P, R, Q)

4 A FORTRAN subroutine can be called by two different methods. The
CALL statement which is used in FORTRAN programs is only allowed
in nosort sections and procedure functions. An example of a CALL statement for the subroutine named ABC is the following.
CALL ABC(P, Q, R, X, Y)
If the output variables of the subroutine are on the right-hand side of the

argument list of the subroutine, a second method for calling a subroutine
can be used. This method can be used in all sections and segments, including macro and procedure functions. An example of this type of statement
for the same ABC subroutine is shown below.
X, Y = ABC(P, Q, R)
It should be reemphasized that the above statement can only be used when

the outputs X and Yare the last variables in the argument list of the subroutine.
Another limitation for using the above form for calling a subroutine is
that it can only be used when there are two or more output variables.
5 When calling a FORTRAN subroutine that is stored in computer memory,
the CALL form must be used in a no sort section or procedure function.
6 If the output of a subprogram includes subscripted variables, the calling
statement in the CSMP program must be in a nosort section of a procedure
function. All subscripted variables used as inputs or outputs must be declared on either a STORAGE or DIMENSION card.
The following example program illustrates the use of a FORTRAN subroutine to calculate the roots of a quadratic equation of the following form;
Ax 2

+ Bx + C =

0

(3.40)

In this program the inputs to the subroutine are the coefficients A, B, and C.
The outputs returned by the subroutine are the real part of the solution: Xl REAL
and X2REAL; and the imaginary part of the solution, XlIM and X2IM.

~

:

~

I

Program statements
generating A, B, and C

Statement for calling
Xl REAL, X2REAL, XlIM, X2IM = ROOTS (A,B,C)/ subroutine

;I
END

STOP

Program statements

Ch.3

Advanced Features of CSMP

167

SUBROUTINE ROOTS (A,B,C,XIREAL,X2REAL,XlIM,X2IM)
IF(B*B - 4.0*A*C) 1,2,3
1 XIREAL = -B/(2.0*A)
X2REAL = XIREAL
XlIM
= SQRT(4.0*A*C-B*B)/(2.0*A)
X2IM
= -XlIM
GO TO 4
2 XIREAL = - B/(2.0* A)
X2REAL = XIREAL
XlIM
= 0.0
X2IM
= 0.0
GO TO 4
3 XIREAL = (-B+SQRT(B*B-4.0*A*C))/(2.0*A)
X2REAL = (-B-SQRT(B*B-4.0*A*C))/(2.0*A)
XlIM
= 0.0
X2IM
= 0.0
4 CONTINUE
RETURN
END
ENDJOB

The statement used in the above example program for calling the subroutine
can be used in all segments and sections of the program. The following statement
can also be used to call the subroutine, but it must be used in a nosort section or
procedure function.
CALL ROOTS(A, B, C, XIREAL, X2REAL, XlIM, X2IM)
Example 3.14

One method for solving a set of simultaneous differential equations is to solve for the
highest derivative of each variable and then successively integrate to obtain the total
answer. This approach sometimes requires solving a set of simultaneous algebraic equations. As an example, consider the following problem,
=

-O.5Xl - 1.7Xl + 0.3X2 + 0.21x~ + sin (1)

(3.41)
(3.42)
(3.43)

where all initial conditions are zero.
The method of solution is to first solve for Xb X2, and X3 as functions of the other
variables that appear in the equations. This requires the solution of a set of simultaneous
linear algebraic equations as shown by Eq. (3.44).
XDD =A-IY

where A, XDD, and Yare defined by the following matrices.

(3.44)

168

Ch.3

Advanced Features of CSMP

A =

I~

t2

l56

+4
o

24

2t

100

OJ

(3.45)

(3.46)

Y =

-0.5X 1 - 1.7x 1. + 0.3X2 + 0.21x~ + s~n
0.017tx1 - 5X2 - X2 + 0.lx1 + 1.6X3
X1X2 - X3 - 2.4X3 + e- xd23

l

(t)J
(3.47)

Since the elements of both the A and Y matrices are time dependent, the XDD
vector must be calculated at each integration step. Most computer installations have programs available for solving matrix relationships of the form given by Eq. (3.44). At many
centers these subroutines are on-line and can be called from storage. In this example, a
subroutine which uses the Gauss-Jordan elimination method with complete pivotal
searching is employed. The subroutine SOLVE is called from the CSMP program. Within
the subroutine SOLVE is another subroutine named INVERT. Figure 3.55 shows a
listing of the CSMP program and the FORTRAN subroutines for solving the set of
differential equations.
Because A is a double-subscripted variable, the FORTRAN DIMENSION statement must be used. The FORTRAN LOGICAL instruction is a FORTRAN specification
statement and is used to declare that SING is a logical variable. If the matrix A is singular,
the logical variable SING is true. In this example, the matrix is never singular and hence
the solution of the equation set is given in Fig. 3.56.
Since the variable-step Runge-Kutta integration method is used in this example,
subroutine SOLVE is called four times for each integration step. If this procedure is used
to solve an equation set that has a large number of variables, a large amount of computer
time will be required for the multiple solution of the XDD vector.
It should be noted that the only way to call the subroutine SOLVE is by using the
CALL SOLVE instruction in a no sort or procedure section. The following statement
cannot be used since the output variable (XDD) is not the last argument of the subroutine.
XDD

=

SOLVE(A, 3, 3, 3, Y, SING)

Note that there is only one output variable. This is another reason why the above
form for calling the subroutine SOLVE cannot be used.
Special consideration must be made when using subprograms where the output
depends on past values of output and past and present values of input.

Memory
This statement is required for subprograms that contain memory functions.
A memory function is one where the output depends only on past values of input
and output. As an example, consider the following statement.
MEMORY ABC(13)

The above instruction specifies that 13 storage locations are allocated for
memory functions which are contained in the subprogram ABC. The MEMORY

TITLE PROGRAM TO DEMONSTRATE THE USE OF A SUBROUTINE AND TO SOLVE
TITLE
A SYSTEM OF SIMULTANEOUS DIFFERENTIAL EQUATIONS
DIMENSION All,3). XDD(3), Yll)
LOGICAL SING
FIXED I, J
NOSORT
DO 1 I
1.3
OOlJ
1.3
AII.J) x 0.0
AU.U x 1.0
All.2)
TI ME*TI ME + 4.0
AIZ.U ~ 5.0
AI2.3) .. 24.0
Al3.i) .. 56.0
All.Z) = 2. O*TI ME
An.3) .. 100.0
Yl 1 J = -0.5*XDl - 1.1*Xl + 0.3*XZ + 0.21*IX].*]) + SINCTIME)
Y(2)
O.011*Xl*TIME - 5.0*XD2 - X2 + O.l*X] + 1.6.XD3
y(3)
XDl*X02 - X3 - 2.4*XD3 + EXPI-Xl/23.0J
CALL SOLVEIA.3.3.3.Y.XOD.SING)
SORT
XDI = INTGRLCO.O,XDDll»)
XOZ .: INTGRLCO.O.XODCZ»
X03 .: INTGRlCO.0.XDD(3»
Xly = I NTGRU O. O. XDU
X2 = INTGRlI0.0.XD2)
X3 = INTGRlIO.O,XD])
PRINT Xl. XZ. Xl
TIMER FINTIM = O.Z. PRDEL .: 0.01
END
STOP
C THE FOLLOWING TWO SUBROUTINES WILL SOLVE A SET OF SIMULTANEOUS
C
LINEAR EQUATIONS.
SUBROUTINE SOlVECA.MA,NA,N,B.X,SING)
REAL AIMA.NA).BlNJ.XIN)
LOGICAL SING
CALL INVERTIA.N.MA.SING.
IF(SINGJRETURN
DO 10 l=l.N
XII)"O.O
DO 10 J=l.N
10 X([)=X(I)+A(I.J)*S(JJ
RETURN
END
SUBROUTINE INVERTlA.ORDER,DIM A, SING)
INTEGER ORDER. DIM A
REAL A(DIM A.l),BClOO).CllOO)
N=ORDER
LOGICAL SING
INTEGER IPCIOO).IOllOO)
DO 1 K=l.N
PIVOT-O.
DO 100 I-=K. N
DO 100 J=K,N
IFCASSIA(I.J»-ABS(PIVOT»)lOO,lOO,lOl
101 PIVOT"'AII,J)
IPIK):a1
IQIKJ=J
100 CONTINUE
IFIPIVOT)102,900.102
102 IPK=tPIK)
IOK=IOCK)
If(IPK-K)200.Z99,200
ZOO DO 201 J=l.N
Z=Al IPK.J)
AIIPK.J)=ACK,J)
ZOI AIK.J)=Z
299 CONT INU E
IF(IQK-K)300,399,300
I
I

Fig. 3.55 CSMP program and subroutines used to solve a set of
differential equations.
169

300
301
399
402

DO 301 l=l.N
Z= A( I .1 QK ~
A(I,IQK)=A(I,K)
A(I.K)=Z
CONTI NUE
DO 400 J=l.N
IF(J-KJ403.40Z,403
B(J)=1./PIVOT
C(J~=l.

403

GOT a 404

404
400
405
1

SOL
503
S02
504
506
500
900

B(J)s-A(K.J~/PIVCT

C(J)=A(J,K)
A(K,JJ=O.
A(J.K)=O.
DO 405 1=1. N
DO 405 J=l.N
AlI,J)=A(I,J)+C(U*S(J)
CONTINUE
K=N
DO 500 KDUM= 1. N
IOK=IQ(K)
IPKaIP(K)
IF( IPK-K)SOl.,502,501
DO 503 I=L,N
Z= A( I, I PK)
A( I , I P K ) =A ( I , K)
A(I,K)=Z
IF( IOK-K)S04,500,504
DO 506 J=l,N
I=A( IQK,J)
A(IQK.JI=A(K.J)
A(K,J)=Z
K=K-l
SING = .FALSE.
RETURN
SING = .TRUE.
RETURN
END

ENDJOB

Fig. 3.55 (Continued)
PROGRAM TO OEMONSTRATE THE USE OF A SUBROUTINE AND TO SOLVE
A ~Y~TEM OF SIMULTANEOUS CIFFERENTIAL EQUATIONS

X2

Xl

TIME
Il.O

1.0000E-02
2.uOOOE-J2
3.0000E-J2
tt. t)()UuE-U2

5.0000E-02
6. UOOOI:-02

7.0000c-02
8.JOOOE-u2

9.0000E-02
1.00uOE-OI
1.1U()Oc-OI
1. 20QuE-Q 1

1.30QOE-Jl
1. 'tOQui:-OI

1. 5000E-O 1
1.6vUUc-OL
1.7000i:-Ol

1.8000E-Ol
1.9JOOE-Ol
2 .OOOOE-O 1

0.0
1.4215E-Ob
5.6849E-06
1.2790E-05
2.2737E-05
3.5528E-05
5.1166E-05
6.<;655E-05
9.1001E-05
1.1521E-04
1.4Z29E-04
1.7225E-04
2.0510E-04
2.4085E-04
2.7952E-04
3.21LIE-04
3.6565E-04
4.1314E-04
4.6361E-04
5.1708E-04
5.7356E-04

c.e
-3.1430E-01
-1.0C;27E-06
-2.6889E-06
-3.C570E-06
-3.1516E-06
-3.9282E-06
-3.3428E-C6
-1.75Z1E-06
i.C862E-06
5.4138E-06
1.1471 E-05
1.'i4C;8E-05
2.9733E-C5
4.2413E-05
5. H14E-C5
7.6053E-05
<;.1482E-C5
1.2229E-04
l.5072E-04
1.8Z99E-04

RKS

X3
0.0
-2.9598E-07
-1.1833E-06
-2.6614E-06
-4.7307=-06
-1.3923E-06
-1.0648E-05
-1.4501E-05
-1.8953E-C5
-2.4010E-05
-2.9616E-05
-3.5951E-05
-4.2859E-05
-5.0389E-05
-5.8555E-05
-6.1367E-05
-1.6833E-05
-8.6964E-05
- 9. 1170E-05
-1.0926E-04
-1. Z146E-04

Fig. 3.56 PRINT output for the solution of the set of differential
equations.
170

INTEGR ATION

Ch. 3

Advanced Features of CSMP

171

card should appear in the deck before the first reference to the subprogram.
Examples of some CSMP memory elements are the following
INTGRL
DELAY
REALPL
CMPXPL

History

This statement is used with subprograms where functions are used in which
the output depends on past and present values of output and present values of input.
The following instruction will reserve 8 history storage locations for the subprogram ABC, and 17 for the subprogram DEF.
HISTORY ABC(8) DEF(17)

The HISTORY statement must appear before any reference to the subprogram.
Some CSMP history functions are:
DERIV
GAUSS
HSTRSS

IMPULS
PULSE
RNDGEN

RST
STEP
ZHOLD

A more comprehensive discussion of MEMORY and HISTORY can be found
in References (1 and 6).

Implicit Functions

For certain types of simulations, the output of CSMP will state that an algebraic loop is formed between a specified list of variables and that the program
cannot be executed. This problem arises whenever a loop does not contain at least
one memory function.
As noted in the previous section, there are two types of memory functions
defined in CSMP. If we consider a function to be characterized as having an output
and input, the following applies.
(a) A MEMORY function is one whose output depends only on past values
of the output and input.
(b) A HISTORY function is one whose output depends on past values of the
output and input and in addition, the present value of the input.
There are four MEMORY functions in CSMP: INTGRL, REALPL,
CMPXPL, and DELAY. Each loop of a simulation must contain either at least
one of these functions or a user-defined memory function to avoid an algebraic
loop. However, loops are not always obvious in a simulation.
Consider the simple circuit shown in Fig. 3.57(a). If the output is the voltage

172

Advanced Features of CSMP

Ch. 3

(a) Series circuit

~
- 1/R 1

(b) Flow graph for the series circuit
Fig. 3.57 Series circuit and proposed flowgraph.

across R2 and the input is the independent source Vinet), a set of equations describing the network is
(3.48)
Vit) = i(t)R2
i(t)

=

Vinet) _ Vit)
Rl

Rl

(3.49)

A flow graph for the two equations is given in Fig. 3.57(b). Since the flow graph
contains a feedback loop without a memory function, programming these equations will result in an algebraic loop. An algebraic loop can often be circumvented
by either rewriting the simulation equations or using the CSMP implicit function.
Formulation of Implicit Functions

An equation of the form F(x) = 0 is an implicit function. The equation for
F(x) can be written as

x =f(x)

(3.50)

where F(x) =1= f(x). As an example, suppose
F(x)

= x 2 + 3x - 4 = 0

(3.51)

One way of expressing the variable x is
x =f(x)

=

t(4 - x 2 )

(3.52)

The CSMP function

x

=

IMPL(XO, ERROR, FOFX)

(3.53)

Ch. 3

Advanced Features of CSMP

will often find an x which satisfies the general equation, x
may satisfy Eq. (3.52). In the IMPL function arguments,

=

113

f(x) , and in particular

XO

=

an initial guess for x as specified by the user

ERROR

=

the error specified by the user in finding x

FOFX

=

the right hand side of Eq. (3.50)

A general rule for using the IMPL function is that the expressions for FOFX must
appear after X = IMPL (XO, ERROR, FOFX) and the last such expression must
specify FOFX. Furthermore, the variable X must appear at least once on the right
side of the equations defining FOFX. As applied to Eq. (3.52) one may write either
X = IMPL (XO, ERROR, FOFX)
A = 4.0/3.0
B = -(X**2)/3.0
FOFX =A + B

or
X = IMPL (XO, ERROR, FOFX)
FOFX = (4.0 - X**2)/3.0

which illustrates that the user is not required to split-up FOFX.
CSMP uses a Wegstein's accelerated convergence algorithm to calculate X n + 1
using Xn-l, xn,f(Xn-l) andf(xn) with a user-specified initial guess for X.(6) The test
for satisfying the user-specified ERROR is based on
Xn+l - Xnl
Xn+l

I

<

ERROR

for

IX n + 1 I >

1

(3.54)

<

1

(3.55)

or
for Ixn+ll

Generally there will be more than one way of expressing x
case, F(x) = X2 + 3x - 4 = 0, two ways of writing x are
X

=

4 - x2
- 3 - =f(x)

=

f(x). For the

(3.56)

and
x =

±,J4 - 3x =f(x)

(3.57)

The IMPL function results will often depend on the form selected for f(x) as well
as the initial guess. The polynomial, x 2 + 3x - 4 = 0, has roots at x = 1 and
x = -4. Suppose Eq. (3.56) is used to represent f(x). The convergence of the
implicit algorithm may be observed by printing out the variables x and f(x) each
time the program passes through the implicit loop. A short program for this purpose is given in Fig. 3.58. With ERROR = 0.05, the following values of X were
obtained for the indicated initial values of XO.

174

Advanced Features of CSMP

Ch. 3

PARAM XO = -3.0, ERROR = 0.05
NOSORT
X = I~PL(XO,ERROR.FCFXt
A = 4.0/3.0
e = -tx**2t/3.0
FQFXl = A + B
WRITE(6.11 X,FOFXl
1 FORMAT(2E20.10t
FfJFX = A + B
TIMER FINTIM = 1.0, DELT = 0.25, PRDEL = 0.25
PRINT X
TITLE ILLUSTRATION OF I~PlICIT FUNCTION
END

STOP
ENDJOB

Fig. 3.58 Program for printing the values of x and f(x) during
the implicit loop convergence process.

Initial Guess
XO

0.5
2.5
-1.0
-3.0
-6.0

Solution
X
1

1
1

-4
-4

Rather than present a lengthy discussion on how convergence takes place, the
reader is encouraged to submit the previous program of Fig. 3.58 and observe the
trial values of X and FOFXl as the program converges to the final value of X.
If X is expressed by
x = -,v'4 - 3x

(3.58)

solutions for X, using ERROR = 0.05, are as follows
Initial Guess
XO

Solution
X

3.0
-1.0
-2.0
-6.0

-4
-4
-4
-4

We observe that for XO = -1, X converges to +1 in one case and -4 in the
other.

Ch. 3

Advanced Features of CSMP

115

Corresponding to the program in Fig. 3.58 a portion of subroutine Update
will give
30000 X = IMPL( 1, XO,ERROR,FOFX)
IF(NALARM) 30002, 30002, 30001
30001 CONTINUE
A = 4.0/3.0
B = -(X**2)/3.0
FOFX1 = A + B
WRITE(6,1) X, FOFX1
FORMAT(2E20.10)
FOFX =A + B
GO TO 30000
30002 CONTINUE

On first entering the IMPL routine, NALARM is set .equal to 1 and X equal to
XO. The value of FOFX is determined and the program returns to 30000. When
the error criteria is satisfied, NALARM is set to zero and X set equal to the last
value of FOFX. The program goes to 30002 and continues in the simulation. If
the error criteria is not satisfied after 100 iterations, NALARM is set to -1 and
the run is terminated with a message stating that 100 iterations have been exceeded.
The entire implicit function may be considered as a functional block with X
as the output variable. Occasions may arise in which intermediate variables defining the implicit function are required for calculations elsewhere in a program. In
such cases, extreme care must be exercised to avoid erroneous results. If at all
possible, the desired intermediate variables should be recalculated outside the implicit loop. However, it may be possible to define the intermediate variables as
outputs from either a procedure function or a user-defined macro which contains
the entire implicit loop. Example 3.16 illustrates the use of a macro for this purpose.
Rules and guidelines for using the IMPL function can be summarized as
follows.
I As many statements as desired may be used to define/ex); however, the output name in the last statement of the definition must be identical to the
third argument, FOFX, of the IMPL statement. The output name for FOFX
cannot be the output of an expression containing an INTGRL block nor
can it be the output of a user defined macro, procedure or user-supplied
routine. The last statement in the implicit loop cannot be continued.
2 The implicit variable must appear on the right side of an equal sign at least
once in the statements defining FOFX.
3 An implicit loop can be defined within a macro or procedure provided the
entire set of required statements is contained within the macro or procedure.
4 An implicit loop cannot be defined within another implicit loop.

176

Ch.3

Advanced Features of CSMP

Example 3.15
Consider the circuit diagram of Fig. 3.57(a) which was earlier described by the
equations
(3.59)
Vo(t) = i(t)R2
i(t)

=

~n(t) _ Vit)
Rl

Rl

(3.60)

A simple CSMP program for the solution of i(t) and the resulting output is

PARAM R1 = 8.0, R2 = 2.0
VIN = 10.0*STEP(0.0)
VO = IA*R2
IA = VINjR1 - VOjR1
TIMER FINTIM = 1.0, DELT = 0.25, PRDEL = 0.25
PRINT IA
END
STOP
ENDJOB
SIMULATION INVOLVES AN ALGEBRAIC LOOP CONTAINING THE
FOLLOWING
ELEMENTS
VIN
VO
IA
********PROBLEM CAN NOT BE EXECUTED********
The algebraic loop can be broken by using the implicit function shown below.

PARAM R1 = 8.0, R2 = 2.0, lAO = 2.0, ERROR = 0.05
VIN = 10.0*STEP(0.0)
IA = IMPL(IAO, ERROR, FOFIA)
= VINjR1
A
VO = IA*R2
B
= -VOjR1
FOFIA = A + B
TIMER FINTIM = 1.0, DELT = 0.25, PRDEL = 0.25
PRINT IA
END
STOP
ENDJOB
The output from the PRINT request is

TIME
0.0
2.5000E-01
5.0000E-01
7.5000E-01
1.0000E 00

IA
1.0000E 00
1.0000E 00
1.0000E 00
1.0000E 00
1.0000E 00

The initial value of IA is specified on the PARAM card as lAO = 2.0 and the acceptable
error as ERROR = 0.05. Note that FOFIA is the last statement used in defining IA and
also corresponds to the third argument in the IMPL function.

Ch.3

Advanced Features of CSMP

111

Example 3.16

The diagram of a feedback system which does not contain a memory function is
shown in Fig. 3.59. An unaware user may write the following program only to find that
the simulation involves an algebraic loop.
OUTPUT

Fig.3.59 Diagram for Example 3.16. (This diagram does not
contain a memory function.)

PARAM K =0.6
INPUT = STEP(O.O)
E
= INPUT - OUTPUT
Xl
= K*E
OUTPUT = LEDLAG(1.0, 1.0/5.0, Xl)
METHOD RKSFX
TIMER FINTIM = 2.0, DELT = 0.05, PRDEL = 0.1
PRINT OUTPUTt
END
STOP
ENDJOB
The algebraic loop can be broken by making OUTPUT an implicit function in the following manner.
PARAM OUTO = 0.2, ERROR = 0.05, K = 0.6
INPUT = STEP(O.O)
OUTPUT = IMPL(OUTO, ERROR, FOFOUT)
E
= INPUT - OUTPUT
Xl
= K*E
FOFOUT = LEDLAG(1.0, 1.0/5.0, Xl)
METHOD RKSFX
TIMER FINTIM = 2.0, DELT = 0.05, PRDEL = 0.1
PRINT OUTPUTt
END
STOP
ENDJOB
The response of the system has a discontinuity at time equals zero and hence a fixed-step
integration method is used to avoid computational difficulties with the variable-step integration. The printed output from the program is shown in Fig. 3.60. One can easily verify
by analytical methods that the values for OUTPUT are correct.
tOUTPUT is acceptable for S/360 CSMP but should be changed to another variable for
CSMP III.

178

Advanced Features of CSMP

Ch.3

PRINTED OUTPUT FOR LEDlAG ALGEBRAIC LOOP
Tt~E

0.0
1.OOOOE-Ol
2.0000E-Ol
3.0000E-Ol
4.0000E-Ol
5.0000E-Ol
b.OOOOE-01
1.0000E-Ol
8.0000E-Ol
9.00 GOE-01
1.0000E 00
1.1000E 00
1.20COE 00
1.3000E 00
1.4000E 00
1.5000E 00
l.bOOOE 00
1.1000E 00
1. BOOOE 00
1.9000E 00
2.00COE 00

OUTPUT

1.5000E-01
b.8202E-01
6.2631E-OI
5.8080E-01
5.4350E-01
5.1296E-Ol
4.8195E-01
4.6747E-01
4.501lE-01
4.3699E-Ol
4.2515E-01
4.1655E-Ol
4.0902E-01
4.0285E-Ol
3.9180E-Ol
3.9361E-Ol
3.9029E-01
3.8152E-01
3.852 5E- 01
3.8339E- 01
3.8181E-Ol

Fig. 3.60 Printer output from the algebraic loop containing the

LED LAG function.
Now suppose that one desires to evaluate the integral of E2 which is often a meaningful index of performance. For this problem, this can be accomplished simply by adding
the statement, ISA = INTGRL(0.0,E**2), outside the implicit loop. As an alternate
approach, E may be expressed as the output of a macro and incorporated into a program
as follows.
MACRO E, OUTPUT = CHECK(OUTO, ERROR, K, INPUT)
OUTPUT = IMPL(OUTO, ERROR, FOFOUT)
E
= INPUT - OUTPUT
Xl
= K*E
FOFOUT = LEDLAG(1.0, 1.0/5.0, Xl)
END MAC
PARAM OUTO = 0.2, ERROR = 0.05, K = 0.6
INPUT = STEP(O.O)
E, OUTPUT = CHECK(OUTO, ERROR, K, INPUT)
ISA = INTGRL(O.O, E**2)
METHOD RKSFX
TIMER FINTIM = 2.0, DELT = 0.05, PRDEL = 0.1
PRINT E, ISA, OUTPUT
END
STOP
ENDJOB
In summary, the implicit function can often be used for breaking an algebraic loop.
The user however should be aware that the specified initial value and the user-selected
form of [(x) can influence the solution. Normally, the user will know the general results
expected from the simulation. Therefore, if an unexpected (or unwanted) solution is

Ch.3

Advanced Features of CSMP

179

obtained when using the IMPL function, one should try several different initial conditions
and perhaps change the form of f(x).

REFERENCES
1. System/360 Continuous System Modeling Program System Manual Y20-011l, IBM
Corporation, Data Processing Division, White Plains, N.Y.
2. MCCRACKEN, DANIEL D., A Guide to FORTRAN IV Programming. New York: John
Wiley and Sons, Inc., 1972.
3. COOPER, LAURA, and MARILYN SMITH, Standard FORTRAN: A Problem-Solving
Approach. Boston: Houghton-MifHin Company, 1973.
4. HOLDEN, HERBERT L., Introduction to FORTRAN IV, New York: The MacMillan
Company, 1970.
5. ANDERSON, DECIMA M., Computer Programming FORTRAN IV, New York: AppletonCentury-Crofts, 1966.

6. Continuous System Modeling Program III (CSMP III) Program Reference Manual
SH-19-7001-2, Program Number 5734-X59, IBM Corporation, Data Processing Division, White Plains, N.Y.
7. SAGE, ANDREW P., Optimum Systems Control, Englewood Cliffs, N.J.: Prentice-Hall,
Inc., 1968.

PROBLEMS
1 Using the END and/or CONTINUE card, solve for the time-history of the value of
a bank account over a four~y~ar period. One hundred dollars is deposited at the
beginning of the first year at the interest rate of 5 %per year. At the beginning of the
second year the interest rate is increased to 6 %, and at the beginning of the third
year the interest rate is 6.75 %. The fourth year, the interest rate is 7.5 %. Assume
that money is continuously compounded according to the following formula.
d$
dt

where i

=

=

i$

yearly interest rate (0.05, 0.06, 0.0675, 0.075)

Answer:
At end of fourth year, $

=

128.72

2 A linear transfer function that can be used to approximate the response of a human
operator to a visual command in turning a steering wheel is shown below. The input
is a unit-step input.
()
IN(S)

~-

(1.2s

(1.6s + l)(O.lls + l)e- O• 2s
+ 1)(0.15s + 1)(0.OO35s 2 + 0.084s + 1)

~

()

o(s)

Determine the response of the man to a unit-step input. Note that the e- o. 2s term
represents a pure time delay of 0.2 sec.

180

Advanced Features of CSMP

Ch. 3

Fig. P3.2

Answer:

At TIME

=

1.0, (Jo

=

1.1874

3 A real estate purchase of $42,000 is financed for 25 years at an interest rate of 9.5 %.
Write a CSMP program to calculate the monthly paymerits, the amount paid in
interest each month, and the amount paid on the principal each month.
Answer:

Monthly payment = $366.95, at the tenth month interest = $329.97,
principal = $36.98
4 Consider the system represented in the following diagram.
Output 1

Output 2

Fig. P3.4

If Input 1 and Input 2 are unit-steps applied at t

=

0, find the responses of Output 1

and Output 2.
Answer:

At TIME

=

1.2, Output 1

=

0.39523, Output 2

=

0.12559

5 The location of a hole is given by the X and Y dimensions. Assume that the X dimension varies between 11.900 in. and 12.100 in. with a uniform distribution and Y
dimension has a Gaussian distribution with a mean of 5.000 inches and a standard
deviation of 0.100 inches.

Fig. P3.S

Ch.3

Advanced Features of CSMP

181

How many parts in a production run of 1000 will have a radius R outside the
tolerance of R = 13.000 ± O.1oo?
Answer:

13'5 parts

6 Use subscripted variables and the array form of the integral statement to solve the
following set of equations that describe a mechanical system. The system is initially
at rest.
ml X l
m2 x 2
m3x3

where

ml
kl

+ (k 1 + k 2)Xl + eXl - k2X2 + (k2 + k 3)X2 + eX2 - k2Xl + k3X3 - k3X2 = 12 sin (4.0t)

= 2.3, m2 =
= 19.0, k2 =

= 0.9
45.0, k3 = 12.0, c =
3.4,

eX2

=0

eXl -

k3X3 =

0

m3

0.8

12 sin (4.0t)

X2

Fig. P3.6

Answer:

At TIME = 2.0,

Xl

=

-0.2075,

X2

=

-0.2707,

X3

=

0.4517

7 The gas pressure acting across a small caliber bullet varies with the distance traveled
by the bullet down the barrel of the gun.
The following table gives this pressure-distance relationship for a 26 in. barrel.

X, in.

Pressure
Ib/in. 2

0
1.0
2.0
3.0
4.0
5.0
6.0
8.0
10.0
12.0
15
18
21
26

5,500
13,000
22,500
27,700
30,200
29,000
27,500
22,000
16,000
11,100
6,200
4,100
3,750
3,540

182

Advanced Features of CSMP

Ch. 3

Pressure

IG;~
~...J 180 grain bullet

Ii

X

Fig. P3.7

Assume the diameter of the bullet is 0.300 in. and weighs 180 gr (0.0234Ib). The
frictional drag on the barrel is to be considered small compared to the gas force.
Use Newton's second law to find the time required for the bullet to leave the
barrel and the muzzle velocity. Compare answers using the NLFGEN and AFGEN
arbitrary function generators.
mX =PA
Answers:

Using AFGEN
v
Using NLFGEN v

=
=

27546 in./sec
27512 in./sec

8 An automobile costing $4000 is financed for 36 months with monthly payments of
$130.50. The annual effective compound interest rate for this loan can be determined
by solving the expression
Iannual =

+ i)12

(1

- 1

where Iannual = annual effective compound interest rate expressed in decimal form
(not per cent)
i

=

interest rate per month expressed in decimal form

The solution for i (rate per month) can be found from
(1
an/i =

+ i)n + i)n

1

i(1

where in this case
an/i

4000

= 130.50 = 30.651

and n = 36. An implicit expression for i can therefore be written as
.
1

(1+i)n-l

= 30.651(1 + i)n

Develop a CSMP program using the IMPL function to solve for i. Include a statement in your program for finding Iannual' Use PRINT to give the values of Iannual and
i. What effect does the initial guess for i have on the solution for i? Use i = 0.01 and
i = 5.0 as initial values and error = 0.00001.
Answers:

For i (initial) = 0.01, i = .0089613,
For i (initial) = 5.0, same answers

Iannual

= .11298

9 Use the multiple run capability of a PARAMETER card to solve Mathieu's equation
for the following values of a

a

=

b

= 2.0, OJ

0.5, 1.5, 3.0, 5.0
=

3.0

Ch. 3

Advanced Features of CSMP

183

Mathieu's equation is

d 2y

dt 2

+ (a yeO)

2b cos rot)y

= yeO) =

0

=

2.0

Answers:
At TIME

1.0

=

a
a
a
a

y = 4.979
y = 3.669

y = 2.046
= 0.4326

y

=
=
=
=

0.5
1.5
3.0
5.0

10 The figure below shows a tapered beam with an axial load of 10,000 lb and a uniform load of 72 lb/in. The differential equation describing the deflection of the beam
is
d 2y
M = moment due to uniform lead + py
El dx2 =-M
Using the CALL RERUN statement, find the deflection of the beam.
Uniform load

x

~'

"

Y

-l-

= 72 Ib/in.

~

THCCQ?-i. .

t---

=0

H

~

B
E

I

x

= 10 - 0.6 Vx
= width = 4.0 in.
= 1.4 x I 0 6 psi

1O,0001b

= 100 in.

= BH3/12

Fig. P3.10

Answer:
Ymax

0.388 in.

=

at X

=

66 in.

11 The acceleration indicated by an accelerometer is given by the following formula.
A =

ro;z

The equation of motion of the seismic mass is

+ 2'ronz + ro;z =

i

ji

z

I
Fig. P3.11(a)

184

Advanced Features of CSMP

Ch. 3

Using the multiple run capability of the PARAMETER and END cards, find
the indicated acceleration reading for the four combinations of natural frequencies
and damping ratios. The input acceleration is shown below.
1. ron
10 rad/sec
0.1
2. ron
10 rad/sec
0.7
3. ron
100 rad/sec
0.1
4. ron
100 rad/sec
0.7

=
=
=
=

,=
,=
,=
,=

3860/sec2

y

0.4

0.5

Fig. P3.11(b)

Time

Answers:

Case
Case
Case
Case

1
2
3
4

At TIME = 0.4, A =
At TIME = 0.4, A =
At TIME = 0.4, A =
At TIME = 0.4, A =

4054.0
2430.0
3839.0
3725.0

12 A steel cantilever beam has a distributed load as shown below.
w(x

= 15) = 121b/in.

y

b

x
~--------------------------------,~
E = 30 x 106 psi
x = 30 in.

= 2 in.

~h=lin.
3

1= bh
12

= 1 in4
6

Fig. P3.12

The equation which describes the shape is the following fourth order differential
equation.

d 4y

w(x)

dx 4 = -

E1

w(x) = density of the distributed load

Using the following boundary condition on the left end and the AFGEN function to represent the density of the distributed load, solve for the deflected shape of
the beam.
yeO)

= d~~) =

d 2y(0)

dx 2
d 3y(0)

2700
=

-

180
(lX3= E1

E1

0

Ch. 3

Advanced Features of CSMP

185

Answer:

At x

=

=

30, y

-0.111 in.

13 The approximate dimensions of the cross-section of a railroad rail are given by the
following table.
y

o

6
6
1.7
1.0
0.65
0.8
0.95
1.2
2.9
2.9
1.0

0.5
1
1.3
3.0
4.7
4.9
5.0
5.3
6.4
6.55

O---L..-.------+-------'
Fig. P3.13

Use the AFGEN function to approximate the shape of the rail and find the
center of mass and the moment of inertia about line 0-0. The moment of inertia is
given by the following formula.

1=

f

y 2 t dy

Answer:
y cg = 2.87 in.

1= 171.9 in.4

14 The transfer function of a system is given by
yes)
U(s)

12

=

(s

+ 2)(s + 6)

186

Advanced Features of CSMP

Ch. 3

A unit-step input is applied to the system. It is desired to sample the output signal,
yet), every 0.04 sec as shown in the diagram below.
U- __- - I
(s
Step input

12

+ 2)(s + 6)

I--Y-X0.04
T =

Write a CSMP program which outputs the sampled signal. Use the IMPULS function
for modeling the sampler.
Answer:
y = 0.76307 at TIME = 0.72 using variable-step integration.

15 The following equations describe the motion of a top spinning about a frictionless
pivot point. The only external torque is due to gravity.

o= I'til

rjJ

=

2

sin Bcos B - I(~

+ til cos B)tiI sin B + WD sin B

I'
-2I'Otil cos B + I(~ + til cos B)O
I' sin B
tilO sin B - rjJ cos B

~ =
I = moment of inertia of top about spin axis = 0.001 Ib-in-sec 2
I' = moment of inertia of top about a line perpendicular to the spin axis and through
the pivot point = 0.04 Ib-in-sec 2
W = weight = 0.8 lb
D = 2.0 in.
---()

cp

Spin axis

Fig. P3.1S

Find the motion of the top for the following initial conditions. Note the singularity at (J = O.

rp = til = 0, ~ = 500 radians/sec, B = 1.0 radians, 0 = 0.5 radians/sec
Answer:

At TIME = 1.0 sec, B = 63.83°, 'II = 200.55°, ~ = 499.31 rad/sec

16 The difference equation for a low pass filter can be expressed as
y(kT) = (1 - rt)x(kT)

+ rty[(k -

I)T]

Ch.3

Advanced Features of CSMP

for ~ less than 1. For this case select
given by
x(t)

= 0.8 and T = 0.1. The input signal, x(t), is

~

=

t

187

+ 0.5 sin (611:t)

Write a CSMP program which (a) gives the input signal x(t) every 0.1 sec; and (b)
gives the filtered signal y(t) every 0.1 sec. t
Answer:

At TIME = 4.1, x(t) = 4.5755, y(t) = 3.7666
17 A classical problem in the calculus of variation is to determine the path of quickest

descent-the brachistochoe problem. This problem involves finding the curve between
two points that a sliding particle would descend in the minimum time. The exact
curve is a cycloid.
x

0,0

......-Sliding particle

y

= f(x)

y

Fig. P3.17

The time required for a mass to slide down a curve under uniform gravity is
given by the following expression.
__1_
t -

,.j2g

fX /1 + y'2 d
'V-y- x
0

Using Euler's equation, the above integral can be minimized by the solution to
the following differential equations
y'

=

~~

-

1

The value of c = 30.32 will yield a solution that will pass through the following
point: x = 25, y = 25.9. Using this value of c, solve the above equation to determine the shape of the curve. Note that in integrating the above expression for y', it
is necessary to add a small number (10- 6 ) to y to avoid dividing by zero at the start
of the integration. Also, it is necessary to use a small step size at the beginning of the
integration. Use the CONTINUE card to increase the step size of a fixed-step size
integration method (RKSFX) after x = 0.5.
Answer:

At x = 25, y

=

tSee Problem 18, Chap. 4 for additional comments.

26.01

188

Advanced Features of CSMP

Ch. 3

18 Consider the first-order differential equation given by

d~~t) + 3y(t)

= u(t)

yeO) = 0

where u(t) is a unit-step defined to be 1 for t greater than or equal to zero and zero
for t less than zero. One approach for numerical solution to this equation is to use the
Tustin approximation for differentiation. In such case

d~~) - + ~ [;

+!J

Y(z)

where T is the time between numerical iterations and z is the z-transform variable.
Using this approximetion one writes

[z +- 1IJ Y(z) + 3Y(z) =

2 z
T

U(z)

which yields

T
Kl =2+3T'

Using the left shifting property of z-transforms gives the difference equation
y(kT) = K 1[u(kT)

+ u((k -

I)T] - K2y((k -

I)T)

(a) Solve the original differential equation using the standard INTGRL function of
CSMP. Use trapezoidal integration (i.e., METHOD TRAPZ) with DELT = 0.1.
(b) Write a CSMP program which solves the difference equation. Use T = 0.1.
Compare the results with that of part (a).
Answers:

At TIME

=

1.0, yet)

=

0.31578 [part (a)], yet)

=

0.31711 [part (b)]

19 The steady-state current for a 60 hertz-120 volt input to the circuit below is given by

the following expression.

.

[

Ri + L2OJ2

1 = 120 L2OJ2(R 1

+ R 2)2 + (R 1R 2)2

J1/2

OJ

= 120n

The phase angle of the current can be expressed as

cp = tan-1 (LOJ) _ tan- 1 [LOJ(R 1 + R 2)J
R2

120 volts
60 hertz

RIR2

L

Fig. P3.19

rad/sec

Ch. 3

Advanced Features of CSMP

189

The values of the resistances and inductance with the appropriate tolerances
and standard deviations are:
Rl

=

10 ohms (± 10%),

O'RI

R2

=

60 ohms (± 20 %),

0' R2 =

L

= 0.18 henries (± 20%),

O'L

=

0.33 ohms
4.0 ohms

= 0.012 henries

Use the GAUSS function to calculate the current and phase angle for gaussian
distributed random values of Rt, R 2 , and L. Find the average and standard deviation
of both the current and phase angle for 300 different combinations of parameters.
An expression for the standard deviation is:
n
0'

x -

±xi' _ (± X/)2]1/2

/=1

[

/=1

n(n - 1)

Answer:
i ave

=

0'/ =

2.294 amps,
0.104 amps

CPave =

0'",=

-

34.29°
2.264°

20 The purpose of this problem is to illustrate how a macro is invoked within another
macro. Consider the general system diagram shown in Fig. P3.20-1. Both subsystem
A and subsystem B can be described by a state equation of the form
=
[~l(t)J
X2(t)

[all
a21

a 12 J [X 1(t)J
a22 X2(t)

+ [btJr(t)
b2

Disturbance A

Output

Fig. P3.20-1

where Xl(O) = ICI and X2(O) = IC2. The program in Fig. P3.20-2 is a proposed
method for writing a single MACRO to describe both subsystems A and B and a
single MACRO to describe both XXA and XXB. Verify that the program is correct.

190

Ch.3

Advanced Features of CSMP

=
=

MACRO Y
STATECAIl.A12,A21.A22,8l,B2.R.ICI.IC2)
XIDOT = AIIOX! • A12 0 X2 • 81 0 R
A2l o Xl • A22 0 X2 • B2 0 R
X200T
Xl
INTGHLCICl.XlDOT)
X2
INTGRLtIC2.X2UOT)
Y Xl
ENDMAC

=
=
=

•

SECOND MACRO FOLLOWS
OUT~ = SIMULACINPUT.GAIN.DIST.SII.S12 ••••
S21,S22,Srll,SB2.SICl,SIC2)
XX
STATECSll.Sl2,S2l.S22.SHl.SB2.GAIN0INPUT.SICl.SIC2)
QQ
INTGRLCO.O.DIST)
OUTX
XX • QQ
ENDMAC
~ACRO

=
=

=

• PARAMETERS FOR THE SUBSYSTEMS FOLLOW
PARAMETER SAAll = 0.0. SAAl2
1.0. SAA2l = -2.0. SAA22 = -3.0 ••••
SABI
0.0. SAB2
1.4. SAGAIN
0.5. SAICI
0.O.SAIC2
0.0
PARAMETER SBAll
0.0. SBA12
1.0. S~A2l
-4.0. SBA22
-5.0 ••••
SBBl
0.0. S8B2
1.0. SBGAIN
2.1. saICl
0.0. SBIC2
0.0

=

=

=
=

=

=
=
=

=

=
=

=

=
=

=

=

INA
STEPCO.O)
DISTA
0.2°SINC400.0oTIME)
INS = STEPCO.U
DISTS
EXPC-O.loTIME)
XXA
SIMULACINA.SAGAIN,DISTA.SAAI1.SAAI2.SAA2l ••••
SAA22.SABl.SAR2,SAICl,SAIC2)
XXB
SIMULACIN~. SBGAIN. DISTB, SBAII. SBAI2. SBA2l ••••
SBA22. SBrll. SBB2.SBICl. S8IC2)
OUTPUT = XXA • XXB
TIMER FINTIM = 2.0, OUTDEL = 0.04
PRTPLT OUTPUTCXXA,XXB)
END
STOP
Fig. P3.20-2

=
=

=
=

Find the response of the system for the inputs, disturbances and system parameters
as given in Figure P3.20-2.
21

Many problems in control theory formerly solved by classical methods ,are now
formulated as an optimal control problem using state space analysis. This problem
illustrates the use of CSMP for simulation of a time optimal control problem in
which the control is expressed in closed form. The state equations for a particular
system are given by

1J [Xl(t)J
+ [OJ
X2(t)
1

u(t)

-rJ-

with initial conditions
Xl(O)

=

XIO

X2(O) = X20

The problem is to find the closed-loop control u(t) such that for any initial set, ~(O),
the system response time for state ~(t) is minimized. Figure P3.21-1 gives a diagram
which expresses the essence of this problem.
The solution for the control u(t) can be expressed as(7)

Ch.3

Advanced Features of CSMP

191

Control
logic

Fig. P3.21-1

which is maximum effort in that u(t) will be either plus or minus one. The solution
for the control logic is obtained from the argument of the sign function and is thus
given by

This equation defines the switching curve as shown in Fig. P3.21-2.
+2

-2

- I

+1

Fig. P3.21-2

192

Advanced Features of CSMP

Ch.3

The program listing for simulating this system is given in Fig. P3.21-3. The complexity of writing a single statement for u(t) can be avoided by grouping the terms of
the switching curve. A conventional FORTRAN statement for the sign of a function
is used in the simulation along with standard CSMP simulation statements. The
FORTRAN statement
y = sign (PbP 2)
takes the value of P l and multiplies by the sign of P 2 •
PARAM ALPHA = 0.4
INCON ICXI = -2.0, ICX2 = 0.0
Xl DOT = X2
Xl = INTGRL(ICXI, XIDOT)
X2DOT = -ALPHA*X2 + U
X2 = INTGRL(ICX2, X2DOT)
GAMMA = ALOG(I.O + ALPHA*ABS(X2»
BETA = SIGN(I.O, X2)/(ALPHA*ALPHA)
RHO = Xl + (X2)/ALPHA
U = -SIGN(l.O, RHO - BETA*GAMMA)
TIMER FINTIM = 3.0, OUTDEL = 0.06
PRTPLT Xl (U ,X2)
LABEL STATE RESPONSE OF Xl AND X2 FOR TIME OPTIMAL
CONTROL
END
STOP
END JOB
Fig. P3.21-3 Program listing for time optimal control.

The time optimal response, starting from any point in the Xl, X2 plane should respond
under control of maximum effort u(t) until the system trajectory reaches the switching
curve. At this point the sign of the control is reversed and the system should follow
the ideal switching curve to the origin. Use the program above with ICXI = -2 and
ICX2 = 0 and find the system response for Xl(t) and X2(t). Use a FINTIM of 3.0
and an OUTDEL of 0.06. Verify that the response intersects the switching curve and
then proceeds to the origin.
Answer:

At TIME = 2.1, Xl = -0.36077, X2 = 0.05055, U = -1.0

4
FURTHER APPLICA TION
OF CSMP

The types of problems which can be simulated with CSMP are practically
unlimited. Consequently, examples in Chaps. 2 and 3 were rather general and specifically selected to illustrate basic features. For the most part, these earlier chapters
present those attributes of the program which are required in the majority of
simulations. The material in Chap. 4 is somewhat more limited in scope but nevertheless relates to important engineering applications.
One normally views CSMP as a tool for obtaining the transient or dynamic
response of a system of equations. In the first part of this chapter, however, two
methods are given for obtaining the steady-state frequency response of a system.
One of these methods relies on direct application of the system transfer function:
the Laplace variable s is replaced by jro and the response is obtained as a function
of ro. The second method uses transient response information to find the frequency
response.
The second topic of the chapter deals with particular block diagram forms of
transfer functions and illustrates how these diagrams can be used to formulate the
system state-variable equations. An example is given in which the state equations
are solved using CSMP.
Real-time digital control has become increasingly important with recent
technological development in the minicomputer and microprocessor field. Therefore, a section is included which gives the basic concepts for simulating direct
digital control. The material covers sample and hold simulation, recursive digital
control algorithms, and the digital three-mode (PID) controller. Anyone involved
with real-time digital control will find this material to be helpful in evaluating the
performance of proposed computer control systems.
Although CSMP is normally viewed as a software package for simulating
continuous systems, the program also has the capability of simulating digital
193

194

Further Application of CSMP

Ch. 4

logic. The final section in this chapter presents an introduction to logic simulation
and thus provides a method for investigating the performance of purposed configurations without actually building hardware realizations.

Frequency Response
The concept of frequency response is well known in most scientific fields,
particularly physics and engineering. (1-4) Basically this concept arises when considering an nth order, linear, differential equation with constant coefficients. In
particular, if such an equation is written as
dnx(t) +
dn- 1x(t) + ... + dx(t) +
(t)
dtn
an- 1 dtn-1
al dt
aox

m
dtm

m
dtm

= bmd J(t) + b _ d - 1 J(t)
and J(t)

m

1

1

+ ... + b

1

dJ(t)
dt

+ b J(t)
0

(4.1)

= F sin rot, the steady-state solution for x(t) can be expressed as

+ if»

(4.2)

I X(jro) I = IA(ro) + jB(ro) I

(4.3)

if> = tan- 1[B(ro)/A(ro)]

(4.4)

x(t) = IX(jro) Isin (rot
where
and

The question arises as to whether CSMP can be effectively used to calculate
the frequency response of a system. The answer is a qualified yes. We have seen
that if the transfer function or differential equation of a system is known, the
response of the system to any forcing function can be determined using INTGRL,
REALPL, LED LAG, CMPXPL, and user-defined transfer function macros. If
the forcing function is selected as a sine wave, the response of the system in steady
state will yield the I X(jro) I and if>. This, however, is a rather awkward approach in
that CSMP must go through the transient portion of the solution for each frequency before reaching steady state. The transient calculations are wasted computer time with respect to determining the steady-state solution. Thus, even though
CSMP can be used to determine the frequency response, excessive computer time
is required if the procedure described above is followed. Only in rare instances,
such as calculating the response for one or two frequencies, could one justify using
this procedure.
While the above method should generally be avoided, there are other approaches to finding the frequency response using CSMP. Two methods are given
below. For the first method a macro is developed and the response determined
without using integrators. The second method uses an array of integrators and is
applicable to finding the frequency response directly from measured time-domain
data.

Ch. 4

Further Application of CSMP

195

Frequency Response Without Integration
Consider a transfer function of the form
G( )

s

=

+ N sS4 + N 4S 3 + N3 S2 + N 2s + Nl
+ D S4 + D4S3 + D3S2 + D 2s + Dl

N6 S5
D6S5

(4.5)

S

Replacing s by j(f), multiplying out, and collecting real and imaginary terms gives

(4.6)
Define

Xl = (N s(f)4 - N3(f)2

+N

X 2 = (N 6(f)s - N 4(f)3

+ N 2(f)

=
X4 =

X3

l)

(D6(f)S -

+ D l)
D4(f)3 + D 2(f)

G(j(f)

Xl

(Ds(f)4 - D3(f)2

(4.7)

giving
=

X3

+ !X2
+ jX

(4.8)

4

Rationalizing the expression for G(j(f) yields
G(' )
j(f)

=

(Xl X 3 + X 2X4) + j(X2X3 - X l X4)
(X~ + Xn

(4.9)

We therefore have from Eq. (4.8)

.

[Xi + X~Jl/2

IG(j(f) 1= X~ + X~

(4.10)

and from (4.9)
(4.11)
To compute the frequency response, various values of (f) must be used to calculate
Xl' X 2 , X 3 , and X 4 •
The values assigned to (f) will normally depend upon the intended application.
Typically, linear increments of (f) are used for Nyquist plots whereas logarithmic
increments are used for Bode diagrams. The frequency increments will be equally
spaced on a log scale provided,
i

where

m
(f)min

A

=

0, 1, 2, ... , m

= the total number of steps over the frequency range

= starting value of (f)
= 1/(the number of desired points per decade)

(f)i = (f) for the ith point

(4.12)

196

Ch. 4

Further Application of CSMP

The natural stepping variable of CSMP is the program variable TIME. The
equations for the frequency response developed above are, however, not functions of time. Nevertheless, the index ia can be replaced by TIME if TIME is
incremented by 0, a, 2a, 3a, ...... , rna. When integration is not specified in
CSMP, the increments of TIME can be controlled by the value of DELT given on
the TIMER card. The following example illustrates how these observations may be
used for obtaining the frequency response.
Example 4.1

The transfer function of a system is given by
25

G(s) =

S2

+ 3s + 25

(4.13)

The frequency response is desired over the range OJ = 0.1 to OJ = 10 radians/sec with
20 equally spaced log steps per decade.
A program for this purpose is given in Fig. 4.1. In this program a procedural macro
is used to calculate IG(jOJ) I and /G(jOJ). The coefficients ofthe transfer function are placed
into the program using the STORAGE and TABLE features. Frequency is incremented
by the equation
(4.14)
OMEGA = WMIN*(10.0**(TIME»
~ACRO FASE, MAG = FREO(N,D,OMEGA)
PROCEDURAL
Xl
N(5)*(OMEGA**4)-N(3)*IOMEGA**2)+Nlll
Xl = N(6)*ICMEGA**5)-N(4)*(OMEGA**3)+N(2)*0~EGA
X3 = D(5)*(0~EGA**4)-C(31*(OMEGA**2)+D(l)
X4 = D(6)*(CMEGA**5)-D(4t*COMEGA**3)+O(2)*OMEGA
MAG = (SQRT(Xl*Xl+XZ*X211/CSQRTlX3*X3+X4*X4»
CONV = 57.29578
XREAl = XI*X) + X2*X4
XIMAG = X2*X3 - X1*X4
FASE = (ATAN2CXIMAG,XREAL»*CONV
IFCFASE)2, 2, )
3
FASE = FASE - 360.0
2
CONTINUE
ENOMAC
INITIAL
PARAM WMIN = 0.1, WMAX = 10.0
DYNAMIC
STORAGE NUM(61, OEN(6)
TARLE NUM(l-61 = 25.0, 5*0.0, •••
DENCl-6) = 25.0, 3.0, 1.0, 3*0.0
NOSORT
OMEGA = WMIN*(lO.O**(TIME»
PHASE, VALUE = FREQ(NU~,DEN,OMEGA)
FINISH CMEGA = WMAX
*
SET OUTDEL EQUAL TO ("IE OVER T~E NU~BER ~F STEPS PER DECADE
TIMER FINTIM =.4.0, DUTOEL = 0.05, DELT = 0.05
PRTPLT VALUECOMEGA,PHASE), PHASECOMEGA,VALUE)
LABEL OUTPUT FOR EXAMPLE 4-1
END
STOP
ENOJOB

Fig. 4.1 Frequency response program listing using a procedural
macro.

Ch. 4

197

Further Application of CSMP

The value of TIME is incremented as the smallest value ofDELT and OUTDEL. Termination of OMEGA is governed by FINTIM or the finish statement, FINISH = WMAX.
One must be careful in specifying FINTIM in this case. When TIME = FINTIM,
OMEGA will be (romin)lOFINTIM. For FINTIM = 4 the maximum OMEGA is 10,000
times rom in which gives 1000 for romin = 0.1. Obviously, in this case the FINISH statement will terminate the run.
The form of output can be selected by the user. The customary Bode diagram will
be obtained if printer-plots of magnitude and phase are requested. As shown on the output in Fig. 4.2, TIME is still listed in the first column and should be ignored except to
observe that its increments vary according to the value of OUTDEL. The actual value of
OMEGA can be listed on the plots by specifying it as an argument of the requested
PRTPLT variable. For example
PRTPLT VALUE (OMEGA)
The program was. written for any transfer function with up to a maximum of a fifthorder numerator and denominator. The macro could be extended to a more general case,
for example a tenth-order numerator and denominator, but at the sacrifice of using more
CPU time.
Frequency Response Using Array
Integrators

A transfer function is defined as the ratio of the Laplace transform of the output to the Laplace transform of the input when the system has zero initial conditions. As noted in the previous section, a transfer function can be defined only for
linear, time-invariant, systems. The frequency-response function can be determined
from the transfer function by replacing s with jro. We can then write

f::
f::

Jrot

.
X( 'ro)
x(t)e- dt
G(Jro) = _J_ = - - , - : - - - - F(jro)
J(t)e- Jrot dt

(4.15)

where X(jro) and F(jro) are the Fourier transforms of x(t) and J(t) respectively.
These integrals are defined provided they are absolutely convergent. This is shown
by

f:: I

x(t)e- Jrot Idt

=

f:: I

x(t) Idt

<

00

(4.16)

and similarly for the integral involving J(t). If x(t) and J(t) are zero for t
Eq. (4.15) becomes

< 0,

fOO x(t)e- Jrot dt

G(jro)

= -=-'::':-----

f

0

(4.17)

J(t)e- Jrot dt

Evaluating these integrals gives another method for finding the frequency response.
From the standpoint of a numerical integration one would never attempt to evaluate the integral over the range (0, 00). Thus, from practical considerations, the

OUTPUT FOR EXAMPLE 4-1

PAGE
MINIMUM
2.3506F-Cl

....

=

TI ~E
0.0
5.0CCO!:-02
1.0COOE-OI
1.5000E-Ot
2.00COE-01
2. 5000E- 01
3.0000E-OI
3.5000E-Ol
4.0000E-Ol
4.5000E-Ol
5. OOOOE- 01
5.5000E-Ol
6. OOOOE-Ol
6.5COOE-Ol
7.0000E-Ol
1.5000E-Ol
8.0000E-01
8.5CCOE-OI
9.0000E-OI
9.5000E-OI
1.0000E 00
I.0500E 00
1.1000E 00
1.1500E 00
1.2000E 00
1.2500E 00
1.3000E 00
1.3500E 00
1.4COOF. 00
1.4500E 00
1.5000E 00
1.5500E 00
1.6000E 00
1.6500E 00
1.7000E 00
1.7500E 00
1.8000E 00
1.8500E 00
1.9000E 00
1.9500E 00
2.0000E 00
2.05COE 00

VALUE
1.0003E CO
1.0004E 00
I.0005E 00
1.0007E 00
1.0008E 00
1.0010E 00
I.0013E 00
1.0016E 00
1.0021E 00
1.0026E 00
1.0033E 00
1.0041E 00
1.00521: 00
1.0066E 00
1.0083E 00
1.0105E 00
1.0132E 00
1.0166E 00
1.0210E 00
1.0266E 00
1.033bE 00
1.0426E 00
1.0541E 00
1.0b88E 00
1.0871E 00
1.1121E 00
1.1439E 00
1.1856E 00
1.2405E 00
1.3132E 00
1.4086E 00
1.5290E 00
1.6b16E 00
1.7459E 00
1.6627E 00
1.3794E 00
1.0402E 00
7.6003E-Ol
S.5637E-01
4.1224E-Ol
3. 0950E-.0 1
2.3506E-Ol

I

VALUE

VER.SUS TIME

1

MAXIMUM
1.7459E 00
I

-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
-------------------------+
--------------------------+
--------------------------+
--------------------------+
--------------------------+
---------------------------+
---------------------------+
----------------------------+
-----------------------------+
------------------------------+
-------------------------------+
---------------------------------+
-----------------------------------+
--------------------------------------+
------------------------------------------+
-----------------------------------------------+
-------------------------------------------------+
-----------------------------------------------+
-------------------------------------+
--------------------------+
-----------------+
----------+
-----+
--+
+
Fig. 4.2 Printer-plot of the frequency response amplitude using
log OJ steps.

OMEGA
1.0000E-01
l.1220E-01
1.2589E-Ol
1.4125E-01
1.5849E-01
1.7783E-Ol
1.9953E-01
2.2387E-OI
2.5119E-Ol
2.8184E-Ol
3.1623E-Ol
3.5481E-Ol
3.9811E-OI
4.4668E-Ol
5.0119E-Ol
5.6234E-OI
6.3096E-Ol
7.0794E-Ol
7.9433E-01
8.9125E-Ol
l.OOOOE 00
1.1220E 00
l.2589E 00
1.4125E 00
1.5849E 00
1.1783E 00
1.9953E 00
2.2381E 00
2.5119E 00
2.8184E 00
3.1623E 00
3.5481E 00
3.9811E 00
4.4668E 00
5.01l8E 00
5.6234E 00
6.3095E 00
7.0194E 00
7.9432E 00
8.9125E 00
9.9999E 00
1.1220E 01

PHASE
-6.8779E-OI
-7.7178E-Ol
-8.6606E-Ol
-9.7187E-OI
-1.0907E 00
-1.2240E 00
-1.3738E 00
-1.5419E 00
-1.7309E 00
-1.9432E 00
-2.1819E 00
-2.4504E 00
-2.7525E 00
-3.0929E 00
-3.4766E 00
-3.9098E 00
-4.3991E 00
-4.9546E 00
-5.5850E 00
-6.3033E 00
-7.1250E 00
-8.0691E 00
-9.1626E 00
-1.0431E 01
-1.1938E 01
-1.3128E 01
-1.5896E 01
-1.8513E 01
-2.l958E 01
-2.6368E 01
-3.2311E 01
-4.0618E 01
-5.2539E 01
-6.9360E 01
-9.0452E 01
-1.1143E 02
-1.2804E 02
-1.3918E 02
-1.4797E 02
-1.5384E 02
-1.5820~ 02
-1.6155f. 02

Ch. 4

Further Application of CSMP

199

range must be limited to a finite practical upper bound, tf' The expression for
G(jro) can be viewed as
x(t)e- joot dt + foo x(t)e- joot dt
G(jro) = ~!~
(4.18)
J(t)e-joo dt
J(t)e- joot dt

f!

+ f t!

So

If the integration process is terminated. after t" error in G(jro) will result according
to the remaining integrals evaluated from t f to 00.(5)
Let the input to a system be a pulse of duration t f/2 where the t f selected is
large enough to cover the range of the transient response shown in Fig. 4.3. The

INPUT

OUTPUT

System

Fig. 4.3 Typical time comain signals for determining frequency
response.

input signal is not required to be an ideal pulse but should contain sufficiently
high harmonics to cover the frequency range of interest for G(jro). G(jw) can be
written as

. _f~ x(t) cos (rot) dt -

G(Jro) -

j

f~ x(t) sin (rot) dt

st! J(t) cos (rot) dt - j ft! J(t) sin (rot) dt
o

(4.19)

0

Suppose the frequency response is desired at the frequency points
Determining G(jroi ) requires that 84 integrals be evaluated. In particular, if
G('ro)
J

=

A(jroi ) - jB(jroi)
C(jro) - j D(jroi )

(4.20)

then

i=1,2, ... ,21

(4.21)

and similar expressions prevail for B(jroj), C(jroj), and D(jro;), Observe that
A(jroj )

=

INTGRL[IC, x(t) cos (rott)]

and thus 21 integrals of this form, one for each roi' could be programmed.

(4.22)

200

Further Application of CSMP

Ch. 4

A series of integrals of this form can best be handled using the integrator
array feature of CSMP. This type of integration was presented earlier in Example
3.3. The following example will show how these concepts can be programmed in
CSMP for finding the frequency response. t
Example 4.2

Find the pulse response and frequency response for the system shown in Fig. 4.4.

R(s)

+

25
+ 3)

C(s)

s(s
-

Fig. 4.4 System diagram for Example 4.2.

We observe that the closed-loop transfer function is given by
C(s)
R(s) =

25

S2

+ 3s + 25

(4.23)

which is identical to the transfer function in Example 4.1.
The first problem to resolve is the width of the pulse test function. Comparing the
above transfer function to the standard second-order form, S2 + 2'coll s + co;, gives
COli = 5 and' = 0.3. The ±1.8% settling time is ts = 4gcoll = 2.67 sec. To insure small
error for G(jco) we select a pulse width of 4.2 sec.
If we now apply a pulse R given by

R = Ql - Q2
Ql = STEP(O.O)
Q2 = STEP(4.2)

(4.24)

then e(t) = x(t) will be the response of the system with R = ret) = f(t) as the input.
An ordinary CSMP program can be written for the system in Fig. 4.4 to find e(t).
This e(t) plays the role of x(t) in the earlier mathematical discussion.
A program for finding the pulse response and the frequency response from CO = 0.1
to co = 10 radians/sec at ten equal log steps per decade is shown in Fig. 4.5. The following
key points are noted.
Frequency W(I) is calculated in the initial segment using a conventional DO loop.
The program determines the pulse response, XX, of the system. The time-varying XX is
passed on to a procedure function where the time-varying XA(I), XB(I), XC(I), and
XD(I) (I = 1, 2, ... , 21) are determined. The procedure function returns XA(I), XB(I),
XC(I), and XD(I) to the arguments of the array integrators A(I), B(I), C(I), and D(I).
tSlight modifications are required for using the array integrator in CSMP III. See Chap. 5.

'"

ILLUSTRATION OF FREQUENCY RESPONSE USING ARRAY INTEGRATION
nl~FNSIQN A(21),B(21),C(21),0(21),AIC(21),6IC(21),CIC(21).0IC(21),
$ XA(Z1) ,XB(2U ,XC(2U ,XD(2U
EOUIVALENCE (Al,A(l)I,(Bl,B(l),(Cl,C(l»,(OI,Oll),
$ ( AI C1 , AI C ( 1 ) I r( Bl C1, B I C ( l I ) , (C 1 C 1, C 1 C ( 1) ) , COl C 1,0 I C' U ) ,
$ (X AI. XA( U ) , ( XB1 , XB( 1) ) ,( XC 1 , XC ( l n , ( XO 1 , X0 Cl ))
F I XED I. IT OT AL
STORAGE W(Z1). GAIN(2U, PHASE(2U

I
I
I
I
I

**
P1ITIAL
XDECAD = 10.0, NUMDEC
N(1S'lRT
IT0TAl = NUMDEC*XDECAD .. 1.0
X = 0.0
Del 20 1= 1, ITOTAl
X = 1.0/XDECAD .. X
20 WeI) = wMIN*(10.0**(X»

PA~AMETER

2.0, WMIN

0.1

*'"
DYNAMIC
01 = STEP(O.OI
02 = STEP(4.Z1
R

= 01

- 02

E = R - XX
Xl
(25./3.01*E
XZ
REAlPltO.O,I.0/3.0,Xl)
XX
INTGRL(O.Q,Xl)
Al
INTGRL(AIC1,XA1,211
Bl
INTGRL(BICl,XBl,211
C1
INTf,~L(CICl.XCl,211
Dl
INTGRL(CICl,XDl,21)
PR~CEOURE XAl,XBl,XC1.XDl = FJRCE(~,XX,R,ITOTAL)
DD 1 I = I,ITOTAL
XA(II
XX*CfJS(WCI)*TIME)
XBC I I
XX*SIN( W( I I*TIM~)
XCII)
~*COS(W(I)*TIME)
1
XD(I)
R*SIN(W(I)*TIME)
ENf)PRO

*
TfRMINAL
CONV = 57.29578
DO 3 I = 1,ITOTAl
GAIN(l) = (SORTU(IJ**2 .. B(I)**Z)/(SQRTCC(I)**2 .. 0(1)**2))
PHASE(!) = (ATAN2(-R(I),A(I)I-ATAN2(-O(I),C(I»)*CONV
IF CPHA S E( 1) ) 9,9.8
8 PHASE(!) = PHASE(!) - 360.0
9 CONTINUE
3 WRITE(6tlO) W(l),GAIN(I), PHASE(1)
10 FnRMAT(IHO,8H OMEGA =,E12.5,3X,11HAMPlITUOE =,2X,E12.5
$,3X,7HPHASE =,2X.FIO.5)

**
TIMER FINTIM = 10.0, OUTDEl = 0.2, DElT
PRTPl T XX
LABEL OUTPUT FOR EXAMPLE 4-2 ARRAY
END
STIJP

0.001, PRDEl

= 0.1

ENDJOB

Fig. 4.5 CSMP program listing for finding frequency response
with integrator array.

201

202

Ch.4

Further Application of CSMP

In the terminal segment conventional FORTRAN statements are used to calculate
GAIN(I)

/ A(I)2

=

+ B(I)2

'\I C(I)2 + D(I)2

(4.25)

PHASE(I) - tan- 1(-B(I») _ tan-1(-D(I»)
A(I)
C(I)
PAGE

OUTPUT FOR EXAMPLE 4-Z ARRAY

xx

TIME
0.0'
2.0000F.-01
4.0000E-01
b.0000E-01
8. OOOOF.-O 1
1.0000E 00
1.2000F 00
1.40doE 00
1.6000E 00
1.8000E 00
Z.OOOOE 00
2.2000E 00
2.4000E 00
2.6000E 00
2.8000E 00
3.0000E 00
3.2000E 00
3.4000E 00
3.6000E 00
3.8000E 00
4.0000F 00
4.2000E 00
4.4000E 00
4.bOOOE 00
4.8000E 00
S.OOOOE 00
S.2000!: 00
5.4000E 00
5.bOOOE 00
5.8000E 00
b.OOOOE 00
b.lOOOE 00
6.4000E 00
6.6000E 00
6.8000E 00
7.0000E 00
7.l000E 00
7.4000E 00
7.6000E 00
7.8000E 00
8.0000E 00
8.2000E 00
8.4000E 00
8.bOOOE 00
8.8000E 00
9.0000E 00
9.2000E 00
9.4000E 00
9.6000E 00
c).8000E 00
1.0000E 01

(4.26)

MIN IMUM
VERSUS TIME
-3.6443E-01
XX
I
0.0
3.8141E-01
1.0186E 00
1.3555E 00
1.294SE 00
1.0573E 00
--------------------------------------~-+
8.8749E-01
8.7Zl2E-01
9.5215 E-01
1.0292E 00
1.05l3E 00
l.0279E 00
9.9580E-Ol
9.8l07E-01
9.8608E-Ol
9.9846E-Ol
l.0063E 00
l.OOb3E 00
l.0019E 00
9.98l9E-01
9.9741E-01
9.9877E-01
6.l897E-Ol
-1.7633E-02
-3.5483E-Ol
+
--+
-2.9445E-01
-5.7717E-02
1.1226E-01
1.280lE-01
4.8140E-02
-2.9031E-02
-5.1352E-02
-2.8l03E-02
4.1044E-03
1.8961E-02
1.4011E-OZ
1.6021E-03
-6.3230-E-03
-6.3044 E-03
-1.9344E-03
1.8041 E-03
2.6104E-03
1.2482E-03
-3.6340E-04
-9.9750E-04
-6.5606 E-04
-1.4780E-OS
3.4716E-04
3.0644E-04
7.1827E-05
-1.0614E-04

MAXIMUM
1.3641E 00
I

----------+
---------------------+
---------------------------------------+
-------------------------------------------------+
-----------------------------------------------+
------------------------------------+
-----------._----------------------+
--------------------------------------+
-------------------------_._------------+
----------------------------------------+
----------------------------------------+
---_
. . _-------------------------------+
--------------------------------------+
----------------------------_._--------+
--------------------------------------+
---------------------------------------+
---------------------------------------+
---------------------------------------+
---------------------------------------+
----------------------------_._--------+
--------------------------------------+
----------------------------+
----------+
--------+

-------------+
--------------+
-----------+
---------+
---------+
---------+
----------+
-----------+
----------+
----------+
----------+
---------+
----------+
----------+
----------+
----------+
----------+
----------+
----------+
----------+
----------+
----------+
----------+
----------+

Fig. 4.6 Pulse response of the system for Example 4.2.

203

Further Application of CSMP

Ch.4

The program output for GAIN(I) and PHASE(I) are neither printer-plotted nor printed
in the usual CSMP form but are listed using FORTRAN Write and Format statements.
The pulse response of the system is given in Fig. 4.6 where we note that the response
overshoot is approximatley 36 %, as expected for , = 0.3. We also note that for all
practical purposes the system has reached steady state in 4 sec.
Frequency response information is given in column format in Fig. 4.7. Comparing
this output with the results of Example 4.1 (Fig. 4.2) shows excellent agreement. The
decibel amplitude could easily be added to the output listing by inserting the statement,
DBGAIN(I) = 20.0*ALOG(GAIN(I»

(4.27)

along with slight modifications in the Write and Format statements.
PROBLEM DURATION 0.0
VAR tABLE

XX

MINIMUM
-3.6443E-01

TIME
4.9000E 00

TO

l.OOOOE 01

MAXIMUM
1.3641E 00

TIME
1.0000E-01
PHASE

-0.86600

O.10008E 01

PHASE

-1.09013

PHASE

-1.37399

OMEGA

0.12589E 00

AMPLITUDE

0.10005E 01

O~EGA

0.15849E 00

AMPLITUDE

OMEGA

0.19953E 00

AMPLITUDE

O.100l3E 01

OMEGA

0.25119E 00

A~PLITUDE

a .10021E

01

PH ASE

-1.13112

OMEGA

0.31623E 00

AMPLITUDE

O.10033E 01

PHASE

-2.18208

OMEGA

0.39811E 00

AMPLITUDE

0.10052E 01

PHASE

-2.15266

OMEGA

0.50119E 00

AMPLITUDE

D.I0083E 01

PHASE

-3.47651

OMEGA

0.63096E 00

AMPLITUDE

0.10132E 01

PHASE

-4.39891

O~EGA

0.19433E 00

AMPLITUDE

D.10210E 01

PHASE

-5.58496

OMEGA

O.10000E 01

AMPLITUDE

O.10336E 01

PHASE

-7.12580

PHASE

-9.16152

OMEGA

0.12589E 01

AMPLITUOE

O.10540E 01

OMEGA

0.15849E 01

A~PLITUDE

C.10874E 01

PHASE

-11.93899

0.19953E 01

AMPLITUDE

O.11440E 01

PHASE

-15.89472

OM~GA

O.25119E 01

AMPLITUDE

O.12405E 01

PHASE

-21.95506

OM~GA

O.31623E 01

AMPLITUDE

O.14086E 01

PHASE

-32.29756

OM~GA

0.39810E 01

AMPLITUDE

0.16619E 01

PHASE

-52.54179

OMEGA

O.SOl18E 01

A~PLITUOE

o • 16627 E

PH AS E

-90.46185

OMEGA

=

01

O~F.GA

0.6309SE 01

AMPLITUDE

O.10394E 01

PHASE

-128.03969

OMEGA

O.79432[ 01

AMPLITUDE

O.55605E 00

PHASE

-141.91351

OMEGA

O.99999E 01

AMPLITUDE

O.30965E 00

PHASE

-158.23978

QMfGA

0.12589E D2

AMPLITUDE

~.17989E

PHASE

-164.20155

00

Fig. 4.7 Frequency response information for Example 4.2 using
the integrator array.

lLLU~I~~1

lU~

Lr

r~~~UC~~T

~~~ru~~c

U~lN~

AKKAT

INI~~KAI

1UN

OIMFNSION A(2lt,BC21t,C(211,O(21),AIC(211,BIC(Zll,CIC(211,OIC(21I,
$ XA(Zlt,XB(21t,XC(21),XO(211
I
EQUIVALENCE (Al,A(lll,(Bl,B(III,(Cl,C(lll,CDl,D(llt,
I
S(AICI,AICCl»,CBICl,BIC(111,(CIC1,CICCll),(DICI,OICClI),
I
$ (XAl, XACl 1 I , (X Bl, XB ( l I I, CXCI, XC (11 I, ( XOl, XO( 1 1 I
FIXE I, I TO TAL
STORAGE W(21), GAIN(211, PHASE(211
FUNCTION SIGNAL = (0.0,0.01,(.2,.3814),(.4,1.019),C.6,1.355), •••
( .8,1.295) , ( 1.0,1.057) , ( 1.2,.8875) , ( 1.4,. 872) , ( 1. 6,.952) , ( 1.8,1.03 I ,. ••
(2.0,1.051),(2.2,1.0281,(2.4,.9961,(2.6,.9811,(2.8,.9861, •••
( 3.0,.9981 , ( 3. 2,1.00) , ( 3.4,1.001 , C3.6,1.00) , (3.8,1.001, •••
(4.00,1.001,(4.2,.6171,(4.4,-.01821,(4.6,-.3541,(4.8,-.2941, •••
(5.0,-.0571,(5.2,.1121,(5.4,.1281,(5.6,.04781,(5.8,-.0291, •••
( 6. 0 ,- • 051 1 , C6. Z , .... 027 Q I , ( 6 • 4 ,. 004) , ( 6. 6 , • 01 89 I , ( 6. 8 , • 0 t 3 9 I , •••
(7.0,.00151,(7.?,~.00631,(7.4,-.0061,(7.6,-.00191,(7.8,.00181, •••
(8.0,.0026),(8.2,.00123),(8.4,-.00041,(8.6,-.00091,(8.8,-.0006), •••
0.01 , ( 9.2, O. a1 ,
4, 0.01 , ( 9.6, O. 0 1 , ( 9. 8, 0.0 I , ( l O. 0, O. 0 1
I
I

°

,q.O,

,q.

*.

INITIAL
PARAMETER XDECAD = 10.0, NUMOEC
NOSORT
ITOTAl = NUMDEC*XOECAC + 1.0
x = 0.0
00 20 I = 1, !TOT Al
X = 1.0/XOECAO + X
20 w( I) = WMIN*' 10.0*"'( XII

2.0, wMIN

0.1

Oyt-iAMIC
Ql

Q2
Q

=

STEP(O.OI

= STEP(4.21
= Ql - Q2

XX
Al
81

Cl

AFGE~(SIGNAl,TIM~1

INTGRL(AICl,XAl,211
INTGRL(RICl,XBl,21 I
INTGRL(CICl,XCl,211

Dl
INTGRl(DICl,XOl,~!1
PROCEOUFE XAl,X91,XCl,XDl = FORCE(W,XX,P,ITOTAlI
DO 1 I = 1,ITOTAL
XA( I)
Xx*CCS(W( I I*TIMEI
XBIII
XX*SIt-JOHII*TIMF.1
XC ( I I
R*c 0 S ( W( I 1*T I ~ F. )
1
XDIII
R*SIN(W(IIHt~FI
ENOPRO

•

~ETHCD

RKSFX

TERMINAL
TFRMlf\Al
CONV = 57.Zt:;578
DO 3 I = 1,ITOTAl
GAIN(l) = (SQRT{!\(It**2 + B(l 1**2) II(SQRT(C(I)**Z + DCII**2lt
PHASE(I) = (ATAN2(-B(I),!\(I»-AUN2C-D(II,C(IIII*CONV
IF(PHASE(IIIQ,9,8
8 PHASE( II = PHASE! I I - 360.0
9 CONTINUE
3 WRITE(6,101 W(lI,GAPHII, PHASE(!I
10 FORMAT(lHO,8~ CMEGA =.~12.5,3X,11HAMPlITUOE :,2X,E12.5
$,3X,7HPHASE =,2X,F10.51

**

=

=

TIMER FINTIM
10.0, OUTOEl
0.2, DELT = 0.005, PRDEl : 0.1
PRTPLT XX
lABEL ARRAY INTEGRATION USING NUMERICAL FUNCTION EXAMPLE 4-Z
!:NO

STOP

Fig. 4.8 CSMP program listing for finding frequency response
from pulse response using the integrator array.

Ch.4

205

Further Application of CSMP

The CPU time for running this program on the 360/65 was approximately 40 sec. The
multiple integrations account for the rather large CPU time as compared to Example 4.1
which used only 10 sec for twice as many frequency points. Obviously, if the system
transfer function is known, the method of Example 4.1 is preferred over the array integration method.
The real advantage of the array-integrator method exhibits itself in the following
light. There are many practical systems where direct frequency response measurements
are extremely difficult and uneconomical to obtain. Making such measurements on
chemical process plants and metal-rolling mills is practically out of the question. However, the pulse response of many systems can be directly and economically measured. If
this time domain data is coupled to the array-integrator program via either AFGEN or
NLFGEN then the system frequency response can be obtained.
To illustrate this point, suppose the time response data of Fig. 4.7 is used to define
a function.
FUNCTION SIGNAL

= (0.0, 0.0), (0.2, 0.3814), ...

from which the signal XX is obtained by:
XX

=

AFGEN (SIGNAL,TIME)

The program in Fig. 4.8 has incorporated these changes by simply removing the original
system-transfer function. The resulting frequency response information is shown in Fig.
4.9. The response compares favorably to the "exact" answers and deviations can be
attributed to interpolation inaccuracy.
In summary, this section shows two methods for obtaining a system frequency response using CSMP. The first method applies directly to those systems with known transfer
functions. The second method can be applied to systems with known transfer functions
and, moreover, has its greatest value in determining the frequency response from pulseresponse information as measured directly from the physical system.

State Variable Formulation from Transfer
Functions
The occasion often arises when one wishes to express the dynamics of a system
in state-variable form rather than the customary transfer function. The state equations for a linear, time-invariant, system can be written as

+ Ru(t)
yet) = Cx(t) + Du(t)

i.(t) = Ax(t)

(4.28)
(4.29)

where x(t) = n-dimensional column vector called the system state vector,
yet) = q-dimensional column vector called the system output vector,
u(t)

=

m-dimensional column vector called the system input vector,

and A, B, C, and D have appropriate matrix dimensions.

206

Further Application of CSMP

OMEGA
OMEGA
OMEGA
OMEGA
OMEGA
OMEGA

= 0.10000E

Ch. 4

00

AMPLITUDE

0.99969E 00

PHASE.

0.12589E 00

AMPLITUOE

0.99986E 00

PHASE

00

AMPLITUDE

0.10001E 01

PHASE

00

AMPLITUDE

0.10006E 01

PHASE

00

AMPLITUDE

0.10013f 01

PHASE

0.31623E 00

AMPLITUDE

O.10024f 01

PHASE

0.10041F.: 01

PHASE

0.10069£ 01

PHASE

= 0.15849E
= 0.19953E
= 0.25119E
= 0.39811£
= 0.50119E
= 0.63096E

=
=

=

-0.68448
-0.86155

=
=
=

-1.08507
-1.36697
-1.72244
-2.17153

=
=

00

Af.'PL I TUDE

00

AMPLITUDE

00

AMPLITUDE

0.10113E 01

PHASE

0.79433£ 00

AMPLITUDE

0.10183£ 01

PHASE

01

Af.1?L ITUDE

0.10297E 01

PHASE

0.12589E 01

AMPLITUOE

0.104B6E 01

PHASE

01

AMPLITUDE

0.10623E 01

PHASE

-15.71143

OMEr,A

0.19953f 01

AMPLITUDE

0.11272E 01

PHASE

-16.04182

OMEGA

0.25119E 01

AMPLITUDE

0.12128E 01

PHASE

-21.98824

AMPLITUDE

0.14504£ 01

PHASE

-33.11356

I TUDE

0015816E 01

PHASE

-52.59436

01

AMPL I TUllE

0.15293£ 01

PHASE

-89.78917

01

At-1PL TrUDE

0.7401'+E

Uo

PHASE

-128.34552

OMEGA

0.7943?'E 01

MHlL t TUI)E

0.42237£ 00

PHASE

-149.91252

OME(;A

0.99999£ 01

"~PLITuOE

0.20528E 00

PHASE

-155.85031

OMEGA
OMEGA
OMEGA
OMEGA
OMEGA
OMEGA
OMEGA

OMEGA
OMEGA
OMEG"
OM£GA

= 0.10000E
= 0.15849E

= 0.31623£

01

0.39810£ 01

= 0.5011AE
= 0.630QC:;f

At~PL

=

-2.73948
-3.45968
-4.37542

=

-5.54671
-7.05657

=

-9.01148

Fig. 4.9 Frequency response information obtained by Fourier
transform.

Consider a system represented by the transfer function
C(s) _
R(s) - S4

a2 s2 + ai s + a o
+ bss s + b2s 2 + b i s + bo

(4.30)

A block diagram which represents this transfer function is given in Fig. 4.10. The
following equations can be written from the diagram.

= X2(t)
xit) = xs(t)

XI(t)

xlt) = X4(t)
X4(t)

= r(t) - bOXI(t) - b Ix 2(t) - b2Xs(t) - bSX4(t)

Ch.4

Further Application of CSMP

207
C(s)

Fig. 4.10 Block diagram for phase variable state equations.

and

e(t)

=

a Oxl

+ a1x2 + a 2X

3

Expressing these equations in matrix form gives

o

1

(t)]
o ][Xxit)
+
1

-b 3

x 3 (t)
xlt)

[0]

0 (
r t)
0

(4.31)

1

and

e(t)

=

(4.32)

[a o

Comparing with Eqs. (4.28) and (4.29) we have

A=

[~ ~ r ~]
-b o -b 1

-b 2

-b 3

B=

[~]
1

and x(t) = [Xl(t), X2(t), x 3 (t), X4(t)Y, yet) = e(t), net) = ret).
Assuming the input to the system in Fig. 4.10 is a unit step, a CSMP program

208

Ch. 4

Further Application of CSMP

corresponding to the system diagram can be written as
R = STEP (0.0)
E = R - BO*Xl - BhX2 - B2*X3 - B3*X4
X4 = INTGRL (0.0, E)
X3 = INTGRL (0.0, X4)
X2 = INTGRL (0.0, X3)
Xl = INTGRL (0.0, X2)
C = AO*Xl + Al *X2 + A2*X3
TIMER FINTIM = 3.0, OUTDEL = 0.1
PRTPLT Xl, X2, X3, X4, C
END
STOP
ENDJOB

The constants AO, AI, A2, BO, B1, B2, and B3 are usually given on parameter
cards and FINTIM and OUTDEL will depend upon these coefficients. This procedure for programming a transfer function can easily be extended to higher-order
polynomials. The state variable formulation in this particular form is commonly
known as the phase variable representation.(6.7.S)
This illustration shows that a set of state equations can always be written for
a system transfer function. The state-representation for a transfer function is not
unique. In fact, it can be proven that for a given transfer function there exist
infinitely many state representations.
Another method for expressing the transfer function of Eq. (4.30) is given in
Fig. 4.11. Using the output of each integration (the l/s terms) as states, one can

R(s)~'-----"---"--------'

Xl

Fig. 4.11 Alternate block diagram form for state variable representation.

= C(s)

Ch. 4

Further Application of CSMP

209

easily write a set of equations corresponding to Eqs. (4.28) and (4.29). This is done
in an exercise at the end of this chapter.

Digital Control Systems

Digital computers have become an important method for controlling feedback
systems. The purpose of this section is to illustrate how CSMP can be used to simulate the digital control process.
A simplified diagram showing the role of the digital computer in a feedback
system is given in Fig. 4.12. The analog output of the system is converted to a
binary representation by the analog to digital (A/D) converter. The system input
must be converted to a compatible binary representation. The computer subtracts
the binary output from the binary input to form a binary error signal. The error
signal becomes the "input" to a properly selected control algorithm.

INPUT

Computer
calculations

OUTPUT

Fig. 4.12 Basic digital feedback control system.

Assume that algorithm calculations are made every T sec to form the binary
signal, m, as shown in the diagram. This binary signal is converted to an analog
signal by the digital to analog converter (D/ A) to produce the signal q which is
applied to the system. The design problem is to determine the algorithm which
satisfies system specifications. The functions carried out by the computer hardware in Fig. 4.12 can be equivalently represented by the more straightforward
model as given in Fig. 4.13. The problem of selecting the control algorithm reduces
to one of finding the function D(z) where z is the z-transform variable. The major
attention in this section will be given to the simulation problem, since methods for
finding D(z) are given in the literature. (9.10.11)

210

Ch.4

Further Application of CSMP

~

OUTPUT
Zero-order
hold

Digital
controller

Plant

Fig. 4.13 Simplified diagram for digital control.

Example. 4.3
The system shown in Fig. 4.14 does not include a controller D(z). It is desired, however, to investigate the effect of the sampling process on the system stability. Ideal sampling, followed by a zero-order hold, can be simulated as follows. If the input to the ideal
INPUT +

E

-

Zero-order
hold

"f T

Q

10
s(s

OUTPUT

+ 3.5)

Fig. 4.14 System diagram with sample and hold. (Example 4.3.)

sampler is E, then the output of the zero-order hold can be represented as Q. This process
can be simulated using the following CSMP statements.
Al

= IMPULS(O.O, T)

Q = ZHOLD(Al, E)
The reader will recall that Al = IMPULS(PI, P2) produces a unit-impulse train starting
at PI with pulses occurring every P2 sec. Properties of the zero-order hold are defined in
Table 4.1. (Also, see Appendix I)
Table 4.1

Properties of the Zero-Order Hold

Function

CSMP Form

Q = ZHOLD(Al, E)

Q(t)
Q(t)
Q(t)

=E
= last output
=0

AI> 0
Al <0
t = initial t

Ch.4

T

=

Further Application of CSMP

211

Now suppose we desire to find the step response of the system for sampling times of
0.3 and T = 0.8. A simple program for this purpose is given below.
PARAM T = (0.3, 0.8)
INPUT = STEP(O.O)
E = INPUT - OUTPUT
Al = IMPULS(O.O, T)
Q = ZHOLD(Al, E)
Xl = (10.0/3.5)*Q
X2 = REALPL(O.O, 1.0/3.5, Xl)
OUTPUT = INTGRL(O.O, X2)
METHOD RKSFX
TIMER FINTIM = 6.0, OUTDEL = 0.24, DELT = 0.01
PRTPLT OUTPUT
LABEL STEP RESPONSE OF SYSTEM WITH SAMPLE AND HOLD
END
STOP
ENDJOB

A fixed-step integration (RKSFX) is selected for this example to insure that an integration
is performed when the sampling switch closes. If a variable-step integration is used, the
integration will not generally occur at the sampling time but rather when KEEP = 1. The
resulting response will not be representative of uniform sampling every T sec. When using
the sample and hold, variable integration can be selected but either OUTDEL or PRDEL
should be chosen to be a sub-multiple of the sampling interval. Fixed-step integration is
recommended for simulating discrete data systems. This is particularly important when a
digital controller is placed in the system.
The responses in Fig. 4.15 show the effect of the sampling process on the system
stability. The continuous system response has approximately 12 % overshoot while the
overshoot becomes larger as T in the sampling process is increased.
Example 4.4
The purpose of this example is to illustrate a procedure for finding the time response
of a closed-loop feedback system which contains a digital controller, D(z), and a zeroorder hold. The basic block diagram of the system is shown in Fig. 4.16. This system is
identical to the one given in Example 4.3 except the gain is raised from 10 to 70 and a
digital controller is added to the system. A procedure for selecting the controller is given
in reference 11.
First consider the simulation of D(z) followed by the zero-order hold. For this
example the particular D(z) is given by
0.981
D(z) -- 0 .1 zz -- 0.998
If this function is represented in a more general form as
D( )

z

=

ao

1

+ al z - 1
+ b1z-1

we can easily employ the phase variable or rectangular programming methods given in
the previous section by replacing s by z. The block diagram for the rectangular form is

212

Ch. 4

Further Application of CSMP

given in Fig. 4.17. The controller and the zero-order hold can be programmed as a
MACRO using the following CSMP statements:
MACRO E2 = COMP(SAMTIM, TX, AO, AI, Bl, El)
TX = IMPULS(O.O, SAMTIM)
EZ = TX*El
YO = AO*EZ + PI
Yl = Al*EZ - Bl*YO
PI = DELAY(I000, SAMTIM, Yl)
E2 = ZHOLD(TX, YO)
END MAC
This macro is completely general for any D(z) of the form so prescribed and can
easily be extended to higher-order D(z).
A block diagram of the total system is shown in Fig. 4.18 and is used to identify
the inputs and outputs of the various blocks within the CSMP program. Figure 4.19 gives
the program listing corresponding to the block diagram. Figure 4.20 gives the step
response, e(t), of the compensated system. Compare this response to that obtained earlier
in Example 4.3. The gain was 10 but has now been raised to 70. Note also that fixed-step
integration is used with DELT = 0.02 to insure that integration is performed at the
sampling interval of T = 0.1.
While the method for simulating D(z) given in this example is completely general
for any digital controller, it is not directly the method followed in programming a control
algorithm for real-time digital control. We recall that the operator Z-l was simulated by
STEP. RESPONSE OF CONTINUOI.JS SYSTEM TO COMPARE WITH SAMPLE AND HOLD
MINIMUM

OUTPUT VER

sus

0.0
OUTPUT

TIME

(a)

Continuous
system

0.0
I.llOOOE-Ol
3.6000E-01
5.40COE-OI
7.2COOE-01
9.0000E-01
I.OBOOE 00
1.2600E 00
1.4400E 00
1.62COE 00
I.S000E 00
1.9BOOE 00
2.1600E 00
2.3400E 00
2.5200E 00
2.7000~ 00
2.BaCOE 00
3.0600E 00
3.2400E 00
3.4200E 00
3.6000E 00
3.7 eCOE 00
3.9600E 00
4.1400E 00
4.3200E 00
4.'5COOE 00
4.6aOOE 00
4.8600E 00
5.04COE 00
5.nCOE 00
5.4000E 00
5.5800E 00
5.7600E 00

0.0
1.2934E-Ol
4. 0196E~01
6.87UE-Ol
9.1221E-01
1.0526E 00
1.1I51E 00
1.1215E 00
1.0964E 00
1.0605E 00
1.0272E 00
1.003lE 00
9.8956E-Ol
9.8478E-01
9.8579E-01
9.8966E-01
9.9414E-Ol
9.9789E-01
1.0004E 00
1.0016E 00
1.0019E 00
1.0016E 00
1.001lE 00
1.0005E 00
1.0001E 00
9.9988E-01
9.9977E-Ol
9.9977E-01
9.9982E-01
9.9989E-01
9.9995E-Ol
I.OOOOE 00
I.OOOOE 00

PAGE
MAXIMUM

T I ME

1.1215E 00
I

+

-----+
-----------------+
------------ -------- ---------- +
----------------------------------------+
----------------------------------------------+
-------------------------------- ------------ - - - - - +
-------------------------------------------------+

------------------------------------------------+

----------- ----------------------------------- +

---------------------------------------------+

-------------------------------------------- +
------------------------------------------+
-------------------------------------------+

-------------------------------------------+
--------------------------------------------+

--------------------------------------------+
----------- -------------------------------- +
--------------------------------------------+

-------------------------------------------+
--------------------------------------------+
--------------------------------------------+
--------------------------------------------+
--------------------------------------------+

--------------------------------------------+
------------------------------------------+
-------------------------------------------+
-------------------------------------------+
--------------------------------------------+

---------------------.,.----------------------+
--------------------------------------------+
--------------------------------------------+

------------------------------------ ------- +

Fig. 4.15 System step-response for Example 4.3.

Ch. 4

213

Further Application of CSMP
PAGE

"lINIMU"l
0.0
TIME

(b)

Sample
and hold,
T ==0.3 sec

OUTPUT VERSUS TIME

T

= 3.0000E-01

OUTPUT

0.0
2.4000E-Ol
4.8000E-Ol
7.2 eOOE-OI
9.60001'-01
1.2000E 00
1.4400E 00
1.6800E 00
1.9200E 00
2.1600E 00
2.4000E 00
2.64COE 00
2.88COE 00
3.1200E 00
3.3600E 00
3.60001: 00
3.84COE 00
4.0800E 00
4.3200E 00
4.5600E 00
4.8COOE 00
5.0400E 00
5.2 eCOE 00
5.5200E 00
5.76COE 00
6.0000E 00

0.0
2.21eOE-01
6.6318E-Ul
1.0e24: 00
1. 3189E ~O
1.3460E 00
1.2343E 00
1.0719E 00
9.3795:-01
8.7641E-Ol
8. 8489E- 01
9.3330E-Ol
9'. 9045E- 01
1.0314E 00
1.0453 E 00
1.0368E 00
1.0175E 00
9.9823E-01
9.8635E-Ol
9.8408 E'-O 1
9.8875E-Ol
9.9594E-Ol
1.·.;)022E 00
1.0054E 00
1.0053E 00
1.0032E 00

MAXIMUM
1.8433E 00
I

-----------------+
----------------------------- +
-----------------------------------+
------------------------------------+
---------------------------------+

----------------------------- +

-------------------------+

-----------------------+
------------------------+

-------------------------+
---------------------------+

--------------------------+

---------------------------- +

----------------------------+
-------- ------------------- +
---------------------------+
--------------------------+
-------- ------------------ +

--------------------------+
---------------------------+
---------------------------+
---------------------------+
--------------------------- +
---------------------------+
PAGE

MINIMU'"
0.0

Tt ME

(c)

Sample
and hold,
T == 0.8 sec

OUT PUT VERSUS T I ME

T

= 8.0000E-Ol

OUTPUT

0.0
2.4000E-01
4.8000E-01
7.2000E-01
9.6000E-01
1.2000E 00
1.4400E 00
1.6eCOE 00
1.9200E 00
2.1600E 00
2.4000E 00
2.6400E 00
2.8eOOE 00
3.1200E 00
3.3600E 00
3.6000E 00
3.8400E 00
4.0eOOE 00
4.3200E 00
4.5600E 00
4.8000E 00
5.0400= 00
5.2800E 00
5.5200E 00
5.7600E 00
6.0000E 00

0.0
2.2180E-Ol
7.0724E-Ol
1.3065E 00
1.7891E 00
1.8172E 00
1.6271E 00
1.3451E 00
1.0454E 00
7.4309E-Ol
4.3961E-Ol
3.6110E-Ol
5.4558E-Ol
8.4359E-Ol
1.1343E 00
1.2845E 00
1.3667E 00
1.4058E 00
1.2947E 00
1.0894E 00
8.4347E-Ol
7.0573E-01
7.0726E-Ol
7.6892E-Ol
8.6170E-Ol
9.8047E-Ol

MAXIMUM
1.8433E 00
I

+

------+
-------- --------------------- ----------- ---- - - - - +
------------------------------------------------- +

--------------------------------------------+

------------------------------------ +
---------------------------- +

-----------+
---------+
--------------+
------------------------------+
----------------------------------+
------------------------------------+
--------------------------------------+
-----------------------------------+
-----------------------------+

----------------------+
-------------------+
-------------------+
-------------------- +
-----------------------+
--------------------------+

Fig. 4.15. (Continued)

---lv;Lx

OUTPUT

T~~

Fig.4.16 System diagram with a digital controller. (Example 4.4.)

214

Further Application of CSMP

Ch. 4

e~-.e_z~______~______-,
T

Fig. 4.17 Block diagram representation for the realization of a
first-order digital controller.
C(s)

Fig. 4.18 Total simulation diagram for Example 4.4.
MACRO

E2
TX
fZ

YO
Yl

P1
E2

COMP(SAMTIM, TX, AO, Al, Bl, Ell
IMPULS(O.O, SAMTIM)
TX*El
AO*El + PI
AI*El - 81*YO
DELAY(10JO, SAMTIM,Y1)
lHOLDnX, YO)

ENOMAC

*

PLANT STRUCTURE FOLLQWS
= -0.0981, 81

PARAMETEP AO = 0.1, Al
C = INTGRL(0.0,X2)

-0.998, SAMTIM

.1

X2
REALPLlO.Q,0.Z86,XIJ
Xl = 20.0*E2
E2 = COMP(SAMTIM, TX, AO, Al, 81, El)
El=R-C
R. = STEPlO.O)
METHOD RKSfX
TIMER FINTIM = 5.0, OUTDEL = 0.18, DElT = 0.02
PRTPLT C
LABEL STEP RESPONSE FOR DIGITAL CONTROL SYSTEM EXAMP. 4-4
END

STOP
ENOJOB

Fig. 4.19 Program listing for a digital control system. (Example
4.4.)

STEP RESPONSE FOR DIGITAL CONTROL SYSTEM EXAMP.

c

MINI MUM

TtME
0.0.
1.80001:=-('11
3.6000E-01
5.4000E-01
1.?OOOE-n 1
9. OOOOE-Ol
1.0800E 00
1.2600E 00
1. 4~OOE 00
1.b200E 00
1.S000E 00
1.9800E 00
2.1600E 00
2.3400E 00
2.5200E 00
2.7000E 00
2.8800E 00
3.0600E 00
3.2~OOE 00
3.4200F 00
3.60001: 0('1
3.7800E 00
3.9600E 00
4.14001; 00
4.3200E 00
~.5000E 00
4.68001:: 00
4.8600E 00

215

Further Application of CSMP

Ch. 4

~-~

VERSUS TIME

0.0

c

0.0
9.2493E-02
3.0146E-Ol
5.4612E-Ol
7.7337E-01
9.5472 E-Ol
1.0806E 00
1.1542 F. 00
l.lS51E 00
1.l857E 00
1 .1681 E 00
1.1421E 00
1.11~8 E 00
1.0906 E 00
1.0716E 00
1.0582 E 00
1.0499E 00
1.0456E 00
1.0439E 00
1.043SE 00
1.0443E 00
l.0449E 00
1.0451E 00
1.0449E 00
1.044LE 00
1.0430E 00
1.0416E 00
1.0400E 00

PAGE
MAXIMUM
l.1883E 00
I

+

---+
------------+
----------------------+
--------------------------------+
----------------------------------------+
---------------------------------------------+
------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
------------------------------------------------+
----------------------------------------------+
---------------------------------------------+
---------------------------------------------+
--------------------------------------------+
--------------------------------------------+
-------------------------------------------+
----------------------~--------------------+
-------------------------------------------+
-------------------------------------------+
-------------------------------------------+
-----------------------------------------+
-------------------------------------------+
----~--------------------------------------+
-------------------------------------------+
-------------------------------------------+
-------------------------------------------.

Fig.4.20 Step response of a system containing a digital controller.

(Example 4.4.)
using the CSMP DELAY function. In the following example the controller will be programmed using a recursive difference equation.
Example 4.5
The system diagram of a process to be controlled by a digital algorithm is shown in
Fig. 4.21. (12) We note from the diagram that D(z) is given by
D(z)

=

Q(z)
E(z)

= 0.19185(z

- 0.56496)(z - 0.96585)
(z - 0.99501)(z - 0.42857)

(4.33)

This controller can be programmed as a difference equation using either a direct, cascade,
or parallel realization. (11) Each of these methods will be briefly discussed.

Direct Realization. The function D(z) can be expressed as
D( ) = Q(z) __ 0.19185z 2 -- 0.29368z + 0.10469
z
E(z) -Z2 -- 1.42358z + 0.42643

(4.34)

The standard procedure here is to divide the numerator and denominator by
and cross-multiply. In terms of Q(z) and E(z) this yields
Q(z)

=

0.19185E(z) -- 0.29368z- 1E(z)

+ 1.42358z-

1

Z2

+ 0.10469z- 2 E(z)

Q(z) -- 0.42643z- 2 Q(z)

(4.35)

216

Further Application of CSMP

Ch. 4

,------------------------------,
I
I

Digital computer

I
I

I

I

I INPUT +

E(z) 0.19185(z - 0.56496) (z - 0.96585)

I

(z - 0.99501) (z - 0.42857)

:

:

L __________________________ J
,--

- - - - - - --- - - - - - - - - - - - - - - - - - - I
I

OUTPUT I
I--t-~ I

I

I
I

I
I
Analog process
I
L _________________ ~ _ ~ ____________ J

I

Fig. 4.21 System diagram with second-order digital controller.
(Example 4.5.)

Using the real-translation property of z-transforms(13) gives
Q(nT)

=

0.19185E(nT) - 0.29368E[(n - I)T]

+ 1.42358Q[(n -

+ 0.10469E[(n -

2)T]

l)T] - 0.42643Q[(n - 2)T]

(4.36)

where T is the sampling interval, n = 0, I, 2, ... , and
Q(nT) = the present value of the output Q at t = nT
Q[(n -

l)T] = the first past value of Q

Q[(n - 2)T] = the second past value of Q
E(nT) = the present value of the input Eat t = nT
E[(n - 1)T] = the first past value of E
E[(n - 2)T]

= the second past value of E

For convenience in programming, the expression for Q(nT) is written as
Q = 0.19185E - 0.29368El

+ 0.10469E2 + 1.42358Ql

- 0.42643Q2

The present value of E is always known in a process. After solving for Q, the
coefficients of the algorithm are immediately updated by including the following
statements;
Q2 = Ql
Ql =Q
E2 =El
El =E

(4.37)

Ch. 4

Further Application of CSMP

217

INITIAL
El

0.0

01
r-2

0.0
0.0
0.0

Q2

PARhM K = ?2e:.
CYNA~IC

INPUT = STEP/C.O)
E = H1PLJT - CL T
OUT = IWGflt (0.0, X2)
X2 = INTGRlIC.O, X2D)
X2D = X3 - 5.71*X2
X3 = iNTGRl(O.O, X3f11
X3D = X4 - ~.7l*X3
X4

X5
Al

= K *X5
= ZhCl[(AI. CI
= IMPUL~(C.O. C.l)

Q = OlJ~MY(F.,El,f2,Ql,Q2,Al)
IF(!I.NE.l.C) Gn Te 10
rF(KE~p.~E.I.C) GC TO 10
Q = .191d5*F-.29368*El+.10469*E2+1.42358*Ql-.42643*Q2

~!H~CEOl)lU

E2
E1
E1 = E

Q2
Q1
10

=
=

Q1
Q

COI\TINUE

[f\!)PRfl

"'ETHon

RKSFX

Tr~ER

fINTIM
PRTPLT OUT

LABEL

OUTPUT

=

8.0, CUTDfL

~OR

=

0.16,

O~lT

0.01

FXAMPlE 4-5

EhD

STOP

ENDJOB

Fig. 4.22 Program listing for Example 4.5 using direct realization.

A CSMP program which incorporates this realization for D(z) is given in Fig. 4.22.
We note that the expressions for D(z) are given as a procedure function since they
must be executed sequentially. The statement
IF(KEEP.NE.1.0) GO TO 10

insures that the statements of the procedure function cannot be executed except
when an integration is performed. Furthermore, when fixed-step integration is
selected, the statement
IF(A1.NE.1.0) go to 10

allows the procedure function to be executed only at sampling instants nT where
n = 0, 1, 2, ... and T (sampling time) is an integral multiple of DELT. One will
note that when a variable step-size integration method is used, integration will
not normally occur at nT and the program will generally give misleading results.
Initial values for E1, E2, Q1 and Q2 are given in the INITIAL segment. It is
important to observe that E2 is updated prior to El and Q2 is updated prior to Q1
in the procedure function.
The response of the system for a unit-step input applied at t = 0 is given in
Fig. 4.23.

'JUTPIJT FOR E:XAMPLE 4-5

PAGE
~l

q

~L~

CUT

VERSUS TIME

TI MI=
0.0
1.6000f-Ol
3.2ceCF-e1
4.800QE-01
6.4CCOE-01
8.0ceCE-e1
9.6000F-Ol
1.12eeE 00
1.2800r 00
1.'~400F 00
1.6eceE CC
1.7600E 00
1.92eOE 00
2.08eeo:: cc
2.24COE 00
2.4CCOE CO
2.56001= 00
2.72COE 00
2.eecct: CO
"3.0400E CO
3.20COE 00
3.3600'" 00
3.5200E 00
3.6fce!:: CC
3.B400E 00
4.0eceE 00
4.1l:00F: OC
4.32001: 00
4.4800': 00
4.6400~ 00
4.8UOOI= 00
4.<;HCr: CO
5.1200£' 00
5.?eCCf 00
5.44eo", oe
5.6CCOF 00
5.7600E CO
5.92eOE 00
6.i.l800F 00
6.?4eCE 00
6.40001: 00
6.56ceE 00
6.72ceE CC
6.8900E 00
7.04eOE 00
7.20COI: 00
7.36COE 00
1.~2eOE ce
7.6dOOE 00
1.84COF OC
8.0ceeE 00

OUT
0.0
2.7389E-02
1.4014E-e1
3.1569E-01
5.1261E-01
1.0248E-Ol
8.6790E-Ol
1.COC<;E cc
1.1001'= CO
1.1678E OC
1.20BSE CC
1.2286E 00
1.2326E 00
1.2251E ac
1.2120E 00
1.1941E ac
1.1761E 00
1.1577E ce
1.1406E ce
1.12!>2E CO
1.lJ..18E ac
1.1003E ac
1.0905t: OC
1.ce23E CC
1.0752E OC
1.06'12E 00
1.0640E OC
1.0595E oe
1.0554F co
1.0516f CC
1.0482E 00
1.04?OE CC
1.0420t 00
1.0392E 00
1.0365E ec
1.0340E ae
1.0317E 00
1.0295E CC
1.0274:: 00
1.0255E CC
1.0231E CC
1.0220E 00
1.0204E ce
1.0189E ec
1.0176E ao
1.011:3E CC
1.01S2E CO
1.0141E CC
1.0BIE 00
1.0122E CC
1.01l3E CC

MAXIMUM
1.2328f 00

C.O

I

+
-+

-----+
------------+
--------------------+
----------------------------+
-----------------------------------+
----------------------------------------+
--------------------------------------------+
-----------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
------------------------------------------------+
-----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
---------------------------------------------+
---------------------------------------------+
--------------------------------------------+
--------------------------------------------+
-------------------------------------------+
-------------------------------------------+
-------------------------------------------+
-------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
----------------------------~------------+
-----------------------------------------+
-----------------------------------------+

Fig. 4.23 Unit-step response of the second-order digital control
system. (Example 4.5.)

Cascade Realization. For cascade realization, D(z) is expressed as

D( ) = Q(z) = 0 19185[1 - O.56496z- 1 ][1 - O.96585Z- 1 ]
Z
E(z)'
1 - O.99501z 1 1 - 0.42857z 1

218

(4.38)

Ch. 4

Further Application of CSMP

219

where the grouping of the numerator and denominator terms within the brackets
is arbitrary. An input/output relationship is assigned to each term of Q(z)/E(z)
by expressing

where

Q(z)
Q(z) V(z) S(z)
E(z) = V(z) • S(z) • E(z)

(4.39)

~~~~ =

(4.40)

0.19185

V(z) _ [1 - 0.56496z- 1 ]
S(z) 1 - 0.99501z- 1

(4.41)

S(z) _ [1 - 0.96585z- 1 ]
E(z) 1 - 0.42857z- 1

(4.42)

Each of these expressions can be written in difference equation form to give
S = E - 0.96585El

+ 0.42857SI

v=

+ 0.99501 VI

Q

=

S - 0.56496S1

(4.43)

0.19185V

Again, after processing the above equations, the coefficients must be updated by
setting
El =E
81 = 8
VI =V

(4.44)

The simulation for the total system is the same as that given in Fig. 4.22 except
the procedure function becomes
PROCEDURE Q = DUMMY(E, At, El, 81, VI)
IF(Al.NE.l.O) GO TO 10
IF(KEEP.NE.1.0) GO TO 10
8 = E - 0.96585*El + 0.42857*81
V = 8 - 0.56496*81 + 0.9950h VI
Q = 0.19185*V
El =E
81 = 8
VI =V
10
CONTINUE
ENDPRO

and in the INITIAL segment El = 0.0, SI = 0.0, and VI = 0.0.
Parallel Realization In the parallel realization method D(z) is expanded in
partial-fraction form. When the numerator and denominator of D(z) are the same
order, the denominator is first divided into the numerator, which for this example
gives
D( ) = 0 19185 + (-0.02057z + 0.022875)
(4.45)
z.
(z - 0.99501)(z - 0.42857)

220

Further Application of CSMP

Ch.4

In partial-fraction form, D(z) becomes
D(z) = 0.19185

A
0.99501

+z _

B
0.42857

+z -

(4.46)

where A = 0.00425 and B = -0.02482. We now write the function as
D(z)

=

Q(z)
E(z)

=

Afc~] =

where:

M(z)
E(z)

+ N(z) + P(z)
E(z)

=

1

-0.02482z- 1
1 - 0.42857z

(4.47)
(4.48)

0.19185

N(z) _
0.00425z- 1
E(z) - 1 - 0.99501z
P(z)
E(z)

E(z)

1

(4.49)
(4.50)

These expressions lead directly to the difference equations
M = 0.19185E

N = 0.00425El

+ 0.99501Nl

P = -0.02482El

+ 0.42857Pl

(4.51)

Q=M+N+P

with coefficient updating
El =E

Ml =M
Nl =N

(4.52)

PI =P
The total simulation program is again identical to that of Fig. 4.22 except
that the INITIAL segment contains the values El = 0.0, MI = 0.0, NI = 0.0,
PI = 0.0 and the procedure function is given by
PROCEDURE Q = DUMMY(E, El, Ml, Nl, PI, AI)
IF(A1.NE.1.0) GO TO 10
IF(KEEP.NE.1.0) GO TO 10
M = 0.19185*E
N = O.00425*El + O.9950hNl
P = -0.02482*El + 0.42857*Pl
Q=M+N+P
El = E
Ml =M
Nl =N
PI = P
10 CONTINUE
ENDPRO

The unit-step output response for each of the three methods is practically

Further Application of CSMP

Ch. 4

221

identical to the response given in Fig. 4.23. The reader may ask why three different methods are presented. When these algorithms are programmed for real-time
digital control, two factors become important. First, the computer time required
to execute the algorithm may be an important factor. If this is the sole consideration one would select the algorithm that requires the fewest number of additions
and mUltiplications. Second, numerical roundoff and truncation may have a significant influence on the system response. In this case one might try each realization and select the one that gives the best results. Several investigators have found
that parallel realization most often gives the best performance.
Example 4.6

Classical analog compensation techniques that rely heavily upon frequency response
methods can be extended to digital control by implementing appropriate algorithms in the
digital computer. The bases for this extension were given in the previous examples.
Obtaining frequency response information or developing models can be extremely
time consuming and therefore is not always a luxury the control engineer can afford. This
is particularly true in the process control industry. Normally one finds in this case that a
three-mode controller is the most attractive compromise for improving system performance. The term three-mode stems from the nature of the controller in that one mode is
directly proportional to the applied signal, one mode is proportional to the integral of the
signal, and one mode is proportional to the derivative. Therefore the term, proportionalintegral-derivative (PID) controller is often used rather than three-mode.
The diagram in Fig. 4.24 shows the representation of this controller as applied to a
unity-negative feedback system. The continuous PID controller can be approximated on
a digital computer using several forms of algorithms. (1 0,14) As a simplified version we
can write
Xlk)
XD(k)

=
=

Xj(k - 1)

+ T*E(k)

(4.53)
(4.54)

(ljT)(E(k) - E(k - 1))

where Eq. (4.53) corresponds to integration and (4.54) to differentiation. The output of
the digital PID is then given by
Y(k)

=

Kp*E(k)

+ KlXj(k -

1)

+ T*E(k)) + KD((ljT)(E(k) -

E(k - 1)))

(4.55)

We note that
T

=

sampling time

E(k) = present value of the applied signal
E(k - 1) = first past value of E(k)
Xlk)
Xlk - 1)

= present estimate of the integral
= first past value of Xlk)

Consider the system shown in Fig. 4.25 where the sample switch and the zero-orderhold represent the digital computer without a control algorithm. With a sampling time of
T = 0.01, the step response shown in Fig. 4.26 is practically identical to the continuous
system (Le. without the sampler and hold).
A program using the same basic system but including a digital representation of the
PID controller is given in Fig. 4.27. The algorithm for the controller is contained in a

222

Further Application of CSMP

Ch. 4

c

Fig. 4.24 Ideal representation of an ideal continuous PID con-

troller.

c

Fig.4.25 System of Example 4.6 without a digital PID controller.

procedure function in the same way as given previously in Example 4.5. Earlier comments
with respect to using fixed integration steps rather than variable steps also apply to this
simulation.
Integration and differentiation for the controller are approximated by Eqs. (4.53) and
(4.54), respectively. Using Kp = 12, K1 = 20, and KD = 4 gives the step response shown in
Fig. 4.28. We note the improvement in the system rise-time as well as a decrease in the
overshoot when compared to the response without a controller.
In conclusion, this section has presented several methods for simulating a digital control system. There are many other ways to view the digital control system, fOl'
example, the digital implementation of a predictive controller. (15) Nevertheless, the
methods presented here are fundamental and generally apply to more advanced
techniques.
There is strong justification for learning the programming concepts presented
in this section. Advances in computer technology, particularly in the microprocessor area, have reduced the cost for digital control by a factor of tenduring the last decade. Continued improvement in computer technology, coupled
with the flexibility offered by a digital controller, will in all likelihood result in a
growing number of applications in this area.

RESPO~SE

WITHOUT PID

CC~TROL

-

MIN I MUM

~XA~PLE

4-6

PAGE
COUT

VERSUS TIME

0.0

TI "E
0.0
8.0000E-02

l.bOCOE-OI
2.4COOE-Cl
3.2000E-01
4.0000E-Ol
4.8000~-01

5.6000E-Ol
6.400()'E-01
7.2000E-01

a.OCCOE-OI
8.8000E-0!
9.6 eOOE-Ol
l.0400E 00
1.1200E 00
1.2000E 00
1.2800IE 00
1.3600E 00
1.44COE 00
1.5200E 00
1.bOCOE 00
1.6S00E 00
1.7600E 00
1.84001; 00
1.9200E 00
2.00001: 00
2.08CO~ 00
2.1600F. 00
2.2400E 00
2.3200E 00
2.4000E 00
2.4800E 00
2.5600E 00
2.6400E 00
2.72COE 00
2.8000E 00
2.8800E 00
2.96001; 00
3.0400E 00
3.1200E 00
3.2000~ 00
3.2800E 00
3.3600E 00
3.4400E 00
3.5200E 00
3.6000E 00
3.6800F. 00
3.7600':: 00
3.84001: 00
3.9200E 00
4.00COE 00

MAXIMUM
1.1628E 00
I

COUT
0.0
1.2118'=-02
4.5165E-02
9.6963E-02
1.6191E-01
2.3704E-Ol
3.1907E-01
4.05041:-01
4.9235E-Ol
5.7873£=-01
6.6229E-Ol
7.4146E-Ol
8.1503E-01
8.8209E-01
9.4202E-01
9.9446E-Ol
1.0393~ 00
1.0765E 00
1.1065!: 00
1.1295E 00
1.1460E 00
1.15671: 00
1.1621E 00
1.1628E 00
1.l596E 00
1.1531E 00
1.1440~ 00
1.1328E 00
1.1201E CO
1.l0t5E 00
1.0923E 00
1.0781E 00
1.0641E 00
1.05071= 00
1.0381': 00
1.0264E 00
1.0159E 00
1.0065E 00
9.9837E-Ol
9.9147E-0l
9.8579E-01
9.8129E-Ol
9.7789(-01
9.7552E-01
9.7408E-01
9.7346E-01
9.7356f-Ol
9.7427E-01
9.7548E-Ol
9.7709E-01
9. HOlE-Ol

1

+
+
-+

----+
------+
----------+
-------------+
-----------------+
---------------------+
------------------------+
----------------------------+
-------------------------------+
-----------------------------------+
-------------------------------------+
----------------------------------------+
------------------------------------------+
--------------------------------------------+
----------------------------------------------+
-----------------------------------------------+
------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
------------------------------------------------+
------------------------------------------------+
-----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
---------------------------------------------+
---------------------------------------------+
--------------------------------------------+
--------------------------------------------+
-------------------------------------------+
-------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
------------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
-----------------------------------------+
------------------------------------------+
------------------------------------------+

Fig.4.26 Step response for Example 4.6 without PID controller.

223

224

Further Application of CSMP

Ch. 4

INITIAL
T = 0.01
El = 0.0
INTGl = 0.0
KINTG = 20.0
KPROP = 12.0
KDERIV = 4.0
DYNAMIC
E = INPUT - RESP
INPUT = STEP(O.OI
RESP = INTGRL(O.O,Xll
Xl
REAlPl(0.0,1.0/2.0,X21
X2 = 2.0*X3
X 3 = l HO l D ( A1 , Y)
Al = IMPULS(O.O,T)
PROCEDURE Y = PtC(41,E,El,T,KPROP,KINTG,KOERIV,INTGll
IF(Al.NE.l.01 GO TO 10
IF(KEEP.NE.l.0) GO TO 10
EPROP = KPROP*E
EDERIV = KOERIV*(l.Q/TI*(E - Ell
tNTG = INTGI + T*E
EINTG = KINTG*INTG
Y = EPROP + EDF.R!V + EINTG
El = ~
INTGI = I~TG
10
CONTI NUE
ENDPRO
t.1ETHtD RKSFX
TIMER FINTIM
4.0, aUTDEL = 0.08, DELT = 0.001
PRTPLT RESP
LABEL OUTPUT FOR EXAMPLE 4-6 WITH PID CONTROLLER
END
ST':JP
ENOJOB

Fig.4.27 CSMP program listing for PID controller. (Example 4.6.)

Simulation of Digital Logic

The capability for simulating various digital logic functions is available in
CSMP. We recall that functional blocks such as INTGRL are the key elements
for simulating continuous systems. The same holds true for the digital logic case
in that again standard blocks are available which make it possible to simulate
practically any digital configuration.
Most of the functions related to logic simulation are given in Table 4.2.
These functions are also given in Appendix I along with other special switching
logic. As an introduction, example problems are given below that illustrate how
these elements can\be used in combination to perform useful logic tasks.
Example 4.7

This problem illustrates how a random-generated binary number (either 0, 1,2, or 3)
can be processed through digital logic so as to form the equivalent decimal representation
of the number and thereby activate the proper edges of a Nixie light.
In Fig. 4.29(a), XLI and XL2 form the binary representation of 0, 1, 2, and 3. El
through E7 in 4.29(b) is a truth table for the edges of the light as defined in 4.29(c). The

OUTPUT FOR EXAMPLE 4-6 WITH PIO CONTROLLER
~It-.lI~U~

PAGE
RESP

VERSUS

TI~E

0.0

TI ~E
0.0
8.0000E-02
1.6000=-01
2.4000E-Ol
3. 2000~-01
4.0000E-Ol
4.ROOOE-01
5.6000E-01
6.4000'=-01
7.2000E-Ol
8.0000E-Ol
8.BOOOE-Ol
CJ.6000E-Ol
1.04COF 00
1.ll00E 00
1.l000E 00
l.2BOOE 00
1.3600E 00
1.4400F. 00
1.5200E 00
l.bOOOE 00
l.6eOOE 00
1.7600E 00
1.84COE 00
1.9200E 00
2.0000E 00
2.0800F. 00
2.16001; 00
2.2400F. 00
2.3200r 00
2.4000E 00
2.48001: 00
2.5600E 00
2.6400E 00
2.7200F 00
2.8000E 00
2.8800F 00
2.CJ6COE 00
3.·0400F 00
3.1200E CO
3.2000E 00
3.2800E 00
3.3600E OC)
3.4400E 00
3.5200E 00
3.6COOE 00
3.6800E 00
3.16COE CO
3.8400e 00
3.9200E 00
4.0000E 00

9.9818~-Ol

9.964bE-Ol
9.9519E-Ol
9.943lE-01
9.9319E-Ol
9.9355E-Ol
9.9356E-Ol
9.9l75~-01

9.93 09E-0J.
9.9454E-Ol
9.9506E-01
9.9562E-01
9.CJ620E-OI
9.9617E-OI
9.9132E-01
9.9784F.-01
9.9832E-Ol
9.9875~-01

9.9913E-01
9.9946E-Ol
9.CJ914E-OI
9.9997E-Ol
1.0001': 00
1.0003E 00
1.0004E 00
1.0004E 00
1.0005E 00
l.0005E 00
1.000S!:; 00
1.0005E 00

MAXIMUM
1.0177F 00
I

RESP

0.0
1.9619E-OI
l.0108E 00
1.0625: 00
1.015SE 00
1.0177E 00
1.0158E 00
1.0718E 00
l.0664E 00
1.0601E 00
l.0533E 00
1.0463': 00
1.0393E 00
l.0326E 00
1.0263E 00
1.0205'= 00
l.OlS2E 00
I.Ol06E 00
l.0066E 00
1.0032!:: 00
1.0004E 00

1

+

------------------------------------+
----------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
-------------------------------------------------+
------------------------------------------------+
------------------------------------------------+
------------------------------------------------+
-----------------------------------------------+
-----------------------------------------------+
-----------------------------------------------+
-----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
----------------------------------------------+
"--+
----------------------------------------------+
----------------------------------------------+

Fig. 4.28 Step response of system with PID digital controller.
(Example 4.6.)

225

226

Further Application of CSMP

Ch. 4
Table 4.2

Logic Functions for CSMP (Also, see Appendix /)

Statement Form

Function

y=o
Y

y N-I = Previous state of flip-flop

=

1

=01

RESETTABLE FLIP-FLOP

= 1 Xl <0,
Y = 0 X 2 :::;;;0,
Y = 1

Y = COMPAR (X b X 2 )
COMPARATOR

y=o
Y = 1

Y

Xl X 2

Y = 1 Xl> 0, X 2 > 0
y=o OTHERWISE
Y = NAND (Xl' X 2 )
NOT AND

y=o Xl> 0, X 2 > 0
Y= 1 OTHERWISE

Y = lOR (Xb X 2)
INCLUSIVE OR

y=o Xl :::;;;0, X 2 <0
Y = 1 OTHERWISE

Y = NOR (X b X 2 )
NOT OR

Y = 1 Xl :::;;;0, X 2 <0
y=o OTHERWISE

EXCLUSIVE OR

Y = 1 Xl :::;;;0, X 2 > 0
Y = 1 Xl> 0, X 2 <0
y=o OTHERWISE

Y = NOT (X)
NOT

Y = 1 X:::;;; 0
y=o X>O

Y = EQUIV (Xl, X 2 )

Y = 1 Xl :::;;;0, X 2 <0
Y = 1 Xl> 0, X 2 > 0
Y=O OTHERWISE

EQUIVALENT

logic statements defining EI through E7 are:
EI
E2
E3
E4
E5
E6
E7

=
=
=
=
=
=
=

XLI· XL2
XLI + XL2
1.0
XLI + XL2
E2
XL2
XLI

(not XLI and not XL2)
(XLI or not XL2)
(always on)
(not XLI or XL2)
(same as the state of E2)
(not XL2)
(the state of XLI)

Ch. 4

Further Application of CSMP

Number

XLI

XL2

0
1
2
3

0
0
1
1

0
1
0
1

221

(a) Binary values of XLI and XL2 for given decimal numbers.
El

E2

E3

E4

E5

E6

E7

Number

1
0
0
0

1
0
1
1

1
1
1
1

1
1
0
1

1
0
1
1

1

o

o

o

o

1

1
1

2

o

1
3

(b) Truth table for light edges.
E2
El

E3
E7

E6

E4
E5

(c) Light edge definition.
Fig.4.29 Diagram defining logic properties for Example 4.7
A logic circuit for performing the above functions is given in Fig. 4.30 where we
assume the random number is available from XLI and XL2.
The program for making this simulation will first use RNDGEN to generate a
random number. The number so generated will lie between 0 and 1. The output of the
random number generator wiII be partioned as follows:
For

0 .977
71.878
78.207
84.969
92.152
99.723
107.61
115.71
123.85
131.78
139.18
145.66
150.71
154.06
155.15
153.81
150.00

ERROR,(b.

0.0
3.279 L LE-J2
0.13132
0.29585
0.52689
0.82510
1.1914
1.6268
2.1328
2.1L07
3.3623
4.0895
4.8946
5.7798
6.7478
1.8014
8.9437
10.17d
11.501
12.936
14.467
16.105
17.853
19.715
21.696
23.797
26.022
2t1. 3 73
30.851
33.456
36.184
39.030
41.986
45.040
48.172
51.359
54.568
57.759
60.881
63.874
66.667
69.179
71.326
73.016
74.162
14.688
74. '>29
73.645
72.025
69.684
66.667

ERROR(7)
0.0
3. 01971E -02
0.1'2088
0.27225
0.48465
0.75854
1.0945
1.4934
1.9559
2.4832
3.0163
3.7365
4.4651
5.2635
6.1333
7.0759
8.0932
9.1865
10.358
11.608
12.936
14.351
15.846
17.423
19.083
20.824
22.645
24.542
26.510
28.544
30.632
32.766
34.929
37.103
39.261
41.393
43.45L
45.403
47.211
48.829
50.210
51.307
52.072
52.461
52.436
51.969
'>1.043
49.652
47.807
45.530
42.857

ERROR(8)
0.0
2.719L2E-02
0.10884
0.24504
0.43597
0.68192
0.983 L4
1.3400
L.7531
2.2227
2.7494
3.3336
3.9161
4.6711
5.4312
6.2568
7.1360
8.0751
9.0139
10.132
1l.249
12.423
L3.652
14.935
16.268
17.647
19.067
20.521
22.001
23.498
25.000
26.493
27.962
29.387
30.750
32.025
33.190
34.216
35.075
35.741
36.184
36.319
36.303
35.938
35.270
34.292
33.004
31.414
29.535
27.389
25.000

ERROR(9)
0.0
2.37885E-02
9.51996E-02
0.21423
0.38091
0.59528
0.85732
1. .1611
1.5246
1.9298
2.3825
2.8827
3.4300
4.0242
4.6647
5.3507
b.0815
6.8557
7.6119
8.5281
9.4220
10.351
1l.3li
12.298
13.307
14.332
15.367
16.403
17.431
18.441
19.421
20.357
21.237
22.044
22.761
23.372
23.• 859
24.205
24.391
24.403
24.226
23.848
23.259
22.455
21.432
20.194
18.747
17.100
15.267
13.265
11.111

ERROR(10
0.0
L.99890E-1
7.9956 LE-I
0.11982
0.31946
0.49870
0.71127
0.97485
1.2711
1.6053
1.9771
2.3856
2.8298
3.3088
3.82LO
4.3650
4.9389
5.5405
6.1611
6.8159
7.4834
8.1655
8.8578
9.5549
10.251
10.940
11.614
12.265
12.885
13.463
13 .990
14.455
14.846
15.152
15.361
15.462
15.444
15.296
15.009
14.576
13.990
13.248
12.347
11.289
10.077
8.7149
7.2117
5.5166
3.8210
1.9576
0.0

Fig. 5.4 Typical print-out from OUTPUT statement for 6-9
variables.

250

STEADY-STATE ERROR OF AN ACCELERO'lETER AS A ,FUNCTION OF FREQUENCY AND DAMPING FACTOR
TYPICAL OUTPUT FOR 10-55 VARIABLES
FREO

0.0

2.00000E-02

4.00000E-02

6.00000E-02

8.00000E-02

E RRnR (l)
ERRORI21
ERROR 0)
ERROR 141
ERRORI51
ERRORI61
ERROR I 71
ERROR(8)
ERRORI91
ERROR (l0)
ERROR Ill)
ERROR I 121
ERROR (13)
ERROR I lit)
ERRORCl5)
ERROR (161
ERRORCl71
ERRORCl81
ERROR Cl9)
ERROR 120 I

0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0
0.0

3.98102E-02
3.91998E-02
3.82080E-02
3.68042E-02
3.50037E-02
3.27911E-02
3.01971E-02
2.71912E-02
2.37885E-02
1.99890E-02
1.57776E-02
1.11847E-02
6'.17981 E-03
7.78198E-01t
-5.06592E-03
-1.12610E-02
-1.774bOE-02
-2.47955E-02
-3.21350E-02
-3.99475E-'02

0.15944
0.15703
0.15302
0.14738
0.14015
0.13132
O. 12088
0.10884
9.51996E-02
7.99561E-02
6.31256E-02
4.46930E-02
2.46735E-02
3.06702E-03
-2.01263E-02
-4.49066E-02
-'7.11975E-02
-9.91821E-02
-0.12868
-0.15977

0.35947
0.35400
0.34492
0.33218
0.31583
0.29585
0.27225
0.24504
0.21423
0.17982
0.14185
0.10028
5.51910E-02
6.54602E-03
-4.55780E-02
-0.10129
-0.16045
-0.22305
-0. 28 1l18
-0.35873

0.64085
0.63107
0.61476
0.59196
0.56265
0.52689
0.48465
0.43597
0.38091
0.31946
0.25169
0.17761
9.12900E-02
,1.07lt22E-02
-8.19550E-02
-0.18079
-0.28558
-0.39650
-0.51329
-0.t:3596

fREe

0.18000

ERROR (1)
ERROR (2)
ERROR 0)
ERRORI41
ERROR(51
ERROR (6)
ERROR( 71
ERROR 181
ERROR(91
ERROR ClO)
ERROR Ill)
ERROR (12)
ERROR I 131
ERRORI141
ERRORI151
ERRORIl6)
ERROR 1171
ERRORCl8)
ERRORI19)
ERROR (20 I

~

"""

0.20000

4.1441
3.3306
4.0764
3.2770
3.9638
3.187'"
3.8068
3.0636
3.6061
2.9043
3.3623
2.7107
3.0763
2.4832
2.7494
2.2227
1.9298
2.3825
1.6053
1.9771
1.5346
1.2504
0.86581
1.0565
0.54440
0.45276
1.23138E-02 0.0
-0.45436
-0.57500
-1.1788
-0.94608
-1.8096
-1.4616
-1.9997
-2.4657
-3.1451
-2.5589
-3.8462
-3.1383

1.0049
0.98949
0.96375
0.92775
0.88152
0.82510
0.75854
0.68192
0.59528
0.49870
0.39229
0.27614
0.15033
1.49994E-02
-0.12973
-0.28378
-0.44699
-0.61919
-0.80026
-0.99013

0.12000

0.14000

0.16000

1.1t535
1.9888
2.6131t
1.1t310
1.9576
2.5119
1.3934
1.9057
2.5029
1.3409
1.8332
2.4066
1.2735
1.7402
2.2831
1.1914
1.6268
2.1328
1.0945
1.4934
1.9559
0.98314
1.3400
1.7531
0.85732
1.1671
1.52106
0.71727
0.97it85
1.2111
0.99303
0.56314
0.76364
0.53383
0.39516
0.69113
0.21350
0.28581
0.36603
1.84326E-02 1.998'iOE-02
1.8lt326E-02
-0.18980
-0.26311
-0.35091
-0.56320
-0.41106
-0.14120
-0.64481
-0.87968
-1.1511
-0.89111
-1.2120
-1.5816
-1.1495
-1.5591
-2.0300
-1.4195
-1.9223
-2.4961

0.28000

0.30000

0.32000

0.34000

6.0777
8.4569
5.0581
7.2084
4.9740
5.9747
7.0837
8.3072
4.8343,
8.0590
5.8037
6.8768
5.5657
6.5891
7.7144
4.6397
5.2621
6.2226
7.2762
4.3910
4.8946
6.7478
4.0895
5.7798
3.7365
4.4651
5.2635
6.1333
5.4372
3.3336
3.9761
4.6771
4.6647
3.4300
4.0242
2.8827
2.8298
3.8210
2.3856
3.3088
2.9119
1.8445
2.1785
2.5349
1.2616
1.4791
1.7010
1.9431
0.92043
0.63914
0.73494
0.82953
-2.03094E-02 -5.0b281E-02 -9.31854E-02 -0.15018
-0.71442
-0.87425
-1.0565
-1.2630
-1.4406
-1.7326
-2.4123
-2.0561
-2.1964
-2.6222
-3.0876
-3.5928
-4.7991
-2.9793
-3.5398
-4.1467
-4.4822
-6.0264
-3.7868
-5.2295
-7.2700
-4.6166
-5.4463
-6.3320

9.8304
9.6520
9.3566
8.9469
8.4270
7.8014
7.0759
6.2568
5.3507
4.3650
3.3071
2.1845
1.0049
-0.22418
-1.4951
-2.8026
-4.1382
-5.4962
-6.8709
-8.2569

11.337
11.126
10.776
10.292
9.6793
8.9437
8.0932
7.1360
6.0815
4.9389
3.7180
2.4286
1.0802
-0.31199
-1.7568
-3.2282
-4.1239
-6.2369
-7.1606
-9.2888

12.988
12.738
12.326
11.751
11.038
10.178
9.1865
8.0151
6.8551

0.22000

0.24000

0.10000

0.26000

Fig. 5.5 Typical print-out from OUTPUT statement for 10-55
variables.

5.51t05
4.1418
2.6120
1.1429
-0.43(>(Xll( • • • • • • • • • ~ • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
1I+>(>(Xll(lI(x • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
"*+)()(lI(lI(lI(lI( • • • ~ • • • • w • • • • • • • • • • • • • • • • • • • • • • • • • • •
"*+)()()(lI(lI(lI(xx • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

•••••••••••••••••••••••••••••••••••••••••••••
xx • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
Xll( • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

*xx • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

.... ,..

....

~

.... LI'

....

"

~

I
I

UJ

oo~

(>(>(X)()()(XXXXXXX.¥X.XXXXX.XXXX~.

"
" " * * * + + • • ++>()(>(X)()(X)(XXXX~XXXXX¥XXXX.X.XXXX
""
*.**++++++X>(>(>(X)(XXX)(XX¥XX.X~XXXXXX~XXXX
""
***+++++++>(XXXXX)()()(XXXXXXxxxxXxXXXXXX¥
""
****++++++>(XX>(X>(>(Xx>(XxxxxxxxxxxxxxxXXX
"
~****++++++>(>(>()(>(X>(X>(>(X>(>(>(xxxxxxxxxxXxx
"
1****+++++++XXX)()(>()(XXXX)(XXX¥XXxXXXXXX¥
"
*****+++++++>(>(X)(X>(>(XX>()(>(>(Xx)(Xxxxxxxxx
"
"****++++++++)()(X>(X>(X>()(X>(>(XX)(X>(XXXXXxX
"
"*****++++++++>()(X>(XX>(X>(>(XXXX>(X>(XX>(Xxx
"
"******++++++++X)(XX>(X>(>(>(XXx)(>()()()(XX)()()(
I
" "*****++++++++++>(>(>(>(>(>(x>(>(>()(>(>(>(>(x>(>(X>(

Q:

•

....

:: :: ~ : : : : : ; :

C~
~:

~

CI-I-O

0000

': :: ::

"::II

-'0

::

N-cN(x)

,

:
:,

~""..t..t

II

II

II

II

0-

* lI(.

I

:,

w
..J

· ..

-cN(X)

Wrt'l..t..t
ex:

CO

I
,,
,
,

,..

(,!)

DUO
~I-~

· ..

000

..to-c

-c

- -)(.-

I-

a

II

II

(0

U

(

:) It

0

w

, .+ .

<1:-

r

I/) _

II

II

"
I

,

,
I

,,

,
,

,
,
,

I

-

oooooooo~oooooooooooo~oo~oooooooooooooooooooo
OO'Joooooooooooooo~ooooooooooooo~ooooooooooooo

0000000 a 0

••••••••••••••••••••••••••••••••••••

• • • • • • • • • oO'Joooo~oooooooooooooooooooooooooooo
xooooooooooO-'~~~~~,..~~O~N""~~~,..~~O~N~..t~~~roo-O~N~~~

w

=~-'N~..tLl'~,..CO~~~~~~~-'-'~~N~NNNNNNNN~~~""~~""~~~~#~..t#~

259

.....

M

:::: vi

~oo'J

"",""'..t

Q)

* ,....

:: ':

"

::::::

*

:

N

a.Nro..t

1/2

~

: :: : :: :: :: ! :: :: ::: 'E.
::*~:::::::!::::!: ~§

·..

w

V)

)W

~,::::::::

~

IJJ

-'
~ 0..
·X

:':::::: :: ::::

1- ............
W

II

"""

,

..t

,) I
c :l!.
JZ
......

""
I

,
,

~a.

UJ
.1-

::

~

,

II

...J

:

:: ~ : : : : :: : : :: : : : : : : : : : : : : : : : ! : !: 'g
:: ::~::::::::::::::::::::::::::: ~

,,

LI'

""..t..t
II

::

II

a:OQIX

....

! !: : : :

!:
~~~~~~ ~~~~~~ ~~~
~
~::::::!!::!:::::~~~:~:~:~~~~:~~:~ ~
:,::::::;:::::::::::~~:~~~~~~:::~~~ 0
~
! : : : : : ~ ~ ~ ~ ~ ~ ~ ~ :: "0

: :::: : : : : : ! : : : : : : : : :
:::~::::::::::::::!:::!:::::~:~~:~~
: II:: *!" *:: *: *: *: *: *: *: *:*:+:+:+:+:+:+:+:+!+:+: +: +: +: +: +: +: +: +::+ ~
"""

~

IX

UJ
..J

=:::::::

::::~~=:::=::::::::::::=:=:=::::::::

I U*+XXXXlI(lI(lI(.xx • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •
I "*++XXXXXXXXXXX • • • • • • • • • • • • • • • • • • • • • • • • • • • •
I U*++)(XX)(lI(XXXx~XXX • • • • • • • • • • c • • • • • • • • • • ~ • • ~ •
1I**++X)(>(>(XX.lI(XxlI(Xx • • • • • • • • • • • • • • • • • • • • • • • ~.
"**++X>(XX>(XXX~XXX.XX • • • • • • • • • • • • • • • • • • • • • • •
I 1I~+++>(>(>(>(X.XXXxxlI(XXXX • • • • • • • • • • • • • • • • • • • • •
I "**+++>(>(>()(>(XXXXX • • XXXXX • • • • • • • • • • • • • • • • • • •
1 "~*+++>(>(X>(>(>(XXXll(x • • x.XXXX • • • • • • e • • • • • • • • • •
I II***+++>(>(>(X>(>(X.XX.XXXXX.XX • • • • • • • • • • • • • • • •
'IIU~*++++>()(>(X>(>(XXlI(lI(lI(lI(lI(~lI(X.X.X • • • • • • • • • • • • • •
,""**++++>(X>(>(>(>(>(lI(XXXlI(X • • XXXXXXXX • • • • • • • • • • •
"U***++++)(>(>(X)(XXlI(XXXXXX • • • XXXXXXXX
.~.~s • • ~
" " "**+++++X>(>(>(>(XXX¥XXXXX~X~XXXxx¥~
.XXX.~R.
, U"***++++X>(XXX>(XXXXX¥XXXXX_XXxXxxx.XXXX~XX
, ""***+++++>(XX>(>(>()(X)(XXXXXXX.X~.XXXXXXXXXXXX

~
~

260

Ch. 5

CSMP 11/

OUTPUT ERROR(8), ERROR(9), ERROR(12), ERROR(15)
PAGE NTAB = 2, GROUP = 4, SYMBOL = (A, B, C, D)

The output for the above statements is shown in Fig. 5.13.
Note that the NTAB parameter provides that only the first two variables
have tabulated output. The GROUP parameter provides that all four variables
are plotted with the same ordinate scale. The SYMBOL parameter specifies that
the letters A, B, C, and D are used to identify the printer plots of the variables
ERROR(8), ERROR(9), ERROR(l2), and ERROR(l5), respectively.
CALL PRINT and CALL OUTPUT

Both the PRINT and OUTPUT instructions can be invoked at any point in
the program by using the CALL statement. These output statements are normally
invoked when specified conditions occur, where the IF instruction is usually used
to branch to the CALL statement. An example of using the CALL OUTPUT
statement is shown below.
NOSORT
IF(X.GT.6.0) CALL OUTPUT

Note that both the CALL PRINT and CALL OUTPUT statements must be used
in nosort or procedure sections. The use of the CALL instruction assumes that
the appropriate PRINT or OUTPUT statement is defined in the program. If either
of the CALL instructions are invoked at a normal PRDEL or OUTDEL interval,
the duplicate printing is suppressed.
As in Sj360 CSMP, the FORTRAN WRITE statement in nosort or procedure
sections is allowed. In some circumstances, this type output may be desirable.
RANGE

This instruction is used to list the maximum and minimum values of selected
variables and the time of occurrence. Its function in CSMP III is exactly the same
as in Sj360 CSMP. The only difference is that the maximum number of variables
allowed in a RANGE statement is 110. An example of a valid instruction is shown
below.
RANGE G, H,'Xl, Yl, T, COST, Q, ...
L, J, R

Subscripted variables should not be used in a RANGE statement.

Functions

In addition to the functions available in Sj360 CSMP, CSMP III provides
the user with additional function blocks. This section briefly describes some of the
more important functions available only in CSMP III.

'C'=ERROR(2)

-40.00
-40.00
-40.00

~
....

FREQ
0.0
2.00000E-02
4.00000E-02
6.00000E-02
8.00000E-02
0.10000
0.ll000
0.14000
0.16000
0.18000
0.20000
0.22000
0.24000
0.26000
0.28000
0.30000
0.32000
0.34000
0.36000
0.38000
0.40000
0.42000
0.44000
0.46000
0.48000
0.50000
0.52000
0.54000
0.56000
0.58000
0.60000
0.62000
0.64000
0.66000
0.68000
0.70000
0.72000
0.74000
0.16000
0.78000
0.80000
0.82000
0.84000
0.86000
0.88000
0.90000
0.92000
0.94000
0.96000
0.98000
1.0000

ERRDR(8)
0.0
2.71912E-02
O.10H84
0.24504
0.43597
0.68192
0.98314
1.3400
1.7531
2.2227
2.7494
3.3336
3.9761
4.6771
5.4372
6.2568
7.1360
8.0751
9.0739
10.132
H.249
12.423
13.652
14.935
16.268
17.647
19.067
20.521
22.001
23.498
25.000
26.493
27.962
29.387
30.750
32.025
33.190
34.216
35.015
35.141
36.184
36.379
36.303
35.938
35.270
34.292
33.004
31.414
29.535
27.389
25.000

40.00
40.00
40.00

'8 t =ERROR(9J
'A'=ERROR(8'

1-------1-------1-------1-------1-------0-------1-------1-------1-------1-------1
1

1

I

1

I

0

1

I

I

1

I
1

I
I

I
I

I
I

I

0

I
I

I
I

1
I

I
I

I

1

1

0
D

I
I

I

I
I

I

I

I

I

I

I

1-------1-------1-------1-------1-------08------1-------1-------1-------1-------1
I
I
I
1
1
DB
I
I
I
I
1
1
1
1
1
1
DC
1
1
I
1
1
I
I
I
I
1
OCB
I
1
I
I
I
I
I
I
I
I
DC 8
I
1
I
I
I
I-------I-------I-------I-------I------OIC8A----I-------1-------1-------1-------1
I
1
1
I
I
D1C 8
I
I
I
I
I
1
I
1
I
DIC BA
I
I
I
I
I
I
I
I
1
1
1
0 1 C 8A
1
1
I
I
I
I
1
I
I
I
01 C 8 1
I
1
1
I
l-------I-------I-------I-------I-----0-I-C--8A-l-------1-------1-------1-------1
I
1
1
1
1
0 I C
BAI
I
1
I
I
1
1
1
1
I
0 I C BA
I
I
I
I
I
1
1
I
I
0 1 C
BA
I
I
I
I
0
I C
I BA
I
I
I
1
1
I
I
1
I
I-------I-------I-------I-------I----O--I--C----I-BA----1-------1-------1-------1
I
I
I
1
10
I
C IB A I
I
I
I
I
I
1
1
10
I
C
I B AI
I
I
I
1
I
1
I
1 0
I
C
I
B AliI
I
I
1
1
I
10
I
C
I
BA
I
I
I
l-------1-------I-------I-------1-0-----I---C---l-----B-I-A-----I-------I-------I
1
I
I
I
10
I
C
I
BA
I
I
I
I
1
1
I
10
I
C
I
IB
A I
I
1
I

1

I

I

0

I

C

I

16

AI

I

I

I
I
I
I
01
I
C
liB
A
I
I
I-------I-------I-------1-----0-1-------I---C---l-------I---B---IA------I-------I
I
I
I
1
01
1 C
1
I
B I A
1
I
1
1
I
101
IC
1
I
Bl
A I
I
I
I
I
101
I C
I
I
BI
AI
I
I
I
I
I 0
1
I C
1
I
BI
AI
I
l-------1-------1-------10------I-------I-C-----I-------I-------8-------A-------I
I
1
I
0
1
IC
I
I
B
I A
I
I
I
I
01
I
C
I
I
B
I A
I
I
I
I
0 I
I
CI
1
I
IB
1 A
I
I
1
1
0 1
I
CI
I
1
IB
I
A I
I-------I-------I---D---I-------I----C--I-------I-------I-------IB------I----A--I
I
I
ID
I
I
C
I
I
I
B
I
A I
I
I
10
1
1 C
I
liB
I
A I
I
I
0
I
I C
I
I
I
Bl
I
A I
I
1
01
I
C
I
I
I
BI
I
A I
l-------I----O--I-------I------CI-------I-------I-------I---B---I-------I--A----I
1
1
0
I
1
C I
1
lIB
I
IA
1
1
I 0
1
I
C I
1
I
IB
I
A
I
10
1
I C
I
I
I
BI
I
AI
I
I
I
0
1
IC
I
I
I
B I
I
A I
I
I-----O-I-------I------CI-------I-------I-------I--B----I-------IA------I-------I

Fig. 5.13 Printer-plot to illustrate the use of NTAB, GROUP,
and SYMBOL.

ERROR(9)
0.0
l.31885E-02
9.51996E-02
0.21423
0.38091
0.59528
0.85732
1.1671
1.5246
1.9298
2.3825
2.8827
3.4.300
4.0242
4.6647
5.3501
6.0815
6.8551
7.6719
B.5281
9.4220
10.351
11.311
12.298
1.3.307
14.332
15.367
16.403
17.431
18.441
19.421
20.357
21.237
22.044
22.761
23.372
23.859
24.205
24.391
24.403
24.226
23.848
23.259
22.455
21.432
20.194
18.741
11.100
15.267
13.265
11.111

262

Ch. 5

CSMP 11/

Arbitrary Function Generators

The AFGEN and NLFGEN function generators used in S/360 CSMP are
also available in CSMP III. There are two additional arbitrary function generators
available for CSMP III users, FUNGEN and TWOVAR.
FUNGEN

This arbitrary-function generator allows the user to choose the degree of
interpolation. A typical statement is shown below.
Y = FUNGEN(ABC, N, X)
where

Y = dependent variable (output)
ABC = function name, it is defined on a FUNCTION card
N = degree of interpolation, may be 1, 2, 3, 4, or 5. N must be an
integer constant or integer variable.
X

= independent variable (input)

When N = 1, FUNGEN is identical to AFGEN; and when N = 2,
FUNGEN uses second-degree interpolation which is the same as NLFGEN.
CALL FGLOAD

In addition to specifying x-y data in a FUNCTION statement as illustrated
in Example 2.4, a CALL FGLOAD instruction using SUbscripted variables can be
used to load the data. A typical set of statements follows.
independent variables
dependent variables
(
(
INITIAL
STORAGE X(26), Y(26)
This statement must be used to specify
SYSTEM NPOINT = 26
the number of data points.
NOSORT
'}
:
generation of the values of X(i) and Y(i)
CALL FGLOAD(ABC, X, Y, 26)
~'-- dependent variables
independent variables
In the above example, 26 pairs of subscripted variables are read in or generated in the Initial segment. This data is then entered into the function ABC by
the CALL FGLOAD instruction. The values of the independent variables X
must be monitonically increasing and single-valued. A typical set of instruction
for using the data entered by the CALL FGLOAD statement is shown below.
COST = AFGEN, (ABC, UNITS)
FUNCTION ABC
~ dummy statement to instruct the CSMP translator
that the name ABC is an arbitrary function

CSMP //I

Ch. 5

263

This function loading capability is useful when the x-y relationship results
from complex calculations. Computer time can be saved by performing the calculations only once in the Initial segment and then using an arbitrary function generator to return the values in the Dynamic segment.
TWOVAR

Z

=

This arbitrary function generator can be used for functions of the form
F(X, Y). An example of this statement is shown below.
Z

where

= TWOVAR(ABC, Y, X)

Z = dependent variable
ABC

=

function name

X & Y = independent variables
A graphical representation of Z as a function of X and Y is given by Fig. 5.14.

Fig. 5.14 Functional relationship between X, Y, and Z.

264

CSMP 11/

Ch. 5

Note in Fig. 5.14 that the three-dimensional surface is represented by four
lines each having a constant value of X. The functional relationship of Y and Z
for constant values of X is the format used to specify the function Z = F(X, Y).
Using the function name ABC, the following statements can be used to define the
functional relationship shown in Fig. 5.14.
Value of

l'

/

FUNCTION ABC, 0.0

=

FUNCTION ABC, 1.0

=

FUNCTION ABC, 2.0

=

FUNCTION ABC, 3.5

=

(0.0, 4.0),
(3.5, 1.7),
(0.0, 3.5),
(4.5, 1.8)
(0.0, 3.0),
(3.8, 1.6).
(0.0, 2.2),
(3.5, 0.9),

(Y, Z) Pairs of data

(0.5, 3.0), (1.5, 2.0), (2.5, 1.7), ...
(4.5, 2.0)
(1.0, 2.8), (2.0, 1.9), (3.0, 1.5), ...
(1.0,
(4.5,
(1.0,
(4.0,

2.3), (2.0, 1.8), (3.2, 1.6), ...
1.6)
1.2), (2.0,0.7),(2.8,0.75), ...
1.05), (4.5, 1.2)

Each FUNCTION statement contains the pairs of (Y, Z) values for a constant
value of X. The cards must be arranged such that the values of X be monotonically increasing in each FUNCTION statement. If the TWOVAR function should
have to extrapolate for values of either X or Y outside the specified range, a
diagnostic message will appear and computation will proceed.
CALL TVLOAD

Data for the TWOVAR function generator can be loaded using the subroutine TVLOAD. Its use is similar to FGLOAD, except TVLOAD must be called
to load the data for each family of curves having a constant value of X. An
example of loading the data contained in Fig. 5.14 for the curve X = 0 is given
by the following instructions.
INITIAL
STORAGE Y(6), Z(6)
SYSTEM NPOINT = 24, NFUN = 6
total number £-z)
point pairs.
NOSORT
TABLE Y(I-6) = 0.0, 0.5, 1.5,2.5, 3.5,4.5
TABLE Z(1-6) = 4.0, 3.0,2.0, 1.7, 1.7,2.0

Function~~~~~~aAD(AwBC
/ 'Y,Z, 6, 1,0.0)
Independent variable ~
Dependent variable
Number of (y-z) pairs
The curve number (1st curve)
Value of X for pairs of (y-z) data

(number of function
curves plus two.

Ch.5

CSMP 11/

265

The CALL TVLOAD statement is used three more times to load the y-z data for
the curves X = 1.0, X = 2.0, and X = 3.5.
An example of the second CALL TVLOAD statement is shown below.
CALL TVLOAD(ABC, Y, Z, 5,2,1.0)

The value of X must be monotonically increasing for the successive CALL
TVLOAD instructions. The range of Y should be the same for each call instruction
and must be monotonically increasing.
A typical set of instructions for using the TWOVAR arbitrary function which
is loaded by the subroutine TV LOAD is shown below.
Q = TWOVAR(ABC, R, S)
FUNCTION ABC }
FUNCTION ABC -Two dummy FUNCTION statements

are required.
SLOPE

This function is used to calculate the slope of a function specified by data
points in a FUNCTION statement. It is not the time derivative as given by the
DERIV function. The standard form is given below.
Y

where

=

SLOPE(ABC, N, X)

Y = the slope of the function ABC at X.
Y _ df(X)
dX

ABC = function name containing the x-y data. The data may also be loaded
by the CALL FGLOAD statement.
N = an integer constant or variable giving the degree of the polynomial
that is used to fit the data. The slope is computed from a polynomial curve fit. N may be 1,2, or 3.
Example 3.12 in Chap. 3 illustrates the use of a macro to handle a general
transfer function. CSMP III has a function block for this purpose.
TRANSF

Consider the following general block diagram written in Laplace transform
notation.

The output for the above block can be obtained by using the following statement.
C = TRANSF(n, B, m, A, R)

266

CSMP 11/

Ch. 5

where n & m = integers giving the order of the denominator and numerator of the transfer function, respectively
B & A = subscripted variables defining the transfer function of the
denominator and numerator, respectively
R = input
The following statements should be used to declare A and B as subscripted
variables and to assign values to A(i) and B(i).
STORAGE A(m + 1), B(n + 1)
TABLE A(1 - (m + 1)) = ah a2, a3, ... , a m+l
TABLE B(1 - (n + 1)) = b h b2 , b 3 , ••• , bn + 1

Consider the example of simulating the following block diagram by the use
of the TRANSF function.
R(s)
--+

ret)

= 12.0

S2

1.1s

4

+ 5s 2 +

+ 4s +
3

11.2
7s
2s
2

+ + 0.5

C(s)
--+

The program for determining the response is shown below.
STORAGE A(3), B(5)
TABLE A(1 - 3) = 5.0, 1.0, 11.2
TABLE B(1 - 5) = 2.0, 7.0, 4.0, 1.1,0.5
C = TRANSF (4, B, 2, A, 12.0)
PRINT C
TIMER FINTIM = 4.0, PRDEL = 0.08
END
STOP
ENDJOB

Control Statements

Additional control capabilities are available in CSMP III. They include
branching instructions, integration techniques, and double-precision calculations.
This section describes the additional control capabilities as well as the changes in
control statements.

END CONTINUE
This statement is used in CSMP III as the CONTINUE instruction is used
in S/360 CSMP. It allows a run to be interrupted so that data or control statements
can be changed during the simulation. A detailed explanation of the CSMP CONTINUE statement is contained in Chap. 3 in the section on translation control
statements.

Ch.5

CSMP 11/

261

INPUT and ENDINPUT

These labels are used to identify the set of cards containing data to be entered
into the program by the FORTRAN READ(5, XYZ) instruction. The INPUT
card must immediately follow the END statement. All data cards must be contained between INPUT and END INPUT. The END INPUT label must be punched
in card columns 1-8.
END
INPUT
:

} data cards

ENDINPUT
STOP
ENDJOB

In S/360 CSMP, the DATA and ENDDATA labels are used in place of INPUT and END INPUT. This is described in Chap. 3 in the section on data statements.
In CSMP III it is possible by the use of the CALL FINISH statement to terminate a run by branching to the Terminal segment. Also new parameters and
control variables can be introduced in the simulation by employing the CALL
CONTIN card.
CALL FINISH

This statement can be used in nosort or procedure sections to branch to the
Terminal segment. If there is no Terminal segment, the program will terminate
when the CALL FINISH instruction is encountered. The CALL FINISH instruction is normally used in conjunction with an IF statement as shown below.
IF(FORCE .GT. FMAX) CALL FINISH

CALL CONTIN

This statement is similar to the CALL RERUN instruction described in
Chap. 2. When the program encounters a CALL CONTIN statement, a new run
is initiated starting with the value of TIME from the previous run. The CALL
CONTIN card does not reset initial conditions. As with the CALL RERUN
instruction, the CALL CONTIN statement should only be used in the Terminal
segment and is normally used with an IF statement.
I ntegration Techniques

There are two additional integration methods available in CSMP III; RKSDP
and STIFF. As in S/360 CSMP, if the integration technique is other than the variable-step Runge-Kutta, it must be specified on a METHOD card as shown below.
METHOD STIFF

268

CSMP 11/

Ch. 5

RKSDP. This is the double-precision version of the variable-step RungeKutta method. To take advantage of the increased accuracy, the ABSERR and
RELERR parameters should be used to decrease the error-bound on the integrator
output. Additional information for using double-precision is contained in a following section.
STIFF. This variable-step integration method should be used'for the class of
problems represented by so-called "stiff" equations. These equations have solutions which have exponents which are greatly different as typified by Eq. (5.4).
x

=

Ae- t

+ Be-lOOt

(5.4)

STIFF integration is used because numerical solutions using a method such
as Runge-Kutta sometimes exhibit what is called partial-induced-instability when
solving a stiff equation. <3>
Array Integration

The array or specification form of the INTGRL function is also available in
CSMP III as illustrated by the following statement.
Y

= INTGRL(XO, X, 40)

The above instruction specifies an array of 40 integrators: Y = output,
XO = initial condition, and X = integrand.
Since the above INTGRL statement in CSMP III automatically specifies
that Y, XO, and X are subscripted variables, they must not be included in a
STORAGE or DIMENSION statement. Unlike S/360 CSMP, the initial conditions can be loaded using a TABLE statement. The EQUIVALENCE card that
is required in S/360 CSMP is not used in CSMP III. Examples of programs using
a CSMP III array integrator are shown in Figs. 5.10 and 5.15. The program of Fig.
5.15 shows the double-precision calculations used in the program of Fig. 5.10.
There are two additional variables that can be included on the TIMER card,
DELMAX and TIME.
DEL MAX

This symbol specifies the maximum allowable integration step size for all
variable-step integration methods. If not specified, the smaller of PRDEL or
OUTDEL is used.
TIME

This variable specifies the value of TIME at the beginning of the run. If not
included on the TIMER card, it is set equal to zero.
Double-Precision Operations

In some simulation problems the round-off errors with single-precision arithmetic are too large for satisfactory solutions. Double-precision calculation can

Ch.5

CSMP 11/

269

improve accuracy and is available in CSMP III. The following describes the various aspects of using double-precision.
integration. The following card provides double precision variable-step
Runge-Kutta integration.
METHOD RKSDP

The numerical integration calculations are performed in double-precision but
the output is returned in single-precision which is rounded from the doubleprecision results.
If double-precision output is required, the specification form of the INTO RL
statement must be used for all integration. The following two control cards should
be included.
SYSTEM DPINTG
METHOD RKSDP

Double-precision initial conditions may be set using the TABLE instruction.
Calculations. There are several rules that must be followed when using
double-precision numbers.

I All double-precision variables must be subscripted and all of these variables not appearing in the specification form of the INTORL function
must be declared on a REAL*8 card.
/

REAL*8

\

Q(15), P(30), S(60)

'-Column 7
" ' - - Virgule in column 1

The above instruction must appear before the first structure statement.
2 Double-precision numbers can be rounded and set equal to single-precision
numbers using the following statement.
Y

= ZZRND(X(4»

In the above instruction, the double-precision variable X(4) is rounded and
set equal to the single-precision variable Y.
3 Double-precision symbols starting with the letters I, J, K, L, M, and N
must be included on a FIXED card.
4 The double-precision symbol for TIME is ZZTIME.
5 The exponential form using D instead of E can be used for assigning values
to double-precision constants.
Y(3)
PI(1)

= 7.987654D5
=

3.1415926535898DO

(7.987654 x 10 6 )
(3.1415926535898)

Output. Double-precision variables cannot be used in standard CSMP III
output statements. They must be equated, or rounded using the ZZRND instruction before they can appear in CSMP output statements.

270

Ch. 5

CSMP //I

x=

XDP(l)
Y = ZZRND(YDP(l»
OUTPUT X, Y

(equated)
(rounded)

If double-precision output is desired, the FORTRAN WRITE statement
should be used as covered in Chap. 3 in the section on data output.
The program of Fig. 5.15 illustrates double-precision integration for calculating the transient temperature distribution of the copper rod of Example 5.3. A
FORTRAN WRITE instruction is used to print the double-precision result which
is shown in Fig. 5.16.
Note the differences between the double-precision program of Fig. 5.15 and
the single-precision program of Fig. 5.10.

*

CSMP III PROGRAM TO SIMULATE THE TRANSIENT TE~PERATURE DISTRIBUTIJN
OF A CCPPER RUD USING COUBL~ PRFCISIDN CALCULATIONS
INITIAL
I
REAL*8 DP( 7)
FIX FD T
TABLE TI(1-20)
20*3.002
SVSTE~ OPINTG
METt-CO RKSOP
RFLERR T(1-20)
1.0~-8
ABSERI{ T(1-20)
1.Of-8
NCSfJRT

*

*

T>-iE I)OllBLE PRECiSION SUBSCRIPTED VARIABLE DP(I) IS USED
TO I"lPUT THE VALUtS OF THE PARAMfHRS OF T~~ COPPEr< ROD UF EXAMPLE- 5.3

*

CPIII
DPI21

d.d9D3

DP( 3)

3.98D2
3.l:l6D2

\) P ( 4 I
DPI'3)
OP( (;)
[) P ( 7)

2 .0 0- 2
3.0C2
5.J02
f.)P (3 1 I ( DP 11) "'uP (2) "'DP 14 1 *oP (4) )

lCO

FnR~AT(5G22.12)

101
EDRM liT ( I , oX. • T I ME' , l8X, • T ( 41 • , 18 X, , T ( tl 1 • , 17 X, • r I 10)' ,17 X, ' T ( 16) • )
WRITF(6,lJll

DYNAMIC
NGSflRT
HHU = flP(71*(iJP(5)
!Vl 1 I
2,19

Te(ll
TD(201

- 2.0*T(l) + T(21)

=

fW(7)'*(T(!-1l

=

OP(71*IT(191

- 2.0*T(I) + T(I+1)
- 2.0*1(20) • DPlb»

SfJRI
T = INIGRLtTI, TD, 20)
NOSOR 1

*
*

THI: rCLLuWlr-.G f-ORIRAN WRITE STATFMENT PRUVIDES OUTPUT AT THE END OF
EACH TENTH VALID INIEGRATICN STEP
I F IKE EP • NE. 1 )

CT = CT .. 1.0
IFICT.LT.0.5)

G(1 TO 2

GU TO 2

WRlTEI6,lOJ) (Tlr-U:,

1(4), TIS).

CT = 0.0
2 CUN T I IIIU 1=
TIMER FINTIM = 450.0
END
STnp

T(lO),

T(1611

EI\iOJOR

Fig. 5.15 Simulation of the temperature of copper rod using
double precision.

Ch. 5

CSMP 11/

TItoIE

T(4)

1.26562500000
3.09375 )00000
5.90625JOOOOO
10.4062500000
17.7187500000
30.0937500000
51.4687500000
89.7187500000
148.218750000
199.968750000
253.96875(100n
303.468750000
355.2187500<)0
406.968750000
450.000000'100
$$$

SIMULATlrN HAL T"f'

~OO

T (8)

.000(10nCOO

100.nf\nf\000nn
11'0.1)('·')('()n?05
3nO. ',)000A,}()1/,
100.01014171 0
::InO.301>Q26535
103.n2}0??391
110. 61131 BnOQ9
::l17.18~;>09177

3?2.91l4 n Il1578
326.86354r)646
1;>9. ~84n<)o91>'i
""?.C9C7BB5
111.4811~11Q2
~('1P

FPIISH

fr"JI'lTTTn~1

161
300.004681049
300.194794311
301.805008651
108.069261558
322.048061889
343.563464148
369.055400686
394.918449206
415.596172422
426.321822957
433.850591096
438.733635794
442.442048677
445.134832194
446.807280527

T (In)

100.000000000
100.0n0000001
1I)n.0r)00n0950
3'10.000221716
10'l.nI461l8661>
1nO.336181644
102. 971H?'!!36
312.7271)54459
17.9. 4775'i021>A
141.543210126
3"il.104'i'l23'}a
151.5951>(1)186
167.611R40784
11>1>.2802,,1105
1I,S.564AI)S895
TIMr
45n.(1)

~OO.OOO(,OnnOO

271

T(

300.000000000
100.000000174
300.000061033
300.004986118
300.13'i408143
301.497811978
307.765962064
323.260691678
344.1413553'1''1
357.814603171
31i8.286939071
375.294859587
3110.685218191
1A4.61QB34664
387.068383799

Fig.5.16 Double precision output from program of Fig. 5.15.

REFERENCES
1. Continuous System Modeling Program III (CSMP III) Program Reference Manual,
SH19-7001-2, Program Number 5734-XS9, IBM Corporation, Data Processing Division, White Plains, N. Y.
2. Continuous System Modeling Program, Program Logic Manual, LY19-7000, IBM
Corporation, Data Processing Division, White Plains, N. Y.

3. Fox, LESLIE and D. F. MAYERS, Computing Methods for Scientists and Engineers,
Clarendon Press at Oxford, 1968, p. 215.

PROBLEMS
1 The equations which defined the concentrations of xenon 135 (X) and iodine 135 (I)
in a nuclear reactor which has been suddenly shut down are given below.

X=
i =

-2.09

X

1O- 5 X

+ 2.88

x 10- 5 1

-2.88 x 10- 51

The initial concentrations are
10 15 atoms per unit volume

X(O)

=

3

1(0)

=

7 x 10 16 atoms per unit volume

Find the concentrations at
ordinate.

X

t =

100,000 sec. Plot the results using a logarithmic

Answer:
At TIME

= 100,000 X = 1.761

X

10 16 I

= 3.929

X

10 15

2 In an epidemic of a contagious disease, the following Kermack-McKendrick set of
equations model the number of the population who are susceptible to the disease S,
the number of infectious carriers C, and the number of individuals who have recovered and are immune R.
S = -A·S·C

C=

A·S·C - B·C

R=B·C
A and B are constants which characterize the epidemic. Time is measured in days.

212

CSMP 1/1

Ch. 5

Using the following initial conditions for a population of 1000,
S(O)

=

900

C(O)

=
=

90

R(O)

10

solve the Kerma~k-McKendrick equation using A = 0.001 and B = 0.072.
Include S, C, and R in a common printer-plot using the same scale for all variables.
Answer:

At TIME = 10 days, S = 27.4, C = 631.2, R = 341.4
3 Solve the following equation using both the RKSFX and STIFF methods.

y + 201j + 200y = 0
y(O) = 1.0
y(O) = 0
Compare the numerical solution with the exact solution.
_ 200 -t
1 -200t
Y - 19g e - 19g e
Answer:

The difference between the exact solution and the numerical solution using
RKSFX and STIFF is less than 10- 4 • However, several program interrupts due to
underflow occur when using RKSFX.
4 Use the TRANSF function to solve for the dynamic response of the system represented by the following block diagram. A unit-step input occurs at t = O.
r(s) -+

S6

S2 + 5s + 7
+ 8ss + 23s4 + 44s3 + 41s2 + 14s + 4

-+ c(s)

Answer:

At TIME

=

10.0 c

=

2.1671

60
Profile of Roller Coaster Track
Height
feet

40

(y)

20

40

80

120
Feet (x)

Fig. P-5.5

160

200

240

CSMP 11/

Ch. 5

5

273

A 640 lb gravity-powered roller coaster travels on a track shown in the above profile.
Aerodynamic drag equal to 0.005v 2 and a rolling resistance of 10 lb oppose motion.
The velocity at the start of the run is 15 ft/sec. Use the SLOPE function to evaluate
dy/dx in simulating the motion of the vehicle.
The equation of motion is

~v
g

=

-w sin 8 - 0.005v 2

-

10.0

where

w

=

g

= acceleration of gravity, 32.17 ft/sec 2

weight

Answer:
At TIME

=

6.0 sec: v

=

35.1 ft/sec and x

=

197.0 ft.

6 A 27 lb weight moving downward at a velocity of 200 in/sec strikes and sticks to a
lead cylinder.

l

V = 200 in·/see

Fig. P-S.6

The dynamic resisting-force of the lead cylinder for large strains is approximated
by the following formula.

F= 620[1 + 0.OO4(L ~ yy.o2](L ~ yr·

44

The equation that describes the motion of the mass is given below.

27
386Y = 27 - F

214

Ch. 5

CSMP 11/

Generate data for the resisting-force F in the Initial segment using the following
range for y and j.
o < y < 0.25 in.

o < j < 200 in./sec
Load the generated data by using the TVLOAD subroutine and then use the
TWOVAR function to calculate F to determine the maximum deflection of the load
cylinder.
Answer:
Ymax

= 0.150 in. at TIME = 0.00343 sec

7 The device below is used to control the water level in a tank. The flow characteristics
of the valve are given in the figure below. The outflow from the tank is given by the
following expression.

Valve

l

y

I"

4"

~ZZZltala::z:zz:z:z:ja::z:zz()

Supply
~
pressure c:====:::c:j3:r==:l

=p

Float

Cross-sectional
area of tank
250in.2

~==~========~~qo
40

p= 62 psi
p= 40 psi

p

= 23 psi

20
p= 10 psi

qin

(in. 3 /sec)

~P=3Psi
0.5

1.0 (in.)

y

Fig. P-5.7

At the start of the simulation, h = 10, P = 23 psi, and Y = 0.5. Use the
TWOVAR function to represent the valve characteristics and solve for the dynamics
of the system when P is suddenly increased to 60 psi.

Ch. 5

CSMP 11/

215

The equation describing the water level is
dh
250 dt

= qin -

qo·

Answer:

= 40 sec, h = 10.69 in.

At TIME

S The curve below represents an odd periodic function. Using the FUNGEN function
with 5th-order interpolation, find the Fourier coefficients for the first five terms of the
periodic function. The odd Fourier coefficients are given by the following expression.
2

f(t)

Fig. P-S.8

~

f: J(t)

bn

=

2p

= period = 8.0

sin

(n;t) dt

Answer:

-0.40, bs = 0.27
9 The road-holding ability of an automobile can generally be improved by decreasing
the unsprung mass. Use the below model of one corner of an automobile to find the
time average ratio of tire force to vehicle weight as the car passes over a depression
in the road. Do the simulation for unsprung masses of 80 and 150 lb.
Equations of motion are
bi

= 0.84, b2 = 0.91, b3 = 0.32, b4

mIYI

=

+ k(Y2 Y2) + CUI -

kt(y - YI)

m2Y2 = k(YI -

=

+ C(Y2 Y2) + m2g

YI)

YI)

+ mIg

initial conditions:
YI(O)

=

(mi tt m2)g
YI(O)

Y2(0) = YI(O)

+ "'kg

= h(O) = 0

Tire force
w~ight

kt(y - Y 1)

= (mi + m2)g

Answer:

Unsprung mass 801b: average force/weight
Unsprung mass 150 Ib: average force/weight

=
=

0.6937
0.6733

276

CSMP III

Ch. 5

v~

(Tire)

Kt

1000 in./sec

= 1100 Ib/in.

T

k = 125 Ib/in.
C

= 10 1lKec/in.

Fig. P-S.9

10 A control system is represented by the following block diagram. For the following

input, use the TRANSF and REALPL functions to find the time response of the
output.
r(t)

+
r(s)
S3

= 5(1

- e- t / 2 )

3s + 2
+ 3s 2 + 5.2s + 1.7

t----r--+- c(s)

Fig. P-S.I0

Answer:
At TIME = 6.0, c = 3.5697
11 Motorcycle helmets are tested by dropping a helmet containing a headform on a
rigid surface. The following data for two different helmets was taken at the Southwest Research Institute and is the acceleration measured in the headform during a
Z-90 test. The helmet has a velocity at impact of 19.6 ft/sec. Using the OVERLAY
statement, find the rebound velocities of both helmets using one program.
The following expression can be used to estimate the injury to a human head
from an impact. A value greater than 1000 is usually fatal.
HIC =
a is the acceleration in g's.

S: a

Z S
•

dt

Ch.5

CSMP III
/'

/

---"

"
\
\

Head form

211

\
\\

Accelerometer

\

lv

= 19.6 rtfsec

Helmet

Fig. P-S.ll

Calculate the value of HIC for both helmets.

Test Results of a Good Helmet
Time
Acceleration
(sec)
(g's)

Test Results of a Poor Helmet
Time
Acceleration
(sec)
(g's)

o

o

o

o

0.001
0.002
0.003
0.004
0.005
0.006
0.007
0.008
0.009
0.01
0.011
0.012

24
45
84
125
144
135
120

0.001
0.0015
0.002
0.0025
0.003
0.0035
0.004
0.0045
0.005
0.0055
0.006
0.0065
0.007

100
180
235
220
258
246
205
175
110
75
48
14

71

52
20
12

o

o

Answer:
Good helmet: rebound velocity
= 7.34 ft/sec
HIC = 935.7

Poor helmet: rebound velocity
= 10.85 ft/sec
HIC = 2653

12 Each ofthe three tanks initially contain 500 gal of brine with 50 lb, 100 lb, and 150 lb
of salt dissolved in tanks 1,2, and 3, respectively. The flow between tanks is shown
in Fig. P-5.12. By assuming the brine is kept well stirred, the following equations
describe the amount of salt in each tank.
dWl

dt

5W2

=

dW2_

3Wl

dt - 500
dW3

dt

3Wl

500 - t - 500

+ 2t

3W2

= 500 - t -

+ 2t

+~_~

500 - t
4W3

500 - t

500 - t

278

CSMP 11/

WI

Ch. 5

= 50 Ib salt

W2

I

= 100 Ib salt

W3

2

3

5 gal/min

I

3 gal/min

•

'"

•

J

= 150 Ib salt

I

I

I

I

3 gal/mm

I
'"
4gal/mm

l

Fig. P-S.12

Find the amount of salt in each tank after 4 hours. Use the GROUP parameter
to plot the time-history of Wb W2, and W3 with the same scale.
Answer:
WI

W2
W3

= 186.77 lb of salt
= 54.927 lb of salt
= 58.308 lb of salt

13 When a perfectly flexible and homogeneous cable is hung between two support
points, the equation of its shape is called the catenary. The exact shape is given by the
solution to the following differential equation.

ddx2y =
2

where:

W

h

~Jl + (dy )2
h

dx

= 0.17 lb/ft, weight per unit length of cable
= tension in cable at the lowest point

~96ft~
y

x

Fig. P-S.13

Find the shape of the free hanging cable for the following values of h.
h = 10,40, and 300lb

Use the MERGE parameter to plot all three curves on one page.
Answer:

At: x
h
h

96ft
101b, y = 97.341 ft
= 401b, y = 19.857 ft
h = 3001b, y = 2.6118 ft
=
=

CSMP 11/

Ch. 5

219

14 An aluminum circular fin on a 0.5 ft. diameter pipe is used to transfer energy from
the surface of the pipe to the ambient air. One fin can transfer 3200 Btu/hour. For a
thin circular fin having only a radial temperature distribution, the following equation
gives the steady-state temperature for natural convection.
2

d T
dr 2

where: T

+ 1- dT _
r dr

2h (T _ T.)
kL
a

=0

= temperature of fin

Ta = ambient temperature = 80°F

h = 0.19(T - Ta)0.33 Btu/hr-ft2-oF

k

=

118 Btu/hr-ft-oF

L = thickness of fin

= 0.0085 ft

Energy flows from surface of
fin by natural convection

~
L

= 0.0085

ft

T

1'a

=

ambient temperature

Fig. P-S.14

Find the temperature at a radius of 0.75 ft. Note that the above equation requires
the integration to start at r = 0.25 ft. An initial condition for the temperature
gradient on the inside surface of the fin can be calculated from the following relationship.
dTI
q = 3200 = -kAdr 7=0.25
A

= area =

O.5nL

Answer:
T(r = 0.75) = 171.55°F

15 Solve problem 14 using the following boundary conditions
T(r

dT
dr (r

= 0.25) = 650°F
=

h

0.75) = -7([T(r = 0.75) - Ta]

In the second boundary condition, the heat flow from the outer edge of the fin is
set equal to the energy removed from the same surface by convection. Since the

280

Ch.5

CSMP //I

temperature gradient at the outer edge is specified, the CALL RERUN statement
must be used in an iterative procedure to calculate the temperature gradient at the
inside surface: dT(r = 0.25)/dr.
Answer:
dT(r
dr
T(r

= 0.25) = -1146 F/IN
0

= 0.75) = 451.7°F

APPENDIX

I
LISTING AND

DEFINITION OF ALL
CsMP FUNCTIONS

The information in this section gives a summary of the functional blocks in
both CSMPj360 and CSMP III. The first portion contains those functions which
are identical for both versions of CSMP. The second portion gives those functions
which have been added to the newer version, CSMP III.
Material in this Appendix can be a valuable asset to the user in that a brief
description of the function is given along with the example numbers in the text
which use the function.
Table A-1

Functions Involving Integration And Differentiation

J>rograr.n Stater.nent

Mather.natical/Transforr.nation Equivalent

INTEGRATION

Y = INTGRL(IC, X)
IC = yet) It=to
X = the input variable or
function
(a) For CSMP/360, to = O.
(b) For CSMP III, to is specified on
the TIMER card by TIME = to.
If not specified, to = O.

y

= ft x dt
to

to

=

+ yet 0)

starting time

t = independent variable

Equivalent Laplace transform
yes)
Xes)

1

=s

These comments apply for all blocks
that contain a to.
281

282

Listing and Definition of All CSMP Functions

App.1

Comments

This is probably one of the most frequently used functional blocks of
CSMP. If the user does not specify a method of integration, then RKS variable
step will automatically be used in the program. However, six other methods of
integration are available and anyone of these can be selected by listing the particular integration form on a METHOD card (see pages 81 to 93). Users may
define their own integration through the use of a FORTRAN subroutine named
CENTRL (pages 93 to 95).
A vector or array integration form is also available by using the specification form
Y
where Y

=

= INTGRL(IC, X, N)

an output array

X

= array of initial conditions
= array of inputs or integrands

N

=

IC

the number of elements in the input array

Before using the specification form of integration, the reader should review the
material starting on page 103. Application of this form of integration for S/360
CSMP is given in Example 3.3, page 104 and Example 4.2, page 200. Examples
of the use of array integration in CSMP III are shown in Chapter 5.
Application of the ordinary integration form, that is Y = INTGRL(IC,X),
can be found in the following examples: Ex. 2.1, p. 14; Ex. 2.2, p. 18; Ex. 2.3,
p. 25; Ex. 2.4, p. 30; Ex. 2.5, p. 35; Ex. 2.6, p. 39; Ex. 2.7, p. 42; Ex. 2.8, p. 52;
Ex. 2.9, p. 58; Ex. 2.10, p. 60; Ex. 3.1, p. 90; Ex. 3.6, p. 114; Ex. 3.8, p. 126; Ex.
3.9, p. 134; Ex. 3.12, p. 151; Ex. 3.13, p. 158; Ex. 3.14, p. 167; Ex. 3.16, p.177;
Ex. 4.3, p. 210; Ex. 4.4, p. 211; Ex. 4.5, p. 215; Ex. 4.6, p. 221; Ex. 5.2, p. 253;
Ex. 5.3, p. 254.

Program Statement

Mathematical/Transformation Equivalent

DIFFERENTIATION

Y

=

DERIV(IC, X)

IC

=

dx(t)
dt

X

l

=to

= input variable

yet) =

~~t)

Equivalent Laplace transform
Yes)
Xes) = s

Comments

Generally, this function is not used to any considerable extent in simulation. DERIV is not a MEMORY or HISTORY function and therefore cannot
be used alone in a closed loop except when the loop is broken by an implicit
function. An example using the DERIV function is given on p. 48.

Listing and Definition of All CSMP Functions

App.1

Program Statement
REAL POLE

or FIRST-ORDER

283

Mathematical/Transformation Equivalent

LAG

Y = REALPL(lC, P, X)

p'Z+y=x

= yet) It=to
X = the forcing function

IC

Equivalent Laplace transform
yes)
1
Xes) = ps + 1

or input

Comments

This function is often used in control system simulation. The terms real pole
and first-order Jag are frequently used in control systems and engineering; hence
these terms are used as descriptive titles. However, the equation

p'Z+y=x
is simply a first-order differential equation. When the transfer function is expressed as
yes)
A
Xes) = s + B
the form must be changed to
yes)
Xes)

A
B

= 1+

s
B

See pp. 21 to 22 for further comments.
Applications using the REALPL function are given in Ex. 2.2, p. 18; Ex.
2.6, p. 39; Ex. 2.8, p. 52; Ex. 4.2, p. 200; Ex. 4.3, p. 210; Ex. 4.4, p. 211; Ex.
4.6, p. 221.

Program Statement

Mathematical/Transformation Equivalent

LEAD-LAG

Y

=

Note:

LEDLAG(Pl, P2, X)
PI and P2 are
parameters; initial
conditions are not used
with this function.

P2

dy
dt

+ Y = PI

dx
dt

+x

Equivalent Laplace transform
yes)
Xes)

PIS

=

P2S

+1
+1

Comments

This is another function often used in control system simulation. The term
lead-lag is descriptive of compensation in control systems. A lead compensator
is of the form given above when PI > P2. A lag compensator is of the same form

284

App.!

Listing and Definition of All CSMP Functions

Comments (continued).

but with P2 > Pl' Further
in Example 2.6, p. 39.

comm~nts

and application of this function are given

Mathematical/Transformation Equivalent

Program Statement
COMPLEX POLES

Y

=

d 2y
dt 2

CMPXPL(ICl, IC2, PI, P2, X)
ICI
IC2

= yet) It=lo
= yet) It=to

dy

2

+ 2P I P 2 dt + P 2 Y = x

Equivalent Laplace transform
yes)
Xes)

I

=

S2

+ 2PI P 2S + P~

Comments

This function is particularly designed for second-order polynomials with
complex roots. If the roots are real, one may employ REALPL twice. Nevertheless, CMPXPL will also handle the case when roots of S2 + 2P 1 P 2 s + P~ are
real. Ordinarily, one encounters this polynomial in the form S2 + 2Cron s + ro~.
Obviously, P 2 is equivalent to ron and PI equivalent to C. If one desires to simulate the transfer function
yes)
Xes)

1

=

S2

+ 1.6s + 4

then P 2 = 2 and PI = 0.4.
Application of this function is given in Example 2.7, p. 42.

Program Statement

Mathematical/Transformation Equivalent

MODE-CONTROLLED INTEGRATOR

Y

= MODINT(IC, Xl, X2, X3)
IC = yet) It=to

yet)

=

ft

X3

dt

+ Ie; for Xl >

0, any

X2

to

IC

yet)

=

yet)

= last output

; for

Xl

; for
from integrator

Xl

<
<

>0

0,

X2

0,

X2 :::;;;

Comments

This function allows the user to start an integration, integrate for prescribed
conditions, then hold the value of y, restart the integration for other prescribed
conditions. For some simulations, the value of y may have large step-changes. If
this occurs while using a variable-integration step-size the condition on DELMIN
may not be satisfied and the simulation will halt. The user can correct the situation by changing to a fixed-step integration with appropriate step-size.
See Example 3.13, p. 158, for application of the mode-controlled integrator.

0

App.1

Listing and Definition of All CSMP Functions

285

Table A-2

Special CSMP Functions

Program Statement

Mathematical/Transformation Equivalent

ZERO-ORDER HOLD

Y

=

ZHOLD(XI, X2)

y(t) =

for

Xl

>0

Xl

=

a trigger signal

y(t) = last value of X2; for

Xl

<0

X2

=

input to the hold

y(t) It=to = 0

X2

;

Equivalent Laplace transform
Y(s)
X(s)

T

=

I - e- sT

=

s

the sampling interval

Comments

This function has important application in the design and simulation of
discrete data systems. The physical property of the zero-order hold is illustrated
in the following sketches.

Y=x2(nT)

o

234567
liT

(b) Output of ZHOLD

(a) Input to ZHOLD

A convenient signal for Xl is the IMPULS function. Thus, to sample and hold a
sine function of a frequency of 30 radians/sec, every 1 sec, one may write
X2
Xl
Y

=
=
=

SIN(30.0*TIME)
IMPULS(O.O, 1.0)
ZHOLD(XI, X2)

It is important to recognize that if a variable-step integration method is used in

a problem, integration will generally not occur when IMPULS is applied. This
means that sampling will not occur at nT but rather at those values of TIME for
which an integration is performed. This problem can be overcome by using a
fixed-step integration in which T is a multiple of DELT.
Application of the zero-order hold can be found in Ex. 4.3, p. 210; Ex. 4.4,
p. 211; Ex. 4.5, p. 215; Ex. 4.6, p. 221.

286

App.!

Listing and Definition of All CSMP Functions

Program Statement
DEAD TIME

Mathematical/Transformation Equivalent

(DELAY)

Y

=

DELAYeN, P, X)

y

P

= the ideal delay time

y

N

=

number of points of X
sampled during P.
N must be an integer
constant ~ 3 but < 16,378

= x(t
=0

- p); for t

>p

; for t 

P2 < P1 X App.! Listing and Definition of All CSMP Functions 293 Comments This function can be used for simulating dead space in a system nonlinearity such as a valve. The slope on the active portion is not limited to 45° and can be changed to a specified value by Y = Q*DEADSP(PI, P2, X) (Q = specified slope) Application of this function is given in Example 2.9, p. 58. Definition 0/ Characteristic Program Statement LIMITER Y = y LIMIT(PI, P2, X) fo = an input PI, P2 = parameters defining X x the range of limiting y y y = PI; for x < PI = P 2 ; for x> P 2 = X ; for PI < x 0 (x - P z ) y =x -PI <0 for [x(t) - x(t - At)] and y(t - At) ~ (x - PI) otherwise y = y(t - At) Table A-6 Switching Functions Description of Switch Program Statement OUTPUT SWITCH YI, Y2 Yl = OUTSW(Xl, X2) Yt YI = X2. Y2 = 0 ; for Xl < 0 = 0 ,Y2 = X2; for Xl ~ 0 App.1 295 Listing and Definition of All CSMP Functions Program Statement INPUT SWITCH Y = INSW(Xl, X2, X3) Description of Switch X2 • ::Q Xl <0 ~ X3 ~f>O •• Xl II( Y y Program Statement = COMPAR(Xl, X2) = X2; for x I < 0 = X3; for Xl ~ 0 Description of Switch COMPARATOR Y y C Xl 0 M y=O Xl X2 X2 Description of Switch X2 • Xl <0 ~ ..... x,=o> ;:.~ x,>O ~ @ X3 Xl oil( Y y y = = = X2; for XI X3; for Xl X4; for Xl < = > 0 0 0 y 296 App.! Listing and Definition of All CSMP Functions Program Statement Description of Switch RESETTABLE FLIP-FLOP Q = S RST(R, S, T) T Q RST flip-flop R I ! ! = 0; for R > 0 (regardless of Sand T) Q = 1; for R < 0, and S > 0 (regardless of T) Q Q Q = 0; = 1; Q = 0; for <0 and S< 0 R Q = 1; = = when T So 0 Q(t - ilt) = T So 0 Q(t - ilt) = T> 0 T> 0 Q(t - ilt) Q(t - ilt) Comments This switch has the operating characteristics of a reset-set-toggle flip-flop. Q(t - ilt) is the previous state of the flip-flop. At the start of a simulation, Q(t - at) = 0 for Rand S < 0 with either state of T. Application of this flip-flop is given in Example 4.8, p. 228. Table A-7 Logic Functions Logic Function Description Program Statement xl AND Y = AND(Xl, X2) Applications given in Ex.3.13,p.158 Ex. 4.7, p. 224 Ex. 4.8, p. 228 NAND (not and) Y = NAND(Xl, X2) 0 x2 y = 1; for x I > 0, X2 > 0 y = 0; otherwise y Xl X2 D = 0; for Xl > 0, X2 > 0 y = 1; otherwise Y y 1 0 0 1 App.1 Program Statement Logic Function Description NOT ~ x Y = NOT(X) Application given in Ex. 4.7, p. 224 Ex. 4.8, p. 228 y y INCLUSIVE OR Xl Y = IOR(Xl, X2) Y = NOR(Xl, X2) = 1; for x:::;: 0 = 0; for X> 0 xl y Y = EOR(Xl, X2) X I :::;: 0, y X2 :::;: 0 )D Xl X2 y y Y = EQUIV(Xl, X2) 0 = 0; otherwise Y = 1; for EQUIVALENT X2 :::;: D X2 Y = 1; for EXCLUSIVE OR y = 0; for Xl :::;: 0, = 1; otherwise y y (not or) y D X2 Application given in Ex. 4.7, p. 224 NOR 297 Listing and Definition of All CSMP Functions Xl :::;: 0, = 1; for X I > 0, = 0; otherwise X2 y >0 X2 :::;: 0 D xl X2 Y = 1; for y y Xl :::;: 0, = 1 ; for X I > 0, = 0; otherwise y X2 :::;: X2 0 >0 FORTRAN Functions. All FORTRAN functions are available for use in CSMP simulation. Also, the majority of FORTRAN techniques can be used with 298 Listing and Definition of All CSMP Functions App.1 CSMP including WRITE statements, DO loops, GO TO, and IF. In some cases the FORTRAN statements require special handling procedures within the body of a CSMP program. Several examples are given in the text in which FORTRAN is included with the CSMP program. In the following table some of the more common FORTRAN functions are listed for convenience. Users should refer to any standard FORTRAN text for a more complete listing. Table A-8 FORTRAN Functions Program Statement Mathematical Description EXPONENTIAL Y = EXP(X) y = eX NATURAL LOGARITHM Y =ALOG(X) y = In (x) COMMON LOGARITHM Y = ALOG lO(X) y = loglo (x) ARCTANGENT Y = ATAN(X) y = tan- 1 (x) TRIGONOMETRIC SINE Y = SIN(X) y = sin (x) TRIGONOMETRIC COSINE Y = COS(X) y = COS (x) SQUARE ROOT Y = SQRT(X) y=,vx HYPERBOLIC TANGENT Y = TANH(X) y = tanh (x) ABSOLUTE VALUE (Real argument and output) Y = ABS(X) y =\x\ App.1 Listing and Definition of All CSMP Functions Program Statement Mathematical Description ABSOLUTE VALUE (Integer argument and output) Y = IABS(X) y =Ixl TRANSFER OF SIGN X = SIGN(A, B) A·B X=lBT LARGEST VALUE (Integer arguments and real output) Y = AMAXO(XI, X2, ... , XN) y = max (x h X2, ••• , y = max (Xh X2, ••• ,Xn) y = max (x h X2, .•• , Xn) y = max (Xh X2, ••• , Xn) y = min (x h X2, ••• , Xn) y = min (x h X2, ••• , Xn) y = min (Xh X2,' x n) LARGEST VALUE (Real arguments and output) Y = AMAXI(XI, X2, ... , XN) LARGEST VALUE (Integer arguments and output) Y = MAXO(XI, X2, ... , XN) LARGEST VALUE (Real arguments and integer output) Y = MAXI(XI, X2, ... , XN) SMALLEST VALUE (Integer arguments and real output) Y = AMINO(XI, X2, ... , XN) SMALLEST VALUE (Real arguments and output) Y = AMINI (Xl, X2, ... , XN) SMALLEST VALUE (Integer arguments and output) Y = MINO(XI, X2, ... , XN) •• , xn) 299 300 App.1 Listing and Definition of All CSMP Functions Program Statement Mathematical Description SMALLEST VALUE (Real arguments and integer output) Y = MIN1(Xl, X2, ... , XN) Additional CSMP Functions. The following functions have been added to CSMP III. Refer to Chap. 5 for addition comments concerning CSMP III. Table A-9 Functions Added to CSMP III. Transformation Equivalent Program Statement GENERAL LAPLACE TRANSFORM (Available only in CSMP III) Y = TRANSF(N, B, M, A, X) Format For Entering Data: STORAGE B(N + 1), A(M + 1) X(s) ams m +am_ls m- 1 + ... +als+am+l bnsn +bn_1s n- 1 + ... +b 1s+bn +1 Y(s) where m:::;; n TABLE + 1» = B(1). B(2), ... ,B(N + 1), A(1 - (M + 1» = A(1), A(2), ... , A(M + 1) B(1 - (N Comments The TRANSF function can be used to find the response of a transfer function with m zeros and n poles (m < n) due to an arbitrary input, x. The user should note with caution that a m + 1 and bn+ 1 are the last coefficients of the numerator and denominator respectively while am and bn are the first coefficients. Suppose one desires to find the step response of the following transfer function using TRANSF. G(s) _ Y(s) _ 3s 2 + 4s + 2 - X(s) - S3 + 6s 2 + 9s + 4 The statements given below can be used in the program for this purpose. STORAGE DENCOF(4), NUMCOF(3) TABLE DENCOF(1-4) = 9.0,6.0, 1.0,4.0, NUMCOF(1-3) = 4.0,3.0,2.0 App.! 301 Listing and Definition of All CSMP Functions Comments (continued). IN = STEP(O.O) OUT = TRANSF(3, DENCOF, 2, NUMCOF, IN) For further comments see Example 3.12, p. 151; and p. 265. Program Statement Equivalent Mathematical Expression VARIABLE FLOW TRANSPORT DELAY (Available only in CSMP III) Y = PIPE(N, IC, P, Xl, X2, ND) = the number of intervals required N Iv ft = Xl dt to to define the 'delay of P. IC P Xl '= the initial condition of entire pipeline = the holdup quantity = flow rate = delayed characteristic ND = degree of interpolation for X2 retrieving delayed characteristic. This may be 1 or 2. y = IC; for Iv < P _ q(1v - P) - q(lv(t - At) - P). y Iv - Iv(t - At) , forlv where Iv q = ~P flow volume = weighted volume This functional block is used to simulate the transient flow of an incompressible fluid in a system having a time delay. Program Statement Equivalent Mathematical Expression FUNCTION GENERATOR WITH DEGREE y OF INTERPOLATION CHOSEN BY USER (Available only in CSMP III) Y = FUNGEN(FUNCT, N, X) FUNCT = function name N = degree of interpolation to be used. User may select from 1, 2, 3,4, or 5. X = value of abscissa x y =[(x) Degree of interpolation between A, B, C, D, E, and F depends upon selection ofN. Comments Use of this function is very similar to AFGEN and NLFGEN. See p. 262. 302 App.1 Listing and Definition of All CSMP Functions Program Statement Function Definition SLOPE OF A CURVE (Available only in CSMP III) N = = = X = Y FUNCT SLOPE(FUNCT, N, X) y user's name of the curve =dfl dx x the degree of interpolation to be used, N = 1, 2, or 3. See p. 265. value of abscissa 2 VARIABLES (Available only in CSMP III) ARBITRARY FUNCTION OF Y = TWOVAR(FUNCT, Z, X) See p. 263. z y =f(x, z) SAMPLING INTERVAL SWITCH (Available only in CSMP III) Y = SAMPL~Pl, P2, (::)] PI = the starting time for sampling to occur P2 = the last time for sampling to occur P3 = the time interval between samples if entered as a floating-point number N = the number of sampling intervals if entered as a fixed-point number Program Statement y = 1 for TIME = P1 y = k 1 for TIME = = P1 + k(P2 n- Pt) 0 e.th 1<0 = { 1 + lh 1 >0 ycCt + h) = yet) + hy it) + hcldl yeCt + h) = J[t + h, ycCt + h)] E = h[ycCt + h) - (y A(t) + codl )] Co (7) (8) (9) (10) Ee = 2c5[Yi t Step 1 + c5) - yet)] To start up ho =0 yiO) =y(O) Step 2 y is assumed to be the sum of an asymptotic part and a perturbation from the asymptote. Steps 3 and 4 These steps constitute Euler integration with step size c5. Step 5 d z ~ yet). It is assumed that the form of J(t, y) makes calculation of y difficult. Step 6 y c is computed solution at end of current step; h is step-size. Step 7 E is used to monitor step-size h. Step 8 Ee is used to monitor Euler step-size. The section on integration methods in Chap. 3 contains details for using the various methods. Information on accuracy and computer time is also included in this section. In the event that none of the methods satisfies the user's requirements, the user can supply his own integration method. This method is entered in the system by the name of CENTRL. Example 3.2 illustrates the procedure for using a usersupplied integration method. 320 Mathematics of Integration Methods App.1I/ REFERENCES 1. System/360 Continuous System Modeling Program, User's Manual GH20-0367-4, Program Number 360A-CX-16X. IBM Corporation, Technical Publications, White Plains, N. Y. 2. Continuous System Modeling Program III (CSMP III), Program Reference Manual SHI9-700l-2, Program Number 5734-XS9, IBM Corporation, Data Processing Division, White Plains, N. Y. 3. Fox, LESLIE and D. F. MAYERS, Computing Methods for Scientists and Engineers, Clarendon Press at Oxford, 1968, p. 215. 4. FOWLER, M. E., and R. M. WARTEN, "A Numerical Integration Technique for Ordinary Differential Equations with Widely Separated Eigenvalues," IBM Journal of Research and Development, II, No.5, Sept. 1967,537-43. INDEX A ABSEER (absolute error): definition, 82, 318 effect on problem solution, 84 program application, 91, 116, 117 resetting during simulation, 114, 117 Accelerometer (simulation), 247 ADAMS (integration): accuracy, 87 application, 85 mathematics of, 318 time requirements, 88 AFGEN function: definition, 31 illustration, 291 program application, 32-34, 204 Algebraic loop: definition, 171 diagnostic message, 313 program application, 48, 176-78 Algorithm: digital filter, 241, 243 for digital control, 216, 219, 220 PID digital controller, 221-24 ALOGI0 function, 203, 234 AND (lo~c): definitIon, 226, 296 program application, 160-61; 229, 232 Arbitrary function generators (see also AFGEN,NLFGEN,FUNGEN) CSMP III, 262-63, 301 CSMP/360, 291, 292 Array integration: general discussion, 103-4, 268 program application, 104-7, 197-203 ATAN2 (arc tangent), 196, 201 B Beam deflection simulation, 60-65 Block diagram: digital control system, 209, 210, 213, 214, 216 position control system, 40 simulation of, 18-22 temperature control system, 52 Bode diagram (see ,Frequency response) Boundary value problem: endpoint calculations, 64-65 program application, 60 c CALL ARRAY statement, 302 CALL CONTIN statement, 267 CALL DEBUG subroutine: description, 129, 130, 132 program application 132, 133 CALL FGLOAD subroutine, 262, 263 CALL FINISH instruction, 267 CALL OUTPUT instruction, 260 CALL PRINT instruction, 260 CALL RERUN statement: definition of, 64 program application, 63 CALL TVLOAD subroutine, 264, 265 Cam follower simulation, 65-68 CENTRAL (integration): application, 9~-95 description, 93 Chemical process, 52-58 Circuit simulation, 42-52 CMPXPL function (complex poles): application using, 46 definition, 45, 284 Coil spring mfg. simulation, 118 COMMON MEN statement, 124 COMMON statement, 21, 34, 124 COMPARATOR (logic), 226 COMPAR function (switching), 295 Complex poles (see also CMPXPL): transfer function for, 45 Constants (in CSMP), 7, 8 CONSTANT statement: definition, 15, 28 limitations on use, 95, 120 program application, 14-17, 54,89 CONTINUE statement: CSMP application, 29 description, 119, 120, 122, 123 FORTRAN application, 63, 64 program illustration, 92, 122, 201 CONTINUE statement (FORTRAN): description, 120 program application, 63, 64, 120 CONTOR parameter: application, 257, 258 description, 254, 256 Control statements: CSMP III, 266-70 CSMP/360, 112-24 CSMP III: control statements, 266-67 dlfferences between S/360 CSMP, 244 functions, 260-66 general comment, 2 program ,examples: accelerometer simulation, 247 heat transfer, 254, 270 spring-mass-damper system, 253 CSMP/S360: basic structure, 10-14 general comment, 2 321 CSMP/S360 (continued) overview, 5-7 program without integration, 65 system installation of, 7 in digital control, 217 in digital logic, 232 program application, 34, 38, 63, 196, 201 D Data output: CSMP III, 245-60 CSMP/360, 124-238 DATA statement: description, 101, 244 program application, 102 DATA statement (FORTRAN): description and application, 100 DEADSP function (dead space): definition, 58, 292 program application, 60 DEBUG (see CALL DEBUG) DECK: description, 135-38 example of, 140, 141 DELAY function (time delay): description, 53, 286 program application, 53-54 used with z-transforms, 212 DELMAX symbol, 268 DELMIN symbol, 18, 85-86 DELT symbol: application, 89 definition, 18, 85-87 . for logic stepping, 232 for program steppin~, 196 Derivative (differentiation) (see also DERIV): DERIV function: application 48, 50 definition, 48, 282 Diagnostic messages: listing of, 304-14 program application, 176 Difference equation, 215-25 Differential equation solution, 151, 167-68 Digital controller: cascade realization, 218 direct realization, 215 parallel realization, 219 PID,221-24 Digital control systems: diagram illustrating, 209 general discussion, 209-20 Digital logic: program application, 224, 228 simulation, 224-32 table of functions, 226 DIMENSION statement: description, 97-99 examples using, 102, 106, 201, 247 DO loop (with CSMP), 201 Double-precision operations: description, 268-70 example, 270 restriction on using, 8 DYNAMIC segment: definition, 12 general use, 2 322 E Electric circuit simulation, 42-52 END card: definition, 18, 113 typical application, 21, 38, 111-15, 122 END CONTINUE statement, 119, 266 ENDDATA statement, 101-2 ENDINPUT statement, 101, 267 ENDJOB card: definition, 18, 124 typical application, 21, 38, 123 ENDJOB STACK card, 124 ENDMAC card: description, 142 illustration, 145 ENDPROCEDURE: application, 156, 217, 220 description, 157-58 EOR function (logic), 226, 297 EQUIV ALENCE statement: description, 103, 105, 106 examples, 106, 109, 201 used in CSMP III, 268 EQUIVALENT function (logic), 226, 297 Examples using CSMP 1360: amortization schedule for home mortgage, 147-51 automobile traffic-flow simulation, 158-65 beam deflection simulation, 60-65 coil spring mfg. (random distribution), 118-19 compounding interest in saving account (user supplied integration), 93-95 control system with compensation, 39-42 feedback system with digital controller, 211-15 feedback system with sample and hold, 210-11 frequency response, 196-205 gear train containing backlash, 58-60 heat transfer in air duct, 104-7 impact dynamics of two railroad cars, 90-93 modulo two up-down counter, 228-332 Nixie light logic simulation, 224-28 orbital trajectory simulation of space vehicle, 126-29 PID digital controller, 221-24 position control system, 18-25 response of piston driven by air cylinder, 134-35 RLC circuit, 42-52 Examples using CSMP 1360 (continued) simulation of system involving an algebraic loop, 176-77 solution of nonlinear, time-varying, simultaneous differential equations, 167-69 spring-mass-damper system, 14-18 stress analysis of cam follower, 65-68 temperature control for a chemical process, 52-58 three-stage Saturn vehicle, 35-39 transfer function simulation, 151-54 transient temperature response, 30-35 Van der 'Pol Equation, 25-30 ventricular pressure simulation of human heart, 110-12 Examples using CSMP III: dynamics of accelet'ometer transducer, 247-48 spring-mass-damper system, 253-54 transient heat distribution, 254-59 F FCNSW function (function switch), 295 FINISH label: definition, 34 program application, 34, 63-64, 196 resetting of, 114, 117 FINTIM symbol: definition, 18 typical application, 17-18, 18-25 used with a CONTINUE statement, 120 FIXED statement: application, 102, 106, 257 description, 101 double precision, 269 Flip-flop (RST), 228-32, 296 Format (card columns), 9-10 FORMAT statements: program application, 102, 128, 129, 229 use in CSMP 9, 101, 125, 126, 201 FORTRAN: as used inCSMP, 6 continuation cards, 125 functions, 297-300 output, 63-64, 124-26 specification statement, 97-98 subprograms, 138, 165-68 FORTRAN functions: CONTINUE,37-38 FORMAT, 38, 201, 204, 229 GO TO, 229 IF,35 WRITE, 38, 201, 204, 229 Frequency response: general discussion, 194 program for calculation of, 196, 201 using array integrators, 197 with Bode diagram, 196-97 without integration, 195 Function generators (see Arbitrary function generators) FUNCTION statement (generation): program application, 34, 67, 204-5 used with AFGEN, 30-31 used with NLFGEN, 30-31 Function blocks, 6-7 FUNGEN function, 262, 301 Heat transfer simulation, 34, 104, 105, 254,270 HEIGHT variable, 252 HISTORY function, 171 HSTRSS function (hysteresis), 294 Integration (continued) changin~ integration technique durmg run, 90 choosing the method, 85 CSMP III, 267-68 double precision, 268 error requirement, 82-84, 86 fixed step method, 85 mathematics of, 317-19 methods, 85 mode-controlled, 163, 284 specification form, 103 step size, 82-87, 129 stiff equation, 268 time requirements, 88 user-supplied integration method, 93 variable step method, 82 Interest on investment, 93, 147 INTGRL (integration): description, 25, 281-82 program application (typical), 14, 18, 42, 54, 60, 91, 106 specification form, 103, 107 with subscripted variables, 99 lOR function (logic): description, 226, 297 program application, 229 I J IF statement: program application, 128, 217, 219, 220, 224, 229 with CSMP, 35, 126 IMPL statement (implicit function) (see also Algebraic loop): application, 176-78 description, 172, 173, 286 IMPULS function: definition, 44, 289 in sampled data, 210-11 program application, 46, 86 Inclusive OR (see lOR) INCON: description, 28 illustrations, 29 limitation on use of, 95, 120 program application, 28, 54 Independent variable: other than TIME, 66 renaming of, 62 INITIAL segment: definition, 11 general comment, 2 in logic simulation, 232 program application, 34, 38, 63, 196, 201 with digital control simulation, 217 INPUT statement, 101, 244, 267 INSW function (switch), 295 Integers: example, 106 specified by, 101 Integration: accuracy of, 84, 86, 87 array, 103, 268 Job control language cards (JCL), 137, 138,245 G GAUSS (distribution function): application, 119, 120 description, 291 Gear train (simulation), 58 GO TO statement, 229 GROUP parameter: application, 260, 261 description, 257 H K KEEP symbol: description, 89 program application, 89, 125, 217 L LABEL statement: definition, 25 program application, 21, 122 resetting of, 114, 117, 123 using more than one, 46 Laplace transform, 19 LEDLAG function: definition, 41, 283 program application, 42 LIMIT function, 293 Logic functions, 226, 296, 297 LOG parameter, 257 M MACRO function: description, 139-54 fundamental rules, 142-45 in digital control, 212 program application, 146-54, 196 MAIN subroutine, 136 MEMORY statement, 168, 171 MERGE instruction: description, 253 example, 254, 255 METHOD statement: description, 82, 85 program application, 89 MILNE integration method: accuracy, 86 description of mathematics, 317 general description, 88 program application, 82 MODINT function: description, 163, 284 program application, 164 N NAND function (logic), 226, 296 NLFGEN function: definition 31, 292 program application, 63, 67, 111 Nonlinear function generator (see NLFGEN) Nonlinear system characteristics, 292-94 Nonlinear systems: differential equation solution, 25-30 function generators for, 292-94 use of dead space in, 58 NOR function (logic), 226, 297 NOSORT section: definition, 12-14 general comments, 6 program application, 38, 196, 201 used in digital logic, 232 NOT function (logic), 226, 297 NPLOT parameter, 257 NTAB parameter: description, 257 example, 260-61 o Offline plotters, 132, 133, 135 Operators (with CSMP), OUTDEL parameter: definition, 24 program application, 18-25 relationship to FINTIM, 24 used with CONTINUE, 120, 122 used with integration, 67 used with PREPARE, 133 OUTPUT statement: description, 246-47 program application, 247-51 OUTSW function, 294 OVERLAY statement: description, 109, 110 example, 111 p Page height/width control (see HEIGHT, WIDTH,) PAGE statement: description, 252 example, 254 PARAMETER card: definition, 28 illustrations, 26, 28 323 PARAMETER card (continued) limitation on use of, 95, 120 multiple values for parameter, 53 program application, 201, 211 PI continuous controller, 52 PID digital controller, 221-24 PIPE function, 301 Piston-cylinder system, 134 PREPARE statement: description, 132, 133 problem application, 134, 136, 137 resetting of, 114, 117 PRTPLT (printer-plot) computer output of (typical), 23, 28 35,40,42,47,49,56,65 CSMP III (see OUTPUT), 247-48 description, 22 of integers, 101 program application (typical), 21, 34,38,46,54,63,67,196,201 resetting, 114, 117, 122, 123 scaling of, 54 subscripted variables, 99, 107 with log stepping, 197-98 PRINT (FORTRAN), 124, 126 PRINTPAGE statement, 246 PRINT statement: column output (typical), 17, 27, 54, 60 computer logic output, 232 description, 16 equation type output, 17, 61 integers, 101 maximum number of variables, 126 program application (typical), 15, 21, 54,60 resetting, 114, 117, 122, 123 subscripted variables 99, 107 PROCEDURE function: description, 154-64 fundamental rules, 156-58 typical application, 161, 164, 196 used in digital control, 217 Program restrictions, 311, 312, 314, 315, 316 PULSE function: application program, 46 definition, 44, 288 Pulse generation (with STEP), 200 Pulse train: application program, 46 generation of, 43-44 random generated, 224-26 PUNCH statement, 124 Q QNTZR function (quantization), 203-94 R RAMP function, 287 Random number generator (see GAUSS and RNDGEN function) 324 RANGE statement: description (CSMP/360), 20 description (CSMP III), 260 resetting of, 114, 117 simulation using, 58-60 READ statement: example, 102 use in CSMP, 101, 267 REALPL function (real pole): definition, 20, 283 program application (typical), 21, 42,54 REAL*8 statement, 269- 70 RECT integration (rectangular): accuracy of, 87 mathematics of, 318 time requirements, 88 use of, 85 Recursive difference equation, 215-21 Relay device, 145, 146 RELERR statement: application 91, 116, 117 definition of, 82, 318 effect on program accuracy, 84 resetting, 114, 117 RENAME statement: description, 62 program application, 62-65 with a MACRO, 142 RERUN statement, 246 Reserve words, 315-16 RESET statement: description, 117 example, 120, 122 Resettable flip-flip (RST): definition, 226 program application, 228-32 Restrictions (see Program restrictions) RKS integration: accuracy of, 84, 86 description, 82 mathematical formulation, 318 time requirements, 88 RKSDP integration (double precision): description, 269 example, 270 RKSFX (fixed-step integration): accuracy of, 86-87 application in digital control, 211-18 description, 85 mathematical formulation, 318 time requirements, 88 RNDGEN function (random number generator) : application with digital logic, 229 description, 119, 290 s Sample data control, 209-24 SAMPLE function (switch), 302 SCALAR function (array-to-scalar converter), 303 SHADE parameter (gray-tone print output): description, 256 example output, 21f;J7, 259 Signal sources, 287-:91 SIMP integration (Simpson): accuracy- of, 87 description, 85 example, 89 mathematical formulation, 93-95, 318 time requirement, 88 SINE function, 290 SLOPE function, 265, 302 SORT section: basic use, 6 definition, 12-14 typical application, 38 Space vehicle simulation, 35-37, 126 Specification statement: description, 97, 98 example, 106 Spring-mass system, 107, 253 SQRT (square root), 63, 194, 201 Standard deviation (expression), 119 State variables: circuit simulation using, 43 transfer function representation in, 205-8 STEP function: definition, 24, 288 in typical example programs, 21, 54, 155 STIFF integration: description of, 267, 268 mathematical formulation, 318-19 STOP statement: description, 123 example, 18, 122, 169 STORAGE statement: description, 98-99, 106 example, 109, 196, 248 Subscripted variables: CSMP III integration with, 254-55 CSMP/360 integration with, 99, 103 output using, 125, 245-48 use in CSMP, 95, 97-103, 201 Switching functions, 294-96 SYMBOL parameter: description, 257 example, 260-61 Symbols (in CSMP), 7-8 T TABLE statement: description, 99-100, 106 program application, 109, 196, 257 TERMINAL segment: definition, 12 general comments, 2 program application, 34, 38, 63, 201 Thermodynamics, 134 TIME (independent variable): double precision, 269 with PREPARE statement, 133 resetting to zero, 113 setting starting value, 268, 281 Time delay function (see DELAY FUNCTION) TIMER card: description, 18 typical application, 14-17, 60 TITLE statement: description, 16, 18, 245-46 resetting of, 114, 117 typical application, 14-17, 60, 122-23 Traffic flow (simulation) 158-65 Transfer function: general application, 43, 195-96 state variable form, 205-8 TRANSF function, 265-66, 300 Translation control statement (see Control statements) TRAPZ integration (trapezoidal): accuracy, 87 description, 85 mathematical formulation, 318 time requirement, 88 Two-point boundary value problem, 60 TWOVAR function (two variable), 263-64,302 x XYPLOT instruction, 252 u UPDATE subroutine, 136-38 User defined functions and subroutines, 138-40 v Ventricular pressure (heart), 110-11 w Wegstein's algorithm, 173 WIDTH variable, 252 WRITE statement: program application, 127-29, 201, 229 use in CSMP, 124-26 z ZHOLD function (zero order hold): definition, 210, 285 program application, 217, 219, 220, 224 Z-transform: algorithm simulation for inverse, 215-20 represented by DELAY function, 211-15 ZZRND instruction, 269-70, 303 ZZTIME symbol, 269 325 Other books of interest .. . TH E APPLICATION OF G S TO M SIMULATIO Geoffrey Gordon This book provides a very practical and easy-to-follow guide to the widely used General Purpose Simulation System, based on the latest version of the language issued by 18M, GPSS V. ' Three chapters. are devoted to modeling, discrete simulation and programming techniques; a series of thirteen chapters explain all features of the GPSS V language; seven valuable appendices summarize programming details of the language , and its assembly program, describe the internal operations of the program, and compare GPSS V with previous versions of the language. 320 pages Published 1975 MINICOMPUTER SYSTEMS: ing (PO -11) Richard H. Eckhouse, Jr. A diverse group of readers will find MINICOMPUTER SYSTEMS to be an excellent guide to the effective use of the inexpensive, yet powerful, small computers now available. There are discussions of the fundamental concepts of computer hardware and software independent of any particular language or machine, programming fundamentals, PDP-ll organization and structure, programming techniques, introduction to data structures, system software, operating systems, and an applications environment. 343 pages Published 1975 ULATION IENTIFIC COMPUTERS Manesh J. Shah This is a practical book, written to bring the convenience and economy of today's compact digital computers to virtually anyone who needs to simulate and solve dynamic systems problems in engineering and the physical sciences. " For example, it treats control systems of various types, mechanical systems and related design problems, chemical processing, simulations of different kinds of chemical reactor systems, and many others. 416 pages Published 1976 PRENTICE-HALL, I C. , Englewood Cliffs, New Jersey 0-13-371377-6


Source Exif Data:
File Type                       : PDF
File Type Extension             : pdf
MIME Type                       : application/pdf
PDF Version                     : 1.3
Linearized                      : No
XMP Toolkit                     : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Create Date                     : 2010:08:24 13:56:35-08:00
Modify Date                     : 2010:08:25 11:49:15-07:00
Metadata Date                   : 2010:08:25 11:49:15-07:00
Producer                        : Adobe Acrobat 9.33 Paper Capture Plug-in
Format                          : application/pdf
Document ID                     : uuid:b816c542-a1de-43c0-b456-b4f338d3b5c9
Instance ID                     : uuid:d8d8c52f-dc37-48b6-adc7-be6dfbefbe24
Page Layout                     : SinglePage
Page Mode                       : UseNone
Page Count                      : 338
EXIF Metadata provided by EXIF.tools

Navigation menu