Skip to content

Resume cells on their saved cycle model and phase - #449

Open
drbergman wants to merge 3 commits into
MathCancer:developmentfrom
drbergman:fix-resume-cycle-state
Open

drbergman wants to merge 3 commits into
MathCancer:developmentfrom
drbergman:fix-resume-cycle-state

Conversation

@drbergman

@drbergman drbergman commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

recreate_sim_state() wrote each cell's saved cycle-model and phase codes into phenotype.cycle.model().code and current_phase().code. Both belong to the Cycle_Model shared by every cell of the type, so each cell read relabeled the shared model, while the cell itself never moved. It stayed on its definition's cycle model, in phase index 0. In a resumed run, dead cells therefore come back on their live cycle model with dead set. Apoptotic and necrotic cells are never removed, and dead cells keep dividing into dead daughters. In multi-phase models, every live cell restarts in phase 0, which then carries the last-read cell's phase code.

The reader now leaves the shared model alone. If the saved dead flag is set, it syncs the cell onto its saved death model, as Cell::start_death() does. It skips the death entry function, because the saved volumes and rates already reflect it. It then sets current_phase_index to the phase with the saved code. The elapsed time and exit rate are restored after the sync, so the sync does not reset them. This changes the dynamics of any resumed run that has dead cells or a multi-phase cycle model.

Same fix as drbergman#80.

🤖 Generated with Claude Code

recreate_sim_state() wrote the saved cycle-model and phase codes into
model().code and current_phase().code. Both belong to the Cycle_Model that
every cell of the type shares, so each cell read overwrote the codes for its
whole type, and the cell itself never moved: it stayed on its definition's
cycle model in phase index 0. Dead cells came back on their live cycle model
with dead = 1, so apoptotic and necrotic cells were never removed and dead
cells could divide.

Match the saved codes instead. If the saved model is not the definition's
cycle model, sync the cell onto the death model with that code, as
Cell::start_death() does, without rerunning the death entry function (the
saved volumes and rates already reflect it). Then set current_phase_index to
the phase with the saved code. elapsed_time_in_phase is read afterward, so
the sync does not reset it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This comment was marked as resolved.

drbergman

This comment was marked as resolved.

drbergman and others added 2 commits December 3, 2026 15:18
Per review: instead of matching the saved cycle-model code against the
definition's death models, use the saved dead flag and death model index,
and drop the code-matching warnings. The phase code, elapsed time and exit
rate are now kept in locals and restored in one place after the death state
is read, since a dead cell's sync to its death model resets the cycle data.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The necrosis entry function sets rupture_volume from the cell's volume when
it died, and cells.mat does not save it, so a resumed cell keeps its cell
definition's value. Document the limitation until rupture_volume is saved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@drbergman drbergman reopened this Dec 3, 2026
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.

2 participants