BackwardEulerTenTusscher2006.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 #include "BackwardEulerTenTusscher2006.hpp"
00014 #include <cmath>
00015 #include <cassert>
00016 #include "CardiacNewtonSolver.hpp"
00017 #include "Exception.hpp"
00018 #include "OdeSystemInformation.hpp"
00019 
00020 class BackwardEulerTenTusscher2006_LookupTables
00021 {
00022 public:
00023     static BackwardEulerTenTusscher2006_LookupTables* Instance()
00024     {
00025         if (mpInstance == NULL)
00026         {
00027             mpInstance = new BackwardEulerTenTusscher2006_LookupTables;
00028         }
00029         return mpInstance;
00030     }
00031     
00032     // Row lookup methods
00033     // using linear interpolation
00034     double* _lookup_0_row(unsigned i, double factor)
00035     {
00036         for (unsigned j=0; j<29; j++)
00037         {
00038             double y1 = _lookup_table_0[i][j];
00039             double y2 = _lookup_table_0[i+1][j];
00040             _lookup_table_0_row[j] = y1 + (y2-y1)*factor;
00041         }
00042         return _lookup_table_0_row;
00043     }
00044     
00045     
00046 protected:
00047     BackwardEulerTenTusscher2006_LookupTables(const BackwardEulerTenTusscher2006_LookupTables&);
00048     BackwardEulerTenTusscher2006_LookupTables& operator= (const BackwardEulerTenTusscher2006_LookupTables&);
00049     BackwardEulerTenTusscher2006_LookupTables()
00050     {
00051         assert(mpInstance == NULL);
00052         for (int i=0 ; i<60001; i++)
00053         {
00054             double var_membrane__V = -250.0001 + i*0.01;
00055             _lookup_table_0[i][0] = 1.0 / (1.0 + exp(( -26.0 - var_membrane__V) * 0.142857142857));
00056         }
00057         
00058         for (int i=0 ; i<60001; i++)
00059         {
00060             double var_membrane__V = -250.0001 + i*0.01;
00061             _lookup_table_0[i][1] = (450.0 / (1.0 + exp(( -45.0 - var_membrane__V) * 0.1))) * (6.0 / (1.0 + exp((var_membrane__V + 30.0) * 0.0869565217391)));
00062         }
00063         
00064         for (int i=0 ; i<60001; i++)
00065         {
00066             double var_membrane__V = -250.0001 + i*0.01;
00067             _lookup_table_0[i][2] = 1.0 / (1.0 + exp((var_membrane__V + 88.0) * 0.0416666666667));
00068         }
00069         
00070         for (int i=0 ; i<60001; i++)
00071         {
00072             double var_membrane__V = -250.0001 + i*0.01;
00073             _lookup_table_0[i][3] = (3.0 / (1.0 + exp(( -60.0 - var_membrane__V) * 0.05))) * (1.12 / (1.0 + exp((var_membrane__V - 60.0) * 0.05)));
00074         }
00075         
00076         for (int i=0 ; i<60001; i++)
00077         {
00078             double var_membrane__V = -250.0001 + i*0.01;
00079             _lookup_table_0[i][4] = 1.0 / (1.0 + exp(( -5.0 - var_membrane__V) * 0.0714285714286));
00080         }
00081         
00082         for (int i=0 ; i<60001; i++)
00083         {
00084             double var_membrane__V = -250.0001 + i*0.01;
00085             _lookup_table_0[i][5] = ((1400.0 / sqrt(1.0 + exp((5.0 - var_membrane__V) * 0.166666666667))) * (1.0 / (1.0 + exp((var_membrane__V - 35.0) * 0.0666666666667)))) + 80.0;
00086         }
00087         
00088         for (int i=0 ; i<60001; i++)
00089         {
00090             double var_membrane__V = -250.0001 + i*0.01;
00091             _lookup_table_0[i][6] = 1.0 / pow(1.0 + exp(( -56.86 - var_membrane__V) * 0.110741971207), 2.0);
00092         }
00093         
00094         for (int i=0 ; i<60001; i++)
00095         {
00096             double var_membrane__V = -250.0001 + i*0.01;
00097             _lookup_table_0[i][7] = (1.0 / (1.0 + exp(( -60.0 - var_membrane__V) * 0.2))) * ((0.1 / (1.0 + exp((var_membrane__V + 35.0) * 0.2))) + (0.1 / (1.0 + exp((var_membrane__V - 50.0) * 0.005))));
00098         }
00099         
00100         for (int i=0 ; i<60001; i++)
00101         {
00102             double var_membrane__V = -250.0001 + i*0.01;
00103             _lookup_table_0[i][8] = 1.0 / pow(1.0 + exp((var_membrane__V + 71.55) * 0.134589502019), 2.0);
00104         }
00105         
00106         for (int i=0 ; i<60001; i++)
00107         {
00108             double var_membrane__V = -250.0001 + i*0.01;
00109             _lookup_table_0[i][9] = 1.0 / (((var_membrane__V <  -40.0) ? (0.057 * exp((-(var_membrane__V + 80.0)) * 0.147058823529)) : 0.0) + ((var_membrane__V <  -40.0) ? ((2.7 * exp(0.079 * var_membrane__V)) + (310000.0 * exp(0.3485 * var_membrane__V))) : (0.77 / (0.13 * (1.0 + exp((var_membrane__V + 10.66) *  -0.0900900900901))))));
00110         }
00111         
00112         for (int i=0 ; i<60001; i++)
00113         {
00114             double var_membrane__V = -250.0001 + i*0.01;
00115             _lookup_table_0[i][10] = 1.0 / pow(1.0 + exp((var_membrane__V + 71.55) * 0.134589502019), 2.0);
00116         }
00117         
00118         for (int i=0 ; i<60001; i++)
00119         {
00120             double var_membrane__V = -250.0001 + i*0.01;
00121             _lookup_table_0[i][11] = 1.0 / (((var_membrane__V <  -40.0) ? (((( -25428.0 * exp(0.2444 * var_membrane__V)) - (6.948e-06 * exp( -0.04391 * var_membrane__V))) * (var_membrane__V + 37.78)) / (1.0 + exp(0.311 * (var_membrane__V + 79.23)))) : 0.0) + ((var_membrane__V <  -40.0) ? ((0.02424 * exp( -0.01052 * var_membrane__V)) / (1.0 + exp( -0.1378 * (var_membrane__V + 40.14)))) : ((0.6 * exp(0.057 * var_membrane__V)) / (1.0 + exp( -0.1 * (var_membrane__V + 32.0))))));
00122         }
00123         
00124         for (int i=0 ; i<60001; i++)
00125         {
00126             double var_membrane__V = -250.0001 + i*0.01;
00127             _lookup_table_0[i][12] = exp((2.0 * (var_membrane__V - 15.0) * 96485.3415) * 3.87974901066e-07);
00128         }
00129         
00130         for (int i=0 ; i<60001; i++)
00131         {
00132             double var_membrane__V = -250.0001 + i*0.01;
00133             _lookup_table_0[i][13] = exp((2.0 * (var_membrane__V - 15.0) * 96485.3415) * 3.87974901066e-07) - 1.0;
00134         }
00135         
00136         for (int i=0 ; i<60001; i++)
00137         {
00138             double var_membrane__V = -250.0001 + i*0.01;
00139             _lookup_table_0[i][14] = 1.0 / (1.0 + exp(( -8.0 - var_membrane__V) * 0.133333333333));
00140         }
00141         
00142         for (int i=0 ; i<60001; i++)
00143         {
00144             double var_membrane__V = -250.0001 + i*0.01;
00145             _lookup_table_0[i][15] = (((1.4 / (1.0 + exp(( -35.0 - var_membrane__V) * 0.0769230769231))) + 0.25) * (1.4 / (1.0 + exp((var_membrane__V + 5.0) * 0.2)))) + (1.0 / (1.0 + exp((50.0 - var_membrane__V) * 0.05)));
00146         }
00147         
00148         for (int i=0 ; i<60001; i++)
00149         {
00150             double var_membrane__V = -250.0001 + i*0.01;
00151             _lookup_table_0[i][16] = 1.0 / (1.0 + exp((var_membrane__V + 20.0) * 0.142857142857));
00152         }
00153         
00154         for (int i=0 ; i<60001; i++)
00155         {
00156             double var_membrane__V = -250.0001 + i*0.01;
00157             _lookup_table_0[i][17] = (1102.5 * exp((-pow(var_membrane__V + 27.0, 2.0)) * 0.00444444444444)) + (200.0 / (1.0 + exp((13.0 - var_membrane__V) * 0.1))) + (180.0 / (1.0 + exp((var_membrane__V + 30.0) * 0.1))) + 20.0;
00158         }
00159         
00160         for (int i=0 ; i<60001; i++)
00161         {
00162             double var_membrane__V = -250.0001 + i*0.01;
00163             _lookup_table_0[i][18] = (0.67 / (1.0 + exp((var_membrane__V + 35.0) * 0.142857142857))) + 0.33;
00164         }
00165         
00166         for (int i=0 ; i<60001; i++)
00167         {
00168             double var_membrane__V = -250.0001 + i*0.01;
00169             _lookup_table_0[i][19] = (562.0 * exp((-pow(var_membrane__V + 27.0, 2.0)) * 0.00416666666667)) + (31.0 / (1.0 + exp((25.0 - var_membrane__V) * 0.1))) + (80.0 / (1.0 + exp((var_membrane__V + 30.0) * 0.1)));
00170         }
00171         
00172         for (int i=0 ; i<60001; i++)
00173         {
00174             double var_membrane__V = -250.0001 + i*0.01;
00175             _lookup_table_0[i][20] = 1.0 / (1.0 + exp((var_membrane__V + 20.0) * 0.2));
00176         }
00177         
00178         for (int i=0 ; i<60001; i++)
00179         {
00180             double var_membrane__V = -250.0001 + i*0.01;
00181             _lookup_table_0[i][21] = (85.0 * exp((-pow(var_membrane__V + 45.0, 2.0)) * 0.003125)) + (5.0 / (1.0 + exp((var_membrane__V - 20.0) * 0.2))) + 3.0;
00182         }
00183         
00184         for (int i=0 ; i<60001; i++)
00185         {
00186             double var_membrane__V = -250.0001 + i*0.01;
00187             _lookup_table_0[i][22] = 1.0 / (1.0 + exp((20.0 - var_membrane__V) * 0.166666666667));
00188         }
00189         
00190         for (int i=0 ; i<60001; i++)
00191         {
00192             double var_membrane__V = -250.0001 + i*0.01;
00193             _lookup_table_0[i][23] = (9.5 * exp((-pow(var_membrane__V + 40.0, 2.0)) * 0.000555555555556)) + 0.8;
00194         }
00195         
00196         for (int i=0 ; i<60001; i++)
00197         {
00198             double var_membrane__V = -250.0001 + i*0.01;
00199             _lookup_table_0[i][24] = 1.0 + (0.1245 * exp(( -0.1 * var_membrane__V * 96485.3415) * 3.87974901066e-07)) + (0.0353 * exp(((-var_membrane__V) * 96485.3415) * 3.87974901066e-07));
00200         }
00201         
00202         for (int i=0 ; i<60001; i++)
00203         {
00204             double var_membrane__V = -250.0001 + i*0.01;
00205             _lookup_table_0[i][25] = exp((0.35 * var_membrane__V * 96485.3415) * 3.87974901066e-07);
00206         }
00207         
00208         for (int i=0 ; i<60001; i++)
00209         {
00210             double var_membrane__V = -250.0001 + i*0.01;
00211             _lookup_table_0[i][26] = exp(( -0.65 * var_membrane__V * 96485.3415) * 3.87974901066e-07);
00212         }
00213         
00214         for (int i=0 ; i<60001; i++)
00215         {
00216             double var_membrane__V = -250.0001 + i*0.01;
00217             _lookup_table_0[i][27] = 3413921.875 * 3.38 * (1.0 + (0.1 * exp(( -0.65 * var_membrane__V * 96485.3415) * 3.87974901066e-07)));
00218         }
00219         
00220         for (int i=0 ; i<60001; i++)
00221         {
00222             double var_membrane__V = -250.0001 + i*0.01;
00223             _lookup_table_0[i][28] = 1.0 + exp((25.0 - var_membrane__V) * 0.167224080268);
00224         }
00225         
00226     }
00227     
00228 private:
00230     static BackwardEulerTenTusscher2006_LookupTables *mpInstance;
00231 
00232     // Row lookup methods memory
00233     double _lookup_table_0_row[29];
00234     
00235     // Lookup tables
00236     double _lookup_table_0[60001][29];
00237     
00238 };
00239 
00240 BackwardEulerTenTusscher2006_LookupTables* BackwardEulerTenTusscher2006_LookupTables::mpInstance = NULL;
00241 
00242     double BackwardEulerTenTusscher2006::Get_membrane__i_Stim()
00243     {
00244         return var_membrane__i_Stim;
00245     }
00246     
00247     double BackwardEulerTenTusscher2006::Get_membrane__i_K1()
00248     {
00249         return var_membrane__i_K1;
00250     }
00251     
00252     double BackwardEulerTenTusscher2006::Get_membrane__i_to()
00253     {
00254         return var_membrane__i_to;
00255     }
00256     
00257     double BackwardEulerTenTusscher2006::Get_membrane__i_Kr()
00258     {
00259         return var_membrane__i_Kr;
00260     }
00261     
00262     double BackwardEulerTenTusscher2006::Get_membrane__i_Ks()
00263     {
00264         return var_membrane__i_Ks;
00265     }
00266     
00267     double BackwardEulerTenTusscher2006::Get_membrane__i_CaL()
00268     {
00269         return var_membrane__i_CaL;
00270     }
00271     
00272     double BackwardEulerTenTusscher2006::Get_membrane__i_NaK()
00273     {
00274         return var_membrane__i_NaK;
00275     }
00276     
00277     double BackwardEulerTenTusscher2006::Get_membrane__i_Na()
00278     {
00279         return var_membrane__i_Na;
00280     }
00281     
00282     double BackwardEulerTenTusscher2006::Get_membrane__i_b_Na()
00283     {
00284         return var_membrane__i_b_Na;
00285     }
00286     
00287     double BackwardEulerTenTusscher2006::Get_membrane__i_NaCa()
00288     {
00289         return var_membrane__i_NaCa;
00290     }
00291     
00292     double BackwardEulerTenTusscher2006::Get_membrane__i_b_Ca()
00293     {
00294         return var_membrane__i_b_Ca;
00295     }
00296     
00297     double BackwardEulerTenTusscher2006::Get_membrane__i_p_K()
00298     {
00299         return var_membrane__i_p_K;
00300     }
00301     
00302     double BackwardEulerTenTusscher2006::Get_membrane__i_p_Ca()
00303     {
00304         return var_membrane__i_p_Ca;
00305     }
00306     
00307     BackwardEulerTenTusscher2006::BackwardEulerTenTusscher2006(boost::shared_ptr<AbstractIvpOdeSolver> /* unused; should be empty */, boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus)
00308         : AbstractBackwardEulerCardiacCell<7>(
00309                 19,
00310                 0,
00311                 pIntracellularStimulus)
00312     {
00313         // Time units: millisecond
00314         // 
00315         mpSystemInfo = OdeSystemInformation<BackwardEulerTenTusscher2006>::Instance();
00316         Init();
00317 
00318     }
00319     
00320     BackwardEulerTenTusscher2006::~BackwardEulerTenTusscher2006()
00321     {
00322     }
00323     
00324     void BackwardEulerTenTusscher2006::VerifyStateVariables()
00325     {}
00326 
00327     double BackwardEulerTenTusscher2006::GetIIonic()
00328     {
00329         std::vector<double>& rY = rGetStateVariables();
00330         double var_membrane__V = rY[0];
00331         // Units: millivolt; Initial value: -85.23
00332         double var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1 = rY[1];
00333         // Units: dimensionless; Initial value: 0.00621
00334         double var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2 = rY[2];
00335         // Units: dimensionless; Initial value: 0.4712
00336         double var_slow_time_dependent_potassium_current_Xs_gate__Xs = rY[3];
00337         // Units: dimensionless; Initial value: 0.0095
00338         double var_fast_sodium_current_m_gate__m = rY[4];
00339         // Units: dimensionless; Initial value: 0.00172
00340         double var_fast_sodium_current_h_gate__h = rY[5];
00341         // Units: dimensionless; Initial value: 0.7444
00342         double var_fast_sodium_current_j_gate__j = rY[6];
00343         // Units: dimensionless; Initial value: 0.7045
00344         double var_L_type_Ca_current_d_gate__d = rY[7];
00345         // Units: dimensionless; Initial value: 3.373e-5
00346         double var_L_type_Ca_current_f_gate__f = rY[8];
00347         // Units: dimensionless; Initial value: 0.7888
00348         double var_L_type_Ca_current_f2_gate__f2 = rY[9];
00349         // Units: dimensionless; Initial value: 0.9755
00350         double var_L_type_Ca_current_fCass_gate__fCass = rY[10];
00351         // Units: dimensionless; Initial value: 0.9953
00352         double var_transient_outward_current_s_gate__s = rY[11];
00353         // Units: dimensionless; Initial value: 0.999998
00354         double var_transient_outward_current_r_gate__r = rY[12];
00355         // Units: dimensionless; Initial value: 2.42e-8
00356         double var_calcium_dynamics__Ca_i = rY[13];
00357         // Units: millimolar; Initial value: 0.000126
00358         double var_calcium_dynamics__Ca_ss = rY[15];
00359         // Units: millimolar; Initial value: 0.00036
00360         double var_sodium_dynamics__Na_i = rY[17];
00361         // Units: millimolar; Initial value: 8.604
00362         double var_potassium_dynamics__K_i = rY[18];
00363         // Units: millimolar; Initial value: 136.89
00364         
00365         // Lookup table indexing
00366         if (var_membrane__V>349.9999 || var_membrane__V<-250.0001)
00367         {
00368 #define COVERAGE_IGNORE
00369             EXCEPTION(DumpState("V outside lookup table range", rY));
00370 #undef COVERAGE_IGNORE
00371         }
00372         
00373         double _offset_0 = var_membrane__V - -250.0001;
00374         double _offset_0_over_table_step = _offset_0 * 100.0;
00375         _table_index_0 = (unsigned)(_offset_0_over_table_step);
00376         _factor_0 = _offset_0_over_table_step - _table_index_0;
00377         _lt_0_row = BackwardEulerTenTusscher2006_LookupTables::Instance()->_lookup_0_row(_table_index_0, _factor_0);
00378         
00379         const double var_reversal_potentials__E_K = 26.7137606597 * log(5.4 / var_potassium_dynamics__K_i);
00380         const double var_inward_rectifier_potassium_current__alpha_K1 = 0.1 / (1.0 + exp(0.06 * ((var_membrane__V - var_reversal_potentials__E_K) - 200.0)));
00381         const double var_inward_rectifier_potassium_current__i_K1 = 5.405 * (var_inward_rectifier_potassium_current__alpha_K1 / (var_inward_rectifier_potassium_current__alpha_K1 + (((3.0 * exp(0.0002 * ((var_membrane__V - var_reversal_potentials__E_K) + 100.0))) + exp(0.1 * ((var_membrane__V - var_reversal_potentials__E_K) - 10.0))) / (1.0 + exp( -0.5 * (var_membrane__V - var_reversal_potentials__E_K)))))) * (var_membrane__V - var_reversal_potentials__E_K);
00382         var_membrane__i_K1 = var_inward_rectifier_potassium_current__i_K1;
00383         const double var_transient_outward_current__i_to = 0.294 * var_transient_outward_current_r_gate__r * var_transient_outward_current_s_gate__s * (var_membrane__V - var_reversal_potentials__E_K);
00384         var_membrane__i_to = var_transient_outward_current__i_to;
00385         const double var_rapid_time_dependent_potassium_current__i_Kr = 0.153 * 1.0 * var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1 * var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2 * (var_membrane__V - var_reversal_potentials__E_K);
00386         var_membrane__i_Kr = var_rapid_time_dependent_potassium_current__i_Kr;
00387         const double var_slow_time_dependent_potassium_current__i_Ks = 0.392 * pow(var_slow_time_dependent_potassium_current_Xs_gate__Xs, 2.0) * (var_membrane__V - (26.7137606597 * log(9.6 / (var_potassium_dynamics__K_i + (0.03 * var_sodium_dynamics__Na_i)))));
00388         var_membrane__i_Ks = var_slow_time_dependent_potassium_current__i_Ks;
00389         const double var_L_type_Ca_current__i_CaL = (((3.98e-05 * var_L_type_Ca_current_d_gate__d * var_L_type_Ca_current_f_gate__f * var_L_type_Ca_current_f2_gate__f2 * var_L_type_Ca_current_fCass_gate__fCass * 4.0 * (var_membrane__V - 15.0) * 9309421124.37) * 3.87974901066e-07) * ((0.25 * var_calcium_dynamics__Ca_ss * _lt_0_row[12]) - 2.0)) / _lt_0_row[13];
00390         var_membrane__i_CaL = var_L_type_Ca_current__i_CaL;
00391         const double var_sodium_potassium_pump_current__i_NaK = ((2.298375 * var_sodium_dynamics__Na_i) / (var_sodium_dynamics__Na_i + 40.0)) / _lt_0_row[24];
00392         var_membrane__i_NaK = var_sodium_potassium_pump_current__i_NaK;
00393         const double var_reversal_potentials__E_Na = 26.7137606597 * log(140.0 / var_sodium_dynamics__Na_i);
00394         const double var_fast_sodium_current__i_Na = 14.838 * pow(var_fast_sodium_current_m_gate__m, 3.0) * var_fast_sodium_current_h_gate__h * var_fast_sodium_current_j_gate__j * (var_membrane__V - var_reversal_potentials__E_Na);
00395         var_membrane__i_Na = var_fast_sodium_current__i_Na;
00396         const double var_sodium_background_current__i_b_Na = 0.00029 * (var_membrane__V - var_reversal_potentials__E_Na);
00397         var_membrane__i_b_Na = var_sodium_background_current__i_b_Na;
00398         const double var_sodium_calcium_exchanger_current__i_NaCa = (1000.0 * ((_lt_0_row[25] * pow(var_sodium_dynamics__Na_i, 3.0) * 2.0) - (_lt_0_row[26] * 2744000.0 * var_calcium_dynamics__Ca_i * 2.5))) / _lt_0_row[27];
00399         var_membrane__i_NaCa = var_sodium_calcium_exchanger_current__i_NaCa;
00400         const double var_calcium_background_current__i_b_Ca = 0.000592 * (var_membrane__V - (13.3568803298 * log(2.0 / var_calcium_dynamics__Ca_i)));
00401         var_membrane__i_b_Ca = var_calcium_background_current__i_b_Ca;
00402         const double var_potassium_pump_current__i_p_K = (0.0146 * (var_membrane__V - var_reversal_potentials__E_K)) / _lt_0_row[28];
00403         var_membrane__i_p_K = var_potassium_pump_current__i_p_K;
00404         const double var_calcium_pump_current__i_p_Ca = (0.1238 * var_calcium_dynamics__Ca_i) / (var_calcium_dynamics__Ca_i + 0.0005);
00405         var_membrane__i_p_Ca = var_calcium_pump_current__i_p_Ca;
00406         
00407         double i_ionic =  (var_membrane__i_K1+var_membrane__i_to+var_membrane__i_Kr+var_membrane__i_Ks+var_membrane__i_CaL+var_membrane__i_NaK+var_membrane__i_Na+var_membrane__i_b_Na+var_membrane__i_NaCa+var_membrane__i_b_Ca+var_membrane__i_p_K+var_membrane__i_p_Ca);
00408         
00409         double i_ionic_in_microA_per_cm2=i_ionic*1.0;
00410         return i_ionic_in_microA_per_cm2;
00411     
00412         /*   i_ionic for this model is in pA/pF.
00413          *    Please note that in the mono/bidomain formulation, i_ionic needs to be in microA/cm2.
00414          *    We then need to divide by the cell capacitance.
00415          *    The cell capacitance of the tenTusscher model is
00416          *    2.0 uF/cm2 in the paper
00417          *    0.185 uF/cm2 in this code (membrane_C)
00418          *    1.0 uF/cm2 in the EvaluateRhsDerivatives method above
00419          *
00420          *    For consistency, we choose the last option.
00421          *    i_ion*pow(10,-6) will be in microA/pF.
00422          *    Cm*pow(10,6) will be in pF/cm2.
00423          *    i_ion*pow(10,-6)*Cm*pow(10,6) = i_ion*Cm is in microA/cm2, the correct units
00424          */
00425     }
00426     
00427     void BackwardEulerTenTusscher2006::ComputeResidual(double var_environment__time, const double rCurrentGuess[7], double rResidual[7])
00428     {
00429         std::vector<double>& rY = rGetStateVariables();
00430         double var_membrane__V = rY[0];
00431         // Units: millivolt; Initial value: -85.23
00432         double var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1 = rY[1];
00433         // Units: dimensionless; Initial value: 0.00621
00434         double var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2 = rY[2];
00435         // Units: dimensionless; Initial value: 0.4712
00436         double var_slow_time_dependent_potassium_current_Xs_gate__Xs = rY[3];
00437         // Units: dimensionless; Initial value: 0.0095
00438         double var_fast_sodium_current_m_gate__m = rY[4];
00439         // Units: dimensionless; Initial value: 0.00172
00440         double var_fast_sodium_current_h_gate__h = rY[5];
00441         // Units: dimensionless; Initial value: 0.7444
00442         double var_fast_sodium_current_j_gate__j = rY[6];
00443         // Units: dimensionless; Initial value: 0.7045
00444         double var_L_type_Ca_current_d_gate__d = rY[7];
00445         // Units: dimensionless; Initial value: 3.373e-5
00446         double var_L_type_Ca_current_f_gate__f = rY[8];
00447         // Units: dimensionless; Initial value: 0.7888
00448         double var_L_type_Ca_current_f2_gate__f2 = rY[9];
00449         // Units: dimensionless; Initial value: 0.9755
00450         double var_transient_outward_current_s_gate__s = rY[11];
00451         // Units: dimensionless; Initial value: 0.999998
00452         double var_transient_outward_current_r_gate__r = rY[12];
00453         // Units: dimensionless; Initial value: 2.42e-8
00454         
00455         double var_L_type_Ca_current_fCass_gate__fCass = rCurrentGuess[0];
00456         double var_calcium_dynamics__Ca_SR = rCurrentGuess[1];
00457         double var_calcium_dynamics__Ca_i = rCurrentGuess[2];
00458         double var_calcium_dynamics__Ca_ss = rCurrentGuess[3];
00459         double var_calcium_dynamics__R_prime = rCurrentGuess[4];
00460         double var_potassium_dynamics__K_i = rCurrentGuess[5];
00461         double var_sodium_dynamics__Na_i = rCurrentGuess[6];
00462         
00463         const double var_reversal_potentials__E_K = 26.7137606597 * log(5.4 / var_potassium_dynamics__K_i);
00464         const double var_inward_rectifier_potassium_current__alpha_K1 = 0.1 / (1.0 + exp(0.06 * ((var_membrane__V - var_reversal_potentials__E_K) - 200.0)));
00465         const double var_inward_rectifier_potassium_current__i_K1 = 5.405 * (var_inward_rectifier_potassium_current__alpha_K1 / (var_inward_rectifier_potassium_current__alpha_K1 + (((3.0 * exp(0.0002 * ((var_membrane__V - var_reversal_potentials__E_K) + 100.0))) + exp(0.1 * ((var_membrane__V - var_reversal_potentials__E_K) - 10.0))) / (1.0 + exp( -0.5 * (var_membrane__V - var_reversal_potentials__E_K)))))) * (var_membrane__V - var_reversal_potentials__E_K);
00466         const double var_transient_outward_current__i_to = 0.294 * var_transient_outward_current_r_gate__r * var_transient_outward_current_s_gate__s * (var_membrane__V - var_reversal_potentials__E_K);
00467         const double var_rapid_time_dependent_potassium_current__i_Kr = 0.153 * 1.0 * var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1 * var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2 * (var_membrane__V - var_reversal_potentials__E_K);
00468         const double var_slow_time_dependent_potassium_current__i_Ks = 0.392 * pow(var_slow_time_dependent_potassium_current_Xs_gate__Xs, 2.0) * (var_membrane__V - (26.7137606597 * log(9.6 / (var_potassium_dynamics__K_i + (0.03 * var_sodium_dynamics__Na_i)))));
00469         const double var_L_type_Ca_current__i_CaL = (((3.98e-05 * var_L_type_Ca_current_d_gate__d * var_L_type_Ca_current_f_gate__f * var_L_type_Ca_current_f2_gate__f2 * var_L_type_Ca_current_fCass_gate__fCass * 4.0 * (var_membrane__V - 15.0) * 9309421124.37) * 3.87974901066e-07) * ((0.25 * var_calcium_dynamics__Ca_ss * _lt_0_row[12]) - 2.0)) / _lt_0_row[13];
00470         const double var_sodium_potassium_pump_current__i_NaK = ((2.298375 * var_sodium_dynamics__Na_i) / (var_sodium_dynamics__Na_i + 40.0)) / _lt_0_row[24];
00471         const double var_reversal_potentials__E_Na = 26.7137606597 * log(140.0 / var_sodium_dynamics__Na_i);
00472         const double var_fast_sodium_current__i_Na = 14.838 * pow(var_fast_sodium_current_m_gate__m, 3.0) * var_fast_sodium_current_h_gate__h * var_fast_sodium_current_j_gate__j * (var_membrane__V - var_reversal_potentials__E_Na);
00473         const double var_sodium_background_current__i_b_Na = 0.00029 * (var_membrane__V - var_reversal_potentials__E_Na);
00474         const double var_sodium_calcium_exchanger_current__i_NaCa = (1000.0 * ((_lt_0_row[25] * pow(var_sodium_dynamics__Na_i, 3.0) * 2.0) - (_lt_0_row[26] * 2744000.0 * var_calcium_dynamics__Ca_i * 2.5))) / _lt_0_row[27];
00475         const double var_calcium_background_current__i_b_Ca = 0.000592 * (var_membrane__V - (13.3568803298 * log(2.0 / var_calcium_dynamics__Ca_i)));
00476         const double var_potassium_pump_current__i_p_K = (0.0146 * (var_membrane__V - var_reversal_potentials__E_K)) / _lt_0_row[28];
00477         const double var_calcium_pump_current__i_p_Ca = (0.1238 * var_calcium_dynamics__Ca_i) / (var_calcium_dynamics__Ca_i + 0.0005);
00478         var_membrane__i_Stim = GetStimulus((1.0/1)*var_environment__time);
00479         const double var_calcium_dynamics__kcasr = 2.5 - (1.5 / (1.0 + pow(1.5 / var_calcium_dynamics__Ca_SR, 2.0)));
00480         const double var_calcium_dynamics__k1 = 0.15 / var_calcium_dynamics__kcasr;
00481         const double var_calcium_dynamics__i_rel = 0.102 * ((var_calcium_dynamics__k1 * pow(var_calcium_dynamics__Ca_ss, 2.0) * var_calcium_dynamics__R_prime) / (0.06 + (var_calcium_dynamics__k1 * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss);
00482         const double var_calcium_dynamics__i_up = 0.006375 / (1.0 + (6.25e-08 / pow(var_calcium_dynamics__Ca_i, 2.0)));
00483         const double var_calcium_dynamics__i_leak = 0.00036 * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_i);
00484         const double var_calcium_dynamics__i_xfer = 0.0038 * (var_calcium_dynamics__Ca_ss - var_calcium_dynamics__Ca_i);
00485         const double d_dt_L_type_Ca_current_fCass_gate__fCass = (((0.6 / (1.0 + pow(var_calcium_dynamics__Ca_ss * 20.0, 2.0))) + 0.4) - var_L_type_Ca_current_fCass_gate__fCass) / ((80.0 / (1.0 + pow(var_calcium_dynamics__Ca_ss * 20.0, 2.0))) + 2.0);
00486         const double d_dt_calcium_dynamics__R_prime = ((-(0.045 * var_calcium_dynamics__kcasr)) * var_calcium_dynamics__Ca_ss * var_calcium_dynamics__R_prime) + (0.005 * (1.0 - var_calcium_dynamics__R_prime));
00487         const double d_dt_calcium_dynamics__Ca_i = (1.0 / (1.0 + (0.0002 / pow(var_calcium_dynamics__Ca_i + 0.001, 2.0)))) * (((((var_calcium_dynamics__i_leak - var_calcium_dynamics__i_up) * 0.001094) * 60.9607412826) + var_calcium_dynamics__i_xfer) - ((((var_calcium_background_current__i_b_Ca + var_calcium_pump_current__i_p_Ca) - (2.0 * var_sodium_calcium_exchanger_current__i_NaCa)) * 0.185) * 0.000315906749849));
00488         const double d_dt_calcium_dynamics__Ca_SR = (1.0 / (1.0 + (3.0 / pow(var_calcium_dynamics__Ca_SR + 0.3, 2.0)))) * (var_calcium_dynamics__i_up - (var_calcium_dynamics__i_rel + var_calcium_dynamics__i_leak));
00489         const double d_dt_calcium_dynamics__Ca_ss = (1.0 / (1.0 + (0.0001 / pow(var_calcium_dynamics__Ca_ss + 0.00025, 2.0)))) * (((((-var_L_type_Ca_current__i_CaL) * 0.185) * 0.0947720249546) + ((var_calcium_dynamics__i_rel * 0.001094) * 18288.2223848)) - ((var_calcium_dynamics__i_xfer * 0.016404) * 18288.2223848));
00490         const double d_dt_sodium_dynamics__Na_i = ((-(var_fast_sodium_current__i_Na + var_sodium_background_current__i_b_Na + (3.0 * var_sodium_potassium_pump_current__i_NaK) + (3.0 * var_sodium_calcium_exchanger_current__i_NaCa))) * 0.000631813499697) * 0.185;
00491         const double d_dt_potassium_dynamics__K_i = ((-((var_inward_rectifier_potassium_current__i_K1 + var_transient_outward_current__i_to + var_rapid_time_dependent_potassium_current__i_Kr + var_slow_time_dependent_potassium_current__i_Ks + var_potassium_pump_current__i_p_K + var_membrane__i_Stim) - (2.0 * var_sodium_potassium_pump_current__i_NaK))) * 0.000631813499697) * 0.185;
00492         
00493         rResidual[0] = rCurrentGuess[0] - rY[10] - mDt*1.0*d_dt_L_type_Ca_current_fCass_gate__fCass;
00494         rResidual[2] = rCurrentGuess[2] - rY[13] - mDt*1.0*d_dt_calcium_dynamics__Ca_i;
00495         rResidual[1] = rCurrentGuess[1] - rY[14] - mDt*1.0*d_dt_calcium_dynamics__Ca_SR;
00496         rResidual[3] = rCurrentGuess[3] - rY[15] - mDt*1.0*d_dt_calcium_dynamics__Ca_ss;
00497         rResidual[4] = rCurrentGuess[4] - rY[16] - mDt*1.0*d_dt_calcium_dynamics__R_prime;
00498         rResidual[6] = rCurrentGuess[6] - rY[17] - mDt*1.0*d_dt_sodium_dynamics__Na_i;
00499         rResidual[5] = rCurrentGuess[5] - rY[18] - mDt*1.0*d_dt_potassium_dynamics__K_i;
00500     }
00501     
00502     void BackwardEulerTenTusscher2006::ComputeJacobian(double var_environment__time, const double rCurrentGuess[7], double rJacobian[7][7])
00503     {
00504         std::vector<double>& rY = rGetStateVariables();
00505         double var_membrane__V = rY[0];
00506         // Units: millivolt; Initial value: -85.23
00507         double var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1 = rY[1];
00508         // Units: dimensionless; Initial value: 0.00621
00509         double var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2 = rY[2];
00510         // Units: dimensionless; Initial value: 0.4712
00511         double var_slow_time_dependent_potassium_current_Xs_gate__Xs = rY[3];
00512         // Units: dimensionless; Initial value: 0.0095
00513         double var_fast_sodium_current_m_gate__m = rY[4];
00514         // Units: dimensionless; Initial value: 0.00172
00515         double var_fast_sodium_current_h_gate__h = rY[5];
00516         // Units: dimensionless; Initial value: 0.7444
00517         double var_fast_sodium_current_j_gate__j = rY[6];
00518         // Units: dimensionless; Initial value: 0.7045
00519         double var_L_type_Ca_current_d_gate__d = rY[7];
00520         // Units: dimensionless; Initial value: 3.373e-5
00521         double var_L_type_Ca_current_f_gate__f = rY[8];
00522         // Units: dimensionless; Initial value: 0.7888
00523         double var_L_type_Ca_current_f2_gate__f2 = rY[9];
00524         // Units: dimensionless; Initial value: 0.9755
00525         double var_transient_outward_current_s_gate__s = rY[11];
00526         // Units: dimensionless; Initial value: 0.999998
00527         double var_transient_outward_current_r_gate__r = rY[12];
00528         // Units: dimensionless; Initial value: 2.42e-8
00529         
00530         double var_L_type_Ca_current_fCass_gate__fCass = rCurrentGuess[0];
00531         double var_calcium_dynamics__Ca_SR = rCurrentGuess[1];
00532         double var_calcium_dynamics__Ca_i = rCurrentGuess[2];
00533         double var_calcium_dynamics__Ca_ss = rCurrentGuess[3];
00534         double var_calcium_dynamics__R_prime = rCurrentGuess[4];
00535         double var_potassium_dynamics__K_i = rCurrentGuess[5];
00536         double var_sodium_dynamics__Na_i = rCurrentGuess[6];
00537         
00538         const double dt = 1.0 * mDt;
00539 
00540         
00541         rJacobian[0][0] = 1.0 + (dt / ((80.0 / (1.0 + (400.0 * pow(var_calcium_dynamics__Ca_ss, 2.0)))) + 2.0));
00542         rJacobian[0][1] = 0.0;
00543         rJacobian[0][2] = 0.0;
00544         rJacobian[0][3] = ((((480.0 * dt) / pow(1.0 + (400.0 * pow(var_calcium_dynamics__Ca_ss, 2.0)), 2.0)) * var_calcium_dynamics__Ca_ss) / ((80.0 / (1.0 + (400.0 * pow(var_calcium_dynamics__Ca_ss, 2.0)))) + 2.0)) - (((((64000.0 * dt) * (((0.6 / (1.0 + (400.0 * pow(var_calcium_dynamics__Ca_ss, 2.0)))) + 0.4) - var_L_type_Ca_current_fCass_gate__fCass)) / pow((80.0 / (1.0 + (400.0 * pow(var_calcium_dynamics__Ca_ss, 2.0)))) + 2.0, 2.0)) / pow(1.0 + (400.0 * pow(var_calcium_dynamics__Ca_ss, 2.0)), 2.0)) * var_calcium_dynamics__Ca_ss);
00545         rJacobian[0][4] = 0.0;
00546         rJacobian[0][5] = 0.0;
00547         rJacobian[0][6] = 0.0;
00548         rJacobian[1][0] = 0.0;
00549         rJacobian[1][1] = (1.0 - ((((6.0 * dt) / pow(1.0 + (3.0 / pow(var_calcium_dynamics__Ca_SR + 0.3, 2.0)), 2.0)) * ((((0.006375 / (1.0 + (6.25e-08 / pow(var_calcium_dynamics__Ca_i, 2.0)))) - (((((0.0153 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss))) - (0.00036 * var_calcium_dynamics__Ca_SR)) + (0.00036 * var_calcium_dynamics__Ca_i))) / pow(var_calcium_dynamics__Ca_SR + 0.3, 3.0))) - ((dt / (1.0 + (3.0 / pow(var_calcium_dynamics__Ca_SR + 0.3, 2.0)))) * (((((((((((-0.103275) / pow(2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))), 2.0)) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss)) / pow(1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)), 2.0)) / pow(var_calcium_dynamics__Ca_SR, 3.0)) + (((((((0.01549125 / pow(2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))), 3.0)) * pow(var_calcium_dynamics__Ca_ss, 4.0)) * var_calcium_dynamics__R_prime) / pow(0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)), 2.0)) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss)) / pow(1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)), 2.0)) / pow(var_calcium_dynamics__Ca_SR, 3.0))) - ((((0.0153 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0))))) - 0.00036));
00550         rJacobian[1][2] = ((-dt) / (1.0 + (3.0 / pow(var_calcium_dynamics__Ca_SR + 0.3, 2.0)))) * (((7.96875e-10 / pow(1.0 + (6.25e-08 / pow(var_calcium_dynamics__Ca_i, 2.0)), 2.0)) / pow(var_calcium_dynamics__Ca_i, 3.0)) + 0.00036);
00551         rJacobian[1][3] = ((-dt) / (1.0 + (3.0 / pow(var_calcium_dynamics__Ca_SR + 0.3, 2.0)))) * ((((((((-0.0306) / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * var_calcium_dynamics__Ca_ss) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss)) + (((((0.00459 / pow(2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))), 2.0)) * pow(var_calcium_dynamics__Ca_ss, 3.0)) * var_calcium_dynamics__R_prime) / pow(0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)), 2.0)) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss))) + ((((0.0153 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))));
00552         rJacobian[1][4] = (((((0.0153 * dt) / (1.0 + (3.0 / pow(var_calcium_dynamics__Ca_SR + 0.3, 2.0)))) / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss);
00553         rJacobian[1][5] = 0.0;
00554         rJacobian[1][6] = 0.0;
00555         rJacobian[2][0] = 0.0;
00556         rJacobian[2][1] = ((-2.400877835e-05) * dt) / (1.0 + (0.0002 / pow(var_calcium_dynamics__Ca_i + 0.001, 2.0)));
00557         rJacobian[2][2] = (1.0 - ((((0.0004 * dt) / pow(1.0 + (0.0002 / pow(var_calcium_dynamics__Ca_i + 0.001, 2.0)), 2.0)) * ((((((((2.400877835e-05 * var_calcium_dynamics__Ca_SR) - (0.003824008778 * var_calcium_dynamics__Ca_i)) - (0.0004251554499 / (1.0 + (6.25e-08 / pow(var_calcium_dynamics__Ca_i, 2.0))))) + (0.0038 * var_calcium_dynamics__Ca_ss)) - (3.459810726e-08 * var_membrane__V)) + (4.621227783e-07 * log(2.0 / var_calcium_dynamics__Ca_i))) - ((7.235212295e-06 * var_calcium_dynamics__Ca_i) / (var_calcium_dynamics__Ca_i + 0.0005))) + ((1.012955463e-08 * (((2.0 * exp(0.01310186179 * var_membrane__V)) * pow(var_sodium_dynamics__Na_i, 3.0)) - ((6860000.0 * exp((-0.02433202904) * var_membrane__V)) * var_calcium_dynamics__Ca_i))) / (1.0 + (0.1 * exp((-0.02433202904) * var_membrane__V)))))) / pow(var_calcium_dynamics__Ca_i + 0.001, 3.0))) - ((dt / (1.0 + (0.0002 / pow(var_calcium_dynamics__Ca_i + 0.001, 2.0)))) * ((((((-0.003824008778) - ((5.314443124e-11 / pow(1.0 + (6.25e-08 / pow(var_calcium_dynamics__Ca_i, 2.0)), 2.0)) / pow(var_calcium_dynamics__Ca_i, 3.0))) - (4.621227783e-07 / var_calcium_dynamics__Ca_i)) - (7.235212295e-06 / (var_calcium_dynamics__Ca_i + 0.0005))) + ((7.235212295e-06 * var_calcium_dynamics__Ca_i) / pow(var_calcium_dynamics__Ca_i + 0.0005, 2.0))) - ((0.06948874476 * exp((-0.02433202904) * var_membrane__V)) / (1.0 + (0.1 * exp((-0.02433202904) * var_membrane__V))))));
00558         rJacobian[2][3] = ((-0.0038) * dt) / (1.0 + (0.0002 / pow(var_calcium_dynamics__Ca_i + 0.001, 2.0)));
00559         rJacobian[2][4] = 0.0;
00560         rJacobian[2][5] = 0.0;
00561         rJacobian[2][6] = (((((-6.077732778e-08) * dt) / (1.0 + (0.0002 / pow(var_calcium_dynamics__Ca_i + 0.001, 2.0)))) * exp(0.01310186179 * var_membrane__V)) * pow(var_sodium_dynamics__Na_i, 2.0)) / (1.0 + (0.1 * exp((-0.02433202904) * var_membrane__V)));
00562         rJacobian[3][0] = (((((((0.01008140958 * dt) / (1.0 + (0.0001 / pow(var_calcium_dynamics__Ca_ss + 0.00025, 2.0)))) * var_L_type_Ca_current_d_gate__d) * var_L_type_Ca_current_f_gate__f) * var_L_type_Ca_current_f2_gate__f2) * (var_membrane__V - 15.0)) * (((0.25 * var_calcium_dynamics__Ca_ss) * exp((0.07486778168 * var_membrane__V) - 1.123016725)) - 2.0)) / (exp((0.07486778168 * var_membrane__V) - 1.123016725) - 1.0);
00563         rJacobian[3][1] = ((-dt) / (1.0 + (0.0001 / pow(var_calcium_dynamics__Ca_ss + 0.00025, 2.0)))) * (((((((((2.066255486 / pow(2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))), 2.0)) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss)) / pow(1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)), 2.0)) / pow(var_calcium_dynamics__Ca_SR, 3.0)) - (((((((0.3099383229 / pow(2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))), 3.0)) * pow(var_calcium_dynamics__Ca_ss, 4.0)) * var_calcium_dynamics__R_prime) / pow(0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)), 2.0)) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss)) / pow(1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)), 2.0)) / pow(var_calcium_dynamics__Ca_SR, 3.0))) + ((((0.3061119239 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))));
00564         rJacobian[3][2] = ((-1.14) * dt) / (1.0 + (0.0001 / pow(var_calcium_dynamics__Ca_ss + 0.00025, 2.0)));
00565         rJacobian[3][3] = (1.0 - ((((0.0002 * dt) / pow(1.0 + (0.0001 / pow(var_calcium_dynamics__Ca_ss + 0.00025, 2.0)), 2.0)) * (((((((((((-0.01008140958) * var_L_type_Ca_current_d_gate__d) * var_L_type_Ca_current_f_gate__f) * var_L_type_Ca_current_f2_gate__f2) * var_L_type_Ca_current_fCass_gate__fCass) * (var_membrane__V - 15.0)) * (((0.25 * var_calcium_dynamics__Ca_ss) * exp((0.07486778168 * var_membrane__V) - 1.123016725)) - 2.0)) / (exp((0.07486778168 * var_membrane__V) - 1.123016725) - 1.0)) + (((((0.3061119239 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss))) - (1.14 * var_calcium_dynamics__Ca_ss)) + (1.14 * var_calcium_dynamics__Ca_i))) / pow(var_calcium_dynamics__Ca_ss + 0.00025, 3.0))) - ((dt / (1.0 + (0.0001 / pow(var_calcium_dynamics__Ca_ss + 0.00025, 2.0)))) * ((((((((((((-0.002520352395) * var_L_type_Ca_current_d_gate__d) * var_L_type_Ca_current_f_gate__f) * var_L_type_Ca_current_f2_gate__f2) * var_L_type_Ca_current_fCass_gate__fCass) * (var_membrane__V - 15.0)) * exp((0.07486778168 * var_membrane__V) - 1.123016725)) / (exp((0.07486778168 * var_membrane__V) - 1.123016725) - 1.0)) + (((((0.6122238478 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * var_calcium_dynamics__Ca_ss) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss))) - (((((0.09183357717 / pow(2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))), 2.0)) * pow(var_calcium_dynamics__Ca_ss, 3.0)) * var_calcium_dynamics__R_prime) / pow(0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)), 2.0)) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss))) - ((((0.3061119239 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) * var_calcium_dynamics__R_prime) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0))))) - 1.14));
00566         rJacobian[3][4] = ((((((-0.3061119239) * dt) / (1.0 + (0.0001 / pow(var_calcium_dynamics__Ca_ss + 0.00025, 2.0)))) / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)) / (0.06 + ((0.15 / (2.5 - (1.5 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * pow(var_calcium_dynamics__Ca_ss, 2.0)))) * (var_calcium_dynamics__Ca_SR - var_calcium_dynamics__Ca_ss);
00567         rJacobian[3][5] = 0.0;
00568         rJacobian[3][6] = 0.0;
00569         rJacobian[4][0] = 0.0;
00570         rJacobian[4][1] = (((((-0.30375) * dt) / pow(1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)), 2.0)) / pow(var_calcium_dynamics__Ca_SR, 3.0)) * var_calcium_dynamics__Ca_ss) * var_calcium_dynamics__R_prime;
00571         rJacobian[4][2] = 0.0;
00572         rJacobian[4][3] = (dt * (0.1125 - (0.0675 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * var_calcium_dynamics__R_prime;
00573         rJacobian[4][4] = 1.0 - (dt * (((-(0.1125 - (0.0675 / (1.0 + (2.25 / pow(var_calcium_dynamics__Ca_SR, 2.0)))))) * var_calcium_dynamics__Ca_ss) - 0.005));
00574         rJacobian[4][5] = 0.0;
00575         rJacobian[4][6] = 0.0;
00576         rJacobian[5][0] = 0.0;
00577         rJacobian[5][1] = 0.0;
00578         rJacobian[5][2] = 0.0;
00579         rJacobian[5][3] = 0.0;
00580         rJacobian[5][4] = 0.0;
00581         rJacobian[5][5] = 1.0 - (dt * (((((((((((0.0001012610925 / pow(1.0 + exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0), 2.0)) / ((0.1 / (1.0 + exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0))) + (((3.0 * exp(((0.0002 * var_membrane__V) - (0.005342752132 * log(5.4 / var_potassium_dynamics__K_i))) + 0.02)) + exp(((0.1 * var_membrane__V) - (2.671376066 * log(5.4 / var_potassium_dynamics__K_i))) - 1.0)) / (1.0 + exp(((-0.5) * var_membrane__V) + (13.35688033 * log(5.4 / var_potassium_dynamics__K_i))))))) * (var_membrane__V - (26.71376066 * log(5.4 / var_potassium_dynamics__K_i)))) / var_potassium_dynamics__K_i) * exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0)) + ((((6.317661134e-05 / (1.0 + exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0))) / pow((0.1 / (1.0 + exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0))) + (((3.0 * exp(((0.0002 * var_membrane__V) - (0.005342752132 * log(5.4 / var_potassium_dynamics__K_i))) + 0.02)) + exp(((0.1 * var_membrane__V) - (2.671376066 * log(5.4 / var_potassium_dynamics__K_i))) - 1.0)) / (1.0 + exp(((-0.5) * var_membrane__V) + (13.35688033 * log(5.4 / var_potassium_dynamics__K_i))))), 2.0)) * (var_membrane__V - (26.71376066 * log(5.4 / var_potassium_dynamics__K_i)))) * ((((((-0.160282564) / pow(1.0 + exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0), 2.0)) / var_potassium_dynamics__K_i) * exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0)) + ((((0.0160282564 / var_potassium_dynamics__K_i) * exp(((0.0002 * var_membrane__V) - (0.005342752132 * log(5.4 / var_potassium_dynamics__K_i))) + 0.02)) + ((2.671376066 / var_potassium_dynamics__K_i) * exp(((0.1 * var_membrane__V) - (2.671376066 * log(5.4 / var_potassium_dynamics__K_i))) - 1.0))) / (1.0 + exp(((-0.5) * var_membrane__V) + (13.35688033 * log(5.4 / var_potassium_dynamics__K_i)))))) + ((((13.35688033 * ((3.0 * exp(((0.0002 * var_membrane__V) - (0.005342752132 * log(5.4 / var_potassium_dynamics__K_i))) + 0.02)) + exp(((0.1 * var_membrane__V) - (2.671376066 * log(5.4 / var_potassium_dynamics__K_i))) - 1.0))) / pow(1.0 + exp(((-0.5) * var_membrane__V) + (13.35688033 * log(5.4 / var_potassium_dynamics__K_i))), 2.0)) / var_potassium_dynamics__K_i) * exp(((-0.5) * var_membrane__V) + (13.35688033 * log(5.4 / var_potassium_dynamics__K_i))))))) - (((0.001687684875 / (1.0 + exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0))) / ((0.1 / (1.0 + exp(((0.06 * var_membrane__V) - (1.60282564 * log(5.4 / var_potassium_dynamics__K_i))) - 12.0))) + (((3.0 * exp(((0.0002 * var_membrane__V) - (0.005342752132 * log(5.4 / var_potassium_dynamics__K_i))) + 0.02)) + exp(((0.1 * var_membrane__V) - (2.671376066 * log(5.4 / var_potassium_dynamics__K_i))) - 1.0)) / (1.0 + exp(((-0.5) * var_membrane__V) + (13.35688033 * log(5.4 / var_potassium_dynamics__K_i))))))) / var_potassium_dynamics__K_i)) - (((0.0009180006536 * var_transient_outward_current_r_gate__r) * var_transient_outward_current_s_gate__s) / var_potassium_dynamics__K_i)) - (((0.0004777350339 * var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1) * var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2) / var_potassium_dynamics__K_i)) - ((0.001224000871 * pow(var_slow_time_dependent_potassium_current_Xs_gate__Xs, 2.0)) / (var_potassium_dynamics__K_i + (0.03 * var_sodium_dynamics__Na_i)))) - ((4.558778755e-05 / var_potassium_dynamics__K_i) / (1.0 + exp(4.180602008 - (0.1672240803 * var_membrane__V))))));
00582         rJacobian[5][6] = (-dt) * (((((-3.672002614e-05) * pow(var_slow_time_dependent_potassium_current_Xs_gate__Xs, 2.0)) / (var_potassium_dynamics__K_i + (0.03 * var_sodium_dynamics__Na_i))) + ((0.0005372934102 / (var_sodium_dynamics__Na_i + 40.0)) / ((1.0 + (0.1245 * exp((-0.003743389084) * var_membrane__V))) + (0.0353 * exp((-0.03743389084) * var_membrane__V))))) - (((0.0005372934102 * var_sodium_dynamics__Na_i) / pow(var_sodium_dynamics__Na_i + 40.0, 2.0)) / ((1.0 + (0.1245 * exp((-0.003743389084) * var_membrane__V))) + (0.0353 * exp((-0.03743389084) * var_membrane__V)))));
00583         rJacobian[6][0] = 0.0;
00584         rJacobian[6][1] = 0.0;
00585         rJacobian[6][2] = (((-0.2084662341) * dt) * exp((-0.02433202904) * var_membrane__V)) / (1.0 + (0.1 * exp((-0.02433202904) * var_membrane__V)));
00586         rJacobian[6][3] = 0.0;
00587         rJacobian[6][4] = 0.0;
00588         rJacobian[6][5] = 0.0;
00589         rJacobian[6][6] = 1.0 - (dt * (((((((((-0.04633093093) * pow(var_fast_sodium_current_m_gate__m, 3.0)) * var_fast_sodium_current_h_gate__h) * var_fast_sodium_current_j_gate__j) / var_sodium_dynamics__Na_i) - (9.055108486e-07 / var_sodium_dynamics__Na_i)) - ((0.0008059401153 / (var_sodium_dynamics__Na_i + 40.0)) / ((1.0 + (0.1245 * exp((-0.003743389084) * var_membrane__V))) + (0.0353 * exp((-0.03743389084) * var_membrane__V))))) + (((0.0008059401153 * var_sodium_dynamics__Na_i) / pow(var_sodium_dynamics__Na_i + 40.0, 2.0)) / ((1.0 + (0.1245 * exp((-0.003743389084) * var_membrane__V))) + (0.0353 * exp((-0.03743389084) * var_membrane__V))))) - (((1.823319832e-07 * exp(0.01310186179 * var_membrane__V)) * pow(var_sodium_dynamics__Na_i, 2.0)) / (1.0 + (0.1 * exp((-0.02433202904) * var_membrane__V))))));
00590     }
00591     
00592     void BackwardEulerTenTusscher2006::UpdateTransmembranePotential(double var_environment__time)
00593     {
00594         // Time units: millisecond
00595         var_environment__time *= 1.0;
00596         std::vector<double>& rY = rGetStateVariables();
00597         double var_membrane__V = rY[0];
00598         // Units: millivolt; Initial value: -85.23
00599         double var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1 = rY[1];
00600         // Units: dimensionless; Initial value: 0.00621
00601         double var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2 = rY[2];
00602         // Units: dimensionless; Initial value: 0.4712
00603         double var_slow_time_dependent_potassium_current_Xs_gate__Xs = rY[3];
00604         // Units: dimensionless; Initial value: 0.0095
00605         double var_fast_sodium_current_m_gate__m = rY[4];
00606         // Units: dimensionless; Initial value: 0.00172
00607         double var_fast_sodium_current_h_gate__h = rY[5];
00608         // Units: dimensionless; Initial value: 0.7444
00609         double var_fast_sodium_current_j_gate__j = rY[6];
00610         // Units: dimensionless; Initial value: 0.7045
00611         double var_L_type_Ca_current_d_gate__d = rY[7];
00612         // Units: dimensionless; Initial value: 3.373e-5
00613         double var_L_type_Ca_current_f_gate__f = rY[8];
00614         // Units: dimensionless; Initial value: 0.7888
00615         double var_L_type_Ca_current_f2_gate__f2 = rY[9];
00616         // Units: dimensionless; Initial value: 0.9755
00617         double var_L_type_Ca_current_fCass_gate__fCass = rY[10];
00618         // Units: dimensionless; Initial value: 0.9953
00619         double var_transient_outward_current_s_gate__s = rY[11];
00620         // Units: dimensionless; Initial value: 0.999998
00621         double var_transient_outward_current_r_gate__r = rY[12];
00622         // Units: dimensionless; Initial value: 2.42e-8
00623         double var_calcium_dynamics__Ca_i = rY[13];
00624         // Units: millimolar; Initial value: 0.000126
00625         double var_calcium_dynamics__Ca_ss = rY[15];
00626         // Units: millimolar; Initial value: 0.00036
00627         double var_sodium_dynamics__Na_i = rY[17];
00628         // Units: millimolar; Initial value: 8.604
00629         double var_potassium_dynamics__K_i = rY[18];
00630         // Units: millimolar; Initial value: 136.89
00631         
00632         // Lookup table indexing
00633         if (var_membrane__V>349.9999 || var_membrane__V<-250.0001)
00634         {
00635 #define COVERAGE_IGNORE
00636             EXCEPTION(DumpState("V outside lookup table range", rY));
00637 #undef COVERAGE_IGNORE
00638         }
00639         
00640         double _offset_0 = var_membrane__V - -250.0001;
00641         double _offset_0_over_table_step = _offset_0 * 100.0;
00642         _table_index_0 = (unsigned)(_offset_0_over_table_step);
00643         _factor_0 = _offset_0_over_table_step - _table_index_0;
00644         _lt_0_row = BackwardEulerTenTusscher2006_LookupTables::Instance()->_lookup_0_row(_table_index_0, _factor_0);
00645         
00646         const double var_reversal_potentials__E_K = 26.7137606597 * log(5.4 / var_potassium_dynamics__K_i);
00647         const double var_inward_rectifier_potassium_current__alpha_K1 = 0.1 / (1.0 + exp(0.06 * ((var_membrane__V - var_reversal_potentials__E_K) - 200.0)));
00648         const double var_inward_rectifier_potassium_current__i_K1 = 5.405 * (var_inward_rectifier_potassium_current__alpha_K1 / (var_inward_rectifier_potassium_current__alpha_K1 + (((3.0 * exp(0.0002 * ((var_membrane__V - var_reversal_potentials__E_K) + 100.0))) + exp(0.1 * ((var_membrane__V - var_reversal_potentials__E_K) - 10.0))) / (1.0 + exp( -0.5 * (var_membrane__V - var_reversal_potentials__E_K)))))) * (var_membrane__V - var_reversal_potentials__E_K);
00649         var_membrane__i_K1 = var_inward_rectifier_potassium_current__i_K1;
00650         const double var_transient_outward_current__i_to = 0.294 * var_transient_outward_current_r_gate__r * var_transient_outward_current_s_gate__s * (var_membrane__V - var_reversal_potentials__E_K);
00651         var_membrane__i_to = var_transient_outward_current__i_to;
00652         const double var_rapid_time_dependent_potassium_current__i_Kr = 0.153 * 1.0 * var_rapid_time_dependent_potassium_current_Xr1_gate__Xr1 * var_rapid_time_dependent_potassium_current_Xr2_gate__Xr2 * (var_membrane__V - var_reversal_potentials__E_K);
00653         var_membrane__i_Kr = var_rapid_time_dependent_potassium_current__i_Kr;
00654         const double var_slow_time_dependent_potassium_current__i_Ks = 0.392 * pow(var_slow_time_dependent_potassium_current_Xs_gate__Xs, 2.0) * (var_membrane__V - (26.7137606597 * log(9.6 / (var_potassium_dynamics__K_i + (0.03 * var_sodium_dynamics__Na_i)))));
00655         var_membrane__i_Ks = var_slow_time_dependent_potassium_current__i_Ks;
00656         const double var_L_type_Ca_current__i_CaL = (((3.98e-05 * var_L_type_Ca_current_d_gate__d * var_L_type_Ca_current_f_gate__f * var_L_type_Ca_current_f2_gate__f2 * var_L_type_Ca_current_fCass_gate__fCass * 4.0 * (var_membrane__V - 15.0) * 9309421124.37) * 3.87974901066e-07) * ((0.25 * var_calcium_dynamics__Ca_ss * _lt_0_row[12]) - 2.0)) / _lt_0_row[13];
00657         var_membrane__i_CaL = var_L_type_Ca_current__i_CaL;
00658         const double var_sodium_potassium_pump_current__i_NaK = ((2.298375 * var_sodium_dynamics__Na_i) / (var_sodium_dynamics__Na_i + 40.0)) / _lt_0_row[24];
00659         var_membrane__i_NaK = var_sodium_potassium_pump_current__i_NaK;
00660         const double var_reversal_potentials__E_Na = 26.7137606597 * log(140.0 / var_sodium_dynamics__Na_i);
00661         const double var_fast_sodium_current__i_Na = 14.838 * pow(var_fast_sodium_current_m_gate__m, 3.0) * var_fast_sodium_current_h_gate__h * var_fast_sodium_current_j_gate__j * (var_membrane__V - var_reversal_potentials__E_Na);
00662         var_membrane__i_Na = var_fast_sodium_current__i_Na;
00663         const double var_sodium_background_current__i_b_Na = 0.00029 * (var_membrane__V - var_reversal_potentials__E_Na);
00664         var_membrane__i_b_Na = var_sodium_background_current__i_b_Na;
00665         const double var_sodium_calcium_exchanger_current__i_NaCa = (1000.0 * ((_lt_0_row[25] * pow(var_sodium_dynamics__Na_i, 3.0) * 2.0) - (_lt_0_row[26] * 2744000.0 * var_calcium_dynamics__Ca_i * 2.5))) / _lt_0_row[27];
00666         var_membrane__i_NaCa = var_sodium_calcium_exchanger_current__i_NaCa;
00667         const double var_calcium_background_current__i_b_Ca = 0.000592 * (var_membrane__V - (13.3568803298 * log(2.0 / var_calcium_dynamics__Ca_i)));
00668         var_membrane__i_b_Ca = var_calcium_background_current__i_b_Ca;
00669         const double var_potassium_pump_current__i_p_K = (0.0146 * (var_membrane__V - var_reversal_potentials__E_K)) / _lt_0_row[28];
00670         var_membrane__i_p_K = var_potassium_pump_current__i_p_K;
00671         const double var_calcium_pump_current__i_p_Ca = (0.1238 * var_calcium_dynamics__Ca_i) / (var_calcium_dynamics__Ca_i + 0.0005);
00672         var_membrane__i_p_Ca = var_calcium_pump_current__i_p_Ca;
00673         var_membrane__i_Stim = GetStimulus((1.0/1)*var_environment__time);
00674         
00675         double d_dt_membrane__V = -1.0 * (var_membrane__i_K1 + var_membrane__i_to + var_membrane__i_Kr + var_membrane__i_Ks + var_membrane__i_CaL + var_membrane__i_NaK + var_membrane__i_Na + var_membrane__i_b_Na + var_membrane__i_NaCa + var_membrane__i_b_Ca + var_membrane__i_p_K + var_membrane__i_p_Ca + var_membrane__i_Stim);
00676         
00677         
00678         rY[0] += mDt * 1.0*d_dt_membrane__V;
00679     }
00680     
00681     void BackwardEulerTenTusscher2006::ComputeOneStepExceptVoltage(double var_environment__time)
00682     {
00683         // Time units: millisecond
00684         var_environment__time *= 1.0;
00685         std::vector<double>& rY = rGetStateVariables();
00686         double var_membrane__V = rY[0];
00687         // Units: millivolt; Initial value: -85.23
00688         
00689         // Lookup table indexing
00690         if (var_membrane__V>349.9999 || var_membrane__V<-250.0001)
00691         {
00692 #define COVERAGE_IGNORE
00693             EXCEPTION(DumpState("V outside lookup table range", rY));
00694 #undef COVERAGE_IGNORE
00695         }
00696         
00697         double _offset_0 = var_membrane__V - -250.0001;
00698         double _offset_0_over_table_step = _offset_0 * 100.0;
00699         _table_index_0 = (unsigned)(_offset_0_over_table_step);
00700         _factor_0 = _offset_0_over_table_step - _table_index_0;
00701         _lt_0_row = BackwardEulerTenTusscher2006_LookupTables::Instance()->_lookup_0_row(_table_index_0, _factor_0);
00702         
00703         
00704         const double _g_0 = _lt_0_row[14] / _lt_0_row[15];
00705         const double _h_0 = (-1.0) / _lt_0_row[15];
00706         const double _g_1 = _lt_0_row[18] / _lt_0_row[19];
00707         const double _h_1 = (-1.0) / _lt_0_row[19];
00708         const double _g_2 = _lt_0_row[16] / _lt_0_row[17];
00709         const double _h_2 = (-1.0) / _lt_0_row[17];
00710         const double _g_3 = _lt_0_row[8] / _lt_0_row[9];
00711         const double _h_3 = (-1.0) / _lt_0_row[9];
00712         const double _g_4 = _lt_0_row[10] / _lt_0_row[11];
00713         const double _h_4 = (-1.0) / _lt_0_row[11];
00714         const double _g_5 = _lt_0_row[6] / _lt_0_row[7];
00715         const double _h_5 = (-1.0) / _lt_0_row[7];
00716         const double _g_6 = _lt_0_row[0] / _lt_0_row[1];
00717         const double _h_6 = (-1.0) / _lt_0_row[1];
00718         const double _g_7 = _lt_0_row[2] / _lt_0_row[3];
00719         const double _h_7 = (-1.0) / _lt_0_row[3];
00720         const double _g_8 = _lt_0_row[4] / _lt_0_row[5];
00721         const double _h_8 = (-1.0) / _lt_0_row[5];
00722         const double _g_9 = _lt_0_row[22] / _lt_0_row[23];
00723         const double _h_9 = (-1.0) / _lt_0_row[23];
00724         const double _g_10 = _lt_0_row[20] / _lt_0_row[21];
00725         const double _h_10 = (-1.0) / _lt_0_row[21];
00726         
00727         const double dt = mDt*1.0;
00728         rY[1] = (rY[1] + _g_6*dt) / (1 - _h_6*dt);
00729         rY[2] = (rY[2] + _g_7*dt) / (1 - _h_7*dt);
00730         rY[3] = (rY[3] + _g_8*dt) / (1 - _h_8*dt);
00731         rY[4] = (rY[4] + _g_5*dt) / (1 - _h_5*dt);
00732         rY[5] = (rY[5] + _g_3*dt) / (1 - _h_3*dt);
00733         rY[6] = (rY[6] + _g_4*dt) / (1 - _h_4*dt);
00734         rY[7] = (rY[7] + _g_0*dt) / (1 - _h_0*dt);
00735         rY[8] = (rY[8] + _g_2*dt) / (1 - _h_2*dt);
00736         rY[9] = (rY[9] + _g_1*dt) / (1 - _h_1*dt);
00737         rY[11] = (rY[11] + _g_10*dt) / (1 - _h_10*dt);
00738         rY[12] = (rY[12] + _g_9*dt) / (1 - _h_9*dt);
00739         
00740         double _guess[7] = {rY[10],rY[14],rY[13],rY[15],rY[16],rY[18],rY[17]};
00741         CardiacNewtonSolver<7> *_solver = CardiacNewtonSolver<7>::Instance();
00742         _solver->Solve(*this, var_environment__time, _guess);
00743         rY[10] = _guess[0];
00744         rY[14] = _guess[1];
00745         rY[13] = _guess[2];
00746         rY[15] = _guess[3];
00747         rY[16] = _guess[4];
00748         rY[18] = _guess[5];
00749         rY[17] = _guess[6];
00750     }
00751     
00752 template<>
00753 void OdeSystemInformation<BackwardEulerTenTusscher2006>::Initialise(void)
00754 {
00755     // Time units: millisecond
00756     // 
00757     this->mVariableNames.push_back("membrane__V");
00758     this->mVariableUnits.push_back("millivolt");
00759     this->mInitialConditions.push_back(-85.23);
00760 
00761     this->mVariableNames.push_back("rapid_time_dependent_potassium_current_Xr1_gate__Xr1");
00762     this->mVariableUnits.push_back("dimensionless");
00763     this->mInitialConditions.push_back(0.00621);
00764 
00765     this->mVariableNames.push_back("rapid_time_dependent_potassium_current_Xr2_gate__Xr2");
00766     this->mVariableUnits.push_back("dimensionless");
00767     this->mInitialConditions.push_back(0.4712);
00768 
00769     this->mVariableNames.push_back("slow_time_dependent_potassium_current_Xs_gate__Xs");
00770     this->mVariableUnits.push_back("dimensionless");
00771     this->mInitialConditions.push_back(0.0095);
00772 
00773     this->mVariableNames.push_back("fast_sodium_current_m_gate__m");
00774     this->mVariableUnits.push_back("dimensionless");
00775     this->mInitialConditions.push_back(0.00172);
00776 
00777     this->mVariableNames.push_back("fast_sodium_current_h_gate__h");
00778     this->mVariableUnits.push_back("dimensionless");
00779     this->mInitialConditions.push_back(0.7444);
00780 
00781     this->mVariableNames.push_back("fast_sodium_current_j_gate__j");
00782     this->mVariableUnits.push_back("dimensionless");
00783     this->mInitialConditions.push_back(0.7045);
00784 
00785     this->mVariableNames.push_back("L_type_Ca_current_d_gate__d");
00786     this->mVariableUnits.push_back("dimensionless");
00787     this->mInitialConditions.push_back(3.373e-5);
00788 
00789     this->mVariableNames.push_back("L_type_Ca_current_f_gate__f");
00790     this->mVariableUnits.push_back("dimensionless");
00791     this->mInitialConditions.push_back(0.7888);
00792 
00793     this->mVariableNames.push_back("L_type_Ca_current_f2_gate__f2");
00794     this->mVariableUnits.push_back("dimensionless");
00795     this->mInitialConditions.push_back(0.9755);
00796 
00797     this->mVariableNames.push_back("L_type_Ca_current_fCass_gate__fCass");
00798     this->mVariableUnits.push_back("dimensionless");
00799     this->mInitialConditions.push_back(0.9953);
00800 
00801     this->mVariableNames.push_back("transient_outward_current_s_gate__s");
00802     this->mVariableUnits.push_back("dimensionless");
00803     this->mInitialConditions.push_back(0.999998);
00804 
00805     this->mVariableNames.push_back("transient_outward_current_r_gate__r");
00806     this->mVariableUnits.push_back("dimensionless");
00807     this->mInitialConditions.push_back(2.42e-8);
00808 
00809     this->mVariableNames.push_back("calcium_dynamics__Ca_i");
00810     this->mVariableUnits.push_back("millimolar");
00811     this->mInitialConditions.push_back(0.000126);
00812 
00813     this->mVariableNames.push_back("calcium_dynamics__Ca_SR");
00814     this->mVariableUnits.push_back("millimolar");
00815     this->mInitialConditions.push_back(3.64);
00816 
00817     this->mVariableNames.push_back("calcium_dynamics__Ca_ss");
00818     this->mVariableUnits.push_back("millimolar");
00819     this->mInitialConditions.push_back(0.00036);
00820 
00821     this->mVariableNames.push_back("calcium_dynamics__R_prime");
00822     this->mVariableUnits.push_back("dimensionless");
00823     this->mInitialConditions.push_back(0.9073);
00824 
00825     this->mVariableNames.push_back("sodium_dynamics__Na_i");
00826     this->mVariableUnits.push_back("millimolar");
00827     this->mInitialConditions.push_back(8.604);
00828 
00829     this->mVariableNames.push_back("potassium_dynamics__K_i");
00830     this->mVariableUnits.push_back("millimolar");
00831     this->mInitialConditions.push_back(136.89);
00832 
00833     this->mInitialised = true;
00834 }
00835 
00836 
00837 // Serialization for Boost >= 1.36
00838 #include "SerializationExportWrapperForCpp.hpp"
00839 CHASTE_CLASS_EXPORT(BackwardEulerTenTusscher2006)

Generated by  doxygen 1.6.2