Cantera Ignition Delay

Cantera Ignition Delay

by:

@OpenSourceBuffGuy

📚 Education & Research

Guides an agent to run Cantera homogeneous reactor simulations and compute ignition delay with mechanism provenance, conservation checks and numerical refinement.

Skill files4 files

assets/

references/

scripts/

SKILL.md140 lines
1
---
2
name: cantera
3
description: Runs Cantera homogeneous chemical reactors and evaluates ignition delay with mechanism provenance, conservation checks, and numerical refinement. Use for combustion kinetics, closed adiabatic ideal-gas constant-volume or constant-pressure ignition, temperature histories, or mechanism-specific ignition-delay comparisons.
4
license: MIT
5
compatibility: Requires Python 3.12-3.14, Cantera 3.2.0, and NumPy. Installation needs network access; simulations run locally without credentials. Custom mechanisms must be available as Cantera YAML files.
6
metadata:
7
version: "1.1"
8
skill-author: K-Dense Inc.
9
tested-package-version: "3.2.0"
10
last-reviewed: "2026-09-30"
11
---
12
13
# Cantera: homogeneous ignition calculations
14
15
## When to use
16
17
Use for a closed, adiabatic, homogeneous ideal-gas reactor with a known kinetic mechanism,
18
initial temperature, pressure, and mole composition. The bundled helper runs both constant
19
volume and constant pressure cases and reports a precisely defined temperature-based delay.
20
It is not a flame solver or a general reactor-network builder.
21
22
A calculation completing successfully establishes numerical execution, not mechanism
23
validity for the fuel, pressure, temperature, diluent, or measured ignition observable.
24
Read [references/interpretation.md](references/interpretation.md) when choosing a mechanism,
25
comparing experiments, or interpreting unresolved/two-stage ignition.
26
27
## Workflow
28
29
1. Identify the mechanism and its validated condition range. Preserve its source, version,
30
citation, and any modifications. Check that its phase is `ideal-gas` and that every
31
reactant, diluent, and tracked species exists. For custom YAML with imports, retain the
32
original dependency files as well as the generated phase snapshot. Custom Python rate
33
extensions additionally need their original code and environment for replay.
34
2. Choose constant volume or constant pressure from the physical experiment. Supply K,
35
Pa, seconds, and mole amounts explicitly. `mole_amounts` is normalized to mole fractions;
36
it is not a mass-fraction mapping. The report includes the normalized initial composition.
37
3. Copy [assets/hydrogen-ignition.json](assets/hydrogen-ignition.json) and change its conditions.
38
The supplied H2/O2/Ar case uses Cantera's bundled `h2o2.yaml` for an executable numerical
39
example; it is not a recommendation for every hydrogen experiment.
40
4. Set a time horizon long enough to observe the temperature rise and the decline of the
41
heating-rate peak. Choose output spacing fine enough to locate that peak. Set a minimum
42
temperature rise to distinguish ignition from negligible heating or numerical noise.
43
5. Run the helper and inspect all four histories and the report. Refine again if the delay
44
changes materially, if the maximum approaches a time boundary, or if conservation fails.
45
Compare the temperature and tracked-species histories with the actual ignition definition.
46
6. Report the condition set, mechanism hash, reactor constraint, delay definition, output
47
spacing, numerical changes, and scientific limits together with the delay.
48
49
## Execute the tested example
50
51
From the collection root:
52
53
```bash
54
uv run --no-project --python 3.12 --with cantera==3.2.0 --with numpy==2.5.3 \
55
python skills/cantera/scripts/ignition_delay.py \
56
skills/cantera/assets/hydrogen-ignition.json hydrogen-result
57
```
58
59
Tested on Python 3.12, Cantera 3.2.0, and NumPy 2.5.3. No external solver executable or
60
credentials are needed. Local relative mechanism paths resolve against the configuration
61
file directory before Cantera's built-in data search. Use a new output directory each run.
62
63
The 1000 K, 101325 Pa, H2:O2:Ar = 2:1:7 constant-volume example gives about **0.313 ms**
64
using the stated `max(dT/dt)` definition. At 3 ms its temperature is approximately
65
2920.67 K and agrees with a separate `UV` equilibrium calculation. These are package
66
regression values, not experimental validation data.
67
68
## Exact delay and refinement contract
69
70
Delay is the time of the global maximum of `numpy.gradient(T, time, edge_order=2)` on
71
a uniform output grid. It is reported only if the maximum temperature rise reaches
72
`minimum_temperature_rise_k` and the maximum is at least two sample indices from each
73
boundary. Otherwise `delay_s` is null and a status explains why. No delay beyond the
74
simulation horizon is extrapolated.
75
76
The helper explicitly uses Cantera 3.2's `clone=True` and reads evolving properties from
77
`reactor.phase`. The original `Solution` retains the initial state; do not read it as
78
the reactor's final state. `ReactorNet.advance(t)` requests an absolute time, and no
79
advance limits are configured, so the output grid remains uniform.
80
81
It runs four independent fresh reactors:
82
83
| Run | Change from configured conditions |
84
| --- | --- |
85
| baseline | Original settings |
86
| finer_output | Half output spacing, same horizon and solver controls |
87
| tighter_solver | Both solver tolerances divided by ten; maximum internal time step halved |
88
| longer_horizon | Twice the horizon with the original output spacing |
89
90
`numerically_resolved` requires all runs to yield delays, relative delay changes within
91
`delay_relative_tolerance`, and all conservation checks to pass. Agreement on a discrete
92
grid is not a statistical error bar: also report the output spacing. The baseline samples
93
must be between 11 and 50000, leaving room for refinement. Runtime grows with mechanism
94
size, stiffness, and the chosen horizon; integration failures retain Cantera's error text.
95
96
## Outputs and checks
97
98
- `report.json`: all input settings, package versions, configuration and mechanism hashes,
99
normalized starting composition, four delay estimates, numerical changes, conservation,
100
and mechanism thermodynamic temperature bounds.
101
- `baseline.csv`, `finer_output.csv`, `tighter_solver.csv`, `longer_horizon.csv`: time,
102
temperature, pressure, volume, mass, total internal energy, total enthalpy, and requested
103
species mole fractions.
104
- `mechanism.yaml`: a Cantera-written snapshot of the loaded phase, species, and reactions.
105
The helper requests `write_yaml(precision=17)` and saves the exact UTF-8 bytes it hashes,
106
without platform newline conversion. The report also hashes the located original
107
mechanism file. Imported source dependencies are not separately hashed; the snapshot
108
captures the loaded model. Its generated header includes a date, so the snapshot hash
109
identifies the saved artifact and need not match between otherwise identical reruns.
110
111
Closed reactors conserve mass and elemental mass fractions. The constant-volume case
112
checks total internal energy; the constant-pressure case checks total enthalpy. Energy
113
error is divided by `max(abs(initial_energy_J), 1 J)`. Diagnostic tolerances are mass
114
relative drift <1e-8, elemental absolute drift <1e-8, energy scaled drift <1e-6, species
115
mass-fraction sum error <1e-8, and species mass fractions >-1e-10. These checks expose
116
numerical issues and do not measure kinetic-model uncertainty.
117
118
Check `within_thermo_temperature_range` separately: it checks saved output states, not
119
every internal integration state. Numerical resolution does not mean species thermodynamic
120
fits stayed within their temperature bounds. The helper cannot assess pressure-dependent
121
kinetic validity from these bounds.
122
123
## Scope and upstream references
124
125
The suite covers both reactor constraints, conservation, final-state agreement with
126
independent Cantera equilibrium, nonigniting conditions, unresolved boundary maxima,
127
refinement, snapshot replay, and invalid composition/conditions. It does not validate
128
shock-tube heat loss, real-gas effects, surfaces, flow devices, flames, or multistage
129
experimental ignition definitions. Build those models only with the necessary physics
130
and their own checks; do not relabel this helper's result as one of them.
131
132
- [Reactor model equations](https://cantera.org/stable/reference/reactors/index.html)
133
- [Python reactor API](https://cantera.org/stable/python/zerodim.html)
134
- [Thermodynamic properties and equilibrium](https://cantera.org/stable/python/thermo.html)
135
- [Phase serialization API](https://cantera.org/stable/python/importing.html#cantera.Solution.write_yaml)
136
- [Custom extension registration](https://cantera.org/stable/python/utilities.html#cantera.extension)
137
- [Cantera 3.2 release notes](https://cantera.org/stable/reference/releasenotes/v3.2.html)
138
- [Upstream ignition example](https://cantera.org/stable/examples/python/reactors/non_ideal_shock_tube.html)
139
uses a species mass-fraction peak; its delay definition differs from this helper's dT/dt peak.
140

© K-Dense Inc. · MIT · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…