Skip to content

Commit adf0c9b

Browse files
committed
numeric rotation working
1 parent 0171c73 commit adf0c9b

File tree

8 files changed

+529
-899
lines changed

8 files changed

+529
-899
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ test
22
stats
33
validation
44
*.pyc
5+
*.zip

atomorder/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
21
from .definitions import Constants, Settings
32
settings = Settings()
43
constants = Constants()
54

65
from .structure import Reaction
7-
from .utils import parse_args
8-
6+
from .ordering import Ordering

atomorder/definitions.py

+81-10
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def __init__(self):
7575
# didn't have many S-H hits, so guesstimate them
7676
self.bond_length_limits[("H","S")] = (1.2,1.3,1.4,1.5)
7777

78-
# make inverse atom order
79-
for key, value in self.bond_length_limits.items():
80-
self.bond_length_limits[key[::-1]] = value
78+
## make inverse atom order
79+
#for key, value in self.bond_length_limits.items():
80+
# self.bond_length_limits[key[::-1]] = value
8181

8282
# Number of bonds each atom type commonly form
8383
# Doubles as list of atom types implemented
@@ -89,17 +89,54 @@ def __init__(self):
8989
"H" : np.asarray( [1] , dtype=int) ,
9090
"I" : np.asarray( [1] , dtype=int) ,
9191
"N" : np.asarray( [1,2,3,4], dtype=int) ,
92-
"O" : np.asarray( [1,2,3] , dtype=int) ,
92+
"O" : np.asarray( [1,2,3] , dtype=int) ,
9393
"P" : np.asarray( [3] , dtype=int) ,
9494
"S" : np.asarray( [1,2,3,4], dtype=int)
9595
}
96-
# charge states
97-
se
98-
9996
# monovalent atoms
10097
self.monovalent = ["Br","Cl","F","H","D","I"]
10198

102-
class Settings(object):
99+
# Properties of different sybyl atom types for bonding
100+
# This is for very internal use. Basically the properties are
101+
# {num_bonds: (no. pi electrons, participating lone pairs, base charge)}
102+
# (num_bonds + no_pi - charge) should equal the valency
103+
# monovalent atoms is {1: (0,0,0)}
104+
# TODO find a molecule with S.2 so I can understand how it works
105+
self.sybyl_bonds = {
106+
"C.3" : {4: (0,0,0)},
107+
"C.2" : {3: (1,0,0)},
108+
"C.1" : {2: (2,0,0)},
109+
"O.co2": {1: (1,1,0)},
110+
"O.3" : {2: (0,0,0), 3: (0,0,+1)},
111+
"O.2" : {1: (1,1,0)},
112+
"N.4" : {4: (0,0,+1)},
113+
"N.3" : {3: (0,0,0)},
114+
"N.2" : {2: (1,0,0)},
115+
"N.am" : {3: (1,1,+1)},
116+
"N.pl3": {3: (1,1,+1)},
117+
"N.1" : {1: (2,0,0), 2: (2,0,+1)},
118+
"S.o" : {3: (0,0,+1)},
119+
"S.o2" : {4: (2,0,0)},
120+
"S.3" : {2: (0,0,0)},
121+
"Br" : {1: (0,0,0)},
122+
"Cl" : {1: (0,0,0)},
123+
"F" : {1: (0,0,0)},
124+
"I" : {1: (0,0,0)},
125+
"H" : {1: (0,0,0)},
126+
}
127+
128+
def get_bond_length_limits(self, element1, element2):
129+
if element1 > element2:
130+
element1, element2 = element2, element1
131+
132+
if (element1, element2) in self.bond_length_limits:
133+
return self.bond_length_limits[(element1, element2)]
134+
135+
# Return limits such that no bonds are formed
136+
# if the elements are not in self.bond_length_limits
137+
return (0,0,0,0)
138+
139+
class Settings(object):
103140
"""
104141
Settings()
105142
@@ -120,7 +157,10 @@ def __init__(self):
120157
self.product_filenames = [None]
121158
self.print_level = 1
122159
self.file_format = None
123-
self.simple_rotate = False
160+
self.method = None
161+
self.create_atoms = False
162+
self.rotation_objective = False
163+
self.bond_objective = False
124164

125165
def update(self, args):
126166
"""
@@ -132,4 +172,35 @@ def update(self, args):
132172
self.product_filenames = args.products
133173
self.print_level = args.print_level
134174
self.file_format = args.format
135-
self.simple_rotate = args.simple_rotate
175+
self.method = args.method
176+
177+
# Sets flags needed to define the pipeline of the method
178+
self.construct_pipeline()
179+
180+
def construct_pipeline(self):
181+
"""
182+
Sets flags needed to define the pipeline of the method
183+
184+
"""
185+
186+
if self.method == "rotate":
187+
self.create_atoms = False
188+
self.rotation_objective = True
189+
self.bond_objective = False
190+
191+
elif self.method == "full":
192+
self.create_atoms = True
193+
self.rotation_objective = True
194+
self.bond_objective = True
195+
196+
elif self.method == "info":
197+
self.create_atoms = True
198+
self.rotation_objective = False
199+
self.bond_objective = False
200+
201+
# sanity check override
202+
if self.bond_objective == True:
203+
self.create_atoms = True
204+
205+
206+
# TODO add parameters in ordering algorithm

0 commit comments

Comments
 (0)