HyperWorks Solvers

YFOSUB

YFOSUB

Previous topic Next topic No expanding text in this topic  

YFOSUB

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Subroutine Type

Modeling

Definition

Calculates 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"

 />

Calling Syntax

Fortran

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)

 

C

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)

 

Python

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

 

MATLAB

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)

Input Arguments

[integer] ID

The user-defined vector force/torque element identifier.

 

[double precision] TIME

The current simulation time.

 

[double precision] PAR

An array that contains the constant arguments from the list provided in the user defined statement

 

[integer] NPAR

The number of entries in the PAR array.

 

[logical] DFLAG

The differencing flag.

 

[logical] IFLAG

The initialization flag.

 

[integer] NSTATE

The number of state variables taken from the num_state attribute of the Control_StateEqn entity.

 

[double precision] STATES

An array of size NSTATE containing current values of state variables.

 

[integer] NINPUT

The size of the input (U) array.

 

[double precision] INPUT

An array containing current values of the inputs.

Output Values

[integer] NOUTPT

The number of outputs taken from the num_output attribute of the Control_StateEqn entity.

 

[double precision] STATED

An array of size NSTATE containing current values of the derivatives of state variables.

 

[double precision] OUTPUT

An array of size NOUTPT containing current values of the derivatives of outputs.

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

1.The INPUT is from a u-array referenced in the <Force_StateEqn/> model element.
2.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>.
3.When the derivative functions (for example YFOXX) are missing, the derivatives are computed from finite-differencing YFOSUB.
4.You can function YFORCE(…) to query the force in an expression or ‘YFORCE’ in a SYSFNC to query the force in a subroutine.
5.The X array cannot be a NULL array without any entries.

See Also:

Modeling Subroutines