fix(stokes): bodyforce setter accepts a UWQuantity component#284
Merged
Conversation
The Stokes bodyforce setter tried to handle UWQuantity components via item._sympify_() — a method that does not exist on UWQuantity (_sympy_ also raises on a dimensional quantity). So any units-active buoyancy assignment (stokes.bodyforce = [0, ρ₀ α g (T − T_ref)]) crashed with AttributeError: 'UWQuantity' object has no attribute '_sympify_'. The body force feeds the non-dimensional solver, so non_dimensionalise the UWQuantity component (consistent with the ND<->units boundary contract and the #282 fix). The component may be symbolic (a buoyancy carries the T field), so non_dimensionalise yields a 1x1 array/Matrix whose element is extracted (the existing shape-handling is preserved). Plain non-quantity components are unchanged. Verified: a symbolic UWQuantity buoyancy assigns to bodyforce as the correct ND expression; test_1010 (Stokes) unchanged. Regression: tests/test_1011_bodyforce_units.py. The second blocker (after #267/#282) for the thermal-convection units tutorial (#263). Underworld development team with AI support from Claude Code
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.
Summary
The Stokes
bodyforcesetter crashed on a units-active buoyancy (stokes.bodyforce = [0, ρ₀ α g (T − T_ref)]):The setter's
UWQuantitybranch calleditem._sympify_()— which doesn't exist (_sympy_also raises on a dimensional quantity).Fix
non_dimensionalisetheUWQuantitycomponent (the body force feeds the ND solver — same boundary as #282). The component may be symbolic (buoyancy carries the T field), so non_dimensionalise yields a 1×1 array/Matrix whose element is extracted (existing shape-handling preserved). Plain components unchanged.Verification
612.34*{T} − 306.17).test_1010(Stokes) unchanged. Regression:tests/test_1011_bodyforce_units.py.Third blocker (after #267 trace-back, #282 meshvar±quantity) for the thermal-convection units tutorial (#263).
Underworld development team with AI support from Claude Code