VARIABLE

A VARIABLE command redefines or lists data for a VARIABLE statement that defines a variable in terms of a scalar algebraic equation. The variable can be either independently used, or as part of the PINPUT, POUTPUT, or ARRAY statement.

Format

Arguments

 
Respecifies an expression or redefines 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
Respecifies 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.
LIST
Lists the current values of the VARIABLE arguments.
ROUTINE=libname::subname
Specifies an alternative library and name for the user subroutine VARSUB.
Learn more about the ROUTINE Argument.

Extended Definition

The VARIABLE command redefines or lists a user-defined algebraic equation and its initial value.
After a change to a variable, Adams Solver (FORTRAN) reprocesses the model at the next SIMULATE command, as if it had just been read in from the dataset. During the reprocessing, Adams Solver (FORTRAN) checks the entire model for consistency, reinitializes user subroutines, and recomputes initial conditions.
Adams Solver (FORTRAN) also reinitializes user subroutines to re-establish functional dependencies. For each element that refers to a user-written subroutine, Adams Solver (FORTRAN) calls the user-written subroutine with the IFLAG argument set to true.
 
Tip:  
Consider using ARRAY instead of VARIABLE if the function is a constant value.
Caution:  
Caution should be used 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 a message appears on the screen indicating that the solution has failed to converge.
The IC argument can be altered only prior to a simulation. If you run a simulation and then try to alter IC, Adams Solver (FORTRAN) rejects the entire VARIABLE command.
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.
See other Reference data available.