Skip to content

Commit

Permalink
add requires_rms to pdep, thermo filtering, and process_new_rxns
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonBurns committed Oct 27, 2023
1 parent 34796db commit 7de8a3a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions rmgpy/rmg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ def execute(self, initialize=True, **kwargs):
)

if not np.isinf(self.model_settings_list[0].thermo_tol_keep_spc_in_edge):
self.reaction_model.thermo_filter_down(maximum_edge_species=self.model_settings_list[0].maximum_edge_species)
self.reaction_model.thermo_filter_down(maximum_edge_species=self.model_settings_list[0].maximum_edge_species, requires_rms=requires_rms)

Check warning on line 844 in rmgpy/rmg/main.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/rmg/main.py#L844

Added line #L844 was not covered by tests

logging.info("Completed initial enlarge edge step.\n")

Expand Down Expand Up @@ -1108,7 +1108,7 @@ def execute(self, initialize=True, **kwargs):
reactor_done = False

if not np.isinf(self.model_settings_list[0].thermo_tol_keep_spc_in_edge):
self.reaction_model.thermo_filter_down(maximum_edge_species=model_settings.maximum_edge_species)
self.reaction_model.thermo_filter_down(maximum_edge_species=model_settings.maximum_edge_species, requires_rms=requires_rms)

Check warning on line 1111 in rmgpy/rmg/main.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/rmg/main.py#L1111

Added line #L1111 was not covered by tests

max_num_spcs_hit = len(self.reaction_model.core.species) >= model_settings.max_num_species

Expand Down
28 changes: 14 additions & 14 deletions rmgpy/rmg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def enlarge(self, new_object=None, react_edge=False, unimolecular_react=None, bi
pdep_network, new_species = new_object
new_reactions.extend(pdep_network.explore_isomer(new_species))

self.process_new_reactions(new_reactions, new_species, pdep_network)
self.process_new_reactions(new_reactions, new_species, pdep_network, requires_rms=requires_rms)

else:
raise TypeError(
Expand All @@ -667,7 +667,7 @@ def enlarge(self, new_object=None, react_edge=False, unimolecular_react=None, bi
if len(products) == 1 and products[0] == species:
new_reactions = network.explore_isomer(species)

self.process_new_reactions(new_reactions, species, network)
self.process_new_reactions(new_reactions, species, network, requires_rms=requires_rms)
network.update_configurations(self)
index = 0
break
Expand All @@ -692,7 +692,7 @@ def enlarge(self, new_object=None, react_edge=False, unimolecular_react=None, bi
# Identify a core species which was used to generate the reaction
# This is only used to determine the reaction direction for processing
spc = spcTuple[0]
self.process_new_reactions(rxnList, spc)
self.process_new_reactions(rxnList, spc, requires_rms=requires_rms)

################################################################
# Begin processing the new species and reactions
Expand All @@ -704,7 +704,7 @@ def enlarge(self, new_object=None, react_edge=False, unimolecular_react=None, bi

# Do thermodynamic filtering
if not np.isinf(self.thermo_tol_keep_spc_in_edge) and self.new_species_list != []:
self.thermo_filter_species(self.new_species_list)
self.thermo_filter_species(self.new_species_list, requires_rms=requires_rms)

Check warning on line 707 in rmgpy/rmg/model.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/rmg/model.py#L707

Added line #L707 was not covered by tests

# Update unimolecular (pressure dependent) reaction networks
if self.pressure_dependence:
Expand Down Expand Up @@ -1131,7 +1131,7 @@ def add_species_to_core(self, spec, requires_rms=False):
if spec in self.edge.species:
# remove forbidden species from edge
logging.info("Species {0} was Forbidden and not added to Core...Removing from Edge.".format(spec))
self.remove_species_from_edge(self.reaction_systems, spec)
self.remove_species_from_edge(self.reaction_systems, spec, requires_rms=requires_rms)
# remove any empty pdep networks as a result of species removal
if self.pressure_dependence:
self.remove_empty_pdep_networks()
Expand Down Expand Up @@ -1207,7 +1207,7 @@ def set_thermodynamic_filtering_parameters(
self.reaction_systems = reaction_systems
self.maximum_edge_species = maximum_edge_species

def thermo_filter_species(self, spcs):
def thermo_filter_species(self, spcs, requires_rms=False):
"""
checks Gibbs energy of the species in species against the
maximum allowed Gibbs energy
Expand All @@ -1222,13 +1222,13 @@ def thermo_filter_species(self, spcs):
"greater than the thermo_tol_keep_spc_in_edge of "
"{3} ".format(spc, G, Gn, self.thermo_tol_keep_spc_in_edge)
)
self.remove_species_from_edge(self.reaction_systems, spc)
self.remove_species_from_edge(self.reaction_systems, spc, requires_rms=requires_rms)

# Delete any networks that became empty as a result of pruning
if self.pressure_dependence:
self.remove_empty_pdep_networks()

def thermo_filter_down(self, maximum_edge_species, min_species_exist_iterations_for_prune=0):
def thermo_filter_down(self, maximum_edge_species, min_species_exist_iterations_for_prune=0, requires_rms=False):
"""
removes species from the edge based on their Gibbs energy until maximum_edge_species
is reached under the constraint that all removed species are older than
Expand Down Expand Up @@ -1270,7 +1270,7 @@ def thermo_filter_down(self, maximum_edge_species, min_species_exist_iterations_
logging.info(
"Removing species {0} from edge to meet maximum number of edge species, Gibbs " "number is {1}".format(spc, Gns[rInds[i]])
)
self.remove_species_from_edge(self.reaction_systems, spc)
self.remove_species_from_edge(self.reaction_systems, spc, requires_rms=requires_rms)

# Delete any networks that became empty as a result of pruning
if self.pressure_dependence:
Expand Down Expand Up @@ -1643,9 +1643,9 @@ def add_seed_mechanism_to_core(self, seed_mechanism, react=False, requires_rms=F
# This unimolecular library reaction is flagged as `elementary_high_p` and has Arrhenius type kinetics.
# We should calculate a pressure-dependent rate for it
if len(rxn.reactants) == 1:
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.reactants[0])
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.reactants[0], requires_rms=requires_rms)
else:
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.products[0])
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.products[0], requires_rms=requires_rms)

# Perform species constraints and forbidden species checks

Expand Down Expand Up @@ -1693,7 +1693,7 @@ def add_seed_mechanism_to_core(self, seed_mechanism, react=False, requires_rms=F
submit(spec, self.solvent_name)

rxn.fix_barrier_height(force_positive=True)
self.add_reaction_to_core(rxn)
self.add_reaction_to_core(rxn, requires_rms=requires_rms)

# Check we didn't introduce unmarked duplicates
self.mark_chemkin_duplicates()
Expand Down Expand Up @@ -1765,9 +1765,9 @@ def add_reaction_library_to_edge(self, reaction_library, requires_rms=False):
# This unimolecular library reaction is flagged as `elementary_high_p` and has Arrhenius type kinetics.
# We should calculate a pressure-dependent rate for it
if len(rxn.reactants) == 1:
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.reactants[0])
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.reactants[0], requires_rms=requires_rms)

Check warning on line 1768 in rmgpy/rmg/model.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/rmg/model.py#L1768

Added line #L1768 was not covered by tests
else:
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.products[0])
self.process_new_reactions(new_reactions=[rxn], new_species=rxn.products[0], requires_rms=requires_rms)

Check warning on line 1770 in rmgpy/rmg/model.py

View check run for this annotation

Codecov / codecov/patch

rmgpy/rmg/model.py#L1770

Added line #L1770 was not covered by tests

# Perform species constraints and forbidden species checks
for spec in self.new_species_list:
Expand Down
4 changes: 2 additions & 2 deletions rmgpy/rmg/pdep.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ def update(self, reaction_model, pdep_settings):
f'from the {rxn.library} library, and was not added to the model')
break
else:
reaction_model.add_reaction_to_core(net_reaction)
reaction_model.add_reaction_to_core(net_reaction, requires_rms=True)
else:
# Check whether netReaction already exists in the edge as a LibraryReaction
for rxn in reaction_model.edge.reactions:
Expand All @@ -929,7 +929,7 @@ def update(self, reaction_model, pdep_settings):
f'from the {rxn.library} library, and was not added to the model')
break
else:
reaction_model.add_reaction_to_edge(net_reaction)
reaction_model.add_reaction_to_edge(net_reaction, requires_rms=True)

# Set/update the net reaction kinetics using interpolation model
kdata = K[:, :, i, j].copy()
Expand Down

0 comments on commit 7de8a3a

Please sign in to comment.