Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 51 additions & 4 deletions documentation/source/users/rmg/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1073,13 +1073,17 @@ Miscellaneous options::
units='si',
generateOutputHTML=True,
generatePlots=False,
generatePESDiagrams=False,
generatePESDiagrams=False,
saveSimulationProfiles=True,
verboseComments=False,
saveEdgeSpecies=True,
keepIrreversible=True,
trimolecularProductReversible=False,
saveSeedModulus=-1
saveSeedModulus=-1,
generateChemkin=True,
generateRMSYAML=True,
generateCanteraYAML1=False,
generateCanteraYAML2=False,
)

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

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.

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.
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).

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.
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).

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.

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

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``.

Per-writer Output Configuration
--------------------------------

Each of the following options controls a separate output-format writer. Each
accepts ``True``, ``False``, or a Python dict with optional keys:

* ``'saveInterval'`` *(int)* — positive N writes every N iterations (iteration
numbering starts at 0); ``-1`` writes only at the very end of the run.
Defaults to ``1`` (every iteration) for writers that are on by default.
* ``'verboseComments'`` *(bool, optional)* — overrides the global
``verboseComments`` flag for this writer only.
* ``'saveEdge'`` *(bool, optional)* — overrides the global ``saveEdgeSpecies``
flag for this writer only.

Examples::

# Chemkin: save only at the end, with verbose comments and edge species
generateChemkin={'saveInterval': -1, 'verboseComments': True, 'saveEdge': True}

# RMS YAML: save every 5 iterations
generateRMSYAML={'saveInterval': 5}

# Cantera YAML v2: save every iteration with verbose comments
generateCanteraYAML2={'saveInterval': 1, 'verboseComments': True, 'saveEdge': False}

``generateChemkin`` (default ``True``)
Controls the Chemkin writer. Output is written to the ``chemkin/`` folder.

``generateRMSYAML`` (default ``True``)
Controls the RMS YAML writer. Output is written to the ``rms/`` folder.

``generateCanteraYAML1`` (default ``False``)
Controls the Cantera YAML v1 writer. Output is written to the ``cantera1/``
folder. This writer is disabled by default.

``generateCanteraYAML2`` (default ``False``)
Controls the Cantera YAML v2 writer. Output is written to the ``cantera2/``
folder. This writer is disabled by default.

``generateOutputHTML`` (default ``False``)
Controls the HTML species-visualisation writer. Output is written to the
``species/`` folder. Accepts ``True``/``False`` or the same dict format.

Species Constraints
=====================

Expand Down
6 changes: 3 additions & 3 deletions documentation/source/users/rmg/running.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ at the command line will print the documentation from ``util.py``, which is repr
-P, --postprocess postprocess profiling statistics from previous
[failed] run; does not run the simulation
-t DD:HH:MM:SS, --walltime DD:HH:MM:SS
set the maximum execution time
set the maximum execution time (overrides input.py if provided)
-i MAXITER, --maxiter MAXITER
set the maximum number of RMG iterations
set the maximum number of RMG iterations (overrides input.py if provided)
-n MAXPROC, --maxproc MAXPROC
max number of processes used during reaction
generation
Expand All @@ -73,7 +73,7 @@ Run with multiprocessing for reaction generation and QMTP::

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

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

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

Expand Down
5 changes: 5 additions & 0 deletions examples/rmg/1,3-hexadiene/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@
generateOutputHTML=False,
generatePlots=False,
generatePESDiagrams=True,
# Large model: write output every 5 iterations and skip edge species to reduce I/O
generateChemkin={'saveInterval': 1, 'saveEdge': False},
generateRMSYAML={'saveInterval': 5},
generateCanteraYAML1={'saveInterval': 5},
generateCanteraYAML2={'saveInterval': 5},
)
4 changes: 2 additions & 2 deletions examples/rmg/MR_test/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@
#Sets a time limit in the form DD:HH:MM:SS after which the RMG job will stop. Useful for profiling on jobs that
#do not converge.
#wallTime = '00:00:00',
#When keepIrreversible=False (default), forces RMG to import library reactions as reversible.
#Otherwise, if set to True, RMG will import library reactions while keeping the reversibility as specified.
keepIrreversible=False,
#Forces RMG to import library reactions as reversible (default). Otherwise, if set to True, RMG will import library
#reactions while keeping the reversibility as as.
)

# optional module allows for correction to unimolecular reaction rates at low pressures and/or temperatures.
Expand Down
5 changes: 5 additions & 0 deletions examples/rmg/ch3no2/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,13 @@
)

simulator(atol=1e-16,rtol=1e-8)

options(
units='si',
generateOutputHTML=False,
generatePlots=False,
# Large model: write output every 5 iterations to reduce I/O
generateChemkin={'saveInterval': 5, 'saveEdge': False},
generateRMSYAML={'saveInterval': 5},
generateCanteraYAML2={'saveInterval': 10, 'saveEdge': True},
)
44 changes: 34 additions & 10 deletions examples/rmg/commented/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,23 +221,47 @@
generatePESDiagrams=False,
# saves mole fraction of species in 'solver/' to help you create plots
saveSimulationProfiles=False,
# gets RMG to output comments on where kinetics were obtained in the chemkin file.
# useful for debugging kinetics but increases memory usage of the chemkin output file
# Global fallback for verbose comments (comments on where kinetics were obtained).
# Useful for debugging kinetics but increases output file size.
# Individual writers can override this with their own verboseComments key.
verboseComments=False,
# gets RMG to generate edge species chemkin files. Uses lots of memory in output.
# Helpful for seeing why some reaction are not appearing in core model.
# Global fallback for saving edge-species files. Uses lots of memory in output.
# Helpful for seeing why some reactions are not appearing in the core model.
# Individual writers can override this with their own saveEdge key.
saveEdgeSpecies=False,
# Sets a time limit in the form DD:HH:MM:SS after which the RMG job will stop. Useful for profiling on jobs that
# do not converge.
# wallTime = '00:00:00',
# Forces RMG to import library reactions as reversible (default). Otherwise, if set to True, RMG will import library
# reactions while keeping the reversibility as as.
# Sets a time limit in the form DD:HH:MM:SS after (or shortly before) which the RMG job will stop.
# Useful for profiling on jobs that do not converge.
wallTime = '00:00:00:00',
# If keepIrreversible=False (default) forces RMG to import library reactions as reversible.
# If set to True, RMG will import library reactions while keeping the reversibility as specified.
keepIrreversible=False,
# Allows families with three products to react in the diverse direction (default).
trimolecularProductReversible=True,
# Allows a seed to be saved every n iterations.
# The default of -1 causes the iteration to only be saved at the end of the RMG job
saveSeedModulus=-1
saveSeedModulus=-1,
#
# --- Per-writer output configuration ---
# Each writer accepts True/False or a dict with keys:
# 'saveInterval': N (positive = every N iterations; -1 = end of run only)
# 'verboseComments': True/False (overrides the global verboseComments above)
# 'saveEdge': True/False (overrides the global saveEdgeSpecies above)
#
# Chemkin writer: always on by default; saves every iteration.
generateChemkin=True,
# generateChemkin={'saveInterval': -1, 'verboseComments': True, 'saveEdge': True},
#
# RMS YAML writer: always on by default; saves every iteration.
generateRMSYAML=True,
# generateRMSYAML={'saveInterval': -1},
#
# Cantera YAML v1 writer: off by default.
generateCanteraYAML1=False,
# generateCanteraYAML1={'saveInterval': -1, 'verboseComments': True, 'saveEdge': False},
#
# Cantera YAML v2 writer: off by default.
generateCanteraYAML2=False,
# generateCanteraYAML2={'saveInterval': 1, 'verboseComments': True, 'saveEdge': True},
)

# optional module allows for correction to unimolecular reaction rates at low pressures and/or temperatures.
Expand Down
5 changes: 5 additions & 0 deletions examples/rmg/diesel/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,9 @@
units='si',
generateOutputHTML=False,
generatePlots=False,
# Large model: write output every 5 iterations and skip edge species to reduce I/O
generateChemkin={'saveInterval': 5, 'saveEdge': False},
generateRMSYAML={'saveInterval': 5},
generateCanteraYAML1={'saveInterval': 10},
generateCanteraYAML2={'saveInterval': 10},
)
4 changes: 4 additions & 0 deletions examples/rmg/e85/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,9 @@
units='si',
generateOutputHTML=False,
generatePlots=False,
generateChemkin={'saveInterval': 5, 'saveEdge': True},
generateRMSYAML={'saveInterval': 5},
generateCanteraYAML1={'saveInterval': 5},
generateCanteraYAML2={'saveInterval': 5},
)

12 changes: 10 additions & 2 deletions examples/rmg/heptane-eg5/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
thermoLibraries = ['primaryThermoLibrary'],
reactionLibraries = [],
seedMechanisms = [],
kineticsDepositories = ['training'],
kineticsDepositories = ['training'],
kineticsFamilies = 'default',
kineticsEstimator = 'rate rules',
)
Expand Down Expand Up @@ -71,4 +71,12 @@
interpolation=('Chebyshev', 6, 4),
)


options(
units='si',
generateOutputHTML={'saveInterval': 10, 'saveEdge': True},
generatePlots=False,
generateChemkin={'saveInterval': 1, 'saveEdge': False},
generateRMSYAML={'saveInterval': 5},
generateCanteraYAML1={'saveInterval': 5, 'saveEdge': True},
generateCanteraYAML2={'saveInterval': 10, 'saveEdge': True},
)
6 changes: 4 additions & 2 deletions rmgpy/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,13 @@ def main():

kwargs = {
'restart': args.restart,
'walltime': args.walltime,
'maxproc': args.maxproc,
'kineticsdatastore': args.kineticsdatastore,
'max_iterations': args.maxiter,
}
if args.walltime is not None:
kwargs['walltime'] = args.walltime
if args.maxiter is not None:
kwargs['max_iterations'] = args.maxiter

if args.profile:
import cProfile
Expand Down
16 changes: 11 additions & 5 deletions rmgpy/chemkin.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2272,10 +2272,12 @@ def save_chemkin(reaction_model, path, verbose_path, dictionary_path=None, trans
save_transport_file(transport_path, species_list)


def save_chemkin_files(rmg):
def save_chemkin_files(rmg, config=None):
"""
Save the current reaction model to a set of Chemkin files.
"""
verbose = config.verbose_comments if (config and config.verbose_comments is not None) else rmg.verbose_comments
save_edge = config.save_edge if (config and config.save_edge is not None) else rmg.save_edge_species

# todo: make this an attribute or method of reactionModel
is_surface_model = any([s.contains_surface_site() for s in rmg.reaction_model.core.species])
Expand Down Expand Up @@ -2310,7 +2312,7 @@ def save_chemkin_files(rmg):
os.unlink(latest_chemkin_path)
shutil.copy2(this_chemkin_path, latest_chemkin_path)

if rmg.save_edge_species:
if save_edge:
logging.info('Saving current model core and edge to Chemkin file...')
this_chemkin_path = os.path.join(rmg.output_directory, 'chemkin',
'chem_edge{0:04d}.inp'.format(len(rmg.reaction_model.core.species)))
Expand All @@ -2319,7 +2321,7 @@ def save_chemkin_files(rmg):
latest_dictionary_path = os.path.join(rmg.output_directory, 'chemkin', 'species_edge_dictionary.txt')
latest_transport_path = None
save_chemkin(rmg.reaction_model, this_chemkin_path, latest_chemkin_verbose_path, latest_dictionary_path,
latest_transport_path, rmg.save_edge_species)
latest_transport_path, save_edge)

if is_surface_model:
paths = []
Expand Down Expand Up @@ -2386,9 +2388,13 @@ class ChemkinWriter(object):
rmg.detach(listener)

"""
def __init__(self, output_directory=''):
def __init__(self, output_directory='', config=None):
super(ChemkinWriter, self).__init__()
self.config = config
make_output_subdirectory(output_directory, 'chemkin')

def update(self, rmg):
save_chemkin_files(rmg)
if self.config is not None and not self.config.should_write(
rmg.reaction_model.iteration_num, rmg.is_final_save):
return
save_chemkin_files(rmg, config=self.config)
Loading
Loading