Skip to content

Commit 4ec80a2

Browse files
authored
Merge pull request #2 from m-bone/PathSearchMethod
Path search method
2 parents c10281a + e6e6798 commit 4ec80a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+32765
-1239
lines changed

AtomMapping.py

Lines changed: 0 additions & 120 deletions
This file was deleted.

AutoMapper.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/usr/bin/env python3
2+
##############################################################################
3+
# Developed by: Matthew Bone
4+
# Last Updated: 16/06/2021
5+
# Updated by: Matthew Bone
6+
#
7+
# Contact Details:
8+
# Bristol Composites Institute (BCI)
9+
# Department of Aerospace Engineering - University of Bristol
10+
# Queen's Building - University Walk
11+
# Bristol, BS8 1TR
12+
# U.K.
13+
# Email - matthew.bone@bristol.ac.uk
14+
#
15+
# File Description:
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.
19+
##############################################################################
20+
21+
import argparse
22+
from LammpsUnifiedCleaner import file_unifier
23+
from LammpsToMolecule import lammps_to_molecule
24+
from LammpsToMoleculePartial import lammps_to_molecule_partial
25+
from LammpsToLammpsPartial import lammps_to_lammps_partial
26+
from PathSearch import map_from_path
27+
28+
# Init the parser
29+
parser = argparse.ArgumentParser(description='Run preprocessing tools for LAMMPS simulation using fix bond/react')
30+
31+
# List of arguments for command line
32+
parser.add_argument('directory', metavar='directory', type=str, nargs=1, help='Directory of file(s), can be found in bash with . or $PWD')
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')
35+
parser.add_argument('--coeff_file', metavar='coeff_file', nargs=1, help='Argument for the "clean" tool: a coefficients file to be cleaned')
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')
41+
42+
# Get arguments from parser
43+
args = parser.parse_args()
44+
# Take compulsory args out of list - other args done later
45+
tool = args.tool[0]
46+
directory = args.directory[0]
47+
48+
49+
# Throw errors if arguments are missing from certain tools
50+
if tool == 'clean' and (args.coeff_file is None):
51+
parser.error('"clean" tool requries --coeff_file')
52+
53+
if tool == 'molecule' and (args.save_name is None or args.ba is None):
54+
parser.error('"molecule" tool requries --save_name and --ba (bonding atoms) arguments')
55+
56+
if 'partial' in tool and (args.save_name is None or args.ba is None or args.ebt is None):
57+
parser.error('"molecule-partial" or "lammps-partial" tools require --save_name, --ba (bonding atoms) and --ebt (elements by type) arguments')
58+
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')
61+
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')
64+
65+
# Unified data file clean
66+
if tool == "clean":
67+
print(f'DataFiles List: {args.data_files}')
68+
file_unifier(directory, args.coeff_file[0], args.data_files)
69+
70+
# Produce molecule data file
71+
elif tool == "molecule":
72+
lammps_to_molecule(directory, args.data_files[0], args.save_name[0], args.ba, args.da)
73+
74+
# Produce partial molecule data file
75+
elif tool == "molecule-partial":
76+
lammps_to_molecule_partial(directory, args.data_files[0], args.save_name[0], args.ebt, args.ba, args.da)
77+
78+
# Produce partial lammps data file
79+
elif tool == "lammps-partial":
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)

0 commit comments

Comments
 (0)