Skip to content

Commit 7de8a3a

Browse files
committed
add requires_rms to pdep, thermo filtering, and process_new_rxns
1 parent 34796db commit 7de8a3a

3 files changed

Lines changed: 18 additions & 18 deletions

File tree

rmgpy/rmg/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ def execute(self, initialize=True, **kwargs):
841841
)
842842

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

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

@@ -1108,7 +1108,7 @@ def execute(self, initialize=True, **kwargs):
11081108
reactor_done = False
11091109

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

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

rmgpy/rmg/model.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ def enlarge(self, new_object=None, react_edge=False, unimolecular_react=None, bi
643643
pdep_network, new_species = new_object
644644
new_reactions.extend(pdep_network.explore_isomer(new_species))
645645

646-
self.process_new_reactions(new_reactions, new_species, pdep_network)
646+
self.process_new_reactions(new_reactions, new_species, pdep_network, requires_rms=requires_rms)
647647

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

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

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

705705
# Do thermodynamic filtering
706706
if not np.isinf(self.thermo_tol_keep_spc_in_edge) and self.new_species_list != []:
707-
self.thermo_filter_species(self.new_species_list)
707+
self.thermo_filter_species(self.new_species_list, requires_rms=requires_rms)
708708

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

1210-
def thermo_filter_species(self, spcs):
1210+
def thermo_filter_species(self, spcs, requires_rms=False):
12111211
"""
12121212
checks Gibbs energy of the species in species against the
12131213
maximum allowed Gibbs energy
@@ -1222,13 +1222,13 @@ def thermo_filter_species(self, spcs):
12221222
"greater than the thermo_tol_keep_spc_in_edge of "
12231223
"{3} ".format(spc, G, Gn, self.thermo_tol_keep_spc_in_edge)
12241224
)
1225-
self.remove_species_from_edge(self.reaction_systems, spc)
1225+
self.remove_species_from_edge(self.reaction_systems, spc, requires_rms=requires_rms)
12261226

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

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

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

16501650
# Perform species constraints and forbidden species checks
16511651

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

16951695
rxn.fix_barrier_height(force_positive=True)
1696-
self.add_reaction_to_core(rxn)
1696+
self.add_reaction_to_core(rxn, requires_rms=requires_rms)
16971697

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

17721772
# Perform species constraints and forbidden species checks
17731773
for spec in self.new_species_list:

rmgpy/rmg/pdep.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ def update(self, reaction_model, pdep_settings):
917917
f'from the {rxn.library} library, and was not added to the model')
918918
break
919919
else:
920-
reaction_model.add_reaction_to_core(net_reaction)
920+
reaction_model.add_reaction_to_core(net_reaction, requires_rms=True)
921921
else:
922922
# Check whether netReaction already exists in the edge as a LibraryReaction
923923
for rxn in reaction_model.edge.reactions:
@@ -929,7 +929,7 @@ def update(self, reaction_model, pdep_settings):
929929
f'from the {rxn.library} library, and was not added to the model')
930930
break
931931
else:
932-
reaction_model.add_reaction_to_edge(net_reaction)
932+
reaction_model.add_reaction_to_edge(net_reaction, requires_rms=True)
933933

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

0 commit comments

Comments
 (0)