
This script “fills” the parameter array r with the n desired parameter values
1
r[1] = 5, r[2] = 10, r[3] = 15, r[4] = 20, r[5] = 25 (4-6)
Next, a new DYNAMIC program segment replaces the model (4-3) with the
corresponding vectorized model
DYNAMIC
-----------------------------------------------------------
Vectr d/dt x = xdot
Vectr d/dt xdot = – ww * x – r * xdot
dispt x[1], x[2], x[3], x[4], x[5] | -- display 5 curves (4-7)
DESIRE’s vectorizing compiler (Sections 3-2 and 3-3) automatically com-
piles this vector model into
n replicated scalar state-equation systems
d/dt x[i] = xdot[i]
d/dt xdot[i] = – ww * x[i] – r[i] * xdot[i] (i = 1, 2, …, n) (4-8)
The n state-variable initial values xdot[i] default to 0, and ww is a scalar
parameter common to all
n models. Our program effectively replicates the
original model (4-3)
n times with different parameter values [Eq. (4-6)] and
exercises all
n replicated models in a single simulation run. The resulting
solutions
x[1], x[2], x[3], x[4], x[5] are exactly the same as the solutions x
obtained for r = 5, 10, 15, 20, 25 in Figure 4-1.
The DESIRE vector compiler makes model replication automatic.
Vectorization works for both differential-equation systems and sampled-data
assignments. Replicated models can involve user-defined functions, table-
lookup functions, and submodels; each function or submodel definition is
necessarily the same for all
n models. Vector and matrix operations (Chapter 3),
and also time delays and
store/get operations (see the DESIRE reference
manual in CD) cannot be replicated.
Model replication improves computing speed by eliminating the runtime
loop and run-starting overhead of repeated-run studies. Model replication
requires extra memory; a compact vector model can generate a large equation
system. DESIRE currently admits up to 150,000 double-precision defined
variables, plus up to 40,000 differential-equation state variables for fixed- and
Parameter-influence Studies and Vectorization 83
1
Instead of filling state and parameter arrays with a program loop, array elements can also be
given individual assignments such as
b[17] = 9.8887, and multiple vector arrays can be filled with
a single
data/read assignment such as data 0.1, – 7.8, cos (gamma), 12.1,
…
read b,x