Skip to content

Commit b32e9fa

Browse files
authored
Merge PR #2825 for generatePESDiagrams option
More helpful debugging for PDep networks, and option to always generatePESDiagrams.
2 parents 6ef9e17 + 0ed78ec commit b32e9fa

File tree

12 files changed

+42
-15
lines changed

12 files changed

+42
-15
lines changed

arkane/pdep.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,18 @@ def plot(self, output_directory):
618618
plt.savefig(os.path.join(output_directory, 'plots', 'kinetics_{0:d}.pdf'.format(count)))
619619
plt.close()
620620

621-
def draw(self, output_directory, file_format='pdf'):
621+
def draw(self, output_directory, file_format='pdf', filename_stem='network'):
622622
"""
623623
Generate a PDF drawing of the pressure-dependent reaction network.
624624
This requires that Cairo and its Python wrapper be available; if not,
625625
the drawing is not generated.
626626
627627
You may also generate different formats of drawings, by changing format to
628628
one of the following: `pdf`, `svg`, `png`.
629+
630+
The default filename stem is 'network', which will result in a file
631+
named 'network.pdf' in the specified output directory. You can change
632+
this by passing a different `filename_stem` argument.
629633
"""
630634

631635
# Skip this step if cairo is not installed
@@ -639,7 +643,7 @@ def draw(self, output_directory, file_format='pdf'):
639643

640644
from rmgpy.pdep.draw import NetworkDrawer
641645

642-
path = os.path.join(output_directory, 'network.' + file_format)
646+
path = os.path.join(output_directory, f'{filename_stem}.{file_format}')
643647

644648
NetworkDrawer().draw(self.network, file_format=file_format, path=path)
645649

documentation/source/users/rmg/input.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -965,6 +965,7 @@ Miscellaneous options::
965965
units='si',
966966
generateOutputHTML=True,
967967
generatePlots=False,
968+
generatePESDiagrams=False,
968969
saveSimulationProfiles=True,
969970
verboseComments=False,
970971
saveEdgeSpecies=True,
@@ -986,6 +987,8 @@ HTML file for your model containing all the species and reactions. Turning this
986987

987988
Setting ``generatePlots`` to ``True`` will generate a number of plots describing the statistics of the RMG job, including the reaction model core and edge size and memory use versus execution time. These will be placed in the output directory in the plot/ folder.
988989

990+
Setting ``generatePESDiagrams`` to ``True`` will generate potential energy surface diagrams for each pressure dependent network in the model. These diagrams will be saved in the ``pdep/`` folder in the output directory. Only applicable if pressure dependence is enabled.
991+
989992
Setting ``saveSimulationProfiles`` to ``True`` will make RMG save csv files of the simulation in .csv files in the ``solver/`` folder. The filename will be ``simulation_1_26.csv`` where the first number corresponds to the reaciton system, and the second number corresponds to the total number of species at the point of the simulation. Therefore, the highest second number will indicate the latest simulation that RMG has complete while enlarging the core model. The information inside the csv file will provide the time, reactor volume in m^3, as well as mole fractions of the individual species.
990993

991994
Setting ``verboseComments`` to ``True`` will make RMG generate chemkin files with complete verbose commentary for the kinetic and thermo parameters. This will be helpful in debugging what values are being averaged for the kinetics. Note that this may produce very large files.

examples/rmg/1,3-hexadiene/input.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,5 @@
8989
units='si',
9090
generateOutputHTML=False,
9191
generatePlots=False,
92+
generatePESDiagrams=True,
9293
)

examples/rmg/commented/input.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@
217217
generateOutputHTML=True,
218218
# generates plots of the RMG's performance statistics. Not helpful if you just want a model.
219219
generatePlots=False,
220+
# generates potential energy surface diagrams for pressure dependent networks in the model.
221+
generatePESDiagrams=False,
220222
# saves mole fraction of species in 'solver/' to help you create plots
221223
saveSimulationProfiles=False,
222224
# gets RMG to output comments on where kinetics were obtained in the chemkin file.

examples/rmg/ethane-oxidation/input.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,5 @@
6767
units='si',
6868
generateOutputHTML=False,
6969
generatePlots=False,
70+
generatePESDiagrams=True,
7071
)

rmgpy/data/kinetics/family.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4487,6 +4487,7 @@ def extract_source_from_comments(self, reaction):
44874487
template_matches = re.search(template_pattern, full_comment_string)
44884488
if autogen_node_matches is not None: # autogenerated trees
44894489
template_str = autogen_node_matches.group(1).split('Multiplied by reaction path degeneracy')[0].strip()
4490+
template_str = template_str.split('in family')[0].strip()
44904491
tokens = template_str.split()
44914492
if len(tokens) == 2: # The node was probably split because wordwrap was turned off
44924493
assert len(template_str) > 115, 'The node name is too short to have been broken up by the chemkin writer'

rmgpy/data/kinetics/rules.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -367,20 +367,18 @@ def estimate_kinetics(self, template, degeneracy=1):
367367

368368
kinetics = deepcopy(entry.data)
369369
if entry0 == entry:
370-
kinetics.comment = "Estimated from node {}".format(entry.label)
370+
kinetics.comment = f"Estimated from node {entry.label} in family {self.label.replace('/rules','')}."
371371
kinetics.A.value_si *= degeneracy
372372
if degeneracy > 1:
373-
kinetics.comment += "\n"
374-
kinetics.comment += "Multiplied by reaction path degeneracy {0}".format(degeneracy)
375-
return kinetics,entry
373+
kinetics.comment += f"\nMultiplied by reaction path degeneracy {degeneracy}"
374+
return kinetics, entry
376375
else:
377-
kinetics.comment = "Matched node {}\n".format(entry0.label)
378-
kinetics.comment += "Estimated from node {}".format(entry.label)
376+
kinetics.comment = f"Matched node {entry0.label}\n"
377+
kinetics.comment += f"Estimated from node {entry.label} in family {self.label.replace('/rules','')}."
379378
kinetics.A.value_si *= degeneracy
380379
if degeneracy > 1:
381-
kinetics.comment += "\n"
382-
kinetics.comment += "Multiplied by reaction path degeneracy {0}".format(degeneracy)
383-
return kinetics,None
380+
kinetics.comment += f"\nMultiplied by reaction path degeneracy {degeneracy}"
381+
return kinetics, None
384382

385383
original_leaves = get_template_label(template)
386384
template_list = [template]

rmgpy/pdep/network.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ def set_conditions(self, T, P, ymB=None):
408408
logging.error("Increasing number of grains did not decrease error enough "
409409
"(Current badness: {0:.1f}, previous {1:.1f}). Something must be wrong with "
410410
"network {2}".format(badness, previous_error.badness(), self.label))
411+
self.log_summary()
411412
raise error
412413
previous_error = error
413414
success = False

rmgpy/rmg/input.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ def pressure_dependence(
13691369

13701370

13711371
def options(name='Seed', generateSeedEachIteration=True, saveSeedToDatabase=False, units='si', saveRestartPeriod=None,
1372-
generateOutputHTML=False, generatePlots=False, saveSimulationProfiles=False, verboseComments=False,
1372+
generateOutputHTML=False, generatePlots=False, generatePESDiagrams=False, saveSimulationProfiles=False, verboseComments=False,
13731373
saveEdgeSpecies=False, keepIrreversible=False, trimolecularProductReversible=True, wallTime='00:00:00:00',
13741374
saveSeedModulus=-1):
13751375
if saveRestartPeriod:
@@ -1386,6 +1386,9 @@ def options(name='Seed', generateSeedEachIteration=True, saveSeedToDatabase=Fals
13861386
logging.warning('Generate Output HTML option was turned on. Note that this will slow down model generation.')
13871387
rmg.generate_output_html = generateOutputHTML
13881388
rmg.generate_plots = generatePlots
1389+
rmg.generate_PES_diagrams = generatePESDiagrams
1390+
if generatePESDiagrams:
1391+
logging.info('Potential Energy Surface diagrams will be generated in the "pdep" folder.')
13891392
rmg.save_simulation_profiles = saveSimulationProfiles
13901393
rmg.verbose_comments = verboseComments
13911394
if saveEdgeSpecies:
@@ -1835,6 +1838,7 @@ def save_input_file(path, rmg):
18351838
f.write(' units = "{0}",\n'.format(rmg.units))
18361839
f.write(' generateOutputHTML = {0},\n'.format(rmg.generate_output_html))
18371840
f.write(' generatePlots = {0},\n'.format(rmg.generate_plots))
1841+
f.write(' generatePESDiagrams = {0},\n'.format(rmg.generate_PES_diagrams))
18381842
f.write(' saveSimulationProfiles = {0},\n'.format(rmg.save_simulation_profiles))
18391843
f.write(' saveEdgeSpecies = {0},\n'.format(rmg.save_edge_species))
18401844
f.write(' keepIrreversible = {0},\n'.format(rmg.keep_irreversible))

rmgpy/rmg/main.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ class RMG(util.Subject):
143143
`units` The unit system to use to save output files (currently must be 'si')
144144
`generate_output_html` ``True`` to draw pictures of the species and reactions, saving a visualized model in an output HTML file. ``False`` otherwise
145145
`generate_plots` ``True`` to generate plots of the job execution statistics after each iteration, ``False`` otherwise
146+
`generate_PES_diagrams` ``True`` to generate potential energy surface diagrams for pressure dependent networks in the model, ``False`` otherwise
146147
`verbose_comments` ``True`` to keep the verbose comments for database estimates, ``False`` otherwise
147148
`save_edge_species` ``True`` to save chemkin and HTML files of the edge species, ``False`` otherwise
148149
`keep_irreversible` ``True`` to keep ireversibility of library reactions as is ('<=>' or '=>'). ``False`` (default) to force all library reactions to be reversible ('<=>')
@@ -222,6 +223,7 @@ def clear(self):
222223
self.units = "si"
223224
self.generate_output_html = None
224225
self.generate_plots = None
226+
self.generate_PES_diagrams = None
225227
self.save_simulation_profiles = None
226228
self.verbose_comments = None
227229
self.save_edge_species = None
@@ -271,6 +273,7 @@ def load_input(self, path=None):
271273
if self.pressure_dependence:
272274
self.pressure_dependence.output_file = self.output_directory
273275
self.reaction_model.pressure_dependence = self.pressure_dependence
276+
self.pressure_dependence.generate_PES_diagrams = self.generate_PES_diagrams
274277
if self.solvent:
275278
self.reaction_model.solvent_name = self.solvent
276279

0 commit comments

Comments
 (0)