Skip to content

Commit 35ac761

Browse files
authored
Merge pull request #2909 from ReactionMechanismGenerator/auto_db
Added the auto-database feature
2 parents bac23ad + 23b1719 commit 35ac761

8 files changed

Lines changed: 2117 additions & 26 deletions

File tree

documentation/source/users/rmg/input.rst

Lines changed: 80 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,17 +204,92 @@ The last section is specifying that RMG is estimating kinetics of reactions from
204204
kineticsEstimator = 'rate rules'
205205

206206

207-
The following is an example of a database block, based on above chosen libraries and options::
207+
.. _auto_library_selection:
208+
209+
Automatic Library and Family Selection
210+
--------------------------------------
211+
Instead of manually listing every library, you can let RMG choose the appropriate
212+
thermo libraries, kinetics libraries, transport libraries, seed mechanisms, and
213+
kinetics families automatically based on the species and reactor conditions in your
214+
input file. Use the ``'auto'`` keyword in any library field::
208215

209216
database(
210-
thermoLibraries = ['primaryThermoLibrary', 'GRI-Mech3.0'],
211-
reactionLibraries = [('Glarborg/C3',False)],
212-
seedMechanisms = ['GRI-Mech3.0'],
217+
thermoLibraries = 'auto',
218+
reactionLibraries = 'auto',
219+
transportLibraries = 'auto',
220+
seedMechanisms = 'auto',
221+
kineticsFamilies = 'auto',
213222
kineticsDepositories = ['training'],
214-
kineticsFamilies = 'defult',
215223
kineticsEstimator = 'rate rules',
216224
)
217225

226+
When ``'auto'`` is specified, RMG analyzes the initial species and reactor
227+
conditions to detect the chemistry present (e.g., nitrogen, sulfur, oxygen,
228+
halogens, surface, liquid phase) and selects the relevant library sets.
229+
The triggered sets and their corresponding libraries are logged at the start
230+
of the RMG run.
231+
232+
.. note::
233+
Non-reactive species (those declared with ``reactive=False``, such as bath
234+
gases) are skipped during chemistry detection and will not trigger any
235+
chemistry sets on their own. For example, using N\ :sub:`2` purely as a
236+
bath gas will not pull in the nitrogen library — the nitrogen set is
237+
triggered only when a reactive species containing nitrogen is present.
238+
239+
**Mixing manual and auto selection.** You can combine user-specified libraries
240+
with ``'auto'`` in a list. The position of ``'auto'`` controls the priority:
241+
libraries before it have higher priority, libraries after it have lower::
242+
243+
thermoLibraries = ['myCustomLib', 'auto']
244+
245+
thermoLibraries = ['auto', 'myFallbackLib']
246+
247+
If a library you listed manually also appears in the auto-selected set, it will
248+
not be added twice. It keeps the position you gave it, and the auto-selected
249+
copy is skipped.
250+
251+
**PAH libraries and the ``<PAH_libs>`` keyword.**
252+
The auto-selection splits high-temperature C/H chemistry into two tiers:
253+
254+
* **CH_pyrolysis_core** — fundamental high-T radical and small-molecule chemistry
255+
(e.g., acetylene initiation, alkane cracking). Always included when carbon is
256+
present and the maximum reactor temperature is at least 800 K.
257+
* **PAH_formation** — aromatic ring formation, naphthalene pathways (CPD + HACA),
258+
and larger PAH growth. This is a large set (~70 kinetics libraries) that can
259+
significantly increase model size and generation time.
260+
261+
For **pure C/H pyrolysis** (no oxygen in any input species), both tiers are
262+
included automatically — PAH formation is expected in such systems.
263+
264+
For **oxygenated systems** (any species contains O, including oxygenated fuels
265+
like ethanol or DME), only CH_pyrolysis_core is included by default because
266+
PAH chemistry is typically a minor pathway. If you know your system forms
267+
significant amounts of aromatics (e.g., fuel-rich partial oxidation), you can
268+
explicitly request the PAH libraries by adding the ``'<PAH_libs>'`` keyword
269+
to any library field::
270+
271+
database(
272+
thermoLibraries = ['auto', '<PAH_libs>'],
273+
reactionLibraries = ['auto', '<PAH_libs>'],
274+
seedMechanisms = 'auto',
275+
transportLibraries = 'auto',
276+
kineticsFamilies = 'auto',
277+
)
278+
279+
The ``'<PAH_libs>'`` keyword is consumed during processing (it does not appear
280+
in the final library list) — it only serves as a signal to include the
281+
PAH_formation set. It can be placed anywhere in the list; its position does
282+
not affect library priority.
283+
284+
**Previewing the selection.** A Jupyter notebook is provided at
285+
:file:`ipython/auto_library_selection.ipynb` that lets you preview exactly which
286+
libraries and families RMG would choose for a given input file, without running
287+
the full job.
288+
289+
.. note::
290+
The ``'auto'`` keyword is opt-in. If you do not use it you must list every library explicitly.
291+
292+
218293
.. _species_list:
219294

220295
List of species
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Same chemistry as the ``superminimal`` example (H2/O2 at 1000 K), but with
2+
# every database field set to ``'auto'`` so RMG selects libraries, seed
3+
# mechanisms, transport data, and kinetics families automatically based on
4+
# the species and reactor conditions.
5+
database(
6+
thermoLibraries = 'auto',
7+
reactionLibraries = 'auto',
8+
seedMechanisms = 'auto',
9+
transportLibraries = 'auto',
10+
kineticsFamilies = 'auto',
11+
kineticsDepositories = ['training'],
12+
kineticsEstimator = 'rate rules',
13+
)
14+
15+
# List of species
16+
species(
17+
label='H2',
18+
reactive=True,
19+
structure=SMILES("[H][H]"),
20+
)
21+
species(
22+
label='O2',
23+
reactive=True,
24+
structure=SMILES("[O][O]"),
25+
)
26+
27+
# Reaction systems
28+
simpleReactor(
29+
temperature=(1000,'K'),
30+
pressure=(1.0,'bar'),
31+
initialMoleFractions={
32+
'H2':.67, 'O2':.33,
33+
},
34+
terminationConversion={
35+
'H2': 0.9,
36+
},
37+
terminationTime=(1e6,'s'),
38+
)
39+
40+
simulator(
41+
atol=1e-16,
42+
rtol=1e-8,
43+
)
44+
45+
model(
46+
toleranceKeepInEdge=0.0,
47+
toleranceMoveToCore=0.001,
48+
toleranceInterruptSimulation=0.001,
49+
maximumEdgeSpecies=100000,
50+
)
51+
52+
options(
53+
units='si',
54+
generateOutputHTML=True,
55+
generatePlots=False,
56+
saveEdgeSpecies=True,
57+
saveSimulationProfiles=True,
58+
)

0 commit comments

Comments
 (0)