From d541afc0ed2a3927ced6f22471c25a8c20e731d0 Mon Sep 17 00:00:00 2001 From: Jackson Burns <33505528+JacksonBurns@users.noreply.github.com> Date: Wed, 12 Jun 2024 14:18:01 -0400 Subject: [PATCH] remove unnesecary `NO_JULIA` check --- rmgpy/rmg/main.py | 19 ++++++++++--------- rmgpy/rmg/model.py | 16 ++++++++-------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/rmgpy/rmg/main.py b/rmgpy/rmg/main.py index 5380a23e20..8a9ebf2d2a 100644 --- a/rmgpy/rmg/main.py +++ b/rmgpy/rmg/main.py @@ -81,7 +81,6 @@ from rmgpy.tools.uncertainty import Uncertainty, process_local_results from rmgpy.yml import RMSWriter from rmgpy.rmg.reactionmechanismsimulator_reactors import Reactor as RMSReactor -from rmgpy.rmg.reactionmechanismsimulator_reactors import NO_JULIA ################################################################################ @@ -560,7 +559,7 @@ def initialize(self, **kwargs): self.reaction_model.add_species_to_edge(spec, requires_rms=requires_rms) for reaction_system in self.reaction_systems: - if not NO_JULIA and isinstance(reaction_system, RMSReactor): + if isinstance(reaction_system, RMSReactor): reaction_system.finish_termination_criteria() # Load restart seed mechanism (if specified) @@ -711,7 +710,9 @@ def initialize(self, **kwargs): # 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: for index, reaction_system in enumerate(self.reaction_systems): - if ((NO_JULIA or not isinstance(reaction_system, RMSReactor)) and reaction_system.const_spc_names is not None): # if no constant species provided do nothing + if ( + not isinstance(reaction_system, RMSReactor) + ) and reaction_system.const_spc_names is not None: # if no constant species provided do nothing reaction_system.get_const_spc_indices(self.reaction_model.core.species) # call the function to identify indices in the solver self.initialize_reaction_threshold_and_react_flags() @@ -729,7 +730,7 @@ def register_listeners(self, requires_rms=False): """ self.attach(ChemkinWriter(self.output_directory)) - if not NO_JULIA and requires_rms: + if requires_rms: self.attach(RMSWriter(self.output_directory)) if self.generate_output_html: @@ -742,7 +743,7 @@ def register_listeners(self, requires_rms=False): if self.save_simulation_profiles: for index, reaction_system in enumerate(self.reaction_systems): - if not NO_JULIA and requires_rms and isinstance(reaction_system, RMSReactor): + if requires_rms and isinstance(reaction_system, RMSReactor): typ = type(reaction_system) raise InputError(f"save_simulation_profiles=True not compatible with reactor of type {typ}") reaction_system.attach(SimulationProfileWriter(self.output_directory, index, self.reaction_model.core.species)) @@ -786,7 +787,7 @@ def execute(self, initialize=True, **kwargs): # Update react flags if self.filter_reactions: # Run the reaction system to update threshold and react flags - if not NO_JULIA and requires_rms and isinstance(reaction_system, RMSReactor): + if requires_rms and isinstance(reaction_system, RMSReactor): self.update_reaction_threshold_and_react_flags( rxn_sys_unimol_threshold=np.zeros((len(self.reaction_model.core.species),), bool), rxn_sys_bimol_threshold=np.zeros((len(self.reaction_model.core.species), len(self.reaction_model.core.species)), bool), @@ -908,7 +909,7 @@ def execute(self, initialize=True, **kwargs): prune = False try: - if not NO_JULIA and requires_rms and isinstance(reaction_system, RMSReactor): + if requires_rms and isinstance(reaction_system, RMSReactor): ( terminated, resurrected, @@ -1010,7 +1011,7 @@ def execute(self, initialize=True, **kwargs): temp_model_settings.tol_keep_in_edge = 0 if not resurrected: try: - if not NO_JULIA and requires_rms and isinstance(reaction_system, RMSReactor): + if requires_rms and isinstance(reaction_system, RMSReactor): ( terminated, resurrected, @@ -2229,7 +2230,7 @@ def __init__(self, reaction_system, bspc): if isinstance(value, list): self.Ranges[key] = [v.value_si for v in value] - if not NO_JULIA and isinstance(reaction_system, RMSReactor): + if isinstance(reaction_system, RMSReactor): self.tmax = reaction_system.tf else: for term in reaction_system.termination: diff --git a/rmgpy/rmg/model.py b/rmgpy/rmg/model.py index 756d4b64cf..54943270cc 100644 --- a/rmgpy/rmg/model.py +++ b/rmgpy/rmg/model.py @@ -1134,7 +1134,7 @@ def add_species_to_core(self, spec, requires_rms=False): rxn_list = [] if spec in self.edge.species: - if not NO_JULIA and requires_rms: + if requires_rms: self.edge.phase_system.pass_species(spec.label, self.core.phase_system) # If species was in edge, remove it logging.debug("Removing species %s from edge.", spec) @@ -1157,7 +1157,7 @@ def add_species_to_core(self, spec, requires_rms=False): for rxn in rxn_list: self.add_reaction_to_core(rxn, requires_rms=requires_rms) logging.debug("Moving reaction from edge to core: %s", rxn) - elif not NO_JULIA and requires_rms: + elif requires_rms: destination_phase = "Surface" if spec.molecule[0].contains_surface_site() else "Default" self.core.phase_system.phases[destination_phase].add_species(spec, edge_phase=self.edge.phase_system.phases[destination_phase]) self.edge.phase_system.species_dict[spec.label] = spec @@ -1170,7 +1170,7 @@ def add_species_to_edge(self, spec, requires_rms=False): Add a species `spec` to the reaction model edge and optionally the RMS phase. """ self.edge.species.append(spec) - if NO_JULIA or not requires_rms: + if not requires_rms: return destination_phase = "Surface" if spec.molecule[0].contains_surface_site() else "Default" self.edge.phase_system.phases[destination_phase].add_species(spec) @@ -1395,12 +1395,12 @@ def remove_species_from_edge(self, reaction_systems, spec, requires_rms=False): # remove the species self.edge.species.remove(spec) self.index_species_dict.pop(spec.index) - if not NO_JULIA and requires_rms: + if requires_rms: self.edge.phase_system.remove_species(spec) # clean up species references in reaction_systems for reaction_system in reaction_systems: - if NO_JULIA or not requires_rms or not isinstance(reaction_system, RMSReactor): + if not requires_rms or not isinstance(reaction_system, RMSReactor): try: reaction_system.species_index.pop(spec) except KeyError: @@ -1481,8 +1481,8 @@ def add_reaction_to_core(self, rxn, requires_rms=False): """ if rxn not in self.core.reactions: self.core.reactions.append(rxn) - - if not NO_JULIA and requires_rms and rxn not in self.edge.reactions: + + if requires_rms and rxn not in self.edge.reactions: # If a reaction is not in edge but is going to add to core, it is either a seed mechanism or a newly generated reaction where all reactants and products are already in core # If the reaction is in edge, then the corresponding rms_rxn was moved from edge phase to core phase in pass_species already. rms_species_list = self.core.phase_system.get_rms_species_list() @@ -1508,7 +1508,7 @@ def add_reaction_to_edge(self, rxn, requires_rms=False): edge). """ self.edge.reactions.append(rxn) - if NO_JULIA or not requires_rms: + if not requires_rms: return rms_species_list = self.edge.phase_system.get_rms_species_list() species_names = self.edge.phase_system.get_species_names()