Skip to content

Conversation

@akutuva21
Copy link

Add Multi-Compartment (cBNGL) Support to NFsim

This PR adds native support for multi-compartment (cBNGL) models to NFsim, enabling molecule transport between compartments. Previously, NFsim only supported well-mixed (single-compartment) simulations.

Key Features

  • New Compartment Class: Added compartment.hh/cpp to manage compartment hierarchies and properties.
  • Molecule Transport: Implemented MoveTransformation to handle the transport of molecules matching specific patterns between compartments.
  • XML Support: Added XML parsing for the <ChangeCompartment> operation, enabling full compatibility with cBNGL models exported from BioNetGen.
  • Improved Integration: Updated System and Molecule classes to correctly track and manage compartment assignments during a simulation.

Technical Details

  • Core: Added getCompartmentId() to Molecule and TemplateMolecule.
  • Destruction: Fixed destructor syntax in system.cpp and added compartment cleanup.
  • Input: Updated NFinput.cpp to parse compartment definitions and set up parent-child relationships correctly.

Verification

The implementation has been verified through:

  1. WASM Integration: Successfully bundled and tested in a BioNetGen web simulator using Playwright.
  2. Native Build: Successfully compiled as a native binary (MinGW/CMake) and verified using BNG2.pl.
  3. Parity Tests: Confirmed results match analytical solutions and standard BNGL ODE/SSA engines for transport models.

Files Modified/Added

  • src/NFcore/compartment.hh (New)
  • src/NFcore/compartment.cpp (New)
  • src/NFcore/molecule.cpp
  • src/NFcore/templateMolecule.cpp
  • src/NFcore/templateMolecule.hh
  • src/NFcore/system.cpp
  • src/NFcore/NFcore.hh
  • src/NFinput/NFinput.cpp
  • src/NFreactions/transformations/transformation.cpp
  • src/NFreactions/transformations/transformation.hh
  • src/NFreactions/transformations/transformationSet.hh
  • src/NFreactions/transformations/moleculeCreator.hh

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