4.8.2.3. DIFFERENTIAL_EQUATION
This subroutine defines a user - defined differential equation.
Language type |
Subroutine |
FORTRAN |
differential_usub (time,upar,npar,jflag,iflag,result) |
C/C++ |
differential_usub (double time, double upar[], int npar, int jflag, int iflag, double result) |
VariableName |
Size |
Description |
time |
double |
Current simulation time of RecurDyn/Solver. |
upar |
double[30] |
Parameters defined by the user. The maximum size of array is 30. |
npar |
int |
Number of user parameters. |
jflag |
int |
When RecurDyn/Solver evaluates Jacobian, the flag is true. Otherwise, the flag is false. |
iflag |
int |
When RecurDyn/Solver makes its initial call to this routine, the flag is true. Otherwise, the flag is false |
result |
double |
Returned force and one-dimensional variable |
Example
Note
If the user wants to run this model using a user subroutine, the user can refer it in the directory (<install dir>\Help\usub\**).
C---- SUB. DIFFERENTIAL
SUBROUTINE DIFFERENTIAL_USUB
& (TIME,UPAR,NPAR,JFLAG,IFLAG,RESULT)
C---- TO EXPORT * SUBROUTINE
!DEC$ ATTRIBUTES DLLEXPORT,C::DIFFERENTIAL_USUB
C---- INCLUDE SYSTEM CALL
INCLUDE 'SYSCAL.F'
C---- DEFINE VARIABLES
C Parameter Information
C TIME : Simulation time of RD/Solver. (Input)
C UPAR : Parameters defined by user. (Input)
C NPAR : Number of user parameters. (Input)
C JFLAG : When RD/Solver evaluates a Jacobian, the flag is true. (Input)
C IFLAG : When RD/Solver initializes arrays, the flag is true. (Input)
C RESULT : Returned value. (Output)
DOUBLE PRECISION TIME, UPAR(*)
INTEGER NPAR
LOGICAL JFLAG, IFLAG
DOUBLE PRECISION RESULT[REFERENCE]
C---- USER STATEMENT
DOUBLE PRECISION VALUE, VELO, STIME
INTEGER IORD
LOGICAL ERRFLG
STIME = 1.0D0
VELO = 74.0D0
IORD = 0
CALL RD_HAVSIN(TIME,0.0D0,0.0D0,STIME,VELO,IORD,VALUE,ERRFLG)
RESULT = VALUE
RETURN
END
#include "stdafx.h"
#include "DllFunc.h"
Differential_API void __cdecl differential_usub
(double time, double upar[], int npar, int jflag, int iflag, double* result)
{
using namespace rd_syscall;
// Parameter Information
// time : Simulation time of RD/Solver. (Input)
// upar : Parameters defined by user. (Input)
// npar : Number of user parameters. (Input)
// jflag : When RD/Solver evaluates a Jacobian, the flag is true. (Input)
// iflag : When RD/Solver initializes arrays, the flag is true. (Input)
// result : Returned value. (Output)
// User Statement
double value, velo, stime;
int iord, errflg;
stime = 1.0;
velo = 74.0;
iord = 0;
rd_havsin(time,0.0,0.0,stime,velo,iord,&value,&errflg);
*result = value;
}