HyperWorks Solvers

GCOSUB

GCOSUB

Previous topic Next topic No expanding text in this topic  

GCOSUB

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

Subroutine Type

Modeling

Definition

Calculates a constraint defined using a Constraint_General element.  Such constraints are typically used in conjunction with defining 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

A Constraint_General element calling a GCOSUB for the calculation of a user-defined general constraint:

 

<Constraint_General

    id                  = "1"

    usrsub_param_string = "USER(5000000,1,30101020,30102020)"

    usrsub_dll_name     = "NULL"

    usrsub_fnc_name     = "GCOSUB"

 />

Calling Syntax

Fortran

SUBROUTINE GCOSUB (ID, TIME, PAR, NPAR, DFLAG,IFLAG, RESULT)

 

C

void STDCALL GCOSUB (int *id, double *time, double *par, int *npar, int *dflag, int *iflag, double *result)

 

Python

def GCOSUB(id, time, par, npar, dflag, iflag):

    return result

 

MATLAB

function result = GCOSUB(id, time, par, npar, dflag, iflag)

Input Arguments

[integer] ID

The Constraint_General 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.

 

[integer] DFLAG

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

 

[logical] IFLAG

The initialization flag.

Output Values

[double precision] RESULT

The value of the constraint.

Example

def GCOSUB(id, time, par, npar, dflag, iflag):

 

    [u1, errflg] = py_sysary("TDISP", [par[1],par[0]])

    [v1, errflg] = py_sysary("TDISP", [par[5],par[3]])

    [u2, errflg] = py_sysary("TDISP", [par[2],par[0]])

    [v2, errflg] = py_sysary("TDISP", [par[4],par[3]])

    result = u1[0]*v1[0]+u1[1]*v1[1]+u1[2]*v1[2]+u2[0]*v2[0]+u2[1]*v2[1]+u2[2]*v2[2]

 

    return result

See Also:

Modeling Subroutines

Constraint_General