Skip to content

Fix units setup in vector projection Poisson test#227

Open
ss2098 wants to merge 1 commit into
underworldcode:mainfrom
ss2098:fix-test-1450-units-reference-scales
Open

Fix units setup in vector projection Poisson test#227
ss2098 wants to merge 1 commit into
underworldcode:mainfrom
ss2098:fix-test-1450-units-reference-scales

Conversation

@ss2098

@ss2098 ss2098 commented Jun 9, 2026

Copy link
Copy Markdown

Summary

This PR fixes test_vector_projection_after_poisson_with_units() by setting model reference quantities before creating meshes and MeshVariable objects with physical units.

The test previously failed in strict units mode with:

ValueError: Strict units mode: Cannot create variable 'T' with units='kelvin' when model has no reference quantities.

What changed

Added reference quantity setup at the start of test_vector_projection_after_poisson_with_units():

uw.reset_default_model()
model = uw.get_default_model()
model.set_reference_quantities(
    domain_depth=uw.quantity(1.0, "m"),
    plate_velocity=uw.quantity(1.0, "m/s"),
    mantle_viscosity=uw.quantity(1.0, "Pa*s"),
    temperature_difference=uw.quantity(1.0, "K"),
)

Rationale

Strict units mode requires model reference quantities to be configured before creating variables with units. This updates the test setup to match the current units-system behavior. The Poisson solve and vector projection logic are unchanged.

Testing

Ran:

pixi run python tests/test_1450_poisson_vector_projection.py

Output:

Structured box element resolution 16 16
✓ test_vector_projection_after_poisson passed
✓ Units system active with automatic non-dimensionalization
Structured box element resolution 16 16
✓ test_vector_projection_after_poisson_with_units passed
Structured box element resolution 16 16
✓ test_multiple_solvers_sequence passed

✓ All tests passed!

@ss2098 ss2098 requested a review from lmoresi as a code owner June 9, 2026 04:36
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.

1 participant