The core.forces module

This submodule contains the Python bindings for the external forces.

BaseForce

The interface class for forces.

RepulsiveSphere

A confining repulsive sphere.

LTCOMTrap

A force acting between the centres of mass of groups of particles evaluated from a lookup table.

LT2DCOMTrap

A force acting between the centres of mass of groups of particles evaluated from a 2D lookup table.

MovingTrap

A harmonic force computed by using as a reference a point that optionally move with a constant velocity along a direction.

class oxpy.core.forces.BaseForce(self: oxpy.core.forces.BaseForce)

Bases: pybind11_object

The interface class for forces.

The default constructor takes no parameters.

as_RepulsiveSphere(self: oxpy.core.forces.BaseForce) RepulsiveSphere

Attempt to cast the current force as a RepulsiveSphere object and return it.

Returns:

The force cast as a RepulsiveSphere or None if the casting fails.

Return type:

RepulsiveSphere

property group_name

The name of the group the force belongs to.

property id

The id of the force.

init(self: oxpy.core.forces.BaseForce, inp: oxpy.core.InputFile) Tuple[List[int], str]

Initialise the force.

Parameters:

inp (input_file) – The input file of the simulation.

property pos0

The reference position associated to the force. The particular meaning of this attribute depends on the subclass external force.

potential(self: oxpy.core.forces.BaseForce, step: int, pos: LR_vector) float

Return the potential energy due to the force at the given position and time step.

Parameters:
  • step (int) – The current time step.

  • pos (numpy.ndarray) – The position where the force should be computed.

Returns:

The computed potential energy.

Return type:

float

property rate

The rate of change of the force. The particular meaning of this attribute depends on the subclass external force.

property stiff

The stiffness (= strength) of the force. The particular meaning of this attribute depends on the subclass external force.

property type

the string used in the external force file to specify the force type (e.g. trap).

value(self: oxpy.core.forces.BaseForce, step: int, pos: LR_vector) LR_vector

Return the force vector that would act at the given position and time step.

Parameters:
  • step (int) – The current time step.

  • pos (numpy.ndarray) – The position where the force should be computed.

Returns:

The computed force vector.

Return type:

numpy.ndarray

class oxpy.core.forces.LTCOMTrap

Bases: BaseForce

A force acting between the centres of mass of groups of particles evaluated from a lookup table.

property potential_grid

The lookup table used to interpolate the potential and the force.

class oxpy.core.forces.LT2DCOMTrap

Bases: BaseForce

A force acting between the centres of mass of groups of particles evaluated from a 2D lookup table.

The force is evaluated by using two collective variables that are the distances between two pairs of centres of mass.

property potential_grid

The lookup table used to interpolate the potential and the force.

class oxpy.core.forces.MovingTrap

Bases: BaseForce

A harmonic force computed by using as a reference a point that optionally move with a constant velocity along a direction.

property dir

The direction towards which the reference point moves.

property pos0

The initial position of the reference point.

property rate

The velocity (in units of time steps) with which the reference point moves. If set to 0 the point will remain in its initial position.

property stiff

The stiffness of the harmonic force.

class oxpy.core.forces.RepulsiveSphere

Bases: BaseForce

A confining repulsive sphere.

property center

The center of the sphere.

property r0

The initial radius of the sphere.

property r_ext

The radius beyond which the force is not felt any more.

property rate

The rate \(A\) with which the sphere radius grows over time with the relation \(r(t) = r_0 + At\), where \(t\) is the current time step.