Skip to content

Commit

Permalink
remove unnesecary NO_JULIA check
Browse files Browse the repository at this point in the history
  • Loading branch information
JacksonBurns committed Jun 12, 2024
1 parent dcef9ab commit d541afc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
19 changes: 10 additions & 9 deletions rmgpy/rmg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

################################################################################

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand All @@ -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:
Expand All @@ -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))
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 8 additions & 8 deletions rmgpy/rmg/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit d541afc

Please sign in to comment.