diff --git a/examples/rmg/MR_test/input.py b/examples/rmg/MR_test/input.py index 39f9e4d0fcf..6cbb04a2eb3 100644 --- a/examples/rmg/MR_test/input.py +++ b/examples/rmg/MR_test/input.py @@ -275,8 +275,8 @@ minimumNumberOfGrains=250, #the conditions for the rate to be output over #parameter order is: low_value, high_value, units, internal points - temperatures=(300,2200,'K',2), - pressures=(0.01,100.01,'bar',3), + temperatures=(300,2200,'K',10), + pressures=(0.01,100.01,'bar',10), #The two options for interpolation are 'PDepArrhenius' (no extra arguments) and #'Chebyshev' which is followed by the number of basis sets in #Temperature and Pressure. These values must be less than the number of diff --git a/examples/rmg/TEOS/input.py b/examples/rmg/TEOS/input.py index 75b6a114085..86b3dcb77e8 100644 --- a/examples/rmg/TEOS/input.py +++ b/examples/rmg/TEOS/input.py @@ -4,7 +4,7 @@ reactionLibraries = [], seedMechanisms = [], kineticsDepositories = ['training'], - kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O'], + kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O', '!surface'], kineticsEstimator = 'rate rules', ) diff --git a/examples/rmg/catalysis/methane_steam/input.py b/examples/rmg/catalysis/methane_steam/input.py index 22c4e098502..5eb8078b7d4 100644 --- a/examples/rmg/catalysis/methane_steam/input.py +++ b/examples/rmg/catalysis/methane_steam/input.py @@ -1,7 +1,7 @@ # Data sources database( thermoLibraries=['surfaceThermoNi111', 'surfaceThermoPt111', 'primaryThermoLibrary', 'thermo_DFT_CCSDTF12_BAC'], - reactionLibraries = [('Surface/Deutschmann_Ni', True)], # when Pt is used change the library to Surface/CPOX_Pt/Deutschmann2006 + reactionLibraries = [('Surface/Methane/Deutschmann_Ni', True)], # when Pt is used change the library to Surface/CPOX_Pt/Deutschmann2006 seedMechanisms = [], kineticsDepositories = ['training'], kineticsFamilies = ['surface','default'], diff --git a/examples/rmg/commented/input.py b/examples/rmg/commented/input.py index 0d6c78b5fea..e0044906c64 100644 --- a/examples/rmg/commented/input.py +++ b/examples/rmg/commented/input.py @@ -250,8 +250,8 @@ minimumNumberOfGrains=250, # the conditions for the rate to be output over # parameter order is: low_value, high_value, units, internal points - temperatures=(300, 2200, 'K', 2), - pressures=(0.01, 100, 'bar', 3), + temperatures=(300, 2200, 'K', 10), + pressures=(0.01, 100, 'bar', 10), # The two options for interpolation are 'PDepArrhenius' (no extra arguments) and # 'Chebyshev' which is followed by the number of basis sets in # Temperature and Pressure. These values must be less than the number of diff --git a/examples/rmg/e85/input.py b/examples/rmg/e85/input.py index 6dcf96aa433..66529b9280c 100644 --- a/examples/rmg/e85/input.py +++ b/examples/rmg/e85/input.py @@ -4,7 +4,7 @@ reactionLibraries = [], seedMechanisms = ['GRI-Mech3.0'], kineticsDepositories = ['training'], - kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O'], + kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O', '!surface'], kineticsEstimator = 'rate rules', ) diff --git a/examples/rmg/gri_mech_rxn_lib/input.py b/examples/rmg/gri_mech_rxn_lib/input.py index a4749408099..033663936d6 100644 --- a/examples/rmg/gri_mech_rxn_lib/input.py +++ b/examples/rmg/gri_mech_rxn_lib/input.py @@ -40,6 +40,10 @@ maximumEdgeSpecies=100000 ) +generatedSpeciesConstraints( + maximumCarbeneRadicals=2, +) + options( units='si', generateOutputHTML=False, diff --git a/examples/rmg/methylformate/input.py b/examples/rmg/methylformate/input.py index 783e04130e8..6cc01c85b1c 100644 --- a/examples/rmg/methylformate/input.py +++ b/examples/rmg/methylformate/input.py @@ -4,7 +4,7 @@ reactionLibraries = [('Methylformate',False),('Glarborg/highP',False)], seedMechanisms = ['Glarborg/C2'], kineticsDepositories = ['training'], - kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O'], + kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O', '!surface'], kineticsEstimator = 'rate rules', ) diff --git a/examples/rmg/minimal_sensitivity/input.py b/examples/rmg/minimal_sensitivity/input.py index c9358cadcd7..85eb1cdf73e 100644 --- a/examples/rmg/minimal_sensitivity/input.py +++ b/examples/rmg/minimal_sensitivity/input.py @@ -4,7 +4,7 @@ reactionLibraries = [], seedMechanisms = [], kineticsDepositories = ['training'], - kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O'], + kineticsFamilies = ['!Intra_Disproportionation','!Substitution_O', '!surface'], kineticsEstimator = 'rate rules', ) diff --git a/examples/rmg/nox_transitory_edge/input.py b/examples/rmg/nox_transitory_edge/input.py index a130c79fd06..569f116699c 100644 --- a/examples/rmg/nox_transitory_edge/input.py +++ b/examples/rmg/nox_transitory_edge/input.py @@ -12,10 +12,12 @@ reactive=True, structure=SMILES("CC"), ) + species( label='O2', structure=SMILES("[O][O]"), ) + species( label='N2', reactive=False, @@ -76,6 +78,7 @@ generatedSpeciesConstraints( allowed=['input species','seed mechanisms','reaction libraries'], + allowSingletO2=True, #maximumCarbonAtoms=5, #maximumOxygenAtoms=8, #maximumNitrogenAtoms=0, diff --git a/rmgpy/constraints.py b/rmgpy/constraints.py index d00d1ca43bf..e88af0e3c02 100644 --- a/rmgpy/constraints.py +++ b/rmgpy/constraints.py @@ -61,7 +61,8 @@ def pass_cutting_threshold(species): def fails_species_constraints(species): """ Pass in either a `Species` or `Molecule` object and checks whether it passes - the speciesConstraints set by the user. If not, returns `True` for failing speciesConstraints. + the speciesConstraints set by the user. If the species fails constraints, returns + a string `reason` describing which constraint failed. If all constraints pass, returns `False`. """ from rmgpy.rmg.input import get_input @@ -86,57 +87,58 @@ def fails_species_constraints(species): max_carbon_atoms = species_constraints.get('maximumCarbonAtoms', -1) if max_carbon_atoms != -1: if struct.get_num_atoms('C') > max_carbon_atoms: - return True + return f"Exceeded maximumCarbonAtoms: {struct.get_num_atoms('C')} > {max_carbon_atoms}" max_oxygen_atoms = species_constraints.get('maximumOxygenAtoms', -1) if max_oxygen_atoms != -1: if struct.get_num_atoms('O') > max_oxygen_atoms: - return True + return f"Exceeded maximumOxygenAtoms: {struct.get_num_atoms('O')} > {max_oxygen_atoms}" max_nitrogen_atoms = species_constraints.get('maximumNitrogenAtoms', -1) if max_nitrogen_atoms != -1: if struct.get_num_atoms('N') > max_nitrogen_atoms: - return True + return f"Exceeded maximumNitrogenAtoms: {struct.get_num_atoms('N')} > {max_nitrogen_atoms}" max_silicon_atoms = species_constraints.get('maximumSiliconAtoms', -1) if max_silicon_atoms != -1: if struct.get_num_atoms('Si') > max_silicon_atoms: - return True + return f"Exceeded maximumSiliconAtoms: {struct.get_num_atoms('Si')} > {max_silicon_atoms}" max_sulfur_atoms = species_constraints.get('maximumSulfurAtoms', -1) if max_sulfur_atoms != -1: if struct.get_num_atoms('S') > max_sulfur_atoms: - return True + return f"Exceeded maximumSulfurAtoms: {struct.get_num_atoms('S')} > {max_sulfur_atoms}" max_heavy_atoms = species_constraints.get('maximumHeavyAtoms', -1) if max_heavy_atoms != -1: - if struct.get_num_atoms() - struct.get_num_atoms('H') > max_heavy_atoms: - return True + heavy_atoms = struct.get_num_atoms() - struct.get_num_atoms('H') + if heavy_atoms > max_heavy_atoms: + return f"Exceeded maximumHeavyAtoms: {heavy_atoms} > {max_heavy_atoms}" max_surface_sites = species_constraints.get('maximumSurfaceSites', -1) if max_surface_sites != -1: if struct.get_num_atoms('X') > max_surface_sites: - return True + return f"Exceeded maximumSurfaceSites: {struct.get_num_atoms('X')} > {max_surface_sites}" max_surface_bond_order = species_constraints.get('maximumSurfaceBondOrder', -1) if max_surface_bond_order != -1: for site in struct.get_surface_sites(): if site.get_total_bond_order() > max_surface_bond_order: - return True + return f"Exceeded maximumSurfaceBondOrder at site: {site.get_total_bond_order()} > {max_surface_bond_order}" max_radicals = species_constraints.get('maximumRadicalElectrons', -1) if max_radicals != -1: if struct.get_radical_count() > max_radicals: - return True + return f"Exceeded maximumRadicalElectrons: {struct.get_radical_count()} > {max_radicals}" max_carbenes = species_constraints.get('maximumSingletCarbenes', 1) - if max_radicals != -1: + if max_carbenes != -1: if struct.get_singlet_carbene_count() > max_carbenes: - return True + return f"Exceeded maximumSingletCarbenes: {struct.get_singlet_carbene_count()} > {max_carbenes}" max_carbene_radicals = species_constraints.get('maximumCarbeneRadicals', 0) if max_carbene_radicals != -1: if struct.get_singlet_carbene_count() > 0 and struct.get_radical_count() > max_carbene_radicals: - return True + return f"Exceeded maximumCarbeneRadicals: {struct.get_radical_count()} > {max_carbene_radicals}" return False diff --git a/rmgpy/data/kinetics/family.py b/rmgpy/data/kinetics/family.py index 4bb0ee949e7..09553473994 100644 --- a/rmgpy/data/kinetics/family.py +++ b/rmgpy/data/kinetics/family.py @@ -1655,7 +1655,12 @@ def _generate_product_structures(self, reactant_structures, maps, forward, relab if self.is_molecule_forbidden(struct): raise ForbiddenStructureException() if fails_species_constraints(struct): - raise ForbiddenStructureException() + reason = fails_species_constraints(struct) + raise ForbiddenStructureException( + "Species constraints forbids product species {0}. Please " + "reformulate constraints, or explicitly " + "allow it. Reason: {1}".format(struct, reason) + ) return product_structures diff --git a/rmgpy/kinetics/chebyshev.pyx b/rmgpy/kinetics/chebyshev.pyx index 3d0cb6bf1eb..7e8a24835f5 100644 --- a/rmgpy/kinetics/chebyshev.pyx +++ b/rmgpy/kinetics/chebyshev.pyx @@ -193,7 +193,7 @@ cdef class Chebyshev(PDepKineticsModel): raise KineticsError("The master equation data needs more temperature and pressure data " "points than are placed into Chebyshev polynomial. Currently, the " "data has {0} temperatures and the polynomial is set to have {1}. " - "The data has {2} pressures and the polynomial is set ot have {3}" + "The data has {2} pressures and the polynomial is set to have {3}" "".format(nT, degreeT, nP, degreeP)) elif nT < 1.25 * degreeT or nP < 1.25 * degreeP: logging.warning('This Chebyshev fitting has few degrees of freedom and may not be ' diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index 88ea75ff4cc..f673912f7fd 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -587,9 +587,9 @@ def initialize(self, **kwargs): shutil.copyfile(self.species_map_path, os.path.join(filters_restart, "species_map.yml")) # Load the seed mechanism to get the core and edge species - self.database.kinetics.load_libraries(restart_dir, libraries=["restart", "restart_edge"]) + self.database.kinetics.load_libraries(restart_dir)#, libraries=["restart", "restart_edge"]) self.seed_mechanisms.append("restart") - self.reaction_libraries.append(("restart_edge", False)) +# self.reaction_libraries.append(("restart_edge", False)) # Set trimolecular reactant flags of reaction systems if self.trimolecular: @@ -693,10 +693,11 @@ def initialize(self, **kwargs): if "allowed" in self.species_constraints and "input species" in self.species_constraints["allowed"]: self.species_constraints["explicitlyAllowedMolecules"].append(spec.molecule[0]) else: + reason = fails_species_constraints(spec) raise ForbiddenStructureException( "Species constraints forbids input species {0}. Please " "reformulate constraints, remove the species, or explicitly " - "allow it.".format(spec.label) + "allow it. Reason: {1}".format(spec.label, reason) ) # For liquidReactor, checks whether the solvent is listed as one of the initial species. diff --git a/rmgpy/rmg/model.py b/rmgpy/rmg/model.py index d677755b079..607d4eecae7 100644 --- a/rmgpy/rmg/model.py +++ b/rmgpy/rmg/model.py @@ -1677,10 +1677,11 @@ def add_seed_mechanism_to_core(self, seed_mechanism, react=False, requires_rms=F if "allowed" in rmg.species_constraints and "seed mechanisms" in rmg.species_constraints["allowed"]: rmg.species_constraints["explicitlyAllowedMolecules"].extend(spec.molecule) else: + reason = fails_species_constraints(spec) raise ForbiddenStructureException( "Species constraints forbids species {0} from seed mechanism {1}." " Please reformulate constraints, remove the species, or" - " explicitly allow it.".format(spec.label, seed_mechanism.label) + " explicitly allow it. Reason: {2}".format(spec.label, seed_mechanism.label, reason) ) for spec in edge_species_to_move+self.new_species_list: @@ -1804,10 +1805,11 @@ def add_reaction_library_to_edge(self, reaction_library, requires_rms=False): if "allowed" in rmg.species_constraints and "reaction libraries" in rmg.species_constraints["allowed"]: rmg.species_constraints["explicitlyAllowedMolecules"].extend(spec.molecule) else: + reason = fails_species_constraints(spec) raise ForbiddenStructureException( "Species constraints forbids species {0} from reaction library " "{1}. Please reformulate constraints, remove the species, or " - "explicitly allow it.".format(spec.label, reaction_library.label) + "explicitly allow it. Reason: {2}".format(spec.label, reaction_library.label, reason) ) for spec in self.new_species_list: diff --git a/test/rmgpy/constraintsTest.py b/test/rmgpy/constraintsTest.py index 45c411942c5..83097d26d60 100644 --- a/test/rmgpy/constraintsTest.py +++ b/test/rmgpy/constraintsTest.py @@ -83,7 +83,6 @@ def test_constraints_not_loaded(self, mock_logging): rmgpy.rmg.input.rmg = None mol = Molecule(smiles="C") - assert not fails_species_constraints(mol) mock_logging.debug.assert_called_with("Species constraints could not be found.") @@ -210,9 +209,11 @@ def test_surface_site_constraint(self): self.rmg.species_constraints["maximumHeavyAtoms"] = 6 assert not fails_species_constraints(mol_1site) + assert not fails_species_constraints(mol_2site) assert fails_species_constraints(mol_3site_vdW) + assert fails_species_constraints(mol_3site) self.rmg.species_constraints["maximumCarbonAtoms"] = max_carbon