DIFSUB

ModelingUsed to calculate a differential equation value for a control DIFF entity.

Use

A control diff statement based on a user-defined differential equation:

<Control_Diff
     label               = "Diff/301001"
     id                  = "301001"
     is_implicit         = "FALSE"
     ic                  = "0."
     ic_dot              = "0."
     is_static_hold      = "FALSE"
     type                = "USERSUB"
     usrsub_param_string = "USER(30102020,30101010)"
     usrsub_dll_name     = "NULL"
  />

Format

Fortran Calling Syntax
SUBROUTINE DIFSUB (ID, TIME, PAR, NPAR, DFLAG, IFLAG, VALUE)
C/C++ Calling Syntax
void STDCALL DIFSUB (int *id, double *time, double *par, int *npar, int *dflag, int *iflag, double *value)
Python Calling Syntax
def DIFSUB(id, time, par, npar, dflag, iflag): 
    return values
MATLAB Calling Syntax
function value = DIFSUB(id, time, par, npar, dflag, iflag)

Attributes

ID
[integer]
The differential equation element identifier.
TIME
[double precision]
The current simulation time.
PAR
[double precision]
An array that contains the constant arguments from the list provided in the user-defined statement.
NPAR
[integer]
The number of entries in the PAR array.
DFLAG
[logical]
The differencing flag set to true when the solver evaluates the partial derivatives.
IFLAG
[logical]
The initialization flag.

Output

VALUE
[double precision]
The double precision value that contains the value of the differential equation.

Example

def DIFSUB(id, time, par, npar, dflag, iflag):
    ipar =2*[0]
    ipar[0] =int(par[0])
    ipar[1] =int(par[1])
    [dz, errflg] = py_sysfnc("DZ", ipar)
    py_errmes(errflg,"Error calling SYSFNC for DZ",id,"STOP")
    ipar =1*[0]
    ipar[0] =id
    [dif, errflg] = py_sysfnc("DIF", ipar)
    py_errmes(errflg,"Error calling SYSFNC for DIF",id,"STOP")
    value = dz-dif
    return value