Compiled TACS Speeds Simulation
(Extracted from Can/Am EMTP News Apr/1997)
Compiled TACS is the much faster, and also more flexible, way to
simulate control system modeling. The story that began last time is being
continued now.
Logical variables pose the greatest incompatibility for compiled
TACS. The average user may not know that these involve floating-point
numeric storage within Mr. Dube's old TACS code. Obviously, in
FORTRAN, the variable type LOGICAL is a more natural choice.
This is possible using AA and BB declarations (in columns 1 and 2)
as first explained in public E-mail dated November 15th.
The following description is close to this summary.
LOGICAL variables in compiled TACS are being left to the user.
That is, no translation or conversion is being provided.
In real FORTRAN, the user is able to declare and use whatever he wants,
of course. At the end of any such computation, if he wants compatibility
with old TACS, he simply defines the associated variable of old TACS
to have value of either zero or unity. For example, from the 9th
illustrative COMPILED TACS MAKE data case M9.DAT, there is the old
TACS line:
AAVAR = .NOT. ( TIMEX .GE. .010 )
The "AA" in columns 1-2 indicates that this is the old,
interpretive half of a split definition. For execution,
the AA automatically will be replaced by 88 to indicate
an internal variable. But then Ma Ren-ming's improved logic
dating to 1984 should convert this to whatever is appropriate
(i.e., possibly input or output types). In any case,
this old TACS line of the first (AA) half of a split block
is to be followed by a compiled half such as the following equivalent:
BB LOGICAL LOG1, LOG2
BB LOG1 = .FALSE.
BB IF ( TIMEX .GE. .010 ) LOG1 = .TRUE.
BB LOG2 = .NOT. LOG1
BB VAR = 0.0
BB IF ( LOG2 ) VAR = 1.0
The AA / BB alternative was illustrated for LOGICAL
variables, but in fact it has nothing particular to do with them.
The technique is general and powerful. Any block of contiguous
supplemental variables can be given an alternative this way. The
AA records come first, and they are used to enter the time-step
loop. They also are used within the time-step loop except for the
case of COMPILED TACS USE in which case it is the BB alternative
that is used instead --- automatically. The first BB
line shown above is a variable declaration. Implicitely,
variables that begin with letters A-H or O-Z will be type
REAL*8 and I-N will be type INTEGER*4. Since LOG1 and
LOG2 would violate this implied rule, they required the manual
declaration shown. The complete list of declarations now being
honored is: EQUIVALENCE, DIMENSION, LOGICAL, REAL, INTEGER,
SAVE, and DATA, with the latter two automatically being separated
from the preceding five to satisfy common rules of ordering of
FORTRAN compilers.
A restriction on the AA / BB alternative should be
understood. The AA statements not only are contiguous,
it also is assumed that they are evaluated in order without
intervening S-block backsubstitution.
Dr. Glenn Wrate of Michigan Tech in Houghton is the perfect
example of why faster simulation still is critical to some.
Using E-mail, there was a public debate about whether speed
mattered. I.e., is the retardation that might result from the use
of MODELS rather than TACS acceptable? In list server mail
dated October 24th, Dr. Wrate reported 338905.220 for seconds
spent within the time-step loop of one of his simulations.
Later, Dr. Wrate answered your Editor*s question of why,
considering the problem with time, he chose slow MODELS
rather than much faster TACS: His answer: "Yes, I was
using MODELS. Two features I used in MODELS that are not available
in TACS are: 1) Branching to change the driving function during
the simulation; and 2) Output files to obtain snapshots of the
simulation waveform ...." Of course, this was true for the old TACS.
Using the new AA/BB structure, any sort of branching permitted by FORTRAN
(e.g., IF, IF THEN, DO WHILE, ELSE IF, GO TO, etc.)
could be placed in the B half. As for a change of driving
functions, all TACS source names are immediately available,
and any other program name could be changed via the recent
extension to provide SPY DEPOSIT capability from within TACS.
Note that output is a strength of compiled TACS .
Rather than conform to whatever either MODELS or ATP
might allow in the way of format and precision, the user
could customize his own. For example, if Dr. Wrate wanted
to connect a file of his choice on Step 1, he could add a
statement such as:
BB IF ( ISTEP .EQ. 1 )
BB 1 OPEN ( UNIT=44, FILE='WRATE.LIS' ...
The file could be FORMATTED, UNFORMATTED, or random access
(with the latter being most appropriate for a data base that
might be updated). If Dr. Wrate wanted to save TACS variables
during the simulation, he could declare whatever storage might
be desired and perform the transfers himself. For example,
to save the waveform of TACS variable ENDB, he could add:
BB DIMENSION TANK(50000)
BB SAVE TANK
BB TANK(ISTEP) = ENDB
When it came time to flush this signal to disk,
Dr. Wrate would have the full power and flexibility of compiler
I / O (e.g., WRITE statements). But prior to flushing,
Dr. Wrate might want to perform a harmonic decomposition on
the contents of TANK to see if some resonance were present.
This would pose no problem, assuming he could supply the FORTRAN
for FFT. Etc., etc.