Skip to content

Commit

Permalink
added input arg for disabling rms yaml write
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisBNEU committed Aug 16, 2023
1 parent c6e2c19 commit 7fddaa8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rmgpy/rmg/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -1337,8 +1337,8 @@ def pressure_dependence(

def options(name='Seed', generateSeedEachIteration=True, saveSeedToDatabase=False, units='si', saveRestartPeriod=None,
generateOutputHTML=False, generatePlots=False, saveSimulationProfiles=False, verboseComments=False,
saveEdgeSpecies=False, keepIrreversible=False, trimolecularProductReversible=True, wallTime='00:00:00:00',
saveSeedModulus=-1):
saveEdgeSpecies=False, keepIrreversible=False, trimolecularProductReversible=True, generateRMSEachIter=True,
wallTime='00:00:00:00', saveSeedModulus=-1):
if saveRestartPeriod:
logging.warning("`saveRestartPeriod` flag was set in the input file, but this feature has been removed. Please "
"remove this line from the input file. This will throw an error after RMG-Py 3.1. For "
Expand All @@ -1352,6 +1352,7 @@ def options(name='Seed', generateSeedEachIteration=True, saveSeedToDatabase=Fals
if generateOutputHTML:
logging.warning('Generate Output HTML option was turned on. Note that this will slow down model generation.')
rmg.generate_output_html = generateOutputHTML
rmg.generate_rms_each_iter = generateRMSEachIter
rmg.generate_plots = generatePlots
rmg.save_simulation_profiles = saveSimulationProfiles
rmg.verbose_comments = verboseComments
Expand Down Expand Up @@ -1800,6 +1801,7 @@ def save_input_file(path, rmg):
f.write('options(\n')
f.write(' units = "{0}",\n'.format(rmg.units))
f.write(' generateOutputHTML = {0},\n'.format(rmg.generate_output_html))
f.write(' generateRMSEachIter = {0},\n'.format(rmg.generate_rms_each_iter))
f.write(' generatePlots = {0},\n'.format(rmg.generate_plots))
f.write(' saveSimulationProfiles = {0},\n'.format(rmg.save_simulation_profiles))
f.write(' saveEdgeSpecies = {0},\n'.format(rmg.save_edge_species))
Expand Down
22 changes: 21 additions & 1 deletion rmgpy/rmg/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,8 +722,10 @@ def register_listeners(self):
"""

self.attach(ChemkinWriter(self.output_directory))
self.attach(RMSWriter(self.output_directory))

if self.generate_rms_each_iter:
self.attach(RMSWriter(self.output_directory))

if self.generate_output_html:
self.attach(OutputHTMLWriter(self.output_directory))

Expand Down Expand Up @@ -1186,6 +1188,24 @@ def execute(self, initialize=True, **kwargs):
except Exception:
logging.exception("Could not generate Cantera files for some reason.")

# if we're not writing rms files each iteration, only write one at the end.
if not self.generate_rms_each_iter:
from rmgpy.yml import write_yml

# make rms dir
dirname = os.path.join(self.output_directory, "rms")
if os.path.exists(dirname):
# The directory already exists, so delete it (and all its content!)
shutil.rmtree(dirname)
os.mkdir(dirname)

# save final rms file
solvent_data = None
if self.solvent:
solvent_data = self.database.solvation.get_solvent_data(self.solvent)
write_yml(self.reaction_model.core.species, self.reaction_model.core.reactions, solvent=self.solvent, solvent_data=solvent_data,
path=os.path.join(dirname, 'chem.rms'))

self.check_model()
# Write output file
logging.info("")
Expand Down

0 comments on commit 7fddaa8

Please sign in to comment.