relentless.model.potential.HarmonicCosineAngle#
- class relentless.model.potential.HarmonicCosineAngle(types, name=None)#
Harmonic cosine angle potential.
\[u(\theta) = \frac{k}{2} (\cos \theta - \cos \theta_0)^2\]where \(\theta\) is the angle between three bonded particles. The parameters for each type are:
Parameter
Description
kSpring constant \(k\).
theta0Minimum-energy angle \(\theta_0\).
- Parameters:
- coeff#
Parameters of the potential for each type.
- Type:
Examples
Cosine Squared Angle:
>>> u = relentless.potential.angle.HarmonicCosineAngle(("A",)) >>> u.coeff["A"].update({'k': 1000, 'theta0': 1})
Methods
derivative(type_, var, theta)Evaluate derivative with respect to a variable.
energy(type_, theta)Evaluate angle energy.
force(type_, theta)Evaluate angle 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(type_, var, theta)#
Evaluate derivative with respect to a variable.
The derivative is evaluated using the
_derivative()function for all \(u_{0,\lambda}(theta)\).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 angle derivative evaluated at
theta. The return type is consistent withtheta.- Return type:
- Raises:
ValueError – If any value in
thetais not between 0 and pi.TypeError – If the parameter with respect to which to take the derivative is not a
Variable.
- energy(type_, theta)#
Evaluate angle energy.
- force(type_, theta)#
Evaluate angle force.
- 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.