jaxdem.domains.reflect_sphere#

Reflective boundary-condition domain.

Classes

ReflectSphereDomain(box_size, inv_box_size, ...)

A Domain implementation that enforces reflective boundary conditions only for spheres.

class jaxdem.domains.reflect_sphere.ReflectSphereDomain(box_size: Array, inv_box_size: Array, anchor: Array, restitution_coefficient: Array)#

Bases: Domain

A Domain implementation that enforces reflective boundary conditions only for spheres. This dedicated version exists for performance.

When a particle moves beyond the defined box_size, the domain reflects its position back into the box. It also reverses the velocity component normal to the boundary, scaled by restitution_coefficient.

Notes

  • The reflection occurs at the boundaries defined by anchor and anchor + box_size.

search_geometry: ClassVar[SearchGeometry | None] = 'orthogonal'#
restitution_coefficient: Array#
classmethod Create(dim: int, box_size: Array | None = None, anchor: Array | None = None, restitution_coefficient: float = 1.0, **kw: Any) → Self[source]#

Default factory method for the ReflectSphereDomain class.

Parameters:
  • dim (int) – The dimensionality of the domain (e.g., 2, 3).

  • box_size (jax.Array, optional) – The size of the domain along each dimension. If not provided, defaults to an array of ones with shape (dim,).

  • anchor (jax.Array, optional) – The anchor (origin) of the domain. If not provided, defaults to an array of zeros with shape (dim,).

  • restitution_coefficient (float) – Restitution coefficient between 0 and 1 to modulate energy conservation with wall.

Returns:

A new instance with the specified or default configuration.

Return type:

ReflectSphereDomain

Raises:

ValueError – If box_size or anchor have the wrong shape, or if restitution_coefficient is outside (0, 1].

static apply(state: State, system: System) → tuple[State, System][source]#

Apply reflective boundary conditions to particles.

The method checks particles against the domain boundaries. When a particle moves beyond a boundary, the method reflects its position back into the box. It also reverses the velocity component normal to that boundary, scaled by the restitution coefficient \(e\).

For each coordinate, the sphere center is bounded by \(l=a+R\) and \(u=a+B-R\), where \(a\) is the anchor, \(B\) the box size, and \(R\) the sphere radius. The shared Verlet collision solver computes the collision fraction \(\alpha\in[0,1]\) from the endpoint position, velocity, and acceleration \(a_{acc}\). For a crossed wall with closing velocity:

\[\begin{split}v_{col} &= v + (\alpha-1)\Delta t\,a_{acc} \\ \Delta v &= -(1+e)v_{col} \\ v' &= v + \Delta v \\ r' &= r + \Delta v(1-\alpha)\Delta t\end{split}\]

Fixed particles and coordinates without a closing wall receive no impulse. Geometric position mirroring is the constant-speed elastic special case of this remaining-time correction. The restitution coefficient is \(e\).

Parameters:
  • state (State) – The current state of the simulation.

  • system (System) – The configuration of the simulation.

Returns:

The updated State object with reflected positions and velocities, and the System object.

Return type:

Tuple[State, System]

Note

  • Only works for states with ONLY spheres.