Skip to content

Commit

Permalink
v1 and v2 of custom DCs
Browse files Browse the repository at this point in the history
  • Loading branch information
rheiland committed Mar 21, 2023
1 parent 2afca6d commit 37fcd7e
Show file tree
Hide file tree
Showing 4 changed files with 450 additions and 0 deletions.
241 changes: 241 additions & 0 deletions unit_tests/custom_DCs_2substrates/custom_modules/custom_v1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
/*
###############################################################################
# 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
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( &microenvironment );

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();

/*
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;

/*
This builds the map of cell definitions and summarizes the setup.
*/

display_cell_definitions( std::cout );

return;
}

// Mock up 2 substrates with different values (and ranges) of DCs on the voxels.
void setup_microenvironment( void )
{
// initialize BioFVM
initialize_microenvironment();

int idx_oxygen = 0; // just hard-coded; better to get index by name.
double oxy_value = 40.0; // set voxel values sequentially, starting with 40

int idx_glucose = 1;
double glu_value = 10.0; // set voxel values sequentially, starting with 10

int idx_xmax = microenvironment.mesh.x_coordinates.size() - 1;
int idx_ymax = microenvironment.mesh.y_coordinates.size() - 1;
int idx_zmax = microenvironment.mesh.z_coordinates.size() - 1;

for (int idz=0; idz<microenvironment.mesh.z_coordinates.size(); idz++)
for (int idy=0; idy<microenvironment.mesh.y_coordinates.size(); idy++)
for (int idx=0; idx<microenvironment.mesh.x_coordinates.size(); idx++)
{
microenvironment.update_dirichlet_node(
microenvironment.voxel_index(idx, idy, idz),
idx_oxygen, oxy_value);

// Originally, I thought this was necessary, but it seems not.
// microenvironment.set_substrate_dirichlet_activation( idx_oxygen,
// microenvironment.voxel_index(idx, idy, idz), true);

microenvironment.update_dirichlet_node(
microenvironment.voxel_index(idx, idy, idz),
idx_glucose, glu_value);
// microenvironment.set_substrate_dirichlet_activation( idx_glucose,
// microenvironment.voxel_index(idx, idy, idz), true);

oxy_value += 1.0;
glu_value += 1.0;
}

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;
}
std::cout << "\n\n------- setup_tissue(): Xmin,Xmax= " << Xmin << ", " << Xmax<<std::endl;
std::cout << "------- setup_tissue(): Ymin,Ymax= " << Ymin << ", " << Ymax<<std::endl;

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<double> 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;

// single cell at origin
Cell_Definition* pCD = cell_definitions_by_index[0];
std::vector<double> position = {0,0,0};
pC = create_cell( *pCD );
pC->assign_position( position );


// load cells from your CSV file (if enabled)
load_cells_from_pugixml();
return;
}

std::vector<std::string> 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; }
Loading

0 comments on commit 37fcd7e

Please sign in to comment.