YFOSUB
ModelingCalculates the vector force/torque between two bodies from a general state equations.
Use
<Force_StateEqn
id = "301001"
type = "USERSUB"
x_array_id = "30100200"
u_array_id = "30100100"
ic_array_id = "0"
num_state = "2"
is_static_hold = "FALSE"
i_marker_id = "30102022"
j_floating_marker_id = "30101023"
ref_marker_id = "30101010"
usrsub_param_string = "USER(998,0,1,-10,.1,10,0,0,1)"
usrsub_dll_name = "NULL"
usrsub_fnc_name = "YFOSUB"
usrsub_der1_name = "YFOXX"
usrsub_der2_name = "YFOXU"
usrsub_der3_name = "YFOYX"
usrsub_der3_name = "YFOYU"
/>
Format
SUBROUTINE YFOSUB (ID, TIME, PAR, NPAR, DFLAG, IFLAG,NSTATE, STATES, NINPUT, INPUT, NOUTPT, STATED, OUTPUT)
SUBROUTINE YFOXX (ID, TIME, PAR, NPAR, IFLAG, NSTATE,STATES, NINPUT, INPUT, NOUTPT, PXXMAT)
SUBROUTINE YFOXU (ID, TIME, PAR, NPAR, IFLAG, NSTATE,STATES, NINPUT, INPUT, NOUTPT, PXUMAT)
SUBROUTINE YFOYX (ID, TIME, PAR, NPAR, IFLAG, NSTATE,STATES, NINPUT, INPUT, NOUTPT, PYXMAT)
SUBROUTINE YFOYU (ID, TIME, PAR, NPAR, IFLAG, NSTATE,STATES, NINPUT, INPUT, NOUTPT, PYUMAT)
void STDCALL YFOSUB (int *id, double *time, double *par, int *npar, int *dflag, int
*iflag, int *nstate, double *states, int *ninput, double *input, int *noutpt, double
*stated, double *output)
void STDCALL YFOXX (int *id, double *time, double *par, int *npar, int *iflag, int
*nstate,double *states, int *ninput, double *input, int *noutpt, double *pxxmat)
void STDCALL YFOXU (int *id, double *time, double *par, int *npar, int *iflag, int
*nstate,double *states, int *ninput, double *input, int *noutpt, double *pxumat
void STDCALL YFOYX (int *id, double *time, double *par, int *npar, int *iflag, int
*nstate,double *states, int *ninput, double *input, int *noutpt, double *pyxmat)
void STDCALL YFOYU (int *id, double *time, double *par, int *npar, int *iflag, int
*nstate,double *states, int *ninput, double *input, int *noutpt, double *pyumat)
def YFOSUB(id, time, par, npar, dflag, iflag, nstate, states, ninput,input, noutpt):
return[stated, output]
def YFOXX(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt)
return pxxmat
def YFOXU(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt)
return pxumat
def YFOYX(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt)
return pyxmat
def YFOYU(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt)
return pyumat
function [stated, output] = YFOSUB(id, time, par, npar, dflag, iflag, nstate, states, ninput, input, noutpt)
function pxxmat = YFOXX(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)
function pxumat = YFOXU(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)
function pyxmat = YFOYX(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)
function pyumat = YFOYU(id, time, par, npar, iflag, nstate, states, ninput, input, noutpt)
Attributes Calling Syntax
- ID
- [integer]
- TIME
- [double precision]
- PAR
- [double precision]
- NPAR
- [integer]
- DFLAG
- [logical]
- IFLAG
- [logical]
- NSTATE
- [integer]
- STATES
- [double precision]
- NINPUT
- [integer]
- INPUT
- [double precision]
Output
- NOUTPT
- [integer]
- STATED
- [double precision]
- OUTPUT
- [double precision]
Example
def YFOSUB(id, time, par, npar, dflag, iflag, nstate, states, ninput,
input, noutpt):
stated = []
for i in xrange(nstate):
stated.append(0.0)
output = []
for i in xrange(noutpt):
output.append(0.0)
A = []
A.append([par[1],par[3]])
A.append([par[2],par[4]])
B = []
B.append(par[5])
B.append(par[6])
C = []
C.append(par[7])
C.append(par[8])
stated[0] = A[0][0]*states[0] + A[0][1]*states[1] + B[0]*input[0]
stated[1] = A[1][0]*states[0] + A[1][1]*states[1] + B[1]*input[0]
output[0] =0.0
output[1] =0.0
output[2] =0.0
output[3] =0.0
output[4] =0.0
output[5] = C[0]*states[0] + C[1]*states[1]
return [stated, output]
def YFOXX(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
pxxmat = []
for i in xrange(nstate*nstate):
pxxmat.append(0.0)
if int(par[0])==998:
pxxmat[0] = par[1]
pxxmat[1] = par[2]
pxxmat[2] = par[3]
pxxmat[3] = par[4]
return pxxmat
def YFOXU(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
pxumat = []
for i in xrange(nstate*ninput):
pxumat.append(0.0)
if int(par[0])==998:
pxumat[0] = par[5]
pxumat[1] = par[6]
return pxumat
def YFOYX(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
pyxmat = []
for i in xrange(nstate*noutpt):
pyxmat.append(0.0)
if int(par[0])==998:
pyxmat[0] = 0.0
pyxmat[1] = 0.0
pyxmat[2] = 0.0
pyxmat[3] = 0.0
pyxmat[4] = 0.0
pyxmat[5] = par[7]
pyxmat[6] = 0.0
pyxmat[7] = 0.0
pyxmat[8] = 0.0
pyxmat[9] = 0.0
pyxmat[10] = 0.0
pyxmat[11] = par[8]
return pyxmat
def YFOYU(id, time, par, npar, iflag, nstate, states, ninput,input, noutpt):
pyumat = []
return pyumat
Comments
- The INPUT is from a u-array referenced in the <Force_StateEqn/> model element.
- The OUTPUT y-array is of dimension 6X1 and is used as the action/reaction force between the i-marker and j-float marker, as in the <Force_Vector_TwoBody>.
- When the derivative functions (for example YFOXX) are missing, the derivatives are computed from finite-differencing YFOSUB.
- You can function YFORCE(…) to query the force in an expression or 'YFORCE' in a SYSFNC to query the force in a subroutine.
- The X array cannot be a NULL array without any entries.