Skip to content

Add advection velocity to species mapping + 'user defined' parameter role - #48

Merged
jcschaff merged 3 commits into
mainfrom
support-velocity
Jun 18, 2026
Merged

Add advection velocity to species mapping + 'user defined' parameter role#48
jcschaff merged 3 commits into
mainfrom
support-velocity

Conversation

@jcschaff

Copy link
Copy Markdown
Member

Cherry-picked from @LDre398 (Logan Drescher), then reviewed, fixed (rebase gaps), tested and linted.

What's in here

Advection velocity on species mappings — round-trips a <Velocity X= Y= Z=> element under LocalizedCompoundSpec:

  • SpeciesMapping gains velocity_x/_y/_z (float | str | None), included in expressions for field-data extraction;
  • reader visit_Velocity parses the element; writer emits it, writing only non-"0.0" components.

Parameter roleModel.add_model_parameter(...) now defaults role="user defined" (and accepts an override), matching VCell's Java representation (was "model_parameter").

Reader method renamegeneric_visitgeneric_visit_children (clearer intent), updated across the visitor.

New SASCO fixtures + tests exercise the feature end-to-end (load → write → simulate → plot), including a velocity model that yields 21 velocity output channels.

Review notes — rebase gaps I fixed

These cherry-picks were authored before the data-model split (#41) and the lenient-reader work (#44), so the rebase left three breakages:

  1. Dropped velocity fields. SpeciesMapping moved from models.py to models_app.py, so the rebase lost the velocity_x/_y/_z field additions. The reader's node.velocity_x = … would raise on a pydantic model with no such field — i.e. any VCML with a <Velocity> element failed to load. Restored the fields.
  2. Incomplete rename. generic_visitgeneric_visit_children missed visit_Parameter (vcml_reader.py:212); the stale call was silently swallowed by the best-effort backstop (a caught AttributeError per <Parameter>, plus dropped nested-parameter children). Fixed the call site.
  3. Unregistered fixtures. The two SASCO fixtures were added to model_fixtures.py but not imported in conftest.py, so the new tests errored with "fixture not found". Registered them.

Also tidied test_results_writing.py (removed debug prints / commented-out dead code, added a channel_data assertion, run cleanup() in finally).

Verification

  • Velocity parses and round-trips through reader→writer (smoke-tested); existing reader/writer round-trip equality is preserved (those fixtures have no velocity → no regression).
  • make check green — ruff, mypy (312 files), deptry, uv lock --check.
  • New SASCO simulation tests pass (incl. len(velocity_channels) == 21); full tests/vcml suite → 43 passed, 5 skipped.

Note

The SASCO tests run real FV simulations (small 16×31×1 2D mesh, EndTime=10 — ~50s total), so they add some CI time but validate the velocity output end-to-end.

🤖 Generated with Claude Code

CodeByDrescher and others added 3 commits June 17, 2026 23:48
Repairs three issues introduced when these cherry-picks were rebased onto main:

- SpeciesMapping moved to models_app.py in the data-model split, so the rebase
  dropped the velocity_x/_y/_z fields the reader/writer rely on — restore them
  (and include velocity in `expressions` for field-data extraction). Without
  this, parsing any VCML with a <Velocity> element raised on an unknown field.
- The generic_visit -> generic_visit_children rename missed visit_Parameter
  (vcml_reader.py:212); the stale call was masked by the best-effort backstop
  (caught AttributeError per parameter). Fix the call site.
- Register the new SASCO fixtures (vcml_sasco_model_path,
  vcml_sasco_model_with_velocity_path) in conftest so the new tests resolve them.

Also tidy test_results_writing (drop debug prints/dead code, add a channel_data
assertion, cleanup in finally).

Velocity round-trips through the reader/writer; existing reader/writer round-trip
equality is preserved (no velocity in those fixtures). make check green; new
SASCO simulation tests pass (incl. the 21-velocity-channel assertion); full vcml
suite 43 passed / 5 skipped.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jcschaff
jcschaff merged commit f0c4a18 into main Jun 18, 2026
5 checks passed
@jcschaff
jcschaff deleted the support-velocity branch June 18, 2026 04:15
@jcschaff jcschaff mentioned this pull request Jun 18, 2026
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