Skip to content

Hybrid models through SBML Spatial, and vcml_convert_units - #26

Merged
jcschaff merged 3 commits into
mainfrom
feat/sbml-spatial-hybrid
Oct 8, 2026
Merged

jcschaff merged 3 commits into
mainfrom
feat/sbml-spatial-hybrid

Conversation

@jcschaff

@jcschaff jcschaff commented Oct 8, 2026

Copy link
Copy Markdown
Member

1. VCell submodule bump: PDE/particle hybrids through SBML Spatial. The submodule now points at virtualcell/vcell#2175.

  • vcml_to_sbml writes spatial stochastic (Smoldyn / PDE-particle hybrid) applications. Each species carries its representation as <vcell:SpeciesContextSpecSettings vcell:representation="continuous|particle"/>; absent means continuous.
  • sbml_to_vcml reads that representation back as a hybrid application.
  • Merge order: merge #2175 first, then repoint the submodule at its merge commit.

2. New vcml_convert_units(vcml_content, unit_system, vcml_file_path). It rewrites a VCML BioModel in another model unit system, converting every quantity, geometry included, with VCell's own ModelUnitConverter.

  • "vcell" means µm, µM and s: VCell's default units, and what its spatial and stochastic math assumes.
  • "sbml" means the units VCell writes SBML in: dm, µmol, l and s.
  • Why it's needed: VCell imports SBML in the SBML's own units, so a converted model can otherwise come back in dm. pyvcell's convert_units (in a companion pyvcell PR) wraps this.
  • It's a new C entry point, vcmlConvertUnits, plus its ctypes binding and Python API.

Tests

  • vcell-native:
    • test_hybrid_vcml_to_sbml_to_vcml: a hybrid with A as particles and B forced continuous goes VCML → SBML → VCML. The annotations come out, and so do Stochastic="true" and the ForceContinuous flags.
    • test_vcml_convert_units: TinySpatial (dm) → VCell units → SBML units, plus rejection of an unknown unit system.
  • Python: test_vcml_convert_units, the same conversion through the native library.
  • Changed: testSbmlToFiniteVolumeInput_not_well_formed now expects SBMLImportException("Unable to read SBML stream"). The newer vcell-core reads the SBML stream itself, so JSBML's ClassCastException no longer surfaces, which is the improvement the test's TODO asked for.
  • Results: locally on macOS arm64 (GraalVM CE 23.0.2), the vcell-native tests pass (32), and so does tests/test_libvcell.py (20) against the native library from scripts/local_build_native.sh.

Context: Phase 6 of viva-pde-particle, describing hybrid models in SBML Spatial. With this build, a hybrid run on the native VCell solver from its SBML (SBML → VCell import → vcell-fvsolver) is bit-identical to the run from the original VCML with the same seed.

🤖 Generated with Claude Code

- Bump the vcell submodule to virtualcell/vcell#2175: SBML Spatial export
  and import of spatial stochastic (PDE/particle hybrid) applications, with
  each species' representation (continuous or particle) in a vcell
  annotation.
- New entry point vcml_convert_units(vcml_content, unit_system,
  vcml_file_path): rewrites a VCML BioModel in VCell's units ("vcell":
  um, uM, s) or VCell's SBML units ("sbml": dm, umol, l, s), converting
  every quantity, geometry included (ModelUnitConverter). VCell imports SBML
  in the SBML's own units; this converts it.
- Tests: a hybrid vcml_to_sbml -> sbml_to_vcml round trip, and unit
  conversion both ways (Java and Python).
- The not-well-formed SBML test now expects SBMLImportException ("Unable to
  read SBML stream"): the newer vcell-core reads the stream itself, so the
  ClassCastException from inside JSBML no longer surfaces.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jcschaff and others added 2 commits October 7, 2026 21:32
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jcschaff
jcschaff merged commit 4dae1c2 into main Oct 8, 2026
5 checks passed
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