Repository navigation
Conversation
UNFILED 40: MeshVariable.diff() returned a UnitAwareDerivativeMatrix with no arithmetic, so tutorial 3's s.diff(x) + s.diff(y) raised TypeError. It now adds, subtracts, multiplies, divides and negates as its sympy Matrix does; a scalar applies to every entry; get_units reads the result's units from the derivatives. UNFILED 41: uw.scaling.non_dimensionalise refused a uw.expression holding a quantity (DimensionalityError, km to dimensionless), so an Annulus with its radii as expressions failed (tutorial 15), and uw.non_dimensionalise refused an expression or Matrix built from fields (tutorial 12's temperature / velocity[0]). A named expression holding a quantity or number takes that value's path; any other expression, or a Matrix, gives its model-unit form, uw.unwrap(expr, keep_constants=False). Underworld development team with AI support from Claude Code
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes for users:
s.diff(x) + s.diff(y)and other arithmetic on a variable's derivative work, as in tutorial 3.uw.non_dimensionaliseanduw.scaling.non_dimensionalisetake auw.expression, and an expression or Matrix built from fields. So a mesh takes its lengths as expressions, as in tutorial 15's annulus, and tutorial 12'suw.non_dimensionalise(temperature / velocity[0])gives its model-unit form.UNFILED 40 and 41, found in the tutorials run 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 da35d14.
UNFILED 40: arithmetic on a derivative
MeshVariable.diff()returns aUnitAwareDerivativeMatrix. It indexes into unit-aware elements, but had no arithmetic, with or without a units model:s.diff(x) + s.diff(y)ands.diff(x) + 1raised TypeError. It now adds, subtracts, multiplies, divides and negates. The result is the plain sympy Matrix of the same arithmetic on the underlying derivatives, so it equals thes.sym.diff(x)form, andget_unitsreads its units from the derivatives in it. A scalar applies to every entry; sympy itself refuses a Matrix plus a scalar, and for a scalar field's 1×1 derivative this is plain addition.UNFILED 41: non-dimensionalising an expression
uw.scaling.non_dimensionalise, which the mesh constructors use, refused auw.expressionholding a quantity. It looked for.unitless, then multiplied by a pint Unit, giving DimensionalityError from km to dimensionless. A named expression holding a quantity or a number now takes that value's path.uw.non_dimensionaliserefused an expression or Matrix built from fields ("Cannot non-dimensionalise object of type MutableDenseMatrix"). Such an expression now gives its model-unit form,uw.unwrap(expr, keep_constants=False): every constant as its model value, every field as the model-unit value it stores. The scaling entry point hands these to it..data. It now returns the value's model-unit form.Tests
tests/test_0776_derivative_matrix_arithmetic.py, 3 tests: every operation against thes.symform as a sympy Matrix; a scalar on every entry; and the units of a sum of two derivatives (K/m).tests/test_0777_non_dimensionalise_expressions.py, 6 tests:temperature / velocity[0];dimensionalise.On the previous build, 7 of the 9 fail. The two that pass are
uw.non_dimensionaliseof a named expression holding a quantity, which worked already, and the round trip.The tutorials
html5/. Without the folder it stops at the last cell, which writes an HTML file there.b.symon line 299:uw.function.derivative(..., evaluate=False)returns a sympyDerivative, which has no.sym. That is outside this PR.Regression runs
test_05*totest_08*), 6 xdist workers: 1661 passed, 0 failed.scripts/test.sh --parallel-only --p 2on 3d9ea0b: all passed.Checklist (UW3 Style Charter)
level_*andtier_*markers (S8)Underworld development team with AI support from Claude Code