Chaste  Release::2018.1
TargetAreaLinearGrowthModifier.cpp
1 /*
2 
3 Copyright (c) 2005-2018, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, 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 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #include "TargetAreaLinearGrowthModifier.hpp"
37 #include "ApoptoticCellProperty.hpp"
38 #include "DifferentiatedCellProliferativeType.hpp"
39 #include "AbstractPhaseBasedCellCycleModel.hpp"
40 
41 template<unsigned DIM>
44  mAgeToStartGrowing(DOUBLE_UNSET),
45  mGrowthRate(DOUBLE_UNSET)
46 {
47 }
48 
49 template<unsigned DIM>
51 {
52 }
53 
54 template<unsigned DIM>
56 {
57  // Get target area A of a healthy cell in S, G2 or M phase
58  double cell_target_area = this->mReferenceTargetArea;
59 
60  // The target area of an apoptotic cell decreases linearly to zero
61  if (pCell->HasCellProperty<ApoptoticCellProperty>())
62  {
64  double time_spent_apoptotic = SimulationTime::Instance()->GetTime() - pCell->GetStartOfApoptosisTime();
65  cell_target_area = cell_target_area - 0.5*cell_target_area/(pCell->GetApoptosisTime())*time_spent_apoptotic;
66 
67  // Don't allow a negative target area
68  if (cell_target_area < 0)
69  {
70  cell_target_area = 0;
71  }
72  }
73  else
74  {
75  bool cell_is_differentiated = pCell->GetCellProliferativeType()->IsType<DifferentiatedCellProliferativeType>();
76  if (!cell_is_differentiated)
77  {
78  /*
79  * If not using a phase-based cell-cycle model, the target area of a proliferating cell increases
80  * linearly from mReferenceTargetArea as soon as the cell's age exceeds mAgeToStartGrowing, with
81  * growth rate mGrowthRate.
82  */
83  double growth_start_time = mAgeToStartGrowing;
84  double growth_rate = mGrowthRate;
85  if (growth_start_time == DOUBLE_UNSET)
86  {
87  if (dynamic_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel()) == nullptr)
88  {
89  EXCEPTION("If SetAgeToStartGrowing() has not been called, a subclass of AbstractPhaseBasedCellCycleModel must be used");
90  }
91 
92  /*
93  * If using a phase-based cell-cycle model, the target area of a proliferating cell increases
94  * linearly from mReferenceTargetArea to 2*mReferenceTargetArea during the cell's G2 phase.
95  */
96  AbstractPhaseBasedCellCycleModel* p_model = static_cast<AbstractPhaseBasedCellCycleModel*>(pCell->GetCellCycleModel());
97  growth_start_time = p_model->GetMDuration() + p_model->GetG1Duration() + p_model->GetSDuration();
98 
99  double g2_duration = p_model->GetG2Duration();
100  growth_rate = cell_target_area/g2_duration;
101  }
102  else if (mGrowthRate == DOUBLE_UNSET)
103  {
104  EXCEPTION("If SetAgeToStartGrowing() has been called, then SetGrowthRate() must also be called");
105  }
106 
107  double time_spent_growing = pCell->GetAge() - growth_start_time;
108 
109  // The target area of a proliferating cell increases linearly
110  if (time_spent_growing > 0)
111  {
112  cell_target_area += time_spent_growing*growth_rate;
113  }
114 
122  if (pCell->ReadyToDivide())
123  {
124  cell_target_area = this->mReferenceTargetArea;
125  }
126  }
127  }
128 
129  // Set cell data
130  pCell->GetCellData()->SetItem("target area", cell_target_area);
131 }
132 
133 template<unsigned DIM>
135 {
136  return mAgeToStartGrowing;
137 }
138 
139 template<unsigned DIM>
141 {
142  assert(ageToStartGrowing >= 0.0);
143  mAgeToStartGrowing = ageToStartGrowing;
144 }
145 
146 template<unsigned DIM>
148 {
149  return mGrowthRate;
150 }
151 
152 template<unsigned DIM>
154 {
155  assert(growthRate >= 0.0);
156  mGrowthRate = growthRate;
157 }
158 
159 template<unsigned DIM>
161 {
162  *rParamsFile << "\t\t\t<AgeToStartGrowing>" << mAgeToStartGrowing << "</AgeToStartGrowing>\n";
163  *rParamsFile << "\t\t\t<GrowthRate>" << mGrowthRate << "</GrowthRate>\n";
164 
165  // Next, call method on direct parent class
167 }
168 
169 // Explicit instantiation
170 template class TargetAreaLinearGrowthModifier<1>;
171 template class TargetAreaLinearGrowthModifier<2>;
172 template class TargetAreaLinearGrowthModifier<3>;
173 
174 // Serialization for Boost >= 1.36
virtual void OutputSimulationModifierParameters(out_stream &rParamsFile)
#define EXCEPTION(message)
Definition: Exception.hpp:143
void OutputSimulationModifierParameters(out_stream &rParamsFile)
static SimulationTime * Instance()
void SetAgeToStartGrowing(double ageToStartGrowing)
const double DOUBLE_UNSET
Definition: Exception.hpp:56
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
double GetTime() const