spheropack.rejection_free.System#

class spheropack.rejection_free.System(positions=None, *, n=None, density=None, box=None, potential, kT=1.0, seed=None, dim=3, method='collisions', chain_length=1.0, irreversible=True)#

Particles interacting with a pair potential in a periodic box, sampled with the rejection-free method.

Parameters:
  • positions (np.ndarray | None) – Initial positions, shape (n, dim). If omitted, n particles are placed uniformly at random (for strongly repulsive potentials start from a packing instead, e.g. sp.pack(...).positions, to avoid huge initial energies).

  • n (int | None) – Number of particles and number density; with box omitted, a cube (square for dim=2) of the matching size is used.

  • density (float | None) – Number of particles and number density; with box omitted, a cube (square for dim=2) of the matching size is used.

  • box (Box | None) – Periodic box (spheropack.PeriodicBox()); edges at least twice the cutoff.

  • potential (PairPotential) – The pair potential.

  • kT (float) – Temperature.

  • seed (int | None) – Random seed. None draws one.

  • dim (int) – Dimension when neither positions nor box are given.

  • method (Literal['collisions', 'event_chain']) – "collisions" (default): all particles move simultaneously and pairs reflect (the first implementation of the paper). "event_chain": one particle moves at a time along a coordinate axis and passes its motion to the partner at a reflection (the straight event-chain variant), usually faster for dense systems.

  • chain_length (float) – Displacement per chain (event_chain only).

  • irreversible (bool) – event_chain only: cycle the directions +x, +y, +z (default, faster; global balance) instead of random axes and signs (detailed balance).

  • methods (Time is measured as the mean displacement per particle in both)

  • with (moves every particle along its path for t (collisions) or performs chains)

  • chain). (a total displacement n * t (event)

__init__(positions=None, *, n=None, density=None, box=None, potential, kT=1.0, seed=None, dim=3, method='collisions', chain_length=1.0, irreversible=True)#
Parameters:

Methods

__init__([positions, n, density, box, kT, ...])

potential_energy()

Total potential energy of the current configuration.

redraw_velocities()

Draws new move velocities (standard normal); collisions method only.

run(time)

Advances the simulation by time.

samples(n_samples, interval[, redraw_velocities])

Yields the positions n_samples times, every interval of simulation time.

set_velocities(velocities)

Sets the move velocities, shape (n, dim); collisions method only.

snapshot()

The current configuration as a Packing (spheres of diameter sigma), for spheropack.analysis and spheropack.io.

Attributes

density

Number density.

dim

n

n_reflections

Number of reflections (lifts in the event-chain method).

positions

Current positions (a copy), wrapped into the box.

time

the mean displacement per particle.

velocities

Current move velocities (a copy); collisions method only.