VARIABLE

The VARIABLE statement defines a variable in terms of a scalar algebraic equation for independent use, or as part of the PINPUT, POUTPUT, or ARRAY statement.

Format

Arguments

 
Specifies an expression or defines and passes constants to a user-written subroutine to define a variable. If you want to define the variable with an expression, FUNCTION must be followed with an equal sign and the expression. If you want to define the variable with a user-written subroutine, FUNCTION must be followed with an equal sign, the character string USER, and the selected values (r1[,...,r30]) that Adams Solver (FORTRAN) passes to the user-written subroutine VARSUB.
IC=r
Specifies an approximate initial value for the VARIABLE. Adams Solver (FORTRAN) may adjust the value of IC when it performs an initial condition analysis. Entering an accurate value for IC may help Adams Solver (FORTRAN) converge to the initial conditions solution.
ROUTINE=libname::subname
Specifies an alternative library and name for the user subroutine VARSUB

Learn more about the ROUTINE Argument.

Extended Definition

The VARIABLE statement creates a user-defined algebraic equation. The value of the VARIABLE statement may depend on almost any Adams Solver (FORTRAN) system variable. Note that you cannot access reaction forces from a UCON, and PTCV and CVCV reaction forces may only be accessed from REQUEST and SENSOR expressions.
You can define the value of the VARIABLE statement by either writing a function expression in the dataset or by calling a VARSUB user-written subroutine. For more on user-written and utility subroutines, see User-Written Subroutines on and Utility Subroutines.
Function expressions and user-written subroutines can access the value of the VARIABLE statement with the Adams Solver (FORTRAN) function VARVAL(id) (see VARVAL) to represent the value, where id specifies the user-selected identifier of the VARIABLE statement. User-written subroutines access single VARIABLE statement values by calling the subroutine SYSFNC.
 
Caution:  
Use caution when defining a VARIABLE statement that is dependent on another VARIABLE statement or on an Adams Solver (FORTRAN) statement that contains functions. If a defined system of equations does not have a stable solution, convergence may fail for the entire Adams Solver (FORTRAN) model. The following example refers to this type of VARIABLE statement:
VARIABLE/1, FUNCTION= VARVAL(1)+1

When looked at as an algebraic equation, it looks like the following:

V=V+1.

However, when Adams Solver (FORTRAN) tries to solve this equation using the Newton-Raphson iteration, the solution diverges and Adams Solver (FORTRAN) displays a message on the screen indicating that the solution has failed to converge.
The IC argument should be used whenever a zero value might cause a floating point exception or lead Adams Solver (FORTRAN) away from the desired solution.

Examples

VARIABLE/4, FUNCTION = IMPACT(DZ(10,90),
, VZ(10,90), 1, 3E5, 1.2, 1,.05)
This VARIABLE statement defines an impact function. You may refer to this function as VARVAL(4) in other function expressions. This may make the other expressions more concise and readable, and might avoid repeated impact function calculations.
See other Generic systems modeling available.