From 54775a8bc36a9ba69646c45536e89974f28580c7 Mon Sep 17 00:00:00 2001 From: Hao-Wei Pang Date: Thu, 2 Mar 2023 12:43:58 -0500 Subject: [PATCH 1/2] add initial species in core before seed mechanism to make sure initial species in phase.names --- rmgpy/rmg/main.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index 8291db4a13..fd5c298a60 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -614,6 +614,25 @@ def initialize(self, **kwargs): # Initialize reaction model + # Also always add in a few bath gases (since RMG-Java does) + for label, smiles in [('Ar', '[Ar]'), ('He', '[He]'), ('Ne', '[Ne]'), ('N2', 'N#N')]: + molecule = Molecule().from_smiles(smiles) + spec, is_new = self.reaction_model.make_new_species(molecule, label=label, reactive=False) + if is_new: + self.initial_species.append(spec) + + for spec in self.initial_species: + submit(spec, self.solvent) + + # Add nonreactive species (e.g. bath gases) to core first + # This is necessary so that the PDep algorithm can identify the bath gas + for spec in self.initial_species: + if not spec.reactive: + self.reaction_model.enlarge(spec) + for spec in self.initial_species: + if spec.reactive: + self.reaction_model.enlarge(spec) + # Seed mechanisms: add species and reactions from seed mechanism # DON'T generate any more reactions for the seed species at this time for seed_mechanism in self.seed_mechanisms: @@ -624,13 +643,6 @@ def initialize(self, **kwargs): for library, option in self.reaction_libraries: self.reaction_model.add_reaction_library_to_edge(library) - # Also always add in a few bath gases (since RMG-Java does) - for label, smiles in [("Ar", "[Ar]"), ("He", "[He]"), ("Ne", "[Ne]"), ("N2", "N#N")]: - molecule = Molecule().from_smiles(smiles) - spec, is_new = self.reaction_model.make_new_species(molecule, label=label, reactive=False) - if is_new: - self.initial_species.append(spec) - # Perform species constraints and forbidden species checks on input species for spec in self.initial_species: if self.database.forbidden_structures.is_molecule_forbidden(spec.molecule[0]): @@ -690,15 +702,6 @@ def initialize(self, **kwargs): spec.get_liquid_volumetric_mass_transfer_coefficient_data() spec.get_henry_law_constant_data() - # Add nonreactive species (e.g. bath gases) to core first - # This is necessary so that the PDep algorithm can identify the bath gas - for spec in self.initial_species: - if not spec.reactive: - self.reaction_model.enlarge(spec) - for spec in self.initial_species: - if spec.reactive: - self.reaction_model.enlarge(spec) - # chatelak: store constant SPC indices in the reactor attributes if any constant SPC provided in the input file # advantages to write it here: this is run only once (as species indexes does not change over the generation) if self.solvent is not None: From b7721837105e0fce1e31bf0876faac77ccbea5f1 Mon Sep 17 00:00:00 2001 From: Hao-Wei Pang Date: Tue, 12 Sep 2023 17:07:40 -0400 Subject: [PATCH 2/2] Move library to edge before adding initial species to core to make sure library reactions get move to core if all reactants and products are in initial species --- rmgpy/rmg/main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index fd5c298a60..6d0e610fca 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -614,6 +614,11 @@ def initialize(self, **kwargs): # Initialize reaction model + # Reaction libraries: add species and reactions from reaction library to the edge so + # that RMG can find them if their rates are large enough + for library, option in self.reaction_libraries: + self.reaction_model.add_reaction_library_to_edge(library) + # Also always add in a few bath gases (since RMG-Java does) for label, smiles in [('Ar', '[Ar]'), ('He', '[He]'), ('Ne', '[Ne]'), ('N2', 'N#N')]: molecule = Molecule().from_smiles(smiles) @@ -638,11 +643,6 @@ def initialize(self, **kwargs): for seed_mechanism in self.seed_mechanisms: self.reaction_model.add_seed_mechanism_to_core(seed_mechanism, react=False) - # Reaction libraries: add species and reactions from reaction library to the edge so - # that RMG can find them if their rates are large enough - for library, option in self.reaction_libraries: - self.reaction_model.add_reaction_library_to_edge(library) - # Perform species constraints and forbidden species checks on input species for spec in self.initial_species: if self.database.forbidden_structures.is_molecule_forbidden(spec.molecule[0]):