Repository navigation
Hybrid histogram: bin each molecule to a node in its own compartment - #34
Merged
Merged
Conversation
computeHistogram binned every molecule to its nearest grid node, whatever compartment that node belonged to. Next to a curved membrane a molecule just inside the cell can be nearest to an exterior node, where the coupled continuous species is not solved, so its PDE contribution was lost (1.2% of A on a ball, R = 16 cells; 0.6% mass lost in a conversion run). The nearest same-compartment re-binning written for this in 2011 was commented out for performance (742e6d7) before the spatial hybrid existed. posincompart now answers from the highResVolumeSamples map, which removes most of that cost. Re-enable it, restore isInSameCompartment, and fix the node centre it compares against (it omitted the mesh origin and used dy for z). Fixes #25. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #25.
The bug.
VCellSmoldynOutput::computeHistogrambins each molecule to its nearest grid node, whatever compartment that node is in. Next to a curved membrane, a molecule inside the cell can be nearest to an exterior node. The PDE does not solve the coupled species there, so that molecule's contribution is lost.The fix. The nearest same-compartment re-binning written for this in 2011 was commented out for performance (742e6d7), before the spatial hybrid existed. Since then,
posincomparthas gained thehighResVolumeSamplesmap, which removes most of that cost. This PR:isInSameCompartmentfrom 1edb089;dyfor z.The issue has the full history.
Measured. Native runs through libvcell → pyvcell-fvsolver: ball R = 4 µm on a 37³ mesh of [0,9]³, 8 seeds.
A_p → B: A + B mass balance at 2 sA_p ⇌ B: A + B mass balance at 5 sNot covered. I haven't run the C++ test suite locally; CI covers it. The cases come from viva-pde-particle, Study B2b
sphere-cosim-vs-native.🤖 Generated with Claude Code