Repository navigation
A dimension with no reference has the SI base unit as its scale (E/R met the temperature reference) - #1284
Conversation
The model's scale for a dimensionality was built from its fundamental scales, and a fundamental dimension without one (amount of substance; a temperature with no temperature reference) raised. Every caller that caught the error fell back to a raw number: UWQuantity.data returned the value in its own units, so an activation energy of 3e5 J/mol and a gas constant of 8.314 J/(mol K) gave E/R = 36084, in kelvin, never divided by the temperature reference. With 1000 K, E/(R T) was 1000 times too large and the normalised Arrhenius factor overflowed to NaN; 300 kJ/mol gave 300. The integral's relabelling, the non-dimensionalisation of a unit-aware array and dimensionalise all went through the same lookup. Such a dimension now has one SI base unit as its scale (one mole; one kelvin with no temperature reference), the scale a field of that dimension already runs at. test_0775 checks each against the hand value, through evaluate, an Integral and a round trip; all 8 fail on development. 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)) #1284 at d1eaf50: a dimension with no reference gets its SI base unit as the scaleVerdict at d1eaf50: ready to merge on green from this review. The fix does what it says. With a 1000 K temperature reference, both Arrhenius forms used to give NaN and now match the hand value to 3e-16. An Arrhenius-viscosity Stokes solve used to stop with NaN/Inf and now converges, with the same answer at np 1, np 2 and np 3 with an empty rank. Nothing that ran on development changed: 139 units test files, 14 parallel units files and 26 docs examples. Finding 1 (Medium) is a regression in What users see differently
Method
ResultsArrhenius at T = 1200 K, T0 = 1000 K, through
E = 1e5 J/mol (hand 0.13470733) shows the same pattern. Scales and model values (L = 30 km, viscosity 1e24 Pa s, velocity 2.5 mm/yr; "+T" adds 1000 K)
Solves
At np 2 and np 3, every rank, including the empty one, printed the same J/mol scale (7.1298197581567495e22) and the same model values for E and R. Tests
#1264 at a9ebf94, with and without this PR (Poisson, top at 1600 K, Neumann flux of 2.6 K·m/s at the bottom, κ = 1 m²/s; hand value 300 K at the bottom)
With this PR's Findings
What was run and not run
Underworld development team with AI support from Claude Code |
The parallel review of #1284: the field-creation warning for a dimension without a reference said the variable "will use scaling_coefficient=1.0", which is no longer what happens. It now says the dimension takes its SI base unit, and gives the variable's model unit (2.64e-15 K/s for K/s in a model with no temperature reference). The _SI_BASE_UNITS comment covers every fundamental dimension, and test_0775 drops a hasattr hedge. Underworld development team with AI support from Claude Code
What changes for users: in a model with reference quantities, a constant whose units include a dimension the model has no reference for has the right model value. An activation energy in J/mol over a gas constant in J/(mol K) is the clearest case. With a temperature reference, the normalised Arrhenius factor
exp(E/(R*T) - E/(R*T0))was 1000 times too large in its exponent and overflowed to NaN; it now evaluates to its value. Without a temperature reference a quantity with amount of substance changes too: in the parallel review's model, 300 kJ/mol had the model value 0.994 and now has 0.00244, its energy over the model's energy scale.The UNFILED item 17 (a NaN in
exp(A*T0/T)*exp(-A)), found and fixed by the units desk (a Claude session). Runs were on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), on development e7e02b9.The defect
Model.get_scale_for_dimensionalitybuilds a scale from the fundamental scales: length, mass, time, temperature. It raised for a dimension with none, which is amount of substance always, and temperature when no temperature reference is given. Every caller caught the error and fell back to a raw number:UWQuantity.data, a named constant's model value. It returned the value in the quantity's own units. So E = 3e5 J/mol gave 3e5 and R = 8.314 J/(mol K) gave 8.314. Their ratio, 36084, is in kelvin, and it never met the temperature reference. Against 1000 K,E/(R*T)came out 25774 where 25.77 is right. The same energy written as 300 kJ/mol gave 300.Integral. It returned the model-unit number labelled with physical units.non_dimensionaliseof a unit-aware array. It warned and returned the array unchanged.dimensionalise. It refused.The fix
In
get_scale_for_dimensionality, a fundamental dimension with no reference takes its SI base unit as the scale: one mole, one kelvin. That is the scale a field of that dimension already runs at: a field in K with no temperature reference warns at creation and uses a scaling coefficient of 1. A mole cancels in every ratio with a meaning. A temperature with no reference stays in kelvin, as before. Every caller listed above goes through this one lookup, so each is fixed by it. A dimension outside the SI base set still raises.Test
tests/test_0775_unreferenced_dimension_scales.py, 8 tests, each against the hand value. All 8 fail on development:E.data / R.dataisE/Rin units of the 1000 K reference;exp(E/(R T) - E/(R T0)),exp(E (1/T - 1/T0)/R)andexp(A T0/T) exp(-A)withA = E/(R T0): each gives 25.0722 at T = 1400 K, T0 = 1600 K, throughevaluate;Integral, which is the JIT's constants path;dimensionalise.Regression runs
tests/test_*.pyexcept tier C, 6 xdist workers, on d1eaf50: 4462 passed, and 3 failed, alltest_1086_mmpde_seam_matches_serial. Its spawned runs go silent under load, a known artefact.scripts/test.sh --parallel-only --p 2on d1eaf50: all passed.Relation to open PRs
evaluateof a J/mol expression with a field in it (R*T) is still wrong after this PR. The cause is inevaluateitself, an absolute 1e-18 term in model units, and J/mol model values are about 1e-18. The solvers andIntegralare exact. It is tracked separately (UNFILED 42).Checklist (UW3 Style Charter)
level_*andtier_*markers (S8)Underworld development team with AI support from Claude Code