Classes/routines for pair potentials (analphipy.potential)#
Classes:
|
Class to define potential using callables. |
|
Base class for defining analytic potentials. |
|
Lennard-Jones potential. |
|
Generalized Lennard-Jones potential |
|
Hard core Yukawa potential |
|
Hard-sphere pair potential |
|
Square-well pair potential |
|
Cubic interpolation table potential. |
Functions:
|
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:
PhiBaseClass to define potential using callables.
- Parameters:
phi_func (
Callable) – Functionphi(r)dphidr (
Callable, optional) – Optional functiondphidr(r).r_min (
float) – Location of minimum in potential energy.phi_min (
float, optional) – Value of potential energy at minimum.segments (sequence of
int) – Integration limits. Forn = len(segments)integration will be performed over ranges(segments[0], segments[1]), (segments[1], segments[2]), ..., (segments[n-2], segments[n-]])
Attributes:
Function \(\phi(r)\)
Function \(d\phi(r)/dr\)
Methods:
- 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:
PhiBaseBase class for defining analytic potentials.
- Parameters:
r_min (
float) – Location of minimum in potential energy.phi_min (
float, optional) – Value of potential energy at minimum.segments (sequence of
int) – Integration limits. Forn = len(segments)integration will be performed over ranges(segments[0], segments[1]), (segments[1], segments[2]), ..., (segments[n-2], segments[n-]])
Notes
Specific subclasses should set values for
r_min,phi_min, andsegments, as well as forms forphianddphidr.Attributes:
Position of minimum in \(\phi(r)\)
Value of
phiat minimum.Integration limits.
- r_min#
Position of minimum in \(\phi(r)\)
- phi_min#
Value of
phiat minimum.
- segments#
Integration limits.
- class analphipy.potential.LennardJones(sig=1.0, eps=1.0)[source]#
Bases:
AnalyticLennard-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, andsegments, as well as forms forphianddphidr.Attributes:
Methods:
- 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:
AnalyticGeneralized 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=12andm=6, this is equivalent toLennardJones.Attributes:
Methods:
- n#
nparameter
- m#
mparameter
- 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:
AnalyticHard 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, andsegments, as well as forms forphianddphidr.Attributes:
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:
AnalyticHard-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, andsegments, as well as forms forphianddphidr.Attributes:
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:
AnalyticSquare-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, andsegments, as well as forms forphianddphidr.Attributes:
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:
PhiBaseCubic interpolation table potential.
- Parameters:
r_min (
float) – Location of minimum in potential energy.phi_min (
float, optional) – Value of potential energy at minimum.bounds (sequence of
float) – the minimum and maximum values of squared pair separation r**2 at which phi_table is evaluated.phi_table (array-like) – Values of potential evaluated on even grid of
r**2values.segments (sequence of
float, optional) – Integration segments. Defaults tosqrt(bounds).phi_left, phi_right, dphi_left, dphi_right (
float, optional) – Values to set forphi/-1/r dphidrif (left)r < bounds[0]or (right)r > bounds[1].
Attributes:
Minimum and maximum values of squared pair separation \(r^2\)
Values of potential evaluated on even grid of \(r^2\) values.
value of phi at left bound (r < bounds[0])
value of phi at right bound (r > bounds[1])
value of dphi at left bound
value of dphi at right bound
Size of the array (less 1).
Minimum value of s = r**2.
Maximum value of s = r**2.
Value of
r**2where potential is defined.Values of
rwhere 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
phiat even spacing ins = r**2space.- Parameters:
phi (
callable()) – pair potential functionrmin (
float) – minimum pair separation r to evaluate at.rmax (
float) – Maximum pair separation r to evaluate at.ds (
float) – spaceing ins = 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.
- 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**2where potential is defined.
- property r_table#
Values of
rwhere 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:
potential_name (
{lj, nm, sw, hs, yk}) – Name of potential.rcut (
float, optional) – if passed, Construct either and ‘lfs’ or ‘cut’ version of the potential.lfs (
bool, defaultFalse) – If True, construct a linear force shifted potentialanalphipy.base_potential.PhiLFS.cut (
bool, defaultFalse) – If True, construct a cut potentialanalphipy.base_potential.PhiCut.
- Returns:
phi (
analphipy.base_potential.PhiBasesubclass) – output potential energy class.
See also
LennardJones,LennardJonesNM,SquareWell,HardSphere,Yukawa