AbstractCvodeCell.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
00029 #ifdef CHASTE_CVODE
00030
00031 #include <sstream>
00032 #include <iostream>
00033 #include <cmath>
00034
00035 #include "AbstractCvodeCell.hpp"
00036 #include "Exception.hpp"
00037 #include "HeartConfig.hpp"
00038 #include "VectorHelperFunctions.hpp"
00039
00040
00041 AbstractCvodeCell::AbstractCvodeCell(boost::shared_ptr<AbstractIvpOdeSolver> ,
00042 unsigned numberOfStateVariables,
00043 unsigned voltageIndex,
00044 boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus)
00045 : AbstractCardiacCellInterface(boost::shared_ptr<AbstractIvpOdeSolver>(), voltageIndex, pIntracellularStimulus),
00046 AbstractCvodeSystem(numberOfStateVariables),
00047 mMaxDt(DOUBLE_UNSET)
00048 {
00049 }
00050
00051
00052 AbstractCvodeCell::~AbstractCvodeCell()
00053 {
00054 }
00055
00056 double AbstractCvodeCell::GetVoltage()
00057 {
00058 assert(mStateVariables);
00059 return GetAnyVariable(mVoltageIndex);
00060 }
00061
00062 void AbstractCvodeCell::SetVoltage(double voltage)
00063 {
00064 assert(mStateVariables);
00065 SetAnyVariable(mVoltageIndex, voltage);
00066 }
00067
00068
00069 void AbstractCvodeCell::SetTimestep(double maxDt)
00070 {
00071 mMaxDt = maxDt;
00072 }
00073
00074
00075 void AbstractCvodeCell::SolveAndUpdateState(double tStart, double tEnd)
00076 {
00077 if (mMaxDt == DOUBLE_UNSET)
00078 {
00079 SetTimestep(HeartConfig::Instance()->GetPrintingTimeStep());
00080 }
00081 Solve(tStart, tEnd, mMaxDt);
00082 }
00083
00084 OdeSolution AbstractCvodeCell::Compute(double tStart, double tEnd, double tSamp)
00085 {
00086 if (tSamp == 0.0)
00087 {
00088 tSamp = HeartConfig::Instance()->GetPrintingTimeStep();
00089 }
00090 if (mMaxDt == DOUBLE_UNSET)
00091 {
00092 SetTimestep(tSamp);
00093 }
00094 return Solve(tStart, tEnd, mMaxDt, tSamp);
00095 }
00096
00097
00098 void AbstractCvodeCell::ComputeExceptVoltage(double tStart, double tEnd)
00099 {
00100 EXCEPTION("This method is not yet implemented for CVODE cells.");
00101 }
00102
00103
00104 void AbstractCvodeCell::SetVoltageDerivativeToZero(bool clamp)
00105 {
00106 if (clamp != mSetVoltageDerivativeToZero)
00107 {
00108 ResetSolver();
00109 mSetVoltageDerivativeToZero = clamp;
00110 }
00111 }
00112
00113
00114 #endif // CHASTE_CVODE