Skip to content

Examples: 1D reacting shock tube with AMR following the front on temperature - #2385

Draft
sbryngelson wants to merge 6 commits into
MFlowCode:masterfrom
sbryngelson:amr-flame-example
Draft

sbryngelson wants to merge 6 commits into
MFlowCode:masterfrom
sbryngelson:amr-flame-example

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

AI-assisted (Claude Code). For #2313. Part of #2247.

Stacked on #2366 (temperature tagging): until that merges, this PR's diff contains it too. Review the commit "Add examples/1D_amr_reactive_shocktube".

What

A new example, examples/1D_amr_reactive_shocktube: the existing 1D_reactive_shocktube (H2/O2/Ar, h2o2.yaml) with one 2:1 AMR level that regrids on temperature (amr_tag_var = 6). An incident shock reflects off the wall at x = 0, the gas behind the reflected shock ignites at about 125 µs, and a reacting front follows the shock into the tube. The refined blocks track the incident shock, then the reflected shock, then the ignition region and the front. --no-amr runs the same case on a uniform grid at the fine resolution. amr.md lists it with the other complete AMR cases.

It is a reacting shock tube rather than a flame: it uses a mechanism and case MFC already has. At the final time the front moves at about 800 to 900 m/s, short of a detonation.

How it was checked

Frontier CPU, one rank. Level-1 blocks (coarse cells) from the restart files:

t (µs) Level-1 blocks Fine cells Covering
15 [154,164] 22 incident shock
77 [4,9] 12 after reflection, near the wall
108 [46,56] 22 reflected shock
124 [4,41] [42,78] 150 ignition
155 [4,9] [51,67] [116,126] 68 wall, reacting front, reflected shock

Against the uniform 800-cell run at 155 µs:

AMR uniform fine difference
Reflected shock 36.500 mm 36.445 mm 0.37 fine cells
Reacting front (H2O at half its maximum) 17.627 mm 17.523 mm 0.7 fine cells
Peak temperature away from the wall 2149.0 K 2151.7 K -0.12%
Time per step 3.05 ms 5.29 ms AMR at 0.58

The example is skipped in the test suite with the other AMR examples (the test grid cap cannot hold a block, and it runs 25k steps); 1D -> Chemistry -> Reactive Shocktube AMR -> Tag Temperature from #2366 tests the same case. ./mfc.sh precheck passes; the AMR group passes (119 tests).

Limitation found

The example stops at 155 µs, not the original example's 230 µs. AMR does not allow reaction sub-stepping (chem_params%reaction_substeps must be 0), and without sub-stepping this flow goes to NaN at about 170 µs, with or without AMR (uniform fine grid alike) and almost regardless of dt (0.02, 0.01, 0.005 of the fine-cell crossing time: 170, 172, 184 µs). With reaction_substeps = 4 the uniform case runs to 230 µs. So the limit is the explicit reaction source, which AMR inherits because it cannot sub-step. The case file says so.

Not checked

Multi-rank, GPU and case-optimized runs of the example; what triggers the failure near 170 µs; comparison with published profiles.

The tag sweep called the indicator per cell, which evaluated the tagged
variable at the cell and its neighbours through function calls: seven
evaluations per cell in 3D. Evaluate it once per cell into a local array
and difference that. Same tags.
amr_tag_var = 5 tags where the vorticity magnitude times the cell size
exceeds amr_tag_eps (central velocity differences, one-sided at a clamped
block edge); 6 tags on the temperature and 7 on the mass fraction of
species amr_tag_species (chemistry). Tests: a Gresho vortex of uniform
density tracked on two levels, and the reactive shocktube regridded onto
its temperature jump.
# Conflicts:
#	src/simulation/m_amr_nest.fpp
#	src/simulation/m_amr_regrid.fpp
# Conflicts:
#	toolchain/mfc/test/cases.py
…ng front tagged on temperature

The reactive shock tube with one 2:1 level regridded every 20 steps on
amr_tag_var = 6. Against a uniform grid at the fine resolution at 155 us:
reflected shock 0.06 mm and reacting front 0.10 mm apart (fine cell
0.15 mm), peak temperature 2291 K against 2278 K (wall strip, coarse
under AMR). Skipped by the Example suite like the other AMR examples;
listed in amr.md.
@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_amr_nest.fpp 495 +48
src/simulation/m_amr_regrid.fpp 941 +4
src/simulation/m_checker.fpp 77 +1
src/simulation/m_global_parameters.fpp 963 +1
Directory Lines Diff
simulation 41214 +54
total 61284 +54

@github-actions

Copy link
Copy Markdown

Claude Code Review

Head SHA: a38ea46

Files changed:

  • 12
  • docs/documentation/amr.md
  • docs/documentation/case.md
  • examples/1D_amr_reactive_shocktube/case.py
  • src/simulation/m_amr_nest.fpp
  • src/simulation/m_amr_regrid.fpp
  • src/simulation/m_checker.fpp
  • src/simulation/m_global_parameters.fpp
  • toolchain/mfc/case_validator.py
  • toolchain/mfc/params/definitions.py
  • toolchain/mfc/params/descriptions.py

Findings:
No issues found. Checked in step 4: m_amr_nest.fpp, m_amr_regrid.fpp, m_checker.fpp, m_global_parameters.fpp, descriptions.py, amr.md and the example case.py.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant