Base classes (analphipy.base_potential)#

Classes:

PhiAbstract(*[, r_min, phi_min, segments])

Abstract class from which base classes inherit.

PhiCutBase(phi_base, rcut, *[, r_min, phi_min])

Base Class for creating cut potential from base potential

PhiCut(phi_base, rcut, *[, r_min, phi_min])

Pair potential cut at position r_cut.

PhiLFS(phi_base, rcut, *[, r_min, phi_min])

Pair potential cut and linear force shifted at r_cut.

PhiBase(*[, r_min, phi_min, segments])

Base class for potentials.

class analphipy.base_potential.PhiAbstract(*, r_min=None, phi_min=None, segments=None)[source]#

Bases: object

Abstract class from which base classes inherit.

Parameters:
  • r_min (float, optional) – Position of minimum.

  • phi_min (float, optional) – Value of phi at r_min.

  • segments (sequence of int) – Integration limits. For n = len(segments) integration will be performed over ranges (segments[0], segments[1]), (segments[1], segments[2]), ..., (segments[n-2], segments[n-]])

Attributes:

r_min

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

phi_min

Value of phi at minimum.

segments

Integration limits

Methods:

asdict()

Convert object to dictionary.

new_like(**kws)

Create a new object with optional parameters.

assign(**kws)

Alias to new_like().

phi(r)

Pair potential.

dphidr(r)

Derivative of pair potential.

minimize(r0[, bounds])

Determine position r where phi is minimized.

assign_min_numeric(r0[, bounds])

Create new object with minima set by numerical minimization.

to_nf(**kws)

Create a analphipy.norofrenkel.NoroFrenkelPair object.

to_measures(**kws)

Create a analphipy.measures.Measures object.

r_min#

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

phi_min#

Value of phi at minimum.

segments#

Integration limits

asdict()[source]#

Convert object to dictionary.

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

assign(**kws)[source]#

Alias to new_like().

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.

minimize(r0, bounds=None, **kws)[source]#

Determine position r where phi is minimized.

Parameters:
  • r0 (float) – Guess for position of minimum. If value is ‘mean’, then use r0 = mean(bounds).

  • bounds (tuple of float, {'segments'}, optional) – Bounds for minimization search. If tuple, should be of form bounds=(lower_bound, upper_bound). If ‘segments, then bounds=(segments[0], segments[-1]). If None, no bounds used.

  • **kws – Extra arguments to analphipy.utils.minimize_phi()

Returns:

See also

minimize_phi

assign_min_numeric(r0, bounds=None, **kws)[source]#

Create new object with minima set by numerical minimization.

call minimize()

to_nf(**kws)[source]#

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Parameters:

**kws – Extra arguments to analphipy.norofrenkel.NoroFrenkelPair constructor. parameters phi, semgnets, r_min’, `phi_min default to values from self.

Returns:

nf (analphipy.norofrenkel.NoroFrenkelPair)

to_measures(**kws)[source]#

Create a analphipy.measures.Measures object.

Parameters:

**kws – Extra arguments to analphipy.measures.Measures constructor. parameters phi, semgnets default to values from self.

Returns:

nf (analphipy.measures.Measures)

class analphipy.base_potential.PhiCutBase(phi_base, rcut, *, r_min=None, phi_min=None)[source]#

Bases: PhiAbstract

Base Class for creating cut potential from base potential

\[ \begin{align}\begin{aligned}\begin{split}\phi_{\rm cut}(r) = \begin{cases} \phi(r) + {\text _vcorrect}(r) & r < r_{\rm cut} \\ 0 & r_{\rm cut} \leq r \end{cases}\end{split}\\\begin{split}\frac{d \phi_{\rm cut}(r)}{d r} = \begin{cases} \frac{d \phi(r)}{d r} + {\text _dvdrcorrect}(r) & r < r_{\rm cut} \\ 0 & r_{\rm cut} \leq r \end{cases}\end{split}\end{aligned}\end{align} \]

So, for example, for just cut, _vcorrect(r) = -v(rcut), dvrcut=0, and for lfs, _vcorrect(r) = -v(rcut) - dv(rcut)/dr (r - rcut) _dvcorrect(r) = …

Parameters:
  • r_min (float, optional) – Position of minimum.

  • phi_min (float, optional) – Value of phi at r_min.

  • segments (sequence of int) – Integration limits. For n = len(segments) integration will be performed over ranges (segments[0], segments[1]), (segments[1], segments[2]), ..., (segments[n-2], segments[n-]])

Attributes:

phi_base

Instance of (sub)class of analphipy.base_potential.PhiAbstract

rcut

Position to cut the potential

segments

Integration limits

phi_min

Value of phi at minimum.

r_min

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

Methods:

phi(r)

Pair potential.

dphidr(r)

Derivative of pair potential.

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

assign_min_numeric(r0[, bounds])

Create new object with minima set by numerical minimization.

minimize(r0[, bounds])

Determine position r where phi is minimized.

new_like(**kws)

Create a new object with optional parameters.

to_measures(**kws)

Create a analphipy.measures.Measures object.

to_nf(**kws)

Create a analphipy.norofrenkel.NoroFrenkelPair object.

phi_base#

Instance of (sub)class of analphipy.base_potential.PhiAbstract

rcut#

Position to cut the potential

segments#

Integration limits

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.

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

assign_min_numeric(r0, bounds=None, **kws)[source]#

Create new object with minima set by numerical minimization.

call minimize()

minimize(r0, bounds=None, **kws)[source]#

Determine position r where phi is minimized.

Parameters:
  • r0 (float) – Guess for position of minimum. If value is ‘mean’, then use r0 = mean(bounds).

  • bounds (tuple of float, {'segments'}, optional) – Bounds for minimization search. If tuple, should be of form bounds=(lower_bound, upper_bound). If ‘segments, then bounds=(segments[0], segments[-1]). If None, no bounds used.

  • **kws – Extra arguments to analphipy.utils.minimize_phi()

Returns:

See also

minimize_phi

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

phi_min#

Value of phi at minimum.

r_min#

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

to_measures(**kws)[source]#

Create a analphipy.measures.Measures object.

Parameters:

**kws – Extra arguments to analphipy.measures.Measures constructor. parameters phi, semgnets default to values from self.

Returns:

nf (analphipy.measures.Measures)

to_nf(**kws)[source]#

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Parameters:

**kws – Extra arguments to analphipy.norofrenkel.NoroFrenkelPair constructor. parameters phi, semgnets, r_min’, `phi_min default to values from self.

Returns:

nf (analphipy.norofrenkel.NoroFrenkelPair)

class analphipy.base_potential.PhiCut(phi_base, rcut, *, r_min=None, phi_min=None)[source]#

Bases: PhiCutBase

Pair potential cut at position r_cut.

\[\begin{split}\phi_{\rm cut}(r) = \begin{cases} \phi(r) - \phi(r_{\rm cut}) & r < r_{\rm cut} \\ 0 & r_{\rm cut} \leq r \end{cases}\end{split}\]
Parameters:
  • phi_base (analphipy.base_potential.PhiBase instance) – Potential class to perform cut on.

  • rcut (float) – Where to ‘cut’ the potential.

  • r_min – The description is missing.

  • phi_min – The description is missing.

Methods:

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

assign_min_numeric(r0[, bounds])

Create new object with minima set by numerical minimization.

dphidr(r)

Derivative of pair potential.

minimize(r0[, bounds])

Determine position r where phi is minimized.

new_like(**kws)

Create a new object with optional parameters.

phi(r)

Pair potential.

to_measures(**kws)

Create a analphipy.measures.Measures object.

to_nf(**kws)

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Attributes:

phi_base

Instance of (sub)class of analphipy.base_potential.PhiAbstract

phi_min

Value of phi at minimum.

r_min

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

rcut

Position to cut the potential

segments

Integration limits

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

assign_min_numeric(r0, bounds=None, **kws)[source]#

Create new object with minima set by numerical minimization.

call minimize()

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.

minimize(r0, bounds=None, **kws)[source]#

Determine position r where phi is minimized.

Parameters:
  • r0 (float) – Guess for position of minimum. If value is ‘mean’, then use r0 = mean(bounds).

  • bounds (tuple of float, {'segments'}, optional) – Bounds for minimization search. If tuple, should be of form bounds=(lower_bound, upper_bound). If ‘segments, then bounds=(segments[0], segments[-1]). If None, no bounds used.

  • **kws – Extra arguments to analphipy.utils.minimize_phi()

Returns:

See also

minimize_phi

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

phi_base#

Instance of (sub)class of analphipy.base_potential.PhiAbstract

phi_min#

Value of phi at minimum.

r_min#

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

rcut#

Position to cut the potential

segments#

Integration limits

to_measures(**kws)[source]#

Create a analphipy.measures.Measures object.

Parameters:

**kws – Extra arguments to analphipy.measures.Measures constructor. parameters phi, semgnets default to values from self.

Returns:

nf (analphipy.measures.Measures)

to_nf(**kws)[source]#

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Parameters:

**kws – Extra arguments to analphipy.norofrenkel.NoroFrenkelPair constructor. parameters phi, semgnets, r_min’, `phi_min default to values from self.

Returns:

nf (analphipy.norofrenkel.NoroFrenkelPair)

class analphipy.base_potential.PhiLFS(phi_base, rcut, *, r_min=None, phi_min=None)[source]#

Bases: PhiCutBase

Pair potential cut and linear force shifted at r_cut.

\[\begin{split}\phi_{\rm lfs}(r) = \begin{cases} \phi(r) - \left( \frac{d \phi}{d r} \right)_{\rm cut} (r - r_{\rm cut}) - \phi(r_{\rm cut}) & r < r_{\rm cut} \\ 0 & r_{\rm cut} < r \end{cases}\end{split}\]
Parameters:

Methods:

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

assign_min_numeric(r0[, bounds])

Create new object with minima set by numerical minimization.

dphidr(r)

Derivative of pair potential.

minimize(r0[, bounds])

Determine position r where phi is minimized.

new_like(**kws)

Create a new object with optional parameters.

phi(r)

Pair potential.

to_measures(**kws)

Create a analphipy.measures.Measures object.

to_nf(**kws)

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Attributes:

phi_base

Instance of (sub)class of analphipy.base_potential.PhiAbstract

phi_min

Value of phi at minimum.

r_min

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

rcut

Position to cut the potential

segments

Integration limits

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

assign_min_numeric(r0, bounds=None, **kws)[source]#

Create new object with minima set by numerical minimization.

call minimize()

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.

minimize(r0, bounds=None, **kws)[source]#

Determine position r where phi is minimized.

Parameters:
  • r0 (float) – Guess for position of minimum. If value is ‘mean’, then use r0 = mean(bounds).

  • bounds (tuple of float, {'segments'}, optional) – Bounds for minimization search. If tuple, should be of form bounds=(lower_bound, upper_bound). If ‘segments, then bounds=(segments[0], segments[-1]). If None, no bounds used.

  • **kws – Extra arguments to analphipy.utils.minimize_phi()

Returns:

See also

minimize_phi

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

phi_base#

Instance of (sub)class of analphipy.base_potential.PhiAbstract

phi_min#

Value of phi at minimum.

r_min#

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

rcut#

Position to cut the potential

segments#

Integration limits

to_measures(**kws)[source]#

Create a analphipy.measures.Measures object.

Parameters:

**kws – Extra arguments to analphipy.measures.Measures constructor. parameters phi, semgnets default to values from self.

Returns:

nf (analphipy.measures.Measures)

to_nf(**kws)[source]#

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Parameters:

**kws – Extra arguments to analphipy.norofrenkel.NoroFrenkelPair constructor. parameters phi, semgnets, r_min’, `phi_min default to values from self.

Returns:

nf (analphipy.norofrenkel.NoroFrenkelPair)

class analphipy.base_potential.PhiBase(*, r_min=None, phi_min=None, segments=None)[source]#

Bases: PhiAbstract

Base class for potentials.

Parameters:
  • r_min (float, optional) – Position of minimum.

  • phi_min (float, optional) – Value of phi at r_min.

  • segments (sequence of int) – Integration limits. For n = len(segments) integration will be performed over ranges (segments[0], segments[1]), (segments[1], segments[2]), ..., (segments[n-2], segments[n-]])

Methods:

cut(rcut)

Create a PhiCut potential.

lfs(rcut)

Create a PhiLFS potential.

asdict()

Convert object to dictionary.

assign(**kws)

Alias to new_like().

assign_min_numeric(r0[, bounds])

Create new object with minima set by numerical minimization.

dphidr(r)

Derivative of pair potential.

minimize(r0[, bounds])

Determine position r where phi is minimized.

new_like(**kws)

Create a new object with optional parameters.

phi(r)

Pair potential.

to_measures(**kws)

Create a analphipy.measures.Measures object.

to_nf(**kws)

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Attributes:

phi_min

Value of phi at minimum.

r_min

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

segments

Integration limits

cut(rcut)[source]#

Create a PhiCut potential.

lfs(rcut)[source]#

Create a PhiLFS potential.

asdict()[source]#

Convert object to dictionary.

assign(**kws)[source]#

Alias to new_like().

assign_min_numeric(r0, bounds=None, **kws)[source]#

Create new object with minima set by numerical minimization.

call minimize()

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.

minimize(r0, bounds=None, **kws)[source]#

Determine position r where phi is minimized.

Parameters:
  • r0 (float) – Guess for position of minimum. If value is ‘mean’, then use r0 = mean(bounds).

  • bounds (tuple of float, {'segments'}, optional) – Bounds for minimization search. If tuple, should be of form bounds=(lower_bound, upper_bound). If ‘segments, then bounds=(segments[0], segments[-1]). If None, no bounds used.

  • **kws – Extra arguments to analphipy.utils.minimize_phi()

Returns:

See also

minimize_phi

new_like(**kws)[source]#

Create a new object with optional parameters.

Parameters:

**kwsattribute, value pairs.

phi(r)[source]#

Pair potential.

Parameters:

r (array-like) – pair separation

Returns:

phi (ndarray) – Evaluated pair potential.

phi_min#

Value of phi at minimum.

r_min#

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

segments#

Integration limits

to_measures(**kws)[source]#

Create a analphipy.measures.Measures object.

Parameters:

**kws – Extra arguments to analphipy.measures.Measures constructor. parameters phi, semgnets default to values from self.

Returns:

nf (analphipy.measures.Measures)

to_nf(**kws)[source]#

Create a analphipy.norofrenkel.NoroFrenkelPair object.

Parameters:

**kws – Extra arguments to analphipy.norofrenkel.NoroFrenkelPair constructor. parameters phi, semgnets, r_min’, `phi_min default to values from self.

Returns:

nf (analphipy.norofrenkel.NoroFrenkelPair)