relentless.model.potential.OPLSDihedral#

class relentless.model.potential.OPLSDihedral(types, name=None)#

OPLS dihedral potential.

\[u(\phi) = \frac{1}{2} \left( k_1 (1+\cos \phi) + k_2 (1+\cos 2\phi) + k_3 (1+ \cos 3\phi) + k_4 (1+ \cos 4\phi) \right)\]

where \(\phi\) is the dihedral between four bonded particles. The potential is described in Watkins and Jorgensen. The parameters for each type are:

Parameter

Description

k_1

First fitting coefficient \(k_1\).

k_2

Second fitting coefficient \(k_2\).

k_3

Third fitting coefficient \(k_3\).

k_4

Fourth fitting coefficient \(k_4\).

Parameters:
  • types (tuple[str]) – Types.

  • name (str) – Unique name of the potential. Defaults to __u[id], where id is the unique integer ID of the potential.

coeff#

Parameters of the potential for each type.

Type:

DihedralParameters

Examples

OPLS dihedral for the CT-CT-CT-CT dihedral (Watkins and Jorgensen).

>>> u = relentless.potential.dihedral.OPLSDihedral(("A",))
>>> u.coeff["A"].update({'k1': 1.740, 'k2': -0.157, 'k3': 0.279, 'k4': 0.00})

Methods

derivative(type_, var, phi)

Evaluate derivative with respect to a variable.

energy(type_, phi)

Evaluate dihedral energy.

force(type_, phi)

Evaluate dihedral 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

count

names

derivative(type_, var, phi)#

Evaluate derivative with respect to a variable.

The derivative is evaluated using the _derivative() function for all \(u_{0,\lambda}(phi)\).

The derivative will be carried out with respect to var for all Variable parameters. The appropriate chain rules are handled automatically. If the potential does not depend on var, the derivative will be zero by definition.

Parameters:
  • _type (tuple[str]) – The type for which to calculate the derivative.

  • var (Variable) – The variable with respect to which the derivative is calculated.

  • phi (float or list) – The dihedral angles(s) at which to evaluate the derivative.

Returns:

The dihedral derivative evaluated at phi. The return type is consistent with phi.

Return type:

float or numpy.ndarray

Raises:
  • ValueError – If any value in phi is not between -pi and pi.

  • TypeError – If the parameter with respect to which to take the derivative is not a Variable.

energy(type_, phi)#

Evaluate dihedral energy.

force(type_, phi)#

Evaluate dihedral 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, name overrides the value in the file. If True, the name in the file is always preserved. If False, the name in the file is always ignored, and a default name is created. If None, 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, name overrides the value in the JSON data. If True, the name in the JSON data is always preserved. If False, the name in the JSON data is always ignored, and a default name is created. If None, 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.

save(filename)#

Save the potential to file as JSON data.

Parameters:

filename (str) – The name of the file to which to save the data.

to_json()#

Export potential to a JSON-compatible dictionary.

The JSON dictionary will contain the id and name of the potential, along with the JSON representation of its coefficients.

Returns:

Potential.

Return type:

dict