HyperWorks Solvers

UCOSUB

UCOSUB

Previous topic Next topic No expanding text in this topic  

UCOSUB

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

Subroutine Type

Modeling

Definition

Calculates a constraint value and its derivatives for a user defined constraint element.  User- defined constraints are typically used in conjunction to define a broad range of holonomic and non-holonomic constraints.  A typical example is the so called "curve of pursuit" constraint, where one particle is chasing another particle.

Use

User-defined surface calling a UCOSUB for the calculation of a user constraint:

 

<Constraint_UserConstr

    id                  = "1"

    usrsub_param_string = "USER(1,31,301,1,350,302)"

    usrsub_dll_name     = "NULL">

</Constraint_UserConstr>

Calling Syntax

Fortran

SUBROUTINE UCOSUB (ID, TIME, Q, PAR, NPAR, IDRSEL, IFLAG, SCALAR, ARRAY, XMATRX)

 

C

void STDCALL UCOSUB (int *id, double *time, double *q, double *par, int *npar, int *idrsel, int *iflag, double *scalar, double *vector, double *xmatrx)

 

Python

def UCOSUB(id, time, q, par, npar, idrsel, iflag):

    return [scalar, vector, xmatrx]

 

MATLAB

function [scalar, vector, xmatrx] = UCOSUB(id, time, q, par, npar, idrsel, iflag)

Input Arguments

[integer] ID

The user-defined constraint element identifier.

 

[double precision] TIME

The current simulation time.

 

[double precision] Q

An array containing the double precision values of the part principal axes variables.

 

[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.

 

[integer] IDRSEL

An array of control value integers that define the type of outputs.  The first value controls the ARRAY output, the second controls the SCALAR output, and the third value controls the MATRIX output.

 

[logical] IFLAG

The initialization flag.

Output Values

[double precision] ARRAY

A thirty element array containing either first derivatives of constraints with respect to principal axes variables, or second partials of constraints with respect to time and the principal axes variables, depending on IDRSEL(2) as follows:

 

 

IDRSEL(1)=0: No evaluation

 

 

IDRSEL(1)=1: scalar=UCOSUB_1

 

 

IDRSEL(1)=2: scalar= UCOSUB_2

 

 

IDRSEL(1)=3: scalar= UCOSUB_3

 

 

Here q represents the variables, UCOSUB_4 represents the constraint, UCOSUB_5 represents the constraint when all variables (q) are set to zero, and t represents time.

 

[double precision] XMATRX

A 30x30 array that returns the second derivatives of the constraint with respect to the principal axes variables.  This is controlled by IDRSEL(3) as follows:

 

 

IDRSEL(1)=0: No evaluation

 

 

IDRSEL(1)=1: xmatrx(m,n)= UCOSUB_6

 

 

Here q represents the variables, UCOSUB_4 represents the constraint, and t represents time.

 

During the initialization of UCOSUB, UCOVAR and/or UCOMAR should be called to declare the variables.

Example

def UCOSUB(id, time, q, par, npar, idrsel, iflag):

 

    ORIG_R0X =    11

    ORIG_R0Y =    12

    ORIG_R0Z =    13

 

    DCMX_U1X =   111

    DCMX_U1Y =   112

    DCMX_U1Z =   113

    DCMX_U2X =   211

    DCMX_U2Y =   212

    DCMX_U2Z =   213

    DCMX_U3X =   311

    DCMX_U3Y =   312

    DCMX_U3Z =   313

 

    vector = 2*[0]

    xmatrx = 155*[0]

    if int(par[0])==5000000:

        imars = 2*[0]

        ivars = 2*[0]

 

        dir1_id     = int(par[1])

        marker1_id  = int(par[2])

        dir2_id     = int(par[3])

        marker2_id  = int(par[4])

        

        imars[0] = marker1_id

        imars[1] = marker2_id

 

        if dir1_id == 1:

            ivars[0] = ORIG_R0X

        elif dir1_id == 2:

            ivars[0] = ORIG_R0Y

        elif dir1_id == 3:

            ivars[0] = ORIG_R0Z

 

        if dir2_id == 1:

            ivars[1] = ORIG_R0X

        elif dir2_id == 2:

            ivars[1] = ORIG_R0Y

        elif dir2_id == 3:

            ivars[1] = ORIG_R0Z

 

        if iflag:

            nmar = 2

            nvar = 2;

            py_ucomar(id, imars, ivars)

            return [0, vector, []]

 

        if idrsel[0] == 1:

            scalar = q[0] - q[1]

        else:

            scalar = 0.0

 

        if idrsel[1] == 1:

            vector[0] =  1.0

            vector[1] = -1.0

        else:

            vector[0] = 0.0

            vector[1] = 0.0

 

   return [scalar, vector, xmatrx]


See Also:

Modeling Subroutines