Chaste  Release::3.4
LinearSpringWithVariableSpringConstantsForce.cpp
1 /*
2 
3 Copyright (c) 2005-2016, 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 "LinearSpringWithVariableSpringConstantsForce.hpp"
37 #include "MeshBasedCellPopulation.hpp"
38 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisOne.hpp"
39 #include "VanLeeuwen2009WntSwatCellCycleModelHypothesisTwo.hpp"
40 #include "ApoptoticCellProperty.hpp"
41 
42 template<unsigned DIM>
45  mUseEdgeBasedSpringConstant(false),
46  mUseMutantSprings(false),
47  mMutantMutantMultiplier(DOUBLE_UNSET),
48  mNormalMutantMultiplier(DOUBLE_UNSET),
49  mUseBCatSprings(false),
50  mUseApoptoticSprings(false),
51  mBetaCatSpringScaler(18.14/6.0), // scale spring constant with beta-catenin level (divided by 6 for heaxagonal cells)
52  mApoptoticSpringTensionStiffness(15.0*0.25),
53  mApoptoticSpringCompressionStiffness(15.0*0.75)
54 {
55 }
56 
57 template<unsigned DIM>
59 {
60 }
61 
62 template<unsigned DIM>
64 {
65  assert(DIM == 2);
66  mUseEdgeBasedSpringConstant = useEdgeBasedSpringConstant;
67 }
68 
69 template<unsigned DIM>
70 void LinearSpringWithVariableSpringConstantsForce<DIM>::SetMutantSprings(bool useMutantSprings, double mutantMutantMultiplier, double normalMutantMultiplier)
71 {
72  mUseMutantSprings = useMutantSprings;
73  mMutantMutantMultiplier = mutantMutantMultiplier;
74  mNormalMutantMultiplier = normalMutantMultiplier;
75 }
76 
77 template<unsigned DIM>
79 {
80  mUseBCatSprings = useBCatSprings;
81 }
82 
83 template<unsigned DIM>
85 {
86  mUseApoptoticSprings = useApoptoticSprings;
87 }
88 
89 template<unsigned DIM>
91  unsigned nodeAGlobalIndex,
92  unsigned nodeBGlobalIndex,
93  AbstractCellPopulation<DIM>& rCellPopulation,
94  bool isCloserThanRestLength)
95 {
96 
97  double multiplication_factor = GeneralisedLinearSpringForce<DIM>::VariableSpringConstantMultiplicationFactor(nodeAGlobalIndex,
98  nodeBGlobalIndex,
99  rCellPopulation,
100  isCloserThanRestLength);
101 
102  CellPtr p_cell_A = rCellPopulation.GetCellUsingLocationIndex(nodeAGlobalIndex);
103  CellPtr p_cell_B = rCellPopulation.GetCellUsingLocationIndex(nodeBGlobalIndex);
104 
105  /*
106  * The next code block computes the edge-dependent spring constant as given by equation
107  * (3) in the following reference: van Leeuwen et al. 2009. An integrative computational model
108  * for intestinal tissue renewal. Cell Prolif. 42(5):617-636. doi:10.1111/j.1365-2184.2009.00627.x
109  */
110  if (mUseEdgeBasedSpringConstant)
111  {
112  assert(bool(dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation)));
113  assert(!mUseBCatSprings); // don't want to do both (both account for edge length)
114 
115  multiplication_factor = (static_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation))->GetVoronoiEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex)*sqrt(3.0);
116  }
117 
118  if (mUseMutantSprings)
119  {
120  unsigned number_of_mutants = 0;
121 
122  if (p_cell_A->GetMutationState()->IsType<ApcTwoHitCellMutationState>() || p_cell_A->GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
123  {
124  // If cell A is mutant
125  number_of_mutants++;
126  }
127 
128  if (p_cell_B->GetMutationState()->IsType<ApcTwoHitCellMutationState>() || p_cell_B->GetMutationState()->IsType<BetaCateninOneHitCellMutationState>())
129  {
130  // If cell B is mutant
131  number_of_mutants++;
132  }
133 
134  switch (number_of_mutants)
135  {
136  case 1u:
137  {
138  multiplication_factor *= mNormalMutantMultiplier;
139  break;
140  }
141  case 2u:
142  {
143  multiplication_factor *= mMutantMutantMultiplier;
144  break;
145  }
146  }
147  }
148 
149  /*
150  * The next code block computes the beta-catenin dependent spring constant as given by equation
151  * (4) in the following reference: van Leeuwen et al. 2009. An integrative computational model
152  * for intestinal tissue renewal. Cell Prolif. 42(5):617-636. doi:10.1111/j.1365-2184.2009.00627.x
153  */
154  if (mUseBCatSprings)
155  {
156  assert(bool(dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation)));
157 
158  // If using beta-cat dependent springs, both cell-cycle models had better be VanLeeuwen2009WntSwatCellCycleModel
159  AbstractVanLeeuwen2009WntSwatCellCycleModel* p_model_A = dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(p_cell_A->GetCellCycleModel());
160  AbstractVanLeeuwen2009WntSwatCellCycleModel* p_model_B = dynamic_cast<AbstractVanLeeuwen2009WntSwatCellCycleModel*>(p_cell_B->GetCellCycleModel());
161 
162  assert(!mUseEdgeBasedSpringConstant); // This already adapts for edge lengths - don't want to do it twice.
163  double beta_cat_cell_1 = p_model_A->GetMembraneBoundBetaCateninLevel();
164  double beta_cat_cell_2 = p_model_B->GetMembraneBoundBetaCateninLevel();
165 
166  MeshBasedCellPopulation<DIM>* p_static_cast_cell_population = (static_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation));
167 
168  double perim_cell_1 = p_static_cast_cell_population->GetSurfaceAreaOfVoronoiElement(nodeAGlobalIndex);
169  double perim_cell_2 = p_static_cast_cell_population->GetSurfaceAreaOfVoronoiElement(nodeBGlobalIndex);
170  double edge_length_between_1_and_2 = p_static_cast_cell_population->GetVoronoiEdgeLength(nodeAGlobalIndex, nodeBGlobalIndex);
171 
172  double beta_cat_on_cell_1_edge = beta_cat_cell_1 * edge_length_between_1_and_2 / perim_cell_1;
173  double beta_cat_on_cell_2_edge = beta_cat_cell_2 * edge_length_between_1_and_2 / perim_cell_2;
174 
175  double min_beta_Cat_of_two_cells = std::min(beta_cat_on_cell_1_edge, beta_cat_on_cell_2_edge);
176 
177  multiplication_factor *= min_beta_Cat_of_two_cells / mBetaCatSpringScaler;
178  }
179 
180  if (mUseApoptoticSprings)
181  {
182  bool cell_A_is_apoptotic = p_cell_A->HasCellProperty<ApoptoticCellProperty>();
183  bool cell_B_is_apoptotic = p_cell_B->HasCellProperty<ApoptoticCellProperty>();
184 
185  if (cell_A_is_apoptotic || cell_B_is_apoptotic)
186  {
187  double spring_a_stiffness = 2.0 * this->GetMeinekeSpringStiffness();
188  double spring_b_stiffness = 2.0 * this->GetMeinekeSpringStiffness();
189 
190  if (cell_A_is_apoptotic)
191  {
192  if (!isCloserThanRestLength) // if under tension
193  {
194  spring_a_stiffness = mApoptoticSpringTensionStiffness;
195  }
196  else // if under compression
197  {
198  spring_a_stiffness = mApoptoticSpringCompressionStiffness;
199  }
200  }
201  if (cell_B_is_apoptotic)
202  {
203  if (!isCloserThanRestLength) // if under tension
204  {
205  spring_b_stiffness = mApoptoticSpringTensionStiffness;
206  }
207  else // if under compression
208  {
209  spring_b_stiffness = mApoptoticSpringCompressionStiffness;
210  }
211  }
212 
213  multiplication_factor /= (1.0/spring_a_stiffness + 1.0/spring_b_stiffness)*this->GetMeinekeSpringStiffness();
214  }
215  }
216 
217  return multiplication_factor;
218 }
219 
220 template<unsigned DIM>
222 {
223  // Throw an exception message if not using a MeshBasedCellPopulation
224  if (dynamic_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation) == NULL)
225  {
226  EXCEPTION("LinearSpringWithVariableSpringConstantsForce is to be used with a subclass of MeshBasedCellPopulation only");
227  }
228 
229  MeshBasedCellPopulation<DIM>* p_static_cast_cell_population = static_cast<MeshBasedCellPopulation<DIM>*>(&rCellPopulation);
230 
231  for (typename MeshBasedCellPopulation<DIM>::SpringIterator spring_iterator = p_static_cast_cell_population->SpringsBegin();
232  spring_iterator != p_static_cast_cell_population->SpringsEnd();
233  ++spring_iterator)
234  {
235  unsigned nodeA_global_index = spring_iterator.GetNodeA()->GetIndex();
236  unsigned nodeB_global_index = spring_iterator.GetNodeB()->GetIndex();
237 
238  c_vector<double, DIM> force = this->CalculateForceBetweenNodes(nodeA_global_index, nodeB_global_index, rCellPopulation);
239  c_vector<double, DIM> negative_force = -1.0*force;
240 
241  spring_iterator.GetNodeB()->AddAppliedForceContribution(negative_force);
242  spring_iterator.GetNodeA()->AddAppliedForceContribution(force);
243  }
244 }
245 
246 template<unsigned DIM>
248 {
249  return mBetaCatSpringScaler;
250 }
251 
252 template<unsigned DIM>
254 {
255  assert(betaCatSpringScaler > 0.0);
256  mBetaCatSpringScaler = betaCatSpringScaler;
257 }
258 
259 template<unsigned DIM>
261 {
262  return mApoptoticSpringTensionStiffness;
263 }
264 
265 template<unsigned DIM>
267 {
268  assert(apoptoticSpringTensionStiffness >= 0.0);
269  mApoptoticSpringTensionStiffness = apoptoticSpringTensionStiffness;
270 }
271 
272 template<unsigned DIM>
274 {
275  return mApoptoticSpringCompressionStiffness;
276 }
277 
278 template<unsigned DIM>
280 {
281  assert(apoptoticSpringCompressionStiffness >= 0.0);
282  mApoptoticSpringCompressionStiffness = apoptoticSpringCompressionStiffness;
283 }
284 
285 template<unsigned DIM>
287 {
288  *rParamsFile << "\t\t\t<UseEdgeBasedSpringConstant>" << mUseEdgeBasedSpringConstant << "</UseEdgeBasedSpringConstant>\n";
289  *rParamsFile << "\t\t\t<UseMutantSprings>" << mUseMutantSprings << "</UseMutantSprings>\n";
290  *rParamsFile << "\t\t\t<MutantMutantMultiplier>" << mMutantMutantMultiplier << "</MutantMutantMultiplier>\n";
291  *rParamsFile << "\t\t\t<NormalMutantMultiplier>" << mNormalMutantMultiplier << "</NormalMutantMultiplier>\n";
292  *rParamsFile << "\t\t\t<UseBCatSprings>" << mUseBCatSprings << "</UseBCatSprings>\n";
293  *rParamsFile << "\t\t\t<UseApoptoticSprings>" << mUseApoptoticSprings << "</UseApoptoticSprings>\n";
294  *rParamsFile << "\t\t\t<BetaCatSpringScaler>" << mBetaCatSpringScaler << "</BetaCatSpringScaler>\n";
295  *rParamsFile << "\t\t\t<ApoptoticSpringTensionStiffness>" << mApoptoticSpringTensionStiffness << "</ApoptoticSpringTensionStiffness>\n";
296  *rParamsFile << "\t\t\t<ApoptoticSpringCompressionStiffness>" << mApoptoticSpringCompressionStiffness << "</ApoptoticSpringCompressionStiffness>\n";
297 
298  // Call method on direct parent class
300 }
301 
306 
307 
308 // Serialization for Boost >= 1.36
double GetSurfaceAreaOfVoronoiElement(unsigned index)
double GetVoronoiEdgeLength(unsigned index1, unsigned index2)
void SetApoptoticSpringTensionStiffness(double apoptoticSpringTensionStiffness)
virtual CellPtr GetCellUsingLocationIndex(unsigned index)
double VariableSpringConstantMultiplicationFactor(unsigned nodeAGlobalIndex, unsigned nodeBGlobalIndex, AbstractCellPopulation< DIM > &rCellPopulation, bool isCloserThanRestLength)
#define EXCEPTION(message)
Definition: Exception.hpp:143
const double DOUBLE_UNSET
Definition: Exception.hpp:56
#define EXPORT_TEMPLATE_CLASS_SAME_DIMS(CLASS)
void AddForceContribution(AbstractCellPopulation< DIM > &rCellPopulation)
virtual double VariableSpringConstantMultiplicationFactor(unsigned nodeAGlobalIndex, unsigned nodeBGlobalIndex, AbstractCellPopulation< ELEMENT_DIM, SPACE_DIM > &rCellPopulation, bool isCloserThanRestLength)
void SetMutantSprings(bool useMutantSprings, double mutantMutantMultiplier=2, double normalMutantMultiplier=1.5)
virtual void OutputForceParameters(out_stream &rParamsFile)
void SetApoptoticSpringCompressionStiffness(double apoptoticSpringCompressionStiffness)