Tissue Forge C 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfCForce.h File Reference
#include "tf_port_c.h"
Include dependency graph for tfCForce.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tfFORCE_TYPEHandle
 Handle to a FORCE_TYPE instance. More...
 
struct  tfUserForceFuncTypeHandle
 Handle to a UserForceFuncType instance. More...
 
struct  tfForceHandle
 Handle to a Force instance. More...
 
struct  tfForceSumHandle
 Handle to a ForceSum instance. More...
 
struct  tfCustomForceHandle
 Handle to a CustomForce instance. More...
 
struct  tfBerendsenHandle
 Handle to a Berendsen instance. More...
 
struct  tfGaussianHandle
 Handle to a Gaussian instance. More...
 
struct  tfFrictionHandle
 Handle to a Friction instance. More...
 

Typedefs

typedef void(* tfUserForceFuncTypeHandleFcn) (struct tfCustomForceHandle *, tfFloatP_t *)
 

Functions

HRESULT tfFORCE_TYPE_init (struct tfFORCE_TYPEHandle *handle)
 Initialize an instance.
 
HRESULT tfForce_EvalFcn_init (struct tfUserForceFuncTypeHandle *handle, tfUserForceFuncTypeHandleFcn *fcn)
 Initialize an instance.
 
HRESULT tfForce_EvalFcn_destroy (struct tfUserForceFuncTypeHandle *handle)
 Destroy an instance.
 
HRESULT tfForce_getType (struct tfForceHandle *handle, unsigned int *te)
 Get the force type.
 
HRESULT tfForce_bind_species (struct tfForceHandle *handle, struct tfParticleTypeHandle *a_type, const char *coupling_symbol)
 Bind a force to a species.
 
HRESULT tfForce_toString (struct tfForceHandle *handle, char **str, unsigned int *numChars)
 Get a JSON string representation.
 
HRESULT tfForce_fromString (struct tfForceHandle *handle, const char *str)
 Create from a JSON string representation.
 
HRESULT tfForce_destroy (struct tfForceHandle *handle)
 Destroy an instance.
 
HRESULT tfForceSum_checkType (struct tfForceHandle *handle, bool *isType)
 Check whether a base handle is of this force type.
 
HRESULT tfForceSum_toBase (struct tfForceSumHandle *handle, struct tfForceHandle *baseHandle)
 Cast to base force.
 
HRESULT tfForceSum_fromBase (struct tfForceHandle *baseHandle, struct tfForceSumHandle *handle)
 Cast from base force. Fails if instance is not of this type.
 
HRESULT tfForceSum_getConstituents (struct tfForceSumHandle *handle, struct tfForceHandle *f1, struct tfForceHandle *f2)
 Get the constituent forces.
 
HRESULT tfCustomForce_init (struct tfCustomForceHandle *handle, struct tfUserForceFuncTypeHandle *func, tfFloatP_t period)
 Create a custom force with a force function.
 
HRESULT tfCustomForce_checkType (struct tfForceHandle *handle, bool *isType)
 Check whether a base handle is of this force type.
 
HRESULT tfCustomForce_toBase (struct tfCustomForceHandle *handle, struct tfForceHandle *baseHandle)
 Cast to base force.
 
HRESULT tfCustomForce_fromBase (struct tfForceHandle *baseHandle, struct tfCustomForceHandle *handle)
 Cast from base force. Fails if instance is not of this type.
 
HRESULT tfCustomForce_getPeriod (struct tfCustomForceHandle *handle, tfFloatP_t *period)
 Get force period.
 
HRESULT tfCustomForce_setPeriod (struct tfCustomForceHandle *handle, tfFloatP_t period)
 Set force period.
 
HRESULT tfCustomForce_setFunction (struct tfCustomForceHandle *handle, struct tfUserForceFuncTypeHandle *fcn)
 Set force function.
 
HRESULT tfCustomForce_getValue (struct tfCustomForceHandle *handle, tfFloatP_t **force)
 Get current force value.
 
HRESULT tfCustomForce_setValue (struct tfCustomForceHandle *handle, tfFloatP_t *force)
 Set current force value.
 
HRESULT tfCustomForce_getLastUpdate (struct tfCustomForceHandle *handle, tfFloatP_t *lastUpdate)
 Get time of last force update.
 
HRESULT tfBerendsen_init (struct tfBerendsenHandle *handle, tfFloatP_t tau)
 Creates a Berendsen thermostat.
 
HRESULT tfBerendsen_checkType (struct tfForceHandle *handle, bool *isType)
 Check whether a base handle is of this force type.
 
HRESULT tfBerendsen_toBase (struct tfBerendsenHandle *handle, struct tfForceHandle *baseHandle)
 Cast to base force.
 
HRESULT tfBerendsen_fromBase (struct tfForceHandle *baseHandle, struct tfBerendsenHandle *handle)
 Cast from base force. Fails if instance is not of this type.
 
HRESULT tfBerendsen_getTimeConstant (struct tfBerendsenHandle *handle, tfFloatP_t *tau)
 Get the time constant.
 
HRESULT tfBerendsen_setTimeConstant (struct tfBerendsenHandle *handle, tfFloatP_t tau)
 Set the time constant.
 
HRESULT tfGaussian_init (struct tfGaussianHandle *handle, tfFloatP_t std, tfFloatP_t mean, tfFloatP_t duration)
 Creates a random force.
 
HRESULT tfGaussian_checkType (struct tfForceHandle *handle, bool *isType)
 Check whether a base handle is of this force type.
 
HRESULT tfGaussian_toBase (struct tfGaussianHandle *handle, struct tfForceHandle *baseHandle)
 Cast to base force.
 
HRESULT tfGaussian_fromBase (struct tfForceHandle *baseHandle, struct tfGaussianHandle *handle)
 Cast from base force. Fails if instance is not of this type.
 
HRESULT tfGaussian_getStd (struct tfGaussianHandle *handle, tfFloatP_t *std)
 Get the magnitude standard deviation.
 
HRESULT tfGaussian_setStd (struct tfGaussianHandle *handle, tfFloatP_t std)
 Set the magnitude standard deviation.
 
HRESULT tfGaussian_getMean (struct tfGaussianHandle *handle, tfFloatP_t *mean)
 Get the magnitude mean.
 
HRESULT tfGaussian_setMean (struct tfGaussianHandle *handle, tfFloatP_t mean)
 Set the magnitude mean.
 
HRESULT tfGaussian_getDuration (struct tfGaussianHandle *handle, tfFloatP_t *duration)
 Get the magnitude duration.
 
HRESULT tfGaussian_setDuration (struct tfGaussianHandle *handle, tfFloatP_t duration)
 Set the magnitude duration.
 
HRESULT tfFriction_init (struct tfFrictionHandle *handle, tfFloatP_t coeff)
 Creates a friction force.
 
HRESULT tfFriction_checkType (struct tfForceHandle *handle, bool *isType)
 Check whether a base handle is of this force type.
 
HRESULT tfFriction_toBase (struct tfFrictionHandle *handle, struct tfForceHandle *baseHandle)
 Cast to base force.
 
HRESULT tfFriction_fromBase (struct tfForceHandle *baseHandle, struct tfFrictionHandle *handle)
 Cast from base force. Fails if instance is not of this type.
 
HRESULT tfFriction_getCoef (struct tfFrictionHandle *handle, tfFloatP_t *coef)
 Get the friction coefficient.
 
HRESULT tfFriction_setCoef (struct tfFrictionHandle *handle, tfFloatP_t coef)
 Set the friction coefficient.
 
HRESULT tfForce_add (struct tfForceHandle *f1, struct tfForceHandle *f2, struct tfForceSumHandle *fSum)
 Add two forces.
 

Function Documentation

◆ tfBerendsen_checkType()

HRESULT tfBerendsen_checkType ( struct tfForceHandle * handle,
bool * isType )

Check whether a base handle is of this force type.

Parameters
handlepopulated handle
isTypeflag signifying whether the handle is of this force type
Returns
S_OK on success

◆ tfBerendsen_fromBase()

HRESULT tfBerendsen_fromBase ( struct tfForceHandle * baseHandle,
struct tfBerendsenHandle * handle )

Cast from base force. Fails if instance is not of this type.

Parameters
baseHandlepopulated handle
handlehandle to populate
Returns
S_OK on success

◆ tfBerendsen_getTimeConstant()

HRESULT tfBerendsen_getTimeConstant ( struct tfBerendsenHandle * handle,
tfFloatP_t * tau )

Get the time constant.

Parameters
handlepopulated handle
tautime constant
Returns
S_OK on success

◆ tfBerendsen_init()

HRESULT tfBerendsen_init ( struct tfBerendsenHandle * handle,
tfFloatP_t tau )

Creates a Berendsen thermostat.

The thermostat uses the target temperature $ T_0 $ from the object to which it is bound. The Berendsen thermostat effectively re-scales the velocities of an object in order to make the temperature of that family of objects match a specified temperature.

The Berendsen thermostat force has the function form:

\[

     \frac{\mathbf{p}}{\tau_T} \left(\frac{T_0}{T} - 1 \right),

\]

where $ \mathbf{p} $ is the momentum, $ T $ is the measured temperature of a family of particles, $ T_0 $ is the control temperature, and $ \tau_T $ is the coupling constant. The coupling constant is a measure of the time scale on which the thermostat operates, and has units of time. Smaller values of $ \tau_T $ result in a faster acting thermostat, and larger values result in a slower acting thermostat.

Parameters
handlehandle to populate
tautime constant that determines how rapidly the thermostat effects the system.
Returns
S_OK on success

◆ tfBerendsen_setTimeConstant()

HRESULT tfBerendsen_setTimeConstant ( struct tfBerendsenHandle * handle,
tfFloatP_t tau )

Set the time constant.

Parameters
handlepopulated handle
tautime constant
Returns
S_OK on success

◆ tfBerendsen_toBase()

HRESULT tfBerendsen_toBase ( struct tfBerendsenHandle * handle,
struct tfForceHandle * baseHandle )

Cast to base force.

Parameters
handlepopulated handle
baseHandlehandle to populate
Returns
S_OK on success

◆ tfCustomForce_checkType()

HRESULT tfCustomForce_checkType ( struct tfForceHandle * handle,
bool * isType )

Check whether a base handle is of this force type.

Parameters
handlepopulated handle
isTypeflag signifying whether the handle is of this force type
Returns
S_OK on success

◆ tfCustomForce_fromBase()

HRESULT tfCustomForce_fromBase ( struct tfForceHandle * baseHandle,
struct tfCustomForceHandle * handle )

Cast from base force. Fails if instance is not of this type.

Parameters
baseHandlepopulated handle
handlehandle to populate
Returns
S_OK on success

◆ tfCustomForce_getLastUpdate()

HRESULT tfCustomForce_getLastUpdate ( struct tfCustomForceHandle * handle,
tfFloatP_t * lastUpdate )

Get time of last force update.

Parameters
handlepopulated handle
lastUpdatetime of last force update
Returns
S_OK on success

◆ tfCustomForce_getPeriod()

HRESULT tfCustomForce_getPeriod ( struct tfCustomForceHandle * handle,
tfFloatP_t * period )

Get force period.

Parameters
handlepopulated handle
periodforce period
Returns
S_OK on success

◆ tfCustomForce_getValue()

HRESULT tfCustomForce_getValue ( struct tfCustomForceHandle * handle,
tfFloatP_t ** force )

Get current force value.

Parameters
handlepopulated handle
forceforce value
Returns
S_OK on success

◆ tfCustomForce_init()

HRESULT tfCustomForce_init ( struct tfCustomForceHandle * handle,
struct tfUserForceFuncTypeHandle * func,
tfFloatP_t period )

Create a custom force with a force function.

Parameters
handlehandle to populate
funcfunction to evaluate the force components
periodforce period; infinite if a negative value is passed
Returns
S_OK on success

◆ tfCustomForce_setFunction()

HRESULT tfCustomForce_setFunction ( struct tfCustomForceHandle * handle,
struct tfUserForceFuncTypeHandle * fcn )

Set force function.

Parameters
handlepopulated handle
fcnforce function
Returns
S_OK on success

◆ tfCustomForce_setPeriod()

HRESULT tfCustomForce_setPeriod ( struct tfCustomForceHandle * handle,
tfFloatP_t period )

Set force period.

Parameters
handlepopulated handle
periodforce period
Returns
S_OK on success

◆ tfCustomForce_setValue()

HRESULT tfCustomForce_setValue ( struct tfCustomForceHandle * handle,
tfFloatP_t * force )

Set current force value.

Parameters
handlepopulated handle
forceforce value
Returns
S_OK on success

◆ tfCustomForce_toBase()

HRESULT tfCustomForce_toBase ( struct tfCustomForceHandle * handle,
struct tfForceHandle * baseHandle )

Cast to base force.

Parameters
handlepopulated handle
baseHandlehandle to populate
Returns
S_OK on success

◆ tfForce_add()

HRESULT tfForce_add ( struct tfForceHandle * f1,
struct tfForceHandle * f2,
struct tfForceSumHandle * fSum )

Add two forces.

Parameters
f1first force
f2second force
fSumhandle to populate with force sum
Returns
S_OK on success

◆ tfForce_bind_species()

HRESULT tfForce_bind_species ( struct tfForceHandle * handle,
struct tfParticleTypeHandle * a_type,
const char * coupling_symbol )

Bind a force to a species.

When a force is bound to a species, the magnitude of the force is scaled by the concentration of the species.

Parameters
handlepopulated handle
a_typeparticle type containing the species
coupling_symbolsymbol of the species
Returns
S_OK on success

◆ tfForce_destroy()

HRESULT tfForce_destroy ( struct tfForceHandle * handle)

Destroy an instance.

Parameters
handlepopulated handle
Returns
S_OK on success

◆ tfForce_EvalFcn_destroy()

HRESULT tfForce_EvalFcn_destroy ( struct tfUserForceFuncTypeHandle * handle)

Destroy an instance.

Parameters
handlehandle to populate
Returns
S_OK on success

◆ tfForce_EvalFcn_init()

HRESULT tfForce_EvalFcn_init ( struct tfUserForceFuncTypeHandle * handle,
tfUserForceFuncTypeHandleFcn * fcn )

Initialize an instance.

Parameters
handlehandle to populate
fcnevaluation function
Returns
S_OK on success

◆ tfForce_fromString()

HRESULT tfForce_fromString ( struct tfForceHandle * handle,
const char * str )

Create from a JSON string representation.

The returned type is automatically registered with the engine.

Returns
S_OK on success

◆ tfForce_getType()

HRESULT tfForce_getType ( struct tfForceHandle * handle,
unsigned int * te )

Get the force type.

Parameters
handlepopulated handle
tetype enum
Returns
S_OK on success

◆ tfForce_toString()

HRESULT tfForce_toString ( struct tfForceHandle * handle,
char ** str,
unsigned int * numChars )

Get a JSON string representation.

Parameters
handlepopulated handle
strstring representation; can be used as an argument in a type particle factory
numCharsnumber of characters of string representation
Returns
S_OK on success

◆ tfFORCE_TYPE_init()

HRESULT tfFORCE_TYPE_init ( struct tfFORCE_TYPEHandle * handle)

Initialize an instance.

Parameters
handlehandle to populate
Returns
S_OK on success

◆ tfForceSum_checkType()

HRESULT tfForceSum_checkType ( struct tfForceHandle * handle,
bool * isType )

Check whether a base handle is of this force type.

Parameters
handlepopulated handle
isTypeflag signifying whether the handle is of this force type
Returns
S_OK on success

◆ tfForceSum_fromBase()

HRESULT tfForceSum_fromBase ( struct tfForceHandle * baseHandle,
struct tfForceSumHandle * handle )

Cast from base force. Fails if instance is not of this type.

Parameters
baseHandlepopulated handle
handlehandle to populate
Returns
S_OK on success

◆ tfForceSum_getConstituents()

HRESULT tfForceSum_getConstituents ( struct tfForceSumHandle * handle,
struct tfForceHandle * f1,
struct tfForceHandle * f2 )

Get the constituent forces.

Parameters
handlepopulated handle
f1first constituent force
f2second constituent force
Returns
S_OK on success

◆ tfForceSum_toBase()

HRESULT tfForceSum_toBase ( struct tfForceSumHandle * handle,
struct tfForceHandle * baseHandle )

Cast to base force.

Parameters
handlepopulated handle
baseHandlehandle to populate
Returns
S_OK on success

◆ tfFriction_checkType()

HRESULT tfFriction_checkType ( struct tfForceHandle * handle,
bool * isType )

Check whether a base handle is of this force type.

Parameters
handlepopulated handle
isTypeflag signifying whether the handle is of this force type
Returns
S_OK on success

◆ tfFriction_fromBase()

HRESULT tfFriction_fromBase ( struct tfForceHandle * baseHandle,
struct tfFrictionHandle * handle )

Cast from base force. Fails if instance is not of this type.

Parameters
baseHandlepopulated handle
handlehandle to populate
Returns
S_OK on success

◆ tfFriction_getCoef()

HRESULT tfFriction_getCoef ( struct tfFrictionHandle * handle,
tfFloatP_t * coef )

Get the friction coefficient.

Parameters
handlepopulated handle
coeffriction coefficient
Returns
S_OK on success

◆ tfFriction_init()

HRESULT tfFriction_init ( struct tfFrictionHandle * handle,
tfFloatP_t coeff )

Creates a friction force.

A friction force has the form:

\[

     - \frac{|| \mathbf{v} ||}{\tau} \mathbf{v} ,

\]

where $ \mathbf{v} $ is the velocity of a particle and $ \tau $ is a time constant.

Parameters
handlehandle to populate
coefftime constant
Returns
S_OK on success

◆ tfFriction_setCoef()

HRESULT tfFriction_setCoef ( struct tfFrictionHandle * handle,
tfFloatP_t coef )

Set the friction coefficient.

Parameters
handlepopulated handle
coeffriction coefficient
Returns
S_OK on success

◆ tfFriction_toBase()

HRESULT tfFriction_toBase ( struct tfFrictionHandle * handle,
struct tfForceHandle * baseHandle )

Cast to base force.

Parameters
handlepopulated handle
baseHandlehandle to populate
Returns
S_OK on success

◆ tfGaussian_checkType()

HRESULT tfGaussian_checkType ( struct tfForceHandle * handle,
bool * isType )

Check whether a base handle is of this force type.

Parameters
handlepopulated handle
isTypeflag signifying whether the handle is of this force type
Returns
S_OK on success

◆ tfGaussian_fromBase()

HRESULT tfGaussian_fromBase ( struct tfForceHandle * baseHandle,
struct tfGaussianHandle * handle )

Cast from base force. Fails if instance is not of this type.

Parameters
baseHandlepopulated handle
handlehandle to populate
Returns
S_OK on success

◆ tfGaussian_getDuration()

HRESULT tfGaussian_getDuration ( struct tfGaussianHandle * handle,
tfFloatP_t * duration )

Get the magnitude duration.

Parameters
handlepopulated handle
durationmagnitude duration
Returns
S_OK on success

◆ tfGaussian_getMean()

HRESULT tfGaussian_getMean ( struct tfGaussianHandle * handle,
tfFloatP_t * mean )

Get the magnitude mean.

Parameters
handlepopulated handle
meanmean magnitude
Returns
S_OK on success

◆ tfGaussian_getStd()

HRESULT tfGaussian_getStd ( struct tfGaussianHandle * handle,
tfFloatP_t * std )

Get the magnitude standard deviation.

Parameters
handlepopulated handle
stdmagnitude standard deviation
Returns
S_OK on success

◆ tfGaussian_init()

HRESULT tfGaussian_init ( struct tfGaussianHandle * handle,
tfFloatP_t std,
tfFloatP_t mean,
tfFloatP_t duration )

Creates a random force.

A random force has a randomly selected orientation and magnitude.

Orientation is selected according to a uniform distribution on the unit sphere.

Magnitude is selected according to a prescribed mean and standard deviation.

Parameters
handlehandle to populate
stdstandard deviation of magnitude
meanmean of magnitude
durationduration of force.
Returns
S_OK on success

◆ tfGaussian_setDuration()

HRESULT tfGaussian_setDuration ( struct tfGaussianHandle * handle,
tfFloatP_t duration )

Set the magnitude duration.

Parameters
handlepopulated handle
durationmagnitude duration
Returns
S_OK on success

◆ tfGaussian_setMean()

HRESULT tfGaussian_setMean ( struct tfGaussianHandle * handle,
tfFloatP_t mean )

Set the magnitude mean.

Parameters
handlepopulated handle
meanmean magnitude
Returns
S_OK on success

◆ tfGaussian_setStd()

HRESULT tfGaussian_setStd ( struct tfGaussianHandle * handle,
tfFloatP_t std )

Set the magnitude standard deviation.

Parameters
handlepopulated handle
stdmagnitude standard deviation
Returns
S_OK on success

◆ tfGaussian_toBase()

HRESULT tfGaussian_toBase ( struct tfGaussianHandle * handle,
struct tfForceHandle * baseHandle )

Cast to base force.

Parameters
handlepopulated handle
baseHandlehandle to populate
Returns
S_OK on success