# Size of variable arrays: sizeAlgebraic = 56 sizeStates = 22 sizeConstants = 132 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 Time (time_units)" legend_constants[0] = "T in component Environment (Temperature_units)" legend_constants[1] = "T_exp in component Environment (Temperature_units)" legend_constants[2] = "F in component Environment (F_units)" legend_constants[3] = "R in component Environment (R_units)" legend_constants[4] = "Q10Ca in component Environment (dimensionless)" legend_constants[5] = "Q10K in component Environment (dimensionless)" legend_constants[6] = "Q10Na in component Environment (dimensionless)" legend_constants[7] = "Ca_o in component Environment (millimolar)" legend_constants[8] = "Na_o in component Environment (millimolar)" legend_constants[9] = "K_o in component Environment (millimolar)" legend_constants[10] = "Cl_o in component Environment (millimolar)" legend_constants[104] = "T_correction_Na in component Environment (dimensionless)" legend_constants[105] = "T_correction_K in component Environment (dimensionless)" legend_constants[106] = "T_correction_Ca in component Environment (dimensionless)" legend_constants[107] = "T_correction_BK in component Environment (conductance_units)" legend_constants[108] = "FoRT in component Environment (Inverse_Voltage_units)" legend_constants[109] = "RToF in component Environment (voltage_units)" legend_constants[11] = "Cm in component ICC_Membrane (capacitance_units)" legend_constants[12] = "Vol in component ICC_Membrane (volume_units)" legend_constants[13] = "P_cyto in component ICC_Membrane (dimensionless)" legend_constants[110] = "V_cyto in component ICC_Membrane (volume_units)" legend_constants[14] = "fc in component ICC_Membrane (dimensionless)" legend_states[0] = "Vm in component ICC_Membrane (voltage_units)" legend_states[1] = "Ca_i in component ICC_Membrane (millimolar)" legend_constants[15] = "Na_i in component ICC_Membrane (millimolar)" legend_constants[16] = "K_i in component ICC_Membrane (millimolar)" legend_constants[17] = "Cl_i in component ICC_Membrane (millimolar)" legend_algebraic[28] = "J_leak in component PU_unit (millimolar_per_second)" legend_algebraic[31] = "I_Na in component I_Na (current_units)" legend_algebraic[13] = "I_Ltype in component I_Ltype (current_units)" legend_algebraic[16] = "I_VDDR in component I_VDDR (current_units)" legend_algebraic[29] = "I_kv11 in component I_kv11 (current_units)" legend_algebraic[21] = "I_BK in component I_BK (current_units)" legend_algebraic[26] = "I_ERG in component I_ERG (current_units)" legend_algebraic[17] = "I_CaCl in component I_CaCl (current_units)" legend_algebraic[33] = "I_NSCC in component I_NSCC (current_units)" legend_algebraic[24] = "I_bk in component I_bk (current_units)" legend_algebraic[14] = "J_PMCA in component J_PMCA (millimolar_per_second)" legend_algebraic[0] = "d_inf_Ltype in component d_Ltype (dimensionless)" legend_constants[111] = "tau_d_Ltype in component d_Ltype (time_units)" legend_states[2] = "d_Ltype in component d_Ltype (dimensionless)" legend_algebraic[1] = "f_inf_Ltype in component f_Ltype (dimensionless)" legend_constants[112] = "tau_f_Ltype in component f_Ltype (time_units)" legend_states[3] = "f_Ltype in component f_Ltype (dimensionless)" legend_algebraic[2] = "f_ca_inf_Ltype in component f_ca_Ltype (dimensionless)" legend_constants[113] = "tau_f_ca_Ltype in component f_ca_Ltype (time_units)" legend_states[4] = "f_ca_Ltype in component f_ca_Ltype (dimensionless)" legend_algebraic[12] = "E_Ca in component I_Ltype (voltage_units)" legend_constants[18] = "G_max_Ltype in component I_Ltype (conductance_units)" legend_constants[19] = "J_max_PMCA in component J_PMCA (millimolar_per_second)" legend_algebraic[3] = "d_inf_VDDR in component d_VDDR (dimensionless)" legend_constants[114] = "tau_d_VDDR in component d_VDDR (time_units)" legend_states[5] = "d_VDDR in component d_VDDR (dimensionless)" legend_algebraic[4] = "f_inf_VDDR in component f_VDDR (dimensionless)" legend_constants[115] = "tau_f_VDDR in component f_VDDR (time_units)" legend_states[6] = "f_VDDR in component f_VDDR (dimensionless)" legend_algebraic[15] = "E_Ca in component I_VDDR (voltage_units)" legend_constants[20] = "G_max_VDDR in component I_VDDR (conductance_units)" legend_algebraic[5] = "d_inf_CaCl in component d_CaCl (dimensionless)" legend_constants[21] = "tau_d_CaCl in component d_CaCl (time_units)" legend_states[7] = "d_CaCl in component d_CaCl (dimensionless)" legend_constants[116] = "E_Cl in component I_CaCl (voltage_units)" legend_constants[22] = "G_max_CaCl in component I_CaCl (conductance_units)" legend_algebraic[19] = "d_BK in component d_BK (dimensionless)" legend_constants[117] = "E_K in component I_BK (voltage_units)" legend_constants[23] = "G_max_BK in component I_BK (conductance_units)" legend_constants[118] = "E_K in component I_bk (voltage_units)" legend_constants[24] = "G_max_bk in component I_bk (conductance_units)" legend_algebraic[6] = "d_inf_ERG in component d_ERG (dimensionless)" legend_constants[119] = "tau_d_ERG in component d_ERG (time_units)" legend_states[8] = "d_ERG in component d_ERG (dimensionless)" legend_constants[120] = "E_K in component I_ERG (voltage_units)" legend_constants[25] = "G_max_ERG in component I_ERG (conductance_units)" legend_algebraic[7] = "d_inf_kv11 in component d_kv11 (dimensionless)" legend_constants[121] = "tau_d_kv11 in component d_kv11 (time_units)" legend_states[9] = "d_kv11 in component d_kv11 (dimensionless)" legend_algebraic[8] = "f_inf_kv11 in component f_kv11 (dimensionless)" legend_constants[122] = "tau_f_kv11 in component f_kv11 (time_units)" legend_states[10] = "f_kv11 in component f_kv11 (dimensionless)" legend_constants[123] = "E_K in component I_kv11 (voltage_units)" legend_constants[26] = "G_max_kv11 in component I_kv11 (conductance_units)" legend_algebraic[9] = "d_inf_Na in component d_Na (dimensionless)" legend_constants[124] = "tau_d_Na in component d_Na (time_units)" legend_states[11] = "d_Na in component d_Na (dimensionless)" legend_algebraic[10] = "f_inf_Na in component f_Na (dimensionless)" legend_constants[125] = "tau_f_Na in component f_Na (time_units)" legend_states[12] = "f_Na in component f_Na (dimensionless)" legend_constants[126] = "E_Na in component I_Na (voltage_units)" legend_constants[27] = "G_max_Na in component I_Na (conductance_units)" legend_states[13] = "Ca_PU in component PU_unit (millimolar)" legend_algebraic[11] = "d_inf_NSCC in component d_NSCC (dimensionless)" legend_constants[28] = "tau_d_NSCC in component d_NSCC (time_units)" legend_states[14] = "d_NSCC in component d_NSCC (dimensionless)" legend_constants[127] = "E_NSCC in component I_NSCC (voltage_units)" legend_constants[29] = "G_max_NSCC in component I_NSCC (conductance_units)" legend_constants[30] = "NaPerm_o_Kperm in component I_NSCC (dimensionless)" legend_constants[31] = "P_PU in component PU_unit (dimensionless)" legend_constants[32] = "P_mito in component PU_unit (dimensionless)" legend_constants[33] = "P_ER in component PU_unit (dimensionless)" legend_constants[128] = "V_MITO in component PU_unit (volume_units)" legend_constants[130] = "V_ER in component PU_unit (volume_units)" legend_constants[129] = "V_PU in component PU_unit (volume_units)" legend_constants[34] = "fe in component PU_unit (dimensionless)" legend_constants[35] = "fm in component PU_unit (dimensionless)" legend_states[15] = "Ca_m in component PU_unit (millimolar)" legend_states[16] = "Ca_ER in component PU_unit (millimolar)" legend_states[17] = "ADP_m in component PU_unit (millimolar)" legend_states[18] = "ADP_i in component PU_unit (millimolar)" legend_states[19] = "NADH_m in component PU_unit (millimolar)" legend_states[20] = "h in component PU_unit (dimensionless)" legend_constants[36] = "IP3 in component PU_unit (millimolar)" legend_states[21] = "deltaPsi in component PU_unit (voltage_units)" legend_constants[37] = "deltapH in component PU_unit (dimensionless)" legend_constants[38] = "Cmito in component PU_unit (millifarads)" legend_constants[39] = "K_res in component PU_unit (dimensionless)" legend_constants[40] = "r1 in component PU_unit (dimensionless)" legend_constants[41] = "r2 in component PU_unit (dimensionless)" legend_constants[42] = "r3 in component PU_unit (dimensionless)" legend_constants[43] = "ra in component PU_unit (rate_constants_units)" legend_constants[44] = "rb in component PU_unit (rate_constants_units)" legend_constants[45] = "rc1 in component PU_unit (rate_constants_units)" legend_constants[46] = "rc2 in component PU_unit (rate_constants_units)" legend_constants[47] = "deltaPsi_B in component PU_unit (voltage_units)" legend_constants[48] = "g in component PU_unit (dimensionless)" legend_constants[49] = "K_F1 in component PU_unit (millimolar)" legend_constants[50] = "Pi_m in component PU_unit (millimolar)" legend_constants[51] = "p1 in component PU_unit (dimensionless)" legend_constants[52] = "p2 in component PU_unit (dimensionless)" legend_constants[53] = "p3 in component PU_unit (dimensionless)" legend_constants[54] = "pa in component PU_unit (rate_constants_units)" legend_constants[55] = "pb in component PU_unit (rate_constants_units)" legend_constants[56] = "pc1 in component PU_unit (rate_constants_units)" legend_constants[57] = "pc2 in component PU_unit (rate_constants_units)" legend_constants[58] = "frac in component PU_unit (dimensionless)" legend_constants[59] = "K_act in component PU_unit (millimolar)" legend_constants[60] = "na in component PU_unit (dimensionless)" legend_constants[61] = "deltaPsi_star in component PU_unit (voltage_units)" legend_constants[62] = "K_Na in component PU_unit (millimolar)" legend_constants[63] = "K_Ca in component PU_unit (millimolar)" legend_constants[64] = "K_trans in component PU_unit (millimolar)" legend_constants[65] = "L in component PU_unit (dimensionless)" legend_constants[66] = "b in component PU_unit (dimensionless)" legend_constants[67] = "beta_max in component PU_unit (rate_constants_units)" legend_constants[68] = "beta1 in component PU_unit (per_millimolar)" legend_constants[69] = "beta2 in component PU_unit (per_millimolar)" legend_constants[70] = "beta3 in component PU_unit (per_millimolar)" legend_constants[71] = "beta4 in component PU_unit (per_millimolar)" legend_constants[72] = "beta5 in component PU_unit (per_millimolar)" legend_constants[73] = "beta6 in component PU_unit (per_millimolar)" legend_constants[74] = "beta7 in component PU_unit (per_millimolar)" legend_constants[75] = "KCa_PDH in component PU_unit (millimolar)" legend_constants[76] = "u1 in component PU_unit (dimensionless)" legend_constants[77] = "u2 in component PU_unit (dimensionless)" legend_constants[78] = "n in component PU_unit (dimensionless)" legend_constants[79] = "K_Glc in component PU_unit (millimolar)" legend_constants[80] = "nhyd in component PU_unit (dimensionless)" legend_constants[81] = "K_hyd in component PU_unit (rate_constants_units)" legend_constants[82] = "J_ERleak in component PU_unit (rate_constants_units)" legend_constants[83] = "Jmax_IP3 in component PU_unit (rate_constants_units)" legend_constants[84] = "d_IP3 in component PU_unit (millimolar)" legend_constants[85] = "d_ACT in component PU_unit (millimolar)" legend_constants[86] = "d_INH in component PU_unit (millimolar)" legend_constants[87] = "tauh in component PU_unit (time_units)" legend_constants[88] = "Jmax_serca in component PU_unit (millimolar_per_second)" legend_constants[89] = "k_serca in component PU_unit (millimolar)" legend_constants[90] = "conc in component PU_unit (millimolar)" legend_constants[91] = "Jmax_uni in component PU_unit (rate_constants_units)" legend_constants[92] = "Jmax_NaCa in component PU_unit (millimolar_per_second)" legend_constants[93] = "J_max_leak in component PU_unit (rate_constants_units)" legend_constants[94] = "rho_res in component PU_unit (millimolar)" legend_constants[95] = "rho_F1 in component PU_unit (millimolar)" legend_constants[96] = "g_H in component PU_unit (millimolar_per_second_per_millivolt)" legend_constants[97] = "J_red_basal in component PU_unit (millimolar_per_second)" legend_constants[98] = "Jmax_ANT in component PU_unit (millimolar_per_second)" legend_constants[99] = "J_hyd_max in component PU_unit (millimolar_per_second)" legend_constants[100] = "Glc in component PU_unit (millimolar)" legend_constants[101] = "total_NAD_m in component PU_unit (millimolar)" legend_constants[102] = "total_ANP_m in component PU_unit (millimolar)" legend_constants[103] = "total_ANP_i in component PU_unit (millimolar)" legend_algebraic[34] = "NAD_m in component PU_unit (millimolar)" legend_algebraic[38] = "ATP_m in component PU_unit (millimolar)" legend_algebraic[39] = "ADP_mfree in component PU_unit (millimolar)" legend_algebraic[43] = "ADP3_m in component PU_unit (millimolar)" legend_algebraic[44] = "ATP4_m in component PU_unit (millimolar)" legend_algebraic[45] = "ATP_i in component PU_unit (millimolar)" legend_algebraic[51] = "ADP_ifree in component PU_unit (millimolar)" legend_algebraic[53] = "ADP3_i in component PU_unit (millimolar)" legend_algebraic[52] = "MgADP_i in component PU_unit (millimolar)" legend_algebraic[54] = "ATP4_i in component PU_unit (millimolar)" legend_algebraic[18] = "J_ERout in component PU_unit (millimolar_per_second)" legend_algebraic[20] = "J_SERCA in component PU_unit (millimolar_per_second)" legend_algebraic[22] = "MWC in component PU_unit (millimolar)" legend_algebraic[23] = "J_uni in component PU_unit (millimolar_per_second)" legend_algebraic[25] = "J_NaCa in component PU_unit (millimolar_per_second)" legend_algebraic[48] = "J_red in component PU_unit (millimolar_per_second)" legend_algebraic[47] = "J_pTCA in component PU_unit (millimolar_per_second)" legend_algebraic[40] = "A_F1 in component PU_unit (voltage_units)" legend_algebraic[41] = "J_pF1 in component PU_unit (millimolar_per_second)" legend_algebraic[42] = "J_HF1 in component PU_unit (millimolar_per_second)" legend_algebraic[35] = "A_res in component PU_unit (voltage_units)" legend_algebraic[36] = "J_o in component PU_unit (millimolar_per_second)" legend_algebraic[46] = "J_glyTotal in component PU_unit (millimolar_per_second)" legend_algebraic[27] = "f_PDHa in component PU_unit (dimensionless)" legend_algebraic[37] = "J_Hres in component PU_unit (millimolar_per_second)" legend_algebraic[55] = "J_ANT in component PU_unit (millimolar_per_second)" legend_algebraic[30] = "PMF in component PU_unit (voltage_units)" legend_algebraic[32] = "J_Hleak in component PU_unit (millimolar_per_second)" legend_algebraic[49] = "J_pGly in component PU_unit (millimolar_per_second)" legend_constants[131] = "J_hydSS in component PU_unit (millimolar_per_second)" legend_algebraic[50] = "J_hyd in component PU_unit (millimolar_per_second)" legend_rates[0] = "d/dt Vm in component ICC_Membrane (voltage_units)" legend_rates[1] = "d/dt Ca_i in component ICC_Membrane (millimolar)" legend_rates[2] = "d/dt d_Ltype in component d_Ltype (dimensionless)" legend_rates[3] = "d/dt f_Ltype in component f_Ltype (dimensionless)" legend_rates[4] = "d/dt f_ca_Ltype in component f_ca_Ltype (dimensionless)" legend_rates[5] = "d/dt d_VDDR in component d_VDDR (dimensionless)" legend_rates[6] = "d/dt f_VDDR in component f_VDDR (dimensionless)" legend_rates[7] = "d/dt d_CaCl in component d_CaCl (dimensionless)" legend_rates[8] = "d/dt d_ERG in component d_ERG (dimensionless)" legend_rates[9] = "d/dt d_kv11 in component d_kv11 (dimensionless)" legend_rates[10] = "d/dt f_kv11 in component f_kv11 (dimensionless)" legend_rates[11] = "d/dt d_Na in component d_Na (dimensionless)" legend_rates[12] = "d/dt f_Na in component f_Na (dimensionless)" legend_rates[14] = "d/dt d_NSCC in component d_NSCC (dimensionless)" legend_rates[19] = "d/dt NADH_m in component PU_unit (millimolar)" legend_rates[17] = "d/dt ADP_m in component PU_unit (millimolar)" legend_rates[18] = "d/dt ADP_i in component PU_unit (millimolar)" legend_rates[13] = "d/dt Ca_PU in component PU_unit (millimolar)" legend_rates[15] = "d/dt Ca_m in component PU_unit (millimolar)" legend_rates[16] = "d/dt Ca_ER in component PU_unit (millimolar)" legend_rates[21] = "d/dt deltaPsi in component PU_unit (voltage_units)" legend_rates[20] = "d/dt h in component PU_unit (dimensionless)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; constants[0] = 310 constants[1] = 297 constants[2] = 96.4846 constants[3] = 8.3144 constants[4] = 2.1 constants[5] = 1.5 constants[6] = 2.45 constants[7] = 2.5 constants[8] = 137 constants[9] = 7 constants[10] = 134 constants[11] = 0.025 constants[12] = 1e-12 constants[13] = 0.7 constants[14] = 0.01 states[0] = -67 states[1] = 0.00000993087 constants[15] = 30 constants[16] = 120 constants[17] = 88 states[2] = 0 states[3] = 1 states[4] = 1 constants[18] = 2 constants[19] = 0.088464 states[5] = 0 states[6] = 1 constants[20] = 3 constants[21] = 0.03 states[7] = 0 constants[22] = 10.1 constants[23] = 23 constants[24] = 0.15 states[8] = 0 constants[25] = 2.5 states[9] = 0 states[10] = 1 constants[26] = 6.3 states[11] = 0 states[12] = 1 constants[27] = 20 states[13] = 0.0000902 constants[28] = 0.35 states[14] = 0 constants[29] = 12.15 constants[30] = 1.056075 constants[31] = 0.001 constants[32] = 0.12871 constants[33] = 0.1 constants[34] = 0.01 constants[35] = 0.0003 states[15] = 0.000136 states[16] = 0.007299 states[17] = 2.60093454 states[18] = 0.0077282 states[19] = 0.101476 states[20] = 0.9397 constants[36] = 0.0006 states[21] = 164.000044 constants[37] = -0.4 constants[38] = 0.006995 constants[39] = 1.35e18 constants[40] = 2.077e-18 constants[41] = 1.728e-9 constants[42] = 1.059e-26 constants[43] = 6.394e-10 constants[44] = 1.762e-13 constants[45] = 2.656e-19 constants[46] = 8.632e-27 constants[47] = 50 constants[48] = 0.85 constants[49] = 1.71e9 constants[50] = 20 constants[51] = 1.346e-8 constants[52] = 7.739e-7 constants[53] = 6.65e-15 constants[54] = 1.656e-5 constants[55] = 3.373e-7 constants[56] = 9.651e-14 constants[57] = 4.845e-19 constants[58] = 0.5 constants[59] = 0.00038 constants[60] = 2.8 constants[61] = 91 constants[62] = 9.4 constants[63] = 0.003 constants[64] = 0.006 constants[65] = 50 constants[66] = 0.5 constants[67] = 2.055 constants[68] = 1.66 constants[69] = 0.0249 constants[70] = 4 constants[71] = 2.83 constants[72] = 1.3 constants[73] = 2.66 constants[74] = 0.16 constants[75] = 0.00005 constants[76] = 15 constants[77] = 1.1 constants[78] = 2 constants[79] = 8.7 constants[80] = 2.7 constants[81] = 0.05125 constants[82] = 1.666667 constants[83] = 50000 constants[84] = 0.00025 constants[85] = 0.001 constants[86] = 0.0014 constants[87] = 4 constants[88] = 1.8333 constants[89] = 0.00042 constants[90] = 0.001 constants[91] = 5000 constants[92] = 0.05 constants[93] = 0.01 constants[94] = 0.4 constants[95] = 0.7 constants[96] = 0.0033333 constants[97] = 0.3333 constants[98] = 15 constants[99] = 0.037625 constants[100] = 1 constants[101] = 8 constants[102] = 12 constants[103] = 2 constants[104] = power(constants[6], (constants[0]-constants[1])/10.0000) constants[105] = power(constants[5], (constants[0]-constants[1])/10.0000) constants[106] = power(constants[4], (constants[0]-constants[1])/10.0000) constants[107] = 1.10000*(constants[0]-constants[1]) constants[108] = constants[2]/(constants[3]*constants[0]) constants[109] = (constants[3]*constants[0])/constants[2] constants[110] = constants[12]*constants[13] constants[111] = constants[106]*0.00100000 constants[112] = constants[106]*0.0860000 constants[113] = constants[106]*0.00200000 constants[114] = constants[106]*0.00600000 constants[115] = constants[106]*0.0400000 constants[116] = constants[109]*log(constants[17]/constants[10]) constants[117] = constants[109]*log(constants[9]/constants[16]) constants[118] = constants[109]*log(constants[9]/constants[16]) constants[119] = constants[105]*0.00300000 constants[120] = constants[109]*log(constants[9]/constants[16]) constants[121] = constants[105]*0.00500000 constants[122] = constants[105]*0.00500000 constants[123] = constants[109]*log(constants[9]/constants[16]) constants[124] = constants[104]*0.00300000 constants[125] = constants[104]*0.00160000 constants[126] = constants[109]*log(constants[8]/constants[15]) constants[127] = constants[109]*log((constants[9]+constants[8]*constants[30])/(constants[16]+constants[15]*constants[30])) constants[128] = constants[12]*constants[32] constants[129] = constants[12]*constants[31] constants[130] = constants[12]*constants[33] constants[131] = constants[99]/(1.00000+power(constants[79]/constants[100], constants[80])) return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic rates[20] = (1.00000*(constants[86]-states[20]*(states[13]+constants[86])))/constants[87] algebraic[0] = 1.00000/(1.00000+exp((states[0]+17.0000)/-4.30000)) rates[2] = (algebraic[0]-states[2])/constants[111] algebraic[1] = 1.00000/(1.00000+exp((states[0]+43.0000)/8.90000)) rates[3] = (algebraic[1]-states[3])/constants[112] algebraic[2] = 1.00000-1.00000/(1.00000+exp(((states[1]-0.000100000)-0.000214000)/-1.31000e-05)) rates[4] = (algebraic[2]-states[4])/constants[113] algebraic[3] = 1.00000/(1.00000+exp((states[0]+26.0000)/-6.00000)) rates[5] = (algebraic[3]-states[5])/constants[114] algebraic[4] = 1.00000/(1.00000+exp((states[0]+66.0000)/6.00000)) rates[6] = (algebraic[4]-states[6])/constants[115] algebraic[5] = 1.00000/(1.00000+power(0.000140000/states[1], 3.00000)) rates[7] = (algebraic[5]-states[7])/constants[21] algebraic[6] = 0.200000+0.800000/(1.00000+exp((states[0]+20.0000)/-1.80000)) rates[8] = (algebraic[6]-states[8])/constants[119] algebraic[7] = 1.00000/(1.00000+exp((states[0]+25.0000)/-7.70000)) rates[9] = (algebraic[7]-states[9])/constants[121] algebraic[8] = 0.500000+0.500000/(1.00000+exp((states[0]+44.8000)/4.40000)) rates[10] = (algebraic[8]-states[10])/constants[122] algebraic[9] = 1.00000/(1.00000+exp((states[0]+47.0000)/-4.80000)) rates[11] = (algebraic[9]-states[11])/constants[124] algebraic[10] = 1.00000/(1.00000+exp((states[0]+78.0000)/7.00000)) rates[12] = (algebraic[10]-states[12])/constants[125] algebraic[11] = 1.00000/(1.00000+power(7.45000e-05/states[13], -85.0000)) rates[14] = (algebraic[11]-states[14])/constants[28] algebraic[18] = (constants[83]*(power(constants[36]/(constants[36]+constants[84]), 3.00000))*(power(states[13]/(states[13]+constants[85]), 3.00000))*(power(states[20], 3.00000))+constants[82])*(states[16]-states[13]) algebraic[20] = (constants[88]*(power(states[13], 2.00000)))/(power(constants[89], 2.00000)+power(states[13], 2.00000)) rates[16] = constants[34]*(algebraic[20]-algebraic[18]) algebraic[22] = (((constants[90]*states[13])/constants[64])*(power(1.00000+states[13]/constants[64], 3.00000)))/(power(1.00000+states[13]/constants[64], 4.00000)+constants[65]/(power(1.00000+states[13]/constants[59], constants[60]))) algebraic[23] = (constants[91]*(algebraic[22]-states[15]*exp(-2.00000*constants[108]*(states[21]-constants[61])))*2.00000*constants[108]*(states[21]-constants[61]))/(1.00000-exp(-2.00000*constants[108]*(states[21]-constants[61]))) algebraic[25] = (constants[92]*exp(constants[66]*constants[108]*(states[21]-constants[61])))/((1.00000+power(constants[62]/constants[15], constants[78]))*(1.00000+constants[63]/states[15])) rates[15] = constants[35]*(algebraic[23]-algebraic[25]) algebraic[28] = constants[93]*(states[13]-states[1]) algebraic[12] = 0.500000*constants[109]*log(constants[7]/states[1]) algebraic[13] = constants[18]*states[3]*states[2]*states[4]*(states[0]-algebraic[12]) algebraic[15] = 0.500000*constants[109]*log(constants[7]/states[1]) algebraic[16] = constants[20]*states[6]*states[5]*(states[0]-algebraic[15]) algebraic[14] = (constants[19]*1.00000)/(1.00000+0.000298000/states[1]) rates[1] = constants[14]*((-1.00000*algebraic[13]+-1.00000*algebraic[16])/(2.00000*1.00000e+06*1.00000e+06*constants[2]*constants[110])+algebraic[28]+-1.00000*algebraic[14]) rates[13] = constants[14]*(((algebraic[25]-algebraic[23])*constants[128])/constants[129]+((algebraic[18]-algebraic[20])*constants[130])/constants[129]+(-1.00000*algebraic[28]*constants[110])/constants[129]) algebraic[31] = constants[27]*states[12]*states[11]*(states[0]-constants[126]) algebraic[29] = constants[26]*states[10]*states[9]*(states[0]-constants[123]) algebraic[19] = 1.00000/(1.00000+exp(states[0]/-17.0000-2.00000*log(states[1]/0.00100000))) algebraic[21] = (constants[23]+constants[107])*algebraic[19]*(states[0]-constants[117]) algebraic[26] = constants[25]*states[8]*(states[0]-constants[120]) algebraic[17] = constants[22]*states[7]*(states[0]-constants[116]) algebraic[33] = constants[29]*states[14]*(states[0]-constants[127]) algebraic[24] = constants[24]*(states[0]-constants[118]) rates[0] = ((-1.00000*1.00000)/constants[11])*(algebraic[31]+algebraic[13]+algebraic[16]+algebraic[29]+algebraic[26]+algebraic[21]+algebraic[17]+algebraic[33]+algebraic[24]+algebraic[14]*2.00000*1.00000e+06*1.00000e+06*constants[2]*constants[110]) algebraic[45] = constants[103]-states[18] algebraic[46] = (constants[67]*(1.00000+constants[68]*constants[100])*constants[69]*constants[100]*algebraic[45])/(1.00000+constants[70]*algebraic[45]+(1.00000+constants[71]*algebraic[45])*constants[72]*constants[100]+(1.00000+constants[73]*algebraic[45])*constants[74]*constants[100]) algebraic[27] = 1.00000/(1.00000+constants[77]*(1.00000+constants[76]/(power(1.00000+states[15]/constants[75], 2.00000)))) algebraic[48] = constants[97]+6.39440*algebraic[27]*algebraic[46] algebraic[34] = constants[101]-states[19] algebraic[35] = constants[109]*log((constants[39]*(power(states[19], 1.0/2)))/(power(algebraic[34], 1.0/2))) algebraic[36] = (constants[94]*0.500000*((constants[43]*(power(10.0000, 6.00000*constants[37]))+constants[45]*exp(6.00000*constants[47]*constants[108]))*exp(algebraic[35]*constants[108])+-1.00000*constants[43]*exp(constants[48]*6.00000*constants[108]*states[21])+constants[46]*exp(constants[108]*algebraic[35])*exp(constants[108]*states[21]*6.00000*constants[48])))/((1.00000+constants[40]*exp(constants[108]*algebraic[35]))*exp(constants[108]*constants[47]*6.00000)+(constants[41]+constants[42]*exp(constants[108]*algebraic[35]))*exp(constants[108]*states[21]*constants[48]*6.00000)) rates[19] = algebraic[48]-algebraic[36] algebraic[47] = constants[97]/3.00000+0.840000*algebraic[27]*algebraic[46] algebraic[38] = constants[102]-states[17] algebraic[39] = 0.800000*states[17] algebraic[40] = constants[109]*log((constants[49]*algebraic[38])/(algebraic[39]*constants[50])) algebraic[41] = (constants[95]*-1.00000*((constants[54]*(power(10.0000, 3.00000*constants[37]))+constants[56]*exp(3.00000*constants[108]*constants[47]))*exp(constants[108]*algebraic[40])+-1.00000*constants[54]*exp(3.00000*constants[108]*states[21])+constants[57]*exp(constants[108]*algebraic[40])*exp(3.00000*constants[108]*states[21])))/((1.00000+constants[51]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*constants[47])+(constants[52]+constants[53]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*states[21])) algebraic[43] = 0.450000*algebraic[39] algebraic[44] = 0.0500000*algebraic[38] algebraic[51] = 0.300000*states[18] algebraic[53] = 0.450000*algebraic[51] algebraic[54] = 0.0500000*algebraic[45] algebraic[55] = (constants[98]*(1.00000-((algebraic[54]*algebraic[43])/(algebraic[53]*algebraic[44]))*exp(-1.00000*constants[108]*states[21])))/((1.00000+(algebraic[54]/algebraic[53])*exp(-1.00000*constants[58]*constants[108]*states[21]))*(1.00000+algebraic[43]/algebraic[44])) rates[17] = algebraic[55]+-1.00000*algebraic[47]+-1.00000*algebraic[41] algebraic[49] = 0.150000*algebraic[46] algebraic[50] = constants[81]*algebraic[45]+constants[131] rates[18] = (-1.00000*algebraic[55]*constants[128])/constants[110]+algebraic[50]+-1.00000*algebraic[49] algebraic[42] = (-1.00000*constants[95]*3.00000*(constants[54]*(power(10.0000, 3.00000*constants[37]))*exp(constants[108]*algebraic[40])+constants[55]*(power(10.0000, 3.00000*constants[37]))+-1.00000*(constants[54]+constants[55])*exp(3.00000*constants[108]*states[21])))/((1.00000+constants[51]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*constants[47])+(constants[52]+constants[53]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*states[21])) algebraic[37] = (constants[94]*3.96600*(constants[43]*(power(10.0000, 6.00000*constants[37]))*exp(constants[108]*algebraic[35])+constants[44]*(power(10.0000, 6.00000*constants[37]))+-1.00000*(constants[43]+constants[44])*exp(constants[48]*constants[108]*states[21]*6.00000)))/((1.00000+constants[40]*exp(constants[108]*algebraic[35]))*exp(6.00000*constants[108]*constants[47])+(constants[41]+constants[42]*exp(constants[108]*algebraic[35]))*exp(constants[48]*6.00000*constants[108]*states[21])) algebraic[30] = states[21]-2.30300*constants[109]*constants[37] algebraic[32] = constants[96]*algebraic[30] rates[21] = ((-1.00000*constants[2]*constants[128]*1.00000e+06*1.00000)/constants[38])*(algebraic[32]+-1.00000*algebraic[37]+algebraic[55]+algebraic[42]+2.00000*algebraic[23]) return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[0] = 1.00000/(1.00000+exp((states[0]+17.0000)/-4.30000)) algebraic[1] = 1.00000/(1.00000+exp((states[0]+43.0000)/8.90000)) algebraic[2] = 1.00000-1.00000/(1.00000+exp(((states[1]-0.000100000)-0.000214000)/-1.31000e-05)) algebraic[3] = 1.00000/(1.00000+exp((states[0]+26.0000)/-6.00000)) algebraic[4] = 1.00000/(1.00000+exp((states[0]+66.0000)/6.00000)) algebraic[5] = 1.00000/(1.00000+power(0.000140000/states[1], 3.00000)) algebraic[6] = 0.200000+0.800000/(1.00000+exp((states[0]+20.0000)/-1.80000)) algebraic[7] = 1.00000/(1.00000+exp((states[0]+25.0000)/-7.70000)) algebraic[8] = 0.500000+0.500000/(1.00000+exp((states[0]+44.8000)/4.40000)) algebraic[9] = 1.00000/(1.00000+exp((states[0]+47.0000)/-4.80000)) algebraic[10] = 1.00000/(1.00000+exp((states[0]+78.0000)/7.00000)) algebraic[11] = 1.00000/(1.00000+power(7.45000e-05/states[13], -85.0000)) algebraic[18] = (constants[83]*(power(constants[36]/(constants[36]+constants[84]), 3.00000))*(power(states[13]/(states[13]+constants[85]), 3.00000))*(power(states[20], 3.00000))+constants[82])*(states[16]-states[13]) algebraic[20] = (constants[88]*(power(states[13], 2.00000)))/(power(constants[89], 2.00000)+power(states[13], 2.00000)) algebraic[22] = (((constants[90]*states[13])/constants[64])*(power(1.00000+states[13]/constants[64], 3.00000)))/(power(1.00000+states[13]/constants[64], 4.00000)+constants[65]/(power(1.00000+states[13]/constants[59], constants[60]))) algebraic[23] = (constants[91]*(algebraic[22]-states[15]*exp(-2.00000*constants[108]*(states[21]-constants[61])))*2.00000*constants[108]*(states[21]-constants[61]))/(1.00000-exp(-2.00000*constants[108]*(states[21]-constants[61]))) algebraic[25] = (constants[92]*exp(constants[66]*constants[108]*(states[21]-constants[61])))/((1.00000+power(constants[62]/constants[15], constants[78]))*(1.00000+constants[63]/states[15])) algebraic[28] = constants[93]*(states[13]-states[1]) algebraic[12] = 0.500000*constants[109]*log(constants[7]/states[1]) algebraic[13] = constants[18]*states[3]*states[2]*states[4]*(states[0]-algebraic[12]) algebraic[15] = 0.500000*constants[109]*log(constants[7]/states[1]) algebraic[16] = constants[20]*states[6]*states[5]*(states[0]-algebraic[15]) algebraic[14] = (constants[19]*1.00000)/(1.00000+0.000298000/states[1]) algebraic[31] = constants[27]*states[12]*states[11]*(states[0]-constants[126]) algebraic[29] = constants[26]*states[10]*states[9]*(states[0]-constants[123]) algebraic[19] = 1.00000/(1.00000+exp(states[0]/-17.0000-2.00000*log(states[1]/0.00100000))) algebraic[21] = (constants[23]+constants[107])*algebraic[19]*(states[0]-constants[117]) algebraic[26] = constants[25]*states[8]*(states[0]-constants[120]) algebraic[17] = constants[22]*states[7]*(states[0]-constants[116]) algebraic[33] = constants[29]*states[14]*(states[0]-constants[127]) algebraic[24] = constants[24]*(states[0]-constants[118]) algebraic[45] = constants[103]-states[18] algebraic[46] = (constants[67]*(1.00000+constants[68]*constants[100])*constants[69]*constants[100]*algebraic[45])/(1.00000+constants[70]*algebraic[45]+(1.00000+constants[71]*algebraic[45])*constants[72]*constants[100]+(1.00000+constants[73]*algebraic[45])*constants[74]*constants[100]) algebraic[27] = 1.00000/(1.00000+constants[77]*(1.00000+constants[76]/(power(1.00000+states[15]/constants[75], 2.00000)))) algebraic[48] = constants[97]+6.39440*algebraic[27]*algebraic[46] algebraic[34] = constants[101]-states[19] algebraic[35] = constants[109]*log((constants[39]*(power(states[19], 1.0/2)))/(power(algebraic[34], 1.0/2))) algebraic[36] = (constants[94]*0.500000*((constants[43]*(power(10.0000, 6.00000*constants[37]))+constants[45]*exp(6.00000*constants[47]*constants[108]))*exp(algebraic[35]*constants[108])+-1.00000*constants[43]*exp(constants[48]*6.00000*constants[108]*states[21])+constants[46]*exp(constants[108]*algebraic[35])*exp(constants[108]*states[21]*6.00000*constants[48])))/((1.00000+constants[40]*exp(constants[108]*algebraic[35]))*exp(constants[108]*constants[47]*6.00000)+(constants[41]+constants[42]*exp(constants[108]*algebraic[35]))*exp(constants[108]*states[21]*constants[48]*6.00000)) algebraic[47] = constants[97]/3.00000+0.840000*algebraic[27]*algebraic[46] algebraic[38] = constants[102]-states[17] algebraic[39] = 0.800000*states[17] algebraic[40] = constants[109]*log((constants[49]*algebraic[38])/(algebraic[39]*constants[50])) algebraic[41] = (constants[95]*-1.00000*((constants[54]*(power(10.0000, 3.00000*constants[37]))+constants[56]*exp(3.00000*constants[108]*constants[47]))*exp(constants[108]*algebraic[40])+-1.00000*constants[54]*exp(3.00000*constants[108]*states[21])+constants[57]*exp(constants[108]*algebraic[40])*exp(3.00000*constants[108]*states[21])))/((1.00000+constants[51]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*constants[47])+(constants[52]+constants[53]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*states[21])) algebraic[43] = 0.450000*algebraic[39] algebraic[44] = 0.0500000*algebraic[38] algebraic[51] = 0.300000*states[18] algebraic[53] = 0.450000*algebraic[51] algebraic[54] = 0.0500000*algebraic[45] algebraic[55] = (constants[98]*(1.00000-((algebraic[54]*algebraic[43])/(algebraic[53]*algebraic[44]))*exp(-1.00000*constants[108]*states[21])))/((1.00000+(algebraic[54]/algebraic[53])*exp(-1.00000*constants[58]*constants[108]*states[21]))*(1.00000+algebraic[43]/algebraic[44])) algebraic[49] = 0.150000*algebraic[46] algebraic[50] = constants[81]*algebraic[45]+constants[131] algebraic[42] = (-1.00000*constants[95]*3.00000*(constants[54]*(power(10.0000, 3.00000*constants[37]))*exp(constants[108]*algebraic[40])+constants[55]*(power(10.0000, 3.00000*constants[37]))+-1.00000*(constants[54]+constants[55])*exp(3.00000*constants[108]*states[21])))/((1.00000+constants[51]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*constants[47])+(constants[52]+constants[53]*exp(constants[108]*algebraic[40]))*exp(3.00000*constants[108]*states[21])) algebraic[37] = (constants[94]*3.96600*(constants[43]*(power(10.0000, 6.00000*constants[37]))*exp(constants[108]*algebraic[35])+constants[44]*(power(10.0000, 6.00000*constants[37]))+-1.00000*(constants[43]+constants[44])*exp(constants[48]*constants[108]*states[21]*6.00000)))/((1.00000+constants[40]*exp(constants[108]*algebraic[35]))*exp(6.00000*constants[108]*constants[47])+(constants[41]+constants[42]*exp(constants[108]*algebraic[35]))*exp(constants[48]*6.00000*constants[108]*states[21])) algebraic[30] = states[21]-2.30300*constants[109]*constants[37] algebraic[32] = constants[96]*algebraic[30] algebraic[52] = 0.550000*algebraic[51] return algebraic 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)