1
from nbody_graph_search import Ugraph
3
# This file defines how improper interactions are generated in class2 files.
4
# To use it, add "(class2_dih.py)" to the name of the "Data Dihedrals By Type"
5
# section, and make sure this file is located in the "common" directory.
7
# write_once("Data Dihedrals By Type (class2_dih.py)") {
11
# To find 4-body "dihedral" interactions, we would use this subgraph:
13
# 1st bond connects atoms 0 and 1
14
# *---*---*---* => 2nd bond connects atoms 1 and 2
15
# 0 1 2 3 3rd bond connects atoms 2 and 3
18
bond_pattern = Ugraph([(0,1), (1,2), (2,3)])
19
# (Ugraph atom indices begin at 0, not 1)
22
def canonical_order(match):
24
When searching for atoms with matching bond patterns GraphMatcher
25
often returns redundant results. We must define a "canonical_order"
26
function which sorts the atoms and bonds in a way which is consistent
27
with the type of N-body interaction being considered.
28
However, some dihedral_styles (such as dihedral_style class2)
29
have no symmetry (at least not for arbitrary choices of parameters).
30
These force-field styles, the different permulations of atom-order
31
are not equivalent. So we do not want to rearrange the order of
32
the atoms (and bonds) in the match, because the formula for the
33
interaction between atoms 1,2,3,4 is not the same as the formula
34
for the interaction between atoms 4,3,2,1.
35
In this case, this function returns
36
the original "match" argument unmodified.