mstk.forcefield.PeriodicDihedralTerm¶
- class mstk.forcefield.PeriodicDihedralTerm(type1, type2, type3, type4)¶
Dihedral term in periodic cosine function form
The energy function is
>>> U = \sum^n k_n*(1+cos(n*phi-phi0_n))
During the initialization, the sequence of atom types to use i-j-k-l or l-k-j-i will be determined by their string order.
DihedralTerm allows wildcard(*) for side atoms. For sorting purpose, the wildcard will always be the last. During force field matching, the terms with wildcard will have lower priority. The terms with wildcard will be used only if exact match cannot be found.
PeriodicTermDihedral is initialized without parameters. The parameters should be added by calling
add_parameter().Examples
>>> term = PeriodicDihedralTerm('h_1', 'c_4', 'c_4', 'h_1') >>> term.add_parameter(0.0, 0.6485, 1) >>> term.add_parameter(3.14, 1.0678, 2) >>> term.add_parameter(0.0, 0.6226, 3) >>> for para in term.parameters: >>> print(para.phi, para.k, para.n) 0.0 0.6485 1 3.14 1.0678 2 0.0 0.6226 3 >>> term = term.to_opls_term() >>> print((term.k1, term.k2, term.k3, term.k4)) (0.6485 1.0678 0.6226 0.0)
- Parameters:
type1 (str) –
type2 (str) –
type3 (str) –
type4 (str) –
- type1¶
- Type:
str
- type2¶
- Type:
str
- type3¶
- Type:
str
- type4¶
- Type:
str
- parameters¶
Each element is a namedtuple
Parameterdescribing the parameter for each multiplicity.- Type:
list of namedtuple
Methods
__init__(type1, type2, type3, type4)add_parameter(phi, k, n)Add parameters for a multiplicity to this dihedral term.
evaluate_energy(val)Evaluate the energy for a force field term like HarmonicBondTerm, PeriodicDihedralTerm, etc...
get_alias()Return a short alias for the name of this class
Get the equivalent OplsDihedralTerm.
to_zff()Pack the attributes of a term into a string so that can be saved into a line in ZFF file.
to_zff_header()Header string to explain a line in ZFF format
to_zfp()Pack the attributes of a term into a dict so that can be saved into ZFP xml file.
Attributes
Whether or not this dihedral terms always give zero energy.
nameThe name of this force field term.
- class Parameter(phi, k, n)¶
- add_parameter(phi, k, n)¶
Add parameters for a multiplicity to this dihedral term.
Multiplicity must be a positive integer. Otherwise, an Exception will be raised. If there already exists parameter for this multiplicity, an Exception will be raised.
- Parameters:
phi (float) – Phase shift for this multiplicity, in unit of radian
k (float) – Force constant
n (int) – Multiplicity
- to_zff()¶
Pack the attributes of a term into a string so that can be saved into a line in ZFF file.
Every class to be packed should have a class property zfp_attrs. This dict records which attributes should be saved into ZFP xml file, and it is also used as the arguments for initializing a FFTerm. It also tell the data type of these attributes.
- Returns:
line
- Return type:
string
- evaluate_energy(val)¶
Evaluate the energy for a force field term like HarmonicBondTerm, PeriodicDihedralTerm, etc…
It is mainly for debugging. It is not (and can not be) implemented for all terms.
- Parameters:
val (float) – The value of distance, angle, dihedral or improper.
- Returns:
energy
- Return type:
float
- property is_zero¶
Whether or not this dihedral terms always give zero energy.
For linear groups like alkyne and nitrile, dihedral terms are presented in topology. But the parameters for these terms usually equal to zero.
- Returns:
is
- Return type:
bool
- to_opls_term()¶
Get the equivalent OplsDihedralTerm.
In OPLS convention, the largest multiplicity equals to 4. The phi_0 for multiplicity (1, 2, 3, 4) equal to (0, PI, 0, PI), respectively. If it does not follow OPLS convention, an Exception will be raised.
- Returns:
term
- Return type: