Repository navigation
A quantity boundary value is non-dimensionalised in a units model (#1238) - #1264
Conversation
) add_condition replaced a uw.quantity or pint Quantity by its SI magnitude and applied that number in model units. An older path then divided plain numbers by the field's scaling_coefficient, which happened to give the model value for a velocity on a field the solver made; with fields passed in without units, a scalar field without units, or a traction (divided by the velocity scale), the value was wrong, 3e9 off for 5 mm/yr against a 10 mm/yr reference, with no warning. In a model with reference quantities a quantity is now non-dimensionalised, as the body force is, and is not divided again. Without reference quantities the SI magnitude is still the value. Underworld development team with AI support from Claude Code
|
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)) At 82df5f0: ready to merge on green from this review. The fix does what the PR says. A quantity in a boundary condition now lands in model units in every case we tried: essential and natural, in a tuple and as a single value, uw.quantity and pint, on fields with and without units, and on Stokes, Poisson, AdvDiffusion and Projection. Plain numbers, sympy expressions and models without reference quantities are unchanged. Plain numbers are bitwise unchanged. The conversion is the same on every rank, and an empty rank does not change it. One medium finding: a quantity of the wrong dimension is still accepted with no error, and it now gives a plausible O(1) number. Development also accepted it with no error. It does not block this PR. Method
Results: recorded value (serial)"Solver's fields" means the solver made its own fields, which carry units (velocity scale 3.169e-10 m/s). "Passed fields" means fields passed in without units (scale 1).
Plain numbers and sympy entries: development and head are identical to the last digit in every case. Some examples: Mixed tuples: the quantity is converted and the plain number keeps its old meaning. Without reference quantities, the full probe (81 cases) gives identical output on development and head. Results: after a solve (serial)
Head now agrees with the Results: parallelThe probe uses a gmsh box (cellSize 0.1) and solves four problems. Stokes with passed fields has a 5 mm/yr wall and a 0.1 MPa top traction. Stokes with the solver's fields has a 5 km/Myr wall. Poisson has a 5 km wall. AdvDiff has degC walls with a temperature reference. Layouts: np 1; np 2 with horizontal bands; np 3 with an empty rank (cells 121/121/0, checked on each rank). All ranks recorded the same value in every case.
np 2 and np 3 agree to all digits printed. np 1 differs from them by 3e-6 relative, and development shows the same np 1 vs np 2 difference. On head, the two Stokes variants agree with each other: 0.43676 × 3.1688e-10 m/s = 1.384e-10 m/s. On development they did not. Regression runs
Findings
Code reading: there is no rank-dependent branch. The conversion depends only on the model's reference quantities, and the runs above confirm this. The one Not run
Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
H1's review of #1264: with the conversion fixed, 1 MPa on a velocity wall became a believable 0.0316 where development's 3e15 was plainly wrong. On a field with units the value of an essential condition must have the field's dimension; otherwise it is refused, naming both. A quantity on a field without units (the case #1238 was filed for) and a pure number are accepted as before. Underworld development team with AI support from Claude Code
|
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)) At a9ebf94: changes requested. This is a short re-check of the one new commit since our review at 82df5f0. The check works as described for velocity, Poisson, vector projection and temperature fields in K. A quantity of the wrong dimension is refused at add time, the error names both dimensions, and every rank raises the same error. One new problem needs a one-line fix first. On a field whose units are Earlier findings, then and now
RunsHead a9ebf94 was built fresh. All 12 compiled modules are newer than the build start, and every probe prints Recorded value of an essential condition:
Code reading. The check runs inside Findings
Not run
Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
…self The parallel review of #1264: on a field in degC every quantity in an essential condition raised pint's OffsetUnitCalculusError, the right ones too, because the check multiplied the field's unit by 1. It now reads the unit's own dimensionality. The message names the condition (essential, Dirichlet) and the component when there are several, and the docstring says a field without units is not checked. Underworld development team with AI support from Claude Code
|
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)) At 1c98a1b: ready to merge on green from this review. This is a short re-check of the one new commit since a9ebf94. The check now takes the field's dimension from the unit itself. On a field in Earlier findings, then and now
RunsHead 1c98a1b was built fresh. All 12 compiled modules are newer than the build start, and every run prints
Code reading. The diff is the one-line dimension change, the component index (only when Findings
Not run
Logs kept by the reviewer. Underworld development team with AI support from Claude Code |
What changes for users: in a model with reference quantities, a boundary condition given as a
uw.quantity(or a pint Quantity) is applied in model units. Before, it could be applied at its SI magnitude: a wall at 5 mm/yr against a 10 mm/yr reference got 1.58e-10 where 0.5 is right, with no warning.Closes #1238. Found by the units desk (a Claude session). The development values in the table were measured on development's
add_condition. Runs were on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), on development c902390.The defect, more narrowly than the issue put it
add_conditionreplaced a quantity byto_base_units().magnitude, its SI number. An older path then divides plain numbers by the field'sscaling_coefficient. For a velocity on a field the solver made itself, which carries units, that division happened to give the model value. It is wrong in three cases:uThe fix
test_0812relies on this. The UNFILED item 17 PR gives such a dimension its SI base unit as the scale, and after it this branch's fallback gives the same answer by the same route.Test
tests/test_0774_boundary_condition_quantities_in_a_units_model.py, 14 tests:uw.quantityand a pint quantity, a natural traction, and a single value on a Poisson field;On development 4 fail: the fields passed without units, the scalar field, the traction, and the wrong-dimension refusal. The cases that development already got right pass on both.
Regression runs
tests/test_*.pyexcept tier C, 6 xdist workers, on 529f1765: 4431 passed and 3 failed, all intest_0812, the dimension with no reference. The fallback above was then added (82df5f0), andtest_0774andtest_0812give 12 passed.scripts/test.sh --parallel-only --p 2on 82df5f0: all passed.test_07*,test_08*,test_100*totest_102*): 1906 passed, 0 failed;test_0774andtest_0812, 18 passed.Checklist (UW3 Style Charter)
level_*andtier_*markers (S8)except ValueErrornames the case it handlesUnderworld development team with AI support from Claude Code