www.kxcad.net Home > CAE Index > MSC Software Index > Adams MD R2 Index
The VTOSUB evaluation subroutine computes torque components for a VTORQUE statement (C++ or FORTRAN). VTOSUB is optional. You only need it if you don't want to use function expressions in the VTORQUE statement.
An integer variable that contains the ID of the VTORQUE statement requesting information from VTOSUB. From the identifier, Adams/Solver automatically recognizes other information (such as the par argument) that is available in the corresponding statement. A double-precision variable through which Adams/Solver conveys the current simulation time. A double-precision array of constants taken in order from the USER parenthetical list of the VTORQUE statement. An integer variable that indicates the number of constants you specify in the USER parenthetical list. The primary purpose of the npar argument is to provide VTOSUB with the number of values stored in the par array. A logical variable that Adams/Solver sets to true when it calls VTOSUB to evaluate the partial derivatives of the specified functions. Otherwise, Adams/Solver sets the dflag argument to false. A logical variable that Adams/Solver sets to true when it needs the functional dependency of the user-defined expressions. You set functional dependencies with the same calls to the SYSARY and SYSFNC utility subroutines that are made to compute the values of the user-defined expressions (see SYSARY and SYSFNC). If the iflag argument is false, the values of the user-defined expressions are computed.
You can often use the VTORQUE statement with function expressions sufficient to define the three rotational vector components of a torque at a point. However, if the torque expressions become lengthy and awkward, you can use a VTOSUB evaluation subroutine. If the algorithms use or consist of already existing FORTRAN-77 subroutines, VTOSUB can be made to call them.You can call utility subroutines, such as AKISPL, CUBSPL, SYSARY and SYSFNC, from VTOSUB to obtain information about system variables, user-defined variables, and splines. See AKISPL, CUBSPL, SYSARY, and SYSFNC.The SYSARY and SYSFNC utility subroutines automatically set functional dependencies when the VTOSUB argument iflag is true. In order for Adams/Solver to compute solutions efficiently, it must know on which other variables each user-defined variable depends directly. Adams/Solver determines these functional dependencies at the beginning of the simulation by calling VTOSUB with the argument iflag set to true. Adams/Solver does this once for each VTORQUE statement with a FUNCTION=USER() argument.During each call to the VTOSUB evaluation subroutine, Adams/Solver records which calls you make to SYSARY and SYSFNC and assumes that the resulting values are dependent on only those Adams/Solver variables accessed through the SYSARY and SYSFNC calls.
If the SYSARY or SYSFNC utility subroutines are called to access angular displacements, the values returned by these may contain discontinuities. To avoid the discontinuities, use the RCNVRT utility subroutine to convert the rotational angles from Euler angles to some other coordinate system that does not encounter a singularity.
• When the iflag argument is true, you must make all the same calls to SYSARY and SYSFNC as are made to compute the component values of VTORQUE. This ensures that Adams/Solver has the proper functional dependencies. In general, failure to account for dependencies in the VTORQUE components may make it difficult for Adams/Solver to converge to a solution and/or may force Adams/Solver to take small integration steps, potentially causing large increases in execution time.
• When the iflag argument is true, SYSARY and SYSFNC return zero values for system and user-defined variables. When you execute Adams/Solver, computations that divide by these values result in fatal errors. You should check for nonzero values or ensure the iflag argument is set to false before dividing by these values.SUBROUTINE VTOSUB(ID, TIME, PAR, NPAR, DFLAG,
& IFLAG, RESULT)
C
C === Type and dimension statements ===================
C
C - External variable definitions -----------
C
INTEGER ID
DOUBLE PRECISION TIME
DOUBLE PRECISION PAR(*)
INTEGER NPAR
LOGICAL DFLAG
LOGICAL IFLAG
DOUBLE PRECISION RESULT(3)
C
C ID Identifier of calling VTORQUE statement
C TIME Current time
C PAR Array containing passed parameters
C NPAR Number of passed parameters
C DFLAG Differencing flag
C IFLAG Initial pass flag
C RESULT Array (dimension 3) of computed VTORQUE
C components returned to ADAMS
C
C - Local variable and parameter definitions ------
C
...
C
C === Executable code =================================
C
C Assign readable variable names to passed parameters
C
...
C
C Call SYSFNC and/or SYSARY to collect information for
C the following calculations. Note: if IFLAG is true, these
C calls are actually setting functional dependencies.
C
CALL SYSFNC (...)
C
C Check SYSFNC call through ERRMES utility routine
C
CALL ERRMES (...)
C
C Repeat for all required SYSFNC or SYSARY calls
C
...
C
IF (IFLAG) THEN
C
C - Subroutine initialization -------------
C
...
C
ENDIF
C
C - Evaluate VTORQUE components ------------
C
C Your algorithms
C
...
C
C Assign values to the RESULT array
C
RESULT(1) = ...
RESULT(2) = ...
RESULT(3) = ...
C
RETURN
ENDtypedef void adams_c_VTOSUB(const struct sAdamsVtorque* vto, double TIME, int DFLAG, int IFLAG, double* RESULT);* VTORQUE -----------------------------------------------------------------