pylj.potentials#

The species and pair potentials packaged with pylj.

Atom species and pair potentials.

pylj.potentials.check_positive_finite(name: str, value: float) None[source]#

Raises ValueError unless value is positive and finite.

Parameters:
  • name – The name of the parameter, for the error message.

  • value – The value to check.

class pylj.potentials.Species(mass: float, name: str = '')[source]#

Bases: object

An atom species.

Parameters:
  • mass – The atom mass, in atomic mass units.

  • name – A label for the species, such as “argon”.

Raises:

ValueError – If the mass is not positive and finite.

class pylj.potentials.PairPotential[source]#

Bases: ABC

The interface every pair potential implements.

Both energies and forces take an array of separations dr, in metres, and return an array of the same shape.

min_separation#

The separation, in metres, below which the potential is unphysical. Zero, the default, means the potential is physical at every separation. A configuration treats any pair closer than this as forbidden: its energy is infinite, and asking for its force raises an error.

Type:

float

abstractmethod energies(dr: ArrayLike) NDArray[float64][source]#

Evaluates the pair energy at each separation in dr.

abstractmethod forces(dr: ArrayLike) NDArray[float64][source]#

Evaluates the signed radial force at each separation in dr.

Minus the derivative of the energy with respect to the separation, so positive where the interaction is repulsive.

class pylj.potentials.LennardJones(*, epsilon: float, sigma: float)[source]#

Bases: PairPotential

The 12-6 Lennard-Jones pair potential.

\[E = 4 \epsilon \left[ (\sigma / r)^{12} - (\sigma / r)^{6} \right]\]
Parameters:
  • epsilon – The well depth, in joules.

  • sigma – The separation at which the pair energy is zero, in metres.

Raises:

ValueError – If epsilon or sigma is not positive and finite.

energies(dr: ArrayLike) NDArray[float64][source]#

Evaluates the pair energy at each separation in dr.

forces(dr: ArrayLike) NDArray[float64][source]#

Evaluates the signed radial force at each separation in dr.

Minus the derivative of the energy with respect to the separation, so positive where the interaction is repulsive.

class pylj.potentials.Buckingham(*, a: float, b: float, c: float)[source]#

Bases: PairPotential

The Buckingham pair potential.

\[E = A e^{-B r} - C / r^{6}\]

The formula falls to minus infinity at short range, beyond a barrier. energies and forces return it at every separation, and min_separation is the separation at the top of that barrier.

Parameters:
  • a – The A parameter, an energy scale, in joules.

  • b – The B parameter, an inverse length, in reciprocal metres.

  • c – The C parameter, the dispersion coefficient, in joule metre^6.

min_separation#

The separation of the top of the short-range barrier, in metres; zero when there is no barrier.

Type:

float

Raises:

ValueError – If a or b is not positive and finite, if c is negative or not finite, or if the barrier lies beyond 100 Angstrom.

energies(dr: ArrayLike) NDArray[float64][source]#

Evaluates the pair energy at each separation in dr.

forces(dr: ArrayLike) NDArray[float64][source]#

Evaluates the signed radial force at each separation in dr.

Minus the derivative of the energy with respect to the separation, so positive where the interaction is repulsive.

class pylj.potentials.SquareWell(*, epsilon: float, sigma: float, lambda_: float, max_val: float = inf)[source]#

Bases: PairPotential

The square-well pair potential.

The energy is max_val below sigma, minus epsilon between sigma and lambda_ times sigma, and zero beyond. It has no finite force, so it is for Monte Carlo, which uses energies only.

Parameters:
  • epsilon – The well depth, in joules.

  • sigma – The hard-core diameter, in metres.

  • lambda – The outer edge of the well, in units of sigma.

  • max_val – The value used in place of the infinite hard core.

Raises:

ValueError – If epsilon or sigma is not positive and finite, lambda_ is not greater than one, or max_val is not positive.

energies(dr: ArrayLike) NDArray[float64][source]#

Evaluates the pair energy at each separation in dr.

forces(dr: ArrayLike) NDArray[float64][source]#

Evaluates the signed radial force at each separation in dr.

Minus the derivative of the energy with respect to the separation, so positive where the interaction is repulsive.