Skip to content

Commit c8bd5ac

Browse files
authored
Merge pull request #2945 to enhance output options
Enhance options for output writing
2 parents f08e9ce + f827297 commit c8bd5ac

21 files changed

Lines changed: 520 additions & 132 deletions

File tree

documentation/source/users/rmg/input.rst

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,13 +1073,17 @@ Miscellaneous options::
10731073
units='si',
10741074
generateOutputHTML=True,
10751075
generatePlots=False,
1076-
generatePESDiagrams=False,
1076+
generatePESDiagrams=False,
10771077
saveSimulationProfiles=True,
10781078
verboseComments=False,
10791079
saveEdgeSpecies=True,
10801080
keepIrreversible=True,
10811081
trimolecularProductReversible=False,
1082-
saveSeedModulus=-1
1082+
saveSeedModulus=-1,
1083+
generateChemkin=True,
1084+
generateRMSYAML=True,
1085+
generateCanteraYAML1=False,
1086+
generateCanteraYAML2=False,
10831087
)
10841088

10851089
The ``name`` field is the name of any generated seed mechanisms
@@ -1099,16 +1103,59 @@ Setting ``generatePESDiagrams`` to ``True`` will generate potential energy surfa
10991103

11001104
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.
11011105

1102-
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.
1106+
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. This is a global fallback; individual writers can override it (see below).
11031107

1104-
Setting ``saveEdgeSpecies`` to ``True`` will make RMG generate chemkin files of the edge reactions in addition to the core model in files such as ``chem_edge.inp`` and ``chem_edge_annotated.inp`` files located inside the ``chemkin`` folder. These files will be helpful in viewing RMG's estimate for edge reactions and seeing if certain reactions one expects are actually in the edge or not.
1108+
Setting ``saveEdgeSpecies`` to ``True`` will make RMG generate chemkin files of the edge reactions in addition to the core model in files such as ``chem_edge.inp`` and ``chem_edge_annotated.inp`` files located inside the ``chemkin`` folder. These files will be helpful in viewing RMG's estimate for edge reactions and seeing if certain reactions one expects are actually in the edge or not. This is a global fallback; individual writers can override it (see below).
11051109

11061110
Setting ``keepIrreversible`` to ``True`` will make RMG import library reactions as is, whether they are reversible or irreversible in the library. Otherwise, if ``False`` (default value), RMG will force all library reactions to be reversible, and will assign the forward rate from the relevant library.
11071111

11081112
Setting ``trimolecularProductReversible`` to ``False`` will not allow families with three products to react in the reverse direction. Default is ``True``.
11091113

11101114
Setting ``saveSeedModulus`` to ``-1`` will only save the seed from the last iteration at the end of an RMG job. Alternatively, the seed can be saved every ``n`` iterations by setting ``saveSeedModulus`` to ``n``.
11111115

1116+
Per-writer Output Configuration
1117+
--------------------------------
1118+
1119+
Each of the following options controls a separate output-format writer. Each
1120+
accepts ``True``, ``False``, or a Python dict with optional keys:
1121+
1122+
* ``'saveInterval'`` *(int)* — positive N writes every N iterations (iteration
1123+
numbering starts at 0); ``-1`` writes only at the very end of the run.
1124+
Defaults to ``1`` (every iteration) for writers that are on by default.
1125+
* ``'verboseComments'`` *(bool, optional)* — overrides the global
1126+
``verboseComments`` flag for this writer only.
1127+
* ``'saveEdge'`` *(bool, optional)* — overrides the global ``saveEdgeSpecies``
1128+
flag for this writer only.
1129+
1130+
Examples::
1131+
1132+
# Chemkin: save only at the end, with verbose comments and edge species
1133+
generateChemkin={'saveInterval': -1, 'verboseComments': True, 'saveEdge': True}
1134+
1135+
# RMS YAML: save every 5 iterations
1136+
generateRMSYAML={'saveInterval': 5}
1137+
1138+
# Cantera YAML v2: save every iteration with verbose comments
1139+
generateCanteraYAML2={'saveInterval': 1, 'verboseComments': True, 'saveEdge': False}
1140+
1141+
``generateChemkin`` (default ``True``)
1142+
Controls the Chemkin writer. Output is written to the ``chemkin/`` folder.
1143+
1144+
``generateRMSYAML`` (default ``True``)
1145+
Controls the RMS YAML writer. Output is written to the ``rms/`` folder.
1146+
1147+
``generateCanteraYAML1`` (default ``False``)
1148+
Controls the Cantera YAML v1 writer. Output is written to the ``cantera1/``
1149+
folder. This writer is disabled by default.
1150+
1151+
``generateCanteraYAML2`` (default ``False``)
1152+
Controls the Cantera YAML v2 writer. Output is written to the ``cantera2/``
1153+
folder. This writer is disabled by default.
1154+
1155+
``generateOutputHTML`` (default ``False``)
1156+
Controls the HTML species-visualisation writer. Output is written to the
1157+
``species/`` folder. Accepts ``True``/``False`` or the same dict format.
1158+
11121159
Species Constraints
11131160
=====================
11141161

documentation/source/users/rmg/running.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ at the command line will print the documentation from ``util.py``, which is repr
4848
-P, --postprocess postprocess profiling statistics from previous
4949
[failed] run; does not run the simulation
5050
-t DD:HH:MM:SS, --walltime DD:HH:MM:SS
51-
set the maximum execution time
51+
set the maximum execution time (overrides input.py if provided)
5252
-i MAXITER, --maxiter MAXITER
53-
set the maximum number of RMG iterations
53+
set the maximum number of RMG iterations (overrides input.py if provided)
5454
-n MAXPROC, --maxproc MAXPROC
5555
max number of processes used during reaction
5656
generation
@@ -73,7 +73,7 @@ Run with multiprocessing for reaction generation and QMTP::
7373

7474
python rmg.py -n <Max number of processes allowed> input.py
7575

76-
Run with setting a limit on the maximum execution time::
76+
Run with setting a limit on the maximum execution time (if specified, then the command-line value overrides any value read from ``input.py``)::
7777

7878
python rmg.py -t <DD:HH:MM:SS> input.py
7979

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,9 @@
9090
generateOutputHTML=False,
9191
generatePlots=False,
9292
generatePESDiagrams=True,
93+
# Large model: write output every 5 iterations and skip edge species to reduce I/O
94+
generateChemkin={'saveInterval': 1, 'saveEdge': False},
95+
generateRMSYAML={'saveInterval': 5},
96+
generateCanteraYAML1={'saveInterval': 5},
97+
generateCanteraYAML2={'saveInterval': 5},
9398
)

examples/rmg/MR_test/input.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@
260260
#Sets a time limit in the form DD:HH:MM:SS after which the RMG job will stop. Useful for profiling on jobs that
261261
#do not converge.
262262
#wallTime = '00:00:00',
263+
#When keepIrreversible=False (default), forces RMG to import library reactions as reversible.
264+
#Otherwise, if set to True, RMG will import library reactions while keeping the reversibility as specified.
263265
keepIrreversible=False,
264-
#Forces RMG to import library reactions as reversible (default). Otherwise, if set to True, RMG will import library
265-
#reactions while keeping the reversibility as as.
266266
)
267267

268268
# optional module allows for correction to unimolecular reaction rates at low pressures and/or temperatures.

examples/rmg/ch3no2/input.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,13 @@
8080
)
8181

8282
simulator(atol=1e-16,rtol=1e-8)
83+
8384
options(
8485
units='si',
8586
generateOutputHTML=False,
8687
generatePlots=False,
88+
# Large model: write output every 5 iterations to reduce I/O
89+
generateChemkin={'saveInterval': 5, 'saveEdge': False},
90+
generateRMSYAML={'saveInterval': 5},
91+
generateCanteraYAML2={'saveInterval': 10, 'saveEdge': True},
8792
)

examples/rmg/commented/input.py

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -221,23 +221,47 @@
221221
generatePESDiagrams=False,
222222
# saves mole fraction of species in 'solver/' to help you create plots
223223
saveSimulationProfiles=False,
224-
# gets RMG to output comments on where kinetics were obtained in the chemkin file.
225-
# useful for debugging kinetics but increases memory usage of the chemkin output file
224+
# Global fallback for verbose comments (comments on where kinetics were obtained).
225+
# Useful for debugging kinetics but increases output file size.
226+
# Individual writers can override this with their own verboseComments key.
226227
verboseComments=False,
227-
# gets RMG to generate edge species chemkin files. Uses lots of memory in output.
228-
# Helpful for seeing why some reaction are not appearing in core model.
228+
# Global fallback for saving edge-species files. Uses lots of memory in output.
229+
# Helpful for seeing why some reactions are not appearing in the core model.
230+
# Individual writers can override this with their own saveEdge key.
229231
saveEdgeSpecies=False,
230-
# Sets a time limit in the form DD:HH:MM:SS after which the RMG job will stop. Useful for profiling on jobs that
231-
# do not converge.
232-
# wallTime = '00:00:00',
233-
# Forces RMG to import library reactions as reversible (default). Otherwise, if set to True, RMG will import library
234-
# reactions while keeping the reversibility as as.
232+
# Sets a time limit in the form DD:HH:MM:SS after (or shortly before) which the RMG job will stop.
233+
# Useful for profiling on jobs that do not converge.
234+
wallTime = '00:00:00:00',
235+
# If keepIrreversible=False (default) forces RMG to import library reactions as reversible.
236+
# If set to True, RMG will import library reactions while keeping the reversibility as specified.
235237
keepIrreversible=False,
236238
# Allows families with three products to react in the diverse direction (default).
237239
trimolecularProductReversible=True,
238240
# Allows a seed to be saved every n iterations.
239241
# The default of -1 causes the iteration to only be saved at the end of the RMG job
240-
saveSeedModulus=-1
242+
saveSeedModulus=-1,
243+
#
244+
# --- Per-writer output configuration ---
245+
# Each writer accepts True/False or a dict with keys:
246+
# 'saveInterval': N (positive = every N iterations; -1 = end of run only)
247+
# 'verboseComments': True/False (overrides the global verboseComments above)
248+
# 'saveEdge': True/False (overrides the global saveEdgeSpecies above)
249+
#
250+
# Chemkin writer: always on by default; saves every iteration.
251+
generateChemkin=True,
252+
# generateChemkin={'saveInterval': -1, 'verboseComments': True, 'saveEdge': True},
253+
#
254+
# RMS YAML writer: always on by default; saves every iteration.
255+
generateRMSYAML=True,
256+
# generateRMSYAML={'saveInterval': -1},
257+
#
258+
# Cantera YAML v1 writer: off by default.
259+
generateCanteraYAML1=False,
260+
# generateCanteraYAML1={'saveInterval': -1, 'verboseComments': True, 'saveEdge': False},
261+
#
262+
# Cantera YAML v2 writer: off by default.
263+
generateCanteraYAML2=False,
264+
# generateCanteraYAML2={'saveInterval': 1, 'verboseComments': True, 'saveEdge': True},
241265
)
242266

243267
# optional module allows for correction to unimolecular reaction rates at low pressures and/or temperatures.

examples/rmg/diesel/input.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,9 @@
8686
units='si',
8787
generateOutputHTML=False,
8888
generatePlots=False,
89+
# Large model: write output every 5 iterations and skip edge species to reduce I/O
90+
generateChemkin={'saveInterval': 5, 'saveEdge': False},
91+
generateRMSYAML={'saveInterval': 5},
92+
generateCanteraYAML1={'saveInterval': 10},
93+
generateCanteraYAML2={'saveInterval': 10},
8994
)

examples/rmg/e85/input.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,9 @@
8787
units='si',
8888
generateOutputHTML=False,
8989
generatePlots=False,
90+
generateChemkin={'saveInterval': 5, 'saveEdge': True},
91+
generateRMSYAML={'saveInterval': 5},
92+
generateCanteraYAML1={'saveInterval': 5},
93+
generateCanteraYAML2={'saveInterval': 5},
9094
)
9195

examples/rmg/heptane-eg5/input.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
thermoLibraries = ['primaryThermoLibrary'],
44
reactionLibraries = [],
55
seedMechanisms = [],
6-
kineticsDepositories = ['training'],
6+
kineticsDepositories = ['training'],
77
kineticsFamilies = 'default',
88
kineticsEstimator = 'rate rules',
99
)
@@ -71,4 +71,12 @@
7171
interpolation=('Chebyshev', 6, 4),
7272
)
7373

74-
74+
options(
75+
units='si',
76+
generateOutputHTML={'saveInterval': 10, 'saveEdge': True},
77+
generatePlots=False,
78+
generateChemkin={'saveInterval': 1, 'saveEdge': False},
79+
generateRMSYAML={'saveInterval': 5},
80+
generateCanteraYAML1={'saveInterval': 5, 'saveEdge': True},
81+
generateCanteraYAML2={'saveInterval': 10, 'saveEdge': True},
82+
)

rmgpy/__main__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ def main():
6262

6363
kwargs = {
6464
'restart': args.restart,
65-
'walltime': args.walltime,
6665
'maxproc': args.maxproc,
6766
'kineticsdatastore': args.kineticsdatastore,
68-
'max_iterations': args.maxiter,
6967
}
68+
if args.walltime is not None:
69+
kwargs['walltime'] = args.walltime
70+
if args.maxiter is not None:
71+
kwargs['max_iterations'] = args.maxiter
7072

7173
if args.profile:
7274
import cProfile

0 commit comments

Comments
 (0)