@@ -219,13 +219,15 @@ def calculate_combined_spin(self):
219219 if len (self .reactants ) == 1 :
220220 reactant_combined_spin = {self .reactants [0 ].multiplicity }
221221 elif len (self .reactants ) == 2 :
222- reactant_combined_spin = set ([self .reactants [0 ].multiplicity + self .reactants [1 ].multiplicity - 1 , np .abs (self .reactants [0 ].multiplicity - self .reactants [1 ].multiplicity )+ 1 ])
222+ reactant_spin_string = "+" .join (sorted ([str (reactant .multiplicity ) for reactant in self .reactants ]))
223+ reactant_combined_spin = allowed_spin [reactant_spin_string ]
223224 else :
224225 return None
225226 if len (self .products ) == 1 :
226227 product_combined_spin = {self .products [0 ].multiplicity }
227228 elif len (self .products ) == 2 :
228- product_combined_spin = set ([self .products [0 ].multiplicity + self .products [1 ].multiplicity - 1 , np .abs (self .products [0 ].multiplicity - self .products [1 ].multiplicity )+ 1 ])
229+ product_spin_string = "+" .join (sorted ([str (product .multiplicity ) for product in self .products ]))
230+ product_combined_spin = allowed_spin [product_spin_string ]
229231 else :
230232 return None
231233 return reactant_combined_spin , product_combined_spin
@@ -1539,6 +1541,7 @@ def _generate_product_structures(self, reactant_structures, maps, forward, relab
15391541 # Apply the generated species constraints (if given)
15401542 for struct in product_structures :
15411543 if self .is_molecule_forbidden (struct ):
1544+ # logging.info(f"{str(struct)} is forbidden!")
15421545 raise ForbiddenStructureException ()
15431546 if fails_species_constraints (struct ):
15441547 raise ForbiddenStructureException ()
@@ -1592,8 +1595,8 @@ def _create_reaction(self, reactants, products, is_forward, check_spin = True):
15921595 reaction .labeled_atoms [key ] = dict (reaction .labeled_atoms [key ], ** species .get_all_labeled_atoms ())
15931596 if check_spin :
15941597 if not reaction .check_if_spin_allowed ():
1595- logging .warn ("Did not create the following reaction, which violates conservation of spin..." )
1596- logging .warn (str (reaction ))
1598+ logging .info ("Did not create the following reaction, which violates conservation of spin..." )
1599+ logging .info (str (reaction ))
15971600 return None
15981601 return reaction
15991602
@@ -1855,6 +1858,7 @@ def _generate_reactions(self, reactants, products=None, forward=True, prod_reson
18551858 reactant_num = self .product_num
18561859
18571860 if self .auto_generated and reactant_num != len (reactants ):
1861+ # logging.info("self.auto_generated and reactant_num != len(reactants)")
18581862 return []
18591863
18601864 if len (reactants ) > len (template .reactants ):
@@ -4534,4 +4538,18 @@ def average_kinetics(kinetics_list):
45344538 )
45354539 return averaged_kinetics
45364540
4537- allowed_spin_violation_families = ['1,2-Birad_to_alkene' ,'1,4_Cyclic_birad_scission' ,'1,4_Linear_birad_scission' ]
4541+ allowed_spin_violation_families = ['1,2-Birad_to_alkene' ,'1,4_Cyclic_birad_scission' ,'1,4_Linear_birad_scission' ]
4542+ allowed_spin = {
4543+ "1+1" : set ([1 ]),
4544+ "1+2" : set ([2 ]),
4545+ "1+3" : set ([3 ]),
4546+ "1+4" : set ([4 ]),
4547+ "1+5" : set ([5 ]),
4548+ "2+2" : set ([1 ,3 ]),
4549+ "2+3" : set ([2 ,4 ]),
4550+ "2+4" : set ([3 ,5 ]),
4551+ "2+5" : set ([4 ,6 ]),
4552+ "3+3" : set ([1 ,3 ,5 ]),
4553+ "3+4" : set ([2 ,4 ,6 ]),
4554+ "3+5" : set ([3 ,5 ,7 ]),
4555+ }
0 commit comments