docs[next]: add a shallow water model example notebook - #2749
Draft
havogt wants to merge 2 commits into
Draft
Conversation
Port the NCAR/SWM shallow water benchmark to a single gt4py.next notebook, alongside a NumPy reference and the 16x16 reference state after the full 4000-step run. Periodicity is applied outside GT4Py for now, which keeps the example free of any src/ changes.
The scheme is verified against Sadourny (1975) Eq. 4 -- cu, cv, h, z are his U, V, H and eta term for term. The constants are not from the paper, and the 'Swarztrauber 1984' attribution came from a code comment in NCAR/SWM rather than from any reference, so point at the benchmark repo instead.
Contributor
Author
|
Corrected the provenance note. The earlier text credited the configuration to "Paul Swarztrauber's 1984 NCAR benchmark setup" — that came from a code-header comment in Now that I have the paper, two things are settled:
The notebook now attributes the scheme to Sadourny and the configuration to NCAR/SWM, without inventing a person in between. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the NCAR SWM shallow water benchmark as a single
gt4py.nextnotebook. First of a small stack; this one is a pureexamples/addition with nosrc/changes.Contents
examples/swm.ipynbexamples/swm_numpy.pyexamples/swm_reference.npzu,v,pafter 4000 steps, 16x16The model is doubly periodic on an Arakawa C-grid, leapfrog with a Robert-Asselin filter, integrated by one fused field operator producing all six updated fields.
Periodicity is outside GT4Py here
The halo is refreshed in NumPy after each step. Expressing the wrap inside the field operator needs
f(I + M)withMa program argument, which the frontend rejects at FOAST construction — that is deliberately deferred to a later PR in this stack so this one carries no frontend risk.Validation
Two levels, because the full benchmark is too slow for CI:
RUN_FULL_BENCHMARK = True) — the full 4000 steps againstswm_reference.npz. ~20 s.I ran the opt-in check before opening this; it passes. Measured differences, against peak
|u|,|v| ~ 3.8and|p| ~ 5e4:uatol=1e-11vatol=1e-11patol=1e-8The two implementations sum the same terms in a different order, so they agree to rounding rather than bit-for-bit. Tolerances are absolute because
uandvcross zero, and are set with ~30x headroom for portability across the CI matrix.The NumPy reference is itself checked against the NCAR data: it reproduces
ref/16x16/{u,v,p}.step4000.final.binto 1.1e-12 / 8.2e-13 / 2.6e-10.Notes
swm_reference.npzis derived fromNCAR/SWMref/16x16, which is Apache-2.0; provenance is recorded in the notebook.dt=90,dx=1e5,alpha=0.001, …) are Swarztrauber's 1984 NCAR benchmark configuration rather than results from the paper — the notebook says so, since the distinction is easy to get wrong.examples/conventions: license header as a markdown cell, embedded backend by default with compiled ones commented out, outputs and execution counts stripped.pytest --nbmake examplespasses (5 notebooks, 21 s).Next in the stack
*_staggeredoperator pairs using staggered dimensions