Chaste Release::3.1
Kerchoffs2003ContractionModel.cpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 
00037 #include "Kerchoffs2003ContractionModel.hpp"
00038 #include "Exception.hpp"
00039 #include "TimeStepper.hpp"
00040 #include <iostream>
00041 
00042 const double Kerchoffs2003ContractionModel::a6 = 2.0; // 1/um
00043 const double Kerchoffs2003ContractionModel::a7 = 1.5; // um
00044 const double Kerchoffs2003ContractionModel::T0 = 180; // kPa
00045 const double Kerchoffs2003ContractionModel::Ea = 20;  // 1/um
00046 const double Kerchoffs2003ContractionModel::v0 = 0.0075; // um/ms
00047 const double Kerchoffs2003ContractionModel::ls0 = 1.9; // um
00048 const double Kerchoffs2003ContractionModel::tr = 75; // ms
00049 const double Kerchoffs2003ContractionModel::td = 75; // ms
00050 const double Kerchoffs2003ContractionModel::b = 150; // ms/um
00051 const double Kerchoffs2003ContractionModel::ld = -0.4; // um
00052 
00053 Kerchoffs2003ContractionModel::Kerchoffs2003ContractionModel()
00054     : AbstractOdeBasedContractionModel(1)
00055 {
00056     mpSystemInfo = OdeSystemInformation<Kerchoffs2003ContractionModel>::Instance();
00057 
00058     mSarcomereLength = ls0;
00059 
00060     mStateVariables.push_back(mSarcomereLength-1.0/Ea); //steady state
00061 
00062     mIsActivated = false;
00063     mElectricallyUnactivated = true;
00064     mActivationTime = 0.0;
00065     mTime = 0.0;
00066 }
00067 
00068 
00069 void Kerchoffs2003ContractionModel::EvaluateYDerivatives(double time,
00070                                                          const std::vector<double>& rY,
00071                                                          std::vector<double>& rDY)
00072 {
00073     double lc = rY[0];
00074     rDY[0]=( Ea*(mSarcomereLength-lc) - 1 )*v0;
00075 }
00076 
00077 
00078 void Kerchoffs2003ContractionModel::SetInputParameters(ContractionModelInputParameters& rInputParameters)
00079 {
00080     assert(rInputParameters.voltage != DOUBLE_UNSET);
00081 
00082     if (mIsActivated && (rInputParameters.voltage < mDeactivationVoltage))
00083     {
00084         // inactive (resting) - note don't set mIsActivated=false yet
00085         // as the cell may yet be producing force, and the code is such
00086         // that if mIsActivated=false, Ta=0
00087         mElectricallyUnactivated = true;
00088     }
00089 
00090     if (!mIsActivated && (rInputParameters.voltage > mActivationVoltage))
00091     {
00092         // activated
00093         mIsActivated = true;
00094         mActivationTime = mTime;
00095         mElectricallyUnactivated = false;
00096     }
00097 }
00098 
00099 void Kerchoffs2003ContractionModel::SetStretchAndStretchRate(double stretch, double stretchRate)
00100 {
00101     mSarcomereLength = stretch*ls0;
00102 }
00103 
00104 
00105 double Kerchoffs2003ContractionModel::GetActiveTension(double lc)
00106 {
00107     double f_iso = 0;
00108     if(lc > a7)
00109     {
00110         f_iso = T0 * pow(tanh(a6*(lc-a7)),2);
00111     }
00112 
00113     double f_twitch = 0;
00114     double t_max = b*(mSarcomereLength - ld);
00115     if(mIsActivated)
00116     {
00117         double t_a = mTime - mActivationTime;
00118 
00119         if(t_a < t_max)
00120         {
00121             f_twitch = pow( tanh(t_a/tr)*tanh((t_max-t_a)/td), 2);
00122         }
00123         else if(mElectricallyUnactivated)
00124         {
00125             // t_a < t_ma => f_twitch=0 => Ta=0
00126             // In this case, if electrically unactivated as well,
00127             // set the state to be unactivated.
00128             mIsActivated = false;
00129         }
00130     }
00131 
00132     // expl is unstable for dt = 0.01, 0.001, impl is fine
00133     return (mSarcomereLength/ls0)*f_iso*f_twitch*(mSarcomereLength-lc)*Ea;
00134 }
00135 
00136 
00137 double Kerchoffs2003ContractionModel::GetActiveTension()
00138 {
00139     return GetActiveTension(mStateVariables[0]);
00140 }
00141 
00142 double Kerchoffs2003ContractionModel::GetNextActiveTension()
00143 {
00144     return GetActiveTension(mTemporaryStateVariables[0]);
00145 }
00146 
00147 template<>
00148 void OdeSystemInformation<Kerchoffs2003ContractionModel>::Initialise()
00149 {
00150     this->mVariableNames.push_back("lc");
00151     this->mVariableUnits.push_back("um");
00152     this->mInitialised = true;
00153 }