# Size of variable arrays: sizeAlgebraic = 126 sizeStates = 41 sizeConstants = 126 from math import * from numpy import * def createLegends(): legend_states = [""] * sizeStates legend_rates = [""] * sizeStates legend_algebraic = [""] * sizeAlgebraic legend_voi = "" legend_constants = [""] * sizeConstants legend_constants[0] = "Bmax_CaM in component buffca (mM)" legend_constants[118] = "Bmax_SLhighjn in component buffca (mM)" legend_constants[122] = "Bmax_SLhighsl in component buffca (mM)" legend_constants[119] = "Bmax_SLlowjn in component buffca (mM)" legend_constants[123] = "Bmax_SLlowsl in component buffca (mM)" legend_constants[87] = "Bmax_SR in component buffca (mM)" legend_constants[1] = "Bmax_TnChigh in component buffca (mM)" legend_constants[2] = "Bmax_TnClow in component buffca (mM)" legend_constants[3] = "Bmax_myosin in component buffca (mM)" legend_states[0] = "CaM in component buffca (mM)" legend_states[1] = "Ca_i in component calcium (mM)" legend_states[2] = "Ca_jn in component calcium (mM)" legend_states[3] = "Ca_sl in component calcium (mM)" legend_algebraic[37] = "J_CaB_cytosol in component buffca (mM_per_ms)" legend_algebraic[35] = "J_CaB_jn in component buffca (mM_per_ms)" legend_algebraic[36] = "J_CaB_sl in component buffca (mM_per_ms)" legend_constants[4] = "Mg_i in component ion (mM)" legend_states[4] = "Myoc in component buffca (mM)" legend_states[5] = "Myom in component buffca (mM)" legend_states[6] = "SLH_jn in component buffca (mM)" legend_states[7] = "SLH_sl in component buffca (mM)" legend_states[8] = "SLL_jn in component buffca (mM)" legend_states[9] = "SLL_sl in component buffca (mM)" legend_states[10] = "SRB in component buffca (mM)" legend_states[11] = "TnCHc in component buffca (mM)" legend_states[12] = "TnCHm in component buffca (mM)" legend_states[13] = "TnCL in component buffca (mM)" legend_constants[113] = "Vjn in component geom (litre)" legend_constants[116] = "Vmyo in component geom (litre)" legend_constants[120] = "Vsl in component geom (litre)" legend_constants[5] = "koff_cam in component buffca (mS_per_uF)" legend_constants[6] = "koff_myoca in component buffca (mS_per_uF)" legend_constants[7] = "koff_myomg in component buffca (mS_per_uF)" legend_constants[8] = "koff_slh in component buffca (mS_per_uF)" legend_constants[9] = "koff_sll in component buffca (mS_per_uF)" legend_constants[10] = "koff_sr in component buffca (mS_per_uF)" legend_constants[11] = "koff_tnchca in component buffca (mS_per_uF)" legend_constants[12] = "koff_tnchmg in component buffca (mS_per_uF)" legend_constants[13] = "koff_tncl in component buffca (mS_per_uF)" legend_constants[14] = "kon_cam in component buffca (per_mM_per_ms)" legend_constants[15] = "kon_myoca in component buffca (per_mM_per_ms)" legend_constants[16] = "kon_myomg in component buffca (per_mM_per_ms)" legend_constants[17] = "kon_slh in component buffca (per_mM_per_ms)" legend_constants[18] = "kon_sll in component buffca (per_mM_per_ms)" legend_constants[19] = "kon_sr in component buffca (per_mM_per_ms)" legend_constants[20] = "kon_tnchca in component buffca (per_mM_per_ms)" legend_constants[21] = "kon_tnchmg in component buffca (per_mM_per_ms)" legend_constants[22] = "kon_tncl in component buffca (per_mM_per_ms)" legend_voi = "time in component engine (ms)" legend_constants[23] = "Bmax_Na_jn in component buffna (mM)" legend_constants[24] = "Bmax_Na_sl in component buffna (mM)" legend_states[14] = "NaB_jn in component buffna (mM)" legend_states[15] = "NaB_sl in component buffna (mM)" legend_states[16] = "Na_jn in component sodium (mM)" legend_states[17] = "Na_sl in component sodium (mM)" legend_constants[25] = "koff_na in component buffna (mS_per_uF)" legend_constants[26] = "kon_na in component buffna (per_mM_per_ms)" legend_constants[124] = "Bmax_Csqn in component calcium (mM)" legend_constants[27] = "C in component cell (farad)" legend_states[18] = "Ca_sr in component calcium (mM)" legend_states[19] = "Csqn in component calcium (mM)" legend_constants[28] = "F in component phys (C_per_mol)" legend_algebraic[87] = "ICaB_jn in component icab (A_per_F)" legend_algebraic[92] = "ICaB_sl in component icab (A_per_F)" legend_algebraic[39] = "ICaL_Ca_jn in component ical (A_per_F)" legend_algebraic[41] = "ICaL_Ca_sl in component ical (A_per_F)" legend_algebraic[88] = "ICa_tot_jn in component calcium (A_per_F)" legend_algebraic[95] = "ICa_tot_sl in component calcium (A_per_F)" legend_algebraic[70] = "INaCa_jn in component inaca (A_per_F)" legend_algebraic[74] = "INaCa_sl in component inaca (A_per_F)" legend_algebraic[81] = "IpCa_jn in component ipca (A_per_F)" legend_algebraic[83] = "IpCa_sl in component ipca (A_per_F)" legend_constants[90] = "JCa_jnsl in component calcium (m3_per_s)" legend_constants[91] = "JCa_slmyo in component calcium (m3_per_s)" legend_algebraic[89] = "J_SRCarel in component ryr (mM_per_ms)" legend_algebraic[91] = "J_SRleak in component ryr (mM_per_ms)" legend_algebraic[93] = "J_serca in component ryr (mM_per_ms)" legend_constants[121] = "Vsr in component geom (litre)" legend_constants[29] = "koff_csqn in component calcium (mS_per_uF)" legend_constants[30] = "kon_csqn in component calcium (per_mM_per_ms)" legend_constants[31] = "AF in component cell (dimensionless)" legend_constants[88] = "Vcell in component geom (litre)" legend_constants[32] = "cell_length in component geom (um)" legend_constants[33] = "cell_radius in component geom (um)" legend_constants[34] = "pi in component geom (dimensionless)" legend_algebraic[86] = "ECa_jn in component nernst (mV)" legend_algebraic[90] = "ECa_sl in component nernst (mV)" legend_constants[35] = "Fjn in component junc (dimensionless)" legend_constants[114] = "Fsl in component junc (dimensionless)" legend_algebraic[94] = "ICaB in component icab (A_per_F)" legend_states[20] = "V in component membrane (mV)" legend_constants[36] = "gCaB in component icab (mS_per_uF)" legend_constants[37] = "Ca_o in component ion (mM)" legend_constants[92] = "FRT in component phys (per_mV)" legend_constants[38] = "Fjn_CaL in component junc (dimensionless)" legend_constants[93] = "Fsl_CaL in component junc (dimensionless)" legend_algebraic[52] = "ICaL in component ical (A_per_F)" legend_algebraic[42] = "ICaL_Ca in component ical (A_per_F)" legend_algebraic[44] = "ICaL_K in component ical (A_per_F)" legend_algebraic[50] = "ICaL_Na in component ical (A_per_F)" legend_algebraic[46] = "ICaL_Na_jn in component ical (A_per_F)" legend_algebraic[48] = "ICaL_Na_sl in component ical (A_per_F)" legend_states[21] = "K_i in component potassium (mM)" legend_constants[39] = "K_o in component ion (mM)" legend_constants[40] = "Na_o in component ion (mM)" legend_constants[117] = "Q in component phys (dimensionless)" legend_constants[41] = "Q10CaL in component ical (dimensionless)" legend_states[22] = "d in component ical (mS_per_uF)" legend_states[23] = "f in component ical (mS_per_uF)" legend_states[24] = "fCaB_jn in component ical (mS_per_uF)" legend_states[25] = "fCaB_sl in component ical (mS_per_uF)" legend_constants[42] = "fcaCaMSL in component ical (dimensionless)" legend_constants[43] = "fcaCaj in component ical (dimensionless)" legend_algebraic[38] = "ibarca_jn in component ical (uA_per_cm2)" legend_algebraic[40] = "ibarca_sl in component ical (uA_per_cm2)" legend_algebraic[43] = "ibark in component ical (uA_per_cm2)" legend_algebraic[45] = "ibarna_jn in component ical (uA_per_cm2)" legend_algebraic[47] = "ibarna_sl in component ical (uA_per_cm2)" legend_algebraic[0] = "ical_d_inf in component ical (dimensionless)" legend_algebraic[14] = "ical_d_tau in component ical (ms)" legend_algebraic[1] = "ical_f_inf in component ical (dimensionless)" legend_algebraic[15] = "ical_f_tau in component ical (ms)" legend_constants[94] = "pCa in component ical (cm_per_s)" legend_constants[95] = "pK in component ical (cm_per_s)" legend_constants[96] = "pNa in component ical (cm_per_s)" legend_constants[115] = "ECl in component nernst (mV)" legend_algebraic[49] = "IClB in component iclb (A_per_F)" legend_constants[44] = "gClB in component iclb (mS_per_uF)" legend_algebraic[54] = "IClCa in component iclca (A_per_F)" legend_algebraic[51] = "IClCa_jn in component iclca (A_per_F)" legend_algebraic[53] = "IClCa_sl in component iclca (A_per_F)" legend_constants[45] = "KdClCa in component iclca (mM)" legend_constants[46] = "gClCa in component iclca (mS_per_uF)" legend_algebraic[97] = "EK in component nernst (mV)" legend_algebraic[101] = "IK1 in component ik1 (A_per_F)" legend_constants[47] = "IK1_Fact in component ik1 (dimensionless)" legend_algebraic[55] = "Na_observed in component ik1 (mM)" legend_algebraic[56] = "a_fact in component ik1 (dimensionless)" legend_constants[97] = "gK1 in component ik1 (mS_per_uF)" legend_algebraic[98] = "ik1_inf_a in component ik1 (mS_per_uF)" legend_algebraic[99] = "ik1_inf_b in component ik1 (mS_per_uF)" legend_algebraic[100] = "inf in component ik1 (dimensionless)" legend_constants[98] = "Act in component ikach (dimensionless)" legend_constants[48] = "CCh in component ikach (dimensionless)" legend_constants[49] = "Constitutive_Frac in component ikach (dimensionless)" legend_algebraic[102] = "IKACh in component ikach (A_per_F)" legend_algebraic[58] = "Na_dep in component ikach (dimensionless)" legend_algebraic[57] = "Na_observed in component ikach (mM)" legend_constants[99] = "gKACh in component ikach (mS_per_uF)" legend_algebraic[105] = "IKp in component ikp (A_per_F)" legend_algebraic[103] = "IKp_jn in component ikp (A_per_F)" legend_algebraic[104] = "IKp_sl in component ikp (A_per_F)" legend_constants[50] = "gKp in component ikp (mS_per_uF)" legend_algebraic[59] = "kp in component ikp (dimensionless)" legend_algebraic[106] = "IKr in component ikr (A_per_F)" legend_constants[100] = "gKr in component ikr (mS_per_uF)" legend_algebraic[2] = "ikr_x_inf in component ikr (dimensionless)" legend_algebraic[16] = "ikr_x_tau in component ikr (ms)" legend_algebraic[60] = "r in component ikr (dimensionless)" legend_states[26] = "x in component ikr (mS_per_uF)" legend_algebraic[61] = "EKs in component iks (mV)" legend_algebraic[64] = "IKs in component iks (A_per_F)" legend_algebraic[62] = "IKs_jn in component iks (A_per_F)" legend_algebraic[63] = "IKs_sl in component iks (A_per_F)" legend_states[27] = "Na_i in component sodium (mM)" legend_constants[101] = "gKs_jn in component iks (mS_per_uF)" legend_constants[102] = "gKs_sl in component iks (mS_per_uF)" legend_algebraic[3] = "iks_x_inf in component iks (dimensionless)" legend_algebraic[17] = "iks_x_tau in component iks (ms)" legend_constants[51] = "pNaK in component iks (dimensionless)" legend_states[28] = "x in component iks (mS_per_uF)" legend_algebraic[107] = "IKur in component ikur (A_per_F)" legend_constants[103] = "gKur in component ikur (mS_per_uF)" legend_algebraic[4] = "ikur_r_inf in component ikur (dimensionless)" legend_algebraic[18] = "ikur_r_tau in component ikur (ms)" legend_algebraic[5] = "ikur_s_inf in component ikur (dimensionless)" legend_algebraic[19] = "ikur_s_tau in component ikur (ms)" legend_states[29] = "r in component ikur (mS_per_uF)" legend_states[30] = "s in component ikur (mS_per_uF)" legend_algebraic[109] = "ENa_jn in component nernst (mV)" legend_algebraic[113] = "ENa_sl in component nernst (mV)" legend_algebraic[115] = "INa in component ina (A_per_F)" legend_algebraic[110] = "INa_jn in component ina (A_per_F)" legend_algebraic[114] = "INa_sl in component ina (A_per_F)" legend_constants[52] = "gNa in component ina (mS_per_uF)" legend_states[31] = "h in component ina (mS_per_uF)" legend_algebraic[6] = "ina_h_alpha in component ina (mS_per_uF)" legend_algebraic[20] = "ina_h_beta in component ina (mS_per_uF)" legend_algebraic[27] = "ina_h_inf in component ina (dimensionless)" legend_algebraic[31] = "ina_h_tau in component ina (ms)" legend_algebraic[7] = "ina_j_alpha in component ina (mS_per_uF)" legend_algebraic[21] = "ina_j_beta in component ina (mS_per_uF)" legend_algebraic[28] = "ina_j_inf in component ina (dimensionless)" legend_algebraic[32] = "ina_j_tau in component ina (ms)" legend_algebraic[8] = "ina_m_alpha in component ina (mS_per_uF)" legend_algebraic[22] = "ina_m_beta in component ina (mS_per_uF)" legend_algebraic[29] = "ina_m_inf in component ina (dimensionless)" legend_algebraic[33] = "ina_m_tau in component ina (ms)" legend_states[32] = "j in component ina (mS_per_uF)" legend_states[33] = "m in component ina (mS_per_uF)" legend_algebraic[117] = "INaB in component inab (A_per_F)" legend_algebraic[111] = "INaB_jn in component inab (A_per_F)" legend_algebraic[116] = "INaB_sl in component inab (A_per_F)" legend_constants[53] = "gNaB in component inab (mS_per_uF)" legend_algebraic[76] = "INaCa in component inaca (A_per_F)" legend_constants[104] = "IbarNCX in component inaca (A_per_F)" legend_algebraic[65] = "Ka_jn in component inaca (dimensionless)" legend_algebraic[66] = "Ka_sl in component inaca (dimensionless)" legend_constants[54] = "Kdact in component inaca (mM)" legend_constants[55] = "KmCai in component inaca (mM)" legend_constants[56] = "KmCao in component inaca (mM)" legend_constants[57] = "KmNai in component inaca (mM)" legend_constants[58] = "KmNao in component inaca (mM)" legend_constants[59] = "Q10NCX in component inaca (dimensionless)" legend_algebraic[67] = "inaca_INaCa_jn_s1 in component inaca (mol4_per_m12)" legend_algebraic[68] = "inaca_INaCa_jn_s2 in component inaca (mol4_per_m12)" legend_algebraic[69] = "inaca_INaCa_jn_s3 in component inaca (mol4_per_m12)" legend_algebraic[71] = "inaca_INaCa_sl_s1 in component inaca (mol4_per_m12)" legend_algebraic[72] = "inaca_INaCa_sl_s2 in component inaca (mol4_per_m12)" legend_algebraic[73] = "inaca_INaCa_sl_s3 in component inaca (mol4_per_m12)" legend_constants[60] = "ksat in component inaca (dimensionless)" legend_constants[61] = "nu in component inaca (dimensionless)" legend_algebraic[79] = "INaK in component inak (A_per_F)" legend_algebraic[77] = "INaK_jn in component inak (A_per_F)" legend_algebraic[78] = "INaK_sl in component inak (A_per_F)" legend_constants[62] = "IbarNaK in component inak (A_per_F)" legend_constants[63] = "KmKo in component inak (mM)" legend_constants[64] = "KmNaip in component inak (mM)" legend_algebraic[75] = "fnak in component inak (dimensionless)" legend_constants[105] = "sigma in component inak (dimensionless)" legend_algebraic[119] = "INaL in component inal (A_per_F)" legend_algebraic[112] = "INaL_jn in component inal (A_per_F)" legend_algebraic[118] = "INaL_sl in component inal (A_per_F)" legend_constants[106] = "gNaL in component inal (mS_per_uF)" legend_states[34] = "hl in component inal (mS_per_uF)" legend_algebraic[9] = "inal_hl_inf in component inal (dimensionless)" legend_constants[65] = "inal_hl_tau in component inal (ms)" legend_algebraic[10] = "inal_ml_a in component inal (mS_per_uF)" legend_algebraic[23] = "inal_ml_b in component inal (mS_per_uF)" legend_states[35] = "ml in component inal (mS_per_uF)" legend_constants[66] = "Cl_i in component ion (mM)" legend_constants[67] = "Cl_o in component ion (mM)" legend_constants[68] = "IbarSLCaP in component ipca (A_per_F)" legend_algebraic[85] = "IpCa in component ipca (A_per_F)" legend_constants[69] = "KmPCa in component ipca (mM)" legend_constants[70] = "Q10SLCaP in component ipca (dimensionless)" legend_constants[89] = "b in component ipca (dimensionless)" legend_algebraic[80] = "ipca_IpCa_jn_a in component ipca (dimensionless)" legend_algebraic[82] = "ipca_IpCa_sl_a in component ipca (dimensionless)" legend_algebraic[108] = "Ito in component ito (A_per_F)" legend_constants[107] = "gto in component ito (mS_per_uF)" legend_algebraic[11] = "ito_x_inf in component ito (dimensionless)" legend_algebraic[24] = "ito_x_tau in component ito (ms)" legend_algebraic[12] = "ito_y_inf in component ito (dimensionless)" legend_algebraic[25] = "ito_y_tau in component ito (ms)" legend_states[36] = "x in component ito (mS_per_uF)" legend_states[37] = "y in component ito (mS_per_uF)" legend_algebraic[96] = "ICa_tot in component membrane (A_per_F)" legend_algebraic[84] = "ICl_tot in component membrane (A_per_F)" legend_algebraic[120] = "IK_tot in component potassium (A_per_F)" legend_algebraic[123] = "INa_tot in component membrane (A_per_F)" legend_algebraic[121] = "INa_tot_jn in component sodium (A_per_F)" legend_algebraic[122] = "INa_tot_sl in component sodium (A_per_F)" legend_algebraic[125] = "I_stim in component stimulus (A_per_F)" legend_algebraic[124] = "I_tot in component membrane (A_per_F)" legend_constants[71] = "R in component phys (mJ_per_mol_per_K)" legend_constants[72] = "T in component phys (kelvin)" legend_constants[108] = "Kmf in component ryr (mM)" legend_constants[73] = "Kmr in component ryr (mM)" legend_constants[74] = "MaxSR in component ryr (dimensionless)" legend_constants[75] = "MinSR in component ryr (dimensionless)" legend_constants[76] = "Q10SRCaP in component ryr (dimensionless)" legend_algebraic[13] = "RI in component ryr (dimensionless)" legend_constants[77] = "Vmax_SRCaP in component ryr (mM_per_ms)" legend_constants[78] = "ec50SR in component ryr (mM)" legend_constants[79] = "hillSRCaP in component ryr (dimensionless)" legend_states[38] = "i in component ryr (mS_per_uF)" legend_algebraic[26] = "kCaSR in component ryr (dimensionless)" legend_constants[80] = "kiCa in component ryr (per_mM_per_ms)" legend_algebraic[30] = "kiSRCa in component ryr (per_mM_per_ms)" legend_constants[81] = "kim in component ryr (mS_per_uF)" legend_constants[109] = "koCa in component ryr (per_mM2_per_ms)" legend_algebraic[34] = "koSRCa in component ryr (per_mM2_per_ms)" legend_constants[82] = "kom in component ryr (mS_per_uF)" legend_constants[83] = "ks in component ryr (mS_per_uF)" legend_states[39] = "o in component ryr (mS_per_uF)" legend_states[40] = "r in component ryr (mS_per_uF)" legend_constants[110] = "JNa_jnsl in component sodium (m3_per_s)" legend_constants[111] = "JNa_slmyo in component sodium (m3_per_s)" legend_constants[112] = "amplitude in component stimulus (A_per_F)" legend_constants[84] = "duration in component stimulus (ms)" legend_constants[85] = "offset in component stimulus (ms)" legend_constants[86] = "period in component stimulus (ms)" legend_rates[0] = "d/dt CaM in component buffca (mM)" legend_rates[13] = "d/dt TnCL in component buffca (mM)" legend_rates[11] = "d/dt TnCHc in component buffca (mM)" legend_rates[12] = "d/dt TnCHm in component buffca (mM)" legend_rates[4] = "d/dt Myoc in component buffca (mM)" legend_rates[5] = "d/dt Myom in component buffca (mM)" legend_rates[10] = "d/dt SRB in component buffca (mM)" legend_rates[8] = "d/dt SLL_jn in component buffca (mM)" legend_rates[6] = "d/dt SLH_jn in component buffca (mM)" legend_rates[9] = "d/dt SLL_sl in component buffca (mM)" legend_rates[7] = "d/dt SLH_sl in component buffca (mM)" legend_rates[14] = "d/dt NaB_jn in component buffna (mM)" legend_rates[15] = "d/dt NaB_sl in component buffna (mM)" legend_rates[1] = "d/dt Ca_i in component calcium (mM)" legend_rates[2] = "d/dt Ca_jn in component calcium (mM)" legend_rates[3] = "d/dt Ca_sl in component calcium (mM)" legend_rates[18] = "d/dt Ca_sr in component calcium (mM)" legend_rates[19] = "d/dt Csqn in component calcium (mM)" legend_rates[22] = "d/dt d in component ical (mS_per_uF)" legend_rates[23] = "d/dt f in component ical (mS_per_uF)" legend_rates[24] = "d/dt fCaB_jn in component ical (mS_per_uF)" legend_rates[25] = "d/dt fCaB_sl in component ical (mS_per_uF)" legend_rates[26] = "d/dt x in component ikr (mS_per_uF)" legend_rates[28] = "d/dt x in component iks (mS_per_uF)" legend_rates[29] = "d/dt r in component ikur (mS_per_uF)" legend_rates[30] = "d/dt s in component ikur (mS_per_uF)" legend_rates[31] = "d/dt h in component ina (mS_per_uF)" legend_rates[32] = "d/dt j in component ina (mS_per_uF)" legend_rates[33] = "d/dt m in component ina (mS_per_uF)" legend_rates[34] = "d/dt hl in component inal (mS_per_uF)" legend_rates[35] = "d/dt ml in component inal (mS_per_uF)" legend_rates[36] = "d/dt x in component ito (mS_per_uF)" legend_rates[37] = "d/dt y in component ito (mS_per_uF)" legend_rates[20] = "d/dt V in component membrane (mV)" legend_rates[21] = "d/dt K_i in component potassium (mM)" legend_rates[38] = "d/dt i in component ryr (mS_per_uF)" legend_rates[39] = "d/dt o in component ryr (mS_per_uF)" legend_rates[40] = "d/dt r in component ryr (mS_per_uF)" legend_rates[27] = "d/dt Na_i in component sodium (mM)" legend_rates[16] = "d/dt Na_jn in component sodium (mM)" legend_rates[17] = "d/dt Na_sl in component sodium (mM)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; constants[0] = 0.024 constants[1] = 0.14 constants[2] = 0.07 constants[3] = 0.14 states[0] = 6.73710089221736985e-04 states[1] = 2.02054825252250719e-04 states[2] = 3.07333085373605341e-04 states[3] = 2.23134214147860355e-04 constants[4] = 1.0 states[4] = 3.79608844523014136e-03 states[5] = 1.35691489581683838e-01 states[6] = 1.00754933940878755e-01 states[7] = 1.86055242143676608e-01 states[8] = 1.28122161143722785e-02 states[9] = 2.05131045874987414e-02 states[10] = 4.31383413366585346e-03 states[11] = 1.27405935029765827e-01 states[12] = 5.91106798633337510e-03 states[13] = 1.77305527980331397e-02 constants[5] = 0.238 constants[6] = 0.00046 constants[7] = 5.7e-05 constants[8] = 0.03 constants[9] = 1.3 constants[10] = 0.06 constants[11] = 3.2e-05 constants[12] = 0.00333 constants[13] = 0.0196 constants[14] = 34.0 constants[15] = 13.8 constants[16] = 0.0157 constants[17] = 100.0 constants[18] = 100.0 constants[19] = 100.0 constants[20] = 2.37 constants[21] = 0.003 constants[22] = 32.7 constants[23] = 7.561 constants[24] = 1.65 states[14] = 3.62527560419928152e+00 states[15] = 7.91087217252140484e-01 states[16] = 9.20484970072274145e+00 states[17] = 9.20559631626608166e+00 constants[25] = 0.001 constants[26] = 0.0001 constants[27] = 1.381e-10 states[18] = 4.85784491491899340e-01 states[19] = 1.11204132576763315e+00 constants[28] = 96485.0 constants[29] = 65.0 constants[30] = 100.0 constants[31] = 0.0 constants[32] = 100.0 constants[33] = 10.25 constants[34] = 3.14159265358979312e+00 constants[35] = 0.11 states[20] = -7.49738877185916408e+01 constants[36] = 6.06430000000000033e-04 constants[37] = 1.8 constants[38] = 0.9 states[21] = 120.0 constants[39] = 5.4 constants[40] = 140.0 constants[41] = 1.8 states[22] = 1.67750282273476489e-05 states[23] = 9.98760022198537767e-01 states[24] = 4.24066845471226944e-02 states[25] = 3.13717989771996886e-02 constants[42] = 0.0 constants[43] = 0.0 constants[44] = 0.009 constants[45] = 0.1 constants[46] = 0.0548 constants[47] = 2.1 constants[48] = 0.0 constants[49] = 0.0 constants[50] = 0.002 states[26] = 4.42405976310802831e-03 states[27] = 9.20582356442186978e+00 constants[51] = 0.01833 states[28] = 6.73017121702351208e-03 states[29] = 3.28872423495696863e-04 states[30] = 9.62950458643225149e-01 constants[52] = 23.0 states[31] = 8.70955463748630310e-01 states[32] = 8.92501441492474679e-01 states[33] = 7.97426794491632243e-03 constants[53] = 0.000597 constants[54] = 0.000384 constants[55] = 0.00359 constants[56] = 1.3 constants[57] = 12.29 constants[58] = 87.5 constants[59] = 1.57 constants[60] = 0.27 constants[61] = 0.35 constants[62] = 1.26 constants[63] = 1.5 constants[64] = 11.0 states[34] = 5.18117114324953484e-02 constants[65] = 600.0 states[35] = 7.97426794490581868e-03 constants[66] = 15.0 constants[67] = 150.0 constants[68] = 0.0471 constants[69] = 0.0005 constants[70] = 2.35 states[36] = 1.19930453889315167e-03 states[37] = 9.52396284498915668e-01 constants[71] = 8314.0 constants[72] = 310.0 constants[73] = 1.7 constants[74] = 15.0 constants[75] = 1.0 constants[76] = 2.6 constants[77] = 0.0053114 constants[78] = 0.45 constants[79] = 1.787 states[38] = 4.16351235655844508e-07 constants[80] = 0.5 constants[81] = 0.005 constants[82] = 0.06 constants[83] = 25.0 states[39] = 1.73377710603823675e-06 states[40] = 8.06359263514647706e-01 constants[84] = 0.5 constants[85] = 50.0 constants[86] = 1000.0 constants[87] = 19.0000*0.000900000 constants[88] = ((constants[34]*(power(constants[33], 2.00000)))*constants[32])*1.00000e-15 constants[89] = power(constants[69]*1.00000, 1.60000) constants[90] = 1.00000/1.21340e+12 constants[91] = 1.00000/2.68510e+11 constants[92] = (constants[28]/constants[71])/constants[72] constants[93] = 1.00000-constants[38] constants[94] = (1.00000-0.500000*constants[31])*0.000270000 constants[95] = (1.00000-0.500000*constants[31])*1.35000e-07 constants[96] = (1.00000-0.500000*constants[31])*7.50000e-09 constants[97] = ((1.00000+constants[31])*(power(constants[39]/5.40000, 1.0/2)))*0.0525000 constants[98] = constants[49]+((1.00000-constants[49])*constants[48])/(constants[48]+0.125000) constants[99] = 0.100000-0.0500000*constants[31] constants[100] = 0.0350000*(power(constants[39]/5.40000, 1.0/2)) constants[101] = (1.00000+constants[31])*0.00350000 constants[102] = (1.00000+constants[31])*0.00350000 constants[103] = (1.00000-0.500000*constants[31])*0.0450000 constants[104] = (1.00000+0.400000*constants[31])*3.15000 constants[105] = (exp(constants[40]/67.3000)-1.00000)/7.00000 constants[106] = 0.00250000*constants[31] constants[107] = (1.00000-0.700000*constants[31])*0.165000 constants[108] = 2.50000*0.000246000 constants[109] = (10.0000+20.0000*constants[31])*1.00000 constants[110] = 1.00000/((1.63820e+12/3.00000)*100.000) constants[111] = 1.00000/((1.83080e+10/3.00000)*100.000) constants[112] = -90.0000 constants[125] = 0.00000 constants[113] = (0.0539000*0.0100000)*constants[88] constants[114] = 1.00000-constants[35] constants[115] = (1.00000/constants[92])*log(constants[66]/constants[67]) constants[116] = 0.650000*constants[88] constants[117] = (constants[72]-310.000)/10.0000 constants[118] = ((0.00165000*constants[116])/constants[113])*0.100000 constants[119] = ((0.00460000*constants[116])/constants[113])*0.100000 constants[120] = 0.0200000*constants[88] constants[121] = 0.0350000*constants[88] constants[122] = (constants[116]/constants[120])*0.0134000 constants[123] = (constants[116]/constants[120])*0.0374000 constants[124] = (constants[116]/constants[121])*0.140000 return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic rates[21] = constants[125] rates[0] = (constants[14]*states[1])*(constants[0]-states[0])-constants[5]*states[0] rates[24] = ((1.70000*states[2])*(1.00000-states[24])-0.0119000*states[24])*1.00000 rates[25] = ((1.70000*states[3])*(1.00000-states[25])-0.0119000*states[25])*1.00000 rates[27] = (constants[111]/constants[116])*(states[17]-states[27]) rates[4] = (constants[15]*states[1])*((constants[3]-states[4])-states[5])-constants[6]*states[4] algebraic[9] = 1.00000/(1.00000+exp((states[20]+91.0000)/6.10000)) rates[34] = (algebraic[9]-states[34])/constants[65] rates[5] = (constants[16]*constants[4])*((constants[3]-states[4])-states[5])-constants[7]*states[5] algebraic[0] = 1.00000/(1.00000+exp(-(states[20]+9.00000)/6.00000)) algebraic[14] = (algebraic[0]*(1.00000-exp(-(states[20]+9.00000)/6.00000)))/(0.0350000*(states[20]+9.00000)) rates[22] = (algebraic[0]-states[22])/algebraic[14] algebraic[1] = 1.00000/(1.00000+exp((states[20]+30.0000)/7.00000))+0.200000/(1.00000+exp((50.0000-states[20])/20.0000)) algebraic[15] = 1.00000/(0.0197000*exp(-(power(0.0337000*(states[20]+25.0000), 2.00000)))+0.0200000) rates[23] = (algebraic[1]-states[23])/algebraic[15] algebraic[2] = 1.00000/(1.00000+exp(-(states[20]+10.0000)/5.00000)) algebraic[16] = (((550.000)/(1.00000+exp((-22.0000-states[20])/9.00000)))*6.00000)/(1.00000+exp((states[20]+11.0000)/9.00000))+230.000/(1.00000+exp((states[20]+40.0000)/20.0000)) rates[26] = (algebraic[2]-states[26])/algebraic[16] algebraic[3] = 1.00000/(1.00000+exp(-(states[20]+3.80000)/14.2500)) algebraic[17] = 990.100/(1.00000+exp(-(states[20]+2.43600)/14.1200)) rates[28] = (algebraic[3]-states[28])/algebraic[17] algebraic[4] = 1.00000/(1.00000+exp((states[20]+6.00000)/-8.60000)) algebraic[18] = 9.00000/(1.00000+exp((states[20]+5.00000)/12.0000))+0.500000 rates[29] = (algebraic[4]-states[29])/algebraic[18] algebraic[5] = 1.00000/(1.00000+exp((states[20]+7.50000)/10.0000)) algebraic[19] = 590.000/(1.00000+exp((states[20]+60.0000)/10.0000))+3050.00 rates[30] = (algebraic[5]-states[30])/algebraic[19] algebraic[10] = (0.320000*(states[20]+47.1300))/(1.00000-exp(-0.100000*(states[20]+47.1300))) algebraic[23] = 0.0800000*exp(-states[20]/11.0000) rates[35] = algebraic[10]*(1.00000-states[35])-algebraic[23]*states[35] algebraic[11] = 1.00000/(1.00000+exp(-(states[20]+1.00000)/11.0000)) algebraic[24] = 3.50000*exp(-(power(states[20]/30.0000, 2.00000)))+1.50000 rates[36] = (algebraic[11]-states[36])/algebraic[24] algebraic[12] = 1.00000/(1.00000+exp((states[20]+40.5000)/11.5000)) algebraic[25] = 25.6350*exp(-(power((states[20]+52.4500)/15.8827, 2.00000)))+24.1400 rates[37] = (algebraic[12]-states[37])/algebraic[25] rates[6] = (constants[17]*states[2])*(constants[118]-states[6])-constants[8]*states[6] rates[7] = (constants[17]*states[3])*(constants[122]-states[7])-constants[8]*states[7] algebraic[6] = custom_piecewise([less(states[20] , -40.0000), 0.135000*exp((states[20]+80.0000)/-6.80000) , True, 0.00000]) algebraic[20] = custom_piecewise([less(states[20] , -40.0000), 3.56000*exp(0.0790000*states[20])+310000.*exp(0.350000*states[20]) , True, 1.00000/(0.130000*(1.00000+exp((states[20]+10.6600)/-11.1000)))]) algebraic[27] = algebraic[6]/(algebraic[6]+algebraic[20]) algebraic[31] = 1.00000/(algebraic[6]+algebraic[20]) rates[31] = (algebraic[27]-states[31])/algebraic[31] algebraic[7] = custom_piecewise([less(states[20] , -40.0000), ((-127140.*exp(0.244400*states[20])-3.47400e-05*exp(-0.0439100*states[20]))*(states[20]+37.7800))/(1.00000+exp(0.311000*(states[20]+79.2300))) , True, 0.00000]) algebraic[21] = custom_piecewise([less(states[20] , -40.0000), (0.121200*exp(-0.0105200*states[20]))/(1.00000+exp(-0.137800*(states[20]+40.1400))) , True, (0.300000*exp(-2.53500e-07*states[20]))/(1.00000+exp(-0.100000*(states[20]+32.0000)))]) algebraic[28] = algebraic[7]/(algebraic[7]+algebraic[21]) algebraic[32] = 1.00000/(algebraic[7]+algebraic[21]) rates[32] = (algebraic[28]-states[32])/algebraic[32] algebraic[8] = custom_piecewise([equal(states[20] , -47.1300), 3.20000 , True, (0.320000*(states[20]+47.1300))/(1.00000-exp(-0.100000*(states[20]+47.1300)))]) algebraic[22] = 0.0800000*exp(-states[20]/11.0000) algebraic[29] = algebraic[8]/(algebraic[8]+algebraic[22]) algebraic[33] = 1.00000/(algebraic[8]+algebraic[22]) rates[33] = (algebraic[29]-states[33])/algebraic[33] algebraic[13] = ((1.00000-states[40])-states[39])-states[38] algebraic[26] = constants[74]-(constants[74]-constants[75])/(1.00000+power(constants[78]/states[18], 2.50000)) algebraic[30] = constants[80]*algebraic[26] algebraic[34] = constants[109]/algebraic[26] rates[38] = ((algebraic[30]*states[2])*states[39]-constants[81]*states[38])-(constants[82]*states[38]-(algebraic[34]*(power(states[2], 2.00000)))*algebraic[13]) rates[39] = ((algebraic[34]*(power(states[2], 2.00000)))*states[40]-constants[82]*states[39])-((algebraic[30]*states[2])*states[39]-constants[81]*states[38]) rates[40] = (constants[81]*algebraic[13]-(algebraic[30]*states[2])*states[40])-((algebraic[34]*(power(states[2], 2.00000)))*states[40]-constants[82]*states[39]) rates[8] = (constants[18]*states[2])*(constants[119]-states[8])-constants[9]*states[8] rates[9] = (constants[18]*states[3])*(constants[123]-states[9])-constants[9]*states[9] rates[10] = (constants[19]*states[1])*(constants[87]-states[10])-constants[10]*states[10] rates[11] = (constants[20]*states[1])*((constants[1]-states[11])-states[12])-constants[11]*states[11] rates[12] = (constants[21]*constants[4])*((constants[1]-states[11])-states[12])-constants[12]*states[12] rates[13] = (constants[22]*states[1])*(constants[2]-states[13])-constants[13]*states[13] rates[14] = (constants[26]*states[16])*(constants[23]-states[14])-constants[25]*states[14] rates[15] = (constants[26]*states[17])*(constants[24]-states[15])-constants[25]*states[15] rates[19] = (constants[30]*states[18])*(constants[124]-states[19])-constants[29]*states[19] algebraic[35] = rates[8]+rates[6] algebraic[86] = ((1.00000/constants[92])/2.00000)*log(constants[37]/states[2]) algebraic[87] = (constants[35]*constants[36])*(states[20]-algebraic[86]) algebraic[38] = (((((constants[94]*4.00000)*states[20])*constants[28])*constants[92])*((0.341000*states[2])*exp((2.00000*states[20])*constants[92])-0.341000*constants[37]))/(exp((2.00000*states[20])*constants[92])-1.00000) algebraic[39] = (((((constants[38]*algebraic[38])*states[22])*states[23])*((1.00000-states[24])+constants[43]))*(power(constants[41], constants[117])))*0.450000 algebraic[65] = 1.00000/(1.00000+power(constants[54]/states[2], 2.00000)) algebraic[67] = (exp((constants[61]*states[20])*constants[92])*(power(states[16], 3.00000)))*constants[37] algebraic[68] = (exp(((constants[61]-1.00000)*states[20])*constants[92])*(power(constants[40], 3.00000)))*states[2] algebraic[69] = ((((constants[55]*(power(constants[40], 3.00000)))*(1.00000+power(states[16]/constants[57], 3.00000))+((power(constants[58], 3.00000))*states[2])*(1.00000+states[2]/constants[55]))+constants[56]*(power(states[16], 3.00000)))+(power(states[16], 3.00000))*constants[37])+(power(constants[40], 3.00000))*states[2] algebraic[70] = (((((constants[35]*constants[104])*(power(constants[59], constants[117])))*algebraic[65])*(algebraic[67]-algebraic[68]))/algebraic[69])/(1.00000+constants[60]*exp(((constants[61]-1.00000)*states[20])*constants[92])) algebraic[80] = power(states[2]*1.00000, 1.60000) algebraic[81] = (((constants[35]*(power(constants[70], constants[117])))*constants[68])*algebraic[80])/(algebraic[80]+constants[89]) algebraic[88] = ((algebraic[39]+algebraic[87])+algebraic[81])-2.00000*algebraic[70] algebraic[89] = (constants[83]*states[39])*(states[18]-states[2]) algebraic[91] = ((1.00000+0.250000*constants[31])*(states[18]-states[2]))*5.34800e-06 rates[2] = ((((-algebraic[88]*constants[27])/((constants[113]*2.00000)*constants[28])+(constants[90]/constants[113])*(states[3]-states[2]))-algebraic[35])+(algebraic[89]*constants[121])/constants[113])+(algebraic[91]*constants[116])/constants[113] algebraic[37] = (((((rates[13]+rates[11])+rates[12])+rates[0])+rates[4])+rates[5])+rates[10] algebraic[93] = (((power(constants[76], constants[117]))*constants[77])*(power(states[1]/constants[108], constants[79])-power(states[18]/constants[73], constants[79])))/((1.00000+power(states[1]/constants[108], constants[79]))+power(states[18]/constants[73], constants[79])) rates[1] = ((-algebraic[93]*constants[121])/constants[116]-algebraic[37])+(constants[91]/constants[116])*(states[3]-states[1]) algebraic[36] = rates[9]+rates[7] algebraic[90] = ((1.00000/constants[92])/2.00000)*log(constants[37]/states[3]) algebraic[92] = (constants[114]*constants[36])*(states[20]-algebraic[90]) algebraic[40] = (((((constants[94]*4.00000)*states[20])*constants[28])*constants[92])*((0.341000*states[3])*exp((2.00000*states[20])*constants[92])-0.341000*constants[37]))/(exp((2.00000*states[20])*constants[92])-1.00000) algebraic[41] = (((((constants[93]*algebraic[40])*states[22])*states[23])*((1.00000-states[25])+constants[42]))*(power(constants[41], constants[117])))*0.450000 algebraic[66] = 1.00000/(1.00000+power(constants[54]/states[3], 2.00000)) algebraic[71] = (exp((constants[61]*states[20])*constants[92])*(power(states[17], 3.00000)))*constants[37] algebraic[72] = (exp(((constants[61]-1.00000)*states[20])*constants[92])*(power(constants[40], 3.00000)))*states[3] algebraic[73] = ((((constants[55]*(power(constants[40], 3.00000)))*(1.00000+power(states[17]/constants[57], 3.00000))+((power(constants[58], 3.00000))*states[3])*(1.00000+states[3]/constants[55]))+constants[56]*(power(states[17], 3.00000)))+(power(states[17], 3.00000))*constants[37])+(power(constants[40], 3.00000))*states[3] algebraic[74] = (((((constants[114]*constants[104])*(power(constants[59], constants[117])))*algebraic[66])*(algebraic[71]-algebraic[72]))/algebraic[73])/(1.00000+constants[60]*exp(((constants[61]-1.00000)*states[20])*constants[92])) algebraic[82] = power(states[3]*1.00000, 1.60000) algebraic[83] = (((constants[114]*(power(constants[70], constants[117])))*constants[68])*algebraic[82])/(algebraic[82]+constants[89]) algebraic[95] = ((algebraic[41]+algebraic[92])+algebraic[83])-2.00000*algebraic[74] rates[3] = (((-algebraic[95]*constants[27])/((constants[120]*2.00000)*constants[28])+(constants[90]/constants[120])*(states[2]-states[3]))+(constants[91]/constants[120])*(states[1]-states[3]))-algebraic[36] rates[18] = (algebraic[93]-((algebraic[91]*constants[116])/constants[121]+algebraic[89]))-rates[19] algebraic[45] = ((((constants[96]*states[20])*constants[28])*constants[92])*((0.750000*states[16])*exp(states[20]*constants[92])-0.750000*constants[40]))/(exp(states[20]*constants[92])-1.00000) algebraic[46] = (((((constants[38]*algebraic[45])*states[22])*states[23])*((1.00000-states[24])+constants[43]))*(power(constants[41], constants[117])))*0.450000 algebraic[109] = (1.00000/constants[92])*log(constants[40]/states[16]) algebraic[110] = ((((constants[35]*constants[52])*(power(states[33], 3.00000)))*states[31])*states[32])*(states[20]-algebraic[109]) algebraic[111] = (constants[35]*constants[53])*(states[20]-algebraic[109]) algebraic[75] = 1.00000/((1.00000+0.124500*exp((-0.100000*states[20])*constants[92]))+(0.0365000*constants[105])*exp(-states[20]*constants[92])) algebraic[77] = ((((constants[35]*constants[62])*algebraic[75])*constants[39])/(1.00000+power(constants[64]/states[16], 4.00000)))/(constants[39]+constants[63]) algebraic[112] = (((constants[35]*constants[106])*(power(states[35], 3.00000)))*states[34])*(states[20]-algebraic[109]) algebraic[121] = ((((algebraic[110]+algebraic[111])+3.00000*algebraic[70])+3.00000*algebraic[77])+algebraic[46])+algebraic[112] rates[16] = ((-algebraic[121]*constants[27])/(constants[113]*constants[28])+(constants[110]/constants[113])*(states[17]-states[16]))-rates[14] algebraic[47] = ((((constants[96]*states[20])*constants[28])*constants[92])*((0.750000*states[17])*exp(states[20]*constants[92])-0.750000*constants[40]))/(exp(states[20]*constants[92])-1.00000) algebraic[48] = (((((constants[93]*algebraic[47])*states[22])*states[23])*((1.00000-states[25])+constants[42]))*(power(constants[41], constants[117])))*0.450000 algebraic[113] = (1.00000/constants[92])*log(constants[40]/states[17]) algebraic[114] = ((((constants[114]*constants[52])*(power(states[33], 3.00000)))*states[31])*states[32])*(states[20]-algebraic[113]) algebraic[116] = (constants[114]*constants[53])*(states[20]-algebraic[113]) algebraic[78] = ((((constants[114]*constants[62])*algebraic[75])*constants[39])/(1.00000+power(constants[64]/states[17], 4.00000)))/(constants[39]+constants[63]) algebraic[118] = (((constants[114]*constants[106])*(power(states[35], 3.00000)))*states[34])*(states[20]-algebraic[113]) algebraic[122] = ((((algebraic[114]+algebraic[116])+3.00000*algebraic[74])+3.00000*algebraic[78])+algebraic[48])+algebraic[118] rates[17] = (((-algebraic[122]*constants[27])/(constants[120]*constants[28])+(constants[110]/constants[120])*(states[16]-states[17]))+(constants[111]/constants[120])*(states[27]-states[17]))-rates[15] algebraic[125] = (custom_piecewise([less((voi-constants[85])-constants[86]*floor((voi-constants[85])/constants[86]) , constants[84]), 1.00000 , True, 0.00000]))*constants[112] algebraic[96] = algebraic[88]+algebraic[95] algebraic[49] = constants[44]*(states[20]-constants[115]) algebraic[51] = ((constants[35]*constants[46])/(1.00000+constants[45]/states[2]))*(states[20]-constants[115]) algebraic[53] = ((constants[114]*constants[46])/(1.00000+constants[45]/states[3]))*(states[20]-constants[115]) algebraic[54] = algebraic[51]+algebraic[53] algebraic[84] = algebraic[54]+algebraic[49] algebraic[43] = ((((constants[95]*states[20])*constants[28])*constants[92])*((0.750000*states[21])*exp(states[20]*constants[92])-0.750000*constants[39]))/(exp(states[20]*constants[92])-1.00000) algebraic[44] = ((((algebraic[43]*states[22])*states[23])*(constants[38]*(constants[43]+(1.00000-states[24]))+constants[93]*(constants[42]+(1.00000-states[25]))))*(power(constants[41], constants[117])))*0.450000 algebraic[97] = (1.00000/constants[92])*log(constants[39]/states[21]) algebraic[55] = states[17] algebraic[56] = 0.100000+0.900000/(1.00000+power(algebraic[55]/7.00000, 2.00000)) algebraic[98] = (algebraic[56]*1.00000)/(1.00000+exp(0.238500*((states[20]-algebraic[97])-59.2150))) algebraic[99] = 1.00000*((0.491240*exp(0.0803200*((states[20]-algebraic[97])+5.47600))+exp(0.0617500*((states[20]-algebraic[97])-594.310)))/(1.00000+exp(-0.514300*((states[20]-algebraic[97])+4.75300)))) algebraic[100] = algebraic[98]/(algebraic[98]+algebraic[99]) algebraic[101] = ((constants[47]*constants[97])*algebraic[100])*(states[20]-algebraic[97]) algebraic[57] = states[17] algebraic[58] = custom_piecewise([less(constants[31] , 1.00000), 1.00000+1.50000/(1.00000+power(9.00000/algebraic[57], 4.00000)) , True, 1.00000]) algebraic[102] = ((((constants[99]*algebraic[58])*constants[98])*(0.0550000+0.400000/(1.00000+exp(((states[20]-algebraic[97])+9.53000)/17.1800))))*(states[20]-algebraic[97]))*(power(constants[39]/5.40000, 1.0/2)) algebraic[59] = 1.00000/(1.00000+exp(7.48800-states[20]/5.98000)) algebraic[103] = ((constants[35]*constants[50])*algebraic[59])*(states[20]-algebraic[97]) algebraic[104] = ((constants[114]*constants[50])*algebraic[59])*(states[20]-algebraic[97]) algebraic[105] = algebraic[103]+algebraic[104] algebraic[60] = 1.00000/(1.00000+exp((states[20]+74.0000)/24.0000)) algebraic[106] = ((constants[100]*states[26])*algebraic[60])*(states[20]-algebraic[97]) algebraic[61] = (1.00000/constants[92])*log((constants[39]+constants[51]*constants[40])/(states[21]+constants[51]*states[27])) algebraic[62] = ((constants[35]*constants[101])*(power(states[28], 2.00000)))*(states[20]-algebraic[61]) algebraic[63] = ((constants[114]*constants[102])*(power(states[28], 2.00000)))*(states[20]-algebraic[61]) algebraic[64] = algebraic[62]+algebraic[63] algebraic[107] = ((constants[103]*states[29])*states[30])*(states[20]-algebraic[97]) algebraic[79] = algebraic[77]+algebraic[78] algebraic[108] = ((constants[107]*states[36])*states[37])*(states[20]-algebraic[97]) algebraic[120] = (((((((algebraic[108]+algebraic[106])+algebraic[64])+algebraic[101])-2.00000*algebraic[79])+algebraic[44])+algebraic[105])+algebraic[107])+algebraic[102] algebraic[123] = algebraic[121]+algebraic[122] algebraic[124] = ((algebraic[123]+algebraic[84])+algebraic[96])+algebraic[120] rates[20] = -(algebraic[124]+algebraic[125]) return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[9] = 1.00000/(1.00000+exp((states[20]+91.0000)/6.10000)) algebraic[0] = 1.00000/(1.00000+exp(-(states[20]+9.00000)/6.00000)) algebraic[14] = (algebraic[0]*(1.00000-exp(-(states[20]+9.00000)/6.00000)))/(0.0350000*(states[20]+9.00000)) algebraic[1] = 1.00000/(1.00000+exp((states[20]+30.0000)/7.00000))+0.200000/(1.00000+exp((50.0000-states[20])/20.0000)) algebraic[15] = 1.00000/(0.0197000*exp(-(power(0.0337000*(states[20]+25.0000), 2.00000)))+0.0200000) algebraic[2] = 1.00000/(1.00000+exp(-(states[20]+10.0000)/5.00000)) algebraic[16] = (((550.000)/(1.00000+exp((-22.0000-states[20])/9.00000)))*6.00000)/(1.00000+exp((states[20]+11.0000)/9.00000))+230.000/(1.00000+exp((states[20]+40.0000)/20.0000)) algebraic[3] = 1.00000/(1.00000+exp(-(states[20]+3.80000)/14.2500)) algebraic[17] = 990.100/(1.00000+exp(-(states[20]+2.43600)/14.1200)) algebraic[4] = 1.00000/(1.00000+exp((states[20]+6.00000)/-8.60000)) algebraic[18] = 9.00000/(1.00000+exp((states[20]+5.00000)/12.0000))+0.500000 algebraic[5] = 1.00000/(1.00000+exp((states[20]+7.50000)/10.0000)) algebraic[19] = 590.000/(1.00000+exp((states[20]+60.0000)/10.0000))+3050.00 algebraic[10] = (0.320000*(states[20]+47.1300))/(1.00000-exp(-0.100000*(states[20]+47.1300))) algebraic[23] = 0.0800000*exp(-states[20]/11.0000) algebraic[11] = 1.00000/(1.00000+exp(-(states[20]+1.00000)/11.0000)) algebraic[24] = 3.50000*exp(-(power(states[20]/30.0000, 2.00000)))+1.50000 algebraic[12] = 1.00000/(1.00000+exp((states[20]+40.5000)/11.5000)) algebraic[25] = 25.6350*exp(-(power((states[20]+52.4500)/15.8827, 2.00000)))+24.1400 algebraic[6] = custom_piecewise([less(states[20] , -40.0000), 0.135000*exp((states[20]+80.0000)/-6.80000) , True, 0.00000]) algebraic[20] = custom_piecewise([less(states[20] , -40.0000), 3.56000*exp(0.0790000*states[20])+310000.*exp(0.350000*states[20]) , True, 1.00000/(0.130000*(1.00000+exp((states[20]+10.6600)/-11.1000)))]) algebraic[27] = algebraic[6]/(algebraic[6]+algebraic[20]) algebraic[31] = 1.00000/(algebraic[6]+algebraic[20]) algebraic[7] = custom_piecewise([less(states[20] , -40.0000), ((-127140.*exp(0.244400*states[20])-3.47400e-05*exp(-0.0439100*states[20]))*(states[20]+37.7800))/(1.00000+exp(0.311000*(states[20]+79.2300))) , True, 0.00000]) algebraic[21] = custom_piecewise([less(states[20] , -40.0000), (0.121200*exp(-0.0105200*states[20]))/(1.00000+exp(-0.137800*(states[20]+40.1400))) , True, (0.300000*exp(-2.53500e-07*states[20]))/(1.00000+exp(-0.100000*(states[20]+32.0000)))]) algebraic[28] = algebraic[7]/(algebraic[7]+algebraic[21]) algebraic[32] = 1.00000/(algebraic[7]+algebraic[21]) algebraic[8] = custom_piecewise([equal(states[20] , -47.1300), 3.20000 , True, (0.320000*(states[20]+47.1300))/(1.00000-exp(-0.100000*(states[20]+47.1300)))]) algebraic[22] = 0.0800000*exp(-states[20]/11.0000) algebraic[29] = algebraic[8]/(algebraic[8]+algebraic[22]) algebraic[33] = 1.00000/(algebraic[8]+algebraic[22]) algebraic[13] = ((1.00000-states[40])-states[39])-states[38] algebraic[26] = constants[74]-(constants[74]-constants[75])/(1.00000+power(constants[78]/states[18], 2.50000)) algebraic[30] = constants[80]*algebraic[26] algebraic[34] = constants[109]/algebraic[26] algebraic[35] = rates[8]+rates[6] algebraic[86] = ((1.00000/constants[92])/2.00000)*log(constants[37]/states[2]) algebraic[87] = (constants[35]*constants[36])*(states[20]-algebraic[86]) algebraic[38] = (((((constants[94]*4.00000)*states[20])*constants[28])*constants[92])*((0.341000*states[2])*exp((2.00000*states[20])*constants[92])-0.341000*constants[37]))/(exp((2.00000*states[20])*constants[92])-1.00000) algebraic[39] = (((((constants[38]*algebraic[38])*states[22])*states[23])*((1.00000-states[24])+constants[43]))*(power(constants[41], constants[117])))*0.450000 algebraic[65] = 1.00000/(1.00000+power(constants[54]/states[2], 2.00000)) algebraic[67] = (exp((constants[61]*states[20])*constants[92])*(power(states[16], 3.00000)))*constants[37] algebraic[68] = (exp(((constants[61]-1.00000)*states[20])*constants[92])*(power(constants[40], 3.00000)))*states[2] algebraic[69] = ((((constants[55]*(power(constants[40], 3.00000)))*(1.00000+power(states[16]/constants[57], 3.00000))+((power(constants[58], 3.00000))*states[2])*(1.00000+states[2]/constants[55]))+constants[56]*(power(states[16], 3.00000)))+(power(states[16], 3.00000))*constants[37])+(power(constants[40], 3.00000))*states[2] algebraic[70] = (((((constants[35]*constants[104])*(power(constants[59], constants[117])))*algebraic[65])*(algebraic[67]-algebraic[68]))/algebraic[69])/(1.00000+constants[60]*exp(((constants[61]-1.00000)*states[20])*constants[92])) algebraic[80] = power(states[2]*1.00000, 1.60000) algebraic[81] = (((constants[35]*(power(constants[70], constants[117])))*constants[68])*algebraic[80])/(algebraic[80]+constants[89]) algebraic[88] = ((algebraic[39]+algebraic[87])+algebraic[81])-2.00000*algebraic[70] algebraic[89] = (constants[83]*states[39])*(states[18]-states[2]) algebraic[91] = ((1.00000+0.250000*constants[31])*(states[18]-states[2]))*5.34800e-06 algebraic[37] = (((((rates[13]+rates[11])+rates[12])+rates[0])+rates[4])+rates[5])+rates[10] algebraic[93] = (((power(constants[76], constants[117]))*constants[77])*(power(states[1]/constants[108], constants[79])-power(states[18]/constants[73], constants[79])))/((1.00000+power(states[1]/constants[108], constants[79]))+power(states[18]/constants[73], constants[79])) algebraic[36] = rates[9]+rates[7] algebraic[90] = ((1.00000/constants[92])/2.00000)*log(constants[37]/states[3]) algebraic[92] = (constants[114]*constants[36])*(states[20]-algebraic[90]) algebraic[40] = (((((constants[94]*4.00000)*states[20])*constants[28])*constants[92])*((0.341000*states[3])*exp((2.00000*states[20])*constants[92])-0.341000*constants[37]))/(exp((2.00000*states[20])*constants[92])-1.00000) algebraic[41] = (((((constants[93]*algebraic[40])*states[22])*states[23])*((1.00000-states[25])+constants[42]))*(power(constants[41], constants[117])))*0.450000 algebraic[66] = 1.00000/(1.00000+power(constants[54]/states[3], 2.00000)) algebraic[71] = (exp((constants[61]*states[20])*constants[92])*(power(states[17], 3.00000)))*constants[37] algebraic[72] = (exp(((constants[61]-1.00000)*states[20])*constants[92])*(power(constants[40], 3.00000)))*states[3] algebraic[73] = ((((constants[55]*(power(constants[40], 3.00000)))*(1.00000+power(states[17]/constants[57], 3.00000))+((power(constants[58], 3.00000))*states[3])*(1.00000+states[3]/constants[55]))+constants[56]*(power(states[17], 3.00000)))+(power(states[17], 3.00000))*constants[37])+(power(constants[40], 3.00000))*states[3] algebraic[74] = (((((constants[114]*constants[104])*(power(constants[59], constants[117])))*algebraic[66])*(algebraic[71]-algebraic[72]))/algebraic[73])/(1.00000+constants[60]*exp(((constants[61]-1.00000)*states[20])*constants[92])) algebraic[82] = power(states[3]*1.00000, 1.60000) algebraic[83] = (((constants[114]*(power(constants[70], constants[117])))*constants[68])*algebraic[82])/(algebraic[82]+constants[89]) algebraic[95] = ((algebraic[41]+algebraic[92])+algebraic[83])-2.00000*algebraic[74] algebraic[45] = ((((constants[96]*states[20])*constants[28])*constants[92])*((0.750000*states[16])*exp(states[20]*constants[92])-0.750000*constants[40]))/(exp(states[20]*constants[92])-1.00000) algebraic[46] = (((((constants[38]*algebraic[45])*states[22])*states[23])*((1.00000-states[24])+constants[43]))*(power(constants[41], constants[117])))*0.450000 algebraic[109] = (1.00000/constants[92])*log(constants[40]/states[16]) algebraic[110] = ((((constants[35]*constants[52])*(power(states[33], 3.00000)))*states[31])*states[32])*(states[20]-algebraic[109]) algebraic[111] = (constants[35]*constants[53])*(states[20]-algebraic[109]) algebraic[75] = 1.00000/((1.00000+0.124500*exp((-0.100000*states[20])*constants[92]))+(0.0365000*constants[105])*exp(-states[20]*constants[92])) algebraic[77] = ((((constants[35]*constants[62])*algebraic[75])*constants[39])/(1.00000+power(constants[64]/states[16], 4.00000)))/(constants[39]+constants[63]) algebraic[112] = (((constants[35]*constants[106])*(power(states[35], 3.00000)))*states[34])*(states[20]-algebraic[109]) algebraic[121] = ((((algebraic[110]+algebraic[111])+3.00000*algebraic[70])+3.00000*algebraic[77])+algebraic[46])+algebraic[112] algebraic[47] = ((((constants[96]*states[20])*constants[28])*constants[92])*((0.750000*states[17])*exp(states[20]*constants[92])-0.750000*constants[40]))/(exp(states[20]*constants[92])-1.00000) algebraic[48] = (((((constants[93]*algebraic[47])*states[22])*states[23])*((1.00000-states[25])+constants[42]))*(power(constants[41], constants[117])))*0.450000 algebraic[113] = (1.00000/constants[92])*log(constants[40]/states[17]) algebraic[114] = ((((constants[114]*constants[52])*(power(states[33], 3.00000)))*states[31])*states[32])*(states[20]-algebraic[113]) algebraic[116] = (constants[114]*constants[53])*(states[20]-algebraic[113]) algebraic[78] = ((((constants[114]*constants[62])*algebraic[75])*constants[39])/(1.00000+power(constants[64]/states[17], 4.00000)))/(constants[39]+constants[63]) algebraic[118] = (((constants[114]*constants[106])*(power(states[35], 3.00000)))*states[34])*(states[20]-algebraic[113]) algebraic[122] = ((((algebraic[114]+algebraic[116])+3.00000*algebraic[74])+3.00000*algebraic[78])+algebraic[48])+algebraic[118] algebraic[125] = (custom_piecewise([less((voi-constants[85])-constants[86]*floor((voi-constants[85])/constants[86]) , constants[84]), 1.00000 , True, 0.00000]))*constants[112] algebraic[96] = algebraic[88]+algebraic[95] algebraic[49] = constants[44]*(states[20]-constants[115]) algebraic[51] = ((constants[35]*constants[46])/(1.00000+constants[45]/states[2]))*(states[20]-constants[115]) algebraic[53] = ((constants[114]*constants[46])/(1.00000+constants[45]/states[3]))*(states[20]-constants[115]) algebraic[54] = algebraic[51]+algebraic[53] algebraic[84] = algebraic[54]+algebraic[49] algebraic[43] = ((((constants[95]*states[20])*constants[28])*constants[92])*((0.750000*states[21])*exp(states[20]*constants[92])-0.750000*constants[39]))/(exp(states[20]*constants[92])-1.00000) algebraic[44] = ((((algebraic[43]*states[22])*states[23])*(constants[38]*(constants[43]+(1.00000-states[24]))+constants[93]*(constants[42]+(1.00000-states[25]))))*(power(constants[41], constants[117])))*0.450000 algebraic[97] = (1.00000/constants[92])*log(constants[39]/states[21]) algebraic[55] = states[17] algebraic[56] = 0.100000+0.900000/(1.00000+power(algebraic[55]/7.00000, 2.00000)) algebraic[98] = (algebraic[56]*1.00000)/(1.00000+exp(0.238500*((states[20]-algebraic[97])-59.2150))) algebraic[99] = 1.00000*((0.491240*exp(0.0803200*((states[20]-algebraic[97])+5.47600))+exp(0.0617500*((states[20]-algebraic[97])-594.310)))/(1.00000+exp(-0.514300*((states[20]-algebraic[97])+4.75300)))) algebraic[100] = algebraic[98]/(algebraic[98]+algebraic[99]) algebraic[101] = ((constants[47]*constants[97])*algebraic[100])*(states[20]-algebraic[97]) algebraic[57] = states[17] algebraic[58] = custom_piecewise([less(constants[31] , 1.00000), 1.00000+1.50000/(1.00000+power(9.00000/algebraic[57], 4.00000)) , True, 1.00000]) algebraic[102] = ((((constants[99]*algebraic[58])*constants[98])*(0.0550000+0.400000/(1.00000+exp(((states[20]-algebraic[97])+9.53000)/17.1800))))*(states[20]-algebraic[97]))*(power(constants[39]/5.40000, 1.0/2)) algebraic[59] = 1.00000/(1.00000+exp(7.48800-states[20]/5.98000)) algebraic[103] = ((constants[35]*constants[50])*algebraic[59])*(states[20]-algebraic[97]) algebraic[104] = ((constants[114]*constants[50])*algebraic[59])*(states[20]-algebraic[97]) algebraic[105] = algebraic[103]+algebraic[104] algebraic[60] = 1.00000/(1.00000+exp((states[20]+74.0000)/24.0000)) algebraic[106] = ((constants[100]*states[26])*algebraic[60])*(states[20]-algebraic[97]) algebraic[61] = (1.00000/constants[92])*log((constants[39]+constants[51]*constants[40])/(states[21]+constants[51]*states[27])) algebraic[62] = ((constants[35]*constants[101])*(power(states[28], 2.00000)))*(states[20]-algebraic[61]) algebraic[63] = ((constants[114]*constants[102])*(power(states[28], 2.00000)))*(states[20]-algebraic[61]) algebraic[64] = algebraic[62]+algebraic[63] algebraic[107] = ((constants[103]*states[29])*states[30])*(states[20]-algebraic[97]) algebraic[79] = algebraic[77]+algebraic[78] algebraic[108] = ((constants[107]*states[36])*states[37])*(states[20]-algebraic[97]) algebraic[120] = (((((((algebraic[108]+algebraic[106])+algebraic[64])+algebraic[101])-2.00000*algebraic[79])+algebraic[44])+algebraic[105])+algebraic[107])+algebraic[102] algebraic[123] = algebraic[121]+algebraic[122] algebraic[124] = ((algebraic[123]+algebraic[84])+algebraic[96])+algebraic[120] algebraic[42] = algebraic[39]+algebraic[41] algebraic[50] = algebraic[46]+algebraic[48] algebraic[52] = (algebraic[42]+algebraic[50])+algebraic[44] algebraic[76] = algebraic[70]+algebraic[74] algebraic[85] = algebraic[81]+algebraic[83] algebraic[94] = algebraic[87]+algebraic[92] algebraic[115] = algebraic[110]+algebraic[114] algebraic[117] = algebraic[111]+algebraic[116] algebraic[119] = algebraic[112]+algebraic[118] 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)