Skip to content

Use Oceananigans and Breeze from main - #943

Open
dkytezab wants to merge 13 commits into
mainfrom
dkzdev/oceananigans-breeze-main
Open

dkytezab wants to merge 13 commits into
mainfrom
dkzdev/oceananigans-breeze-main

Conversation

@dkytezab

@dkytezab dkytezab commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Resolves Oceananigans from its main branch, and the packages that bound it from branches that admit main (0.118.1), through [sources]:

Package Source Environments
Oceananigans CliMA/Oceananigans.jl main root, test/, docs/, examples/
Breeze dkzdev/oceananigans-breeze-main (NumericalEarth/Breeze.jl#1267) test/, docs/, examples/
ClimaSeaIce dkzdev/oceananigans-breeze-main on dkytezab/ClimaSeaIce.jl (CliMA/ClimaSeaIce.jl#221) root, test/, docs/
Terrarium NumericalEarth/Terrarium.jl main, which admits Oceananigans 0.118 since NumericalEarth/Terrarium.jl#259 test/, docs/, examples/
OceanBioME dkzdev/oceananigans-breeze-main (OceanBioME/OceanBioME.jl#473) test/

Pkg takes [sources] only for [deps] and [extras], so the weak dependencies of the package (Breeze, Terrarium, OceanBioME) are pinned in the environments that list them; examples/ picks up the root's ClimaSeaIce through the workspace. Each upstream branch also resolves its own Oceananigans from main, so its CI runs against it.

Every ClimaSeaIce release and the registered OceanBioME 0.21.1 cap Oceananigans at 0.117; Breeze main already admits 0.118.1. Compat here is unchanged: 0.117.2, 0.118 admits main. [sources] needs Julia 1.11 or later, and CI runs 1.12.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

dkytezab and others added 11 commits November 17, 2026 10:23
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… Oceananigans 0.118

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Step each nest level at its own rate

Give `NestedModel` a `time_step_ratio`: the number of child steps per parent
step. The default 1 reproduces lockstep exactly. With n > 1 the child runs n
steps of the finest grid's Δt while the parent waits, then advances once by
their accumulated span, so a coarser level is not forced onto a step sized
for the finest grid.

The rule belongs to `advance_parent!`, and only to the method for a parent
that integrates its own dynamics. A prescribed parent is a function of time
rather than an integration, so it keeps following the child's clock whatever
the ratio — which also leaves its branch-free path intact.

Expressing the rule as accumulated lag rather than a counter makes it
compose through nesting with no extra bookkeeping: ratio 2 at both levels of
a three-level telescope steps the middle level at 2Δt and the outer at 4Δt.
The outer Δt is the finest level's, which is the direction the object graph
already runs in — `cell_advection_timescale` forwards to the innermost
child, so the wizard already produces the finest step and each parent takes
a whole multiple of it. The child's own step is read from the clock that is
already passed (`tick!` records it as `last_Δt`), so no extra argument is
threaded through.

`NestedSimulation` and `nested_atmosphere_model` take the ratio as a
keyword, so it is reachable from every public entry point rather than only
by constructing a `NestedModel` directly.

`time_step_ratio(parent_grid, child_grid)` derives the factor from a pair of
grids as the rounded ratio of their smallest horizontal spacings; rounded
because zonal spacing on a LatitudeLongitudeGrid varies with latitude, so a
nominally 4x nest realizes something near 4.

No stability check on the refined parent step: a ratio taken from the
horizontal refinement can exceed what a level's own CFL allows, since nests
commonly share one vertical grid where w Δt / Δz binds regardless of
horizontal spacing. That is the caller's to choose, as the finest Δt already
is, and `cell_advection_timescale` already expresses the constraint.

Closes #330.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Comment the parent-advance gate

Say what the gap between the clocks is, what closes it, and why the gate
compares a rounded count of child steps rather than an exact multiple: an
accumulated Δt, steady or varying, need not give an integer multiple of the
latest Δt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Test that a boundary-prescribed parent's strips follow the child's clock

`advance_parent!` threads the ratio into each strip of a
`BoundaryPrescribedComponent`, and nothing exercised that parent type. A
strip is prescribed, so it follows the child's clock whatever the ratio.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Give each nest level its own time step, with the parent leading

`time_step!(::NestedModel)` advanced the child and then brought the parent up
to it, so the child integrated across an interval the parent had not reached
and its boundary data was extrapolated by up to a full parent step. Advance
the parent first and clip the child's step so it cannot land past the parent's
state. The child then interpolates between bracketing parent states, and the
clipped step lands it on the parent's time exactly, so the clocks coincide at
a rendezvous without an integer refinement ratio and without predicting the
child's next steps.

`time_step_ratio` as a field and keyword becomes `parent_time_step`, each
level's own step rather than a multiple of the child's: `nothing` keeps the
parent in lockstep with the child, a number is a fixed parent Δt, a function
of the child's Δt such as `Δt -> 3Δt` holds a refinement ratio while the
child's Δt adapts, and a `TimeStepWizard` sizes each parent step from the
parent's own CFL. A fixed Δt cannot hold a ratio against an adapting child:
once the child's Δt outgrows it, the child is clipped down to the parent's
rate.

The `time_step_ratio(parent_grid, child_grid)` helper is unchanged and now
serves to pick a commensurate parent Δt — an incommensurate one costs the
child one short step per parent interval.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Rename parent_time_step to parent_Δt

Matches Oceananigans' convention for Δt-valued keywords (`max_Δt`, `min_Δt`)
and says plainly that the value is a time step.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Keep a prescribed parent's compiled step branch-free

The clip compared the child's clock against the parent's time, and under
Reactant compilation that clock is a traced number, so the comparison
produced a traced condition for the ternary to branch on — the failure mode
issue #816 exists to avoid. A prescribed parent constrains the child's step
not at all, so report that as `nothing` and select the no-op clip by dispatch
instead of by comparison.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

---------

Co-authored-by: Eliot Quon <eliot@aeolus.earth>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
* Step each nest level at its own rate

Give `NestedModel` a `time_step_ratio`: the number of child steps per parent
step. The default 1 reproduces lockstep exactly. With n > 1 the child runs n
steps of the finest grid's Δt while the parent waits, then advances once by
their accumulated span, so a coarser level is not forced onto a step sized
for the finest grid.

The rule belongs to `advance_parent!`, and only to the method for a parent
that integrates its own dynamics. A prescribed parent is a function of time
rather than an integration, so it keeps following the child's clock whatever
the ratio — which also leaves its branch-free path intact.

Expressing the rule as accumulated lag rather than a counter makes it
compose through nesting with no extra bookkeeping: ratio 2 at both levels of
a three-level telescope steps the middle level at 2Δt and the outer at 4Δt.
The outer Δt is the finest level's, which is the direction the object graph
already runs in — `cell_advection_timescale` forwards to the innermost
child, so the wizard already produces the finest step and each parent takes
a whole multiple of it. The child's own step is read from the clock that is
already passed (`tick!` records it as `last_Δt`), so no extra argument is
threaded through.

`NestedSimulation` and `nested_atmosphere_model` take the ratio as a
keyword, so it is reachable from every public entry point rather than only
by constructing a `NestedModel` directly.

`time_step_ratio(parent_grid, child_grid)` derives the factor from a pair of
grids as the rounded ratio of their smallest horizontal spacings; rounded
because zonal spacing on a LatitudeLongitudeGrid varies with latitude, so a
nominally 4x nest realizes something near 4.

No stability check on the refined parent step: a ratio taken from the
horizontal refinement can exceed what a level's own CFL allows, since nests
commonly share one vertical grid where w Δt / Δz binds regardless of
horizontal spacing. That is the caller's to choose, as the finest Δt already
is, and `cell_advection_timescale` already expresses the constraint.

Closes #330.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Comment the parent-advance gate

Say what the gap between the clocks is, what closes it, and why the gate
compares a rounded count of child steps rather than an exact multiple: an
accumulated Δt, steady or varying, need not give an integer multiple of the
latest Δt.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Test that a boundary-prescribed parent's strips follow the child's clock

`advance_parent!` threads the ratio into each strip of a
`BoundaryPrescribedComponent`, and nothing exercised that parent type. A
strip is prescribed, so it follows the child's clock whatever the ratio.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014xTVXyupCmzaWiLTvLrZDC

* Sample a parent in its own vertical coordinate

`interpolate` locates the vertical through the source grid's `znodes`, which
for a terrain-following grid are the reference levels, while `node` on that
grid returns the terrain-deformed height. Querying a terrain-following parent
at the child's physical node therefore displaces every sample by the terrain
elevation (about +400 m at the first cell over a 400 m plateau).

`query_node(source_grid, i, j, k, grid, ℓ...)` returns the coordinate a child
node queries a parent at: the physical node by default, the reference node for
a Breeze `TerrainFollowingGrid` source. The `Interpolated` boundary conditions,
the `VectorComponent` relaxation target and the child initialization
(`interpolate_from_parent!`, which replaces `interpolate!` there) all query
through it. Prescribed parents are not terrain-following, so their results are
unchanged; this is groundwork for nesting in a live Breeze parent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Nest a Breeze child in a live parent atmosphere

`nested_atmosphere_model(parent, child_grid; …)` now also accepts a live
Breeze `AtmosphereModel`, or a `NestedModel` whose child is one, so nests
telescope: each finer nest wraps the coarser one as its parent. The prescribed
path is reused end to end. A live parent has no state exchanger; its own
fields stand in for the exchanger's derived prognostics, under the same keys
(`ρᵈ, ρu, ρv, ρθ, ρqᵛᵉ, θ, u, v`), so the lateral boundary conditions, the
specific-state Davies relaxation and the ρw sponge are built by the same code.
A live parent covers the child, so the constructor also initializes the child
from it (through `balancer`), which a prescribed parent leaves to its caller.

Relaxing toward a live `Field` goes through `InterpolatedParentTarget`, which
samples the parent at `query_node`; Oceananigans' own `InterpolatedFieldTarget`
queries the physical node, which is wrong for a terrain-following parent.
`surface_elevation` gains a `TerrainFollowingGrid` method (the height of the
lowest face), so the child's terrain blends toward a live parent's.

`initialize_nested_child!` drops its unused `dataset, date, dir` arguments and
takes the initial state from either a `FieldTimeSeries` (its first time) or a
`Field`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Nest a Breeze child in a land-coupled parent

A live parent may now be an EarthSystemModel (e.g. an AtmosphereLandModel)
whose atmosphere is a Breeze model or a nest, so each level of a telescope
keeps its own surface. Tested by a three-level telescope of land-coupled nests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Test a time-step ratio on a live Breeze parent

The ratio tests so far use bare NonhydrostaticModels or a prescribed parent;
this one steps a live Breeze parent once per two nest steps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Keep a nest from collecting its live parent's time series

A live parent's Field is reachable from the nest's Interpolated boundary
conditions and InterpolatedParentTarget relaxation targets. Oceananigans'
extract_field_time_series follows a Field into its own boundary conditions,
so every boundary side and forcing of the nest re-collected all of the
parent's FieldTimeSeries, and each telescope level multiplied the count
again (244 for a nest of a nest of a prescribed parent on 8×8×16 grids,
1488 one level deeper). flattened_unique_values then took 613 s to compile
at 244 entries on CPU, and a 2.5 km nest on a T4 spent over an hour there.

The parent advances its own time series, so both wrappers now contribute
none. Nest construction of a land-coupled nest of a nest drops to ~850 s
on a T4, compile included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Import instantiated_location from its owner

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Align the nested_atmosphere_model signature

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Read a live parent through its fields

A Breeze model and a NestedModel both expose the parent state through
Oceananigans.fields, so the live-parent sampling reads it there instead of
unwrapping the parent to its Breeze model. A coupled model's fields are
empty, so it forwards to its atmosphere. The parent's moisture density is
looked up under the child's moisture name, so a parent and child with
different moisture variables fail at construction.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Apply suggestion from @ewquon

* Rename query_node to interpolation_node, with the source grid last

It builds the at_node argument of interpolate(at_node, from_field, from_loc,
from_grid), so it now follows that argument order: the child's node arguments
(i, j, k, grid, ℓx, ℓy, ℓz) first, then from_grid, which only selects the
method. The leading grid argument read as a second evaluation grid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Compute a terrain-following surface elevation once

Field(operation) already computes on construction, so the extra compute! ran the
kernel twice.

Co-Authored-By: glwagner <glwagner@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Eliot Quon <eliot@aeolus.earth>
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: glwagner <glwagner@users.noreply.github.com>

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

DO NOT MERGE ⚠️ DON'T EVEN THINK ABOUT IT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants