diff --git a/ALL_CITATIONS.txt b/ALL_CITATIONS.txt deleted file mode 100644 index 8eaecb06c..000000000 --- a/ALL_CITATIONS.txt +++ /dev/null @@ -1,4 +0,0 @@ -Using PhysiCell version 1.10.4 - Please cite DOI: 10.1371/journal.pcbi.1005991 - Project website: http://PhysiCell.MathCancer.org - diff --git a/Makefile b/Makefile index 1381dd805..f39ef0b73 100644 --- a/Makefile +++ b/Makefile @@ -14,17 +14,8 @@ endif ARCH := native # best auto-tuning # ARCH := core2 # a reasonably safe default for most CPUs since 2007 # ARCH := corei7 -# ARCH := corei7-avx # earlier i7 # ARCH := core-avx-i # i7 ivy bridge or newer # ARCH := core-avx2 # i7 with Haswell or newer -# ARCH := nehalem -# ARCH := westmere -# ARCH := sandybridge # circa 2011 -# ARCH := ivybridge # circa 2012 -# ARCH := haswell # circa 2013 -# ARCH := broadwell # circa 2014 -# ARCH := skylake # circa 2015 -# ARCH := bonnell # ARCH := silvermont # ARCH := skylake-avx512 # ARCH := nocona #64-bit pentium 4 or later @@ -58,24 +49,194 @@ PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o # put your custom objects here (they should be in the custom_modules directory) -PhysiCell_custom_module_OBJECTS := custom.o +PhysiCell_custom_module_OBJECTS := .o pugixml_OBJECTS := pugixml.o PhysiCell_OBJECTS := $(BioFVM_OBJECTS) $(pugixml_OBJECTS) $(PhysiCell_core_OBJECTS) $(PhysiCell_module_OBJECTS) ALL_OBJECTS := $(PhysiCell_OBJECTS) $(PhysiCell_custom_module_OBJECTS) -# compile the project +EXAMPLES := ./examples/PhysiCell_test_mechanics_1.cpp ./examples/PhysiCell_test_mechanics_2.cpp \ + ./examples/PhysiCell_test_DCIS.cpp ./examples/PhysiCell_test_HDS.cpp \ + ./examples/PhysiCell_test_cell_cycle.cpp ./examples/PhysiCell_test_volume.cpp -all: main.cpp $(ALL_OBJECTS) - $(COMPILE_COMMAND) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp - make name +all: + make heterogeneity-sample + make name: @echo "" @echo "Executable name is" $(PROGRAM_NAME) @echo "" +# sample projects +list-projects: + @echo "Sample projects: template biorobots-sample cancer-biorobots-sample cancer-immune-sample" + @echo " celltypes3-sample heterogeneity-sample pred-prey-farmer virus-macrophage-sample" + @echo " worm-sample interaction-sample" + @echo "" + @echo "Sample intracellular projects: ode-energy-sample physiboss-cell-lines-sample cancer-metabolism-sample" + @echo "" + +template: + cp ./sample_projects/template/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/template/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/template/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/template/config/* ./config/ + +# sample projects + +# ---- non-intracellular projects +biorobots-sample: + cp ./sample_projects/biorobots/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/biorobots/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/biorobots/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/biorobots/config/* ./config/ + +cancer-biorobots-sample: + cp ./sample_projects/cancer_biorobots/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/cancer_biorobots/main-cancer_biorobots.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/cancer_biorobots/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/cancer_biorobots/config/* ./config/ + +cancer-immune-sample: + cp ./sample_projects/cancer_immune/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/cancer_immune/main-cancer_immune_3D.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/cancer_immune/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/cancer_immune/config/* ./config/ + +celltypes3-sample: + cp ./sample_projects/celltypes3/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/celltypes3/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/celltypes3/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/celltypes3/config/* ./config/ + +heterogeneity-sample: + cp ./sample_projects/heterogeneity/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/heterogeneity/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/heterogeneity/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/heterogeneity/config/* ./config/ + +pred-prey-farmer: + cp ./sample_projects/pred_prey_farmer/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/pred_prey_farmer/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/pred_prey_farmer/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/pred_prey_farmer/config/* ./config/ + +virus-macrophage-sample: + cp ./sample_projects/virus_macrophage/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/virus_macrophage/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/virus_macrophage/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/virus_macrophage/config/* ./config/ + +worm-sample: + cp ./sample_projects/worm/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/worm/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/worm/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/worm/config/* ./config/ + +interaction-sample: + cp ./sample_projects/interactions/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects/interactions/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects/interactions/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects/interactions/config/* ./config/ + +# ---- intracellular projects +ode-energy-sample: + cp ./sample_projects_intracellular/ode/ode_energy/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects_intracellular/ode/ode_energy/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects_intracellular/ode/ode_energy/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects_intracellular/ode/ode_energy/config/* ./config/ + +physiboss-cell-lines-sample: + cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/Makefile . + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects_intracellular/boolean/physiboss_cell_lines/config/* ./config/ + +ecoli-acetic-switch-sample: + cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/main_ecoli_acetic_switch.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/Makefile ./ + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects_intracellular/fba/ecoli_acetic_switch/config/* ./config/ + +cancer-metabolism-sample: + cp ./sample_projects_intracellular/fba/cancer_metabolism/custom_modules/* ./custom_modules/ + touch main.cpp && cp main.cpp main-backup.cpp + cp ./sample_projects_intracellular/fba/cancer_metabolism/main.cpp ./main.cpp + cp Makefile Makefile-backup + cp ./sample_projects_intracellular/fba/cancer_metabolism/Makefile ./ + cp ./config/PhysiCell_settings.xml ./config/PhysiCell_settings-backup.xml + cp ./sample_projects_intracellular/fba/cancer_metabolism/config/* ./config/ + + +# early examples for convergence testing + +physicell_test_mech1: $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_mechanics_1.cpp + $(COMPILE_COMMAND) -o test_mech1 $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_mechanics_1.cpp + +physicell_test_mech2: $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_mechanics_2.cpp + $(COMPILE_COMMAND) -o test_mech2 $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_mechanics_2.cpp + +physicell_test_DCIS: $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_DCIS.cpp + $(COMPILE_COMMAND) -o test_DCIS $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_DCIS.cpp + +physicell_test_HDS: $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_HDS.cpp + $(COMPILE_COMMAND) -o test_HDS $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_HDS.cpp + +physicell_test_cell_cycle: $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_cell_cycle.cpp + $(COMPILE_COMMAND) -o test_cycle $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_cell_cycle.cpp + +PhysiCell_test_volume: $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_volume.cpp + $(COMPILE_COMMAND) -o test_volume $(PhysiCell_OBJECTS) ./examples/PhysiCell_test_volume.cpp + +examples: $(PhysiCell_OBJECTS) + $(COMPILE_COMMAND) -o ./examples/test_mech1 ./examples/PhysiCell_test_mechanics_1.cpp $(PhysiCell_OBJECTS) + $(COMPILE_COMMAND) -o ./examples/test_mech2 ./examples/PhysiCell_test_mechanics_2.cpp $(PhysiCell_OBJECTS) + $(COMPILE_COMMAND) -o ./examples/test_DCIS ./examples/PhysiCell_test_DCIS.cpp $(PhysiCell_OBJECTS) + $(COMPILE_COMMAND) -o ./examples/test_HDS ./examples/PhysiCell_test_HDS.cpp $(PhysiCell_OBJECTS) + $(COMPILE_COMMAND) -o ./examples/test_cycle ./examples/PhysiCell_test_cell_cycle.cpp $(PhysiCell_OBJECTS) + $(COMPILE_COMMAND) -o ./examples/test_volume ./examples/PhysiCell_test_volume.cpp $(PhysiCell_OBJECTS) + # PhysiCell core components PhysiCell_phenotype.o: ./core/PhysiCell_phenotype.cpp @@ -150,28 +311,25 @@ PhysiCell_MultiCellDS.o: ./modules/PhysiCell_MultiCellDS.cpp PhysiCell_various_outputs.o: ./modules/PhysiCell_various_outputs.cpp $(COMPILE_COMMAND) -c ./modules/PhysiCell_various_outputs.cpp - + PhysiCell_pugixml.o: ./modules/PhysiCell_pugixml.cpp $(COMPILE_COMMAND) -c ./modules/PhysiCell_pugixml.cpp PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp - $(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp PhysiCell_basic_signaling.o: ./core/PhysiCell_basic_signaling.cpp - $(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp - + $(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp + PhysiCell_geometry.o: ./modules/PhysiCell_geometry.cpp $(COMPILE_COMMAND) -c ./modules/PhysiCell_geometry.cpp - -# user-defined PhysiCell modules -custom.o: ./custom_modules/custom.cpp - $(COMPILE_COMMAND) -c ./custom_modules/custom.cpp +# user-defined PhysiCell modules # cleanup reset: - rm -f *.cpp + rm -f *.cpp PhysiCell_cell.o cp ./sample_projects/Makefile-default Makefile rm -f ./custom_modules/* touch ./custom_modules/empty.txt @@ -180,7 +338,7 @@ reset: rm ALL_CITATIONS.txt cp ./config/PhysiCell_settings-backup.xml ./config/PhysiCell_settings.xml touch ./config/empty.csv - rm -f ./config/*.csv + rm ./config/*.csv clean: rm -f *.o @@ -190,9 +348,9 @@ data-cleanup: rm -rf ./output mkdir ./output touch ./output/empty.txt - + # archival - + checkpoint: zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/* diff --git a/config/PhysiCell_settings.xml b/config/PhysiCell_settings.xml index 28627b147..ecedec298 100644 --- a/config/PhysiCell_settings.xml +++ b/config/PhysiCell_settings.xml @@ -1,591 +1,234 @@ + + -1000 + 1000 + -1000 + 1000 + -10 + 10 + 20 + 20 + 20 + true + + + + 64800 + min + micron + + 0.01 + 0.1 + 6 + + + + 6 + + + + output - - -750 - 750 - -750 - 750 - -10 - 10 - 20 - 20 - 20 - true - + + 60 + true + + + + 60 + true + + + + false + + + + + false + true + - - 14400 - min - micron - 0.01 - 0.1 - 6 - + + + + 100000.0 + 0.1 + + 38 + 38 + + 38 + 38 + 38 + 38 + 38 + 38 + + - - 8 - + + true + true + + + ./config/initial.mat + + + + ./config/dirichlet.mat + + + + + + + + + + 0.00072 + + - - output - - 60 - true - - - 60 - true - - - false - - + + + 5.31667e-05 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + - - false - true - + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + - - - - 100000.0 - 0.1 - - 38 - 38 - - 38 - 38 - 38 - 38 - 38 - 38 - - - - - 1000 - 0.1 - - 0 - 0 - - 0 - 0 - 0 - 0 - 0 - 0 - - - - - 1000 - .15625 - - 0 - 0 - - 0 - 0 - 0 - 0 - 0 - 0 - - - - true - true - - ./config/initial.mat - - - ./config/dirichlet.mat - - - + + 0.4 + 10.0 + 1.25 + + 1 + + + 1.8 + 15.12 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + + + + + + + + 0 + 1 + 10 + 0 + + + + + 0 + + 0 + + + + 0 + + + 1 + + 0 + + + - - - - - - 0.00072 - - - - - 5.31667e-05 - - 516 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - 0.0 - - 0 - 86400 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 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.0 - 1.0 - - - 1.8 - 15.12 - - 4.0 - 10.0 - 0.01 - 10.0 - 0.0 - - - 1 - 1 - .5 - - false - true - - false - oxygen - 1 - - - false - false - - 0.0 - 0.0 - 0.0 - - - - - - - 0 - 1 - 10 - 0 - - - 0.0 - 0.0 - 0.0 - 0.0 - - - 0.0 - 0.0 - 0.0 - 0.0 - - - - 0 - - 0 - 0.0 - 0.0 - - - 0 - 0.0 - 0.0 - - 1 - - 0 - 0.0 - 0.0 - - - - - 0 - 0.0 - 0.0 - - - - - 0 - 10 - 0.03333 - 0.004167 - 0.004167 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - - - - - - - 0.0 - - - - - 4.065e-5 - - 516 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - 0.0 - - 0 - 86400 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - - 2494 - 0.75 - 540 - 0.05 - 0.0045 - 0.0055 - 0 - 0 - 2.0 - - - 0 - 50 - 1.25 - - 1.0 - 1.0 - 1.0 - - - 1.8 - 15.12 - - 4.0 - 10.0 - 0.01 - 10.0 - 0.0 - - - 1 - 1 - .5 - - false - true - - false - oxygen - 1 - - - false - false - - 0.0 - 0.0 - 0.0 - - - - - - - 0 - 1 - 1 - 0 - - - 10 - 1 - 0.0 - 0.0 - - - 0.0 - 1 - 0.0 - 0.0 - - - - 0 - - 0.0 - 0.0 - 0.0 - - - 0.0 - 0.0 - 0.0 - - 1 - - 0.0 - 0.0 - 0.0 - - - - - 0.0 - 0.0 - 0.0 - - - - - 1 - 10 - 0.03333 - 0.004167 - 0.004167 - 0.5 - 50 - 0.1 - 18 - 14 - 0.001 - 0.0 - 0.0 - - - - - - - 0.0 - - - - - 0 - - 516 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - 0.0 - - 0 - 86400 - - - 0.05 - 0 - 1.66667e-02 - 5.83333e-03 - 0 - 2.0 - - - - - 2494 - 0.75 - 540 - 0.05 - 0.0045 - 0.0055 - 0 - 0 - 2.0 - - - 0 - 50 - 1.25 - - 1.0 - 1.0 - 1.0 - - - 1.8 - 15.12 - - 4.0 - 10.0 - 0.01 - 10.0 - 0.0 - - - 2 - 5 - .5 - - true - true - - false - oxygen - 1 - - - true - false - - 0.0 - 1 - 0.0 - - - - - - - 0 - 1 - 1 - 0 - - - 0.0 - 0.0 - 0.0 - 0.0 - - - 0.0 - 0.0 - 0.0 - 0.0 - - - - 0 - - 0.0 - 0.0 - 0.0 - - - 0.0 - 0.0 - 0.0 - - 1 - - 0.0 - 0.0 - 0.0 - - - - - 0.0 - 0.0 - 0.0 - - - - - 0 - 10 - 0.03333 - 0.004167 - 0.004167 - 0.5 - 50 - 0.1 - 18 - 14 - 0.001 - 0.5 - 0.5 - - - + + + 0 + + - - - ./config - cells.csv - - + + + 1.0 + + - - 0 - 0 - 10080 - 3 - 0.1 - 500 - 200 + + + + + ./config + cells.csv + + + + + 0 + 5 + 250 + 1 + 0.25 + 0.0 + 2 + \ No newline at end of file diff --git a/sample_projects/cancer_biorobots/Makefile b/sample_projects/cancer_biorobots/Makefile new file mode 100644 index 000000000..1381dd805 --- /dev/null +++ b/sample_projects/cancer_biorobots/Makefile @@ -0,0 +1,288 @@ +VERSION := $(shell grep . VERSION.txt | cut -f1 -d:) +PROGRAM_NAME := project + +CC := g++ +# CC := g++-mp-7 # typical macports compiler name +# CC := g++-7 # typical homebrew compiler name + +# Check for environment definitions of compiler +# e.g., on CC = g++-7 on OSX +ifdef PHYSICELL_CPP + CC := $(PHYSICELL_CPP) +endif + +ARCH := native # best auto-tuning +# ARCH := core2 # a reasonably safe default for most CPUs since 2007 +# ARCH := corei7 +# ARCH := corei7-avx # earlier i7 +# ARCH := core-avx-i # i7 ivy bridge or newer +# ARCH := core-avx2 # i7 with Haswell or newer +# ARCH := nehalem +# ARCH := westmere +# ARCH := sandybridge # circa 2011 +# ARCH := ivybridge # circa 2012 +# ARCH := haswell # circa 2013 +# ARCH := broadwell # circa 2014 +# ARCH := skylake # circa 2015 +# ARCH := bonnell +# ARCH := silvermont +# ARCH := skylake-avx512 +# ARCH := nocona #64-bit pentium 4 or later + +# CFLAGS := -march=$(ARCH) -Ofast -s -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 +CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 + +ifeq ($(OS),Windows_NT) +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Darwin) + UNAME_P := $(shell uname -p) + var := $(shell which $(CC) | xargs file) + ifeq ($(lastword $(var)),arm64) + CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -fopenmp -m64 -std=c++11 + endif + endif +endif + +COMPILE_COMMAND := $(CC) $(CFLAGS) + +BioFVM_OBJECTS := BioFVM_vector.o BioFVM_mesh.o BioFVM_microenvironment.o BioFVM_solvers.o BioFVM_matlab.o \ +BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_container.o + +PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \ +PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o PhysiCell_basic_signaling.o \ +PhysiCell_signal_behavior.o + +PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \ +PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o + +# put your custom objects here (they should be in the custom_modules directory) + +PhysiCell_custom_module_OBJECTS := custom.o + +pugixml_OBJECTS := pugixml.o + +PhysiCell_OBJECTS := $(BioFVM_OBJECTS) $(pugixml_OBJECTS) $(PhysiCell_core_OBJECTS) $(PhysiCell_module_OBJECTS) +ALL_OBJECTS := $(PhysiCell_OBJECTS) $(PhysiCell_custom_module_OBJECTS) + +# compile the project + +all: main.cpp $(ALL_OBJECTS) + $(COMPILE_COMMAND) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp + make name + +name: + @echo "" + @echo "Executable name is" $(PROGRAM_NAME) + @echo "" + +# PhysiCell core components + +PhysiCell_phenotype.o: ./core/PhysiCell_phenotype.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_phenotype.cpp + +PhysiCell_digital_cell_line.o: ./core/PhysiCell_digital_cell_line.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_digital_cell_line.cpp + +PhysiCell_cell.o: ./core/PhysiCell_cell.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell.cpp + +PhysiCell_cell_container.o: ./core/PhysiCell_cell_container.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell_container.cpp + +PhysiCell_standard_models.o: ./core/PhysiCell_standard_models.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_standard_models.cpp + +PhysiCell_utilities.o: ./core/PhysiCell_utilities.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_utilities.cpp + +PhysiCell_custom.o: ./core/PhysiCell_custom.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_custom.cpp + +PhysiCell_constants.o: ./core/PhysiCell_constants.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_constants.cpp + +PhysiCell_signal_behavior.o: ./core/PhysiCell_signal_behavior.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_signal_behavior.cpp + +# BioFVM core components (needed by PhysiCell) + +BioFVM_vector.o: ./BioFVM/BioFVM_vector.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_vector.cpp + +BioFVM_agent_container.o: ./BioFVM/BioFVM_agent_container.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_agent_container.cpp + +BioFVM_mesh.o: ./BioFVM/BioFVM_mesh.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_mesh.cpp + +BioFVM_microenvironment.o: ./BioFVM/BioFVM_microenvironment.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_microenvironment.cpp + +BioFVM_solvers.o: ./BioFVM/BioFVM_solvers.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_solvers.cpp + +BioFVM_utilities.o: ./BioFVM/BioFVM_utilities.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_utilities.cpp + +BioFVM_basic_agent.o: ./BioFVM/BioFVM_basic_agent.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_basic_agent.cpp + +BioFVM_matlab.o: ./BioFVM/BioFVM_matlab.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_matlab.cpp + +BioFVM_MultiCellDS.o: ./BioFVM/BioFVM_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_MultiCellDS.cpp + +pugixml.o: ./BioFVM/pugixml.cpp + $(COMPILE_COMMAND) -c ./BioFVM/pugixml.cpp + +# standard PhysiCell modules + +PhysiCell_SVG.o: ./modules/PhysiCell_SVG.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_SVG.cpp + +PhysiCell_pathology.o: ./modules/PhysiCell_pathology.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pathology.cpp + +PhysiCell_MultiCellDS.o: ./modules/PhysiCell_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_MultiCellDS.cpp + +PhysiCell_various_outputs.o: ./modules/PhysiCell_various_outputs.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_various_outputs.cpp + +PhysiCell_pugixml.o: ./modules/PhysiCell_pugixml.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pugixml.cpp + +PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp + +PhysiCell_basic_signaling.o: ./core/PhysiCell_basic_signaling.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp + +PhysiCell_geometry.o: ./modules/PhysiCell_geometry.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_geometry.cpp + +# user-defined PhysiCell modules + +custom.o: ./custom_modules/custom.cpp + $(COMPILE_COMMAND) -c ./custom_modules/custom.cpp + +# cleanup + +reset: + rm -f *.cpp + cp ./sample_projects/Makefile-default Makefile + rm -f ./custom_modules/* + touch ./custom_modules/empty.txt + touch ALL_CITATIONS.txt + touch ./core/PhysiCell_cell.cpp + rm ALL_CITATIONS.txt + cp ./config/PhysiCell_settings-backup.xml ./config/PhysiCell_settings.xml + touch ./config/empty.csv + rm -f ./config/*.csv + +clean: + rm -f *.o + rm -f $(PROGRAM_NAME)* + +data-cleanup: + rm -rf ./output + mkdir ./output + touch ./output/empty.txt + +# archival + +checkpoint: + zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/* + +zip: + zip -r latest.zip Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.zip $$(date +%b_%d_%Y_%H%M).zip + cp latest.zip VERSION_$(VERSION).zip + mv *.zip archives/ + +tar: + tar --ignore-failed-read -czf latest.tar Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.tar $$(date +%b_%d_%Y_%H%M).tar + cp latest.tar VERSION_$(VERSION).tar + mv *.tar archives/ + +unzip: + cp ./archives/latest.zip . + unzip latest.zip + +untar: + cp ./archives/latest.tar . + tar -xzf latest.tar + +# easier animation + +FRAMERATE := 24 +OUTPUT := output + +jpeg: + @magick identify -format "%h" $(OUTPUT)/initial.svg > __H.txt + @magick identify -format "%w" $(OUTPUT)/initial.svg > __W.txt + @expr 2 \* \( $$(grep . __H.txt) / 2 \) > __H1.txt + @expr 2 \* \( $$(grep . __W.txt) / 2 \) > __W1.txt + @echo "$$(grep . __W1.txt)!x$$(grep . __H1.txt)!" > __resize.txt + @magick mogrify -format jpg -resize $$(grep . __resize.txt) $(OUTPUT)/s*.svg + rm -f __H*.txt __W*.txt __resize.txt + +gif: + magick convert $(OUTPUT)/s*.svg $(OUTPUT)/out.gif + +movie: + ffmpeg -r $(FRAMERATE) -f image2 -i $(OUTPUT)/snapshot%08d.jpg -vcodec libx264 -pix_fmt yuv420p -strict -2 -tune animation -crf 15 -acodec none $(OUTPUT)/out.mp4 + +# upgrade rules + +SOURCE := PhysiCell_upgrade.zip +get-upgrade: + @echo $$(curl https://raw.githubusercontent.com/MathCancer/PhysiCell/master/VERSION.txt) > VER.txt + @echo https://github.com/MathCancer/PhysiCell/releases/download/$$(grep . VER.txt)/PhysiCell_V.$$(grep . VER.txt).zip > DL_FILE.txt + rm -f VER.txt + $$(curl -L $$(grep . DL_FILE.txt) --output PhysiCell_upgrade.zip) + rm -f DL_FILE.txt + +PhysiCell_upgrade.zip: + make get-upgrade + +upgrade: $(SOURCE) + unzip $(SOURCE) PhysiCell/VERSION.txt + mv -f PhysiCell/VERSION.txt . + unzip $(SOURCE) PhysiCell/core/* + cp -r PhysiCell/core/* core + unzip $(SOURCE) PhysiCell/modules/* + cp -r PhysiCell/modules/* modules + unzip $(SOURCE) PhysiCell/sample_projects/* + cp -r PhysiCell/sample_projects/* sample_projects + unzip $(SOURCE) PhysiCell/BioFVM/* + cp -r PhysiCell/BioFVM/* BioFVM + unzip $(SOURCE) PhysiCell/documentation/User_Guide.pdf + mv -f PhysiCell/documentation/User_Guide.pdf documentation + rm -f -r PhysiCell + rm -f $(SOURCE) + +# use: make save PROJ=your_project_name +PROJ := my_project + +save: + echo "Saving project as $(PROJ) ... " + mkdir -p ./user_projects + mkdir -p ./user_projects/$(PROJ) + mkdir -p ./user_projects/$(PROJ)/custom_modules + mkdir -p ./user_projects/$(PROJ)/config + cp main.cpp ./user_projects/$(PROJ) + cp Makefile ./user_projects/$(PROJ) + cp VERSION.txt ./user_projects/$(PROJ) + cp ./config/* ./user_projects/$(PROJ)/config + cp ./custom_modules/* ./user_projects/$(PROJ)/custom_modules + +load: + echo "Loading project from $(PROJ) ... " + cp ./user_projects/$(PROJ)/main.cpp . + cp ./user_projects/$(PROJ)/Makefile . + cp ./user_projects/$(PROJ)/config/* ./config/ + cp ./user_projects/$(PROJ)/custom_modules/* ./custom_modules/ diff --git a/sample_projects/cancer_biorobots/VERSION.txt b/sample_projects/cancer_biorobots/VERSION.txt new file mode 100644 index 000000000..1cac385c6 --- /dev/null +++ b/sample_projects/cancer_biorobots/VERSION.txt @@ -0,0 +1 @@ +1.11.0 diff --git a/sample_projects/cancer_biorobots/config/PhysiCell_settings-backup.xml b/sample_projects/cancer_biorobots/config/PhysiCell_settings-backup.xml new file mode 100644 index 000000000..ecedec298 --- /dev/null +++ b/sample_projects/cancer_biorobots/config/PhysiCell_settings-backup.xml @@ -0,0 +1,234 @@ + + + -1000 + 1000 + -1000 + 1000 + -10 + 10 + 20 + 20 + 20 + true + + + + 64800 + min + micron + + 0.01 + 0.1 + 6 + + + + 6 + + + + output + + + 60 + true + + + + 60 + true + + + + false + + + + + false + true + + + + + + 100000.0 + 0.1 + + 38 + 38 + + 38 + 38 + 38 + 38 + 38 + 38 + + + + + true + true + + + ./config/initial.mat + + + + ./config/dirichlet.mat + + + + + + + + + + 0.00072 + + + + + + 5.31667e-05 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 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 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + + + + + + + + 0 + 1 + 10 + 0 + + + + + 0 + + 0 + + + + 0 + + + 1 + + 0 + + + + + + + 0 + + + + + + 1.0 + + + + + + + + ./config + cells.csv + + + + + 0 + 5 + 250 + 1 + 0.25 + 0.0 + 2 + + + \ No newline at end of file diff --git a/sample_projects/cancer_biorobots/config/PhysiCell_settings.xml b/sample_projects/cancer_biorobots/config/PhysiCell_settings.xml new file mode 100644 index 000000000..28627b147 --- /dev/null +++ b/sample_projects/cancer_biorobots/config/PhysiCell_settings.xml @@ -0,0 +1,591 @@ + + + + -750 + 750 + -750 + 750 + -10 + 10 + 20 + 20 + 20 + true + + + + 14400 + min + micron + 0.01 + 0.1 + 6 + + + + 8 + + + + output + + 60 + true + + + 60 + true + + + false + + + + + false + true + + + + + + 100000.0 + 0.1 + + 38 + 38 + + 38 + 38 + 38 + 38 + 38 + 38 + + + + + 1000 + 0.1 + + 0 + 0 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + 1000 + .15625 + + 0 + 0 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + true + true + + ./config/initial.mat + + + ./config/dirichlet.mat + + + + + + + + + + 0.00072 + + + + + 5.31667e-05 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 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.0 + 1.0 + + + 1.8 + 15.12 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + 0.0 + 0.0 + + + + + + + 0 + 1 + 10 + 0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + + 0 + + 0 + 0.0 + 0.0 + + + 0 + 0.0 + 0.0 + + 1 + + 0 + 0.0 + 0.0 + + + + + 0 + 0.0 + 0.0 + + + + + 0 + 10 + 0.03333 + 0.004167 + 0.004167 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + + + + + + + 0.0 + + + + + 4.065e-5 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0 + 50 + 1.25 + + 1.0 + 1.0 + 1.0 + + + 1.8 + 15.12 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + 0.0 + 0.0 + + + + + + + 0 + 1 + 1 + 0 + + + 10 + 1 + 0.0 + 0.0 + + + 0.0 + 1 + 0.0 + 0.0 + + + + 0 + + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + + 1 + + 0.0 + 0.0 + 0.0 + + + + + 0.0 + 0.0 + 0.0 + + + + + 1 + 10 + 0.03333 + 0.004167 + 0.004167 + 0.5 + 50 + 0.1 + 18 + 14 + 0.001 + 0.0 + 0.0 + + + + + + + 0.0 + + + + + 0 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0 + 50 + 1.25 + + 1.0 + 1.0 + 1.0 + + + 1.8 + 15.12 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + 2 + 5 + .5 + + true + true + + false + oxygen + 1 + + + true + false + + 0.0 + 1 + 0.0 + + + + + + + 0 + 1 + 1 + 0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + + 0 + + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + + 1 + + 0.0 + 0.0 + 0.0 + + + + + 0.0 + 0.0 + 0.0 + + + + + 0 + 10 + 0.03333 + 0.004167 + 0.004167 + 0.5 + 50 + 0.1 + 18 + 14 + 0.001 + 0.5 + 0.5 + + + + + + + ./config + cells.csv + + + + + 0 + 0 + 10080 + 3 + 0.1 + 500 + 200 + + \ No newline at end of file diff --git a/config/cells.csv b/sample_projects/cancer_biorobots/config/cells.csv similarity index 100% rename from config/cells.csv rename to sample_projects/cancer_biorobots/config/cells.csv diff --git a/custom_modules/custom.cpp b/sample_projects/cancer_biorobots/custom_modules/custom.cpp similarity index 100% rename from custom_modules/custom.cpp rename to sample_projects/cancer_biorobots/custom_modules/custom.cpp diff --git a/custom_modules/custom.h b/sample_projects/cancer_biorobots/custom_modules/custom.h similarity index 100% rename from custom_modules/custom.h rename to sample_projects/cancer_biorobots/custom_modules/custom.h diff --git a/main-backup.cpp b/sample_projects/cancer_biorobots/custom_modules/empty.txt similarity index 100% rename from main-backup.cpp rename to sample_projects/cancer_biorobots/custom_modules/empty.txt diff --git a/main.cpp b/sample_projects/cancer_biorobots/main.cpp similarity index 100% rename from main.cpp rename to sample_projects/cancer_biorobots/main.cpp diff --git a/user_projects/cr/Makefile b/user_projects/cr/Makefile new file mode 100644 index 000000000..1381dd805 --- /dev/null +++ b/user_projects/cr/Makefile @@ -0,0 +1,288 @@ +VERSION := $(shell grep . VERSION.txt | cut -f1 -d:) +PROGRAM_NAME := project + +CC := g++ +# CC := g++-mp-7 # typical macports compiler name +# CC := g++-7 # typical homebrew compiler name + +# Check for environment definitions of compiler +# e.g., on CC = g++-7 on OSX +ifdef PHYSICELL_CPP + CC := $(PHYSICELL_CPP) +endif + +ARCH := native # best auto-tuning +# ARCH := core2 # a reasonably safe default for most CPUs since 2007 +# ARCH := corei7 +# ARCH := corei7-avx # earlier i7 +# ARCH := core-avx-i # i7 ivy bridge or newer +# ARCH := core-avx2 # i7 with Haswell or newer +# ARCH := nehalem +# ARCH := westmere +# ARCH := sandybridge # circa 2011 +# ARCH := ivybridge # circa 2012 +# ARCH := haswell # circa 2013 +# ARCH := broadwell # circa 2014 +# ARCH := skylake # circa 2015 +# ARCH := bonnell +# ARCH := silvermont +# ARCH := skylake-avx512 +# ARCH := nocona #64-bit pentium 4 or later + +# CFLAGS := -march=$(ARCH) -Ofast -s -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 +CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -mfpmath=both -fopenmp -m64 -std=c++11 + +ifeq ($(OS),Windows_NT) +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Darwin) + UNAME_P := $(shell uname -p) + var := $(shell which $(CC) | xargs file) + ifeq ($(lastword $(var)),arm64) + CFLAGS := -march=$(ARCH) -O3 -fomit-frame-pointer -fopenmp -m64 -std=c++11 + endif + endif +endif + +COMPILE_COMMAND := $(CC) $(CFLAGS) + +BioFVM_OBJECTS := BioFVM_vector.o BioFVM_mesh.o BioFVM_microenvironment.o BioFVM_solvers.o BioFVM_matlab.o \ +BioFVM_utilities.o BioFVM_basic_agent.o BioFVM_MultiCellDS.o BioFVM_agent_container.o + +PhysiCell_core_OBJECTS := PhysiCell_phenotype.o PhysiCell_cell_container.o PhysiCell_standard_models.o \ +PhysiCell_cell.o PhysiCell_custom.o PhysiCell_utilities.o PhysiCell_constants.o PhysiCell_basic_signaling.o \ +PhysiCell_signal_behavior.o + +PhysiCell_module_OBJECTS := PhysiCell_SVG.o PhysiCell_pathology.o PhysiCell_MultiCellDS.o PhysiCell_various_outputs.o \ +PhysiCell_pugixml.o PhysiCell_settings.o PhysiCell_geometry.o + +# put your custom objects here (they should be in the custom_modules directory) + +PhysiCell_custom_module_OBJECTS := custom.o + +pugixml_OBJECTS := pugixml.o + +PhysiCell_OBJECTS := $(BioFVM_OBJECTS) $(pugixml_OBJECTS) $(PhysiCell_core_OBJECTS) $(PhysiCell_module_OBJECTS) +ALL_OBJECTS := $(PhysiCell_OBJECTS) $(PhysiCell_custom_module_OBJECTS) + +# compile the project + +all: main.cpp $(ALL_OBJECTS) + $(COMPILE_COMMAND) -o $(PROGRAM_NAME) $(ALL_OBJECTS) main.cpp + make name + +name: + @echo "" + @echo "Executable name is" $(PROGRAM_NAME) + @echo "" + +# PhysiCell core components + +PhysiCell_phenotype.o: ./core/PhysiCell_phenotype.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_phenotype.cpp + +PhysiCell_digital_cell_line.o: ./core/PhysiCell_digital_cell_line.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_digital_cell_line.cpp + +PhysiCell_cell.o: ./core/PhysiCell_cell.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell.cpp + +PhysiCell_cell_container.o: ./core/PhysiCell_cell_container.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_cell_container.cpp + +PhysiCell_standard_models.o: ./core/PhysiCell_standard_models.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_standard_models.cpp + +PhysiCell_utilities.o: ./core/PhysiCell_utilities.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_utilities.cpp + +PhysiCell_custom.o: ./core/PhysiCell_custom.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_custom.cpp + +PhysiCell_constants.o: ./core/PhysiCell_constants.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_constants.cpp + +PhysiCell_signal_behavior.o: ./core/PhysiCell_signal_behavior.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_signal_behavior.cpp + +# BioFVM core components (needed by PhysiCell) + +BioFVM_vector.o: ./BioFVM/BioFVM_vector.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_vector.cpp + +BioFVM_agent_container.o: ./BioFVM/BioFVM_agent_container.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_agent_container.cpp + +BioFVM_mesh.o: ./BioFVM/BioFVM_mesh.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_mesh.cpp + +BioFVM_microenvironment.o: ./BioFVM/BioFVM_microenvironment.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_microenvironment.cpp + +BioFVM_solvers.o: ./BioFVM/BioFVM_solvers.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_solvers.cpp + +BioFVM_utilities.o: ./BioFVM/BioFVM_utilities.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_utilities.cpp + +BioFVM_basic_agent.o: ./BioFVM/BioFVM_basic_agent.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_basic_agent.cpp + +BioFVM_matlab.o: ./BioFVM/BioFVM_matlab.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_matlab.cpp + +BioFVM_MultiCellDS.o: ./BioFVM/BioFVM_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./BioFVM/BioFVM_MultiCellDS.cpp + +pugixml.o: ./BioFVM/pugixml.cpp + $(COMPILE_COMMAND) -c ./BioFVM/pugixml.cpp + +# standard PhysiCell modules + +PhysiCell_SVG.o: ./modules/PhysiCell_SVG.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_SVG.cpp + +PhysiCell_pathology.o: ./modules/PhysiCell_pathology.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pathology.cpp + +PhysiCell_MultiCellDS.o: ./modules/PhysiCell_MultiCellDS.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_MultiCellDS.cpp + +PhysiCell_various_outputs.o: ./modules/PhysiCell_various_outputs.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_various_outputs.cpp + +PhysiCell_pugixml.o: ./modules/PhysiCell_pugixml.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_pugixml.cpp + +PhysiCell_settings.o: ./modules/PhysiCell_settings.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_settings.cpp + +PhysiCell_basic_signaling.o: ./core/PhysiCell_basic_signaling.cpp + $(COMPILE_COMMAND) -c ./core/PhysiCell_basic_signaling.cpp + +PhysiCell_geometry.o: ./modules/PhysiCell_geometry.cpp + $(COMPILE_COMMAND) -c ./modules/PhysiCell_geometry.cpp + +# user-defined PhysiCell modules + +custom.o: ./custom_modules/custom.cpp + $(COMPILE_COMMAND) -c ./custom_modules/custom.cpp + +# cleanup + +reset: + rm -f *.cpp + cp ./sample_projects/Makefile-default Makefile + rm -f ./custom_modules/* + touch ./custom_modules/empty.txt + touch ALL_CITATIONS.txt + touch ./core/PhysiCell_cell.cpp + rm ALL_CITATIONS.txt + cp ./config/PhysiCell_settings-backup.xml ./config/PhysiCell_settings.xml + touch ./config/empty.csv + rm -f ./config/*.csv + +clean: + rm -f *.o + rm -f $(PROGRAM_NAME)* + +data-cleanup: + rm -rf ./output + mkdir ./output + touch ./output/empty.txt + +# archival + +checkpoint: + zip -r $$(date +%b_%d_%Y_%H%M).zip Makefile *.cpp *.h config/*.xml custom_modules/* + +zip: + zip -r latest.zip Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.zip $$(date +%b_%d_%Y_%H%M).zip + cp latest.zip VERSION_$(VERSION).zip + mv *.zip archives/ + +tar: + tar --ignore-failed-read -czf latest.tar Makefile* *.cpp *.h BioFVM/* config/* core/* custom_modules/* matlab/* modules/* sample_projects/* + cp latest.tar $$(date +%b_%d_%Y_%H%M).tar + cp latest.tar VERSION_$(VERSION).tar + mv *.tar archives/ + +unzip: + cp ./archives/latest.zip . + unzip latest.zip + +untar: + cp ./archives/latest.tar . + tar -xzf latest.tar + +# easier animation + +FRAMERATE := 24 +OUTPUT := output + +jpeg: + @magick identify -format "%h" $(OUTPUT)/initial.svg > __H.txt + @magick identify -format "%w" $(OUTPUT)/initial.svg > __W.txt + @expr 2 \* \( $$(grep . __H.txt) / 2 \) > __H1.txt + @expr 2 \* \( $$(grep . __W.txt) / 2 \) > __W1.txt + @echo "$$(grep . __W1.txt)!x$$(grep . __H1.txt)!" > __resize.txt + @magick mogrify -format jpg -resize $$(grep . __resize.txt) $(OUTPUT)/s*.svg + rm -f __H*.txt __W*.txt __resize.txt + +gif: + magick convert $(OUTPUT)/s*.svg $(OUTPUT)/out.gif + +movie: + ffmpeg -r $(FRAMERATE) -f image2 -i $(OUTPUT)/snapshot%08d.jpg -vcodec libx264 -pix_fmt yuv420p -strict -2 -tune animation -crf 15 -acodec none $(OUTPUT)/out.mp4 + +# upgrade rules + +SOURCE := PhysiCell_upgrade.zip +get-upgrade: + @echo $$(curl https://raw.githubusercontent.com/MathCancer/PhysiCell/master/VERSION.txt) > VER.txt + @echo https://github.com/MathCancer/PhysiCell/releases/download/$$(grep . VER.txt)/PhysiCell_V.$$(grep . VER.txt).zip > DL_FILE.txt + rm -f VER.txt + $$(curl -L $$(grep . DL_FILE.txt) --output PhysiCell_upgrade.zip) + rm -f DL_FILE.txt + +PhysiCell_upgrade.zip: + make get-upgrade + +upgrade: $(SOURCE) + unzip $(SOURCE) PhysiCell/VERSION.txt + mv -f PhysiCell/VERSION.txt . + unzip $(SOURCE) PhysiCell/core/* + cp -r PhysiCell/core/* core + unzip $(SOURCE) PhysiCell/modules/* + cp -r PhysiCell/modules/* modules + unzip $(SOURCE) PhysiCell/sample_projects/* + cp -r PhysiCell/sample_projects/* sample_projects + unzip $(SOURCE) PhysiCell/BioFVM/* + cp -r PhysiCell/BioFVM/* BioFVM + unzip $(SOURCE) PhysiCell/documentation/User_Guide.pdf + mv -f PhysiCell/documentation/User_Guide.pdf documentation + rm -f -r PhysiCell + rm -f $(SOURCE) + +# use: make save PROJ=your_project_name +PROJ := my_project + +save: + echo "Saving project as $(PROJ) ... " + mkdir -p ./user_projects + mkdir -p ./user_projects/$(PROJ) + mkdir -p ./user_projects/$(PROJ)/custom_modules + mkdir -p ./user_projects/$(PROJ)/config + cp main.cpp ./user_projects/$(PROJ) + cp Makefile ./user_projects/$(PROJ) + cp VERSION.txt ./user_projects/$(PROJ) + cp ./config/* ./user_projects/$(PROJ)/config + cp ./custom_modules/* ./user_projects/$(PROJ)/custom_modules + +load: + echo "Loading project from $(PROJ) ... " + cp ./user_projects/$(PROJ)/main.cpp . + cp ./user_projects/$(PROJ)/Makefile . + cp ./user_projects/$(PROJ)/config/* ./config/ + cp ./user_projects/$(PROJ)/custom_modules/* ./custom_modules/ diff --git a/user_projects/cr/VERSION.txt b/user_projects/cr/VERSION.txt new file mode 100644 index 000000000..1cac385c6 --- /dev/null +++ b/user_projects/cr/VERSION.txt @@ -0,0 +1 @@ +1.11.0 diff --git a/user_projects/cr/config/PhysiCell_settings-backup.xml b/user_projects/cr/config/PhysiCell_settings-backup.xml new file mode 100644 index 000000000..ecedec298 --- /dev/null +++ b/user_projects/cr/config/PhysiCell_settings-backup.xml @@ -0,0 +1,234 @@ + + + -1000 + 1000 + -1000 + 1000 + -10 + 10 + 20 + 20 + 20 + true + + + + 64800 + min + micron + + 0.01 + 0.1 + 6 + + + + 6 + + + + output + + + 60 + true + + + + 60 + true + + + + false + + + + + false + true + + + + + + 100000.0 + 0.1 + + 38 + 38 + + 38 + 38 + 38 + 38 + 38 + 38 + + + + + true + true + + + ./config/initial.mat + + + + ./config/dirichlet.mat + + + + + + + + + + 0.00072 + + + + + + 5.31667e-05 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 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 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + + + + + + + + 0 + 1 + 10 + 0 + + + + + 0 + + 0 + + + + 0 + + + 1 + + 0 + + + + + + + 0 + + + + + + 1.0 + + + + + + + + ./config + cells.csv + + + + + 0 + 5 + 250 + 1 + 0.25 + 0.0 + 2 + + + \ No newline at end of file diff --git a/user_projects/cr/config/PhysiCell_settings.xml b/user_projects/cr/config/PhysiCell_settings.xml new file mode 100644 index 000000000..28627b147 --- /dev/null +++ b/user_projects/cr/config/PhysiCell_settings.xml @@ -0,0 +1,591 @@ + + + + -750 + 750 + -750 + 750 + -10 + 10 + 20 + 20 + 20 + true + + + + 14400 + min + micron + 0.01 + 0.1 + 6 + + + + 8 + + + + output + + 60 + true + + + 60 + true + + + false + + + + + false + true + + + + + + 100000.0 + 0.1 + + 38 + 38 + + 38 + 38 + 38 + 38 + 38 + 38 + + + + + 1000 + 0.1 + + 0 + 0 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + + 1000 + .15625 + + 0 + 0 + + 0 + 0 + 0 + 0 + 0 + 0 + + + + true + true + + ./config/initial.mat + + + ./config/dirichlet.mat + + + + + + + + + + 0.00072 + + + + + 5.31667e-05 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 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.0 + 1.0 + + + 1.8 + 15.12 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + 0.0 + 0.0 + + + + + + + 0 + 1 + 10 + 0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + + 0 + + 0 + 0.0 + 0.0 + + + 0 + 0.0 + 0.0 + + 1 + + 0 + 0.0 + 0.0 + + + + + 0 + 0.0 + 0.0 + + + + + 0 + 10 + 0.03333 + 0.004167 + 0.004167 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + 0.0 + + + + + + + 0.0 + + + + + 4.065e-5 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0 + 50 + 1.25 + + 1.0 + 1.0 + 1.0 + + + 1.8 + 15.12 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + 1 + 1 + .5 + + false + true + + false + oxygen + 1 + + + false + false + + 0.0 + 0.0 + 0.0 + + + + + + + 0 + 1 + 1 + 0 + + + 10 + 1 + 0.0 + 0.0 + + + 0.0 + 1 + 0.0 + 0.0 + + + + 0 + + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + + 1 + + 0.0 + 0.0 + 0.0 + + + + + 0.0 + 0.0 + 0.0 + + + + + 1 + 10 + 0.03333 + 0.004167 + 0.004167 + 0.5 + 50 + 0.1 + 18 + 14 + 0.001 + 0.0 + 0.0 + + + + + + + 0.0 + + + + + 0 + + 516 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + 0.0 + + 0 + 86400 + + + 0.05 + 0 + 1.66667e-02 + 5.83333e-03 + 0 + 2.0 + + + + + 2494 + 0.75 + 540 + 0.05 + 0.0045 + 0.0055 + 0 + 0 + 2.0 + + + 0 + 50 + 1.25 + + 1.0 + 1.0 + 1.0 + + + 1.8 + 15.12 + + 4.0 + 10.0 + 0.01 + 10.0 + 0.0 + + + 2 + 5 + .5 + + true + true + + false + oxygen + 1 + + + true + false + + 0.0 + 1 + 0.0 + + + + + + + 0 + 1 + 1 + 0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + 0.0 + + + + 0 + + 0.0 + 0.0 + 0.0 + + + 0.0 + 0.0 + 0.0 + + 1 + + 0.0 + 0.0 + 0.0 + + + + + 0.0 + 0.0 + 0.0 + + + + + 0 + 10 + 0.03333 + 0.004167 + 0.004167 + 0.5 + 50 + 0.1 + 18 + 14 + 0.001 + 0.5 + 0.5 + + + + + + + ./config + cells.csv + + + + + 0 + 0 + 10080 + 3 + 0.1 + 500 + 200 + + \ No newline at end of file diff --git a/user_projects/cr/config/cells.csv b/user_projects/cr/config/cells.csv new file mode 100644 index 000000000..734bdc767 --- /dev/null +++ b/user_projects/cr/config/cells.csv @@ -0,0 +1 @@ +0,0,0,0 \ No newline at end of file diff --git a/user_projects/cr/custom_modules/custom.cpp b/user_projects/cr/custom_modules/custom.cpp new file mode 100644 index 000000000..9c43db830 --- /dev/null +++ b/user_projects/cr/custom_modules/custom.cpp @@ -0,0 +1,637 @@ +/* +############################################################################### +# 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( µ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(); + + /* + 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.parameters.o2_proliferation_saturation = 38.0; + cell_defaults.parameters.o2_reference = 38.0; + + // cancer cells + Cell_Definition* pCD = find_cell_definition( "cancer cell"); + pCD->functions.update_phenotype = tumor_cell_phenotype_with_therapy; + + pCD->parameters.o2_proliferation_saturation = 38.0; + pCD->parameters.o2_reference = 38.0; + + // cargo cells + pCD = find_cell_definition( "cargo cell"); + + // figure out mechanics parameters + + pCD->phenotype.mechanics.relative_maximum_attachment_distance + = pCD->custom_data["max_attachment_distance"] / pCD->phenotype.geometry.radius ; + + pCD->phenotype.mechanics.relative_detachment_distance + = pCD->custom_data["max_elastic_displacement"] / pCD->phenotype.geometry.radius ; + + pCD->phenotype.mechanics.attachment_elastic_constant + = pCD->custom_data["elastic_coefficient"]; + + // set functions + pCD->functions.update_phenotype = cargo_cell_phenotype_rule; + pCD->functions.custom_cell_rule = cargo_cell_rule; + pCD->functions.contact_function = biorobots_contact_function; + pCD->functions.update_migration_bias = NULL; + + // worker cells + + pCD = find_cell_definition( "worker cell"); + + pCD->phenotype.mechanics.relative_maximum_attachment_distance + = pCD->custom_data["max_attachment_distance"] / pCD->phenotype.geometry.radius ; + + pCD->phenotype.mechanics.relative_detachment_distance + = pCD->custom_data["max_elastic_displacement"] / pCD->phenotype.geometry.radius ; + + pCD->phenotype.mechanics.attachment_elastic_constant + = pCD->custom_data["elastic_coefficient"]; + + pCD->functions.update_phenotype = NULL; // worker_cell_rule; + pCD->functions.custom_cell_rule = worker_cell_rule; + pCD->functions.contact_function = biorobots_contact_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; + + // custom placement + // place a cluster of tumor cells at the center + + double cell_radius = cell_defaults.phenotype.geometry.radius; + double cell_spacing = 0.95 * 2.0 * cell_radius; + + double tumor_radius = parameters.doubles("tumor_radius"); // 200.0; + + Cell* pCell = NULL; + Cell_Definition* pCD_cancer = find_cell_definition( "cancer cell"); + + double x = 0.0; + double x_outer = tumor_radius; + double y = 0.0; + + int n = 0; + while( y < tumor_radius ) + { + x = 0.0; + if( n % 2 == 1 ) + { x = 0.5*cell_spacing; } + x_outer = sqrt( tumor_radius*tumor_radius - y*y ); + + while( x < x_outer ) + { + pCell = create_cell(); // tumor cell + pCell->assign_position( x , y , 0.0 ); + + if( fabs( y ) > 0.01 ) + { + pCell = create_cell(*pCD_cancer); // tumor cell + pCell->assign_position( x , -y , 0.0 ); + } + + if( fabs( x ) > 0.01 ) + { + pCell = create_cell(*pCD_cancer); // tumor cell + pCell->assign_position( -x , y , 0.0 ); + + if( fabs( y ) > 0.01 ) + { + pCell = create_cell(*pCD_cancer); // tumor cell + pCell->assign_position( -x , -y , 0.0 ); + } + } + x += cell_spacing; + } + + y += cell_spacing * sqrt(3.0)/2.0; + n++; + } + + + // load cells from your CSV file (if enabled) + load_cells_from_pugixml(); + + 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; } + +std::vector cancer_biorobots_coloring_function( Cell* pCell ) +{ + std::vector< std::string > output( 4, "black" ); + + double damage = get_single_signal( pCell, "damage"); + + static double max_damage = 1.0 * get_single_signal(pCell,"custom:damage_rate") + / (1e-16 + get_single_signal(pCell,"custom:repair_rate" ) ); + + static Cell_Definition* pCD_cargo = find_cell_definition( "cargo cell"); + static Cell_Definition* pCD_cancer = find_cell_definition( "cancer cell"); + static Cell_Definition* pCD_worker = find_cell_definition( "worker cell"); + + // cargo cell + if( pCell->type == pCD_cargo->type ) + { + output[0] = "blue"; + output[1] = "blue"; + output[2] = "blue"; + output[3] = "none"; // no nuclear outline color + return output; + } + + // worker cell + if( pCell->type == pCD_worker->type ) + { + output[0] = "red"; + output[1] = "red"; + output[2] = "red"; + output[3] = "none"; // no nuclear outline color + return output; + } + + // apoptotic tumor - cyan + if( get_single_signal( pCell, "apoptotic" ) > 0.5 ) // Apoptotic - cyan + { + output[0] = "cyan"; + output[2] = "darkcyan"; + return output; + } + + // Necrotic tumor - Brown + if( get_single_signal( pCell, "necrotic") > 0.5 ) + { + output[0] = "rgb(250,138,38)"; + output[2] = "rgb(139,69,19)"; + return output; + } + + // live tumor -- shade by level of damage + + + // if live: color by damage + if( get_single_signal( pCell, "dead") < 0.5 ) + { + int damage_int = (int) round( damage * 255.0 / max_damage ); + + char szTempString [128]; + sprintf( szTempString , "rgb(%u,%u,%u)" , damage_int , 255-damage_int , damage_int ); + output[0].assign( szTempString ); + output[1].assign( szTempString ); + sprintf( szTempString , "rgb(%u,%u,%u)" , damage_int/4 , (255-damage_int)/4 , damage_int/4 ); + output[2].assign( szTempString ); + } + return output; +} + +void introduce_biorobots( void ) +{ + // idea: we'll "inject" them in a little column + + static double worker_fraction = + parameters.doubles("worker_fraction"); // 0.10; /* param */ + static int number_of_injected_cells = + parameters.ints("number_of_injected_cells"); // 500; /* param */ + + // make these vary with domain size + double left_coordinate = default_microenvironment_options.X_range[1] - 150.0; // 600.0; + double right_cooridnate = default_microenvironment_options.X_range[1] - 50.0; // 700.0; + + double bottom_coordinate = default_microenvironment_options.Y_range[0] + 50.0; // -700; + double top_coordinate = default_microenvironment_options.Y_range[1] - 50.0; // 700; + + Cell_Definition* pCD_worker = find_cell_definition( "worker cell"); + Cell_Definition* pCD_cargo = find_cell_definition( "cargo cell"); + + for( int i=0 ;i < number_of_injected_cells ; i++ ) + { + std::vector position = {0,0,0}; + position[0] = left_coordinate + (right_cooridnate-left_coordinate)*UniformRandom(); + position[1] = bottom_coordinate + (top_coordinate-bottom_coordinate)*UniformRandom(); + + Cell* pCell; + if( UniformRandom() <= worker_fraction ) + { pCell = create_cell( *pCD_worker ); } + else + { pCell = create_cell( *pCD_cargo ); } + pCell->assign_position( position ); + } + + return; +} + +void cargo_cell_rule( Cell* pCell, Phenotype& phenotype, double dt ) +{ + if( get_single_signal( pCell, "dead" ) > 0.5 ) + { + // the cell death functions don't automatically turn off custom functions, + // since those are part of mechanics. + + // Let's just fully disable now. + pCell->functions.custom_cell_rule = NULL; + return; + } + + // if I'm docked + if( pCell->state.number_of_attached_cells() > 0 ) + { + set_single_behavior( pCell, "migration speed" , 0.0 ); + return; + } + + return; +} + +void cargo_cell_phenotype_rule( Cell* pCell, Phenotype& phenotype, double dt ) +{ + // if dettached and receptor on, secrete signal + + // if dettached and receptor off, secrete chemo + + double receptor = get_single_signal( pCell , "custom:receptor" ); + + if( pCell->state.number_of_attached_cells() == 0 ) + { + if( receptor > 0.1 ) + { + set_single_behavior( pCell , "chemoattractant secretion" , 10); + set_single_behavior( pCell , "therapeutic secretion" , 0); + } + else + { + set_single_behavior( pCell , "chemoattractant secretion" , 0); + set_single_behavior( pCell , "therapeutic secretion" , 10); + } + return; + } + + // if you reach this point of the code, the cell is attached + + + // if attached and oxygen high, secrete nothing, receptor off + + // if attached and oxygen low, dettach, start secreting chemo, receptor off + + double o2 = get_single_signal( pCell, "oxygen"); + double o2_drop = get_single_signal( pCell , "custom:cargo_release_o2_threshold"); + + if( o2 > o2_drop ) + { + set_single_behavior( pCell , "chemoattractant secretion" , 0); + set_single_behavior( pCell , "therapeutic secretion" , 0); + set_single_behavior( pCell , "custom:receptor" , 0 ); + } + else + { + set_single_behavior( pCell , "chemoattractant secretion" , 0); + set_single_behavior( pCell , "therapeutic secretion" , 10); + set_single_behavior( pCell , "custom:receptor" , 0 ); + + pCell->remove_all_attached_cells(); + } + + return; +} + +void biorobots_contact_function( Cell* pActingOn, Phenotype& pao, Cell* pAttachedTo, Phenotype& pat , double dt ) +{ + std::vector displacement = pAttachedTo->position - pActingOn->position; + + static double max_elastic_displacement = pao.geometry.radius * pao.mechanics.relative_detachment_distance; + static double max_displacement_squared = max_elastic_displacement*max_elastic_displacement; + + // detach cells if too far apart + + if( norm_squared( displacement ) > max_displacement_squared ) + { + detach_cells( pActingOn , pAttachedTo ); + return; + } + + axpy( &(pActingOn->velocity) , pao.mechanics.attachment_elastic_constant , displacement ); + + return; +} + +void tumor_cell_phenotype_with_therapy( Cell* pCell, Phenotype& phenotype, double dt ) +{ + double damage = get_single_signal( pCell, "damage"); + + double damage_rate = get_single_signal( pCell , "custom:damage_rate"); + double repair_rate = get_single_signal( pCell , "custom:repair_rate"); + double drug_death_rate = get_single_signal( pCell , "custom:drug_death_rate" ); + + double drug = get_single_signal( pCell , "therapeutic"); + + static double max_damage = 1.0 * damage_rate / (1e-16 + repair_rate ); + + // if I'm dead, don't bother. disable my phenotype rule + if( get_single_signal( pCell, "dead") > 0.5 ) + { + pCell->functions.update_phenotype = NULL; + return; + } + + // first, vary the cell birth and death rates with oxygenation + + // std::cout << get_single_behavior( pCell , "cycle entry") << " vs "; + update_cell_and_death_parameters_O2_based(pCell,phenotype,dt); + // std::cout << get_single_behavior( pCell , "cycle entry") << std::endl; + + // the update the cell damage + + // dD/dt = alpha*c - beta-D by implicit scheme + + double temp = drug; + + // reuse temp as much as possible to reduce memory allocations etc. + temp *= dt; + temp *= damage_rate; + + damage += temp; // d_prev + dt*chemo*damage_rate + + temp = repair_rate; + temp *= dt; + temp += 1.0; + damage /= temp; // (d_prev + dt*chemo*damage_rate)/(1 + dt*repair_rate) + + // then, see if the cell undergoes death from the therapy + + temp = dt; + temp *= damage; + temp *= drug_death_rate; + temp /= max_damage; // dt*(damage/max_damage)*death_rate + + // make sure we write the damage (not current a behavior) + pCell->state.damage = damage; + + if( UniformRandom() <= temp ) + { + // pCell->start_death( apoptosis_model_index ); + set_single_behavior( pCell, "apoptosis" , 9e99 ); + pCell->functions.update_phenotype = NULL; + pCell->functions.custom_cell_rule = NULL; + } + + return; +} + +void worker_cell_rule( Cell* pCell, Phenotype& phenotype, double dt ) +{ + // if I am dead, don't bother + + if( get_single_signal( pCell , "dead") > 0.5 ) + { + // the cell death functions don't automatically turn off custom functions, + // since those are part of mechanics. + + // Let's just fully disable now. + pCell->functions.custom_cell_rule = NULL; + return; + } + + // am I searching for cargo? if so, see if I've found it + if( pCell->state.number_of_attached_cells() == 0 ) + { + std::vector nearby = pCell->cells_in_my_container(); + bool attached = false; // want to limit to one attachment + int i =0; + while( i < nearby.size() && attached == false ) + { + // if it is expressing the receptor, dock with it + if( get_single_signal(nearby[i],"custom:receptor") > 0.5 && attached == false ) + { + attach_cells( pCell, nearby[i] ); + // nearby[i]->custom_data["receptor"] = 0.0; // put into cargo cell rule instead? + // nearby[i]->phenotype.secretion.set_all_secretion_to_zero(); // put into cargo rule instead? + attached = true; + } + i++; + } + } + + // from prior motility function + + double o2 = get_single_signal( pCell, "oxygen"); + double chemoattractant = get_single_signal( pCell , "chemoattractant"); + + static double detection_threshold = get_single_signal( pCell, "custom:motility_shutdown_detection_threshold"); + + // if attached, biased motility towards director chemoattractant + // otherwise, biased motility towards cargo chemoattractant + + static double attached_worker_migration_bias = get_single_signal( pCell, "custom:attached_worker_migration_bias"); + static double unattached_worker_migration_bias = get_single_signal( pCell , "custom:unattached_worker_migration_bias"); + + if( pCell->state.number_of_attached_cells() > 0 ) + { + set_single_behavior( pCell , "migration bias" , attached_worker_migration_bias ); + + set_single_behavior( pCell , "chemotactic response to oxygen" , -1 ); + set_single_behavior( pCell , "chemotactic response to chemoattractant" , 0 ); + } + else + { + // if there is no detectable signal, shut down motility (permanently) + if( chemoattractant < detection_threshold ) + { + set_single_behavior( pCell, "migration speed" , 0 ); + } + + set_single_behavior( pCell , "migration bias" , unattached_worker_migration_bias ); + + set_single_behavior( pCell , "chemotactic response to oxygen" , 0 ); + set_single_behavior( pCell , "chemotactic response to chemoattractant" , 1 ); + } + + return; +} + + diff --git a/user_projects/cr/custom_modules/custom.h b/user_projects/cr/custom_modules/custom.h new file mode 100644 index 000000000..ab1adcf04 --- /dev/null +++ b/user_projects/cr/custom_modules/custom.h @@ -0,0 +1,109 @@ +/* +############################################################################### +# 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 "../core/PhysiCell.h" +#include "../modules/PhysiCell_standard_modules.h" + +using namespace BioFVM; +using namespace PhysiCell; + +// setup functions to help us along + +void create_cell_types( void ); +void setup_tissue( void ); + +// set up the BioFVM microenvironment +void setup_microenvironment( void ); + +// custom pathology coloring function + +std::vector my_coloring_function( Cell* ); + +// custom functions can go here + +void phenotype_function( Cell* pCell, Phenotype& phenotype, double dt ); +void custom_function( Cell* pCell, Phenotype& phenotype , double dt ); + +void contact_function( Cell* pMe, Phenotype& phenoMe , Cell* pOther, Phenotype& phenoOther , double dt ); + +std::vector cancer_biorobots_coloring_function( Cell* ); + +void introduce_biorobots( void ); + +// cargo cells + +void cargo_cell_rule( Cell* pCell, Phenotype& phenotype, double dt ); +void cargo_cell_phenotype_rule( Cell* pCell, Phenotype& phenotype, double dt ); + +void biorobots_contact_function( Cell* pActingOn, Phenotype& pao, Cell* pAttachedTo, Phenotype& pat , double dt ); + +// cancer cells +void tumor_cell_phenotype_with_therapy( Cell* pCell, Phenotype& phenotype, double dt ); + +// worker cells +void worker_cell_rule( Cell* pCell, Phenotype& phenotype, double dt ); + diff --git a/user_projects/cr/custom_modules/empty.txt b/user_projects/cr/custom_modules/empty.txt new file mode 100644 index 000000000..e69de29bb diff --git a/user_projects/cr/main.cpp b/user_projects/cr/main.cpp new file mode 100644 index 000000000..41876503a --- /dev/null +++ b/user_projects/cr/main.cpp @@ -0,0 +1,269 @@ +/* +############################################################################### +# 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-2022, 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 +#include +#include +#include +#include +#include +#include + +#include "./core/PhysiCell.h" +#include "./modules/PhysiCell_standard_modules.h" + +// put custom code modules here! + +#include "./custom_modules/custom.h" + +using namespace BioFVM; +using namespace PhysiCell; + +int main( int argc, char* argv[] ) +{ + // load and parse settings file(s) + + bool XML_status = false; + char copy_command [1024]; + if( argc > 1 ) + { + XML_status = load_PhysiCell_config_file( argv[1] ); + sprintf( copy_command , "cp %s %s" , argv[1] , PhysiCell_settings.folder.c_str() ); + } + else + { + XML_status = load_PhysiCell_config_file( "./config/PhysiCell_settings.xml" ); + sprintf( copy_command , "cp ./config/PhysiCell_settings.xml %s" , PhysiCell_settings.folder.c_str() ); + } + if( !XML_status ) + { exit(-1); } + + // copy config file to output directry + system( copy_command ); + + // OpenMP setup + omp_set_num_threads(PhysiCell_settings.omp_num_threads); + + // time setup + std::string time_units = "min"; + + /* Microenvironment setup */ + + setup_microenvironment(); // modify this in the custom code + + /* PhysiCell setup */ + + // set mechanics voxel size, and match the data structure to BioFVM + double mechanics_voxel_size = 30; + Cell_Container* cell_container = create_cell_container_for_microenvironment( microenvironment, mechanics_voxel_size ); + + /* Users typically start modifying here. START USERMODS */ + + create_cell_types(); + + setup_tissue(); + + /* Users typically stop modifying here. END USERMODS */ + + // set MultiCellDS save options + + set_save_biofvm_mesh_as_matlab( true ); + set_save_biofvm_data_as_matlab( true ); + set_save_biofvm_cell_data( true ); + set_save_biofvm_cell_data_as_custom_matlab( true ); + + // save a simulation snapshot + + char filename[1024]; + sprintf( filename , "%s/initial" , PhysiCell_settings.folder.c_str() ); + save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); + + // save a quick SVG cross section through z = 0, after setting its + // length bar to 200 microns + + PhysiCell_SVG_options.length_bar = 200; + + // for simplicity, set a pathology coloring function + + std::vector (*cell_coloring_function)(Cell*) = cancer_biorobots_coloring_function; + + sprintf( filename , "%s/initial.svg" , PhysiCell_settings.folder.c_str() ); + SVG_plot( filename , microenvironment, 0.0 , PhysiCell_globals.current_time, cell_coloring_function ); + + sprintf( filename , "%s/legend.svg" , PhysiCell_settings.folder.c_str() ); + create_plot_legend( filename , cell_coloring_function ); + + display_citations(); + + // set the performance timers + + BioFVM::RUNTIME_TIC(); + BioFVM::TIC(); + + std::ofstream report_file; + if( PhysiCell_settings.enable_legacy_saves == true ) + { + sprintf( filename , "%s/simulation_report.txt" , PhysiCell_settings.folder.c_str() ); + + report_file.open(filename); // create the data log file + report_file<<"simulated time\tnum cells\tnum division\tnum death\twall time"< therapy_activation_time - 0.01*diffusion_dt && therapy_introduced == false ) + { + std::cout << "Therapy started!" << std::endl; + therapy_introduced = true; + PhysiCell_settings.full_save_interval = parameters.doubles("save_interval_after_therapy_start"); // 3.0; + PhysiCell_settings.SVG_save_interval = parameters.doubles("save_interval_after_therapy_start"); // 3.0; + + PhysiCell_globals.next_full_save_time = PhysiCell_globals.current_time; + PhysiCell_globals.next_SVG_save_time = PhysiCell_globals.current_time; + + introduce_biorobots(); + } + + // save data if it's time. + if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_full_save_time ) < 0.01 * diffusion_dt ) + { + display_simulation_status( std::cout ); + if( PhysiCell_settings.enable_legacy_saves == true ) + { + log_output( PhysiCell_globals.current_time , PhysiCell_globals.full_output_index, microenvironment, report_file); + } + + if( PhysiCell_settings.enable_full_saves == true ) + { + sprintf( filename , "%s/output%08u" , PhysiCell_settings.folder.c_str(), PhysiCell_globals.full_output_index ); + + save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); + } + + PhysiCell_globals.full_output_index++; + PhysiCell_globals.next_full_save_time += PhysiCell_settings.full_save_interval; + } + + // save SVG plot if it's time + if( fabs( PhysiCell_globals.current_time - PhysiCell_globals.next_SVG_save_time ) < 0.01 * diffusion_dt ) + { + if( PhysiCell_settings.enable_SVG_saves == true ) + { + sprintf( filename , "%s/snapshot%08u.svg" , PhysiCell_settings.folder.c_str() , PhysiCell_globals.SVG_output_index ); + SVG_plot( filename , microenvironment, 0.0 , PhysiCell_globals.current_time, cell_coloring_function ); + + PhysiCell_globals.SVG_output_index++; + PhysiCell_globals.next_SVG_save_time += PhysiCell_settings.SVG_save_interval; + } + } + + // update the microenvironment + microenvironment.simulate_diffusion_decay( diffusion_dt ); + + // run PhysiCell + ((Cell_Container *)microenvironment.agent_container)->update_all_cells( PhysiCell_globals.current_time ); + + /* + Custom add-ons could potentially go here. + */ + + PhysiCell_globals.current_time += diffusion_dt; + } + + if( PhysiCell_settings.enable_legacy_saves == true ) + { + log_output(PhysiCell_globals.current_time, PhysiCell_globals.full_output_index, microenvironment, report_file); + report_file.close(); + } + } + catch( const std::exception& e ) + { // reference to the base of a polymorphic object + std::cout << e.what(); // information from length_error printed + } + + // save a final simulation snapshot + + sprintf( filename , "%s/final" , PhysiCell_settings.folder.c_str() ); + save_PhysiCell_to_MultiCellDS_v2( filename , microenvironment , PhysiCell_globals.current_time ); + + sprintf( filename , "%s/final.svg" , PhysiCell_settings.folder.c_str() ); + SVG_plot( filename , microenvironment, 0.0 , PhysiCell_globals.current_time, cell_coloring_function ); + + // timer + + std::cout << std::endl << "Total simulation runtime: " << std::endl; + BioFVM::display_stopwatch_value( std::cout , BioFVM::runtime_stopwatch_value() ); + + return 0; +}