Repository navigation
Hybrid 0th-order creation: clipped boundary cells, and cells that straddle a membrane - #32
Merged
Merged
Conversation
…addle a membrane Field-dependent 0th-order creation in a compartment (zeroreact, OPTION_VCELL) drew Poisson(rate*dt*dx*dy*dz) molecules at each node whose centre was inside the compartment. Two errors: - Boundary nodes of the node-centred mesh own half, quarter or eighth cells, but the count used the full cell, so creation was overproduced by sum(full)/sum(clipped): 1.815x on an 11x11x3 slab (#24). The count now uses the cell clipped to the domain, the region randomPosInMesh fills. - Cells that straddle a curved membrane with their centre outside never drew, so creation fell short next to membranes (#26). Every cell whose node or a neighbouring node is inside now draws, and the existing posincompart thinning keeps exactly the molecules in cell & compartment. The rate of a straddling cell whose node is outside is evaluated at the nearest neighbouring node inside the compartment, because the field at the node itself belongs to another region. Node membership is tested with the node nudged just inside the domain, since nodes on the domain walls are ambiguous to posincompart. Fixes #24. Fixes #26. 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 #24 and #26. Both are in the same loop: the
OPTION_VCELLbranch ofzeroreactinsmoldyn-2.38/source/Smoldyn/smolreact.c, which handles field-dependent 0th-order creation in a compartment (reaction_cmpt c r 0 -> A k*B;). The loop moved into a helper,zeroreactcmptmesh.What changed
randomPosInMeshfills, instead of the fulldx·dy·dz.posincompartthinning then keeps exactly the molecules in cell ∩ compartment. Previously a cell drew only if its centre was inside, so straddling cells with the centre outside never created.posincompartis ambiguous for points exactly on a wall.Measured. Native runs through libvcell → pyvcell-fvsolver, 8 seeds each, B a static catalyst, comparing created A with the exact expectation. Before: the stock 0.10.7 wheel, numbers from the issues. After: this branch, built locally.
The remaining ~0.5% is a separate start-up artifact: Smoldyn skips 0th-order creation for about the first 2 of 200 steps.
Not covered
two-way-exchangeand B2bsphere-cosim-vs-native.Related: #25 (particle binning at the same membranes) and #23 (a second solve in one process); separate PRs.
🤖 Generated with Claude Code