<< Click to Display Table of Contents >> Navigation: MODELS > Resident functions |
1. Resident functions
A number of numerical and logical functions are permanently defined and are available for use in a model. Their names are visible in any model, and can be used directly without being declared in a FUNCTION declaration.
The following resident functions are defined:
Function |
Description |
Numerical functions returning one value for each input argument: |
|
abs |
absolute value of each argument |
sqrt |
square root of each argument |
exp |
exponential of each argument |
ln |
base-e logarithm of each argument |
log10 |
base-10 logarithm of each argument |
log2 |
base-2 logarithm of each argument |
recip |
1/x for each argument x, with zero-division protection (1/0 = inf) |
factorial |
x! for each argument x |
trunc |
integer part of each argument |
fract |
fractional part of each argument |
round |
rounded value of each argument (to the nearest integer) |
sign |
=-1 when x<0, =0 when x=0, =+1 when x>0, for each argument x |
rad |
value conversion from degrees to radians, for each argument |
deg |
value conversion from radians to degrees, for each argument |
sin |
sine of each argument |
cos |
cosine of each argument |
tan |
tangent of each argument |
asin |
arc sine of each argument |
acos |
arc cosine of each argument |
atan |
arc tangent of each argument |
sinh |
hyperbolic sine of each argument |
cosh |
hyperbolic cosine of each argument |
tanh |
hyperbolic tangent of each argument |
asinh |
arc hyperbolic sine of each argument |
acosh |
arc hyperbolic cosine of each argument |
atanh |
arc hyperbolic tangent of each argument |
Double-argument numerical functions returning a single value: |
|
atan2(x1,x2) |
tan-1(x1/x2) with 4-quadrant range as determined by the signs of x1 and x2 |
binom(n,r) |
C(n,r)= n!/(n-r)!r! combination of r elements in a set of n |
permut(n,r) |
P(n,r) = n!/(n-r)! permutation of r elements in a set of n |
Multiple-argument numerical functions returning a single value: |
|
min(x1,x2,...) |
minimum value of {x1, x2, ...} |
max(x1,x2,...) |
maximum value of {x1, x2, ...} |
norm(x1,x2,...) |
Euclidian norm =sqrt(x12+x22+...) |
No-argument numerical functions returning a single value: |
|
random |
single random number between 0 and 1, uses no argument |
Logical functions returning one value for each input argument: |
|
bool |
value conversion of each argument from numerical to Boolean value = 1 when argument > 0 value = 0 when argument <= 0 |
Multiple-argument logical functions returning a single value: |
|
and(x1,x2,...) |
returns value of "x1 AND x2 AND ..." =1 only when all the arguments are true |
or(x1,x2,...) |
returns value of "x1 OR x2 OR ..." =1 when one or more of the arguments are true |
nand(x1,x2,...) |
returns value of "NOT(x1 AND x2 AND ...)" =1 when one or more arguments are false |
nor(x1,x2,...) |
returns value of "NOT(x1 OR x2 OR ...)" =1 only when all the arguments are false |
xor(x1,x2,...) |
returns value of "x1 XOR x2 XOR ..." = 1 when only one of the arguments is true |
2. Resident simulation functions
A number of functions which are related to the time simulation of a model are permanently defined and are available for use in a model. Their names are visible in any model, and can be used directly without being declared in a FUNCTION declaration.
For those functions requiring interpolation or extrapolation (see the list of functions below), the interpolation degree "pol" is an optional argument indicating the interpolation degree 0, 1, or 2 used for evaluating the function between the available values of the element (0=discontinuous, 1=linear, 2=quadratic) (default=1).
The following resident simulation functions are defined:
Function |
Description |
deriv(x) |
the value of the first-order time derivative of x at the present simulation time |
deriv2(x) |
the value of the second-order time derivative of x at the present simulation time |
delay(x,d,pol) |
past value of x at time (t-d), including references to pre-simulation times using the history function assigned to x |
prevval(x) |
the value of x at the previous simulation time |
backval(x,t,pol) |
past value of x at a time t within the last time step |
backtime(x,val,pol) |
time at which x had the value val during the last time step = "undefined" if not possible |
predval(x,t,pol) |
predicted value of x at time t |
predtime(x,val,pol) |
predicted value of time at which x will reach the value val = "undefined" if not possible |
histdef(x) |
a reference to the definition of the history function associated with x, used when defining the history of an element in terms of the history of another element |
histval(x,t) |
the value of x evaluated at time t, calculated using the history function associated with x |