From b4ff0a931c188f9019dda7df44e242a12fabb386 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Mon, 25 Aug 2025 14:17:29 -0400 Subject: [PATCH 1/5] add cell_division_direction_function for divide() --- core/PhysiCell_cell.cpp | 29 +++++++++++++++++++++++++---- core/PhysiCell_phenotype.h | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index a14c70b99..683817f5d 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -608,10 +608,19 @@ Cell* Cell::divide( ) normalize( &rand_vec ); rand_vec *= radius; // multiply direction times the displacement */ - - std::vector rand_vec = cell_division_orientation(); - rand_vec = rand_vec- phenotype.geometry.polarity*(rand_vec[0]*state.orientation[0]+ - rand_vec[1]*state.orientation[1]+rand_vec[2]*state.orientation[2])*state.orientation; + + std::vector rand_vec; + if( this->functions.cell_division_direction_function ) + { + rand_vec = this->functions.cell_division_direction_function( this ); + } + else + { + rand_vec = cell_division_orientation(); + rand_vec = rand_vec- phenotype.geometry.polarity*(rand_vec[0]*state.orientation[0]+ + rand_vec[1]*state.orientation[1]+rand_vec[2]*state.orientation[2])*state.orientation; + } + rand_vec *= phenotype.geometry.radius; child->assign_position(position[0] + rand_vec[0], @@ -1362,6 +1371,7 @@ void Cell::ingest_cell( Cell* pCell_to_eat ) pCell_to_eat->functions.update_phenotype = NULL; pCell_to_eat->functions.contact_function = NULL; pCell_to_eat->functions.cell_division_function = NULL; + pCell_to_eat->functions.cell_division_direction_function = NULL; // should set volume fuction to NULL too! pCell_to_eat->functions.volume_update_function = NULL; @@ -1613,6 +1623,7 @@ void Cell::fuse_cell( Cell* pCell_to_fuse ) pCell_to_fuse->functions.update_phenotype = NULL; pCell_to_fuse->functions.contact_function = NULL; pCell_to_fuse->functions.cell_division_function = NULL; + pCell_to_fuse->functions.cell_division_direction_function = NULL; pCell_to_fuse->functions.volume_update_function = NULL; // remove all adhesions @@ -1653,6 +1664,7 @@ void Cell::lyse_cell( void ) functions.update_phenotype = NULL; functions.contact_function = NULL; functions.cell_division_function = NULL; + functions.cell_division_direction_function = NULL; // remove all adhesions @@ -1750,6 +1762,13 @@ void display_ptr_as_bool( void (*ptr)(Cell*,Cell*), std::ostream& os ) os << "false"; return; } +void display_ptr_as_bool( std::vector (*ptr)(Cell*), std::ostream& os ) +{ + if( ptr ) + { os << "true"; return; } + os << "false"; + return; +} void display_cell_definitions( std::ostream& os ) { @@ -1836,6 +1855,8 @@ void display_cell_definitions( std::ostream& os ) os << std::endl; os << "\t\t cell division function: "; display_ptr_as_bool( pCF->cell_division_function , std::cout ); os << std::endl; + os << "\t\t cell division direction function: "; display_ptr_as_bool( pCF->cell_division_direction_function , std::cout ); + os << std::endl; // summarize motility diff --git a/core/PhysiCell_phenotype.h b/core/PhysiCell_phenotype.h index 701d816b5..13edc0c40 100644 --- a/core/PhysiCell_phenotype.h +++ b/core/PhysiCell_phenotype.h @@ -517,6 +517,7 @@ class Cell_Functions Cell* pOther, Phenotype& other_phenotype, double dt ); void (*cell_division_function)(Cell* pCell1, Cell* pCell2 ); + std::vector (*cell_division_direction_function)(Cell* pCell1); /* prototyping / beta in 1.5.0 */ /* From eb870b5809890f267413d5ff89ca1b5eef0f3031 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Thu, 28 Aug 2025 11:46:37 -0400 Subject: [PATCH 2/5] normalize vec from cell_division_direction_function --- core/PhysiCell_cell.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index 683817f5d..6be459835 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -613,6 +613,7 @@ Cell* Cell::divide( ) if( this->functions.cell_division_direction_function ) { rand_vec = this->functions.cell_division_direction_function( this ); + normalize( &rand_vec ); } else { From aa245886d080443922df496ea296b76e91712db3 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Thu, 28 Aug 2025 11:53:07 -0400 Subject: [PATCH 3/5] for 2D, set cell_division_direction_function z=0 --- core/PhysiCell_cell.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/PhysiCell_cell.cpp b/core/PhysiCell_cell.cpp index 6be459835..6b8b9d9b8 100644 --- a/core/PhysiCell_cell.cpp +++ b/core/PhysiCell_cell.cpp @@ -613,7 +613,9 @@ Cell* Cell::divide( ) if( this->functions.cell_division_direction_function ) { rand_vec = this->functions.cell_division_direction_function( this ); - normalize( &rand_vec ); + if( default_microenvironment_options.simulate_2D == true ) // ensure vec in XY plane + { rand_vec[2] = 0.0; } + normalize( &rand_vec ); // ensure normalized } else { From cfcaebdcb2ae7dc60316d8e417f69e5ccd080be8 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Fri, 29 Aug 2025 08:04:44 -0400 Subject: [PATCH 4/5] update --- config/bacteria.xml | 249 ++++++++++++++++++++++++++++++++++++ config/cells_bacteria.csv | 5 + custom_modules/custom.cpp | 262 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 516 insertions(+) create mode 100644 config/bacteria.xml create mode 100644 config/cells_bacteria.csv create mode 100644 custom_modules/custom.cpp diff --git a/config/bacteria.xml b/config/bacteria.xml new file mode 100644 index 000000000..c3f080f42 --- /dev/null +++ b/config/bacteria.xml @@ -0,0 +1,249 @@ + + + + -200.0 + 200.0 + -200.0 + 200.0 + -10.0 + 10.0 + 20.0 + 20.0 + 20.0 + true + + + + 5040.0 + min + micron + 0.01 + 0.1 + 6 + + + + 2 + + + + output_bacteria + + 60 + true + + + 60 + true + + substrate + YlOrRd + 0 + 1 + + + + false + + + + + false + true + false + system_clock + + + + + + 100000.0 + 10 + + 0 + 0 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + true + true + + ./config/initial.mat + + + ./config/dirichlet.mat + + + + + + + + + + 240 + + + 1.0 + + + + + 0 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 1.11667e-2 + 8.33333e-4 + 5.33333e-5 + 2.16667e-3 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0.4 + 10.0 + 1.25 + + 1 + + + 1.8 + 15.12 + + 0.01 + 0.0 + 0.0 + 12 + + + 1 + 1 + .5 + + false + true + + false + substrate + 1 + + + false + false + + 0.0 + + + + + + + 0 + 1 + 0 + 0 + + + + 0 + 0 + 0 + + 0 + + + 0 + + 1 + 0.1 + + 0 + + + + + 0 + + + + 0.0 + 0.0 + + + + 0 + + + + Volume + 4 + 2 + 100000 + + + apoptosis + 1e-6 + 1e-2 + + + + + + + + ./config + cells_bacteria.csv + + + + + + + ./config + cell_rules.csv + + + + + + + 0 + + \ No newline at end of file diff --git a/config/cells_bacteria.csv b/config/cells_bacteria.csv new file mode 100644 index 000000000..0920ba255 --- /dev/null +++ b/config/cells_bacteria.csv @@ -0,0 +1,5 @@ +x,y,z,type,custom:theta,volume,cycle entry,custom:GFP +0.0,-150.0,0.0,default,0 +-12.0,-140.0,0.0,default,2.06 +0.0,-130.0,0.0,default,1.27 +12.0,-140.0,0.0,default,0.49 diff --git a/custom_modules/custom.cpp b/custom_modules/custom.cpp new file mode 100644 index 000000000..acf38aa6f --- /dev/null +++ b/custom_modules/custom.cpp @@ -0,0 +1,262 @@ +/* +############################################################################### +# If you use PhysiCell in your project, please cite PhysiCell and the version # +# number, such as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# See VERSION.txt or call get_PhysiCell_version() to get the current version # +# x.y.z. Call display_citations() to get detailed information on all cite-# +# able software used in your PhysiCell application. # +# # +# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # +# as below: # +# # +# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # +# with BioFVM [2] to solve the transport equations. # +# # +# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # +# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # +# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # +# DOI: 10.1371/journal.pcbi.1005991 # +# # +# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # +# llelized diffusive transport solver for 3-D biological simulations, # +# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # +# # +############################################################################### +# # +# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # +# # +# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions are met: # +# # +# 1. Redistributions of source code must retain the above copyright notice, # +# this list of conditions and the following disclaimer. # +# # +# 2. Redistributions in binary form must reproduce the above copyright # +# notice, this list of conditions and the following disclaimer in the # +# documentation and/or other materials provided with the distribution. # +# # +# 3. Neither the name of the copyright holder nor the names of its # +# contributors may be used to endorse or promote products derived from this # +# software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +# # +############################################################################### +*/ + +#include "./custom.h" + +void create_cell_types( void ) +{ + // set the random seed + if (parameters.ints.find_index("random_seed") != -1) + { + SeedRandom(parameters.ints("random_seed")); + } + + /* + Put any modifications to default cell definition here if you + want to have "inherited" by other cell types. + + This is a good place to set default functions. + */ + + initialize_default_cell_definition(); + cell_defaults.phenotype.secretion.sync_to_microenvironment( µenvironment ); + + cell_defaults.functions.volume_update_function = standard_volume_update_function; + cell_defaults.functions.update_velocity = standard_update_cell_velocity; + + cell_defaults.functions.update_migration_bias = NULL; + cell_defaults.functions.update_phenotype = NULL; // update_cell_and_death_parameters_O2_based; + cell_defaults.functions.custom_cell_rule = NULL; + cell_defaults.functions.contact_function = NULL; + + cell_defaults.functions.add_cell_basement_membrane_interactions = NULL; + cell_defaults.functions.calculate_distance_to_membrane = NULL; + + /* + This parses the cell definitions in the XML config file. + */ + + initialize_cell_definitions_from_pugixml(); + + /* + This builds the map of cell definitions and summarizes the setup. + */ + + build_cell_definitions_maps(); + + /* + This intializes cell signal and response dictionaries + */ + + setup_signal_behavior_dictionaries(); + + /* + Cell rule definitions + */ + + setup_cell_rules(); + + /* + Put any modifications to individual cell definitions here. + + This is a good place to set custom functions. + */ + + cell_defaults.functions.update_phenotype = phenotype_function; + cell_defaults.functions.custom_cell_rule = custom_function; + cell_defaults.functions.contact_function = contact_function; + cell_defaults.functions.cell_division_direction_function = bacteria_division_direction_function; + cell_defaults.functions.cell_division_function = bacteria_division_function; + + /* + This builds the map of cell definitions and summarizes the setup. + */ + + display_cell_definitions( std::cout ); + + return; +} + +void setup_microenvironment( void ) +{ + // set domain parameters + + // put any custom code to set non-homogeneous initial conditions or + // extra Dirichlet nodes here. + + // initialize BioFVM + + initialize_microenvironment(); + + return; +} + +void setup_tissue( void ) +{ + double Xmin = microenvironment.mesh.bounding_box[0]; + double Ymin = microenvironment.mesh.bounding_box[1]; + double Zmin = microenvironment.mesh.bounding_box[2]; + + double Xmax = microenvironment.mesh.bounding_box[3]; + double Ymax = microenvironment.mesh.bounding_box[4]; + double Zmax = microenvironment.mesh.bounding_box[5]; + + if( default_microenvironment_options.simulate_2D == true ) + { + Zmin = 0.0; + Zmax = 0.0; + } + + double Xrange = Xmax - Xmin; + double Yrange = Ymax - Ymin; + double Zrange = Zmax - Zmin; + + // create some of each type of cell + + Cell* pC; + + for( int k=0; k < cell_definitions_by_index.size() ; k++ ) + { + Cell_Definition* pCD = cell_definitions_by_index[k]; + std::cout << "Placing cells of type " << pCD->name << " ... " << std::endl; + for( int n = 0 ; n < parameters.ints("number_of_cells") ; n++ ) + { + std::vector position = {0,0,0}; + position[0] = Xmin + UniformRandom()*Xrange; + position[1] = Ymin + UniformRandom()*Yrange; + position[2] = Zmin + UniformRandom()*Zrange; + + pC = create_cell( *pCD ); + pC->assign_position( position ); + } + } + std::cout << std::endl; + + // load cells from your CSV file (if enabled) + load_cells_from_pugixml(); + set_parameters_from_distributions(); + + return; +} + +std::vector my_coloring_function( Cell* pCell ) +{ return paint_by_number_cell_coloring(pCell); } + +void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ) +{ + return; +} + +void custom_function( Cell* pCell, Phenotype& phenotype , double dt ) +{ return; } + +void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ) +{ return; } + +// custom function called by divide() BEFORE division occurs. +// A pointer to the parent cell is provided. One might use it to determine +// nbr cells, a signal gradient, etc, or simply ignore it. +// Returns a normaliized vector for daughter cell's direction. +std::vector bacteria_division_direction_function( Cell* pParent) +{ + // these are now provided in the .csv ICs for the cells + // static double pi_3_4 = 2.36; + // static double pi_1_2 = 1.57; + // static double pi_1_4 = 0.79; + + static double theta_del = 1.2; // 0.8; // this ccould be a user param easier exploration + // std::vector output = {0.0,100.0,0}; + + // if (pParent->custom_data["theta"] < 0) + // { + // if (pParent->ID == 1) + // pParent->custom_data["theta"] = pi_3_4; + // else if (pParent->ID == 2) + // pParent->custom_data["theta"] = pi_1_2; + // else if (pParent->ID == 3) + // pParent->custom_data["theta"] = pi_1_4; + // } + if (pParent->ID == 0) + { + set_single_behavior(pParent,"cycle entry",0.0); + pParent->is_movable = false; + } + + double theta = pParent->custom_data["theta"] + UniformRandom()*theta_del; + // theta = pParent->custom_data["theta"]; + // std::cout << "ID= "<ID<<", theta= "< xv,yv= " << cos(theta)<<", "< output = {cos(theta),sin(theta),0}; + std::vector output = {2*cos(theta), 2*sin(theta),0}; + // return normalize(output); + return (output); +} + +// custom function called by divide() AFTER division occurs. +void bacteria_division_function( Cell* pParent, Cell* pChild ) +{ + set_single_behavior(pParent,"cycle entry",0.0); +} \ No newline at end of file From a2bd01cc1941e67ada207a5fb00f7dd532a68a39 Mon Sep 17 00:00:00 2001 From: Randy Heiland Date: Fri, 29 Aug 2025 08:23:09 -0400 Subject: [PATCH 5/5] undo commits --- config/bacteria.xml | 249 ------------------------------------ config/cells_bacteria.csv | 5 - custom_modules/custom.cpp | 262 -------------------------------------- 3 files changed, 516 deletions(-) delete mode 100644 config/bacteria.xml delete mode 100644 config/cells_bacteria.csv delete mode 100644 custom_modules/custom.cpp diff --git a/config/bacteria.xml b/config/bacteria.xml deleted file mode 100644 index c3f080f42..000000000 --- a/config/bacteria.xml +++ /dev/null @@ -1,249 +0,0 @@ - - - - -200.0 - 200.0 - -200.0 - 200.0 - -10.0 - 10.0 - 20.0 - 20.0 - 20.0 - true - - - - 5040.0 - min - micron - 0.01 - 0.1 - 6 - - - - 2 - - - - output_bacteria - - 60 - true - - - 60 - true - - substrate - YlOrRd - 0 - 1 - - - - false - - - - - false - true - false - system_clock - - - - - - 100000.0 - 10 - - 0 - 0 - - 0 - 0 - 0 - 0 - 0 - 0 - - - - true - true - - ./config/initial.mat - - - ./config/dirichlet.mat - - - - - - - - - - 240 - - - 1.0 - - - - - 0 - - 516 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - 0.0 - - 0 - 86400 - - - 1.11667e-2 - 8.33333e-4 - 5.33333e-5 - 2.16667e-3 - 0 - 2.0 - - - - - 2494 - 0.75 - 540 - 0.05 - 0.0045 - 0.0055 - 0 - 0 - 2.0 - - - 0.4 - 10.0 - 1.25 - - 1 - - - 1.8 - 15.12 - - 0.01 - 0.0 - 0.0 - 12 - - - 1 - 1 - .5 - - false - true - - false - substrate - 1 - - - false - false - - 0.0 - - - - - - - 0 - 1 - 0 - 0 - - - - 0 - 0 - 0 - - 0 - - - 0 - - 1 - 0.1 - - 0 - - - - - 0 - - - - 0.0 - 0.0 - - - - 0 - - - - Volume - 4 - 2 - 100000 - - - apoptosis - 1e-6 - 1e-2 - - - - - - - - ./config - cells_bacteria.csv - - - - - - - ./config - cell_rules.csv - - - - - - - 0 - - \ No newline at end of file diff --git a/config/cells_bacteria.csv b/config/cells_bacteria.csv deleted file mode 100644 index 0920ba255..000000000 --- a/config/cells_bacteria.csv +++ /dev/null @@ -1,5 +0,0 @@ -x,y,z,type,custom:theta,volume,cycle entry,custom:GFP -0.0,-150.0,0.0,default,0 --12.0,-140.0,0.0,default,2.06 -0.0,-130.0,0.0,default,1.27 -12.0,-140.0,0.0,default,0.49 diff --git a/custom_modules/custom.cpp b/custom_modules/custom.cpp deleted file mode 100644 index acf38aa6f..000000000 --- a/custom_modules/custom.cpp +++ /dev/null @@ -1,262 +0,0 @@ -/* -############################################################################### -# If you use PhysiCell in your project, please cite PhysiCell and the version # -# number, such as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1]. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# See VERSION.txt or call get_PhysiCell_version() to get the current version # -# x.y.z. Call display_citations() to get detailed information on all cite-# -# able software used in your PhysiCell application. # -# # -# Because PhysiCell extensively uses BioFVM, we suggest you also cite BioFVM # -# as below: # -# # -# We implemented and solved the model using PhysiCell (Version x.y.z) [1], # -# with BioFVM [2] to solve the transport equations. # -# # -# [1] A Ghaffarizadeh, R Heiland, SH Friedman, SM Mumenthaler, and P Macklin, # -# PhysiCell: an Open Source Physics-Based Cell Simulator for Multicellu- # -# lar Systems, PLoS Comput. Biol. 14(2): e1005991, 2018 # -# DOI: 10.1371/journal.pcbi.1005991 # -# # -# [2] A Ghaffarizadeh, SH Friedman, and P Macklin, BioFVM: an efficient para- # -# llelized diffusive transport solver for 3-D biological simulations, # -# Bioinformatics 32(8): 1256-8, 2016. DOI: 10.1093/bioinformatics/btv730 # -# # -############################################################################### -# # -# BSD 3-Clause License (see https://opensource.org/licenses/BSD-3-Clause) # -# # -# Copyright (c) 2015-2021, Paul Macklin and the PhysiCell Project # -# All rights reserved. # -# # -# Redistribution and use in source and binary forms, with or without # -# modification, are permitted provided that the following conditions are met: # -# # -# 1. Redistributions of source code must retain the above copyright notice, # -# this list of conditions and the following disclaimer. # -# # -# 2. Redistributions in binary form must reproduce the above copyright # -# notice, this list of conditions and the following disclaimer in the # -# documentation and/or other materials provided with the distribution. # -# # -# 3. Neither the name of the copyright holder nor the names of its # -# contributors may be used to endorse or promote products derived from this # -# software without specific prior written permission. # -# # -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # -# POSSIBILITY OF SUCH DAMAGE. # -# # -############################################################################### -*/ - -#include "./custom.h" - -void create_cell_types( void ) -{ - // set the random seed - if (parameters.ints.find_index("random_seed") != -1) - { - SeedRandom(parameters.ints("random_seed")); - } - - /* - Put any modifications to default cell definition here if you - want to have "inherited" by other cell types. - - This is a good place to set default functions. - */ - - initialize_default_cell_definition(); - cell_defaults.phenotype.secretion.sync_to_microenvironment( µenvironment ); - - cell_defaults.functions.volume_update_function = standard_volume_update_function; - cell_defaults.functions.update_velocity = standard_update_cell_velocity; - - cell_defaults.functions.update_migration_bias = NULL; - cell_defaults.functions.update_phenotype = NULL; // update_cell_and_death_parameters_O2_based; - cell_defaults.functions.custom_cell_rule = NULL; - cell_defaults.functions.contact_function = NULL; - - cell_defaults.functions.add_cell_basement_membrane_interactions = NULL; - cell_defaults.functions.calculate_distance_to_membrane = NULL; - - /* - This parses the cell definitions in the XML config file. - */ - - initialize_cell_definitions_from_pugixml(); - - /* - This builds the map of cell definitions and summarizes the setup. - */ - - build_cell_definitions_maps(); - - /* - This intializes cell signal and response dictionaries - */ - - setup_signal_behavior_dictionaries(); - - /* - Cell rule definitions - */ - - setup_cell_rules(); - - /* - Put any modifications to individual cell definitions here. - - This is a good place to set custom functions. - */ - - cell_defaults.functions.update_phenotype = phenotype_function; - cell_defaults.functions.custom_cell_rule = custom_function; - cell_defaults.functions.contact_function = contact_function; - cell_defaults.functions.cell_division_direction_function = bacteria_division_direction_function; - cell_defaults.functions.cell_division_function = bacteria_division_function; - - /* - This builds the map of cell definitions and summarizes the setup. - */ - - display_cell_definitions( std::cout ); - - return; -} - -void setup_microenvironment( void ) -{ - // set domain parameters - - // put any custom code to set non-homogeneous initial conditions or - // extra Dirichlet nodes here. - - // initialize BioFVM - - initialize_microenvironment(); - - return; -} - -void setup_tissue( void ) -{ - double Xmin = microenvironment.mesh.bounding_box[0]; - double Ymin = microenvironment.mesh.bounding_box[1]; - double Zmin = microenvironment.mesh.bounding_box[2]; - - double Xmax = microenvironment.mesh.bounding_box[3]; - double Ymax = microenvironment.mesh.bounding_box[4]; - double Zmax = microenvironment.mesh.bounding_box[5]; - - if( default_microenvironment_options.simulate_2D == true ) - { - Zmin = 0.0; - Zmax = 0.0; - } - - double Xrange = Xmax - Xmin; - double Yrange = Ymax - Ymin; - double Zrange = Zmax - Zmin; - - // create some of each type of cell - - Cell* pC; - - for( int k=0; k < cell_definitions_by_index.size() ; k++ ) - { - Cell_Definition* pCD = cell_definitions_by_index[k]; - std::cout << "Placing cells of type " << pCD->name << " ... " << std::endl; - for( int n = 0 ; n < parameters.ints("number_of_cells") ; n++ ) - { - std::vector position = {0,0,0}; - position[0] = Xmin + UniformRandom()*Xrange; - position[1] = Ymin + UniformRandom()*Yrange; - position[2] = Zmin + UniformRandom()*Zrange; - - pC = create_cell( *pCD ); - pC->assign_position( position ); - } - } - std::cout << std::endl; - - // load cells from your CSV file (if enabled) - load_cells_from_pugixml(); - set_parameters_from_distributions(); - - return; -} - -std::vector my_coloring_function( Cell* pCell ) -{ return paint_by_number_cell_coloring(pCell); } - -void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ) -{ - return; -} - -void custom_function( Cell* pCell, Phenotype& phenotype , double dt ) -{ return; } - -void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ) -{ return; } - -// custom function called by divide() BEFORE division occurs. -// A pointer to the parent cell is provided. One might use it to determine -// nbr cells, a signal gradient, etc, or simply ignore it. -// Returns a normaliized vector for daughter cell's direction. -std::vector bacteria_division_direction_function( Cell* pParent) -{ - // these are now provided in the .csv ICs for the cells - // static double pi_3_4 = 2.36; - // static double pi_1_2 = 1.57; - // static double pi_1_4 = 0.79; - - static double theta_del = 1.2; // 0.8; // this ccould be a user param easier exploration - // std::vector output = {0.0,100.0,0}; - - // if (pParent->custom_data["theta"] < 0) - // { - // if (pParent->ID == 1) - // pParent->custom_data["theta"] = pi_3_4; - // else if (pParent->ID == 2) - // pParent->custom_data["theta"] = pi_1_2; - // else if (pParent->ID == 3) - // pParent->custom_data["theta"] = pi_1_4; - // } - if (pParent->ID == 0) - { - set_single_behavior(pParent,"cycle entry",0.0); - pParent->is_movable = false; - } - - double theta = pParent->custom_data["theta"] + UniformRandom()*theta_del; - // theta = pParent->custom_data["theta"]; - // std::cout << "ID= "<ID<<", theta= "< xv,yv= " << cos(theta)<<", "< output = {cos(theta),sin(theta),0}; - std::vector output = {2*cos(theta), 2*sin(theta),0}; - // return normalize(output); - return (output); -} - -// custom function called by divide() AFTER division occurs. -void bacteria_division_function( Cell* pParent, Cell* pChild ) -{ - set_single_behavior(pParent,"cycle entry",0.0); -} \ No newline at end of file