Repository navigation
Timestep estimates read model units; timestep setters keep or refuse their input (#891, #1031, #978 part) - #1049
Conversation
…their input - #891: the semi-Lagrangian direction-aware crossing time and the Eulerian accuracy estimate read mesh coordinates in model units (mesh._coords, and the coordinate DM's local array), so a units model and its dimensionless twin give the same estimates. - #978 (estimate_dt part): the Eulerian accuracy estimate evaluates the velocity at the coordinate DM's nodes, which match the gradient recovery on a degree-2 mesh. - #1031: _nondimensionalise_timestep keeps a UWexpression live (TransientDarcy no longer unwraps it), turns a 0-d array into a float, and refuses a non-time quantity or a dimensional time with no reference scales. test_1153 (level_1, tier_b): 10 pass here, 9 fail on development. The 112 timestep-related test files: 915 passed, 0 failed. Underworld development team with AI support from Claude Code
… model units - F1: a dimensionless timestep quantity is reduced before its magnitude is taken; (600 kyr) / (20 Myr) was read as 30, not 0.03. - F2 (#891): the Eulerian accuracy estimate takes the field range from u.data and non-dimensionalises the velocity; with V and T carrying units it was 5.5e15 times too long before a solve and 2500 times after one. - F3: a time-valued UWexpression is refused when the model has no reference scales, as the bare quantity is. - A single-element array is a number; the helper's Returns docstring. test_1153: 17 pass; five mutants, one per fix, each caught. The 112 timestep-related test files: 922 passed, 0 failed. Underworld development team with AI support from Claude Code
Review record, round 1 of 2: b4b5426This is the pre-PR round, on the branch's first commit. 7d376b8 answers F1–F3. Round 2 follows in the next comment. Paths under Pre-PR adversarial review:
|
| issue | verdict | evidence |
|---|---|---|
| #891 | Fixed only for unitless variables; still live with unit-carrying variables (F2). Do not write Closes #891 until F2 is fixed. |
p891.py, np 1 and 2. Variables without units: every estimate (SLCN da0/da1 and dt_adv, Eulerian accuracy, resolution da0/da1, accuracy after a solve) matches the dimensionless twin with rel 0.0. The base was 3.23× / 2.2e6× / 0.61×. With V in m/s and T in K: Eulerian first estimate rel 5.5e15, after a solve rel 2499. The base was also wrong, by 3.3e15 and 2499. |
| #978 (estimate_dt part) | Fixed by this branch. The computeCellGeometryFVM and boundary_normal parts of #978 are not in this branch and stay live [read: not probed]. Write "Refs #978", not Closes. |
p978.py, annulus at degree 1 and 2, cellSize 0.1 and 0.05, np 1 and 2. The degree-2 result equals the P1 result to 1e-16. T = x with V = (1, 0): dt = 0.04 against a hand value of 0.04 (rel 6e-15). T = xy with V = (-y, x): 0.02062, 0.02027 against 0.02 (O(h) recovery error, converging). The recovery returns 0 at the edge nodes, so the maximum is over vertices. The base raises ValueError. Base np 4 on degree 2 hung (one rank's reshape error before a collective; the supervisor killed it). On the branch the SL direction-aware estimate on degree 2 equals P1 (box and annulus). |
| #1031 | Fixed by this branch (the four cases in the table), with F1 and F3 as follow-ups. | p1031.py: the table across 5 solvers × 14 inputs × with and without scales. p1031solve.py: a changed UWexpression reaches the solve for Darcy, Diffusion and NS (E == F, ≠ C). On the base, Darcy's E == C (frozen); with scales, the base Darcy expression-quantity solved at dt 600 (norm 2e-7 against 4.2). A 0-d array gives a Float with no rewire on every setter. A non-time value is refused (UWQuantity, Pint, and UWexpression). A time with no scales is refused. |
| #1025 | Still live. The branch leaves it on purpose. | _advective_diffusive_dt still returns min(dt_diff, dt_adv), with dt_diff = h²/κ_max, for SLCN [read]. Waiting on Louis. |
Findings
F1 (high, regression introduced here). solvers.py:250-252, the new
if not value.dimensionality: return float(magnitude) branch takes the
magnitude of an unreduced dimensionless quantity.
-
uw.quantity(600,"kyr") / model.fundamental_scales["time"](= 0.03) becomes
9.506e-13. -
(600 kyr)/(20 Myr)becomes 30.0. -
Solve comparison against
timestep=0.03(probes/pidiom2.py):solver base branch Diffusion 5.6e-16 0.55 SLCN 5.0e-16 0.64 NS 0.027 0.66 Darcy 0.55 0.55 The branch solves at dt 9.5e-13 with no warning.
-
Fix:
float(value.to("dimensionless").magnitude)(orto_reduced_units(), as the time path
already does), and add both inputs to test_1153.
F2 (high, #891 incomplete). advection_diffusion_eulerian.py, estimate_dt and
_advective_rate:
- The field range comes from
self.u.array, which is dimensional (K) when T has units. - The velocity is
getattr(vel, "magnitude", vel): the dimensional magnitude (m/s) when V has
units. - The gradient (
_lvec) and_last_change_rate(u.data) are nondimensional.
Result with V in m/s, T in K, and scales set: the first estimate is 6.7e13 against
0.0121 (×5.5e15), and every estimate after a solve is 30.2 against 0.0121 (×2500).
Fix:
- read the range from
self.u.data, as the change rate does; - nondimensionalise the velocity as
_centroid_velocities_nddoes
(uw.non_dimensionalisewhen it has units).
test_1153's twin test should also run with unit-carrying V and T: it passes
today because its variables have no units. NS-Eulerian estimate_dt reads range and rate
from u.array consistently, so it is unaffected [read].
F3 (medium). An expression holding a time quantity with no scales is
accepted and read as model units. This is the Q3 bypass of the new refusal. Fix it in the
UWexpression branch, and add a case to test_1153.
F4 (low, pre-existing, base identical). The Eulerian accuracy estimate
depends on np: 0.020271, 0.020152 and 0.020005 at np 1, 2 and 4 on the annulus at
cellSize 0.05. The cause is a one-sided Clement gradient at partition-boundary vertices
(Q1). It is not a blocker. File it if the estimate should be partition-independent.
Possible fixes: assemble the Clement numerator and weights globally, or recover the gradient on a DM
with overlap.
F5 (low, pre-existing).
- A 1-element 1-D array (
np.array([0.03])) still
stores anImmutableDenseNDimArrayand rewires on every step (Darcy, NS, SLCN,
Diffusion). The Eulerian setter raises TypeError for it. - With scales set, a negative time quantity (
-1 kyr) is accepted as dt -5e-5 by every setter
except the Eulerian one.
Either is a one-line extension of the same helper.
F6 (low, pre-existing). AdvDiffusion.delta_t does float(...), so a
UWexpression timestep raises TypeError on both builds. The docstring for
_nondimensionalise_timestep now says that a UWexpression is returned "so that a later
E.sym reaches the solver". That is true for every setter except this one. Either say so
or accept the expression.
F7 (nit).
- The
_nondimensionalise_timestep"Returns" section still says
"otherwisevalueunchanged". It now also returns a float for 0-d arrays and for
dimensionless quantities. - The trailing
try/exceptstill swallows a reduction
failure and returns the quantity, so a time quantity can still reach the kernels unreduced.
That is pre-existing, and the Charter-sanctioned comment is present. - In
test.sh, test_1153 sits before 1151. That is cosmetic. CI reach is fine: it is listed
in batch 4, and the level_1 and tier_b markers are run there.
Attacks that failed
-
Units model: estimate_dt's crossing time and first accuracy estimate read dimensional mesh coordinates as model units (dt 3.4x too large, silently) #891 twin, variables without units, np 1 and 2, SLCN and Eulerian, direction-aware
and not, accuracy before and after a solve: rel 0.0 everywhere. -
Rank symmetry: 18 cases × np 1, 2, 4, plus the annulus case: always symmetric.
-
Degree-2 vertex ordering for the SL
mesh._coords[tris]index: on box and annulus, degree 2
equals P1 to 1e-16, so vertex rows come first. -
Degree-2 meshes: computeCellGeometryFVM, boundary_normal and estimate_dt still read or refuse midpoints #978 hand calculation: exact for a linear field, and O(h) convergent for xy.
-
Mutants (
mut/mutplug.py, patched at runtime, no worktree writes): each one is caught by
test_1153.mutant failing tests SL coords back to mesh.X.coords1 (twin) Eulerian coords back to mesh.X.coords2 (twin, degree 2) Eulerian vertices only, in model units 1 (degree 2) 0-d handling removed 2 non-time refusal removed 2 no-scales refusal removed 2 Darcy unwrap restored 1 -
test_1153 on the base: 9 fail and 1 passes (NS expression-live, which the base NS already did). On the
branch, 10 pass. -
Doc examples: no difference between builds except the intended Units model: estimate_dt's crossing time and first accuracy estimate read dimensional mesh coordinates as model units (dt 3.4x too large, silently) #891 dt change.
Regression run at np 2 (branch against base)
We ran 93 files at np 2 on both builds, one mpirun per file under the supervisor
(silence 600 s, lowered to 180 s part-way through, the same for both builds):
- 86 serial-suite files: the timestep, estimate_dt and transient-solver tests, without level_3;
- 7
tests/paralleltimestep files.
Results (np2-results.txt, logs/np2-*):
- No regression. Every file has the same per-rank outcome on both builds, with two
exceptions:test_1153: the branch passes 10 on both ranks. The base fails, then hangs: the degree-2 reshape
error happens before the allreduce on one rank only, and the supervisor killed it.test_1070_free_surface_plume: the base has 1 failure
(ring_quadrature_is_exact_in_parallel) and the branch has 0. Both builds hit the silence
limit, so we read this as timing, not code.
- Summed over ranks: branch 562 passed, 56 failed, 8 skipped; base 557, 56, 8.
The difference is test_1153 and test_1070. The 56 failures are the same tests on both builds. - 16 files hit the supervisor on both builds. Most of the serial suite is not
written for MPI (for example test_0017, 0075, 0114, 1052, 1054, 1064, 1100, 1101, 1105).
They are equally hung on base and branch.
Merge conditions
- Fix F1 (reduce dimensionless quantities before taking the magnitude), with test_1153
cases for600 kyr / time_scaleand(600 kyr)/(20 Myr). - Fix F2 (Eulerian range from
u.data, velocity nondimensionalised), with the
twin test extended to unit-carrying V and T. - Fix F3 (refuse a time-valued UWexpression when there are no time scales), with a test.
- Rerun test_1153 and its mutants. The PR body should say "Closes Timestep setters: a UWexpression is frozen, a non-time quantity is accepted, a 0-d array rewires every step (TransientDarcy, Richards, NavierStokesSLCN) #1031", "Closes Units model: estimate_dt's crossing time and first accuracy estimate read dimensional mesh coordinates as model units (dt 3.4x too large, silently) #891" (only after F2)
and "Refs Degree-2 meshes: computeCellGeometryFVM, boundary_normal and estimate_dt still read or refuse midpoints #978". It should state that Degree-2 meshes: computeCellGeometryFVM, boundary_normal and estimate_dt still read or refuse midpoints #978's FVM and boundary_normal parts and SLCN estimate_dt limits the step by the cell diffusion time, which shrinks it as h² on fine meshes #1025 stay open. - Optional: F4 filed as an issue, and F5 to F7 tidied in the same helper.
What we could not test
- The author's exact 112-file list is not on hyperion. We used our own selection:
93 files, the tests matching delta_t, timestep, estimate_dt or the transient solver names, minus level_3,
plus 7 timestep-relatedtests/parallelfiles. - np 4 was run only for the probes (Q1), not for the test suite. Most serial test files are not
written for MPI, so the np 2 comparison is branch against base and not absolute. - Notebook 15 could not run past mesh construction on either build. Notebooks were
run as converted scripts, not through Jupyter. - The ZG95 driver from Units model: estimate_dt's crossing time and first accuracy estimate read dimensional mesh coordinates as model units (dt 3.4x too large, silently) #891 (uw3-campaigns) was not run.
- Degree-2 meshes: computeCellGeometryFVM, boundary_normal and estimate_dt still read or refuse midpoints #978's
computeCellGeometryFVMandboundary_normalparts were not probed [read]. - The base at np 4 on a degree-2 mesh hung in our probe, so that branch-against-base cell is missing.
- Housekeeping: our first serial runs (before we set TMPDIR) left pytest tmp dirs under the
sharedhyperion-work/cache/tmp/pytest-of-lmoresi/. The emptyruns/2026-11-06/cache-rvB-*dirs thatactivate.shcreates
have been removed. Everything else is underreview/.
Underworld development team with AI support from Claude Code
Review record, round 2 of 2: 7d376b8Verdict: ready to merge. F1, F2 and F3 are fixed. The branch was rebuilt and re-run on hyperion with round 1's own probes. F1, the unreduced dimensionless timestep (
F2, the Eulerian estimate with unit-carrying variables ( F3. Covered by the author's new tests on Darcy and NS. It was not re-probed separately here. Tests. test_1153: 17 passed at np 1 and at np 2. Underworld development team with AI support from Claude Code |
NavierStokesSLCN.solve hands its raw timestep to the characteristic trace and to the DDt managers, whose _as_float went through non_dimensionalise and left a dimensionless ratio unreduced: (600 kyr) / (20 Myr) was 30, 600 kyr over the time scale 1.2e-16. _as_float now reduces a dimensionless quantity first, as the solvers' setter helper does (F1). test_1153: two Navier-Stokes steps with the ratio equal two with 0.03 (one step from rest cannot show it: the trace-back is empty and the first-order coefficients do not depend on the step); the mutant is caught by the solve comparison alone. 18 pass; the 112 timestep-related test files: 923 passed, 0 failed. Underworld development team with AI support from Claude Code
Review record, round 3: aef4cf1Verdict: ready to merge. aef4cf1 fixes the NavierStokesSLCN solve-path residual that round 2 left open. It is a 6-line change in Rebuilt and re-run on hyperion with round 1's probe,
test_1153: 18 passed at np 1 and at np 2. The author's mutant (the reduction undone) is caught by the solve comparison and by the
Underworld development team with AI support from Claude Code |
The timestep estimates now read the model's units, and the timestep setters either keep what they are given or refuse it. This is bundle B of the issue sweep: #891, #1031, and the
estimate_dtpart of #978.Timestep estimates in a model with units (#891)
In a model with reference scales,
mesh.X.coordsis dimensional. Two estimates read it as model units:mesh._coords.The Eulerian accuracy estimate also mixed frames when the variables carry units, which is the usual set-up in a model with units. The field range came from
u.array(dimensional) and the velocity was taken at its dimensional magnitude, while the gradient and the change rate are non-dimensional. With V in cm/yr and T in K, the first estimate was 5.5e15 times too long, and each one after a solve was 2500 times too long (the temperature scale). The range now comes fromu.data, and the velocity is non-dimensionalised.A model with units and its dimensionless twin now give the same three estimates to 1e-9, with and without units on the variables.
The accuracy estimate on a degree-2 mesh (#978)
The Eulerian accuracy estimate evaluated the velocity at the vertices, while the Clement gradient recovery returns values at the coordinate DM's nodes, edge midpoints included. On a degree-2 mesh it raised
ValueError(714 gradient values into 98 vertices). Both now use the coordinate DM's nodes. On degree 2 the estimate equals the P1 estimate to 1e-16. This is theestimate_dtpart of #978; its FVM and boundary-normal parts stay open.Timestep setters (#1031)
The setters of
TransientDarcyandRichards,NavierStokesSLCN, the semi-Lagrangian and Eulerian solvers andDiffusionshare_nondimensionalise_timestep. It now:UWexpressionas it is, so a laterE.sym = ...reaches the solve.TransientDarcyunwrapped it, freezing the value.(600 kyr) / (20 Myr)is 0.03.ddt._as_float):NavierStokesSLCN.solvehands them the raw timestep, and on development they read(600 kyr) / (20 Myr)as 30.Tests
tests/test_1153_timestep_estimates_and_setters.py(level_1, tier_b) has 18 cases: the units twin with and without units on the variables, the degree-2 estimate against its analytic value, and the setter cases onTransientDarcyandNavierStokesSLCN. It fails on development. Six mutants, each undoing one fix, are each caught. The 112 timestep-related test files on wombat (serial, not level_3): 923 passed, 0 failed.Not covered
h²/κdiffusion cap) is unchanged. It is a solver default, and the measurements are with Louis for a decision.delta_tsetter does not take aUWexpression(on development too); a negative time quantity is accepted when scales are set; and in parallel the Eulerian estimate can differ by about 1% across rank counts on a fine annulus, because a ghost vertex's Clement gradient is one-sided (on development too).Reviewed on hyperion before opening (record below).
Underworld development team with AI support from Claude Code