Chaste  Build::
Owen11CaUpdateRule.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 "Owen11CaUpdateRule.hpp"
37 #include "Owen11Parameters.hpp"
38 #include "BaseUnits.hpp"
39 #include "CancerCellMutationState.hpp"
40 #include "QuiescentCancerCellMutationState.hpp"
41 
42 template<unsigned DIM>
44  : AbstractCaUpdateRule<DIM>(),
45  mDiffusionParameter(Owen11Parameters::mpCellMotilityCancer->GetValue("Owen11CaUpdateRule")),
46  mpVesselNetwork(),
47  mpRegularGrid(),
48  mReferenceLengthScale(BaseUnits::Instance()->GetReferenceLengthScale()),
49  mCancerCellCarryingCapacity(2)
50 
51 {
52 }
53 
54 template<unsigned DIM>
56 {
57 }
58 
59 template<unsigned DIM>
60 double Owen11CaUpdateRule<DIM>::EvaluateProbability(unsigned currentNodeIndex,
61  unsigned targetNodeIndex,
62  CaBasedCellPopulation<DIM>& rCellPopulation,
63  double dt,
64  double deltaX,
65  CellPtr pCell)
66 {
67  if(pCell->GetMutationState()->IsType<CancerCellMutationState>() || pCell->GetMutationState()->IsType<QuiescentCancerCellMutationState>())
68  {
69  // Check if the carrying capacity is sufficient
70  unsigned num_cells_at_site = 0;
71 
72  if(mpVesselNetwork and DIM>1)
73  {
74  if(!mpRegularGrid)
75  {
76  EXCEPTION("A regular grid is required for determining vessel based lattice occupancy");
77  }
78  if(mpRegularGrid->IsSegmentAtLatticeSite(targetNodeIndex, false))
79  {
80  num_cells_at_site = 1;
81  }
82  }
83 
84  num_cells_at_site += rCellPopulation.GetCellsUsingLocationIndex(targetNodeIndex).size();
85 
86  // Get the sprouting probability
87  c_vector<double, DIM> node_index_location = rCellPopulation.GetNode(currentNodeIndex)->rGetLocation();
88  c_vector<double, DIM> node_neighbour_location = rCellPopulation.GetNode(targetNodeIndex)->rGetLocation();
89  units::quantity<unit::length> grid_distance = norm_2(rCellPopulation.rGetMesh().GetVectorFromAtoB(node_index_location,
90  node_neighbour_location))*mReferenceLengthScale;
91 
92  units::quantity<unit::time> time_increment = dt*BaseUnits::Instance()->GetReferenceTimeScale();
93  double carrying_capacity_factor = (double(mCancerCellCarryingCapacity)-double(num_cells_at_site))/double(mCancerCellCarryingCapacity);
94  return mDiffusionParameter*time_increment*carrying_capacity_factor/(2.0* units::pow<2>(grid_distance));
95  }
96  else
97  {
98  return 0.0;
99  }
100 }
101 
112 template<>
113 double Owen11CaUpdateRule<1>::EvaluateProbability(unsigned currentNodeIndex,
114  unsigned targetNodeIndex,
115  CaBasedCellPopulation<1>& rCellPopulation,
116  double dt,
117  double deltaX,
118  CellPtr pCell)
119 {
120  EXCEPTION("This update rule is not supported in 1D");
121 }
122 
123 template<unsigned DIM>
124 void Owen11CaUpdateRule<DIM>::SetVesselNetwork(boost::shared_ptr<VesselNetwork<DIM> > pVesselNetwork)
125 {
126  mpVesselNetwork = pVesselNetwork;
127 }
128 
129 template<unsigned DIM>
130 void Owen11CaUpdateRule<DIM>::SetReferenceLengthScale(units::quantity<unit::length> referenceLengthScale)
131 {
132  mReferenceLengthScale = referenceLengthScale;
133 }
134 
135 template<unsigned DIM>
136 void Owen11CaUpdateRule<DIM>::SetRegularGrid(boost::shared_ptr<RegularGrid<DIM> > pRegularGrid)
137 {
138  mpRegularGrid = pRegularGrid;
139 }
140 
141 template<unsigned DIM>
142 units::quantity<unit::diffusivity> Owen11CaUpdateRule<DIM>::GetDiffusionParameter()
143 {
144  return mDiffusionParameter;
145 }
146 
147 template<unsigned DIM>
148 void Owen11CaUpdateRule<DIM>::SetDiffusionParameter(units::quantity<unit::diffusivity> diffusionParameter)
149 {
150  mDiffusionParameter = diffusionParameter;
151 }
152 
153 template<unsigned DIM>
155 {
156  *rParamsFile << "\t\t\t<DiffusionParameter>" << mDiffusionParameter << "</DiffusionParameter>\n";
157 
158  // Call method on direct parent class
160 }
161 
162 // Explicit instantiation
163 template class Owen11CaUpdateRule<2u>;
164 template class Owen11CaUpdateRule<3u>;
165 
166 // Serialization for Boost >= 1.36
167 #include "SerializationExportWrapperForCpp.hpp"
168 EXPORT_TEMPLATE_CLASS_SAME_DIMS(Owen11CaUpdateRule)
unsigned mCancerCellCarryingCapacity
void SetVesselNetwork(boost::shared_ptr< VesselNetwork< DIM > > pVesselNetwork)
boost::shared_ptr< VesselNetwork< DIM > > mpVesselNetwork
void OutputUpdateRuleParameters(out_stream &rParamsFile)
units::quantity< unit::time > GetReferenceTimeScale()
Definition: BaseUnits.cpp:72
units::quantity< unit::length > mReferenceLengthScale
units::quantity< unit::diffusivity > mDiffusionParameter
double EvaluateProbability(unsigned currentNodeIndex, unsigned targetNodeIndex, CaBasedCellPopulation< DIM > &rCellPopulation, double dt, double deltaX, CellPtr cell)
units::quantity< unit::diffusivity > GetDiffusionParameter()
void SetReferenceLengthScale(units::quantity< unit::length > referenceLengthScale)
void SetDiffusionParameter(units::quantity< unit::diffusivity > diffusionParameter)
boost::shared_ptr< RegularGrid< DIM > > mpRegularGrid
static BaseUnits * Instance()
Definition: BaseUnits.cpp:53
void SetRegularGrid(boost::shared_ptr< RegularGrid< DIM > > pRegularGrid)