Skip to content

Tests: analytic_full sweeps KramerSphericalStokes and flips its smooth-density body force - #1204

Merged
lmoresi merged 1 commit into
developmentfrom
tests/analytic-full-kramer-spherical
Nov 16, 2026
Merged

lmoresi merged 1 commit into
developmentfrom
tests/analytic-full-kramer-spherical

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 16, 2026

Copy link
Copy Markdown
Member

Test-only. Two failures on development in tests/analytic_full/test_analytic_full_family.py, both from KramerSphericalStokes, which #1108 added to the analytic family. Found by the parallel review desk.

The two failures (on development fafbecb)

  1. test_this_file_sweeps_the_whole_family: AssertionError: unswept: {'KramerSphericalStokes'}; stale: set(). Native spherical Kramer Stokes references, gravity kernels and real spherical harmonics #1108 added the family member but not its SWEEP entry.
  2. test_flipping_the_body_force_breaks_the_momentum_balance[KramerSphericalStokes]: "flipping the body force left the momentum residual at 3.175e-14". The default density="delta" loads the shell with a density sheet at r_int: a stress jump at the sheet, and a body force of zero. Flipping a zero vector changes nothing, so the negative control cannot fail.

The change

  • SWEEP["KramerSphericalStokes"]: smooth density; smooth density with ell=3, m=1, k=1; delta density with ell=3, m=2, boundary="zero", component="sin". The two m > 0 cases use normalization="real_orthonormal", which the constructor requires for non-axisymmetric modes (the default normalization refuses with "defined only for m=0").
  • The flip test takes its case from a new FLIP_CASE table: the defaults, except KramerSphericalStokes, which flips its smooth-density case.

Why not put it in FORCE_FREE beside EllipticalInclusion and FaultedMedium: those are driven by their boundaries and have no body force in any configuration. Kramer has a smooth-density configuration that does carry one, so the negative control can exercise it there instead of excluding the class. The delta default still runs every other gate (momentum, incompressibility, tracelessness, strain-rate consistency) as the first case in CASES.

This file is not in CI, deliberately

From the file's own docstring: "Nothing in CI runs this file, and that is deliberate rather than an oversight. Run it before a release, and whenever you touch underworld3/analytic/ or _validation.py." Five solutions (SolC, SolDA, SolH, SolKx, SolKz) cost 565 s of the analytic suite's 1010 s, and CI was already near its 60-minute cap. scripts/test.sh selects files by non-recursive globs, so the subdirectory is excluded by construction, and the level_2 mark keeps it out of pytest -m "level_1 and tier_a" tests/. That is why #1108 did not catch these.

What was run

On a 96-thread Linux workstation (single system image, Intel Xeon Gold 6240R, MPICH), one process, a build of this branch.

What Result
the two tests on development fafbecb 2 failed (the messages above), 12 passed
the Kramer cases and the sweep check on this branch 18 passed
python -m pytest tests/analytic_full/ on this branch 224 passed in 1152 s

Not run: macOS; anything in parallel (the file is symbolic, with no solve).

Checklist (UW3 Style Charter — docs/developer/UW3_STYLE_CHARTER.md)

  • I have read the Style Charter and followed it over the surrounding code (S2)
  • No drive-by refactors, renames, or "while I was here" cleanups (S9)
  • Bug fixes ship the regression test, written first, with level_* and tier_* markers (S8) — test-only; the file keeps its existing markers
  • No hedging names (maybe_ / try_ / do_) and no commented-out code (S3, S4)
  • Every exception swallow states its sanctioned failure mode in a comment (S4) — not applicable
  • New data access uses .array / mesh.X.coords (S7) — not applicable
  • Parallel safety considered (S11) — not applicable: no library code
  • No mesh entity or rank identified by coordinates; any remaining tolerance is named, relative and says what it bounds (S12) — no tolerance added
  • No pixi.toml / pixi.lock or other dependency changes riding in an unrelated PR
  • AI-assisted work carries the attribution line below

Reviewer: the parallel review desk.

Underworld development team with AI support from Claude Code

…y body force

#1108 added KramerSphericalStokes to the family but not to this file's SWEEP,
and its default (a density sheet at r_int) carries no body force, so the
negative control flipped a zero vector. The sweep now covers smooth density
and two non-axisymmetric modes (real_orthonormal harmonics, which m > 0
requires), and the flip test flips the smooth-density case.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 16, 2026 01:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lmoresi

lmoresi commented Nov 16, 2026

Copy link
Copy Markdown
Member Author

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))
(H1 is the session that reviews pull requests and runs the parallel tests.)

Verdict on b3fb580: ready to merge on green from this review (a comment, not a GitHub approval).

  • Both failures reproduce on development and are fixed here.
  • The whole tests/analytic_full/ file passes.
  • The flip test now does real work on Kramer: the smooth-density case carries a body force, and flipping it moves the momentum residual from 3e-15 to 2.0.
  • The default delta-density case is swept by every other gate.

How it was run

The branch is test-only. It ran against a development install (176958a) with fafbecb's two changed Python files laid over it (discretisation_mesh.py, meshing/smoothing/graph.py). The underworld3 import was checked to load from that overlay. The analytic package itself is the same at 176958a and fafbecb. The tests are this branch's.

Findings

No blocking findings.

Nit

  1. The ground for substituting Kramer's flip case is stated in a comment but not asserted. FORCE_FREE has test_the_force_free_solutions_really_have_no_body_force, which checks its stated reason. FLIP_CASE swaps Kramer's default for its smooth-density case because the default "carries no body force", but nothing checks that.
    • A one-line assertion would keep the table honest if the default ever changes: for each name in FLIP_CASE, its default fn_bodyforce is zero and the substituted case's is not.
    • Measured here, the default's body force is [0, 0, 0] and the smooth case's three components are all nonzero.

Confirmed correct

  • Both failures reproduce on development (fafbecb's test file, which is identical to 176958a's):

    • test_this_file_sweeps_the_whole_family: AssertionError: unswept: {'KramerSphericalStokes'}; stale: set();
    • test_flipping_the_body_force_breaks_the_momentum_balance[KramerSphericalStokes]: assert 3.175215757781887e-14 > 0.01.

    On this branch both pass.

  • The flip really tests something. We measured each Kramer case directly, with the same sample points and the same _validation.momentum_residual the test uses:

    case body force residual after the flip
    default (delta sheet) zero 3.2e-14 3.2e-14 (unchanged: nothing to flip)
    density="smooth" (the FLIP_CASE) all three components nonzero 3.2e-15 2.0
    smooth, ell=3, m=1, k=1, orthonormal nonzero 1.9e-14 1.49
    delta, ell=3, m=2, boundary="zero", sin zero 2.4e-14 2.4e-14

    The flipped residual (2.0) is 14 orders of magnitude above the unflipped one and 200 times the test's 1e-2 threshold.

  • The default delta case is covered. CASES puts every solution's defaults first. Kramer's {} case passes the momentum, incompressibility, tracelessness and strain-rate gates. A second delta case (ell=3, m=2, boundary="zero") is in the sweep as well. The SWEEP and FLIP_CASE comments say why the delta case cannot be the flip case: its load is a stress jump at r_int, not a body force. That reasoning is right. FLIP_CASE is the better choice over adding Kramer to FORCE_FREE, which would have dropped a class that does have a forced configuration.

  • The m > 0 cases' normalization: they pass normalization="real_orthonormal", which the constructor requires for non-axisymmetric modes.

What was run

run result
this branch: pytest -n 4 tests/analytic_full/test_analytic_full_family.py 224 passed in 466 s (four workers), matching the author's 224 serially
of which Kramer 17 passed: 4 cases x 4 gates, plus the flip
development: the sweep check and the Kramer flip 2 failed, with the messages above
body-force and flip-residual probe for the four Kramer cases as tabled

All runs were pinned to four cores.

Not run: macOS. The file has no MPI component, so nothing was run in parallel beyond the xdist workers.

Logs kept by the reviewer.

Underworld development team with AI support from Claude Code

@lmoresi
lmoresi merged commit 5ff4404 into development Nov 16, 2026
10 checks passed
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.

3 participants