1
from nbody_graph_search import Ugraph
3
# To find 4-body "improper" interactions,
4
# (by default, most of the time), we would use this subgraph:
6
# * 1st bond connects atoms 0 and 1
7
# | => 2nd bond connects atoms 0 and 2
8
# _.*._ 3rd bond connects atoms 0 and 3
13
bond_pattern = Ugraph([(0,1), (0,2), (0,3)])
14
# (Ugraph atom indices begin at 0, not 1)
17
def canonical_order(match):
19
When searching for atoms with matching bond patterns GraphMatcher
20
often returns redundant results. We must define a "canonical_order"
21
function which sorts the atoms and bonds in a way which is consistent
22
with the type of N-body interaction being considered.
23
However, some improper_styles (such as improper_style class2)
24
have no symmetry (at least not for arbitrary choices of parameters).
25
These force-field styles, the different permulations of atom-order
26
are not equivalent. So we do not want to rearrange the order of
27
the atoms (and bonds) in the match, because the resulting interaction
28
is not equivalent. In this case, this function returns
29
the original "match" argument unmodified.