Repository navigation
Conversation
Cell::update_position() zeroes velocity after every position update so it can accumulate forces for the next mechanics step. Output is written between mechanics steps, so the saved velocity was always (0,0,0). Write previous_velocity, which holds the velocity used in the last step. recreate_sim_state() now restores the saved value into previous_velocity rather than velocity. Loading it into velocity would add it on top of the freshly computed forces in the first step after resuming. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified in the velocity snapshot and restart-handling changes.
No open issues 🎉
What changed in this PR
Corrects PhysiCell velocity output and restart handling without changing simulation dynamics.
Changes:
- Saves the most recently computed velocity instead of the cleared force accumulator.
- Restores saved velocity into the integration history, avoiding extra velocity on the first resumed step.
| File | Description |
|---|---|
modules/PhysiCell_MultiCellDS.cpp |
Writes and restores previous_velocity in cell snapshots. |
Review effort: Balanced
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.
The
velocityfield in everyoutput*_cells.mathas always been (0,0,0).Cell::update_position()zeroesvelocityat the end of each mechanics step so it can accumulate forces for the next one, and output is written between mechanics steps, so the writer only ever saw the zeroed vector. This PR writesprevious_velocityinstead, which is the velocity used in the most recent position update. Simulation dynamics are unchanged; only the saved values differ.recreate_sim_state()(used byresume_from_MultiCellDS()) read the saved value back intovelocity. That was harmless while the value was always zero, but with real values it would add the saved velocity on top of the freshly computed forces in the first step after resuming, so cells would overshoot by about 3x on that step. The reader now restores the value intoprevious_velocity, which also gives the Adams-Bashforth update its history. Before this change, a resumed run's first step overshot by 1.5x because that history was missing.🤖 Generated with Claude Code