NhsCellularMechanicsOdeSystem.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #include "NhsCellularMechanicsOdeSystem.hpp"
00029 #include "OdeSystemInformation.hpp"
00030 #include <cmath>
00031 
00032 
00033 
00034 //
00035 // Model-scope constant parameters
00036 //
00037 const double NhsCellularMechanicsOdeSystem::mKon = 100;
00038 const double NhsCellularMechanicsOdeSystem::mKrefoff = 0.2;
00039 const double NhsCellularMechanicsOdeSystem::mGamma = 2;
00040 const double NhsCellularMechanicsOdeSystem::mCalciumTroponinMax = 0.07;
00041 const double NhsCellularMechanicsOdeSystem::mAlphaR1 = 0.002;
00042 const double NhsCellularMechanicsOdeSystem::mAlphaR2 = 0.00175;
00043 const double NhsCellularMechanicsOdeSystem::mKZ = 0.15;
00044 const double NhsCellularMechanicsOdeSystem::mNr = 3;
00045 const double NhsCellularMechanicsOdeSystem::mBeta1 = -4;
00046 const double NhsCellularMechanicsOdeSystem::mAlpha0 = 0.008;
00047 const double NhsCellularMechanicsOdeSystem::mN = 3;
00048 const double NhsCellularMechanicsOdeSystem::mZp = 0.85;
00049 const double NhsCellularMechanicsOdeSystem::mCalcium50ref = 0.00105;
00050 const double NhsCellularMechanicsOdeSystem::mTref = 56.2;
00051 const double NhsCellularMechanicsOdeSystem::mBeta0 = 4.9;
00052 const double NhsCellularMechanicsOdeSystem::mA = 0.35;
00053 const double NhsCellularMechanicsOdeSystem::mA1 = -29;
00054 const double NhsCellularMechanicsOdeSystem::mA2 = 138;
00055 const double NhsCellularMechanicsOdeSystem::mA3 = 129;
00056 const double NhsCellularMechanicsOdeSystem::mAlpha1 = 0.03;
00057 const double NhsCellularMechanicsOdeSystem::mAlpha2 = 0.130;
00058 const double NhsCellularMechanicsOdeSystem::mAlpha3 = 0.625;
00059 
00060 
00061 /*
00062  * ============================== PRIVATE FUNCTIONS =====================================
00063  */
00064 void NhsCellularMechanicsOdeSystem::CalculateCalciumTrop50()
00065 {
00066     double one_plus_beta1_times_lam_minus_one = 1 + mBeta1*(mLambda-1);
00067 
00068     mCalciumTrop50 = mCalciumTroponinMax * mCalcium50ref * one_plus_beta1_times_lam_minus_one;
00069     mCalciumTrop50 /= mCalcium50ref*one_plus_beta1_times_lam_minus_one + (1-one_plus_beta1_times_lam_minus_one/(2*mGamma))*mKrefoff/mKon;
00070 }
00071 
00072 
00073 double NhsCellularMechanicsOdeSystem::CalculateT0(double z)
00074 {
00075     double calcium_ratio_to_n = pow(mCalciumTrop50/mCalciumTroponinMax, mN);
00076 
00077     double z_max = mAlpha0 - mK2*calcium_ratio_to_n;
00078     z_max /= mAlpha0 + (mAlphaR1 + mK1)*calcium_ratio_to_n;
00079 
00080     return z * mTref * (1+mBeta0*(mLambda-1)) / z_max;
00081 }
00082 
00083 
00084 
00085 /*
00086  * ============================== PUBLIC FUNCTIONS =====================================
00087  */
00088 
00089 NhsCellularMechanicsOdeSystem::NhsCellularMechanicsOdeSystem()
00090     :   AbstractOdeSystem(5) // five state variables
00091 {
00092     mpSystemInfo = OdeSystemInformation<NhsCellularMechanicsOdeSystem>::Instance();
00093     SetStateVariables(GetInitialConditions());
00094 
00095     mLambda = 1.0;
00096     mDLambdaDt = 0.0;
00097     mCalciumI = 0.0;
00098 
00099     // Initialise mCalciumTrop50!!
00100     CalculateCalciumTrop50();
00101 
00102     double zp_to_n_plus_K_to_n = pow(mZp,mNr) + pow(mKZ,mNr);
00103 
00104     mK1 = mAlphaR2 * pow(mZp,mNr-1) * mNr * pow(mKZ,mNr);
00105     mK1 /= zp_to_n_plus_K_to_n * zp_to_n_plus_K_to_n;
00106 
00107     mK2 = mAlphaR2 * pow(mZp,mNr)/zp_to_n_plus_K_to_n;
00108     mK2 *= 1 - mNr*pow(mKZ,mNr)/zp_to_n_plus_K_to_n;
00109 }
00110 
00111 void NhsCellularMechanicsOdeSystem::SetLambdaAndDerivative(double lambda, double dlambdaDt)
00112 {
00113     assert(lambda>0.0);
00114     mLambda = lambda;
00115     mDLambdaDt = dlambdaDt;
00116     // lambda changed so update mCalciumTrop50!!
00117     CalculateCalciumTrop50();
00118 }
00119 
00120 void NhsCellularMechanicsOdeSystem::SetIntracellularCalciumConcentration(double calciumI)
00121 {
00122     assert(calciumI > 0.0);
00123     mCalciumI = calciumI;
00124 }
00125 
00126 #define COVERAGE_IGNORE // this is covered, but gcov is rubbish
00127 double NhsCellularMechanicsOdeSystem::GetCalciumTroponinValue()
00128 {
00129     return mStateVariables[0];
00130 }
00131 #undef COVERAGE_IGNORE
00132 
00133 void NhsCellularMechanicsOdeSystem::EvaluateYDerivatives(double time,
00134                                                          const std::vector<double> &rY,
00135                                                          std::vector<double> &rDY)
00136 {
00137     const double& calcium_troponin = rY[0];
00138     const double& z = rY[1];
00139     const double& Q1 = rY[2];
00140     const double& Q2 = rY[3];
00141     const double& Q3 = rY[4];
00142 
00143     // check the state vars are in the expected range
00144     #define COVERAGE_IGNORE
00145     if(calcium_troponin < 0)
00146     {
00147         EXCEPTION("CalciumTrop concentration went negative");
00148     }
00149     if(z<0)
00150     {
00151         EXCEPTION("z went negative");
00152     }
00153     if(z>1)
00154     {
00155         EXCEPTION("z became greater than 1");
00156     }
00157     #undef COVERAGE_IGNORE
00158 
00159 
00160     double Q = Q1 + Q2 + Q3;
00161     double T0 = CalculateT0(z);
00162 
00163     double Ta;
00164     if(Q>0)
00165     {
00166         Ta = T0*(1+(2+mA)*Q)/(1+Q);
00167     }
00168     else
00169     {
00170         Ta = T0*(1+mA*Q)/(1-Q);
00171     }
00172 
00173     rDY[0] =   mKon * mCalciumI * ( mCalciumTroponinMax - calcium_troponin)
00174              - mKrefoff * (1-Ta/(mGamma*mTref)) * calcium_troponin;
00175 
00176     double ca_trop_to_ca_trop50_ratio_to_n = pow(calcium_troponin/mCalciumTrop50, mN);
00177 
00178     rDY[1] =   mAlpha0 * ca_trop_to_ca_trop50_ratio_to_n * (1-z)
00179              - mAlphaR1 * z
00180              - mAlphaR2 * pow(z,mNr) / (pow(z,mNr) + pow(mKZ,mNr));
00181 
00182 
00183     rDY[2] = mA1 * mDLambdaDt - mAlpha1 * Q1;
00184     rDY[3] = mA2 * mDLambdaDt - mAlpha2 * Q2;
00185     rDY[4] = mA3 * mDLambdaDt - mAlpha3 * Q3;
00186 }
00187 
00188 
00189 double NhsCellularMechanicsOdeSystem::GetActiveTension()
00190 {
00191     double T0 = CalculateT0(mStateVariables[1]);
00192     double Q = mStateVariables[2]+mStateVariables[3]+mStateVariables[4];
00193 
00194     if(Q>0)
00195     {
00196         return T0*(1+(2+mA)*Q)/(1+Q);
00197     }
00198     else
00199     {
00200         return T0*(1+mA*Q)/(1-Q);
00201     }
00202 }
00203 
00204 double NhsCellularMechanicsOdeSystem::GetLambda()
00205 {
00206     return mLambda;
00207 }
00208 
00209 
00210 template<>
00211 void OdeSystemInformation<NhsCellularMechanicsOdeSystem>::Initialise(void)
00212 {
00213     this->mVariableNames.push_back("CalciumTroponin");
00214     this->mVariableUnits.push_back("microMols");
00215     this->mInitialConditions.push_back(0);
00216 
00217     this->mVariableNames.push_back("z");
00218     this->mVariableUnits.push_back("");
00219     this->mInitialConditions.push_back(0);
00220 
00221     this->mVariableNames.push_back("Q1");
00222     this->mVariableUnits.push_back("");
00223     this->mInitialConditions.push_back(0);
00224 
00225     this->mVariableNames.push_back("Q2");
00226     this->mVariableUnits.push_back("");
00227     this->mInitialConditions.push_back(0);
00228 
00229     this->mVariableNames.push_back("Q3");
00230     this->mVariableUnits.push_back("");
00231     this->mInitialConditions.push_back(0);
00232 
00233     this->mInitialised = true;
00234 }

Generated on Tue Aug 4 16:10:22 2009 for Chaste by  doxygen 1.5.5