Skip to content

fix(stokes): bodyforce setter accepts a UWQuantity component#284

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/bodyforce-uwquantity-setter
Jun 24, 2026
Merged

fix(stokes): bodyforce setter accepts a UWQuantity component#284
lmoresi merged 1 commit into
developmentfrom
bugfix/bodyforce-uwquantity-setter

Conversation

@lmoresi

@lmoresi lmoresi commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

The Stokes bodyforce setter crashed on a units-active buoyancy (stokes.bodyforce = [0, ρ₀ α g (T − T_ref)]):

AttributeError: 'UWQuantity' object has no attribute '_sympify_'

The setter's UWQuantity branch called item._sympify_() — which doesn't exist (_sympy_ also raises on a dimensional quantity).

Fix

non_dimensionalise the UWQuantity component (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

  • A symbolic UWQuantity buoyancy now assigns as the correct ND expression (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

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
Copilot AI review requested due to automatic review settings June 24, 2026 03:33
@lmoresi lmoresi merged commit 1947512 into development Jun 24, 2026
@lmoresi lmoresi deleted the bugfix/bodyforce-uwquantity-setter branch June 24, 2026 03:33

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 reached their quota limit.

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.

2 participants