pyretis.forcefield.potentials package¶
A collection of potential functions.
This package defines some potential functions. These potential functions can be used to create force fields.
Package structure¶
Modules¶
- potentials.py (
pyretis.forcefield.potentials.potentials) - This module defines some simple potential functions.
Sub-packages¶
- pairpotentials (
pyretis.forcefield.potentials.pairpotentials) - This package defines different pair interactions, for instance the Lennard-Jones 6-12 simple cut potential.
Important classes defined in this package¶
- DoubleWell (
DoubleWell) - A double well potential
- RectangularWell (
RectangularWell) - A rectangular well potential – useful as a bias potential.
- TripleWell (
TripleWell) - A 1D triple well potential, useful for demonstrating multi-state
sampling features such as the
zero_leftinterface. - PairLennardJonesCut (
PairLennardJonesCut) - The Lennard-Jones potential in pure python.
- PairLennardJonesCutnp (
PairLennardJonesCutnp) - The Lennard-Jones potential, making use of numpy.
- DoubleWellWCA (
DoubleWellWCA) - A n-dimensional Double Well potential.
Subpackages¶
- pyretis.forcefield.potentials.pairpotentials package
List of submodules¶
pyretis.forcefield.potentials.potentials module¶
A collection of simple position dependent potentials.
This module defines some potential functions which are useful as simple models.
Important classes defined here¶
- DoubleWell (
DoubleWell) - This class defines a one-dimensional double well potential.
- RectangularWell (
RectangularWell) - This class defines a one-dimensional rectangular well potential.
- TripleWell (
TripleWell) - This class defines a one-dimensional triple well potential.
-
class
pyretis.forcefield.potentials.potentials.DoubleWell(a=1.0, b=1.0, c=0.0, desc='1D double well potential')[source]¶ Bases:
PotentialFunctionA 1D double well potential.
This class defines a one-dimensional double well potential. The potential energy (\(V_\text{pot}\)) is given by
\[V_\text{pot} = a x^4 - b (x - c)^2\]where \(x\) is the position and \(a\), \(b\) and \(c\) are parameters for the potential. These parameters are stored as attributes of the class. Typically, both \(a\) and \(b\) are positive quantities, however, we do not explicitly check that here.
Variables: params (dict) – Contains the parameters. The keys are:
- a: The
aparameter for the potential. - b: The
bparameter for the potential. - c: The
cparameter for the potential.
These keys corresponds to the parameters in the potential, \(V_\text{pot} = a x^4 - b (x - c)^2\).
-
__init__(a=1.0, b=1.0, c=0.0, desc='1D double well potential')[source]¶ Initialise the one dimensional double well potential.
Parameters: - a (float, optional) – Parameter for the potential.
- b (float, optional) – Parameter for the potential.
- c (float, optional) – Parameter for the potential.
- desc (string, optional) – Description of the force field.
-
force(system)[source]¶ Evaluate forces for the 1D double well potential.
Parameters: system (object like System) – The system we evaluate the potential for. Here, we make use of the positions only.Returns: - out[0] (numpy.array) – The calculated force.
- out[1] (numpy.array) – The virial, currently not implemented for this potential!
-
potential(system)[source]¶ Evaluate the potential for the one-dimensional double well.
Parameters: system (object like System) – The system we evaluate the potential for. Here, we make use of the positions only.Returns: out (float) – The potential energy.
-
potential_and_force(system)[source]¶ Evaluate the potential and the force.
Parameters: system (object like System) – The system we evaluate the potential for. Here, we make use of the positions only.Returns: - out[0] (float) – The potential energy as a float.
- out[1] (numpy.array) – The force as a numpy.array of the same shape as the positions in particles.pos.
- out[2] (numpy.array) – The virial, currently not implemented for this potential!
- a: The
-
class
pyretis.forcefield.potentials.potentials.RectangularWell(left=0.0, right=1.0, largenumber=inf, desc='1D Rectangular well potential')[source]¶ Bases:
PotentialFunctionA 1D rectangular well potential.
This class defines a one-dimensional rectangular well potential. The potential energy is zero within the potential well and infinite outside. The well is defined with a left and right boundary.
Variables: params (dict) – The parameters for the potential. The keys are:
- left: Left boundary of the potential.
- right: Right boundary of the potential.
- largenumber: Value of potential outside the boundaries.
It is possible to define left > right, however, a warning will be issued then.
-
__init__(left=0.0, right=1.0, largenumber=inf, desc='1D Rectangular well potential')[source]¶ Initialise the one-dimensional rectangular well.
Parameters: - left (float, optional) – The left boundary of the potential.
- right (float, optional) – The right boundary of the potential.
- largenumber (float, optional) – The value of the potential outside (left, right).
- desc (string, optional) – Description of the force field.
-
class
pyretis.forcefield.potentials.potentials.TripleWell(a=1.0, b=-4.0, c=4.0, d=0.0, desc='1D triple well potential')[source]¶ Bases:
PotentialFunctionA 1D triple well potential.
This class defines a one-dimensional triple well potential. The potential energy (\(V_\text{pot}\)) is given by
\[V_\text{pot} = a x^6 + b x^4 + c x^2 + d x\]where \(x\) is the position and \(a\), \(b\), \(c\) and \(d\) are parameters for the potential. With the default parameters (\(a = 1\), \(b = -4\), \(c = 4\), \(d = 0\)) the potential has three minima at \(x = -\sqrt{2}\), \(x = 0\) and \(x = +\sqrt{2}\) (states A, B and C) separated by two equal-height barriers at \(x = \pm\sqrt{2/3}\). The \(d\) parameter introduces a linear tilt that can be used to break the A/C symmetry.
Variables: params (dict) – Contains the parameters. The keys are:
- a: The
aparameter for the potential. - b: The
bparameter for the potential. - c: The
cparameter for the potential. - d: The
dparameter for the potential.
-
__init__(a=1.0, b=-4.0, c=4.0, d=0.0, desc='1D triple well potential')[source]¶ Initialise the one-dimensional triple well potential.
Parameters: - a (float, optional) – Sixth-order coefficient of the polynomial.
- b (float, optional) – Fourth-order coefficient of the polynomial.
- c (float, optional) – Second-order coefficient of the polynomial.
- d (float, optional) – Linear coefficient; tilts the potential to break A/C symmetry.
- desc (string, optional) – Description of the force field.
-
force(system)[source]¶ Evaluate forces for the 1D triple well potential.
Parameters: system (object like System) – The system we evaluate the potential for. Here, we make use of the positions only.Returns: - out[0] (numpy.array) – The calculated force.
- out[1] (numpy.array) – The virial, currently not implemented for this potential!
-
potential(system)[source]¶ Evaluate the potential for the one-dimensional triple well.
Parameters: system (object like System) – The system we evaluate the potential for. Here, we make use of the positions only.Returns: out (float) – The potential energy.
-
potential_and_force(system)[source]¶ Evaluate the potential and the force.
Parameters: system (object like System) – The system we evaluate the potential for. Here, we make use of the positions only.Returns: - out[0] (float) – The potential energy as a float.
- out[1] (numpy.array) – The force as a numpy.array of the same shape as the positions in particles.pos.
- out[2] (numpy.array) – The virial, currently not implemented for this potential!
- a: The