Skip to content

Generate SW4 input files from a realisation - #141

Draft
lispandfound wants to merge 1 commit into
nzvm/sw4-configfrom
nzvm/sw4-template
Draft

Generate SW4 input files from a realisation#141
lispandfound wants to merge 1 commit into
nzvm/sw4-configfrom
nzvm/sw4-template

Conversation

@lispandfound

Copy link
Copy Markdown
Contributor

create-sw4-input renders the SW4 input file for a realisation: the
grid, the refinement stack, the source, the stations, and whatever
commands the sw4 section carries.

The requested domain becomes the grid's interior. The grid is padded
laterally by one supergrid width on each side, so the sponge sits
outside the region anyone asked to simulate rather than eating into it.

adjust_for_topography handles the interaction between topography and
the refinement stack. Topography lifts the top of the grid above z=0,
which thins the first layer; SW4 requires every grid in the stack to
hold at least nz_min cells, so any layer left too thin is pushed down
until it does. The topography surface participates in that count as a
boundary but is not itself returned as a refinement -- the caller gets
back the real layers plus the depth used.

Commands come from the realisation rather than being hard-coded, so a
run can add or override any SW4 command without a code change. Output
commands that take a time window are merged with the simulation
duration on the way out.

test_bottom_refinement_holds_the_sponge asserts against the shipped
v26.7.1Hz configuration rather than a synthetic one: the invariant that
matters is that the bottom refinement of a real domain is thick enough
to hold the bottom sponge, at every depth we support.

Requires nzcvm (for nzcvm.formats.sfile, used to read the model's
lateral footprint), which in turn forces requires-python >= 3.13.
nzcvm is currently a git dependency and this cannot merge until it is
released.

Co-Authored-By: Claude Opus 5 noreply@anthropic.com


Stack created with GitHub Stacks CLIGive Feedback 💬

`create-sw4-input` renders the SW4 input file for a realisation: the
grid, the refinement stack, the source, the stations, and whatever
commands the `sw4` section carries.

The requested domain becomes the grid's *interior*. The grid is padded
laterally by one supergrid width on each side, so the sponge sits
outside the region anyone asked to simulate rather than eating into it.

`adjust_for_topography` handles the interaction between topography and
the refinement stack. Topography lifts the top of the grid above z=0,
which thins the first layer; SW4 requires every grid in the stack to
hold at least `nz_min` cells, so any layer left too thin is pushed down
until it does. The topography surface participates in that count as a
boundary but is not itself returned as a refinement -- the caller gets
back the real layers plus the depth used.

Commands come from the realisation rather than being hard-coded, so a
run can add or override any SW4 command without a code change. Output
commands that take a time window are merged with the simulation
duration on the way out.

`test_bottom_refinement_holds_the_sponge` asserts against the shipped
v26.7.1Hz configuration rather than a synthetic one: the invariant that
matters is that the bottom refinement of a *real* domain is thick enough
to hold the bottom sponge, at every depth we support.

Requires nzcvm (for `nzcvm.formats.sfile`, used to read the model's
lateral footprint), which in turn forces `requires-python >= 3.13`.
nzcvm is currently a git dependency and this cannot merge until it is
released.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant