PhysiCell icon indicating copy to clipboard operation
PhysiCell copied to clipboard

add update_density and update_parameter function

Open elmbeech opened this issue 1 year ago • 1 comments

pull request for the staled pull request https://github.com/MathCancer/PhysiCell/pull/264, https://github.com/MathCancer/PhysiCell/pull/250 and https://github.com/MathCancer/PhysiCell/pull/232.

this pull request is compatible with physicell version 1.14.0 and keeps the changes to the existing code bases as small as possible. default settings were chosen so that the current models not will break through these changes. each case was manually tested, the code works as expected.

add_density and add_parameter functions:

Microenvironment::add_density: throw error, if a density with the same name already exists.
Parameters::add_parameter : throw error, if a parameter with the same name and type already exists.

update_density and update_parameter functions:

Microenvironment::update_density : new function which does not throw an error but updates the values, if a density with the same name already exists.
Parameters::update_parameter : new function which does not throw an error but updates the values, if a parameter with the same name and type already exists.

function calls arguments:

load_PhysiCell_config_file: additional bool update_variables argument with default set to false.
setup_microenvironment_from_XML (called from load_PhysiCell_config_file): additional bool update_density argument with default set to false.
User_Parameters::read_from_pugixml (called from load_PhysiCell_config_file): additional bool update_parameter argument with default set to false.

elmbeech avatar Sep 21 '24 12:09 elmbeech

as discussed, update_density and update_parameter through an error, if one tries to update a density or parameter that not already exists. the rest is the same.

elmbeech avatar Sep 25 '24 22:09 elmbeech

@drbergman can you please give your ok to this change? I really would like to get this pull request in now! thank you, Elmar

elmbeech avatar Nov 28 '24 05:11 elmbeech

Hi Paul (@MathCancer )! I attached a zip folder which contains physicell 1.14.1 inclusive the changes from this pull request. The main.cpp and the custom.cpp were adjusted to run consecutive episodes.

  • the main.cpp contains an extra episode loop.
  • the custom.cpp has generate_cell_types and a reset_cell_types function, which are based on the original create_cell_types function. I tried to use the physicell high-level functions as much as possible. All works well, if episodes run for e.g. 1440 min, but if episodes are e.g. set to 7200 min, the in the following episode I run into a core dump, when I try to delete all the cells. This is where I am at this moment stuck with this pull request. Elmar Dec_26_2024_0443.zip

elmbeech avatar Dec 26 '24 10:12 elmbeech

I'd suggest making any new arguments to functions as optional, if possible. E.g., void initialize_microenvironment( bool update_microenvironment = true). This would avoid needing to edit all the sample projects.

rheiland avatar Dec 31 '24 12:12 rheiland

Thank you, @rheiland! This is exactly the way I implemented it. BioFVM/BioFVM_microenvironment.cpp line 1178 (1178 -1230) and BioFVM/BioFVM_microenvironment.h line 370. However, I set the default from bool update_microenvironment = false because update is only needed if you run another episode. The code is passing all the old unit tests. It will not break with the past. There is no need to change any old project code.

elmbeech avatar Jan 01 '25 10:01 elmbeech

superseded by pull request: https://github.com/MathCancer/PhysiCell/pull/344

elmbeech avatar Jan 03 '25 16:01 elmbeech