Skip to content

Commit e6e6798

Browse files
author
Matt Bone
committed
Beta Release
General tidy up and minor changes to code Documentation improved Example workflow provided - to be changed later
1 parent 512612d commit e6e6798

17 files changed

+28773
-194
lines changed

AutoMapper.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22
##############################################################################
33
# Developed by: Matthew Bone
4-
# Last Updated: 09/04/2021
4+
# Last Updated: 16/06/2021
55
# Updated by: Matthew Bone
66
#
77
# Contact Details:
@@ -13,28 +13,31 @@
1313
# Email - matthew.bone@bristol.ac.uk
1414
#
1515
# File Description:
16-
# This script is designed to be run from run_bond_react.sh, allowing the user
17-
# to call Bond_React python code from wherever their data is stored
16+
# This wrapper is used to call all the AutoMapper family of tools from a command
17+
# line. Linux users can consider adding the location of this repo to their PATH
18+
# so that this wrapper can be called from anywhere.
1819
##############################################################################
1920

2021
import argparse
2122
from LammpsUnifiedCleaner import file_unifier
2223
from LammpsToMolecule import lammps_to_molecule
2324
from LammpsToMoleculePartial import lammps_to_molecule_partial
2425
from LammpsToLammpsPartial import lammps_to_lammps_partial
26+
from PathSearch import map_from_path
2527

2628
# Init the parser
2729
parser = argparse.ArgumentParser(description='Run preprocessing tools for LAMMPS simulation using fix bond/react')
2830

2931
# List of arguments for command line
3032
parser.add_argument('directory', metavar='directory', type=str, nargs=1, help='Directory of file(s), can be found in bash with . or $PWD')
31-
parser.add_argument('tool', metavar='tool', type=str, nargs=1, choices=['clean', 'molecule', 'molecule-partial', 'lammps-partial'], help='Name of tool to be used. Possible tools: clean, molecule, molecule-partial, lammps-partial')
32-
parser.add_argument('data_files', metavar='data_files', nargs='+', help='Name of file to be acted on. If tool is "clean" this can be a list of files')
33+
parser.add_argument('tool', metavar='tool', type=str, nargs=1, choices=['clean', 'molecule', 'molecule-partial', 'lammps-partial', 'map'], help='Name of tool to be used. Possible tools: clean, molecule, molecule-partial, lammps-partial, map')
34+
parser.add_argument('data_files', metavar='data_files', nargs='+', help='Name of file(s) to be acted on. If tool is "map" then this must be two files ordered as pre-bond post-bond. If "clean" this can be a list of files in any order')
3335
parser.add_argument('--coeff_file', metavar='coeff_file', nargs=1, help='Argument for the "clean" tool: a coefficients file to be cleaned')
34-
parser.add_argument('--save_name', metavar='save_name', nargs=1, help='Argument for "molecule", "molecule-partial" and "lammps-partial" tools: sets the file name for the new file')
35-
parser.add_argument('--ba', metavar='bonding_atoms', nargs=2, help='Argument for "molecule", "molecule-partial" and "lammps-partial" tools: atom IDs of the atoms that will be involved in creating a new bond')
36-
parser.add_argument('--ebt', metavar='elements_by_type', nargs='+', help='Argument for "molecule-partial" and "lammps-partial" tools: list of elements symbols in the same order as the types specified in the data file')
37-
parser.add_argument('--da', metavar='delete_atoms', nargs='+', help='Argument for "molecule", "molecule-partial" and "lammps-partial" tools: atom IDs of the atoms that will be deleted after the bond has formed')
36+
parser.add_argument('--save_name', metavar='save_name', nargs=1, help='Argument for "molecule", "molecule-partial" and "lammps-partial" tools: a prefix that is added to "molecule.data" for the file name of the new file')
37+
parser.add_argument('--ba', metavar='bonding_atoms', nargs=2, help='Argument for "molecule", "molecule-partial" and "lammps-partial" tools: atom IDs of the atoms that will be involved in creating a new bond, separated by white space. Order of atoms must be the same between molecule files, when mapping.')
38+
parser.add_argument('--ebt', metavar='elements_by_type', nargs='+', help='Argument for "molecule-partial", "lammps-partial" and "map" tools: series of elements symbols in the same order as the types specified in the data file and separated with a whitespace')
39+
parser.add_argument('--da', metavar='delete_atoms', nargs='+', help='An optional argument for "molecule", "molecule-partial" and "lammps-partial" tools: atom IDs of the atoms that will be deleted after the bond has formed, separated by white space')
40+
parser.add_argument('--debug', action='store_true', help='Argument for "map": prints debugging statements highlighting which parts of the path search determine a mapped atom pair')
3841

3942
# Get arguments from parser
4043
args = parser.parse_args()
@@ -53,9 +56,11 @@
5356
if 'partial' in tool and (args.save_name is None or args.ba is None or args.ebt is None):
5457
parser.error('"molecule-partial" or "lammps-partial" tools require --save_name, --ba (bonding atoms) and --ebt (elements by type) arguments')
5558

56-
if tool != 'clean' and len(args.data_files) > 1:
57-
parser.error('Only the "clean" tool can take more than 1 data_file as input')
59+
if tool != 'clean' and tool != 'map' and len(args.data_files) > 1:
60+
parser.error('This tool can only take 1 data_file as input')
5861

62+
if tool == 'map' and (len(args.data_files) != 2 or args.ebt is None):
63+
parser.error('Map tool requires 2 data_files and --ebt (elements by type) arguments')
5964

6065
# Unified data file clean
6166
if tool == "clean":
@@ -72,4 +77,7 @@
7277

7378
# Produce partial lammps data file
7479
elif tool == "lammps-partial":
75-
lammps_to_lammps_partial(directory, args.data_files[0], args.save_name[0], args.ebt, args.ba, args.da)
80+
lammps_to_lammps_partial(directory, args.data_files[0], args.save_name[0], args.ebt, args.ba, args.da)
81+
82+
elif tool == 'map':
83+
map_from_path(directory, args.data_files[0], args.data_files[1], args.ebt, args.debug)

Example_Workflow/instructions.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is an example using the fictional reaction between phenol and an alkane with H2 given as a byproduct. I will likely replace this with a better example later, once I have a good intricate one that bonds quickly in LAMMPS.
2+
3+
Commands to generate an 'automap.data' file are as follows:
4+
5+
Clean the data files and system.in.settings
6+
AutoMapper.py . clean pre_reaction.data post_reaction.data --coeff_file system.in.settings
7+
8+
Create pre-bond partial molecule file
9+
AutoMapper.py . molecule-partial cleanedpre_reaction.data --save_name pre- --ba 13 14 --da 12 19 --ebt H H C C O O
10+
11+
Create post-bond partial molecule file
12+
AutoMapper.py . molecule-partial cleanedpost_reaction.data --save_name post- --ba 13 14 --da 23 24 --ebt H H C C O O
13+
14+
NOTE: for both these molecule files the bonding atom order represents the same atoms in each file i.e. the 13 is the reacting oxygen and 14 is the reacting carbon. The order of the atoms should always be the same.
15+
16+
Create the map
17+
AutoMapper.py . map pre-molecule.data post-molecule.data --ebt H H C C O O
18+
19+
NOTE: the order of files for the map should always be "pre-bond molecule post-bond molecule".
20+
21+
Run the LAMMPS code
22+
lmp -in run.bond
23+
24+
You should see the 0 turn to a 1 next to the step count in the thermo output.
Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
LAMMPS Description
2+
3+
24 atoms
4+
23 bonds
5+
37 angles
6+
47 dihedrals
7+
6 impropers
8+
9+
107 atom types
10+
1176 bond types
11+
30 angle types
12+
17576 dihedral types
13+
3 improper types
14+
15+
0.0 25.0 xlo xhi
16+
0.0 25.0 ylo yhi
17+
0.0 25.0 zlo zhi
18+
19+
Masses
20+
21+
1 1.008 # H
22+
2 1.008 # H_HB
23+
3 12.011 # C_3
24+
4 16.043 # C_34
25+
5 15.035 # C_33
26+
6 14.027 # C_32
27+
7 13.019 # C_31
28+
8 12.011 # C_R
29+
9 13.019 # C_R1
30+
10 12.011 # C_R_b1
31+
11 13.019 # C_R1_b1
32+
12 12.011 # C_2
33+
13 12.011 # C_2_b1
34+
14 12.011 # C_2_b2
35+
15 12.011 # C_1
36+
16 12.011 # C_1_b1
37+
17 14.007 # N_3
38+
18 14.007 # N_3_ha
39+
19 14.007 # N_3_hd
40+
20 14.007 # N_R_d1
41+
21 14.007 # N_R_d1_ha
42+
22 14.007 # N_R_d2
43+
23 14.007 # N_R_d2_ha
44+
24 14.007 # N_R_d2_hd
45+
25 14.007 # N_R_b1_d2
46+
26 14.007 # N_R_b1_d2_ha
47+
27 14.007 # N_R_b1_d2_hd
48+
28 14.007 # N_2_d1
49+
29 14.007 # N_2_d1_ha
50+
30 14.007 # N_2_d1_hd
51+
31 14.007 # N_2_b1_d1
52+
32 14.007 # N_2_b1_d1_ha
53+
33 14.007 # N_2_b2_d1
54+
34 14.007 # N_2_b2_d1_ha
55+
35 14.007 # N_2_d2
56+
36 14.007 # N_2_d2_hd
57+
37 14.007 # N_2_d2_ha
58+
38 14.007 # N_2_b1_d2
59+
39 14.007 # N_2_b1_d2_hd
60+
40 14.007 # N_2_b1_d2_ha
61+
41 14.007 # N_2_b2_d2
62+
42 14.007 # N_2_b2_d2_hd
63+
43 14.007 # N_2_b2_d2_ha
64+
44 14.007 # N_1
65+
45 14.007 # N_1_ha
66+
46 15.999 # O_3
67+
47 15.999 # O_3_hd
68+
48 15.999 # O_3_ha
69+
49 15.999 # O_R
70+
50 15.999 # O_R_ha
71+
51 15.999 # O_2
72+
52 15.999 # O_2_ha
73+
53 15.999 # O_2_b1
74+
54 15.999 # O_2_b1_ha
75+
55 15.999 # O_2_b1_hd
76+
56 15.999 # O_2_b2
77+
57 15.999 # O_2_b2_ha
78+
58 15.999 # O_1
79+
59 15.999 # O_1_ha
80+
60 1.008 # H_B
81+
61 10.81 # B_3
82+
62 10.81 # B_2_d1
83+
63 10.81 # B_2_d2
84+
64 10.81 # B_2_b1_d1
85+
65 10.81 # B_2_b1_d2
86+
66 10.81 # B_2_b2_d1
87+
67 10.81 # B_2_b2_d2
88+
68 18.998 # F
89+
69 18.998 # F_hd
90+
70 18.998 # F_ha
91+
71 34.45 # Cl
92+
72 79.904 # Br
93+
73 126.904 # I
94+
74 26.982 # Al_3_d1
95+
75 26.982 # Al_3_d2
96+
76 28.085 # Si_3
97+
77 30.974 # P_3_d2
98+
78 30.974 # P_3_d3
99+
79 30.974 # P_3_d4
100+
80 32.06 # S_3
101+
81 69.723 # Ga_3
102+
82 72.63 # Ge_3_d1
103+
83 72.63 # Ge_3_d2
104+
84 72.63 # Ge_3_d3
105+
85 74.922 # As_3_d1
106+
86 74.922 # As_3_d2
107+
87 74.922 # As_3_d3
108+
88 74.922 # As_3_d4
109+
89 78.971 # Se_3_d1
110+
90 78.971 # Se_3_d2
111+
91 78.971 # Se_3_d3
112+
92 78.971 # Se_3_d5
113+
93 114.818 # In_3_d1
114+
94 114.818 # In_3_d2
115+
95 118.71 # Sn_3_d2
116+
96 118.71 # Sn_3_d3
117+
97 121.76 # Sb_3_d2
118+
98 121.76 # Sb_3_d3
119+
99 121.76 # Sb_3_d4
120+
100 127.6 # Te_3_d1
121+
101 127.6 # Te_3_d2
122+
102 127.6 # Te_3_d3
123+
103 127.6 # Te_3_d5
124+
104 22.99 # Na
125+
105 40.078 # Ca
126+
106 55.845 # Fe
127+
107 65.38 # Zn
128+
129+
Atoms # full
130+
131+
1 1 8 -0.150000913665795 -1.425 1.2892 0.0093
132+
2 1 8 -0.0987392104548446 -1.8172 0.0601 0.538
133+
3 1 8 -0.106718815774047 -0.947 -1.0282 0.4922
134+
4 1 8 -0.1492602545952 0.7035 0.3368 -0.6245
135+
5 1 1 0.127681308976076 -2.107 2.1357 0.0374
136+
6 1 8 -0.099403261714571 0.3126 -0.8898 -0.0894
137+
7 1 1 0.0959590766509538 -2.8035 -0.0501 0.9812
138+
8 1 1 0.0949714275176672 -1.2536 -1.9874 0.9032
139+
9 1 8 0.277743536303305 -0.1617 1.4297 -0.5634
140+
10 1 1 0.12846091351979 1.6805 0.4394 -1.0888
141+
11 1 1 0.095054530411991 0.989 -1.74 -0.1313
142+
12 1 1 0.107257734625108 4.2822 4.0704 0.4987
143+
13 1 54 -0.522292319460014 0.2056 2.6397 -1.1106
144+
14 1 3 0.00343959458073527 0.9206 3.6243 -0.3271
145+
15 1 1 0.111547560499986 3.1667 5.2711 -0.171
146+
16 1 1 0.109076386725339 2.8698 4.583 1.4375
147+
17 1 3 -0.189978721320177 2.4065 3.2297 -0.2066
148+
18 1 1 0.115423781312847 0.8416 4.5835 -0.8458
149+
19 1 1 0.100009473752045 0.4599 3.7131 0.6613
150+
20 1 3 -0.348166206199218 3.2316 4.3615 0.4309
151+
21 1 1 0.121784504827182 2.5043 2.328 0.4018
152+
22 1 1 0.13530448688936 2.8065 3.0073 -1.1987
153+
23 1 1 0.0345443029060094 -1.8381 5.0252 -0.2185
154+
24 1 1 0.00630108368547296 -1.7203 5.7425 0.6071
155+
156+
Bonds
157+
158+
1 231 1 2
159+
2 211 1 5
160+
3 231 1 9
161+
4 231 2 3
162+
5 211 2 7
163+
6 231 3 6
164+
7 211 3 8
165+
8 231 4 6
166+
9 231 4 9
167+
10 211 4 10
168+
11 211 6 11
169+
12 549 9 13
170+
13 548 13 14
171+
14 210 14 17
172+
15 191 14 18
173+
16 191 14 19
174+
17 210 17 20
175+
18 191 17 21
176+
19 191 17 22
177+
20 191 12 20
178+
21 191 15 20
179+
22 191 16 20
180+
23 1 23 24
181+
182+
Angles
183+
184+
1 5 12 20 17
185+
2 5 15 20 17
186+
3 5 16 20 17
187+
4 5 17 14 18
188+
5 5 17 14 19
189+
6 5 14 17 21
190+
7 5 20 17 21
191+
8 5 14 17 22
192+
9 5 20 17 22
193+
10 5 12 20 15
194+
11 5 12 20 16
195+
12 5 15 20 16
196+
13 5 18 14 19
197+
14 5 21 17 22
198+
15 5 13 14 17
199+
16 5 13 14 18
200+
17 5 13 14 19
201+
18 5 14 17 20
202+
19 28 9 13 14
203+
20 30 1 2 3
204+
21 30 1 9 4
205+
22 30 2 1 9
206+
23 30 2 3 6
207+
24 30 3 6 4
208+
25 30 6 4 9
209+
26 30 1 2 7
210+
27 30 2 1 5
211+
28 30 2 3 8
212+
29 30 3 2 7
213+
30 30 3 6 11
214+
31 30 4 6 11
215+
32 30 6 3 8
216+
33 30 6 4 10
217+
34 30 5 1 9
218+
35 30 9 4 10
219+
36 30 1 9 13
220+
37 30 4 9 13
221+
222+
Dihedrals
223+
224+
1 996 12 20 17 14
225+
2 996 14 17 20 15
226+
3 996 14 17 20 16
227+
4 996 18 14 17 20
228+
5 996 19 14 17 20
229+
6 996 12 20 17 21
230+
7 996 12 20 17 22
231+
8 996 15 20 17 21
232+
9 996 15 20 17 22
233+
10 996 16 20 17 21
234+
11 996 16 20 17 22
235+
12 996 18 14 17 21
236+
13 996 18 14 17 22
237+
14 996 19 14 17 21
238+
15 996 19 14 17 22
239+
16 996 13 14 17 20
240+
17 996 13 14 17 21
241+
18 996 13 14 17 22
242+
19 1375 9 13 14 17
243+
20 1375 9 13 14 18
244+
21 1375 9 13 14 19
245+
22 1504 1 2 3 6
246+
23 1504 1 9 4 6
247+
24 1504 2 1 9 4
248+
25 1504 2 3 6 4
249+
26 1504 3 2 1 9
250+
27 1504 3 6 4 9
251+
28 1504 1 2 3 8
252+
29 1504 1 9 4 10
253+
30 1504 2 3 6 11
254+
31 1504 3 2 1 5
255+
32 1504 3 6 4 10
256+
33 1504 4 6 3 8
257+
34 1504 4 9 1 5
258+
35 1504 6 3 2 7
259+
36 1504 7 2 1 9
260+
37 1504 9 4 6 11
261+
38 1504 2 1 9 13
262+
39 1504 6 4 9 13
263+
40 1504 5 1 2 7
264+
41 1504 7 2 3 8
265+
42 1504 8 3 6 11
266+
43 1504 10 4 6 11
267+
44 1504 5 1 9 13
268+
45 1504 10 4 9 13
269+
46 1671 1 9 13 14
270+
47 1671 4 9 13 14
271+
272+
Impropers
273+
274+
1 2 1 2 5 9
275+
2 2 2 1 3 7
276+
3 2 3 2 6 8
277+
4 2 4 6 9 10
278+
5 2 6 3 4 11
279+
6 2 9 1 4 13
280+

0 commit comments

Comments
 (0)