Chaste Commit::ca8ccdedf819b6e02855bc0e8e6f50bdecbc5208
RandomCellKiller.cpp
1/*
2
3Copyright (c) 2005-2024, University of Oxford.
4All rights reserved.
5
6University of Oxford means the Chancellor, Masters and Scholars of the
7University of Oxford, having an administrative office at Wellington
8Square, Oxford OX1 2JD, UK.
9
10This file is part of Chaste.
11
12Redistribution and use in source and binary forms, with or without
13modification, are permitted provided that the following conditions are met:
14 * Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimer.
16 * Redistributions in binary form must reproduce the above copyright notice,
17 this list of conditions and the following disclaimer in the documentation
18 and/or other materials provided with the distribution.
19 * Neither the name of the University of Oxford nor the names of its
20 contributors may be used to endorse or promote products derived from this
21 software without specific prior written permission.
22
23THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
34*/
35
36#include "RandomCellKiller.hpp"
37
38template<unsigned DIM>
39RandomCellKiller<DIM>::RandomCellKiller(AbstractCellPopulation<DIM>* pCellPopulation, double probabilityOfDeathInAnHour)
40 : AbstractCellKiller<DIM>(pCellPopulation),
41 mProbabilityOfDeathInAnHour(probabilityOfDeathInAnHour)
42{
44 {
45 EXCEPTION("Probability of death must be between zero and one");
46 }
47}
48
49template<unsigned DIM>
51{
52 return mProbabilityOfDeathInAnHour;
53}
54
55template<unsigned DIM>
57{
58 /*
59 * We assume a constant time step and that there are an integer number (n = 1/dt)
60 * of time steps per hour. We also assume that this method is called every time step
61 * and that the probabilities of dying at different times are independent.
62 *
63 * Let q=mProbabilityOfDeathInAnHour and p="probability of death in a given time step".
64 *
65 * Probability of not dying in an hour:
66 * (1-q) = (1-p)^n = (1-p)^(1/dt).
67 *
68 * Rearranging for p:
69 * p = 1 - (1-q)^dt.
70 */
71 double death_prob_this_timestep = 1.0 - pow((1.0 - mProbabilityOfDeathInAnHour), SimulationTime::Instance()->GetTimeStep());
72
73 if (!pCell->HasApoptosisBegun() &&
74 RandomNumberGenerator::Instance()->ranf() < death_prob_this_timestep)
75 {
76 // Mark the cell as apoptotic and store removal information if required.
77 this->mpCellPopulation->StartApoptosisOnCell(pCell, "RandomCellKiller");
78 }
79}
80
81template<unsigned DIM>
83{
84 for (typename AbstractCellPopulation<DIM>::Iterator cell_iter = this->mpCellPopulation->Begin();
85 cell_iter != this->mpCellPopulation->End();
86 ++cell_iter)
87 {
88 CheckAndLabelSingleCellForApoptosis(*cell_iter);
89 }
90}
91
92template<unsigned DIM>
94{
95 *rParamsFile << "\t\t\t<ProbabilityOfDeathInAnHour>" << mProbabilityOfDeathInAnHour << "</ProbabilityOfDeathInAnHour>\n";
96
97 // Call method on direct parent class
99}
100
101// Explicit instantiation
102template class RandomCellKiller<1>;
103template class RandomCellKiller<2>;
104template class RandomCellKiller<3>;
105
106// Serialization for Boost >= 1.36
#define EXCEPTION(message)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputCellKillerParameters(out_stream &rParamsFile)=0
double GetDeathProbabilityInAnHour() const
void OutputCellKillerParameters(out_stream &rParamsFile)
RandomCellKiller(AbstractCellPopulation< DIM > *pCellPopulation, double probabilityOfDeathInAnHour)
void CheckAndLabelCellsForApoptosisOrDeath()
void CheckAndLabelSingleCellForApoptosis(CellPtr pCell)
static RandomNumberGenerator * Instance()
static SimulationTime * Instance()