jaxdem.forces.force_manager#
Utilities for managing per-particle force contributions.
Classes
|
Manage per-particle force contributions prior to pairwise interactions. |
- class jaxdem.forces.force_manager.ForceManager(gravity: jax.Array, external_force: jax.Array, external_torque: jax.Array, force_functions: Tuple[ForceFunction, ...] = ())[source]#
Bases:
objectManage per-particle force contributions prior to pairwise interactions.
- gravity: jax.Array#
Constant acceleration applied to all particles. Shape
(dim,).
- external_force: jax.Array#
Accumulated external force applied to all particles. This buffer is cleared when
apply()is invoked.
- external_torque: jax.Array#
Accumulated external torque applied to all particles. This buffer is cleared when
apply()is invoked.
- force_functions: Tuple[ForceFunction, ...]#
Optional tuple of callables with signature
(state, system, i)returning per-particle force and torque contributions for particlei.
- static create(dim: int, shape: Tuple, *, gravity: jax.Array | None = None, force_functions: Sequence[ForceFunction] = ()) ForceManager[source][source]#
Create a
ForceManagerfor a system withdimspatial dimensions.- Parameters:
dim – Spatial dimension of the managed system.
gravity – Optional initial gravitational acceleration. Defaults to zeros.
force_functions – Sequence of callables with signature (state, system, index) returning per-particle force/torque contributions.
- static add_force(state: State, system: System, force: jax.Array, *, torque: jax.Array | None = None) System[source][source]#
Accumulate an external force (and optionally torque) to be applied on the next
applycall for all particles.- Parameters:
- Returns:
A new
jaxdem.Systeminstance with the updated accumulated forces and torques.- Return type:
- static add_force_at(state: State, system: System, force: jax.Array, idx: jax.Array, *, torque: jax.Array | None = None) System[source][source]#
Accumulate an external force (and optionally torque) to be applied on the next
applycall overidxparticles.- Parameters:
state (State) – Current state of the simulation.
system (System) – Simulation system configuration.
force – Force contribution to accumulate. Must be an array broadcastable to
external_force[idx].idx – integer indices of the particles receiving the contribution.
torque – Optional torque contribution to accumulate. Must be an array broadcastable to
external_torque[idx].
- Returns:
A new
jaxdem.Systeminstance with the updated accumulated forces and torques.- Return type: