~ubuntu-branches/debian/sid/lammps/sid

« back to all changes in this revision

Viewing changes to tools/moltemplate/src/nbody_alternate_symmetry/class2_dih.py

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-04-29 23:44:49 UTC
  • mfrom: (5.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20150429234449-mbhy9utku6hp6oq8
Tags: 0~20150313.gitfa668e1-1
Upload into unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from nbody_graph_search import Ugraph
 
2
 
 
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.
 
6
# For example:
 
7
# write_once("Data Dihedrals By Type (class2_dih.py)") {
 
8
#   ...
 
9
# }
 
10
 
 
11
#    To find 4-body "dihedral" interactions, we would use this subgraph:
 
12
#
 
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
 
16
#                               
 
17
 
 
18
bond_pattern = Ugraph([(0,1), (1,2), (2,3)])
 
19
# (Ugraph atom indices begin at 0, not 1)
 
20
 
 
21
 
 
22
def canonical_order(match):
 
23
    """
 
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.
 
37
 
 
38
    """
 
39
 
 
40
    return match