35#include "WntConcentration.hpp"
44 if (mpInstance ==
nullptr)
56 mpCellPopulation(nullptr),
58 mConstantWntValueForTesting(0),
59 mUseConstantWntValueForTesting(false),
60 mWntConcentrationParameter(1.0),
61 mCryptProjectionParameterA(0.5),
62 mCryptProjectionParameterB(2.0)
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);
111template<
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);
127template<
unsigned DIM>
130 mpCellPopulation = &rCellPopulation;
133template<
unsigned DIM>
136 return *mpCellPopulation;
139template<
unsigned DIM>
145template<
unsigned DIM>
148 assert(cryptLength > 0.0);
149 if (mLengthSet==
true)
151 EXCEPTION(
"Destroy has not been called");
154 mCryptLength = cryptLength;
158template<
unsigned DIM>
164template<
unsigned DIM>
169 EXCEPTION(
"Destroy has not been called");
175template<
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);
218template<
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");
259template<
unsigned DIM>
263 if (mTypeSet && mLengthSet && mpCellPopulation!=
nullptr && mWntType!=NONE)
270template<
unsigned DIM>
275 EXCEPTION(
"WntConcentration<DIM>::SetConstantWntValueForTesting - Wnt value for testing should be non-negative.\n");
277 mConstantWntValueForTesting = value;
278 mUseConstantWntValueForTesting =
true;
285template<
unsigned DIM>
288 return mWntConcentrationParameter;
291template<
unsigned DIM>
294 assert(wntConcentrationParameter > 0.0);
295 mWntConcentrationParameter = wntConcentrationParameter;
298template<
unsigned DIM>
301 return mCryptProjectionParameterA;
304template<
unsigned DIM>
307 return mCryptProjectionParameterB;
310template<
unsigned DIM>
313 assert(cryptProjectionParameterA >= 0.0);
314 mCryptProjectionParameterA = cryptProjectionParameterA;
317template<
unsigned DIM>
320 assert(cryptProjectionParameterB >= 0.0);
321 mCryptProjectionParameterB = cryptProjectionParameterB;
const double DOUBLE_UNSET
#define EXCEPTION(message)
static WntConcentration * Instance()
void SetWntConcentrationParameter(double wntConcentrationParameter)
AbstractCellPopulation< DIM > & rGetCellPopulation()
double GetCryptProjectionParameterB()
void SetType(WntConcentrationType type)
c_vector< double, DIM > GetWntGradient(c_vector< double, DIM > &rLocation)
void SetCellPopulation(AbstractCellPopulation< DIM > &rCellPopulation)
static WntConcentration * mpInstance
double GetCryptProjectionParameterA()
void SetCryptProjectionParameterB(double cryptProjectionParameterB)
WntConcentrationType GetType()
double GetWntConcentrationParameter()
void SetCryptLength(double cryptLength)
void SetCryptProjectionParameterA(double cryptProjectionParameterA)
double GetWntLevel(double height)
void SetConstantWntValueForTesting(double value)
virtual ~WntConcentration()