-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathModel.cpp
1896 lines (1806 loc) · 67.2 KB
/
Model.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* ----------------------------------------------------
NOTICE OF COPYRIGHT AND OWNERSHIP OF SOFTWARE
Copyright 2004, The Johns Hopkins University
School of Medicine. All rights reserved.
For research use only; commercial use prohibited.
Distribution without permission of Raimond L. Winslow
not permitted. rwinslow@bme.jhu.edu
Name of Program: Guinea Pig C++: Coupled, Algbraic, BB, MCA
Version: Documented Version, version 1.0.1
Date: August 2004
-----------------------------------------------------
*/
#include "model.h"
Model::Model(void) {
errweight = NULL;
s = NULL;
dS = NULL;
initializeModel();
}
// So the model can be reset midway through
void Model::initializeModel(bool algebraicMode) {
if ( errweight != NULL ) delete[] errweight;
if ( s != NULL ) delete[] s;
if ( dS != NULL ) delete[] dS;
modelTypeLookup["Coupled"] = Coupled;
modelTypeLookup["Mitochondria"] = Mitochondria;
modelTypeLookup["Force"] = Force;
stimulasModeLookup["BB"] = BB;
stimulasModeLookup["IF"] = IF;
stimulasModeLookup["periodic"] = periodic;
stimulasModeLookup["none"] = none;
errweight = new double[MAXSTATES];
s = new double[MAXSTATES];
dS = new double[MAXSTATES];
linkStatesReferences_Full(dS, s);
usingAlgebraicMembranePotential = algebraicMode;
//Initial/none Current stimulation level
Istim = 0;
//Error weights for integrators
errweight[index_V] = 1E-2; //46
errweight[index_mNa] = 1.0; //1
errweight[index_hNa] = 1.0; //2
errweight[index_jNa] = 1.0; //3
errweight[index_xKs] = 1.0; //4
errweight[index_Nai] = 0.2; //5
errweight[index_Ki] = 1.0/132.0; //6
errweight[index_Cai] = 1000.0; //7
errweight[index_CaNSR] = 0.5; //8
errweight[index_CaSS] = 1000.0; //9
errweight[index_CaJSR] = 0.05; //10
errweight[index_C1_RyR] = 1.0; //11
errweight[index_O2_RyR] = 1.0; //12
errweight[index_C2_RyR] = 1.0; //13
errweight[index_C0] = 1.0; //14
errweight[index_C1] = 1.0; //15
errweight[index_C2] = 1.0; //16
errweight[index_C3] = 1.0; //17
errweight[index_C4] = 1.0; //18
errweight[index_Open] = 1.0; //19
errweight[index_CCa0] = 1.0; //20
errweight[index_CCa1] = 1.0; //21
errweight[index_CCa2] = 1.0; //22
errweight[index_CCa3] = 1.0; //23
errweight[index_CCa4] = 1.0; //24
errweight[index_OCa] = 1.0; //25
errweight[index_yCa] = 1.0; //26
errweight[index_LTRPNCa] = 1.0; //27
errweight[index_HTRPNCa] = 1.0; //28
errweight[index_N0] = 1.0; //29
errweight[index_N1] = 1.0; //30
errweight[index_P0] = 1.0; //31
errweight[index_P1] = 1.0; //32
errweight[index_P2] = 1.0; //33
errweight[index_P3] = 1.0; //34
errweight[index_ATPi] = 1.0/8.0; //35
/**after Mitochondria mod**/
errweight[index_Cam]= 1.0; //not sure
errweight[index_ADPm]= 1.0/10.0;
errweight[index_Dpsi]= 1.0/200.0;
errweight[index_NADH]= 1.0/15.0;
errweight[index_ISOC]= 1.0;
errweight[index_AKG]= 1.0;
errweight[index_SCoA]= 1.0;
errweight[index_Succ]= 1.0;
errweight[index_FUM]=1.0;
errweight[index_MAL]= 1.0;
errweight[index_Oaa]= 1.0;
errweight[index_ASP]= 1.0;
errweight[index_ASP]= 1.0;
errweight[index_ASP]= 1.0;
errweight[index_ASP]= 1.0;
//CK mod
errweight[index_ATPi_cyto] = 1.0/8.0;
errweight[index_CrPi_cyto] = 1.0/40.0;
errweight[index_CrPi_mito] = 1.0/40.0;
//Setup the Dependent (i.e. current, outputs)
dependentVariableIndexLookup["INa"] = 1;
dependentVariableIndexLookup["IKs"] = 2;
dependentVariableIndexLookup["IK1"] = 3;
dependentVariableIndexLookup["INab"] = 4;
dependentVariableIndexLookup["IKp"] = 5;
dependentVariableIndexLookup["ICa"] = 6;
dependentVariableIndexLookup["ICaK"] = 7;
dependentVariableIndexLookup["INaK"] = 8;
dependentVariableIndexLookup["RNaK"] = 9;
dependentVariableIndexLookup["InsCa"] = 10;
dependentVariableIndexLookup["INaCa"] = 11;
dependentVariableIndexLookup["ICab"] = 12;
dependentVariableIndexLookup["IpCa"] = 13;
dependentVariableIndexLookup["RpCa"] = 14;
dependentVariableIndexLookup["Jup"] = 15;
dependentVariableIndexLookup["Jrel"] = 16;
dependentVariableIndexLookup["Jtr"] = 17;
dependentVariableIndexLookup["Jxfer"] = 18;
dependentVariableIndexLookup["V_AM"] = 19;
dependentVariableIndexLookup["VNO"] = 20;
dependentVariableIndexLookup["VANT"] = 21;
dependentVariableIndexLookup["VATPase"] = 22;
dependentVariableIndexLookup["VnaCa"] = 23;
dependentVariableIndexLookup["Vuni"] = 24;
dependentVariableIndexLookup["VIDH"] = 25;
dependentVariableIndexLookup["VKGDH"] = 26;
dependentVariableIndexLookup["FN_Ca"] = 27;
dependentVariableIndexLookup["Fnorm"] = 28;
dependentVariableIndexLookup["Force"] = 29;
}
Model::~Model(void) {
delete[] errweight;
delete[] s;
delete[] dS;
}
//Should be a simpler way to do all this, i.e. too many function calls.
//This is a wrapper to perform getF with arrays and not N_Vectors
//In theory (check documentation to see if change is made) y, and ydot correspond to s, dS
void Model::F_GPC(double start_time) {
//Because the code base changes this (a hack by another person)
//We have to save and restore the value
sharedVariableUpdate_Force();
if (usingAlgebraicMembranePotential)
calculateAlgebraicMembranePotential();
sharedVariableUpdate_GPC_1(start_time);
calculateStimulatedCurrent(start_time);
if (clampVoltage)
calculateClampedVoltage();
calculateReversalPotentials();
sharedVariableUpdate_GPC_2();
calculateINa();
calculateIKs();
calculateIK1();
calculateINab();
calculateIKp();
calculateICa();
calculateICaK();
calculateINaK();
calculateINaCa();
calculateICab();
calculateIpCa();
calculateInsCa();
/*after ATP mod**/
calculateV_AM();
/**after Mitochondria mod**/
calculateATPm();
calculateDmuH();
calculateNAD();
sharedVariableUpdate_Mitochondria();
calculateVCS();
calculateVACO();
calculateVIDH();
calculateVKGDH();
calculateVSL();
calculateVSDH();
calculateVFH();
calculateVMDH();
calculateVAAT();
calculateVNO_VHNe();
calculateVFO_VHFe();
calculateVATPase_Vhu();
calculateVANT_Vhleak();
//Starting Derivatives
calculateFNa();
calculateFxKs();
calculateInCalFlux(); //Not derivative
calculateForce();
calculateF_trpmyo();
calculateFLTRPNCa();
calculateFHTRPNCa();
calculateJtrpn();
calculateVuni(); // moved up
calculateVnaCa(); // from below (in the Mitene folder)
//CHF()
if (usingCHF) {
IK1 = chfsc_IK1 * IK1;
Jup = chfsc_Jup * Jup;
INaCa = chfsc_INaCa * INaCa;
}
calculateFNai();
calculateFKi();
calculateFCai();
calculateFCaSS();
calculateFCaJSR();
calculateFCaNSR();
calculateFV(); //Don't need to do in algebriac case
calculateFRyR();
calculateFCaL();
calculateFyCa();
calculateFOCa();
/**after ATP mod**/
if(usingCK) {
calculateCK(); //CK Mod
} else {
calculateFATPi(); //No CK mod
}
calculateF_mitene();
}
//Model F function for the mitochondria model
void Model::F_Mitochondria() {
//Shared updated variables
//Calculate Intemediates
calculateATPm();
calculateDmuH();
calculateNAD();
sharedVariableUpdate_Mitochondria();
calculateVCS();
calculateVACO();
calculateVIDH();
calculateVKGDH();
calculateVSL();
calculateVSDH();
calculateVFH();
calculateVMDH();
if (usingASP)
calculateVAAT_ASP();
else
calculateVAAT();
calculateVNO_VHNe();
calculateVFO_VHFe();
calculateVATPase_Vhu();
calculateVANT_Vhleak();
calculateVuni();
calculateVnaCa();
//Put them all together
calculateF_mitene();
}
//Model F for the Force Model
void Model::F_Force() {
sharedVariableUpdate_Force();
calculateForce();
calculateF_trpmyo();
calculateFLTRPNCa();
}
//Common variable computations for the GPC Model Part 1
//Must be done after calculateAlgebraicMembranePotential()
void Model::sharedVariableUpdate_GPC_1(double start_time) {
//Before IpCa
ADP = 8.0 - (*ATPi);
inv_ATPi = 1.0 / (*ATPi);
//Done after V -> Algebraic Potential, before ICA
VF_over_RT = (*V) * F_over_RT;
exp_VF_over_RT = exp( VF_over_RT );
VFsq_over_RT = FaradayE3 * VF_over_RT; //VF_over_RT is unitless mV/mV
exp2VFRT = exp_VF_over_RT * exp_VF_over_RT;
//Done before calculateStimulatedCurrent
start_time_shift = start_time - shift;
start_time_shift_time_on = floor( (start_time_shift) / period ) * period;
//Intermediate Variables
O1_RyR = 1.0 - *C1_RyR - *C2_RyR - *O2_RyR;
V_30 = (*V) + 30.0;
}
//Common variable computations for the GPC Model Part 2
//Done after calculateReversalPotentials and before calculateIk1
void Model::sharedVariableUpdate_GPC_2() {
//Done After calculateReversalPotentials, before Ik1
V_E_K = (*V) - E_K;
}
//Common variable computations for the Mitochondria Model
void Model::sharedVariableUpdate_Mitochondria() {
//Must be done after calculateNAD is Called
KmIDNAD_NAD = KmIDNAD / NAD;
//After calculateDmuH
exp_FRT_6_g_DmuH = exp(FRT_6_g * DmuH);
//Anytime
FRT2_Dpsi = FRT2 * ( (*Dpsi) - 91.0 );
}
//Common variable computations for the Force Model, well if there were any
void Model::sharedVariableUpdate_Force() {}
//Perform pre-Computations
void Model::calculateConstantModelParameters() {
//Moved from reading.cpp
Vtotal = (Vmyo + VJSR + VNSR + VSS) / 0.64;
Vmito = Vtotal * 0.36; //assuming Vmito is 36% of the cellular volume
f_01 = 3.0 * f_xb;
f_12 = 10.0 * f_xb;
f_23 = 7.0 * f_xb;
//g_xbSL=gmin_xb*(1-pow((1-SLnorm),1.6));
double g0_01 = 1.0 * gmin_xb;
double g0_12 = 2.0 * gmin_xb;
double g0_23 = 3.0 * gmin_xb;
double paths = g0_01 * g0_12 * g0_23 + f_01 * g0_12 * g0_23 + f_01 * f_12 * g0_23 + f_01 * f_12 * f_23;
double P1max = (f_01 * (2.0 * gmin_xb) * (3.0 * gmin_xb)) / paths;
double P2max = (f_01 * f_12 * (3.0 * gmin_xb)) / paths;
double P3max = (f_01 * f_12 * f_23) / paths;
double Fmax = P1max + 2.0 * P2max + 3 * P3max;
fnormmax = Fmax / 3.0;
double SLnorm = (SL - 1.7) / 0.6;
double Ktrop_Ca = kltrpn_minus / kltrpn_plus;
Ktrop_half = 1.0 / (1.0 + (Ktrop_Ca / (1.7 / 1000.0 + ((0.9 / 1000.0 - 1.7 / 1000.0) / (2.3 - 1.7)) * (SL - 1.7))));
Ntrop = 3.5 * SL - 2.0;
//Real model in Fortran
fnormmax2 = (P1max + P2max + P3max);
double La = 1; // um
double Lm_prime = 1.5; // um
double Lz = 0.1; // um
double Lb = 0.1; // um
double Lm = Lm_prime - Lb; // um
double mod_factor = 1 + (2.3 - SL) / pow((2.3 - 1.7),1.6); // dimensionless
if (SL <2.2)
alpha_SL = __min(1.0,(SL - 2.0 * La + Lm_prime - Lz) / Lm); // dimensionless
else
alpha_SL = 1 - (SL - 2.2) / Lm;
g_01_mod = g0_01 * mod_factor; // 1 / ms
g_12_mod = g0_12 * mod_factor; // 1 / ms
g_23_mod = g0_23 * mod_factor; // 1 / ms
double g_01_off = 30.0 / 1000.0; // New variable - - >unit: (1 / ms)
g_01_off_mod = g_01_off * mod_factor; // 1 / ms
//Optimization Precalcs
Vmyo_1000_F_Acap_C_m = Vmyo * ( Faraday * 1000) / (Acap * C_m);
Co = Vtotal * ( 2 * Cao + Ko + Nao) / Vmyo;
high_freq_hz = ( 1.0 / high_freq ) * 1000; //(ms)
norm_freq_hz = ( 1.0 / norm_freq ) * 1000; //(ms)
RTF_05 = RT_over_F * 0.5;
RTF_log_Nao = RT_over_F * log(Nao);
RTF_log_Ko = RT_over_F * log(Ko);
RTF_log_Nao_Ko = RT_over_F * log(Ko + 0.01833 * Nao);
RTF_05_log_Cao = RTF_05 * log(Cao);
//When Cai is clamped to __min 1e-10
E_Ca_Cai_Min = RTF_05_log_Cao + 10 * RTF_05;
G_Ks = 0.282 * sqrt( Ko / 5.4 );
G_K1 = 0.75 * sqrt( Ko / 5.4 );
inv_5p98 = 1.0 / 5.98;
FaradayE3 = (1000.0*Faraday);
Cao_341 = Cao * 341;
//scale by 1000, so current is in uA/uf
ICamax_LHospital = 2.0 * PCa * 1000.0 * Faraday *(1.0 - 341.0 * Cao);
Pca_4En3 = 4.0E-3 * PCa;
F_over_RT = 1.0 / RT_over_F;
inv_ICahalf = 1.0 / ICahalf;
PKFe3 = FaradayE3 * PK;
sigma = 0.0365 * ( exp(Nao / 67.3)-1.0)/7.0;
inv_KmNai = 1.0 / KmNai;
KmNaiP1p5 = sqrt(KmNai*KmNai*KmNai); //KmNai^1.5
INaKmax_Ko_Ko_KmKo = INaKmax * Ko / (Ko + KmKo);
inv_Ki1AD_NaK = 1.0 / Ki1AD_NaK;
eta_1 = eta-1.0;
Nao_p3 = pow( Nao, 3.0) / Cao;
KmCa_Cao = (KmCa + Cao) * (pow(KmNa, 3.0) + pow(Nao, 3.0)) / kNaCa /Cao;
KmCa_Cao_ksat = KmCa_Cao * ksat;
inv_KiADP_CaP = 1.0 / KiADP_CaP;
KmnsCa_p3 = pow(KmnsCa, 3.0);
V_AM_scaler_max_1_f_01_12_23 = V_AM_scaler * V_AM_max / (f_01 + f_12 + f_23);
KmATP_AM_Ki_AM = KmATP_AM / Ki_AM;
//Mitochondira Constants : ATPm
DmuH_Constant = -2.303 * RT_over_F * DpH;
VCS_C1 = (KCS * EtCS * AcCoA) / (KmAcCoA + AcCoA);
one_inv_KACOeq = 1.0 + 1.0 / KACOeq;
VIDH_Constant = 1.0 + H / kh_1 + kh_2 / H;
kIDH_EtID = kIDH * EtID;
inv_KADP = 1.0 / KADP;
inv_KaCa = 1.0 / KaCa;
inv_KidhNADH = 1.0 / KidhNADH;
KmKGNAD_KmIDNAD = KmKGNAD / KmIDNAD;
Mg_Kmg_1 = Mg / Kmg + 1.0;
Mg_Kmg_1_Kca = Mg_Kmg_1 / Kca;
kKGDH_EtKG = kKGDH * EtKG;
CoA_KSLeq = CoA / KSLeq;
kSDH_EtSDH = kSDH * EtSDH;
KmSucc_KiFUM = KmSucc / KiFUM;
inv_KiOxaa = 1.0 / KiOxaa;
kfFH_KFHeq = kfFH / KFHeq;
kMDH_Fh_EtMD = pow( ( 1.0 / ( 1.0 + Kh3 / H + Kh3 * Kh4 / pow(H,2) ) ) ,2) *
( 1.0 / ( 1.0 + H / Kh1 + pow(H,2) / ( Kh1 * Kh2 ) ) + Koff) *
kMDH * EtMD;
Kmal_Kioaa = Kmal / Kioaa;
VAAT_Constant = kfAAT * GLU * kcnsASP * KAATeq / kfAAT;
kcnsASP_KAATeq_kfAAT = kcnsASP * KAATeq / kfAAT;
KfAAT_GLU = kfAAT * GLU;
KfAAT_KAATeq = kfAAT/KAATeq;
kres_sq_KmIDNAD = kres * kres / KmIDNAD;
exp_6_FRT_Dpsio = exp( 6.0 * Dpsio * F_over_RT);
FRT_6_g = 6.0 * g * F_over_RT;
ra_rc1_exp_6_FRT_Dpsio = ra + rc1 * exp_6_FRT_Dpsio;
r1_exp_6_FRT_Dpsio = r1 * exp_6_FRT_Dpsio;
rhoREN_ra_rc1_exp_6_FRT_Dpsio = 0.5 * rhoREN * ra_rc1_exp_6_FRT_Dpsio;
rhoREN_rc2 = 0.5 * rhoREN * rc2;
rhoREN_ra = 0.5 * rhoREN * ra;
rhoRen_6_ra = 6.0 * rhoREN * ra;
rhoRen_6_ra_rb = 6.0 * rhoREN * ( ra + rb );
AREF = RT_over_F * log ( kresf * sqrt ( FADH2 / FAD ) );
exp_AREF_FRT = exp( AREF * F_over_RT );
ra_rc2_exp_AREF_FRT = 0.5 * (ra + rc2 * exp_AREF_FRT);
VFO_C1 = ( ra + rc1 * exp_6_FRT_Dpsio ) * exp_AREF_FRT * 0.5;
ra_exp_AREF_FRT = 4.0 * ra * exp_AREF_FRT;
ra_rb = 4.0 * (ra + rb);
VFO_VHFe_C1 = ( 1.0 + r1 * exp_AREF_FRT) * exp_6_FRT_Dpsio;
r2_r3_exp_AREF_FRT = r2 + r3 * exp_AREF_FRT;
exp_3_FRT_Dpsio = exp( 3.0 * Dpsio * F_over_RT);
FRT_3 = 3.0 * F_over_RT;
kf1_Pi = kf1 / Pi;
VATPase_C1 = ( 100.0 * pa + pc1 * exp_3_FRT_Dpsio);
pa_pb_3 = 3.0 * (pa + pb);
pa_300 = 300.0 * pa;
p1_exp_3_FRT_Dpsio = p1 * exp_3_FRT_Dpsio;
hm_F_over_RT = hm * F_over_RT;
VmDT_75 = 0.75 * VmDT;
VmDT_20 = 20.0 * VmDT;
tenDiv9 = 10.0 / 9.0;
//Pause doing Mitochondria : VHLeak
inv_11 = 1.0 / 11.0;
inv_11p1 = -1.0 / 11.1;
inv_6p8 = -1.0 / 6.8;
hNa_HAlpha_C1 = 0.135*exp(-80.0/6.8);
hNa_HBeta_C1 = 0.13*exp( - 10.66 / 11.1);
inv_Kfb = 1.0 / Kfb;
inv_Krb = 1.0 / Krb;
inv_tautr = 1.0 / tautr;
inv_tauxfer = 1.0 / tauxfer;
KmATP_SR_Ki_SR = KmATP_SR / Ki_SR;
inv_Ki_prime_SR = 1.0 / Ki_prime_SR;
//Start Force Model : Force
alpha_SL_fnormmax2 = alpha_SL / fnormmax2;
alpha_SL_fnormmax = alpha_SL / fnormmax / 3.0;
inv_LTRPNtot_Ktrop_half = 1.0 / ( LTRPNtot * Ktrop_half );
kTrop_pn_f_01 = -kTrop_pn - f_01;
kTrop_pn_f_12_g_01_mod = -(kTrop_pn + f_12 + g_01_mod);
f_23_g_12_mod = -(f_23 + g_12_mod);
twoThirds = 2.0 / 3.0;
//End Force Model : FLTRPNCa
CMDNtot_KmCMDN = CMDNtot * KmCMDN;
CSQNtot_KmCSQN = CSQNtot * KmCSQN;
//Start Mitochondria Again : Vuni
inv_ktrans = 1.0 / ktrans;
inv_kact = 1.0 / kact;
Vmuni_ktrans = Vmuni / ktrans;
FRT2 = 2.0 * F_over_RT;
b_05 = b * 0.5;
//Pause Mitochondria Again : Vanca
Acap_Vmyo_F = Acap / ( Vmyo * Faraday * 1000.0);
Acap_VSS_F = Acap / ( 2.0 * VSS * Faraday * 1000.0);
VJSR_VSS = VJSR / VSS;
Vmyo_VSS = Vmyo / VSS;
Vmyo_VNSR = Vmyo / VNSR;
VJSR_VNSR = VJSR / VNSR;
inv_C_m = 1.0 / C_m;
neg_inv_13 = -1.0 / 13;
inv_bL = 1.0 / bL;
inv_7p5 = 1.0 / 7.5;
inv_6 = 1.0 / 6.0;
inv_9p5 = 1.0 / 9.5;
//Mitochondria Last Time : F_Mitene
inv_Cmito = 1.0 / Cmito;
two_b = 2.0 * b;
//CK Mod
inv_keq = 1.0 / keq;
//Dependent Variables
zeta_alpha_SL_fnormmax = zeta * alpha_SL_fnormmax;
}
// algebraic membrane potential method; Currently has some issues
void Model::calculateAlgebraicMembranePotential() {
//Parameters: Faraday, Acap, C_m, Vtotal, Cao, Ko, Nao, Vmyo, CMDNtot, KmCMDN, VJSR, VNSR, CSQNtot, KmCSQN, VSS, Vmito
double Ca_all = 2.0 * ( (*Cai) + (*Cai) * CMDNtot / ( (*Cai) + KmCMDN ) + (*LTRPNCa) + (*HTRPNCa) ) +
VJSR * (1.0 + CSQNtot / ( (*CaJSR) + KmCSQN )) * (*CaJSR) +
VNSR * (*CaNSR) + VSS * (*CaSS) + Vmito * (*Cam);
(*V) = Vmyo_1000_F_Acap_C_m * ( (*Nai) + (*Ki) + Ca_all - Co ); // + extra);
}
// Cell Stimulation, BB, IF, periodic and none modes
void Model::calculateStimulatedCurrent(double start_time)
{
//Parameters: high_freq, norm_freq, start_time, shift, time_on_Is2, time_off_Is2, pulse_amplitude, t1, t2
//Assigned: Istim, [period, time_on_Is1, time_off_Is1]
switch (stimulasMode)
{
case IF:
if ( ((start_time >= time_on_Is1) && (start_time <= time_off_Is1)) ||
( (start_time >= time_on_Is2) && (start_time <= time_off_Is2) ) )
Istim = pulse_amplitude;
else
Istim = 0;
break;
case BB:
start_time_shift = start_time - shift;
if ( (start_time_shift >= t1) && (start_time_shift <= t2) )
period = high_freq_hz;
else
period = norm_freq_hz;
time_on_Is1 = start_time_shift_time_on;
time_off_Is1 = time_on_Is1 + pulse_duration;
if ( ( (start_time_shift) >= time_on_Is1) &&
( (start_time_shift) <= time_off_Is1))
Istim = pulse_amplitude;
else
Istim = 0;
break;
case periodic:
time_on_Is1 = start_time_shift_time_on;
time_off_Is1 = time_on_Is1 + pulse_duration;
Istim = 0;
if ( ( (start_time_shift) >= time_on_Is1) &&
( (start_time_shift) <= time_off_Is1))
Istim = pulse_amplitude;
else
Istim = 0;
break;
case none:
//Change this if mode changes
// time_on_Is1=floor((start_time-shift)/period)*period;
// time_off_Is1=time_on_Is1+pulse_duration;
// Istim = 0;
break;
}
}
//sets the voltage clamp
//Optimizations can be done if 2 or more of these are parameters:
//time_vclamp_on, vclamp_set, vclamp_hold
void Model::calculateClampedVoltage() {
//Parameters: time_vclamp_on, time_vclamp_off, vclamp_set, vclamp_hold
bool test1 = start_time_shift >= (start_time_shift_time_on + time_vclamp_on);
if ( test1 && (start_time_shift < (start_time_shift_time_on + time_vclamp_off)) ) {
double ramp = ( (start_time_shift - start_time_shift_time_on - time_vclamp_on)*0.5 )
*(vclamp_set - vclamp_hold) + vclamp_hold;
if ( vclamp_hold <= vclamp_set )
(*V) = __min(vclamp_set, ramp); // depol. steps
else
(*V) = __max(vclamp_set, ramp); // hyperpol. steps
} else if ( !test1 ) {
(*V) = vclamp_hold;
} else {
double ramp = (start_time_shift_time_on + time_vclamp_off - start_time_shift) *
0.5 * (vclamp_set - vclamp_hold) + vclamp_set;
if (vclamp_hold <= vclamp_set)
(*V) = __max(vclamp_hold, ramp); // depol. step
else
(*V) = __min(vclamp_hold, ramp); // hyper. step
}
}
// Calculates reversal potentials
//Calcs log(*Nai), log(*Ki), log(Cai),log(*Ki + 0.01833 * *Nai): Optomize?
void Model::calculateReversalPotentials() {
//Parameters: Nao, Ko, Cao
//Fixed Precomputes
E_Na = RTF_log_Nao - RT_over_F * log( (*Nai) );
E_K = RTF_log_Ko - RT_over_F * log( (*Ki) );
E_Ks = RTF_log_Nao_Ko - RT_over_F * log( (*Ki) + 0.01833 * (*Nai));
if ((*Cai) < 1.0e-10) {
// (*Cai) = 1.0E-10;
E_Ca = E_Ca_Cai_Min;
cerr << "calculateReversalPotentials: Below minimum calcium levels." <<endl;
} else {
E_Ca = RTF_05_log_Cao - RTF_05 * log( (*Cai) );
}
}
//The current value of INa, an intermediate variable;E_Na
void Model::calculateINa() {
//Parameters: G_Na
INa = G_Na *( (*mNa)*(*mNa)*(*mNa)*(*hNa)*(*jNa)*((*V) - E_Na) );
// INa=G_Na*(pow(mNa,3.0)*hNa*jNa*(V-E_Na));
}
//The current value of IKs, Fortran Code; exp((v-40)/40); intermediate Variable
void Model::calculateIKs() {
//Parameters: Ko
IKs = G_Ks * (*xKs) * (*xKs) * ( (*V) - E_Ks ) / ( 1.0 + exp(( (*V) - 40.0) / 40.0) );
}
//IK1 current; some math optimizations possible; V-E_K(V_E_K )
void Model::calculateIK1() {
//Parameters: Ko
double K1Alpha = 1.02 / ( 1.0 + exp( 0.2385* ( V_E_K - 59.215)));
double K1Beta = ( 0.4912 * exp( 0.08032 * ( V_E_K + 5.476)) +
exp( 0.06175 * ( V_E_K - 594.31)) ) /
( 1.0 + exp( -0.5143 * ( (*V) - E_K + 4.753 ) ) );
double K1_inf = K1Alpha / ( K1Alpha + K1Beta );
IK1 = G_K1 * K1_inf * (V_E_K);
// IK1 = 0.68* G_K1 * K1_inf * (V_E_K);
}
//Background Na+ current; intermediate Variable; V-E_Na
void Model::calculateINab() {
//Parameters: G_Nab
INab = G_Nab * ( (*V) - E_Na);
}
//IKp Current--plateau current, Math optimizations possible; Intermediate Variable; V_E_K
void Model::calculateIKp() {
//Parameters: G_Kp
IKp = G_Kp * (V_E_K) / ( 1.0 + exp( ( 7.488 - (*V) ) * inv_5p98) );
}
//Fortran and JT;VF_over_RT;VFsq_over_RT;exp_VF_over_RT
void Model::calculateICa() {
//Parameters Pca, Cao
//Taylor series: x/exp(2x) => 0.5 + -0.5 x, x = VFRT, => 0.5 + -0.02V
if (fabs(*V) < LHospitalThreshold) { // Use limit V->0, AT
ICamax = Pca_4En3 * (exp2VFRT - Cao_341) * ( 0.5 - 0.02 * (*V) );
} else {
ICamax = Pca_4En3 * VFsq_over_RT * (exp2VFRT - Cao_341)/(exp2VFRT - 1.0);
}
//The 5 factor added to account for low open probability of CAY L-type channel.
ICa = 6.0 * ICamax * (*yCa) * (*Open);
}
//L-Type Ca channel permeable to K+; Fortran Code;F_over_RT;exp_VF_over_RT;VF_over_RT;PKprime
void Model::calculateICaK() {
//Parameters: PK, ICahalf, Ko
//Taylor series: x/exp(2x) => 0.5 + -0.5 x, x = VFRT, => 0.5 + -0.02V
if (fabs(*V) < LHospitalThreshold) { // Use limit V->0, AT
ICaK = PKFe3 * ( (*Open) + (*OCa) ) * (*yCa) * ( (*Ki) * exp2VFRT - Ko ) * ( 0.5 - 0.02 * (*V) )
/ ( 1.0 + ICamax * inv_ICahalf );
} else {
ICaK = PKFe3 * ( (*Open) + (*OCa) ) * (*yCa) * ( (*Ki) * exp2VFRT - Ko ) * VF_over_RT
/ ( ( exp2VFRT - 1.0 ) * ( 1.0 + ICamax * inv_ICahalf ) );
}
}
//Sodium ATPase pump;ATP Mod;VF_over_RT;exp_VF_over_RT;ADP;inv_ATPi
void Model::calculateINaK() {
//Parameters: Ko, KmKo, KmNai, INaKmax, Ki1AD_NaK, Km1AT_NaK
double NaiP1p5 = sqrt((*Nai)*(*Nai)*(*Nai));
INaK = INaKmax_Ko_Ko_KmKo * NaiP1p5 /
( ( NaiP1p5 + KmNaiP1p5)*
( 1.0 + 0.1245 * exp ( -0.1 * VF_over_RT) + sigma / exp_VF_over_RT)*
( 1.0 + (Km1AT_NaK * inv_ATPi) * ( 1.0 + ADP * inv_Ki1AD_NaK ) ));
}
//The sodium-calcium exchanger;VF_over_RT;exp_VF_over_RT
void Model::calculateINaCa() {
//Parameters eta, Nao, Cao, ksat, KmCa
double exp_eta_VF_over_RT = exp( eta * VF_over_RT);
double exp_eta1_VF_over_RT = exp_eta_VF_over_RT / exp_VF_over_RT;
INaCa =( exp_eta_VF_over_RT * (*Nai) * (*Nai) * (*Nai) -
exp_eta1_VF_over_RT * Nao_p3 * (*Cai) )/
( KmCa_Cao + KmCa_Cao_ksat * exp_eta1_VF_over_RT);
}
//ICab;E_Ca
void Model::calculateICab() {
//G_Cab is a parameter
ICab = G_Cab * ((*V) - E_Ca);
}
//Sarcolemmal pump current; After ATP mod;ADP;inv_ATPi
void Model::calculateIpCa() {
//Parameters: Km2ATP_CaP, KiADP_CaP, Km1ATP_CaP, KmpCa, IpCamax
IpCa = IpCamax * (*Cai) / ( KmpCa + (*Cai) ) *
( 1.0 / ( 1.0+( Km1ATP_CaP * inv_ATPi)*( 1.0 + ADP * inv_KiADP_CaP) )
+ 1.0 / ( 1.0 + ( Km2ATP_CaP*inv_ATPi )));
}
// InsCa added to Guinea pig project (JT);VF_over_RT;exp_VF_over_RT;VFsq_over_RT;exp_VF_over_RT_1
//Do a taylor series expansion on this as soon as possible
void Model::calculateInsCa() {
//VFsq_over_RT, exp_VF_over_RT_1, Cai_p3, VFsq_over_RT, KmnsCa_p3, PnsK_75, PnsNa_75, PnsK_Nao_PnsNa_Ko_75
//Parameters:Nao, PnsNa, KmnsCa, PnsK
//Taylor series: x/exp(x) => 1 + -0.5 x, x = VFRT, => 1 + -0.02V
double common;
double CaiP3 = (*Cai)*(*Cai)*(*Cai);
if (fabs(*V) < LHospitalThreshold) {// Use limit V->0, AT
common = 0.75 * CaiP3 * ( 1.0 - 0.02 * (*V) ) / ( CaiP3 + KmnsCa_p3 );
} else {
common = 0.75 * CaiP3 * VFsq_over_RT / ( (exp_VF_over_RT - 1.0) * (CaiP3 + KmnsCa_p3) );
}
InsNa = PnsNa * common * ((*Nai) * exp_VF_over_RT - Nao);
InsK = PnsK * common * ((*Ki) * exp_VF_over_RT - Ko);
InsCa = InsNa + InsK;
}
//After ATP mod;Uses P1,2,3; ADP; inv_ATPi
void Model::calculateV_AM() {
//Parameters: V_AM_scaler, V_AM_max, f_01, f_12, f_23, KmATP_AM, Ki_AM
V_AM = V_AM_scaler_max_1_f_01_12_23 * (f_01 * (*P0) + f_12 * (*P1) + f_23 * (*P2))
/ (1.0 + inv_ATPi * ( KmATP_AM + KmATP_AM_Ki_AM * ADP ));
}
//Mitochondia; Intemediate Variable; Optimize Things that use this
void Model::calculateATPm() {
ATPm = Cm - (*ADPm);
}
//Mitochondia; Intemediate Variable; Optimize Things that use this
void Model::calculateDmuH() {
DmuH = DmuH_Constant + (*Dpsi);
}
//Mitochondia; Intemediate Variable; Optimize Things that use this
void Model::calculateNAD() {
NAD = CPN - (*NADH);
}
//Mitochondia; Intemediate Variable; Optimize Things that use this
void Model::calculateVCS() {
//Parameter: KmOaa, KCS, EtCS, AcCoA, KmAcCoA
VCS = VCS_C1 * (*Oaa) / ((*Oaa) + KmOaa);
}
//Mitochondia;Also CIT; Intemediate Variable; Optimize Things that use this
void Model::calculateVACO() {
VACO = kfACO * ( CIK - (*AKG) - (*SCoA) - (*Succ) - (*FUM) - (*MAL) - (*Oaa) - (*ISOC)* one_inv_KACOeq );
}
//Mitochondia; Intemediate Variable; Optimize Things that use this;1/Isoc;Dependent on NAD;KmIDNAD_NAD
void Model::calculateVIDH() {
double Fa = 1.0 / (( 1.0 + (*ADPm) * inv_KADP) * (1.0 + (*Cam) * inv_KaCa));
double Fi = 1.0 + (*NADH) * inv_KidhNADH;
VIDH = kIDH_EtID /
(VIDH_Constant + KmIDNAD_NAD * Fi + pow( Kmiso/(*ISOC), nID) * Fa * (1.0 + KmIDNAD_NAD * Fi));
}
//Mitochondia; Intemediate Variable; Optimize Things that use this; Dependent on Calculate NAD(KmIDNAD_NAD); 1/akg
void Model::calculateVKGDH() { //corrected on 07/26)
double a = ( (Mg_Kmg_1 + Mg_Kmg_1_Kca*(*Cam)) );
VKGDH = kKGDH_EtKG * a / ( a + pow(KmKG/(*AKG),nKG) + KmKGNAD_KmIDNAD * KmIDNAD_NAD );//corregir
}
//Mitochondia;Also CIT; Intemediate Variable; Optimize Things that use this; Dependent on calculateATPm
void Model::calculateVSL() {
VSL = kfSL * ( (*SCoA) * (*ADPm) - CoA_KSLeq * (*Succ) * ATPm);
}
//Mitochondia; Intemediate Variable; Optimize Things that use this;1/Succ
void Model::calculateVSDH() {
//Parameters: kSDH, EtSDH, KmSucc, KiFUM, KiOxaa
VSDH = kSDH_EtSDH * (*Succ) / ((*Succ) + (KmSucc + KmSucc_KiFUM*(*FUM)) * (1.0 + inv_KiOxaa*(*Oaa)) );
}
//Mitochondia; Intemediate Variable; Optimize Things that use this;Dependent on NAD(KmIDNAD_NAD)
void Model::calculateVFH() {
//Parameters: kfFH, KFHeq
VFH = kfFH * (*FUM) - kfFH_KFHeq * (*MAL);
}
//Mitochondia; Intemediate Variable; Optimize Things that use this;
void Model::calculateVMDH() {
//Parameters: Kh1, Kh2, Kh3, Kh4, Koff, H, Kioaa, KmmNAD, Kmal, EtMD, kMDH
VMDH = kMDH_Fh_EtMD * (*MAL) * NAD /
( ( (*MAL) + Kmal + (*Oaa) * Kmal_Kioaa ) * ( KmmNAD + NAD ) );
}
//Mitochondia; Intemediate Variable; Optimize Things that use this;
void Model::calculateVAAT() {
//Parameters: kfAAT, GLU, kcnsASP, KAATeq,
VAAT = VAAT_Constant * (*Oaa) / ( kcnsASP_KAATeq_kfAAT + (*AKG) );
}
//Mitochondia; Matlab model Calculation of VAAT. Uses ASP
void Model::calculateVAAT_ASP() {
//Parameters: kfAAT, GLU, KAATeq
VAAT = KfAAT_GLU * (*Oaa) - KfAAT_KAATeq * (*ASP) * (*AKG);
}
//Mitochondia; Intemediate Variable; Optimize Things that use this;RT_over_F; F_over_RT;KmIDNAD_NAD;DmuH;exp_6_FRT_Dpsio;exp_FRT_6_g_DmuH;
void Model::calculateVNO_VHNe() {
//Parameters: kres, rhoREN, Dpsio, g, ra, rc1, r1, rc2, rb
double AREN = sqrt ( (*NADH) * kres_sq_KmIDNAD * KmIDNAD_NAD) ;
double denominator = 1.0 / ( (exp_6_FRT_Dpsio + r1_exp_6_FRT_Dpsio * AREN ) + ( r2 + r3 * AREN ) * exp_FRT_6_g_DmuH );
VNO = ( (rhoREN_ra_rc1_exp_6_FRT_Dpsio + rhoREN_rc2 * exp_FRT_6_g_DmuH) * AREN - rhoREN_ra * exp_FRT_6_g_DmuH ) * denominator;
VHNe = (rhoRen_6_ra * AREN - rhoRen_6_ra_rb * exp_FRT_6_g_DmuH ) * denominator;
}
//Mitochondia; Intemediate Variable; Optimize Things that use this;RT_over_F;exp_6_FRT_Dpsio;exp_FRT_6_g_DmuH;
void Model::calculateVFO_VHFe() {
//Parameters: kresf, FADH2, FAD, r2, r3, rhoREF
double denominator = rhoREF / (VFO_VHFe_C1 + r2_r3_exp_AREF_FRT * exp_FRT_6_g_DmuH);
//Unused
//VFO = ( VFO_C1 - ra_rc2_exp_AREF_FRT * exp_FRT_6_g_DmuH) * denominator;
VHFe = ( ra_exp_AREF_FRT - ra_rb*exp_FRT_6_g_DmuH ) * denominator;
}
//Mitochondia; Intemediate Variable; Optimize Things that use this; RT_over_F; exp_3_FRT_Dpsio;F_over_RT; 1/ADPm; ATPm
void Model::calculateVATPase_Vhu() {
//This has a numeric instability due to round off (I guess) dependent on the order of evaluation of variables in VATPase
// DO NOT combine the exp_3FRT_DmuH statements, breaks the model
//Parameters: kf1, Pi, pa, pc1, pc2, p1, p2, p3 ,rhoF1
//Bad naming on some of the parameters
double exp_3FRT_DmuH = exp( FRT_3 * DmuH );
double AF1 = kf1_Pi * ATPm / (*ADPm);
double denominator = -rhoF1 / ( exp_3_FRT_Dpsio + p1_exp_3_FRT_Dpsio * AF1 + ( p2 + p3 * AF1 ) * exp_3FRT_DmuH);
// VATPase = ( VATPase_C1 * AF1 - (pa + pc2 * AF1) * exp_3FRT_DmuH ) * denominator;
VATPase = ( (VATPase_C1 + pc2 * exp_3FRT_DmuH) * AF1 - pa * exp_3FRT_DmuH ) * denominator;
Vhu = ( pa_300 + pa_300 * AF1 - pa_pb_3 * exp_3FRT_DmuH ) * denominator;
}
//Mitochondia;Different from paper; Intemediate Variable; Optimize Things that use this; ATPm;ADP
void Model::calculateVANT_Vhleak() {
//Parameters: gh, VmDT; hm
double ATPi_ADP = (*ATPi) / ADP;
double ADPm_ATPm = (*ADPm) / ATPm;
VANT = ( VmDT_75 - VmDT_20 * ATPi_ADP * ADPm_ATPm * exp(-F_over_RT * (*Dpsi)) ) /
( ( 1.0 + tenDiv9 * ATPi_ADP * exp( -hm_F_over_RT * (*Dpsi) ) ) * (1.0 + 18 * ADPm_ATPm ) );
Vhleak = gh * DmuH;
}
//getFNa will get the time rate of change of mNa, hNa, and jNa; fortran;
void Model::calculateFNa() {
//Parameters:
//Verbose check done
double MAlpha;
double MBeta;
double inv_MBeta_MAlpha;
double HAlpha;
double HBeta;
double JAlpha;
double JBeta;
double tmNa;
if ( (*V) == -47.13)
MAlpha = 3.2;
else
MAlpha = 0.32 * ( (*V) + 47.13 ) / ( 1.0 - exp(-0.1 * ( (*V) + 47.13) ) );
MBeta = 0.08*exp ( -(*V) * inv_11);
inv_MBeta_MAlpha = 1.0 / ( MBeta + MAlpha);
if ( inv_MBeta_MAlpha < 0.03) {
tmNa = MAlpha * inv_MBeta_MAlpha;
} else {
tmNa = (*mNa);
}
if ( (*V) < -40 ) {
HAlpha = hNa_HAlpha_C1*exp( inv_6p8 * (*V) );
HBeta = 3.56 * exp(0.079 * (*V) ) + 310000.0 * exp( 0.35 * (*V) );
JAlpha = (-127140.0 * exp(0.2444 * (*V)) - 3.474E-5 * exp ( - 0.04391 * (*V) ) ) *
( (*V) + 37.78 ) / (1.0 + exp( 0.311 * ( (*V) + 79.23) ));
JBeta = 0.1212 * exp( -0.01052 * (*V) ) / ( 1.0 + exp( -0.1378 * ( (*V) + 40.14 ) ) );
} else {
HAlpha = 0.0;
JAlpha = 0.0;
HBeta = 1.0 / ( 0.13 + hNa_HBeta_C1 * exp( (*V) * inv_11p1));
JBeta = 0.3*exp( - 2.535E-7 * (*V)) / (1.0 + exp( -0.1 * (*V) - 3.2) );
}
(*dmNa) = MAlpha * ( 1.0 - (tmNa) ) - MBeta * (tmNa);
(*dhNa) = HAlpha * (1.0 - (*hNa)) - HBeta * (*hNa);
(*djNa) = JAlpha * (1.0 - (*jNa)) - JBeta * (*jNa);
}
//xKs
void Model::calculateFxKs() {
(*dxKs) = 7.19E-5 * V_30 / (1.0 - exp( -0.148 * V_30)) * (1.0-(*xKs)) -
1.31E-4 * V_30 / (exp(0.0687 * V_30) - 1.0) * (*xKs);
}
//computes current values for Jup, Jrel, Jtr, and Jxfer; After ATPmod;O1_RyR;ADP;inv_ATPi
void Model::calculateInCalFlux(){
//Paramerters: Kfb, Krb, Nfb,Nrb, KSR, vmaxf, vmaxr, KmATP_SR, Ki_SR, Ki_prime_SR, v1, tauxfer, tautr
double fb = pow( (*Cai) * inv_Kfb, Nfb);
double rb = pow( (*CaNSR) * inv_Krb, Nrb);
Jup = KSR * ( vmaxf * fb - vmaxr * rb) /
( (1.0+fb+rb)*( inv_ATPi*( KmATP_SR + ADP * KmATP_SR_Ki_SR) + (1.0 + ADP * inv_Ki_prime_SR) ) );
Jrel = v1 * ( O1_RyR + (*O2_RyR) ) * ( (*CaJSR) - (*CaSS) );
Jtr = ( (*CaNSR) - (*CaJSR) ) * inv_tautr;
Jxfer = ( (*CaSS) - (*Cai) ) * inv_tauxfer;
}
//Force Model; FN_Ca;Fnorm; Force
void Model::calculateForce() {
//Parameters: alpha_SL, zeta
P1_N1_P2_P3 = (*P1) + (*N1) + (*P2) + (*P3);
FN_Ca = alpha_SL_fnormmax2 * P1_N1_P2_P3;
}
//Force Model; Tropomyosin_XB added to project (JT);LTRPNCa;kTrop_np;dP0;dP1;dP2;dP3;dN0;dN1;Fortran;
void Model::calculateF_trpmyo() {
//Parameters: kTrop_pn; LTRPNtot; Ktrop_half; Ntrop; f_01; g_01_mod; f_12; g_12_mod; g_23_mod; f_23
double kTrop_np = kTrop_pn * pow( (*LTRPNCa) * inv_LTRPNtot_Ktrop_half, Ntrop);
(*dP0) = kTrop_pn_f_01 * (*P0) + kTrop_np * (*N0) + g_01_mod * (*P1);
(*dP1) = kTrop_pn_f_12_g_01_mod * (*P1) + kTrop_np * (*N1) + f_01 * (*P0) + g_12_mod * (*P2);
(*dP2) = f_23_g_12_mod * (*P2) + f_12 * (*P1) + g_23_mod * (*P3);
(*dP3) = -g_23_mod * (*P3) + f_23 * (*P2);
(*dN1) = kTrop_pn * (*P1) - (kTrop_np + g_01_off_mod) * (*N1);
(*dN0) = -(*dP0)-(*dP1)-(*dP2)-(*dP3)-(*dN1); //added by JT
}
// TROPONIN FRACTION DERIVATIVES; Fortran; FN_Ca; kltrpn_plus_Cai
// These methods get the time rate of change for LTRPNCa and HTRPNCa
//Force Model;
void Model::calculateFLTRPNCa() {
//Parameters:kltrpn_plus;LTRPNtot;kltrpn_minus
(*dLTRPNCa) = kltrpn_plus * (*Cai) * (LTRPNtot - (*LTRPNCa))- ( kltrpn_minus * (*LTRPNCa) ) * ( 1.0 - twoThirds * FN_Ca );
}
//dHTRPNCa; kltrpn_plus_Cai
void Model::calculateFHTRPNCa() {
//Parameters:kltrpn_plus;HTRPNtot;kltrpn_minus
(*dHTRPNCa) = khtrpn_plus * (*Cai) * (HTRPNtot - (*HTRPNCa)) - khtrpn_minus * (*HTRPNCa);
}
//computes current values for beta_SS, beta_JSR, and beta_i
void Model::calculateJtrpn() {
//Parameters: CMDNtot; KmCMDN; CSQNtot;KmCSQN
Jtrpn = (*dLTRPNCa) + (*dHTRPNCa);
beta_SS = 1.0 / ( 1.0 + CMDNtot_KmCMDN / ( ((*CaSS) + KmCMDN)*((*CaSS) + KmCMDN) ) );
beta_JSR = 1.0 / ( 1.0 + CSQNtot_KmCSQN / ( ((*CaJSR) + KmCSQN)*((*CaJSR) + KmCSQN) ) );
beta_i = 1.0 / ( 1.0 + CMDNtot_KmCMDN / ( ((*Cai) + KmCMDN)*((*Cai) + KmCMDN) ) );
}
//Mitochondia;Vuni; F_over_RT; FRT2_Dpsi; Treat Cai as parameter in Mitochondia only model
void Model::calculateVuni() {
//Parameters: Vmuni; ktrans; L; kact; na
double Cai_ktrans_plus1 = 1.0 + (*Cai) * inv_ktrans;
double Cai_ktrans_plus1_p3 = Cai_ktrans_plus1 * Cai_ktrans_plus1 * Cai_ktrans_plus1;
Vuni = Vmuni_ktrans * (*Cai) * FRT2_Dpsi * Cai_ktrans_plus1_p3 /
( ( Cai_ktrans_plus1_p3 * Cai_ktrans_plus1 + L / pow( 1.0 + (*Cai) * inv_kact, na) ) * ( 1.0 - exp(-FRT2_Dpsi) ) );
}
///Mitochondia; F_over_RT; FRT2_Dpsi; 1/Nai; 1/Cam; 1/Cai ; Cai Nai as params in Mito only
void Model::calculateVnaCa() {
//Parameters: b; VmNC; Kna; n; Knca;
VnaCa = VmNC * exp( b_05 * FRT2_Dpsi ) * (*Cam) / ( (*Cai) * pow( ( 1.0 + Kna / (*Nai) ) , n) * ( 1.0 + Knca / (*Cam) ) );
}
//Intercellular Concentration calculations
//These methods get the time rate of change for Nai, Ki, and Cai; Post-Mitochondrial mod
//INa;INab;INaCa;INaK;InsNa;VnaCa | Acap_Vmyo_F
void Model::calculateFNai() {
//Parameters: InsNa; Vmyo; Acap
(*dNai) = - ( INa + INab + InsNa + 3.0 * ( INaCa + INaK ) ) * Acap_Vmyo_F - VnaCa * 0.615;
//(*dNai) = 0.0;
}
//Ki; Acap_Vmyo_F | INaK, Istim, ICaK, IKp, IK1, IKs
void Model::calculateFKi() {
//Parameters: InsK
//temporarily change in lines to calculate elasticities!
(*dKi) = -(InsK + IKs + IK1 + IKp + ICaK + Istim - 2.0 * INaK) * Acap_Vmyo_F;
//(*dKi) = 0.0;
}
//Cai; Acap_Vmyo_F; ICab; INaCa; IpCa; beta_i; Jxfer; Jup; Jtrpn
void Model::calculateFCai() {
//temporarily change in line 959 to calculate elasticities!
(*dCai) = beta_i * ( Jxfer - Jup - Jtrpn - 0.25 * Acap_Vmyo_F * (ICab - 2.0 * INaCa + IpCa) + ( VnaCa - Vuni ) * 0.615);
//(*dCai) = 0.0;
}
//These methods get the time rate of change for CaSS, CaJSR, and CaNSR
//CaSS; ICa, beta_SS
void Model::calculateFCaSS() {
//Parameters: VSS
(*dCaSS) = beta_SS * ( Jrel * VJSR_VSS - Jxfer * Vmyo_VSS - ICa * Acap_VSS_F);
//(*dCaSS) = 0.0;
}
//CaJSR;beta_JSR; Jtr; Jrel
void Model::calculateFCaJSR() {
(*dCaJSR) = beta_JSR * ( Jtr - Jrel );
//(*dCaJSR) = 0.0;
}
//CaNSR; Jup; Jtr
void Model::calculateFCaNSR() {
//parameter: Vmyo,| VNSR; VJSR
(*dCaNSR) = Jup * Vmyo_VNSR - Jtr * VJSR_VNSR;
//(*dCaNSR) = 0.0;
}
//gets the time rate of change for V; INa; INaCa; INab
void Model::calculateFV() {
//Parameters: C_m
if ( clampVoltage || usingAlgebraicMembranePotential ) {
(*dV) = 0;
} else {
(*dV)= -inv_C_m *( INa + ICa + ICaK + IKs + IK1 + IKp + INaCa + INaK + InsCa + IpCa + ICab + INab + Istim );
}
}
//getFRyR gets the time rate of change for C1_RyR,O2_RyR, C2_RyR.
void Model::calculateFRyR() {
//Parameters: kaplus; kbplus; kcplus; kaminus; kbminus; kcminus; ncoop; mcoop
(*dC1_RyR) = -kaplus * pow( (*CaSS), ncoop) * (*C1_RyR) + kaminus * O1_RyR;
(*dO2_RyR) = kbplus * pow( (*CaSS), mcoop) * O1_RyR - kbminus * (*O2_RyR);
(*dC2_RyR) = kcplus * O1_RyR - kcminus * (*C2_RyR);
}
//L-Type Ca++ current; fortran; Some Variables could be optimized( Gamma|Omega)
//getFCaL gets the time rate of change for C0,C1,C2,C3,C4,Open,CCa0,CCa1,CCa2,CCa3, and CCa4