diff --git a/documentation/source/users/rmg/input.rst b/documentation/source/users/rmg/input.rst index e9198d568d4..79049b909c3 100644 --- a/documentation/source/users/rmg/input.rst +++ b/documentation/source/users/rmg/input.rst @@ -1021,7 +1021,7 @@ all of RMG's reaction families. :: maximumRadicalElectrons=2, maximumSingletCarbenes=1, maximumCarbeneRadicals=0, - maximumIsotopicAtoms=2, + maximumFusedRings=3, allowSingletO2 = False, speciesCuttingThreshold=20, ) @@ -1031,6 +1031,8 @@ from either the input file, seed mechanisms, or reaction libraries to bypass the Note that this should be done with caution, since the constraints will still apply to subsequent products that form. +``maximumFusedRings`` is the maximum number of rings in any fused ring system in the species. + By default, the ``allowSingletO2`` flag is set to ``False``. See :ref:`representing_oxygen` for more information. Note that ``speciesCuttingThreshold`` is set by default to 20 heavy atoms. This means that if a species containing diff --git a/documentation/source/users/rmg/modules/isotopes.rst b/documentation/source/users/rmg/modules/isotopes.rst index fda03e0fc9f..e567a1fc6d4 100644 --- a/documentation/source/users/rmg/modules/isotopes.rst +++ b/documentation/source/users/rmg/modules/isotopes.rst @@ -49,10 +49,6 @@ not match the same depository reactions, leading to inconsistent kinetics. If degeneracy errors arise when generating reactions from scratch, try using this option to see if it reduces errors in degeneracy. -The arguement ``--maximumIsotopicAtoms [integer]`` limits the number of enriched -atoms in any isotopologue in the model. This is beneficial for decreasing model -size, runtime of model creation and runtime necessary for analysis. - Adding kinetic isotope effects which are described in this paper can be obtained through the argument ``--kineticIsotopeEffect simple``. Currently this is the only supported method, though this can be extended to other effects. diff --git a/examples/rmg/MR_test/input.py b/examples/rmg/MR_test/input.py index 39f9e4d0fcf..1079a64d81c 100644 --- a/examples/rmg/MR_test/input.py +++ b/examples/rmg/MR_test/input.py @@ -305,7 +305,5 @@ #If this is false or missing, RMG will throw an error if the more less-stable form of O2 is entered #which doesn't react in the RMG system. normally input O2 as triplet with SMILES [O][O] #allowSingletO2=False, - # maximum allowed number of non-normal isotope atoms: - #maximumIsotopicAtoms=2, ) diff --git a/examples/rmg/commented/input.py b/examples/rmg/commented/input.py index 0d6c78b5fea..3eb24f5e37e 100644 --- a/examples/rmg/commented/input.py +++ b/examples/rmg/commented/input.py @@ -287,8 +287,6 @@ # If this is false or missing, RMG will throw an error if the more less-stable form of O2 is entered # which doesn't react in the RMG system. normally input O2 as triplet with SMILES [O][O] # allowSingletO2=False, - # maximum allowed number of non-normal isotope atoms: - # maximumIsotopicAtoms=2, ) # optional block allows thermo to be estimated through quantum calculations diff --git a/rmgpy/constraints.py b/rmgpy/constraints.py index d00d1ca43bf..2f2aa56c5ea 100644 --- a/rmgpy/constraints.py +++ b/rmgpy/constraints.py @@ -31,6 +31,7 @@ from rmgpy.species import Species + def pass_cutting_threshold(species): """ Pass in either a `Species` or `Molecule` object and checks whether it passes @@ -58,6 +59,7 @@ def pass_cutting_threshold(species): return False + def fails_species_constraints(species): """ Pass in either a `Species` or `Molecule` object and checks whether it passes @@ -139,4 +141,9 @@ def fails_species_constraints(species): if struct.get_singlet_carbene_count() > 0 and struct.get_radical_count() > max_carbene_radicals: return True + max_fused_rings = species_constraints.get('maximumFusedRings', -1) + if max_fused_rings != -1 and struct.is_cyclic(): + if struct.get_ring_count_in_largest_fused_ring_system() > max_fused_rings: + return True + return False diff --git a/rmgpy/molecule/molecule.py b/rmgpy/molecule/molecule.py index 1a32f07adde..475a23c0802 100644 --- a/rmgpy/molecule/molecule.py +++ b/rmgpy/molecule/molecule.py @@ -3002,6 +3002,35 @@ def get_desorbed_molecules(self): return desorbed_molecules + def get_ring_count_in_largest_fused_ring_system(self) -> int: + """ + Get the number of rings in the largest fused ring system in the molecule. + """ + cython.declare(polycycles=list, sssr=list, sssr_sets=list, ring_counts=list) + cython.declare(polycycle=list, ring=list) + + polycycles = self.get_polycycles() + if not polycycles: + return 0 + + sssr = self.get_smallest_set_of_smallest_rings() + if not sssr: + return 0 + + sssr_sets = [set(r) for r in sssr] + + ring_counts = list() + for polycycle in polycycles: + poly_set = set(polycycle) + ring_count = 0 + for ring_set in sssr_sets: + if ring_set.issubset(poly_set): + ring_count += 1 + ring_counts.append(ring_count) + + return max(ring_counts) if ring_counts else 0 + + # this variable is used to name atom IDs so that there are as few conflicts by # using the entire space of integer objects atom_id_counter = -2 ** 15 diff --git a/rmgpy/rmg/input.py b/rmgpy/rmg/input.py index 8c34e815d45..c818b22e2c2 100644 --- a/rmgpy/rmg/input.py +++ b/rmgpy/rmg/input.py @@ -1415,6 +1415,7 @@ def generated_species_constraints(**kwargs): 'maximumRadicalElectrons', 'maximumSingletCarbenes', 'maximumCarbeneRadicals', + 'maximumFusedRings', 'allowSingletO2', 'speciesCuttingThreshold', ] diff --git a/scripts/rmg2to3.py b/scripts/rmg2to3.py index a2e9a3db005..211dbfdfac7 100644 --- a/scripts/rmg2to3.py +++ b/scripts/rmg2to3.py @@ -1796,7 +1796,6 @@ # rmgpy.tools.isotopes 'useOriginalReactions': 'use_original_reactions', 'kineticIsotopeEffect': 'kinetic_isotope_effect', - 'maximumIsotopicAtoms': 'maximum_isotopic_atoms', # rmgpy.tools.loader 'generateImages': 'generate_images', 'useJava': 'use_java', diff --git a/test/rmgpy/molecule/moleculeTest.py b/test/rmgpy/molecule/moleculeTest.py index 9621d6fc7d4..7d6622665e0 100644 --- a/test/rmgpy/molecule/moleculeTest.py +++ b/test/rmgpy/molecule/moleculeTest.py @@ -3043,3 +3043,14 @@ def test_remove_van_der_waals_bonds(self): assert len(mol.get_all_edges()) == 2 mol.remove_van_der_waals_bonds() assert len(mol.get_all_edges()) == 1 + + def test_get_ring_count_in_largest_fused_ring_system(self): + """Test that we can count the rings in the largest fused ring system.""" + mol = Molecule(smiles="CCCC") + assert mol.get_ring_count_in_largest_fused_ring_system() == 0 + mol = Molecule(smiles="c1ccccc1") + assert mol.get_ring_count_in_largest_fused_ring_system() == 0 + mol = Molecule(smiles="c12ccccc1cccc2") + assert mol.get_ring_count_in_largest_fused_ring_system() == 2 + mol = Molecule(smiles="C[C]1C2C(=O)C3CC4C(=O)C=C2CC143") + assert mol.get_ring_count_in_largest_fused_ring_system() == 4