relentless.model.potential.LennardJones#
- class relentless.model.potential.LennardJones(types, name=None)#
Lennard-Jones 12-6 pair potential.
The classic molecular simulation potential:
\[u(r) = 4 \varepsilon\left[\left(\frac{\sigma}{r}\right)^{12} - \left(\frac{\sigma}{r}\right)^6 \right]\]where \(r\) is the distance between two particles. The parameters for each \((i,j)\) pair are:
Parameter
Description
Initial
epsilonInteraction energy \(\varepsilon\).
sigmaInteraction length \(\sigma\).
rminMinimum distance cutoff \(r_{\rm min}\). Force is zero and energy is constant for \(r < r_{\rm min}\). Ignored if
False.FalsermaxMaximum distance cutoff \(r_{\rm max}\). Force is zero and energy is constant for \(r > r_{\rm max}\). Ignored if
False.FalseshiftIf
True, shift potential to zero atrmax.FalseFor example, setting \(r_{\rm max} = 2^{1/6}\sigma\) and
shift=Truewill give the purely repulsive Weeks–Chandler–Anderson potential that is often used to model nearly hard spheres.- Parameters:
- coeff#
Parameters of the potential for each pair.
- Type:
Examples
Standard Lennard-Jones parameters:
>>> u = relentless.potential.pair.LennardJones(('A',)) >>> u.coeff['A','A'].update({'epsilon': 1.0, 'sigma': 1.0, 'rmax': 3.0}) >>> u.energy(('A','A'), 1.0) 0.0 >>> u.force(('A','A'), 2.**(1./6.)) 0.0
Methods
derivative(pair, var, r)Evaluate pair derivative with respect to a variable.
energy(pair, r)Evaluate pair energy.
force(pair, r)Evaluate pair force.
from_file(filename[, name])Create potential from a JSON file.
from_json(data[, name])Create potential from JSON data.
save(filename)Save the potential to file as JSON data.
to_json()Export potential to a JSON-compatible dictionary.
Attributes
countnames- derivative(pair, var, r)#
Evaluate pair derivative with respect to a variable.
The derivative is evaluated using the
_derivative()function for all \(u_{0,\lambda}(r)\). The truncation and shifting scheme is applied.The derivative will be carried out with respect to
varfor allVariableparameters. The appropriate chain rules are handled automatically. If the potential does not depend onvar, the derivative will be zero by definition.- Parameters:
- Returns:
The pair derivative evaluated at
r. The return type is consistent withr.- Return type:
- Raises:
ValueError – If any value in
ris negative.TypeError – If the parameter with respect to which to take the derivative is not a
Variable.ValueError – If the potential is shifted without setting
rmax.
- energy(pair, r)#
Evaluate pair energy.
The energy is evaluated using the
_energy()function for \(u_0(r)\). The truncation and shifting scheme is applied.- Parameters:
- Returns:
The pair energy evaluated at
r. The return type is consistent withr.- Return type:
- Raises:
ValueError – If any value in
ris negative.ValueError – If the potential is shifted without setting
rmax.
- force(pair, r)#
Evaluate pair force.
The force is evaluated using the
_force()function for \(f_0(r)\). The truncation and shifting scheme is applied.- Parameters:
- Returns:
The pair force evaluated at
r. The return type is consistent withr.- Return type:
- Raises:
ValueError – If any value in
ris negative.
- classmethod from_file(filename, name=None)#
Create potential from a JSON file.
It is assumed that the JSON file is compatible with the potential type.
- Parameters:
filename (str) – JSON file to load.
name (str or bool or None) – Name of the potential. If a
str,nameoverrides the value in the file. IfTrue, the name in the file is always preserved. IfFalse, the name in the file is always ignored, and a default name is created. IfNone, the value in the file is used if it is not taken and does not match the default name pattern; otherwise, a new default name is generated.
- classmethod from_json(data, name=None)#
Create potential from JSON data.
It is assumed that the data is compatible with the pair potential.
- Parameters:
data (dict) – JSON data for potential.
name (str or bool or None) – Name of the potential. If a
str,nameoverrides the value in the JSON data. IfTrue, the name in the JSON data is always preserved. IfFalse, the name in the JSON data is always ignored, and a default name is created. IfNone, the value in the JSON data is used if it is not taken and does not match the default name pattern; otherwise, a new default name is generated.