HyperWorks Solvers

ARYSUB

ARYSUB

Previous topic Next topic No expanding text in this topic  

ARYSUB

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

Subroutine Type

Modeling

Definition

Calculates the values for a user-defined input array element.

Use

<Reference_Array

    id                  = "30100100"

    type                = "U"

    num_element         = "6"

    usrsub_param_string = "USER(502,11401020,11701100,339.3,207)"

    usrsub_dll_name     = "NULL"

    usrsub_fnc_name     = "ARYSUB"

 />

Calling Syntax

Fortran

SUBROUTINE ARYSUB (ID, TIME, PAR, NPAR, DFLAG, IFLAG, NVALUE, VALUE)

 

C

void STDCALL ARYSUB (int *id, double *time, double *par, int *npar, int *dflag, int *iflag, int *nvalue, double *value)

 

Python

def ARYSUB(id, time, par, npar, dflag, iflag, nvalue):

 

MATLAB

function value = ARYSUB(id, time, par, npar, dflag, iflag, nvalue)

Input Arguments

[integer] ID

The array 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

A Boolean variable that MotionSolve sets to true when it needs partial derivatives.  Otherwise, it is set to false.

 

[logical] IFLAG

A Boolean variable that MotionSolve sets to true when it needs to know on which functions CNFSUB depends. When the flag is set to false, then the values of the user-defined expressions are computed.

 

NVALUES

The number of values the user-defined Reference_Array contains.

Output Values

[double precision] VALUES

Output array that contains the values for the user-defined Reference_Array.

Example

This example describes how ARYSUB is used to calculate six state-dependent quantities that obey the following mathematical law:

is a 3x1 matrix that represents the displacement vector from the origin of a J Marker to the origin of the I Marker as measured in the global coordinate system.

is a 3x1 matrix that represents the time derivative of {X}.

is a 3x1 matrix that represents the small angle rotation of the I Marker with respect to the J Marker.

is a 3x1 matrix that represents angular velocity of the I Marker with respect to the J Marker as measured in the ground coordinate system.

are 3x3 diagonal matrices that are passed in to ARYSUB through the PAR array.

is a 3x1 matrix whose entries are defined as spline functions of the displacement X.

def ARYSUB(id, time, par, npar, dflag, iflag, nvalue)

 

    # Initialize outputs first 

    errflg = 0

    value = 6*[0.0]

 

    # Get I/J, the spline ids and [K]/[C] matrices from PAR

    Ipar = []

    ipar.append(int(par[1]))

    ipar.append(int(par[2]))

 

    kx_spl_id=int(par[3])

    ky_spl_id=int(par[4])

    kz_spl_id=int(par[5])

 

    ktx=par[6]

    kty=par[7]

    ktz=par[8]

 

    cx=par[9]

    cy=par[10]

    cz=par[11]

 

 

 

    ctx=par[12]

    cty=par[13]

    ctz=par[14]

 

    # Calculate AX(I,J),AY(I,J),AZ(I,J)

    [ax,errflg]=py_sysfnc("ax",ipar)

    [ay,errflg]=py_sysfnc("ay",ipar)

    [az,errflg]=py_sysfnc("az",ipar)

 

    #CalculateDX(I,J,J),DY(I,J,J),DZ(I,J,J)

    ipar.append(int(par[2]))

    [dx,errflg]=py_sysfnc("dx",ipar)

    [dy,errflg]=py_sysfnc("dy",ipar)

    [dz,errflg]=py_sysfnc("dz",ipar)

 

    #CalculateWX(I,J,J),WY(I,J,J),WZ(I,J,J)

    [wx,errflg]=py_sysfnc("wx",ipar)

    [wy,errflg]=py_sysfnc("wy",ipar)

    [wz,errflg]=py_sysfnc("wz",ipar)

 

    #CalculateVX(I,J,J,J),VY(I,J,J,J),VZ(I,J,J,J)

    ipar.append(int(par[2]))

    [vx,errflg]=py_sysfnc("vx",ipar)

    [vy,errflg]=py_sysfnc("vy",ipar)

    [vz,errflg]=py_sysfnc("vz",ipar)

 

    #Calculate{F(x)}

    [fx,errflg]=py_akispl(-dx,0.0,kx_spl_id,0)

    [fy,errflg]=py_akispl(-dy,0.0,ky_spl_id,0)

    [fz,errflg]=py_akispl(-dz,0.0,kz_spl_id,0)

 

    #{a}

    value[0]=fx-cx*vx

    value[1]=fy-cy*vy

    value[2]=fz-cz*vz

 

    #{b}

    value[3]=-ktx*ax-ctx*wx

    value[4]=-kty*ay-cty*wy

    value[5]=-ktz*az-ctz*wz

 

    return value

Comments

1.ARYSUB can only be defined for an input array element.  For example: Reference_Array with type=”U”.
2.The ID of the Reference_Array, defined with ARYSUB, may be referenced as the u_array_id in Control_StateEqn or Force_StateEqn element. For example:

 

<Control_StateEqn

    id                  = "301001"

    type                = "USERSUB"

    x_array_id          = "30100200"

    y_array_id          = "30100300"

    u_array_id          = "30100100"

    num_state           = "2"

    num_output          = "1"

    is_static_hold      = "FALSE"

    usrsub_param_string = "USER(998,0,1,-10,.1,10,0,0,1)"

    usrsub_dll_name     = "NULL"

    usrsub_fnc_name     = "GSESUB"

    usrsub_der1_name    = "GSEXX"

    usrsub_der2_name    = "GSEXU"

    usrsub_der3_name    = "GSEYX"

 />

<Force_StateEqn

    id                  = "301001"

    type                = "USERSUB"

    x_array_id          = "535050504"

    y_array_id          = "535050508"

    u_array_id          = "535050505"

    num_state           = "2"

    num_output          = "6"

    usrsub_param_string = "USER(1001,100.,0.31625,0.0004,1.,5.,5,3,0.5,0.3,0.)"

    usrsub_dll_name     = "ms_csubdll"

    usrsub_fnc_name     = "YFOSUB"

    is_static_hold      = "FALSE"

    i_marker_id         = "30101020"

    j_floating_marker_id= "30102020"

    ref_marker_id       = "30102020"

 />

See Also:

Modeling Subroutines