35 #include "WntConcentration.hpp"
38 template<
unsigned DIM>
41 template<
unsigned DIM>
44 if (mpInstance ==
nullptr)
51 template<
unsigned DIM>
56 mpCellPopulation(nullptr),
58 mConstantWntValueForTesting(0),
59 mUseConstantWntValueForTesting(false),
60 mWntConcentrationParameter(1.0),
61 mCryptProjectionParameterA(0.5),
62 mCryptProjectionParameterB(2.0)
68 template<
unsigned DIM>
73 template<
unsigned DIM>
83 template<
unsigned DIM>
86 if (mUseConstantWntValueForTesting)
88 return mConstantWntValueForTesting;
91 assert(mpCellPopulation!=
nullptr);
97 if (mWntType == RADIAL)
99 double a = GetCryptProjectionParameterA();
100 double b = GetCryptProjectionParameterB();
101 height = a*pow(norm_2(mpCellPopulation->GetLocationOfCellCentre(pCell)), b);
105 height = mpCellPopulation->GetLocationOfCellCentre(pCell)[DIM-1];
108 return GetWntLevel(height);
111 template<
unsigned DIM>
114 if (mUseConstantWntValueForTesting)
116 return zero_vector<double>(DIM);
118 assert(mpCellPopulation!=
nullptr);
122 c_vector<double, DIM> location_of_cell = mpCellPopulation->GetLocationOfCellCentre(pCell);
124 return GetWntGradient(location_of_cell);
127 template<
unsigned DIM>
130 mpCellPopulation = &rCellPopulation;
133 template<
unsigned DIM>
136 return *mpCellPopulation;
139 template<
unsigned DIM>
145 template<
unsigned DIM>
148 assert(cryptLength > 0.0);
149 if (mLengthSet==
true)
151 EXCEPTION(
"Destroy has not been called");
154 mCryptLength = cryptLength;
158 template<
unsigned DIM>
164 template<
unsigned DIM>
169 EXCEPTION(
"Destroy has not been called");
175 template<
unsigned DIM>
178 if (mWntType == NONE)
186 double wnt_level = -1.0;
189 if (mWntType==LINEAR || mWntType==RADIAL)
191 if ((height >= -1e-9) && (height < mWntConcentrationParameter*GetCryptLength()))
193 wnt_level = 1.0 - height/(mWntConcentrationParameter*GetCryptLength());
201 if (mWntType==EXPONENTIAL)
203 if ((height >= -1e-9) && (height < GetCryptLength()))
205 wnt_level = exp(-height/(GetCryptLength()*mWntConcentrationParameter));
213 assert(wnt_level >= 0.0);
218 template<
unsigned DIM>
221 c_vector<double, DIM> wnt_gradient = zero_vector<double>(DIM);
225 if (mWntType==LINEAR)
227 if ((rLocation[DIM-1] >= -1e-9) && (rLocation[DIM-1] < mWntConcentrationParameter*GetCryptLength()))
229 wnt_gradient[DIM-1] = -1.0/(mWntConcentrationParameter*GetCryptLength());
232 else if (mWntType==RADIAL)
234 double a = GetCryptProjectionParameterA();
235 double b = GetCryptProjectionParameterB();
236 double r = norm_2(rLocation);
237 double r_critical = pow(mWntConcentrationParameter*GetCryptLength()/a, 1.0/b);
241 if (r>=-1e-9 && r<r_critical)
243 dwdr = -mWntConcentrationParameter*GetCryptLength()*pow(r, b-1.0)/a;
246 for (
unsigned i=0; i<DIM; i++)
248 wnt_gradient[i] = rLocation[i]*dwdr/r;
253 EXCEPTION(
"No method to calculate gradient of this Wnt type");
259 template<
unsigned DIM>
263 if (mTypeSet && mLengthSet && mpCellPopulation!=
nullptr && mWntType!=NONE)
270 template<
unsigned DIM>
275 EXCEPTION(
"WntConcentration<DIM>::SetConstantWntValueForTesting - Wnt value for testing should be non-negative.\n");
277 mConstantWntValueForTesting = value;
278 mUseConstantWntValueForTesting =
true;
285 template<
unsigned DIM>
288 return mWntConcentrationParameter;
291 template<
unsigned DIM>
294 assert(wntConcentrationParameter > 0.0);
295 mWntConcentrationParameter = wntConcentrationParameter;
298 template<
unsigned DIM>
301 return mCryptProjectionParameterA;
304 template<
unsigned DIM>
307 return mCryptProjectionParameterB;
310 template<
unsigned DIM>
313 assert(cryptProjectionParameterA >= 0.0);
314 mCryptProjectionParameterA = cryptProjectionParameterA;
317 template<
unsigned DIM>
320 assert(cryptProjectionParameterB >= 0.0);
321 mCryptProjectionParameterB = cryptProjectionParameterB;
double GetWntLevel(double height)
double GetWntConcentrationParameter()
#define EXCEPTION(message)
double GetCryptProjectionParameterB()
WntConcentrationType GetType()
const double DOUBLE_UNSET
void SetType(WntConcentrationType type)
void SetCellPopulation(AbstractCellPopulation< DIM > &rCellPopulation)
virtual ~WntConcentration()
static WntConcentration * Instance()
c_vector< double, DIM > GetWntGradient(c_vector< double, DIM > &rLocation)
void SetCryptLength(double cryptLength)
void SetConstantWntValueForTesting(double value)
static WntConcentration * mpInstance
AbstractCellPopulation< DIM > & rGetCellPopulation()
void SetCryptProjectionParameterA(double cryptProjectionParameterA)
void SetCryptProjectionParameterB(double cryptProjectionParameterB)
double GetCryptProjectionParameterA()
void SetWntConcentrationParameter(double wntConcentrationParameter)