Generated Code
The following is python code generated by the CellML API from this CellML file. (Back to language selection)
The raw code is available.
# Size of variable arrays:
sizeAlgebraic = 86
sizeStates = 41
sizeConstants = 90
from math import *
from numpy import *
def createLegends():
legend_states = [""] * sizeStates
legend_rates = [""] * sizeStates
legend_algebraic = [""] * sizeAlgebraic
legend_voi = ""
legend_constants = [""] * sizeConstants
legend_voi = "time in component environment (second)"
legend_constants[0] = "R in component model_parameters (joule_per_kilomole_kelvin)"
legend_constants[1] = "T in component model_parameters (kelvin)"
legend_constants[2] = "F in component model_parameters (coulomb_per_mole)"
legend_constants[3] = "Nae in component model_parameters (millimolar)"
legend_constants[4] = "Cae in component model_parameters (millimolar)"
legend_constants[5] = "Ke in component model_parameters (millimolar)"
legend_constants[87] = "Vt in component model_parameters (cm3)"
legend_constants[54] = "Vd in component model_parameters (cm3)"
legend_constants[56] = "Vmyo in component model_parameters (cm3)"
legend_constants[58] = "Sms in component model_parameters (cm2)"
legend_constants[59] = "Smt in component model_parameters (cm2)"
legend_constants[89] = "Cms in component model_parameters (microF)"
legend_constants[88] = "Cmt in component model_parameters (microF)"
legend_constants[86] = "Rst in component model_parameters (ohm)"
legend_constants[55] = "VSRrel in component model_parameters (cm3)"
legend_constants[57] = "VSRup in component model_parameters (cm3)"
legend_constants[51] = "Vc in component model_parameters (cm3)"
legend_constants[84] = "pt in component model_parameters (dimensionless)"
legend_constants[85] = "Lt in component model_parameters (cm)"
legend_constants[6] = "Rot in component model_parameters (ohm_cm)"
legend_constants[7] = "radiust in component model_parameters (cm)"
legend_constants[8] = "ptcm in component model_parameters (per_cm2)"
legend_constants[9] = "Smtot in component model_parameters (cm2)"
legend_algebraic[22] = "i_circ in component i_circ (microA)"
legend_states[0] = "Vms in component Vms (millivolt)"
legend_states[1] = "Vmt in component Vmt (millivolt)"
legend_algebraic[46] = "i_Stim in component i_Stim (microA)"
legend_constants[10] = "stim_offset in component i_Stim (second)"
legend_constants[11] = "stim_period in component i_Stim (second)"
legend_constants[12] = "stim_duration in component i_Stim (second)"
legend_constants[13] = "stim_amplitude in component i_Stim (microA)"
legend_algebraic[43] = "past in component i_Stim (second)"
legend_constants[60] = "gNas in component membrane_permeabilities (milliS)"
legend_constants[61] = "gCas in component membrane_permeabilities (cm3_per_second)"
legend_constants[62] = "gKfs in component membrane_permeabilities (milliS)"
legend_constants[63] = "gKsts in component membrane_permeabilities (milliS)"
legend_constants[64] = "gK1s in component membrane_permeabilities (milliS)"
legend_constants[65] = "gKbs in component membrane_permeabilities (milliS)"
legend_constants[66] = "gKtos in component membrane_permeabilities (milliS)"
legend_constants[67] = "gNabs in component membrane_permeabilities (milliS)"
legend_constants[68] = "gCabs in component membrane_permeabilities (milliS)"
legend_constants[69] = "i_pCa_maxs in component membrane_permeabilities (microA)"
legend_constants[70] = "i_NaK_maxs in component membrane_permeabilities (microA)"
legend_constants[71] = "i_NaCa_maxs in component membrane_permeabilities (microA)"
legend_constants[72] = "gNat in component membrane_permeabilities (milliS)"
legend_constants[73] = "gCat in component membrane_permeabilities (cm3_per_second)"
legend_constants[74] = "gKft in component membrane_permeabilities (milliS)"
legend_constants[75] = "gKstt in component membrane_permeabilities (milliS)"
legend_constants[76] = "gK1t in component membrane_permeabilities (milliS)"
legend_constants[77] = "gKbt in component membrane_permeabilities (milliS)"
legend_constants[78] = "gKtot in component membrane_permeabilities (milliS)"
legend_constants[79] = "gNabt in component membrane_permeabilities (milliS)"
legend_constants[80] = "gCabt in component membrane_permeabilities (milliS)"
legend_constants[81] = "i_pCa_maxt in component membrane_permeabilities (microA)"
legend_constants[82] = "i_NaK_maxt in component membrane_permeabilities (microA)"
legend_constants[83] = "i_NaCa_maxt in component membrane_permeabilities (microA)"
legend_constants[14] = "gNa in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[15] = "fNat in component membrane_permeabilities (dimensionless)"
legend_constants[16] = "gKf in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[17] = "fKft in component membrane_permeabilities (dimensionless)"
legend_constants[18] = "gKst in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[19] = "fKstt in component membrane_permeabilities (dimensionless)"
legend_constants[20] = "gK1 in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[21] = "fK1t in component membrane_permeabilities (dimensionless)"
legend_constants[22] = "gKb in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[23] = "fKbt in component membrane_permeabilities (dimensionless)"
legend_constants[24] = "gKto in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[25] = "fKtot in component membrane_permeabilities (dimensionless)"
legend_constants[26] = "gNab in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[27] = "fNabt in component membrane_permeabilities (dimensionless)"
legend_constants[28] = "gCab in component membrane_permeabilities (milliS_per_cm2)"
legend_constants[29] = "fCabt in component membrane_permeabilities (dimensionless)"
legend_constants[30] = "gCa in component membrane_permeabilities (cm_per_second)"
legend_constants[31] = "fCat in component membrane_permeabilities (dimensionless)"
legend_constants[32] = "i_NaCa_max in component membrane_permeabilities (microA_per_cm2)"
legend_constants[33] = "fNaCat in component membrane_permeabilities (dimensionless)"
legend_constants[34] = "i_NaK_max in component membrane_permeabilities (microA_per_cm2)"
legend_constants[35] = "fNaKt in component membrane_permeabilities (dimensionless)"
legend_constants[36] = "i_pCa_max in component membrane_permeabilities (microA_per_cm2)"
legend_constants[37] = "fpCat in component membrane_permeabilities (dimensionless)"
legend_algebraic[48] = "i_Nas in component i_Nas (microA)"
legend_algebraic[47] = "E_Nas in component i_Nas (millivolt)"
legend_states[2] = "Nai in component ion_concentrations (millimolar)"
legend_states[3] = "Ki in component ion_concentrations (millimolar)"
legend_states[4] = "m in component i_Nas_m_gate (dimensionless)"
legend_states[5] = "h in component i_Nas_h_gate (dimensionless)"
legend_algebraic[0] = "alpha_m in component i_Nas_m_gate (per_second)"
legend_algebraic[23] = "beta_m in component i_Nas_m_gate (per_second)"
legend_algebraic[1] = "alpha_h in component i_Nas_h_gate (per_second)"
legend_algebraic[24] = "beta_h in component i_Nas_h_gate (per_second)"
legend_algebraic[50] = "i_Nat in component i_Nat (microA)"
legend_algebraic[49] = "E_Nat in component i_Nat (millivolt)"
legend_states[6] = "Nat in component ion_concentrations (millimolar)"
legend_states[7] = "Kt in component ion_concentrations (millimolar)"
legend_states[8] = "m in component i_Nat_m_gate (dimensionless)"
legend_states[9] = "h in component i_Nat_h_gate (dimensionless)"
legend_algebraic[2] = "alpha_m in component i_Nat_m_gate (per_second)"
legend_algebraic[25] = "beta_m in component i_Nat_m_gate (per_second)"
legend_algebraic[3] = "alpha_h in component i_Nat_h_gate (per_second)"
legend_algebraic[26] = "beta_h in component i_Nat_h_gate (per_second)"
legend_algebraic[52] = "i_Cas in component i_Cas (microA)"
legend_algebraic[51] = "E_Cas in component i_Cas (millivolt)"
legend_states[10] = "Co in component i_Cas (dimensionless)"
legend_states[11] = "C1 in component i_Cas (dimensionless)"
legend_states[12] = "C2 in component i_Cas (dimensionless)"
legend_algebraic[27] = "tauCo in component i_Cas (second)"
legend_constants[38] = "tauCcast in component i_Cas (second)"
legend_algebraic[28] = "tauC1 in component i_Cas (second)"
legend_algebraic[44] = "tauC2 in component i_Cas (second)"
legend_states[13] = "Ccast in component i_Cas (dimensionless)"
legend_algebraic[4] = "Coinf in component i_Cas (dimensionless)"
legend_algebraic[5] = "Ccastinf in component i_Cas (dimensionless)"
legend_algebraic[6] = "C1inf in component i_Cas (dimensionless)"
legend_algebraic[29] = "C2inf in component i_Cas (dimensionless)"
legend_states[14] = "Cass in component ion_concentrations (millimolar)"
legend_states[15] = "Cai in component ion_concentrations (millimolar)"
legend_algebraic[54] = "i_Cat in component i_Cat (microA)"
legend_algebraic[53] = "E_Cat in component i_Cat (millivolt)"
legend_states[16] = "Co in component i_Cat (dimensionless)"
legend_states[17] = "C1 in component i_Cat (dimensionless)"
legend_states[18] = "C2 in component i_Cat (dimensionless)"
legend_algebraic[30] = "tauCo in component i_Cat (second)"
legend_constants[39] = "tauCcast in component i_Cat (second)"
legend_algebraic[31] = "tauC1 in component i_Cat (second)"
legend_algebraic[45] = "tauC2 in component i_Cat (second)"
legend_algebraic[7] = "Coinf in component i_Cat (dimensionless)"
legend_states[19] = "Ccast in component i_Cat (dimensionless)"
legend_algebraic[8] = "Ccastinf in component i_Cat (dimensionless)"
legend_algebraic[9] = "C1inf in component i_Cat (dimensionless)"
legend_algebraic[32] = "C2inf in component i_Cat (dimensionless)"
legend_states[20] = "Cat in component ion_concentrations (millimolar)"
legend_algebraic[56] = "i_Ktos in component i_Ktos (microA)"
legend_algebraic[55] = "E_Ks in component i_Ktos (millivolt)"
legend_states[21] = "rs in component i_Ktos_rs_gate (dimensionless)"
legend_states[22] = "ss in component i_Ktos_ss_gate (dimensionless)"
legend_states[23] = "sss in component i_Ktos_sss_gate (dimensionless)"
legend_algebraic[33] = "taurs in component i_Ktos_rs_gate (second)"
legend_algebraic[10] = "rinfs in component i_Ktos_rs_gate (dimensionless)"
legend_algebraic[34] = "tauss in component i_Ktos_ss_gate (second)"
legend_algebraic[11] = "sinfs in component i_Ktos_ss_gate (dimensionless)"
legend_algebraic[35] = "tausss in component i_Ktos_sss_gate (second)"
legend_algebraic[12] = "ssinfs in component i_Ktos_sss_gate (dimensionless)"
legend_algebraic[58] = "i_Ktot in component i_Ktot (microA)"
legend_algebraic[57] = "E_Kt in component i_Ktot (millivolt)"
legend_states[24] = "rt in component i_Ktot_rt_gate (dimensionless)"
legend_states[25] = "st in component i_Ktot_st_gate (dimensionless)"
legend_states[26] = "sst in component i_Ktot_sst_gate (dimensionless)"
legend_algebraic[36] = "taurt in component i_Ktot_rt_gate (second)"
legend_algebraic[13] = "rinft in component i_Ktot_rt_gate (dimensionless)"
legend_algebraic[37] = "taust in component i_Ktot_st_gate (second)"
legend_algebraic[14] = "sinft in component i_Ktot_st_gate (dimensionless)"
legend_algebraic[38] = "tausst in component i_Ktot_sst_gate (second)"
legend_algebraic[15] = "ssinft in component i_Ktot_sst_gate (dimensionless)"
legend_algebraic[59] = "i_Ksts in component i_Ksts (microA)"
legend_states[27] = "rsts in component i_Ksts_rsts_gate (dimensionless)"
legend_states[28] = "ssts in component i_Ksts_ssts_gate (dimensionless)"
legend_algebraic[39] = "taursts in component i_Ksts_rsts_gate (second)"
legend_algebraic[16] = "rstinfs in component i_Ksts_rsts_gate (dimensionless)"
legend_constants[40] = "taussts in component i_Ksts_ssts_gate (second)"
legend_algebraic[17] = "sstinfs in component i_Ksts_ssts_gate (dimensionless)"
legend_algebraic[60] = "i_Kstt in component i_Kstt (microA)"
legend_states[29] = "rstt in component i_Kstt_rstt_gate (dimensionless)"
legend_states[30] = "sstt in component i_Kstt_sstt_gate (dimensionless)"
legend_algebraic[40] = "taurstt in component i_Kstt_rstt_gate (second)"
legend_algebraic[18] = "rstinft in component i_Kstt_rstt_gate (dimensionless)"
legend_constants[41] = "tausstt in component i_Kstt_sstt_gate (second)"
legend_algebraic[19] = "sstinft in component i_Kstt_sstt_gate (dimensionless)"
legend_algebraic[61] = "i_Kfs in component i_Kfs (microA)"
legend_states[31] = "qs in component i_Kfs_qs_gate (dimensionless)"
legend_algebraic[41] = "tauqs in component i_Kfs_qs_gate (second)"
legend_algebraic[20] = "qinfs in component i_Kfs_qs_gate (dimensionless)"
legend_algebraic[62] = "i_Kft in component i_Kft (microA)"
legend_states[32] = "qt in component i_Kft_qt_gate (dimensionless)"
legend_algebraic[42] = "tauqt in component i_Kft_qt_gate (second)"
legend_algebraic[21] = "qinft in component i_Kft_qt_gate (dimensionless)"
legend_algebraic[63] = "i_K1s in component i_K1s (microA)"
legend_algebraic[64] = "i_K1t in component i_K1t (microA)"
legend_algebraic[65] = "i_Nabs in component i_Nabs (microA)"
legend_algebraic[66] = "i_Nabt in component i_Nabt (microA)"
legend_algebraic[67] = "i_Cabs in component i_Cabs (microA)"
legend_algebraic[68] = "i_Cabt in component i_Cabt (microA)"
legend_algebraic[69] = "i_Kbs in component i_Kbs (microA)"
legend_algebraic[70] = "i_Kbt in component i_Kbt (microA)"
legend_algebraic[71] = "i_NaCas in component i_NaCas (microA)"
legend_algebraic[72] = "i_NaCat in component i_NaCat (microA)"
legend_algebraic[73] = "i_NaKs in component i_NaKs (microA)"
legend_algebraic[74] = "i_NaKt in component i_NaKt (microA)"
legend_algebraic[77] = "i_pCas in component i_pCas (microA)"
legend_algebraic[78] = "i_pCat in component i_pCat (microA)"
legend_algebraic[75] = "JteNa in component t_tubular_ion_fluxes (millimolar_per_second)"
legend_algebraic[79] = "JteCa in component t_tubular_ion_fluxes (millimolar_per_second)"
legend_algebraic[76] = "JteK in component t_tubular_ion_fluxes (millimolar_per_second)"
legend_constants[42] = "tauNa in component t_tubular_ion_fluxes (second)"
legend_constants[43] = "tauCa in component t_tubular_ion_fluxes (second)"
legend_constants[44] = "tauK in component t_tubular_ion_fluxes (second)"
legend_algebraic[80] = "JCaSRup in component JCaSRup (millimolar_per_second)"
legend_states[33] = "CaSRup in component CaSRup (millimolar)"
legend_algebraic[81] = "Jtr in component Jtr (millimolar_per_second)"
legend_constants[45] = "tautr in component Jtr (second)"
legend_states[34] = "CaSRrel in component CaSRrel (millimolar)"
legend_algebraic[82] = "JCaSRrel in component JCaSRrel (millimolar_per_second)"
legend_constants[52] = "kap in component JCaSRrel (per_millimolar4_per_second)"
legend_constants[46] = "kam in component JCaSRrel (per_second)"
legend_constants[53] = "kbp in component JCaSRrel (per_millimolar3_per_second)"
legend_constants[47] = "kbm in component JCaSRrel (per_second)"
legend_constants[48] = "kcp in component JCaSRrel (per_second)"
legend_constants[49] = "kcm in component JCaSRrel (per_second)"
legend_states[35] = "F1 in component JCaSRrel (dimensionless)"
legend_states[36] = "F2 in component JCaSRrel (dimensionless)"
legend_states[37] = "F3 in component JCaSRrel (dimensionless)"
legend_states[38] = "F4 in component JCaSRrel (dimensionless)"
legend_algebraic[83] = "JCad in component JCad (millimolar_per_second)"
legend_constants[50] = "taud in component JCad (second)"
legend_states[39] = "BTRH in component ion_concentrations (millimolar)"
legend_states[40] = "BTRL in component ion_concentrations (millimolar)"
legend_algebraic[84] = "dBTRH in component ion_concentrations (millimolar_per_second)"
legend_algebraic[85] = "dBTRL in component ion_concentrations (millimolar_per_second)"
legend_rates[4] = "d/dt m in component i_Nas_m_gate (dimensionless)"
legend_rates[5] = "d/dt h in component i_Nas_h_gate (dimensionless)"
legend_rates[8] = "d/dt m in component i_Nat_m_gate (dimensionless)"
legend_rates[9] = "d/dt h in component i_Nat_h_gate (dimensionless)"
legend_rates[11] = "d/dt C1 in component i_Cas (dimensionless)"
legend_rates[12] = "d/dt C2 in component i_Cas (dimensionless)"
legend_rates[10] = "d/dt Co in component i_Cas (dimensionless)"
legend_rates[13] = "d/dt Ccast in component i_Cas (dimensionless)"
legend_rates[17] = "d/dt C1 in component i_Cat (dimensionless)"
legend_rates[18] = "d/dt C2 in component i_Cat (dimensionless)"
legend_rates[16] = "d/dt Co in component i_Cat (dimensionless)"
legend_rates[19] = "d/dt Ccast in component i_Cat (dimensionless)"
legend_rates[21] = "d/dt rs in component i_Ktos_rs_gate (dimensionless)"
legend_rates[22] = "d/dt ss in component i_Ktos_ss_gate (dimensionless)"
legend_rates[23] = "d/dt sss in component i_Ktos_sss_gate (dimensionless)"
legend_rates[24] = "d/dt rt in component i_Ktot_rt_gate (dimensionless)"
legend_rates[25] = "d/dt st in component i_Ktot_st_gate (dimensionless)"
legend_rates[26] = "d/dt sst in component i_Ktot_sst_gate (dimensionless)"
legend_rates[27] = "d/dt rsts in component i_Ksts_rsts_gate (dimensionless)"
legend_rates[28] = "d/dt ssts in component i_Ksts_ssts_gate (dimensionless)"
legend_rates[29] = "d/dt rstt in component i_Kstt_rstt_gate (dimensionless)"
legend_rates[30] = "d/dt sstt in component i_Kstt_sstt_gate (dimensionless)"
legend_rates[31] = "d/dt qs in component i_Kfs_qs_gate (dimensionless)"
legend_rates[32] = "d/dt qt in component i_Kft_qt_gate (dimensionless)"
legend_rates[35] = "d/dt F1 in component JCaSRrel (dimensionless)"
legend_rates[36] = "d/dt F2 in component JCaSRrel (dimensionless)"
legend_rates[37] = "d/dt F3 in component JCaSRrel (dimensionless)"
legend_rates[38] = "d/dt F4 in component JCaSRrel (dimensionless)"
legend_rates[33] = "d/dt CaSRup in component CaSRup (millimolar)"
legend_rates[34] = "d/dt CaSRrel in component CaSRrel (millimolar)"
legend_rates[39] = "d/dt BTRH in component ion_concentrations (millimolar)"
legend_rates[40] = "d/dt BTRL in component ion_concentrations (millimolar)"
legend_rates[14] = "d/dt Cass in component ion_concentrations (millimolar)"
legend_rates[15] = "d/dt Cai in component ion_concentrations (millimolar)"
legend_rates[2] = "d/dt Nai in component ion_concentrations (millimolar)"
legend_rates[3] = "d/dt Ki in component ion_concentrations (millimolar)"
legend_rates[6] = "d/dt Nat in component ion_concentrations (millimolar)"
legend_rates[20] = "d/dt Cat in component ion_concentrations (millimolar)"
legend_rates[7] = "d/dt Kt in component ion_concentrations (millimolar)"
legend_rates[0] = "d/dt Vms in component Vms (millivolt)"
legend_rates[1] = "d/dt Vmt in component Vmt (millivolt)"
return (legend_states, legend_algebraic, legend_voi, legend_constants)
def initConsts():
constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
constants[0] = 8310
constants[1] = 295
constants[2] = 96500
constants[3] = 140
constants[4] = 1.2
constants[5] = 5.4
constants[6] = 83.33
constants[7] = 150e-7
constants[8] = 30000000
constants[9] = 0.0001
states[0] = -7.9709547e1
states[1] = -7.9709536e1
constants[10] = 0
constants[11] = 1
constants[12] = 0.001
constants[13] = 0.0052
constants[14] = 10
constants[15] = 0.56
constants[16] = 0.0145
constants[17] = 0.56
constants[18] = 0.07
constants[19] = 0.76
constants[20] = 0.24
constants[21] = 0.56
constants[22] = 0.00138
constants[23] = 0.56
constants[24] = 0.35
constants[25] = 0.56
constants[26] = 0.0008015
constants[27] = 0.56
constants[28] = 0.000648
constants[29] = 0.56
constants[30] = 0.00021
constants[31] = 0.87
constants[32] = 0.00018
constants[33] = 0.81
constants[34] = 1
constants[35] = 0.59
constants[36] = 0.85
constants[37] = 0.56
states[2] = 6.9435814e0
states[3] = 1.3753311e2
states[4] = 2.1832558e-6
states[5] = 5.8232781e-1
states[6] = 1.4001386e2
states[7] = 5.3627676e0
states[8] = 2.1832694e-6
states[9] = 5.8232717e-1
states[10] = 2.5436465e-6
states[11] = 9.9994546e-1
states[12] = 9.9994546e-1
constants[38] = 0.009
states[13] = 9.9570063e-1
states[14] = 4.3112114e-5
states[15] = 3.5486498e-5
states[16] = 2.543652e-6
states[17] = 9.9994546e-1
states[18] = 9.9994546e-1
constants[39] = 0.009
states[19] = 9.9570063e-1
states[20] = 1.2271399e0
states[21] = 2.3485072e-3
states[22] = 9.8315843e-1
states[23] = 6.748337e-1
states[24] = 2.3485094e-3
states[25] = 9.8315865e-1
states[26] = 6.7478532e-1
states[27] = 3.1079213e-3
states[28] = 3.0773393e-1
constants[40] = 2.1
states[29] = 3.1079241e-3
states[30] = 3.0773368e-1
constants[41] = 2.1
states[31] = 3.4357356e-3
states[32] = 3.4357175e-3
constants[42] = 0.15
constants[43] = 0.5
constants[44] = 0.15
states[33] = 2.2755058e-1
constants[45] = 0.03448
states[34] = 2.2638169e-1
constants[46] = 576
constants[47] = 1930
constants[48] = 18
constants[49] = 0.8
states[35] = 6.7606483e-1
states[36] = 3.8333331e-4
states[37] = 6.4516879e-11
states[38] = 3.2355462e-1
constants[50] = 0.003125
states[39] = 9.2804169e-1
states[40] = 3.4317829e-2
constants[51] = constants[9]/7850.00
constants[52] = 1.21500e+13
constants[53] = 4.05000e+09
constants[54] = constants[51]*7.50000e-05
constants[55] = constants[51]*0.00350000
constants[56] = constants[51]*0.585000
constants[57] = constants[51]*0.0315000
constants[58] = constants[9]-4400.00*constants[51]
constants[59] = constants[9]-constants[58]
constants[60] = constants[14]*(constants[58]+constants[59])*(1.00000-constants[15])
constants[61] = constants[30]*(constants[58]+constants[59])*(1.00000-constants[31])
constants[62] = constants[16]*(constants[58]+constants[59])*(1.00000-constants[17])
constants[63] = constants[18]*(constants[58]+constants[59])*(1.00000-constants[19])
constants[64] = constants[20]*(constants[58]+constants[59])*(1.00000-constants[21])
constants[65] = constants[22]*(constants[58]+constants[59])*(1.00000-constants[23])
constants[66] = constants[24]*(constants[58]+constants[59])*(1.00000-constants[25])
constants[67] = constants[26]*(constants[58]+constants[59])*(1.00000-constants[27])
constants[68] = constants[28]*(constants[58]+constants[59])*(1.00000-constants[29])
constants[69] = constants[36]*(constants[58]+constants[59])*(1.00000-constants[37])
constants[70] = constants[34]*(constants[58]+constants[59])*(1.00000-constants[35])
constants[71] = constants[32]*(constants[58]+constants[59])*(1.00000-constants[33])
constants[72] = constants[14]*(constants[58]+constants[59])*constants[15]
constants[73] = constants[30]*(constants[58]+constants[59])*constants[31]
constants[74] = constants[16]*(constants[58]+constants[59])*constants[17]
constants[75] = constants[18]*(constants[58]+constants[59])*constants[19]
constants[76] = constants[20]*(constants[58]+constants[59])*constants[21]
constants[77] = constants[22]*(constants[58]+constants[59])*constants[23]
constants[78] = constants[24]*(constants[58]+constants[59])*constants[25]
constants[79] = constants[26]*(constants[58]+constants[59])*constants[27]
constants[80] = constants[28]*(constants[58]+constants[59])*constants[29]
constants[81] = constants[36]*(constants[58]+constants[59])*constants[37]
constants[82] = constants[34]*(constants[58]+constants[59])*constants[35]
constants[83] = constants[32]*(constants[58]+constants[59])*constants[33]
constants[84] = constants[8]*constants[58]
constants[85] = constants[59]/(2.00000*3.14159*constants[7]*constants[84])
constants[86] = ((constants[6]*constants[85])/2.00000)/(3.14159*(power(constants[7], 2.00000))*constants[84])
constants[87] = 3.14159*(power(constants[7], 2.00000))*constants[85]*constants[84]
constants[88] = constants[59]*1.00000
constants[89] = constants[58]*1.00000
return (states, constants)
def computeRates(voi, states, constants):
rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
rates[35] = states[36]*constants[46]-states[35]*constants[52]*(power(states[14], 4.00000))
rates[36] = (states[35]*constants[52]*(power(states[14], 4.00000))+states[37]*constants[47]+states[38]*constants[49])-states[36]*(constants[46]+constants[53]*(power(states[14], 3.00000))+constants[48])
rates[37] = states[36]*constants[53]*(power(states[14], 3.00000))-states[37]*constants[47]
rates[38] = states[36]*constants[48]-states[38]*constants[49]
algebraic[5] = 1.00000/(1.00000+states[14]/0.0100000)
rates[13] = (algebraic[5]-states[13])/constants[38]
algebraic[8] = 1.00000/(1.00000+states[14]/0.0100000)
rates[19] = (algebraic[8]-states[19])/constants[39]
algebraic[17] = 1.00000/(1.00000+exp((states[0]+87.5000)/10.3000))
rates[28] = (algebraic[17]-states[28])/constants[40]
algebraic[19] = 1.00000/(1.00000+exp((states[1]+87.5000)/10.3000))
rates[30] = (algebraic[19]-states[30])/constants[41]
algebraic[0] = (117.260*(states[0]+59.3000))/(1.00000-exp(-0.550000*(states[0]+59.3000)))
algebraic[23] = 3800.00*exp(-0.0720000*(states[0]+61.0000))
rates[4] = algebraic[0]*(1.00000-states[4])-algebraic[23]*states[4]
algebraic[1] = 284.400/(1.00000+exp(0.0812000*(states[0]+115.900)))
algebraic[24] = (18.7700*(states[0]+64.4000))/(1.00000-exp(-0.220000*(states[0]+64.4000)))
rates[5] = algebraic[1]*(1.00000-states[5])-algebraic[24]*states[5]
algebraic[2] = (117.260*(states[1]+59.3000))/(1.00000-exp(-0.550000*(states[1]+59.3000)))
algebraic[25] = 3800.00*exp(-0.0720000*(states[1]+61.0000))
rates[8] = algebraic[2]*(1.00000-states[8])-algebraic[25]*states[8]
algebraic[3] = 284.400/(1.00000+exp(0.0812000*(states[1]+115.900)))
algebraic[26] = (18.7700*(states[1]+64.4000))/(1.00000-exp(-0.220000*(states[1]+64.4000)))
rates[9] = algebraic[3]*(1.00000-states[9])-algebraic[26]*states[9]
algebraic[28] = 0.105000*exp(-(power((states[0]+45.0000)/12.0000, 2.00000)))+0.0400000/(1.00000+exp((-states[0]+25.0000)/25.0000))+0.0150000/(1.00000+exp((states[0]+75.0000)/25.0000))
algebraic[6] = 1.00000/(1.00000+exp((states[0]+26.7000)/5.40000))
rates[11] = (algebraic[6]-states[11])/algebraic[28]
algebraic[27] = 0.000250000+0.00305000*exp(-0.00450000*(power(states[0]+7.00000, 2.00000)))+0.00105000*exp(-0.00200000*(power(states[0]-18.0000, 2.00000)))
algebraic[4] = 1.00000/(1.00000+exp(-(states[0]+15.3000)/5.00000))
rates[10] = (algebraic[4]-states[10])/algebraic[27]
algebraic[31] = 0.105000*exp(-(power((states[1]+45.0000)/12.0000, 2.00000)))+0.0400000/(1.00000+exp((-states[1]+25.0000)/25.0000))+0.0150000/(1.00000+exp((states[1]+75.0000)/25.0000))
algebraic[9] = 1.00000/(1.00000+exp((states[1]+26.7000)/5.40000))
rates[17] = (algebraic[9]-states[17])/algebraic[31]
algebraic[30] = 0.000250000+0.00305000*exp(-0.00450000*(power(states[1]+7.00000, 2.00000)))+0.00105000*exp(-0.00200000*(power(states[1]-18.0000, 2.00000)))
algebraic[7] = 1.00000/(1.00000+exp(-(states[1]+15.3000)/5.00000))
rates[16] = (algebraic[7]-states[16])/algebraic[30]
algebraic[33] = 1.00000/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000)))
algebraic[10] = 1.00000/(1.00000+exp((states[0]+10.6000)/-11.4200))
rates[21] = (algebraic[10]-states[21])/algebraic[33]
algebraic[34] = 0.350000*exp(-(power(0.0666000*(states[0]+70.0000), 2.00000)))+0.0350000
algebraic[11] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410))
rates[22] = (algebraic[11]-states[22])/algebraic[34]
algebraic[35] = 3.70000*exp(-(power(0.0333000*(states[0]+70.0000), 2.00000)))+0.0350000
algebraic[12] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410))
rates[23] = (algebraic[12]-states[23])/algebraic[35]
algebraic[36] = 1.00000/(45.1600*exp(0.0357700*(states[1]+50.0000))+98.9000*exp(-0.100000*(states[1]+38.0000)))
algebraic[13] = 1.00000/(1.00000+exp((states[1]+10.6000)/-11.4200))
rates[24] = (algebraic[13]-states[24])/algebraic[36]
algebraic[37] = 0.350000*exp(-(power(0.0666000*(states[1]+70.0000), 2.00000)))+0.0350000
algebraic[14] = 1.00000/(1.00000+exp((states[1]+45.3000)/6.88410))
rates[25] = (algebraic[14]-states[25])/algebraic[37]
algebraic[38] = 3.70000*exp(-(power(0.0333000*(states[1]+70.0000), 2.00000)))+0.0350000
algebraic[15] = 1.00000/(1.00000+exp((states[1]+45.3000)/6.88410))
rates[26] = (algebraic[15]-states[26])/algebraic[38]
algebraic[39] = 10.0000/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000)))
algebraic[16] = 1.00000/(1.00000+exp(-(states[0]+11.5000)/11.8200))
rates[27] = (algebraic[16]-states[27])/algebraic[39]
algebraic[40] = 10.0000/(45.1600*exp(0.0357700*(states[1]+50.0000))+98.9000*exp(-0.100000*(states[1]+38.0000)))
algebraic[18] = 1.00000/(1.00000+exp(-(states[1]+11.5000)/11.8200))
rates[29] = (algebraic[18]-states[29])/algebraic[40]
algebraic[41] = 1.00000/(0.118850*exp((states[0]+80.0000)/28.3700)+0.562300*exp(-(states[0]+80.0000)/14.1900))
algebraic[20] = 1.00000/(1.00000+exp((states[0]+138.600)/10.4800))
rates[31] = (algebraic[20]-states[31])/algebraic[41]
algebraic[42] = 1.00000/(0.118850*exp((states[1]+80.0000)/28.3700)+0.562300*exp(-(states[1]+80.0000)/14.1900))
algebraic[21] = 1.00000/(1.00000+exp((states[1]+138.600)/10.4800))
rates[32] = (algebraic[21]-states[32])/algebraic[42]
algebraic[44] = 0.0410000*exp(-(power((states[0]+47.0000)/12.0000, 2.00000)))+0.0800000/(1.00000+exp(-(states[0]+55.0000)/5.00000))+0.0150000/(1.00000+exp((states[0]+75.0000)/25.0000))
algebraic[29] = algebraic[6]
rates[12] = (algebraic[29]-states[12])/algebraic[44]
algebraic[45] = 0.0410000*exp(-(power((states[1]+47.0000)/12.0000, 2.00000)))+0.0800000/(1.00000+exp(-(states[1]+55.0000)/5.00000))+0.0150000/(1.00000+exp((states[1]+75.0000)/25.0000))
algebraic[32] = algebraic[9]
rates[18] = (algebraic[32]-states[18])/algebraic[45]
algebraic[48] = constants[60]*(power(states[4], 3.00000))*states[5]*(states[0]-(log((constants[3]+0.120000*constants[5])/(states[2]+0.120000*states[3]))*constants[0]*constants[1])/constants[2])
algebraic[50] = constants[72]*(power(states[8], 3.00000))*states[9]*(states[1]-(log((states[6]+0.120000*states[7])/(states[2]+0.120000*states[3]))*constants[0]*constants[1])/constants[2])
algebraic[47] = (log(constants[3]/states[2])*constants[0]*constants[1])/constants[2]
algebraic[65] = constants[67]*(states[0]-algebraic[47])
algebraic[49] = (log(states[6]/states[2])*constants[0]*constants[1])/constants[2]
algebraic[66] = constants[79]*(states[1]-algebraic[49])
algebraic[71] = (constants[71]*(exp(0.0187000*states[0])*(power(states[2], 3.00000))*constants[4]-exp(-0.0187000*states[0])*(power(constants[3], 3.00000))*states[15]))/(1.00000+0.000100000*((power(constants[3], 3.00000))*states[15]+(power(states[2], 3.00000))*constants[4]))
algebraic[72] = (constants[83]*(exp(0.0187000*states[1])*(power(states[2], 3.00000))*states[20]-exp(-0.0187000*states[1])*(power(states[6], 3.00000))*states[15]))/(1.00000+0.000100000*((power(states[6], 3.00000))*states[15]+(power(states[2], 3.00000))*states[20]))
algebraic[73] = ((((constants[70]/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+((0.0365000*1.00000)/7.00000)*(exp(constants[3]/67.3000)-1.00000)*exp((-states[0]*constants[2])/(constants[0]*constants[1]))))*1.00000)/(1.00000+power(10.0000/states[2], 1.50000)))*constants[5])/(constants[5]+1.50000)
algebraic[74] = ((((constants[82]/(1.00000+0.124500*exp((-0.100000*states[1]*constants[2])/(constants[0]*constants[1]))+((0.0365000*1.00000)/7.00000)*(exp(states[6]/67.3000)-1.00000)*exp((-states[1]*constants[2])/(constants[0]*constants[1]))))*1.00000)/(1.00000+power(10.0000/states[2], 1.50000)))*states[7])/(states[7]+1.50000)
rates[2] = -(algebraic[48]+algebraic[50]+algebraic[65]+algebraic[66]+3.00000*algebraic[71]+3.00000*algebraic[72]+3.00000*algebraic[73]+3.00000*algebraic[74])/(constants[2]*constants[56])
algebraic[43] = floor(voi/constants[11])*constants[11]
algebraic[46] = custom_piecewise([greater_equal(voi-algebraic[43] , constants[10]) & less_equal(voi-algebraic[43] , constants[10]+constants[12]), constants[13] , True, 0.00000])
algebraic[55] = (log(constants[5]/states[3])*constants[0]*constants[1])/constants[2]
algebraic[56] = constants[66]*states[21]*(0.886000*states[22]+0.114000*states[23])*(states[0]-algebraic[55])
algebraic[57] = (log(states[7]/states[3])*constants[0]*constants[1])/constants[2]
algebraic[58] = constants[78]*states[24]*(0.886000*states[25]+0.114000*states[26])*(states[1]-algebraic[57])
algebraic[59] = constants[63]*states[27]*states[28]*(states[0]-algebraic[55])
algebraic[60] = constants[75]*states[29]*states[30]*(states[1]-algebraic[57])
algebraic[61] = constants[62]*states[31]*(0.200000*(states[0]-algebraic[47])+0.800000*(states[0]-algebraic[55]))
algebraic[62] = constants[74]*states[32]*(0.200000*(states[1]-algebraic[49])+0.800000*(states[1]-algebraic[57]))
algebraic[63] = (constants[64]*((states[0]-algebraic[55])-1.73000))/(1.00000+exp(((1.61300*constants[2])/(constants[0]*constants[1]))*((states[0]-algebraic[55])-1.73000))*(1.00000+exp((constants[5]-0.998800)/-0.124000)))
algebraic[64] = (constants[76]*((states[1]-algebraic[57])-1.73000))/(1.00000+exp(((1.61300*constants[2])/(constants[0]*constants[1]))*((states[1]-algebraic[57])-1.73000))*(1.00000+exp((states[7]-0.998800)/-0.124000)))
algebraic[69] = constants[65]*(states[0]-algebraic[55])
algebraic[70] = constants[77]*(states[1]-algebraic[57])
rates[3] = -((((-algebraic[46]+algebraic[61]+algebraic[62]+algebraic[59]+algebraic[60]+algebraic[63]+algebraic[64]+algebraic[69]+algebraic[70])-2.00000*algebraic[73])-2.00000*algebraic[74])+algebraic[56]+algebraic[58])/(constants[2]*constants[56])
algebraic[75] = ((1.00000*constants[87])/constants[42])*(states[6]-constants[3])
rates[6] = ((algebraic[50]+algebraic[66]+3.00000*algebraic[72]+3.00000*algebraic[74])/constants[2]-1.00000*algebraic[75])/constants[87]
algebraic[76] = ((1.00000*constants[87])/constants[44])*(states[7]-constants[5])
rates[7] = ((((algebraic[62]+algebraic[60]+algebraic[64]+algebraic[70])-2.00000*algebraic[74])+algebraic[58])/constants[2]-1.00000*algebraic[76])/constants[87]
algebraic[22] = 1000.00*(states[1]/constants[86]-states[0]/constants[86])
algebraic[52] = ((((constants[61]*4.00000*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(states[14]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-0.341000*constants[4]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000))*states[10]*((0.900000+states[13]/10.0000)*states[11]+(0.100000-states[13]/10.0000)*states[12])
algebraic[51] = (log(constants[4]/states[15])*constants[0]*constants[1])/(2.00000*constants[2])
algebraic[67] = constants[68]*(states[0]-algebraic[51])
algebraic[77] = (constants[69]*states[15])/(0.000400000+states[15])
rates[0] = (1000.00*((algebraic[46]+algebraic[22])-(algebraic[48]+algebraic[52]+algebraic[56]+algebraic[59]+algebraic[61]+algebraic[63]+algebraic[65]+algebraic[67]+algebraic[69]+algebraic[73]+algebraic[71]+algebraic[77])))/constants[89]
algebraic[54] = ((((constants[73]*4.00000*states[1]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(states[14]*exp((2.00000*states[1]*constants[2])/(constants[0]*constants[1]))-0.341000*states[20]))/(exp((2.00000*states[1]*constants[2])/(constants[0]*constants[1]))-1.00000))*states[16]*((0.900000+states[19]/10.0000)*states[17]+(0.100000-states[19]/10.0000)*states[18])
algebraic[53] = (log(states[20]/states[15])*constants[0]*constants[1])/(2.00000*constants[2])
algebraic[68] = constants[80]*(states[1]-algebraic[53])
algebraic[78] = (constants[81]*states[15])/(0.000400000+states[15])
rates[1] = (1000.00*-(algebraic[22]+algebraic[50]+algebraic[54]+algebraic[58]+algebraic[60]+algebraic[62]+algebraic[64]+algebraic[66]+algebraic[68]+algebraic[70]+algebraic[74]+algebraic[72]+algebraic[78]))/constants[88]
algebraic[79] = ((1.00000*constants[87])/constants[43])*(states[20]-constants[4])
rates[20] = ((-2.00000*algebraic[72]+algebraic[54]+algebraic[68]+algebraic[78])/(2.00000*constants[2])-1.00000*algebraic[79])/constants[87]
algebraic[80] = (1.00000*constants[56]*(0.0400000*10.0000*(power(states[15]/0.000168000, 1.20000))-(0.900000*states[33])/3.29000))/(1.00000+power(states[15]/0.000168000, 1.20000)+states[33]/3.29000)
algebraic[81] = ((1.00000*constants[55])/constants[45])*(states[33]-states[34])
rates[33] = (algebraic[80]-algebraic[81])/(1.00000*constants[57])
algebraic[82] = 1800.00*constants[55]*(states[36]+states[37])*(states[34]-states[14])
rates[34] = ((1.00000/(1.00000+(15.0000*0.800000)/(power(0.800000+states[34], 2.00000))))*(algebraic[81]-algebraic[82]))/constants[55]
algebraic[83] = (1.00000*(states[14]-states[15])*constants[56])/constants[50]
rates[14] = (1.00000/(1.00000+(0.0500000*0.00238000)/(power(0.00238000+states[14], 2.00000))))*((-(algebraic[52]+algebraic[54])/(2.00000*constants[2]*constants[54])+(1.00000*algebraic[82])/constants[54])-(1.00000*algebraic[83])/constants[54])
algebraic[84] = 20000.0*states[15]*(1.00000-states[39])-0.0700000*states[39]
rates[39] = algebraic[84]
algebraic[85] = 40000.0*states[15]*(1.00000-states[40])-states[40]*40.0000
rates[40] = algebraic[85]
rates[15] = (1.00000/(1.00000+(0.0500000*0.00238000)/(power(0.00238000+states[15], 2.00000))))*((((-2.00000*(algebraic[71]+algebraic[72])+algebraic[67]+algebraic[68]+algebraic[77]+algebraic[78])/(-2.00000*constants[2]*constants[56])+(1.00000*(algebraic[83]-algebraic[80]))/constants[56])-algebraic[84]*0.140000)-algebraic[85]*0.0700000)
return(rates)
def computeAlgebraic(constants, states, voi):
algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
states = array(states)
voi = array(voi)
algebraic[5] = 1.00000/(1.00000+states[14]/0.0100000)
algebraic[8] = 1.00000/(1.00000+states[14]/0.0100000)
algebraic[17] = 1.00000/(1.00000+exp((states[0]+87.5000)/10.3000))
algebraic[19] = 1.00000/(1.00000+exp((states[1]+87.5000)/10.3000))
algebraic[0] = (117.260*(states[0]+59.3000))/(1.00000-exp(-0.550000*(states[0]+59.3000)))
algebraic[23] = 3800.00*exp(-0.0720000*(states[0]+61.0000))
algebraic[1] = 284.400/(1.00000+exp(0.0812000*(states[0]+115.900)))
algebraic[24] = (18.7700*(states[0]+64.4000))/(1.00000-exp(-0.220000*(states[0]+64.4000)))
algebraic[2] = (117.260*(states[1]+59.3000))/(1.00000-exp(-0.550000*(states[1]+59.3000)))
algebraic[25] = 3800.00*exp(-0.0720000*(states[1]+61.0000))
algebraic[3] = 284.400/(1.00000+exp(0.0812000*(states[1]+115.900)))
algebraic[26] = (18.7700*(states[1]+64.4000))/(1.00000-exp(-0.220000*(states[1]+64.4000)))
algebraic[28] = 0.105000*exp(-(power((states[0]+45.0000)/12.0000, 2.00000)))+0.0400000/(1.00000+exp((-states[0]+25.0000)/25.0000))+0.0150000/(1.00000+exp((states[0]+75.0000)/25.0000))
algebraic[6] = 1.00000/(1.00000+exp((states[0]+26.7000)/5.40000))
algebraic[27] = 0.000250000+0.00305000*exp(-0.00450000*(power(states[0]+7.00000, 2.00000)))+0.00105000*exp(-0.00200000*(power(states[0]-18.0000, 2.00000)))
algebraic[4] = 1.00000/(1.00000+exp(-(states[0]+15.3000)/5.00000))
algebraic[31] = 0.105000*exp(-(power((states[1]+45.0000)/12.0000, 2.00000)))+0.0400000/(1.00000+exp((-states[1]+25.0000)/25.0000))+0.0150000/(1.00000+exp((states[1]+75.0000)/25.0000))
algebraic[9] = 1.00000/(1.00000+exp((states[1]+26.7000)/5.40000))
algebraic[30] = 0.000250000+0.00305000*exp(-0.00450000*(power(states[1]+7.00000, 2.00000)))+0.00105000*exp(-0.00200000*(power(states[1]-18.0000, 2.00000)))
algebraic[7] = 1.00000/(1.00000+exp(-(states[1]+15.3000)/5.00000))
algebraic[33] = 1.00000/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000)))
algebraic[10] = 1.00000/(1.00000+exp((states[0]+10.6000)/-11.4200))
algebraic[34] = 0.350000*exp(-(power(0.0666000*(states[0]+70.0000), 2.00000)))+0.0350000
algebraic[11] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410))
algebraic[35] = 3.70000*exp(-(power(0.0333000*(states[0]+70.0000), 2.00000)))+0.0350000
algebraic[12] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410))
algebraic[36] = 1.00000/(45.1600*exp(0.0357700*(states[1]+50.0000))+98.9000*exp(-0.100000*(states[1]+38.0000)))
algebraic[13] = 1.00000/(1.00000+exp((states[1]+10.6000)/-11.4200))
algebraic[37] = 0.350000*exp(-(power(0.0666000*(states[1]+70.0000), 2.00000)))+0.0350000
algebraic[14] = 1.00000/(1.00000+exp((states[1]+45.3000)/6.88410))
algebraic[38] = 3.70000*exp(-(power(0.0333000*(states[1]+70.0000), 2.00000)))+0.0350000
algebraic[15] = 1.00000/(1.00000+exp((states[1]+45.3000)/6.88410))
algebraic[39] = 10.0000/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000)))
algebraic[16] = 1.00000/(1.00000+exp(-(states[0]+11.5000)/11.8200))
algebraic[40] = 10.0000/(45.1600*exp(0.0357700*(states[1]+50.0000))+98.9000*exp(-0.100000*(states[1]+38.0000)))
algebraic[18] = 1.00000/(1.00000+exp(-(states[1]+11.5000)/11.8200))
algebraic[41] = 1.00000/(0.118850*exp((states[0]+80.0000)/28.3700)+0.562300*exp(-(states[0]+80.0000)/14.1900))
algebraic[20] = 1.00000/(1.00000+exp((states[0]+138.600)/10.4800))
algebraic[42] = 1.00000/(0.118850*exp((states[1]+80.0000)/28.3700)+0.562300*exp(-(states[1]+80.0000)/14.1900))
algebraic[21] = 1.00000/(1.00000+exp((states[1]+138.600)/10.4800))
algebraic[44] = 0.0410000*exp(-(power((states[0]+47.0000)/12.0000, 2.00000)))+0.0800000/(1.00000+exp(-(states[0]+55.0000)/5.00000))+0.0150000/(1.00000+exp((states[0]+75.0000)/25.0000))
algebraic[29] = algebraic[6]
algebraic[45] = 0.0410000*exp(-(power((states[1]+47.0000)/12.0000, 2.00000)))+0.0800000/(1.00000+exp(-(states[1]+55.0000)/5.00000))+0.0150000/(1.00000+exp((states[1]+75.0000)/25.0000))
algebraic[32] = algebraic[9]
algebraic[48] = constants[60]*(power(states[4], 3.00000))*states[5]*(states[0]-(log((constants[3]+0.120000*constants[5])/(states[2]+0.120000*states[3]))*constants[0]*constants[1])/constants[2])
algebraic[50] = constants[72]*(power(states[8], 3.00000))*states[9]*(states[1]-(log((states[6]+0.120000*states[7])/(states[2]+0.120000*states[3]))*constants[0]*constants[1])/constants[2])
algebraic[47] = (log(constants[3]/states[2])*constants[0]*constants[1])/constants[2]
algebraic[65] = constants[67]*(states[0]-algebraic[47])
algebraic[49] = (log(states[6]/states[2])*constants[0]*constants[1])/constants[2]
algebraic[66] = constants[79]*(states[1]-algebraic[49])
algebraic[71] = (constants[71]*(exp(0.0187000*states[0])*(power(states[2], 3.00000))*constants[4]-exp(-0.0187000*states[0])*(power(constants[3], 3.00000))*states[15]))/(1.00000+0.000100000*((power(constants[3], 3.00000))*states[15]+(power(states[2], 3.00000))*constants[4]))
algebraic[72] = (constants[83]*(exp(0.0187000*states[1])*(power(states[2], 3.00000))*states[20]-exp(-0.0187000*states[1])*(power(states[6], 3.00000))*states[15]))/(1.00000+0.000100000*((power(states[6], 3.00000))*states[15]+(power(states[2], 3.00000))*states[20]))
algebraic[73] = ((((constants[70]/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+((0.0365000*1.00000)/7.00000)*(exp(constants[3]/67.3000)-1.00000)*exp((-states[0]*constants[2])/(constants[0]*constants[1]))))*1.00000)/(1.00000+power(10.0000/states[2], 1.50000)))*constants[5])/(constants[5]+1.50000)
algebraic[74] = ((((constants[82]/(1.00000+0.124500*exp((-0.100000*states[1]*constants[2])/(constants[0]*constants[1]))+((0.0365000*1.00000)/7.00000)*(exp(states[6]/67.3000)-1.00000)*exp((-states[1]*constants[2])/(constants[0]*constants[1]))))*1.00000)/(1.00000+power(10.0000/states[2], 1.50000)))*states[7])/(states[7]+1.50000)
algebraic[43] = floor(voi/constants[11])*constants[11]
algebraic[46] = custom_piecewise([greater_equal(voi-algebraic[43] , constants[10]) & less_equal(voi-algebraic[43] , constants[10]+constants[12]), constants[13] , True, 0.00000])
algebraic[55] = (log(constants[5]/states[3])*constants[0]*constants[1])/constants[2]
algebraic[56] = constants[66]*states[21]*(0.886000*states[22]+0.114000*states[23])*(states[0]-algebraic[55])
algebraic[57] = (log(states[7]/states[3])*constants[0]*constants[1])/constants[2]
algebraic[58] = constants[78]*states[24]*(0.886000*states[25]+0.114000*states[26])*(states[1]-algebraic[57])
algebraic[59] = constants[63]*states[27]*states[28]*(states[0]-algebraic[55])
algebraic[60] = constants[75]*states[29]*states[30]*(states[1]-algebraic[57])
algebraic[61] = constants[62]*states[31]*(0.200000*(states[0]-algebraic[47])+0.800000*(states[0]-algebraic[55]))
algebraic[62] = constants[74]*states[32]*(0.200000*(states[1]-algebraic[49])+0.800000*(states[1]-algebraic[57]))
algebraic[63] = (constants[64]*((states[0]-algebraic[55])-1.73000))/(1.00000+exp(((1.61300*constants[2])/(constants[0]*constants[1]))*((states[0]-algebraic[55])-1.73000))*(1.00000+exp((constants[5]-0.998800)/-0.124000)))
algebraic[64] = (constants[76]*((states[1]-algebraic[57])-1.73000))/(1.00000+exp(((1.61300*constants[2])/(constants[0]*constants[1]))*((states[1]-algebraic[57])-1.73000))*(1.00000+exp((states[7]-0.998800)/-0.124000)))
algebraic[69] = constants[65]*(states[0]-algebraic[55])
algebraic[70] = constants[77]*(states[1]-algebraic[57])
algebraic[75] = ((1.00000*constants[87])/constants[42])*(states[6]-constants[3])
algebraic[76] = ((1.00000*constants[87])/constants[44])*(states[7]-constants[5])
algebraic[22] = 1000.00*(states[1]/constants[86]-states[0]/constants[86])
algebraic[52] = ((((constants[61]*4.00000*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(states[14]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-0.341000*constants[4]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000))*states[10]*((0.900000+states[13]/10.0000)*states[11]+(0.100000-states[13]/10.0000)*states[12])
algebraic[51] = (log(constants[4]/states[15])*constants[0]*constants[1])/(2.00000*constants[2])
algebraic[67] = constants[68]*(states[0]-algebraic[51])
algebraic[77] = (constants[69]*states[15])/(0.000400000+states[15])
algebraic[54] = ((((constants[73]*4.00000*states[1]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(states[14]*exp((2.00000*states[1]*constants[2])/(constants[0]*constants[1]))-0.341000*states[20]))/(exp((2.00000*states[1]*constants[2])/(constants[0]*constants[1]))-1.00000))*states[16]*((0.900000+states[19]/10.0000)*states[17]+(0.100000-states[19]/10.0000)*states[18])
algebraic[53] = (log(states[20]/states[15])*constants[0]*constants[1])/(2.00000*constants[2])
algebraic[68] = constants[80]*(states[1]-algebraic[53])
algebraic[78] = (constants[81]*states[15])/(0.000400000+states[15])
algebraic[79] = ((1.00000*constants[87])/constants[43])*(states[20]-constants[4])
algebraic[80] = (1.00000*constants[56]*(0.0400000*10.0000*(power(states[15]/0.000168000, 1.20000))-(0.900000*states[33])/3.29000))/(1.00000+power(states[15]/0.000168000, 1.20000)+states[33]/3.29000)
algebraic[81] = ((1.00000*constants[55])/constants[45])*(states[33]-states[34])
algebraic[82] = 1800.00*constants[55]*(states[36]+states[37])*(states[34]-states[14])
algebraic[83] = (1.00000*(states[14]-states[15])*constants[56])/constants[50]
algebraic[84] = 20000.0*states[15]*(1.00000-states[39])-0.0700000*states[39]
algebraic[85] = 40000.0*states[15]*(1.00000-states[40])-states[40]*40.0000
return algebraic
def custom_piecewise(cases):
"""Compute result of a piecewise function"""
return select(cases[0::2],cases[1::2])
def solve_model():
"""Solve model with ODE solver"""
from scipy.integrate import ode
# Initialise constants and state variables
(init_states, constants) = initConsts()
# Set timespan to solve over
voi = linspace(0, 10, 500)
# Construct ODE object to solve
r = ode(computeRates)
r.set_integrator('vode', method='bdf', atol=1e-06, rtol=1e-06, max_step=1)
r.set_initial_value(init_states, voi[0])
r.set_f_params(constants)
# Solve model
states = array([[0.0] * len(voi)] * sizeStates)
states[:,0] = init_states
for (i,t) in enumerate(voi[1:]):
if r.successful():
r.integrate(t)
states[:,i+1] = r.y
else:
break
# Compute algebraic variables
algebraic = computeAlgebraic(constants, states, voi)
return (voi, states, algebraic)
def plot_model(voi, states, algebraic):
"""Plot variables against variable of integration"""
import pylab
(legend_states, legend_algebraic, legend_voi, legend_constants) = createLegends()
pylab.figure(1)
pylab.plot(voi,vstack((states,algebraic)).T)
pylab.xlabel(legend_voi)
pylab.legend(legend_states + legend_algebraic, loc='best')
pylab.show()
if __name__ == "__main__":
(voi, states, algebraic) = solve_model()
plot_model(voi, states, algebraic)
