Forces
- class mechanica.MxForce
MxForce is a metatype, in that Mechanica has lots of different instances of force functions, that have different attributes, but only have one base type.
Forces are one of the fundamental processes in Mechanica that cause objects to move.
- bind_species(a_type: MxParticleType, coupling_symbol: std::string const &) HRESULT
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
a_type (
MxParticleType) – particle type containing the speciescoupling_symbol (string) – symbol of the species
- Return type
int
- Returns
HRESULT
- static berendsen_tstat(tau: float const &) Berendsen *
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
tau (float) – time constant that determines how rapidly the thermostat effects the system.
- Return type
- Returns
Berendsen*
- static random(std: float const &, mean: float const &, duration: float const & = 0.01) Gaussian *
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
std (float) – standard deviation of magnitude
mean (float) – mean of magnitude
duration (float) – duration of force. Defaults to 0.01.
- Return type
- Returns
Gaussian*
- static friction(coef: float const &) Friction *
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
coef (float) – time constant
- Return type
- Returns
Friction*
- toString() std::string
Get a JSON string representation
- Return type
string
- Returns
std::string
- static fromString(str: std::string const &) MxForce *
Create from a JSON string representation
- Parameters
str (string) –
- Return type
- Returns
MxForce*
- __reduce__()
Helper for pickle.
- mechanica.ConstantForce
alias of
MxConstantForcePy
- class mechanica.MxConstantForce(*args)
Bases:
MxForceA custom force function.
The force is updated according to an update frequency.
This object acts like a constant force, but also acts like a time event, in that it periodically calls a custom function to update the applied force.
- class mechanica.MxConstantForcePy(*args)
Bases:
MxConstantForceCreates an instance from an underlying custom python function
- Parameters
f (PyObject) – python function. Takes no arguments and returns a three-component vector.
period (float) – period at which the force is updated.
- mechanica.ForceSum
alias of
MxForceSum
- class mechanica.MxForceSum
Bases:
MxForce- f1
- f2
- class mechanica.Berendsen
Bases:
MxForceBerendsen force.
Create one with
MxForce.berendsen_tstat.- itau
time constant
- class mechanica.Gaussian
Bases:
MxForceRandom force.
Create one with
MxForce.random.- std
standard deviation of magnitude
- mean
mean of magnitude
- durration_steps
duration of force.
- class mechanica.Friction
Bases:
MxForceFriction force.
Create one with
MxForce.friction.- coef
time constant