NhsContractionModel.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "NhsContractionModel.hpp"
00029 #include "OdeSystemInformation.hpp"
00030 #include "EulerIvpOdeSolver.hpp"
00031 #include "UblasCustomFunctions.hpp"
00032
00033 #include <cmath>
00034
00035
00036
00037
00038
00039
00040 const double NhsContractionModel::mKon = 100;
00041 const double NhsContractionModel::mKrefoff = 0.2;
00042 const double NhsContractionModel::mGamma = 2;
00043 const double NhsContractionModel::mCalciumTroponinMax = 0.07;
00044 const double NhsContractionModel::mAlphaR1 = 0.002;
00045 const double NhsContractionModel::mAlphaR2 = 0.00175;
00046 const double NhsContractionModel::mKZ = 0.15;
00047 const unsigned NhsContractionModel::mNr = 3u;
00048 const double NhsContractionModel::mBeta1 = -4;
00049 const double NhsContractionModel::mAlpha0 = 0.008;
00050 const unsigned NhsContractionModel::mN = 3u;
00051 const double NhsContractionModel::mZp = 0.85;
00052 const double NhsContractionModel::mCalcium50ref = 0.00105;
00053 const double NhsContractionModel::mTref = 56.2;
00054 const double NhsContractionModel::mBeta0 = 4.9;
00055 const double NhsContractionModel::mA = 0.35;
00056 const double NhsContractionModel::mA1 = -29;
00057 const double NhsContractionModel::mA2 = 138;
00058 const double NhsContractionModel::mA3 = 129;
00059 const double NhsContractionModel::mAlpha1 = 0.03;
00060 const double NhsContractionModel::mAlpha2 = 0.130;
00061 const double NhsContractionModel::mAlpha3 = 0.625;
00062
00063
00064
00065
00066
00067 void NhsContractionModel::CalculateCalciumTrop50()
00068 {
00069 double one_plus_beta1_times_lam_minus_one = 1 + mBeta1*(mLambda-1);
00070
00071 mCalciumTrop50 = mCalciumTroponinMax * mCalcium50ref * one_plus_beta1_times_lam_minus_one;
00072 mCalciumTrop50 /= mCalcium50ref*one_plus_beta1_times_lam_minus_one + (1-one_plus_beta1_times_lam_minus_one/(2*mGamma))*mKrefoff/mKon;
00073 }
00074
00075
00076 double NhsContractionModel::CalculateT0(double z)
00077 {
00078 double calcium_ratio_to_n = SmallPow(mCalciumTrop50/mCalciumTroponinMax, mN);
00079
00080 double z_max = mAlpha0 - mK2*calcium_ratio_to_n;
00081 z_max /= mAlpha0 + (mAlphaR1 + mK1)*calcium_ratio_to_n;
00082
00083 return z * mTref * (1+mBeta0*(mLambda-1)) / z_max;
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 NhsContractionModel::NhsContractionModel()
00093 : AbstractOdeBasedContractionModel(5)
00094 {
00095 mpSystemInfo = OdeSystemInformation<NhsContractionModel>::Instance();
00096 SetStateVariables(GetInitialConditions());
00097
00098 mLambda = 1.0;
00099 mDLambdaDt = 0.0;
00100 mCalciumI = 0.0;
00101
00102
00103 CalculateCalciumTrop50();
00104
00105 double zp_to_n_plus_K_to_n = SmallPow(mZp,mNr) + SmallPow(mKZ,mNr);
00106
00107 mK1 = mAlphaR2 * SmallPow(mZp,mNr-1) * mNr * SmallPow(mKZ,mNr);
00108 mK1 /= zp_to_n_plus_K_to_n * zp_to_n_plus_K_to_n;
00109
00110 mK2 = mAlphaR2 * SmallPow(mZp,mNr)/zp_to_n_plus_K_to_n;
00111 mK2 *= 1 - mNr*SmallPow(mKZ,mNr)/zp_to_n_plus_K_to_n;
00112 }
00113
00114 void NhsContractionModel::SetStretchAndStretchRate(double lambda, double dlambdaDt)
00115 {
00116 assert(lambda>0.0);
00117 mLambda = lambda;
00118 mDLambdaDt = dlambdaDt;
00119
00120 CalculateCalciumTrop50();
00121 }
00122
00123 void NhsContractionModel::SetInputParameters(ContractionModelInputParameters& rInputParameters)
00124 {
00125 assert(rInputParameters.intracellularCalciumConcentration != DOUBLE_UNSET);
00126 assert(rInputParameters.intracellularCalciumConcentration > 0.0);
00127 mCalciumI = rInputParameters.intracellularCalciumConcentration;
00128 }
00129
00130 void NhsContractionModel::SetIntracellularCalciumConcentration(double calciumConcentration)
00131 {
00132 assert(calciumConcentration > 0.0);
00133 mCalciumI = calciumConcentration;
00134 }
00135
00136 double NhsContractionModel::GetCalciumTroponinValue()
00137 {
00138 return mStateVariables[0];
00139 }
00140
00141 void NhsContractionModel::EvaluateYDerivatives(double time,
00142 const std::vector<double> &rY,
00143 std::vector<double> &rDY)
00144 {
00146
00147 const double& calcium_troponin = rY[0];
00148 const double& z = rY[1];
00149 const double& Q1 = rY[2];
00150 const double& Q2 = rY[3];
00151 const double& Q3 = rY[4];
00152
00153
00154 #define COVERAGE_IGNORE
00155 if(calcium_troponin < 0)
00156 {
00157 EXCEPTION("CalciumTrop concentration went negative");
00158 }
00159 if(z<0)
00160 {
00161 EXCEPTION("z went negative");
00162 }
00163 if(z>1)
00164 {
00165 EXCEPTION("z became greater than 1");
00166 }
00167 #undef COVERAGE_IGNORE
00168
00169
00170 double Q = Q1 + Q2 + Q3;
00171 double T0 = CalculateT0(z);
00172
00173 double Ta;
00174 if(Q>0)
00175 {
00176 Ta = T0*(1+(2+mA)*Q)/(1+Q);
00177 }
00178 else
00179 {
00180 Ta = T0*(1+mA*Q)/(1-Q);
00181 }
00182
00183 rDY[0] = mKon * mCalciumI * ( mCalciumTroponinMax - calcium_troponin)
00184 - mKrefoff * (1-Ta/(mGamma*mTref)) * calcium_troponin;
00185
00186 double ca_trop_to_ca_trop50_ratio_to_n = SmallPow(calcium_troponin/mCalciumTrop50, mN);
00187
00188 rDY[1] = mAlpha0 * ca_trop_to_ca_trop50_ratio_to_n * (1-z)
00189 - mAlphaR1 * z
00190 - mAlphaR2 * SmallPow(z,mNr) / (SmallPow(z,mNr) + SmallPow(mKZ,mNr));
00191
00192
00193 rDY[2] = mA1 * mDLambdaDt - mAlpha1 * Q1;
00194 rDY[3] = mA2 * mDLambdaDt - mAlpha2 * Q2;
00195 rDY[4] = mA3 * mDLambdaDt - mAlpha3 * Q3;
00196 }
00197
00198
00199 double NhsContractionModel::GetActiveTension()
00200 {
00201 double T0 = CalculateT0(mStateVariables[1]);
00202 double Q = mStateVariables[2]+mStateVariables[3]+mStateVariables[4];
00203
00204 if(Q>0)
00205 {
00206 return T0*(1+(2+mA)*Q)/(1+Q);
00207 }
00208 else
00209 {
00210 return T0*(1+mA*Q)/(1-Q);
00211 }
00212 }
00213
00214 template<>
00215 void OdeSystemInformation<NhsContractionModel>::Initialise(void)
00216 {
00217 this->mVariableNames.push_back("CalciumTroponin");
00218 this->mVariableUnits.push_back("microMols");
00219 this->mInitialConditions.push_back(0);
00220
00221 this->mVariableNames.push_back("z");
00222 this->mVariableUnits.push_back("");
00223 this->mInitialConditions.push_back(0);
00224
00225 this->mVariableNames.push_back("Q1");
00226 this->mVariableUnits.push_back("");
00227 this->mInitialConditions.push_back(0);
00228
00229 this->mVariableNames.push_back("Q2");
00230 this->mVariableUnits.push_back("");
00231 this->mInitialConditions.push_back(0);
00232
00233 this->mVariableNames.push_back("Q3");
00234 this->mVariableUnits.push_back("");
00235 this->mInitialConditions.push_back(0);
00236
00237 this->mInitialised = true;
00238 }