Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
NormallyDistributedTargetAreaModifier.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 "NormallyDistributedTargetAreaModifier.hpp"
37#include "AbstractPhaseBasedCellCycleModel.hpp"
38#include "ApoptoticCellProperty.hpp"
39#include "RandomNumberGenerator.hpp"
40
41#include <algorithm>
42
43template<unsigned DIM>
49
50template<unsigned DIM>
54
55template<unsigned DIM>
57{
58 // Generate random numbers if needed
59 while (pCell->GetCellId() >= mNormalRandomNumbers.size())
60 {
61 // Generate N(1, 0.4)
62 double random_number = RandomNumberGenerator::Instance()->NormalRandomDeviate(1.0, 0.4);
63
64 // Bound the result to be in [0.5, 1.5]
65 random_number = std::min(1.5, random_number);
66 random_number = std::max(0.5, random_number);
67
68 mNormalRandomNumbers.push_back(random_number);
69 }
70
71 // Get target area A of a healthy cell in S, G2 or M phase
72 double cell_target_area = this->mReferenceTargetArea;
73
74 double growth_duration = mGrowthDuration;
75 if (growth_duration == DOUBLE_UNSET)
76 {
77 if (dynamic_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel()) == NULL)
78 {
79 EXCEPTION("If SetGrowthDuration() has not been called, a subclass of AbstractPhaseBasedCellCycleModel must be used");
80 }
81 AbstractPhaseBasedCellCycleModel* p_model = static_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel());
82
83 growth_duration = p_model->GetG1Duration();
84
85 // If the cell is differentiated then its G1 duration is infinite
86 if (growth_duration == DBL_MAX)
87 {
88 // This is just for fixed cell-cycle models, need to work out how to find the g1 duration
89 growth_duration = p_model->GetTransitCellG1Duration();
90 }
91 }
92
93 if (pCell->HasCellProperty<ApoptoticCellProperty>())
94 {
95 // Age of cell when apoptosis begins
96 if (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime() < growth_duration)
97 {
98 cell_target_area *= 0.5*(1 + (pCell->GetStartOfApoptosisTime() - pCell->GetBirthTime())/growth_duration);
99 }
100
101 // The target area of an apoptotic cell decreases linearly to zero
102 double time_spent_apoptotic = SimulationTime::Instance()->GetTime() - pCell->GetStartOfApoptosisTime();
103
104 cell_target_area *= 1.0 - 0.5/(pCell->GetApoptosisTime())*time_spent_apoptotic;
105 if (cell_target_area < 0)
106 {
107 cell_target_area = 0;
108 }
109 }
110 else
111 {
112 double cell_age = pCell->GetAge();
113
114 // The target area of a proliferating cell increases linearly from A/2 to A over the course of the prescribed duration
115 if (cell_age < growth_duration)
116 {
117 cell_target_area *= 0.5*(1 + cell_age/growth_duration);
118 }
119 else
120 {
128 if (pCell->ReadyToDivide())
129 {
130 cell_target_area = 0.5*this->mReferenceTargetArea;
131 }
132 }
133 }
134
135 // Set cell data
136 pCell->GetCellData()->SetItem("target area", cell_target_area * mNormalRandomNumbers[pCell->GetCellId()]);
137}
138
139template<unsigned DIM>
141{
142 return mGrowthDuration;
143}
144
145template<unsigned DIM>
147{
148 assert(growthDuration >= 0.0);
149 mGrowthDuration = growthDuration;
150}
151
152template<unsigned DIM>
154{
155 *rParamsFile << "\t\t\t<GrowthDuration>" << mGrowthDuration << "</GrowthDuration>\n";
156
157 // Next, call method on direct parent class
159}
160
161// Explicit instantiation
165
166// Serialization for Boost >= 1.36
const double DOUBLE_UNSET
Definition Exception.hpp:57
#define EXCEPTION(message)
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)
double NormalRandomDeviate(double mean, double stdDev)
static RandomNumberGenerator * Instance()
double GetTime() const
static SimulationTime * Instance()