pylj.simulation#
The base class the two simulations share.
Shared simulation base class and sample records.
- pylj.simulation.DEFAULT_CUT_OFF = 15#
The cut-off used when none is given, in Angstrom, or half the box if that is smaller.
- class pylj.simulation.Samples(step: NDArray[int64] = <factory>)[source]#
Bases:
objectThe record a simulation’s
sampleappends to.Every array holds one entry per call of
sample, in order.- step#
The step at which each sample was taken.
- Type:
numpy._typing._array_like.NDArray[numpy.int64]
- class pylj.simulation.Simulation(configuration: Configuration, model: Model, *, cut_off: float | None = None, seed: int | None = None)[source]#
Bases:
ABCThe base class molecular dynamics and Monte Carlo share.
The constructor takes a configuration that is already built, in SI units; the
initialisemethod of either subclass builds one from a model and a number of atoms instead.- Parameters:
configuration – The starting configuration.
model – The model.
cut_off – The separation, in metres, beyond which a pair’s energy and force are zero. By default
DEFAULT_CUT_OFFAngstrom or half the box, whichever is smaller; it may not exceed half the box.seed – Seed for the random number generator; the same seed reproduces the run, and without one the run differs each time.
- configuration#
The current configuration.
- rng#
The random number generator for this simulation.
- steps#
The number of steps taken.
- samples#
The record
sampleappends to.
- trajectory#
The configurations sampled so far, a
Trajectory.
- Raises:
ValueError – If a species in the configuration is not in the model, or the cut-off exceeds half the box.
- restart() Self[source]#
Returns a new simulation continuing from the current configuration.
The new simulation copies the model, the numerical choices and the state of the random number generator, and starts with
stepsat zero, no samples and an empty trajectory. This simulation is unchanged. Use it to start a production run after equilibration:for _ in range(1000): simulation.step() production = simulation.restart() for _ in range(5000): production.step() production.sample()
- Returns:
The new simulation.