# GFOSUB

ModelingUsed to calculate the six component forces and torques for a general force entity.

## Use

User-defined force using forces and torques computed in a GFOSUB:

<Force_Vector_TwoBody
id                   = "30701"
type                 = " ForceAndTorque"
i_marker_id          = "30701010"
body1_id             = "30301"
j_floating_marker_id = "30701012"
body2_id             = "30101"
ref_marker_id        = "30301010"
ref_body_id          = "30101"
usrsub_param_string  = "USER(1,30700800,30700700,30301011)"
usrsub_dll_name      = "NULL">
</Force_Vector_TwoBody>

## Format

Fortran Calling Syntax
SUBROUTINE GFOSUB (ID, TIME, PAR, NPAR, DFLAG, IFLAG, RESULTS)
C/C++ Calling Syntax
void STDCALL GFOSUB (int *id, double *time, double *par, int *npar, int *dflag, int *iflag, double *result)
Python Calling Syntax
def GFOSUB(id,  time, par, npar, dflag, iflag):
return result
MATLAB Calling Syntax
function results = GFOSUB(id, time, par, npar, dflag, iflag)

## Attributes

ID
[integer]
The general force element identifier.
TIME
[double precision]
The current simulation time.
PAR
[double precision]
An array that contains the constant arguments from the list provided in the user defined statement.
NPAR
[integer]
The number of entries in the PAR array.
DFLAG
[logical]
The differencing flag.
IFLAG
[logical]
The initialization flag.

## Output

RESULT
[double precision]
The vector output value of dimension 6 that contains the computed forces/torques (three translational and three rotational components).

## Example

Here, GFOSUB is used to compute the six components of GFORCE with three translational (Force) and three rotational (Torque) components, below.

The following mathematical equation is used for GFOSUB computation:

f = -k*x - c*xdot