Repository navigation
NavierStokesSLCN commits its stress history after the solve (#742); it refuses a stress_transport it does not honour - #1256
Conversation
…ther families do (#742); it refuses a stress_transport it does not honour After a solve, a viscoelastic history's level 0 held the solve's stress on Stokes and the composed NavierStokes, and the previous step's on NavierStokesSLCN, which recorded the flux at the next step's start: five ETD-1 solves of the Maxwell box read 0.329681 against exact 0.393469. With a stress history it now carries without recording and commits after the solve; a purely viscous flux history keeps its record. stress_transport on NavierStokesSLCN was accepted and ignored; it now reads semi_lagrangian and refuses any other value, naming uw.systems.NavierStokes for those. Underworld development team with AI support from Claude Code
…ress-history-contract
|
Review from the Underworld development team with AI support from Claude Code (H1: review and parallel test runs on a 96-thread Linux workstation (Intel Xeon Gold 6240R, AVX-512; MPICH)) Verdict at 291d579: ready to merge on green from this review. The change does what it says. After a solve, What users see differentlyMaxwell shear box (eta = G = 1, ETD-1, 5 solves of dt 0.1, 16x8 quads, read at the origin). The exact stress after 5 solves is 0.393469. One step old, it is 0.329681.
Method
ResultsA. #742 probe,
|
| np | development SLCN | PR SLCN | Stokes, NavierStokes (PR) |
|---|---|---|---|
| 1 | 0.329681 | 0.393421 | 0.393469, 0.393469 |
| 2 | 0.329681 | 0.393526 | 0.393469, 0.393469 |
| 3 | not run | 0.393429 to 0.393512 (rank-local reads) | 0.393469, 0.393469 |
The integration_point case on the PR raises the new ValueError on every rank, at np 1, 2 and 3. Nothing hangs.
B. Heterogeneous box: SLCN against the references at step 12 (v / solved stress)
| Case | development vs Stokes | PR vs Stokes | development vs NavierStokes | PR vs NavierStokes |
|---|---|---|---|---|
| ETD-1, fixed dt | 5.5e-3 / 7.9e-3 | 4.9e-3 / 1.0e-2 | 4.3e-3 / 8.4e-3 | 3.7e-3 / 1.1e-2 |
| ETD-1, changing dt | 1.5e-2 / 2.0e-2 (max 1.9e-1) | 4.3e-3 / 1.1e-2 | 2.0e-2 / 2.1e-2 | 3.0e-3 / 1.1e-2 |
| BDF order 2, fixed dt | 6.6 / 0.56 (diverging) | 0.18 / 7.3e-3 (diverging, slower) | same | same |
- For scale: Stokes and
NavierStokesagree to 2.7e-3 at ETD-1 and to 5e-9 at BDF order 2. - PR against development directly (ETD-1, fixed dt): v differs by 9.3e-4 absolute at step 12 and grows steadily. This is the projected history against the evaluated one, carried forward.
- With a changing dt, development forms the stored stress with the new step's coefficients. That is because
dt_elasticis set before the record. The PR stores it with the step's own dt. This explains why the PR is 3 to 6 times closer to the references. - Order 2 BDF over 30 steps: Stokes is smooth. SLCN oscillates and diverges on both sides. The v error passes 1 at step 15 on the PR and at step 10 on development. Order 1 ETD on the PR stays smooth over 30 steps.
- ETD order 2 on SLCN is refused on both sides ("needs a stress history with a forcing slot"). This PR does not change that.
- Stokes and
NavierStokesat order 2 ETD are bit-identical between development and the PR. - Viscous-only SLCN (order 2 with fixed dt, order 1 with changing dt) is bit-identical between development and the PR.
C. Checkpoint and restart (save after step 6, continue to 12, compare with the unbroken run; v / stress)
| Written by → read by | ETD-1 | BDF order 2 |
|---|---|---|
| development → development (np 1) | 3.5e-10 / 1.4e-10 | 1.5e-8 / 1.9e-9 |
| PR → PR (np 1) | 1.2e-6 / 2.3e-6 | 1.2e-5 / 4.4e-6 |
| PR → PR (np 2) | 1.5e-6 / 1.3e-6 | not run |
| development → PR (np 1) | 1.7e-2 / 1.5e-1 | 5.8e-1 / 3.7e-1 |
| PR → development (np 1) | 2.6e-2 / 1.8e-1 | not run |
D. Parallel against serial (heterogeneous box, ETD-1, v / stress, max over 12 steps)
| Case | development | PR |
|---|---|---|
| np 2, quads | 3.0e-5 / 1.1e-5 | 4.1e-4 / 4.3e-4 |
| np 3, simplex, last rank empty | 1.7e-5 / 1.3e-4 | 9.8e-5 / 5.5e-4 |
| np 2, quads, BDF order 2 | not run | 4.1e-2 / 3.2e-3 (unstable scheme, see B) |
E. Tests
| Run | development (e7e02b9) | PR (291d579) |
|---|---|---|
| Serial, 4 workers: test_1247, test_1059 and 12 neighbour files (0020, 0506, 0610 SLCN projection, 1018, 1056 x2, 1060 x2, 1063, 1148, 1153, 1164) | 118 passed, 1 timed out | 122 passed, 1 timed out |
| The PR's tests run against development | test_1247: SLCN level 0 = 0.329681 fails; refusal fails (no attribute); test_1059 SLCN ETD leg fails (0.85043 vs 0.86466) | (these are the PR's own tests) |
| np 2: parallel/0780 (skipped, needs 4 ranks), 1062, 1078, 1107 | 5 passed, 1 skipped | 5 passed, 1 skipped |
| np 2: test_1247 and test_1059's SLCN test | test_1059 SLCN test (with the NavierStokes test in 2 of the 3 runs): all passed, 3 runs | 5 passed, 4 runs; one run did not exit (see finding 5) |
The test that timed out is the same one on both sides: test_1060_stress_store_smoothing::...integration_point_history. It is a 15-minute tier-c NavierStokes characterisation, and I capped each test at 600 s. This PR does not touch that path.
Findings
-
Medium: checkpoints do not carry over across this change. A
NavierStokesSLCNviscoelastic checkpoint written on development holds level 0 one step old. Read on the PR, the history is taken as current, so the run restarts a step behind. v is off by 1.7e-2 and the stress by up to 1.5e-1 at ETD-1, and v by 5.8e-1 at BDF order 2. The reverse direction is off by the same amount. A restart with the same version is fine on both sides. Please add a line to the PR body (and CHANGES if there is an entry) saying that a viscoelasticNavierStokesSLCNcheckpoint written before this change must not be continued after it. A version mark on the history state would let a later reader refuse such a file. That can be a follow-up. -
Medium (existed before this PR; please file separately): order-2 viscoelastic
NavierStokesSLCNis unstable. With BDF order 2, SLCN oscillates and diverges on the heterogeneous box. Stokes andNavierStokesagree to 5e-9 on the same case. On development the v error is 6.6 at step 12. On the PR it is 0.18 at step 12 and passes 1 at step 15. The PR slows the growth but does not remove it. The likely cause is the Adams-Moulton flux inF1blended on top of a constitutive flux that already carries the history. That needs a separate look. ETD order 2 is refused on SLCN on both sides. -
Low: level 0 is a projection with tolerance 1e-4. SLCN's history is degree 2 (Stokes uses
u.degree - 1). The commit projection runs at its default tolerance of 1e-4. The result is that the uniform-shear value reads 0.393421 at np 1 and 0.393526 at np 2, where Stokes andNavierStokesread exactly 0.393469. In the heterogeneous box the PR's partition spread is about 10 times development's (table D), though still well inside typical run tolerances. Setting the projection tolerance to 1e-10 after the first solve gives 0.393457 at np 1 and 0.393472 at np 2. Consider giving the commit projection a tighter tolerance, or the Stokes degree. The PR body's "0.393469" holds for SLCN only to the test's 2e-3. -
Low: the flux read between solves changed.
constitutive_model.fluxafter a solve now reads one step ahead (0.451197 against 0.393469 before). That matches the other families, but it is a visible change, so the PR body should name it next topsi_star[0]. -
Low (not attributed to this PR): one np 2 run did not exit. In 1 of 4 np 2 runs of test_1247 plus test_1059's SLCN test, both ranks passed all 5 tests and then did not exit. The 900 s timeout ended the run. In that run the supervisor had seen no output for 60 s mid-test and attached to the ranks for a stack dump. Its native dump failed ("No such process"). The other 3 runs finished in about 55 s with no silence. Development's 3 runs of the SLCN test exited cleanly, but they never reached 60 s of silence. I read this as a side effect of the stack dump, not of the change. Recorded for completeness.
On test_1059: its SLCN test compares against the analytic value (1e-3 for ETD, 0.02 for BDF, after 20 steps). It now reads psi_star[0], so it does exercise the changed path. Run against development, the ETD leg fails (one step old, 1.6 % off). The BDF leg's 2 % tolerance would not catch a one-step lag. The pins "pass unchanged" because before this PR the test read the flux, which held the solved stress, and now it reads level 0, which holds the same thing.
Diff read in full. The order is right: with a stress history, the pre-solve carry runs with store_result=False, which traces every level back without shifting or recording. After the solve, commit_flux_to_history projects the new stress into level 0 and shifts the carried old level 0 to level 1, once per step. Then update_post_solve records the dt. This is the Stokes sequence. On the first step, initialise_history fills the levels from the zero-velocity flux as before, so step 1 is bit-identical on both sides. The refusal is a pure-Python setter check with no collective, so it is rank-identical. The class is also exported as NavierStokesSwarm, which gets the same change.
What was run and not run
Run: the #742 probe at np 1, 2 and 3 on the PR, and at np 1 and 2 on development. The heterogeneous probe (about 30 serial runs, 12 to 30 steps). Restart at np 1 (same version and across versions) and at np 2 (PR). np 2 on quads and np 3 on simplex with an empty rank. A projection-tolerance check. The serial neighbour tests on both sides. The PR's tests against development. Four parallel test files at np 2 on both sides. Logs kept by the reviewer.
Not run: np 4 of parallel/0780 (it needs 4 ranks; the core budget was 4). Restart across versions at BDF order 2 from PR to development. Restart at np 3. A mesh-refinement study of the PR-against-development difference. The 15-minute tier-c smoothing test to completion.
Underworld development team with AI support from Claude Code
Fixes #742, and a side finding from the same sweep (no issue was filed for it).
1. After a solve, every family's stress history holds that solve's stress (#742)
On the analytic Maxwell shear box (rate 1, η = G = 1, ETD-1, five solves of 0.1),
DFDt.psi_star[0]after the fifth solve read:StokesNavierStokes(composed)NavierStokesSLCNThe exact value is$1 - e^{-0.5} = 0.393469$ . The stale one is $1 - e^{-0.4} = 0.329681$ .
The cause: the Stokes family commits the stress after the solve (
_stress_history_post_solve).NavierStokesSLCNrecorded its flux at the start of the next step, so a diagnostic or checkpoint read after a solve was a step stale. With a stress history (a model withrequires_stress_history),NavierStokesSLCNnow:store_result=False);A purely viscous flux history keeps its record at the start of the step.
Behaviour change for
NavierStokesSLCNusers with a viscoelastic model:psi_star[0]holds between solves, and so what a checkpoint written after a solve stores, is now the stress just solved for;test_1059's pinnedNavierStokesSLCNvalues pass unchanged.test_1059's Maxwell-box helper read the constitutive flux for this solver as a workaround for After solve(), psi_star[0] holds the new stress on the Stokes family but the previous step's stress on NavierStokesSLCN #742. It now readspsi_star[0]for every family.NavierStokesSLCNcheckpoint written before this change and read after it, or the reverse, restarts from a history one step off. The parallel review measured the velocity off by 1.7e-2 at ETD-1 and 0.58 at BDF-2. Restarting within one version is unaffected. Anyone restarting an older run should restart it on the version that wrote it. A version mark on the history state would let a restart refuse the mismatch; that is a later improvement.constitutive_model.fluxread between solves now gives the next step's flux, as inStokesandNavierStokes, because it is formed from the just-committed history. Code that read it for the latest stress must readDFDt.psi_star[0]instead.Test:
test_1247runs the box on all three families. Before the fix,NavierStokesSLCNfails at 0.3296808; after it, all three pass.2.
NavierStokesSLCNrefuses astress_transportit does not honourIt accepted any
stress_transport(a plain attribute) and always built a semi-Lagrangian history, so"integration_point"was ignored without a word. It now:"semi_lagrangian";ValueErrornaminguw.systems.NavierStokes, which carries the other flavours.test_1247checks this; it failed before.Tests
Measured by H7 (the stress-history desk, a Claude session on a 96-thread Linux workstation: Intel Xeon Gold 6240R, MPICH).
test_1247(4): 2 failed before, all pass after.test_1059and the 8 files that buildNavierStokesSLCN,SNES_NavierStokesorNavierStokesSwarm, on 4 xdist workers: 110 passed.Checklist (UW3 Style Charter)
level_1andtier_amarkers; it fails on development (S8)Underworld development team with AI support from Claude Code