SmoldynFileWriter sets no boxsize: models starting with few or no particles get one virtual box (N×M surface checks)

Open
#2,159 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
66/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
java

Research direction

Start at vcell-core/src/main/java/org/vcell/solver/smoldyn/SmoldynFileWriter.java, where the .smoldynInput file is assembled, and locate where box statements could be emitted alongside molperbox. Determine what mesh-spacing or diffusion-length information is available at that point (the writer already has geometry/membrane panel data) to compute a boxsize. Done means a model starting with zero or few particles produces a .smoldynInput containing an explicit boxsize, verified by running such a model and checking Smoldyn's log reports more than 1 virtual box.

Written by the indexing model from the issue text.

Description

Summary

SmoldynFileWriter writes neither boxsize nor molperbox. Smoldyn then sizes its virtual boxes from the initial molecule count.

In vcell-fvsolver's Smoldyn 2.38, boxesupdatelists uses mpbox = 4 or 5 and molcount(...) (L638). The boxes per side are ceil(L·(n / mpbox / V)^(1/dim)). A model that starts with no particles, e.g. particles created by a reaction, therefore gets 0 → clamped to 1 box per side, so a single box. Few initial particles give a few huge boxes.

With one box, every molecule is tested against every surface panel every time step: N molecules × M triangles. VCell meshes membranes finely (9,516 triangles for a 4 µm sphere on a 37³ mesh), so this can dominate run time as particles accumulate.

Evidence

  • Native: confirmed from the code above, not from a timed run. The .smoldynInput VCell generates has no box statements, and vcell-fvsolver's log does not print Smoldyn's box parameters.
  • The same Smoldyn logic, measured in a co-simulation (upstream Smoldyn with the VCell hybrid extensions; 806 membrane triangles; exchange model starting with 0 particles):
    • Smoldyn reported 1 virtual box. Profiling put about 95% of the time in checksurfaces → lineXpanel/panelside.
    • Setting boxsize explicitly (two grid spacings) cut the cost 10×, from 4.55 to 0.45 wall s per simulated s.
    • A model starting with 20,000 particles automatically got 18³ boxes and did not show the problem.
    • Details: DESIGN.md §11.

Suggested fix

Write boxsize explicitly, e.g. a small multiple of the mesh spacing (or the diffusion length per step), instead of relying on molperbox and the initial count.

Related, and already in VCell: the highResVolumeSamples map accelerates compartment tests (posincompart). Box sizing is the corresponding acceleration for collision checks during diffusion.

Found while benchmarking the embedded hybrid against a process-bigraph co-simulation (vivarium-collective/viva-pde-particle).

Dominant language
Java
Stars
140
Forks
35
Avg merge
17h 39m
Merged PRs (30d)
19

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from virtualcell/vcell

All issues in virtualcell/vcell

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.