Classes/routines for pair potentials (analphipy.potential)#

Classes:

Generic(phi_func[, dphidr_func, r_min, ...])

Class to define potential using callables.

Analytic()

Base class for defining analytic potentials.

LennardJones([sig, eps])

Lennard-Jones potential.

LennardJonesNM([n, m, sig, eps])

Generalized Lennard-Jones potential

Yukawa([z, sig, eps])

Hard core Yukawa potential

HardSphere([sig])

Hard-sphere pair potential

SquareWell([sig, eps, lam])

Square-well pair potential

CubicTable(bounds, phi_table[, phi_left, ...])

Cubic interpolation table potential.

Functions:

factory(potential_name[, rcut, lfs, cut])

Factory function to construct Phi object by name.

class analphipy.potential.Generic(phi_func, dphidr_func=None, *, r_min=None, phi_min=None, segments=None)[source]#

Bases: PhiBase

Class to define potential using callables.

Parameters:
  • r_min – The description is missing.

  • phi_min – The description is missing.

  • segments – The description is missing.

Attributes:

phi_func

Function \(\phi(r)\)

dphidr_func

Function \(d\phi(r)/dr\)

Methods:

phi(r)

Pair potential.

dphidr(r)

Derivative of pair potential.

phi_func#

Function \(\phi(r)\)

dphidr_func#

Function \(d\phi(r)/dr\)

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

dphidr(r)[source]#

Derivative of pair potential.

This returns the value of \(d \phi(r) / dr\)

Parameters:

r (array-like) – pair separation

Returns:

dphidr (ndarray) – Pair potential values.

class analphipy.potential.Analytic[source]#

Bases: PhiBase

Base class for defining analytic potentials.

Parameters:
  • r_min (float) – The description is missing.

  • phi_min (float) – The description is missing.

  • segments (Sequence[float]) – The description is missing.

Notes

Specific subclasses should set values for r_min, phi_min, and segments, as well as forms for phi and dphidr.

Attributes:

r_min

Position of minimum in \(\phi(r)\)

phi_min

Value of phi at minimum.

segments

Integration limits.

r_min#

Position of minimum in \(\phi(r)\)

phi_min#

Value of phi at minimum.

segments#

Integration limits.

class analphipy.potential.LennardJones(sig=1.0, eps=1.0)[source]#

Bases: Analytic

Lennard-Jones potential.

\[\phi(r) = 4 \epsilon \left[ \left(\frac{\sigma}{r}\right)^{12} - \left(\frac{\sigma}{r}\right)^6\right]\]

Notes

Specific subclasses should set values for r_min, phi_min, and segments, as well as forms for phi and dphidr.

Attributes:

sig

Length parameter \(\sigma\)

eps

Energy parameter \(\epsilon\)

Methods:

phi(r)

Pair potential.

dphidr(r)

Calculate phi and dphi (=-1/r dphi/dr) at particular r.

sig#

Length parameter \(\sigma\)

eps#

Energy parameter \(\epsilon\)

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

dphidr(r)[source]#

Calculate phi and dphi (=-1/r dphi/dr) at particular r.

Parameters:

r (array-like) – pair separation

Returns:

dphidr (ndarray) – Pair potential values.

class analphipy.potential.LennardJonesNM(n=12, m=6, sig=1.0, eps=1.0)[source]#

Bases: Analytic

Generalized Lennard-Jones potential

\[\phi(r) = \epsilon \frac{n}{n-m} \left( \frac{n}{m} \right) ^{m / (n-m)} \left[ \left(\frac{\sigma}{r}\right)^n - \left(\frac{\sigma}{r}\right)^m\right]\]

Notes

with parameters n=12 and m=6, this is equivalent to LennardJones.

Attributes:

n

n parameter

m

m parameter

sig

Length parameter

eps

Energy parameter

Methods:

phi(r)

Pair potential.

dphidr(r)

Derivative of pair potential.

n#

n parameter

m#

m parameter

sig#

Length parameter

eps#

Energy parameter

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

dphidr(r)[source]#

Derivative of pair potential.

This returns the value of \(d \phi(r) / dr\)

Parameters:

r (array-like) – pair separation

Returns:

dphidr (ndarray) – Pair potential values.

class analphipy.potential.Yukawa(z=1.0, sig=1.0, eps=1.0)[source]#

Bases: Analytic

Hard core Yukawa potential

\[\begin{split}\phi(r) = \begin{cases} \infty & r \leq \sigma \\ -\epsilon \frac{\sigma}{r} \exp\left[-z (r/\sigma - 1) \right] & r > \sigma \end{cases}\end{split}\]

Notes

Specific subclasses should set values for r_min, phi_min, and segments, as well as forms for phi and dphidr.

Attributes:

z

Interaction parameter

sig

Length parameter

eps

Energy parameter

Methods:

phi(r)

Pair potential.

z#

Interaction parameter

sig#

Length parameter

eps#

Energy parameter

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

class analphipy.potential.HardSphere(sig=1.0)[source]#

Bases: Analytic

Hard-sphere pair potential

\[\begin{split}\phi(r) = \begin{cases} \infty & r \leq \sigma \\ 0 & r > \sigma \end{cases}\end{split}\]

Notes

Specific subclasses should set values for r_min, phi_min, and segments, as well as forms for phi and dphidr.

Attributes:

sig

Length parameter

Methods:

phi(r)

Pair potential.

sig#

Length parameter

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

class analphipy.potential.SquareWell(sig=1.0, eps=1.0, lam=1.5)[source]#

Bases: Analytic

Square-well pair potential

\[\begin{split}\phi(r) = \begin{cases} \infty & r \leq \sigma \\ \epsilon & \sigma < r \leq \lambda \sigma \\ 0 & r > \lambda \sigma \end{cases}\end{split}\]

Notes

Specific subclasses should set values for r_min, phi_min, and segments, as well as forms for phi and dphidr.

Attributes:

sig

Length parameter.

eps

Energy parameter.

lam

Well width parameter.

Methods:

phi(r)

Pair potential.

sig#

Length parameter.

eps#

Energy parameter.

lam#

Well width parameter.

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

class analphipy.potential.CubicTable(bounds, phi_table, phi_left=inf, phi_right=0.0, dphi_left=inf, dphi_right=0.0, *, r_min=None, phi_min=None, segments=None)[source]#

Bases: PhiBase

Cubic interpolation table potential.

Parameters:
  • r_min – The description is missing.

  • phi_min – The description is missing.

  • segments (sequence of float, optional) – Integration segments. Defaults to sqrt(bounds).

Attributes:

bounds

Minimum and maximum values of squared pair separation \(r^2\)

phi_table

Values of potential evaluated on even grid of \(r^2\) values.

phi_left

value of phi at left bound (r < bounds[0])

phi_right

value of phi at right bound (r > bounds[1])

dphi_left

value of dphi at left bound

dphi_right

value of dphi at right bound

size

Size of the array (less 1).

smin

Minimum value of s = r**2.

smax

Maximum value of s = r**2.

rsq_table

Value of r**2 where potential is defined.

r_table

Values of r where potential is defined.

Methods:

from_phi(phi, rmin, rmax, ds, **kws)

Create object from callable pair potential function.

phidphi(r)

Values of phi and dphi at r.

phi(r)

Pair potential.

dphidr(r)

Derivative of pair potential.

bounds#

Minimum and maximum values of squared pair separation \(r^2\)

phi_table#

Values of potential evaluated on even grid of \(r^2\) values.

phi_left#

value of phi at left bound (r < bounds[0])

phi_right#

value of phi at right bound (r > bounds[1])

dphi_left#

value of dphi at left bound

dphi_right#

value of dphi at right bound

classmethod from_phi(phi, rmin, rmax, ds, **kws)[source]#

Create object from callable pair potential function.

This will evaluate phi at even spacing in s = r**2 space.

Parameters:
  • phi (callable()) – pair potential function

  • rmin (float) – minimum pair separation r to evaluate at.

  • rmax (float) – Maximum pair separation r to evaluate at.

  • ds (float) – spaceing in s = r ** 2.

  • **kws – Extra arguments to constructor.

Returns:

table (CubicTable)

property size#

Size of the array (less 1).

property smin#

Minimum value of s = r**2.

property smax#

Maximum value of s = r**2.

phidphi(r)[source]#

Values of phi and dphi at r.

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

dphidr(r)[source]#

Derivative of pair potential.

This returns the value of \(d \phi(r) / dr\)

Parameters:

r (array-like) – pair separation

Returns:

dphidr (ndarray) – Pair potential values.

property rsq_table#

Value of r**2 where potential is defined.

property r_table#

Values of r where potential is defined.

analphipy.potential.factory(potential_name, rcut=None, lfs=False, cut=False, **kws)[source]#

Factory function to construct Phi object by name.

Parameters:
Returns:

phi (analphipy.base_potential.PhiBase subclass) – output potential energy class.