DIFF

The DIFF statement creates a user-defined state variable and defines a first-order differential equation that describes it.

Format

Argument

 
Specifies an expression for a differential equation or defines the argument list for the user-written subroutine that defines the differential equation. To define the equation with an expression, follow FUNCTION with an equal sign and the expression. To define the equation with a user-written subroutine, follow FUNCTION with an equal sign, the character string USER, and the argument list (r1[,...,r30]) of values and system variables to be passed to the user-written subroutine DIFSUB (see the DIFSUB subroutine). In a function expression, the system variable DIF(i) is the value of the dependent variable defined by the DIFF/i statement. DIF1(j) is the first derivative of the dependent variable defined by the DIFF/j statement. Note that the FUNCTION argument must either be the last argument in the DIFF statement or be followed by a backslash (\).
IC=r1[,r2]
Specifies the initial value of the user-defined variable and, optionally, an approximate value of the initial time derivative. The value r1 is the value of the user-defined variable at the start of the simulation. If you enter an implicit equation, r2 may also need to be specified, which is an approximate value of the time derivative of the user-defined variable at the start of the simulation. Adams Solver (C++) might adjust the value of the time derivative when it performs an initial conditions analysis. Entering an initial value for the time derivative helps Adams Solver (C++) converge to a desired initial conditions solution. You do not need to supply r2 when you enter a explicit equation since Adams Solver (C++) can compute the initial time derivative directly from the equation. Adams Solver (C++) requires you to enter r1.
Default: 0
IMPLICIT
Indicates that the function expression or DIFSUB subroutine defines the implicit form of a differential equation. Adams Solver (C++) assumes that either the expression or user-written subroutine defines the explicit form of the equation if IMPLICIT is not specified. In this case, the time derivative of the state variable is set to the value of FUNCTION.
ROUTINE=libname::subname
Specifies an alternative library and name for the user subroutine DIFSUB.
Learn more about the ROUTINE Argument.
STATIC_HOLD
Indicates that the DIFF state is not permitted to change during static and quasi-static analysis.
DYNAMIC_HOLD
Indicates that the DIFF state is not permitted to change during dynamic analysis.

Extended Definition

The DIFF statement creates a user-defined state variable and defines a first-order differential equation that describes it. The equation may be dependent on any Adams Solver (C++) state variable available in a function expression. You can create systems of differential equations by using more than one DIFF statement or LSE and GSE statements.
Both function expressions and user-written subroutines can access the DIFF state variable and its derivative. Function expressions access the value by using the function DIF(id) and the derivative by using DIF1(id) (see DIF and DIF1 functions). In each case, id specifies the identifier of the DIFF statement that defines the variable. User-written subroutines access the value and derivative by calling the subroutine SYSFNC (see the SYSFNC subroutine).
The function can be defined by a function expression, or by providing a user-written subroutine. Because Adams Solver (C++) typically handles a function expression more efficiently than a user-written subroutine, it is recommended that you use a function expression whenever possible.
The DIFF may be defined in either explicit or implicit form. The following equation defines the explicit form of a differential equation:
= f (y, u, t)
where:
is the time derivative of the user-defined state variable
y is the user-defined state variable itself
u is a vector of Adams Solver-defined state variables
You need to use the implicit form if the first derivative of the state variable cannot be isolated. The following equation defines the implicit form of a differential equation:
0 = F( y, , u, t)
 
 
Caution:  
Although you can currently use a DIFF statement to define an implicit, algebraic (rather then differential) equation, Adams Solver (C++) might not allow this in the future. You should use VARIABLE statements to define algebraic equations instead.
During a static analysis, Adams Solver (C++) finds equilibrium values for user-defined differential variables (DIFFs, GSEs, LSEs, and TFSISOs), as well as for the displacement and force variables. This changes the initial conditions for a subsequent analysis. Adams Solver (C++) sets the time derivatives of the user-defined variables to zero if STATIC_HOLD is not specified during a static analysis, and uses the user-supplied initial-condition values only as an initial guess for the static solution. Generally, the final equilibrium values are not the same as the initial condition values. Adams Solver (C++) then uses the equilibrium values of the user-defined variables as the initial values for any subsequent analysis, just as with the equilibrium displacement and force values.
However, the user-specified initial conditions are retained as the static equilibrium values if STATIC_HOLD is specified. Thus, the final equilibrium values are the same as the user-specified initial conditions. Note that this does not guarantee that the time derivatives of the user-defined variable are zero after static analysis.

Examples

 
DIFF/11, IC=1.75,
, FUNCTION = -2.0*DIF(11) + 4.0 + SIN(TIME)
DIFF/12, IC=1.75, IMPLICIT,
, FUNCTION = DIF1(12) + 2.0*DIF(12) - 4.0 - SIN(TIME)
These DIFF statements both define the following differential equation.
+ 2y - 4 = sin (t), y(0) = 1.75
DIFF/11 defines the equation in explicit form, where the function expression computes as shown below.
= -2y + 4 + sin (t)
DIFF/12 defines the equation in implicit form, where Adams Solver equates the function expression to zero, as shown below.
+ 2y - 4 - sin (t) = 0

Applications

The DIFF statement defines a first order, linear or nonlinear, explicit or implicit, ordinary differential equation for Adams Solver (C++) to integrate along with the dynamic simulation of a multibody system. The equation may be independent of the rest of the problem or it may depend upon any variable in the state vector. The solution to the differential equation can be used in the function expressions which define a number of other elements in Adams Solver (C++) such as the SFORCE statement. Thus, you can use Adams Solver (C++) to solve an independent initial value problem, or the differential equations defined by DIFF statements may be fully coupled with the system of equations that governs the dynamics of the problem.
DIFF statements are best for creating single equations or small sets of equations. Although you may create sets of DIFF statements to represent higher order equations or large systems of equations, other Adams Solver (C++) elements such as TFSISO, LSE, or GSE may be more convenient in these cases.
See other Generic systems modeling available.