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:
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:
Function \(\phi(r)\)
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:
Notes
Specific subclasses should set values for
r_min
,phi_min
, andsegments
, as well as forms forphi
anddphidr
.Attributes:
Position of minimum in \(\phi(r)\)
Value of
phi
at minimum.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
, andsegments
, as well as forms forphi
anddphidr
.Attributes:
Length parameter \(\sigma\)
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
andm=6
, this is equivalent toLennardJones
.Attributes:
n
parameterm
parameterLength parameter
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
, andsegments
, as well as forms forphi
anddphidr
.Attributes:
Interaction parameter
Length parameter
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
, andsegments
, as well as forms forphi
anddphidr
.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:
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
, andsegments
, as well as forms forphi
anddphidr
.Attributes:
Length parameter.
Energy parameter.
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:
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**2
where potential is defined.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 ins = r**2
space.- 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**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:
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.PhiBase
subclass) – output potential energy class.
See also
LennardJones
,LennardJonesNM
,SquareWell
,HardSphere
,Yukawa