# CFFSUB

ModelingUsed to calculate friction forces for the Force_Contact element.

## Use

Implements a friction force for contact.

<Force_Contact
id                  = "301001"
num_i_graphics      = "1"
i_graphics_id       = "90000"
num_j_graphics      = "1"
j_graphics_id       = "90001"
cnf_type            = "Impact"
stiffness           = "500."
exponent            = "1.5"
damping             = "0.5"
dmax                = "0.01"
cff_type            = "UserCFF"
cff_param_string    = "USER(0.05,0.01,0.1,0.5)"
cff_fnc_name        = "CFFSUB"
cff_dll_name        = "NULL"
/>

## Format

Fortran Calling Syntax
SUBROUTINE CFFSUB (ID, TIME, PAR, NPAR, LOCI, LOCJ, X, XDOT, NFORCE, AREA, DFLAG, IFLAG, RESULTS)
C/C++ Calling Syntax
void STDCALL CFFSUB (int *id, double *time, double *par, int *npar, double *loci, double *locj, double *x, double *xdot, double *nforce, int *dflag, int *iflag, double *result)
Python Calling Syntax
def CFFSUB(id, time, par, npar, loci, locj, x, xdot, nforce, dflag, iflag):
return result
MATLAB Calling Syntax
function vector = CFFSUB(id, time, par, npar, loci, locj, x, xdot, nforce, dflag, iflag)

## Attributes

AREA
[double precision]
The area of the contact patch.
DFLAG
[logical]
A Boolean variable that MotionSolve sets to true when it needs partial derivatives. Otherwise, it is set to false.
ID
[integer]
Force_Contact element identifier.
IFLAG
[logical]
A Boolean variable that MotionSolve sets to true when it needs to know which functions CFFSUB depends on. When the flag is set to false, the values of the user-defined expressions are computed.
LOCI
[double precision]
An array that contains the position vector of the contact point on I_GRAPHICS_ID with respect to the origin of the I_GRAPHICS_ID reference marker, resolved in the I_GRAPHICS_ID reference marker coordinate system.
LOCJ
[double precision]
An array that contains the position vector of the contact point on J_GRAPHICS_ID with respect to the origin of the J_GRAPHICS_ID reference marker, resolved in the J_GRAPHICS_ID reference marker coordinate system.
NFORCE
[double precision]
The value of the normal force.
NPAR
[integer]
The number of entries in the PAR array.
PAR
[double precision]
An array that contains the constant arguments from the list provided in the user-defined statement.
TIME
[double precision]
The current simulation time.
X
[double precision]
The contact deformation vector.
The first two elements contain deformation along the x- and y-axes of the I incident marker. The third element contains the rotational deformation about z-axis of I incident marker.
XDOT
[double precision]
The contact slip velocity vector.
The first two elements contain the slip velocity along the x- and y-axes of the I incident marker. The third element contains the angular velocity about the z-axis of the I incident marker.

## Output

RESULT
[double precision]
The value of the friction force vector.
The first two elements contain the force along the x- and y-axes of the I incident marker. The third element contains the torque about the z-axis of the I incident marker.

## Example

def CFFSUB(id, time, par, npar, loci, locj, x, xdot, nforce, dflag, iflag):
result = [0,0,0]
mu_sta =float(par)
mu_dyn = float(par)
vs = float(par)
vd = float(par)

v = sqrt(xdot*xdot+xdot*xdot)
mu = 0.0
if v>=vd:
mu = mu_dyn
elif v>vs:
mu, errflg] = py_step(v, vs, mu_sta, vd, mu_dyn,0)
else:
[mu, errflg] = py_step(v, -vs, -mu_sta, vs, mu_sta,0)

result = -mu*(nforce)*xdot/v
result = -mu*(nforce)*xdot/v

return result