Skip to content

Coordinates: exact zeros in the spherical and geographic frames - #1303

Open
lmoresi wants to merge 2 commits into
developmentfrom
bugfix/coordinates-exact-zeros
Open

lmoresi wants to merge 2 commits into
developmentfrom
bugfix/coordinates-exact-zeros

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026

Copy link
Copy Markdown
Member

What changed and why

UNFILED 43, follow-up to #1295, from the parallel review desk's review of #1284.

The east (azimuthal) direction of the spherical and geographic frames has no z component. coordinates.py wrote that zero as independent_of_N, the expression vanishing * x * y * z with vanishing = 1e-18, so that a matrix mixing constant and coordinate-dependent entries would lambdify to one array (the reason given beside its definition; it entered the frames with 0f1dbfc, #313, and the geographic east vector with bb23386). The frames are also used to build solver forms, so every form built from the east direction (a rotated frame, a tangential body force, unit_e_2) carried 1e-18·x·y·z in model units. In a model whose values are of order one that is nothing; in a units model whose model-unit values are of order 1e-18 (#1284's J/mol case) it is an error of order one in the assembled form.

Those four zeros are now sympy.Integer(0):

  • the spherical rRotN and its symbolic form rRotN_sym, entry (2, 2);
  • the geographic east vector's z component, and with it the geographic geoRotN, unit_WE and unit_SN (built from it by a cross product);
  • the geographic system's spherical rRotN, entry (2, 2).

independent_of_N and zero_matrix are unchanged; #1295 removes zero_matrix from the evaluators, and this PR does not touch that file, so the two do not conflict. Evaluating the frames still returns the right shape on development's evaluator: evaluate(unit_e_2) at three points gives shape (3, 1, 3) with the z column exactly 0.

What a user's run sees: on a shell or geographic mesh, forms built from the east direction lose a 1e-18·x·y·z term. Measured on a shell Stokes solve with a body force along unit_e_2 and rotated free slip on both walls (cell 0.25), against the same base without this change: velocity differs by 1.6e-15 relative; pressure differs only in its free constant (this setup has a constant-pressure null space), and with the mean removed by 1.7e-13.

Test

tests/test_1296_coordinate_frames_hold_exact_zeros.py (level 1, tier B), five cases: on a SphericalShell and a RegionalGeographicBox, no frame contains the term and the east direction's z entry is exactly sympy.Integer(0); and the unwrapped F0 of a Stokes solver whose body force is unit_e_2 contains no such term. All five fail on development (the term is present) and pass here.

What was run

On a 96-thread Linux workstation (single system image, Intel Xeon Gold 6240R, MPICH), with another session's full-suite run sharing the machine:

What Result
15 serial files on meshes, geometric directions, spherical Poisson and Stokes, shell null space, rotated free slip, the constrained shell response, geoid, spherical free surface, boundary integrals, and the new test 161 passed, 1 skipped (this host's gmsh builds a different mesh for test_1111's recorded answer), 1 xfailed (known)
6 parallel shell files at np 2 (rotated free slip, boundary normal, shell geoid, shell region labels, internal-sphere snap, sphere refinement folds) all pass on both ranks
shell Stokes solve, branch against the same base without the change velocity 1.6e-15; pressure 1.7e-13 with its constant removed
scripts/check_test_coverage.py OK, 510 files reachable

Not run

np 3 or more; the geographic box in a solve; macOS; the full suite.

Underworld development team with AI support from Claude Code

Fails on development: the east direction's z entry is vanishing*x*y*z
(1e-18*x*y*z), in the rotation matrices, the geographic east vector, and a
Stokes form built from it.

Underworld development team with AI support from Claude Code
The east direction's z component was written as independent_of_N, the
expression vanishing*x*y*z, so every solver form built from the frame
carried 1e-18*x*y*z in model units. It is now sympy.Integer(0) in the
spherical rRotN and its symbolic form, and in the geographic east vector
and rotation matrix. independent_of_N and zero_matrix are unchanged.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 20, 2026 15:55

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.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants