# Size of variable arrays: sizeAlgebraic = 71 sizeStates = 22 sizeConstants = 90 from math import * from numpy import * def createLegends(): legend_states = [""] * sizeStates legend_rates = [""] * sizeStates legend_algebraic = [""] * sizeAlgebraic legend_voi = "" legend_constants = [""] * sizeConstants legend_voi = "time in component environment (second)" legend_constants[0] = "dCell in component membrane (dimensionless)" legend_constants[66] = "FCell in component membrane (dimensionless)" legend_states[0] = "V in component membrane (millivolt)" legend_constants[1] = "R in component membrane (millijoule_per_mole_kelvin)" legend_constants[2] = "T in component membrane (kelvin)" legend_constants[3] = "F in component membrane (coulomb_per_mole)" legend_constants[71] = "Cm in component membrane (microF)" legend_constants[4] = "CmCentre in component membrane (microF)" legend_constants[5] = "CmPeriphery in component membrane (microF)" legend_algebraic[33] = "i_Na in component sodium_current (nanoA)" legend_algebraic[42] = "i_Ca_L in component L_type_Ca_channel (nanoA)" legend_algebraic[49] = "i_Ca_T in component T_type_Ca_channel (nanoA)" legend_algebraic[50] = "i_to in component four_AP_sensitive_currents (nanoA)" legend_algebraic[51] = "i_sus in component four_AP_sensitive_currents (nanoA)" legend_algebraic[53] = "i_K_r in component rapid_delayed_rectifying_potassium_current (nanoA)" legend_algebraic[54] = "i_K_s in component slow_delayed_rectifying_potassium_current (nanoA)" legend_algebraic[55] = "i_f_Na in component hyperpolarisation_activated_current (nanoA)" legend_algebraic[56] = "i_f_K in component hyperpolarisation_activated_current (nanoA)" legend_algebraic[57] = "i_b_Na in component sodium_background_current (nanoA)" legend_algebraic[59] = "i_b_Ca in component calcium_background_current (nanoA)" legend_algebraic[58] = "i_b_K in component potassium_background_current (nanoA)" legend_algebraic[60] = "i_NaCa in component sodium_calcium_exchanger (nanoA)" legend_algebraic[61] = "i_p in component sodium_potassium_pump (nanoA)" legend_algebraic[63] = "i_Ca_P in component intracellular_calcium_handling (nanoA)" legend_algebraic[1] = "i_st in component sustained_inward_current (nanoA)" legend_constants[72] = "g_Na in component sodium_current (microlitre_per_second)" legend_constants[6] = "g_Na_Centre in component sodium_current (microlitre_per_second)" legend_constants[7] = "g_Na_Periphery in component sodium_current (microlitre_per_second)" legend_constants[67] = "E_Na in component reversal_and_equilibrium_potentials (millivolt)" legend_constants[8] = "Na_o in component ionic_concentrations (millimolar)" legend_states[1] = "m in component sodium_current_m_gate (dimensionless)" legend_algebraic[17] = "h in component sodium_current_h_gate (dimensionless)" legend_algebraic[2] = "m_infinity in component sodium_current_m_gate (dimensionless)" legend_algebraic[18] = "tau_m in component sodium_current_m_gate (second)" legend_algebraic[0] = "F_Na in component sodium_current_h_gate (dimensionless)" legend_states[2] = "h1 in component sodium_current_h_gate (dimensionless)" legend_states[3] = "h2 in component sodium_current_h_gate (dimensionless)" legend_algebraic[3] = "h1_infinity in component sodium_current_h_gate (dimensionless)" legend_algebraic[19] = "h2_infinity in component sodium_current_h_gate (dimensionless)" legend_algebraic[20] = "tau_h1 in component sodium_current_h_gate (second)" legend_algebraic[34] = "tau_h2 in component sodium_current_h_gate (second)" legend_constants[9] = "g_Ca_L_Centre in component L_type_Ca_channel (microS)" legend_constants[10] = "g_Ca_L_Periphery in component L_type_Ca_channel (microS)" legend_constants[73] = "g_Ca_L in component L_type_Ca_channel (microS)" legend_constants[11] = "E_Ca_L in component L_type_Ca_channel (millivolt)" legend_states[4] = "d_L in component L_type_Ca_channel_d_gate (dimensionless)" legend_states[5] = "f_L in component L_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[4] = "alpha_d_L in component L_type_Ca_channel_d_gate (per_second)" legend_algebraic[21] = "beta_d_L in component L_type_Ca_channel_d_gate (per_second)" legend_algebraic[43] = "d_L_infinity in component L_type_Ca_channel_d_gate (dimensionless)" legend_algebraic[35] = "tau_d_L in component L_type_Ca_channel_d_gate (second)" legend_algebraic[5] = "alpha_f_L in component L_type_Ca_channel_f_gate (per_second)" legend_algebraic[22] = "beta_f_L in component L_type_Ca_channel_f_gate (per_second)" legend_algebraic[44] = "f_L_infinity in component L_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[36] = "tau_f_L in component L_type_Ca_channel_f_gate (second)" legend_constants[12] = "g_Ca_T_Centre in component T_type_Ca_channel (microS)" legend_constants[13] = "g_Ca_T_Periphery in component T_type_Ca_channel (microS)" legend_constants[74] = "g_Ca_T in component T_type_Ca_channel (microS)" legend_constants[14] = "E_Ca_T in component T_type_Ca_channel (millivolt)" legend_states[6] = "d_T in component T_type_Ca_channel_d_gate (dimensionless)" legend_states[7] = "f_T in component T_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[6] = "alpha_d_T in component T_type_Ca_channel_d_gate (per_second)" legend_algebraic[23] = "beta_d_T in component T_type_Ca_channel_d_gate (per_second)" legend_algebraic[45] = "d_T_infinity in component T_type_Ca_channel_d_gate (dimensionless)" legend_algebraic[37] = "tau_d_T in component T_type_Ca_channel_d_gate (second)" legend_algebraic[7] = "alpha_f_T in component T_type_Ca_channel_f_gate (per_second)" legend_algebraic[24] = "beta_f_T in component T_type_Ca_channel_f_gate (per_second)" legend_algebraic[46] = "f_T_infinity in component T_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[38] = "tau_f_T in component T_type_Ca_channel_f_gate (second)" legend_constants[15] = "g_to_Centre in component four_AP_sensitive_currents (microS)" legend_constants[16] = "g_to_Periphery in component four_AP_sensitive_currents (microS)" legend_constants[75] = "g_to in component four_AP_sensitive_currents (microS)" legend_constants[17] = "g_sus_Centre in component four_AP_sensitive_currents (microS)" legend_constants[18] = "g_sus_Periphery in component four_AP_sensitive_currents (microS)" legend_constants[76] = "g_sus in component four_AP_sensitive_currents (microS)" legend_constants[68] = "E_K in component reversal_and_equilibrium_potentials (millivolt)" legend_states[8] = "q in component four_AP_sensitive_currents_q_gate (dimensionless)" legend_states[9] = "r in component four_AP_sensitive_currents_r_gate (dimensionless)" legend_algebraic[8] = "q_infinity in component four_AP_sensitive_currents_q_gate (dimensionless)" legend_algebraic[25] = "tau_q in component four_AP_sensitive_currents_q_gate (second)" legend_algebraic[9] = "r_infinity in component four_AP_sensitive_currents_r_gate (dimensionless)" legend_algebraic[26] = "tau_r in component four_AP_sensitive_currents_r_gate (second)" legend_constants[19] = "g_K_r_Centre in component rapid_delayed_rectifying_potassium_current (microS)" legend_constants[20] = "g_K_r_Periphery in component rapid_delayed_rectifying_potassium_current (microS)" legend_constants[77] = "g_K_r in component rapid_delayed_rectifying_potassium_current (microS)" legend_algebraic[52] = "P_a in component rapid_delayed_rectifying_potassium_current (dimensionless)" legend_states[10] = "P_af in component rapid_delayed_rectifying_potassium_current_P_af_gate (dimensionless)" legend_states[11] = "P_as in component rapid_delayed_rectifying_potassium_current_P_as_gate (dimensionless)" legend_states[12] = "P_i in component rapid_delayed_rectifying_potassium_current_P_i_gate (dimensionless)" legend_algebraic[10] = "P_af_infinity in component rapid_delayed_rectifying_potassium_current_P_af_gate (dimensionless)" legend_algebraic[27] = "tau_P_af in component rapid_delayed_rectifying_potassium_current_P_af_gate (second)" legend_algebraic[28] = "P_as_infinity in component rapid_delayed_rectifying_potassium_current_P_as_gate (dimensionless)" legend_algebraic[39] = "tau_P_as in component rapid_delayed_rectifying_potassium_current_P_as_gate (second)" legend_algebraic[11] = "P_i_infinity in component rapid_delayed_rectifying_potassium_current_P_i_gate (dimensionless)" legend_constants[21] = "tau_P_i in component rapid_delayed_rectifying_potassium_current_P_i_gate (second)" legend_constants[22] = "g_K_s_Centre in component slow_delayed_rectifying_potassium_current (microS)" legend_constants[23] = "g_K_s_Periphery in component slow_delayed_rectifying_potassium_current (microS)" legend_constants[78] = "g_K_s in component slow_delayed_rectifying_potassium_current (microS)" legend_constants[69] = "E_K_s in component reversal_and_equilibrium_potentials (millivolt)" legend_states[13] = "xs in component slow_delayed_rectifying_potassium_current_xs_gate (dimensionless)" legend_algebraic[12] = "alpha_xs in component slow_delayed_rectifying_potassium_current_xs_gate (per_second)" legend_algebraic[29] = "beta_xs in component slow_delayed_rectifying_potassium_current_xs_gate (per_second)" legend_constants[24] = "g_f_Na_Centre in component hyperpolarisation_activated_current (microS)" legend_constants[25] = "g_f_Na_Periphery in component hyperpolarisation_activated_current (microS)" legend_constants[79] = "g_f_Na in component hyperpolarisation_activated_current (microS)" legend_constants[26] = "g_f_K_Centre in component hyperpolarisation_activated_current (microS)" legend_constants[27] = "g_f_K_Periphery in component hyperpolarisation_activated_current (microS)" legend_constants[80] = "g_f_K in component hyperpolarisation_activated_current (microS)" legend_states[14] = "y in component hyperpolarisation_activated_current_y_gate (dimensionless)" legend_algebraic[13] = "alpha_y in component hyperpolarisation_activated_current_y_gate (per_second)" legend_algebraic[30] = "beta_y in component hyperpolarisation_activated_current_y_gate (per_second)" legend_constants[28] = "g_b_Na_Centre in component sodium_background_current (microS)" legend_constants[29] = "g_b_Na_Periphery in component sodium_background_current (microS)" legend_constants[81] = "g_b_Na in component sodium_background_current (microS)" legend_constants[30] = "g_b_K_Centre in component potassium_background_current (microS)" legend_constants[31] = "g_b_K_Periphery in component potassium_background_current (microS)" legend_constants[82] = "g_b_K in component potassium_background_current (microS)" legend_constants[32] = "g_b_Ca_Centre in component calcium_background_current (microS)" legend_constants[33] = "g_b_Ca_Periphery in component calcium_background_current (microS)" legend_constants[83] = "g_b_Ca in component calcium_background_current (microS)" legend_constants[70] = "E_Ca in component reversal_and_equilibrium_potentials (millivolt)" legend_constants[34] = "k_NaCa_Centre in component sodium_calcium_exchanger (nanoA)" legend_constants[35] = "k_NaCa_Periphery in component sodium_calcium_exchanger (nanoA)" legend_constants[84] = "k_NaCa in component sodium_calcium_exchanger (nanoA)" legend_constants[36] = "d_NaCa in component sodium_calcium_exchanger (dimensionless)" legend_constants[37] = "gamma_NaCa in component sodium_calcium_exchanger (dimensionless)" legend_constants[38] = "Na_i in component ionic_concentrations (millimolar)" legend_constants[39] = "Ca_i in component ionic_concentrations (millimolar)" legend_constants[40] = "Ca_o in component ionic_concentrations (millimolar)" legend_constants[41] = "K_m_Na in component sodium_potassium_pump (millimolar)" legend_constants[42] = "K_m_K in component sodium_potassium_pump (millimolar)" legend_constants[43] = "i_p_max_Centre in component sodium_potassium_pump (nanoA)" legend_constants[44] = "i_p_max_Periphery in component sodium_potassium_pump (nanoA)" legend_constants[85] = "i_p_max in component sodium_potassium_pump (nanoA)" legend_constants[45] = "K_o in component ionic_concentrations (millimolar)" legend_constants[46] = "K_i in component ionic_concentrations (millimolar)" legend_constants[47] = "g_st in component sustained_inward_current (microS)" legend_states[15] = "d_s in component sustained_inward_current_d_gate (dimensionless)" legend_states[16] = "f_s in component sustained_inward_current_f_gate (dimensionless)" legend_algebraic[14] = "alpha_d_s in component sustained_inward_current_d_gate (per_second)" legend_algebraic[31] = "beta_d_s in component sustained_inward_current_d_gate (per_second)" legend_algebraic[47] = "d_s_infinity in component sustained_inward_current_d_gate (dimensionless)" legend_algebraic[40] = "tau_d_s in component sustained_inward_current_d_gate (second)" legend_algebraic[15] = "alpha_f_s in component sustained_inward_current_f_gate (per_second)" legend_algebraic[32] = "beta_f_s in component sustained_inward_current_f_gate (per_second)" legend_algebraic[48] = "f_s_infinity in component sustained_inward_current_f_gate (dimensionless)" legend_algebraic[41] = "tau_f_s in component sustained_inward_current_f_gate (second)" legend_algebraic[62] = "U_d in component intracellular_calcium_handling (dimensionless)" legend_algebraic[66] = "U_s in component intracellular_calcium_handling (dimensionless)" legend_constants[48] = "i_Ca_P_max in component intracellular_calcium_handling (nanoA)" legend_algebraic[64] = "J_Ca_ds in component intracellular_calcium_handling (millimole_per_second)" legend_algebraic[65] = "J_Ca_r in component intracellular_calcium_handling (millimole_per_second)" legend_algebraic[16] = "J_Ca_P in component intracellular_calcium_handling (millimole_per_second)" legend_constants[49] = "J_Ca_P_max in component intracellular_calcium_handling (millimole_per_second)" legend_algebraic[67] = "J_Ca_u in component intracellular_calcium_handling (millimole_per_second)" legend_constants[50] = "J_Ca_u_max in component intracellular_calcium_handling (millimole_per_second)" legend_algebraic[68] = "J_Ca_ur in component intracellular_calcium_handling (millimole_per_second)" legend_algebraic[69] = "J_Ca_1 in component intracellular_calcium_handling (millimole_per_second)" legend_states[17] = "Ca_d in component intracellular_calcium_handling (millimolar)" legend_states[18] = "Ca_s in component intracellular_calcium_handling (millimolar)" legend_states[19] = "Ca_u in component intracellular_calcium_handling (millimolar)" legend_states[20] = "Ca_r in component intracellular_calcium_handling (millimolar)" legend_constants[51] = "B_d in component intracellular_calcium_handling (millimolar)" legend_constants[52] = "B_s in component intracellular_calcium_handling (millimolar)" legend_constants[86] = "Vol_u in component intracellular_calcium_handling (litre)" legend_constants[87] = "Vol_r in component intracellular_calcium_handling (litre)" legend_constants[88] = "Vol_d in component intracellular_calcium_handling (litre)" legend_constants[89] = "Vol_s in component intracellular_calcium_handling (litre)" legend_constants[53] = "Vol_c in component intracellular_calcium_handling (litre)" legend_constants[54] = "K_m_b in component intracellular_calcium_handling (millimolar)" legend_constants[55] = "K_m_r in component intracellular_calcium_handling (millimolar)" legend_constants[56] = "K_m_u in component intracellular_calcium_handling (millimolar)" legend_constants[57] = "f_d in component intracellular_calcium_handling (dimensionless)" legend_constants[58] = "f_r in component intracellular_calcium_handling (dimensionless)" legend_constants[59] = "f_u in component intracellular_calcium_handling (dimensionless)" legend_constants[60] = "alpha_ds in component intracellular_calcium_handling (per_second)" legend_constants[61] = "alpha_fR in component intracellular_calcium_handling (per_second_millimolar)" legend_constants[62] = "alpha_1 in component intracellular_calcium_handling (per_second)" legend_constants[63] = "alpha_r in component intracellular_calcium_handling (per_second)" legend_constants[64] = "alpha_ur in component intracellular_calcium_handling (per_second)" legend_constants[65] = "beta_fR in component intracellular_calcium_handling (per_second)" legend_states[21] = "f_R in component intracellular_calcium_handling (dimensionless)" legend_algebraic[70] = "i_Ca in component intracellular_calcium_handling (nanoA)" legend_rates[0] = "d/dt V in component membrane (millivolt)" legend_rates[1] = "d/dt m in component sodium_current_m_gate (dimensionless)" legend_rates[2] = "d/dt h1 in component sodium_current_h_gate (dimensionless)" legend_rates[3] = "d/dt h2 in component sodium_current_h_gate (dimensionless)" legend_rates[4] = "d/dt d_L in component L_type_Ca_channel_d_gate (dimensionless)" legend_rates[5] = "d/dt f_L in component L_type_Ca_channel_f_gate (dimensionless)" legend_rates[6] = "d/dt d_T in component T_type_Ca_channel_d_gate (dimensionless)" legend_rates[7] = "d/dt f_T in component T_type_Ca_channel_f_gate (dimensionless)" legend_rates[8] = "d/dt q in component four_AP_sensitive_currents_q_gate (dimensionless)" legend_rates[9] = "d/dt r in component four_AP_sensitive_currents_r_gate (dimensionless)" legend_rates[10] = "d/dt P_af in component rapid_delayed_rectifying_potassium_current_P_af_gate (dimensionless)" legend_rates[11] = "d/dt P_as in component rapid_delayed_rectifying_potassium_current_P_as_gate (dimensionless)" legend_rates[12] = "d/dt P_i in component rapid_delayed_rectifying_potassium_current_P_i_gate (dimensionless)" legend_rates[13] = "d/dt xs in component slow_delayed_rectifying_potassium_current_xs_gate (dimensionless)" legend_rates[14] = "d/dt y in component hyperpolarisation_activated_current_y_gate (dimensionless)" legend_rates[15] = "d/dt d_s in component sustained_inward_current_d_gate (dimensionless)" legend_rates[16] = "d/dt f_s in component sustained_inward_current_f_gate (dimensionless)" legend_rates[21] = "d/dt f_R in component intracellular_calcium_handling (dimensionless)" legend_rates[17] = "d/dt Ca_d in component intracellular_calcium_handling (millimolar)" legend_rates[18] = "d/dt Ca_s in component intracellular_calcium_handling (millimolar)" legend_rates[19] = "d/dt Ca_u in component intracellular_calcium_handling (millimolar)" legend_rates[20] = "d/dt Ca_r in component intracellular_calcium_handling (millimolar)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; constants[0] = 0 states[0] = -39.013558536 constants[1] = 8314 constants[2] = 310 constants[3] = 96845 constants[4] = 2e-5 constants[5] = 6.5e-5 constants[6] = 0 constants[7] = 1.2e-6 constants[8] = 140 states[1] = 0.092361701692 states[2] = 0.015905380261 states[3] = 0.01445216109 constants[9] = 0.0058 constants[10] = 0.0659 constants[11] = 46.4 states[4] = 0.04804900895 states[5] = 0.48779845203 constants[12] = 0.0043 constants[13] = 0.0139 constants[14] = 45 states[6] = 0.42074047435 states[7] = 0.038968420558 constants[15] = 0.00491 constants[16] = 0.03649 constants[17] = 6.65e-5 constants[18] = 0.0114 states[8] = 0.29760539675 states[9] = 0.064402950262 constants[19] = 0.000797 constants[20] = 0.016 states[10] = 0.13034201158 states[11] = 0.46960956028 states[12] = 0.87993375273 constants[21] = 0.002 constants[22] = 0.000518 constants[23] = 0.0104 states[13] = 0.082293827208 constants[24] = 0.000548 constants[25] = 0.0069 constants[26] = 0.000548 constants[27] = 0.0069 states[14] = 0.03889291759 constants[28] = 5.8e-5 constants[29] = 0.000189 constants[30] = 2.52e-5 constants[31] = 8.19e-5 constants[32] = 1.32e-5 constants[33] = 4.3e-5 constants[34] = 2.7e-6 constants[35] = 8.8e-6 constants[36] = 0.0001 constants[37] = 0.5 constants[38] = 8 constants[39] = 0.0001 constants[40] = 2 constants[41] = 5.64 constants[42] = 0.621 constants[43] = 0.0478 constants[44] = 0.16 constants[45] = 5.4 constants[46] = 140 constants[47] = 0.00214 states[15] = 0.230 states[16] = 0.283 constants[48] = 0.24 constants[49] = 0.00000000096 constants[50] = 0.00000000096 states[17] = 0.001544 states[18] = 0.05487 states[19] = 6.983 states[20] = 4.909 constants[51] = 0.4 constants[52] = 0.2 constants[53] = 8.0e-12 constants[54] = 0.002 constants[55] = 0.001 constants[56] = 0.005 constants[57] = 0.1 constants[58] = 0.3 constants[59] = 0.06 constants[60] = 3300.0 constants[61] = 6670.0 constants[62] = 0.172 constants[63] = 333.5 constants[64] = 533.6 constants[65] = 2.0 states[21] = 0.188 constants[66] = (1.07000*(3.00000*constants[0]-0.100000))/(3.00000*(1.00000+0.774500*exp(-(3.00000*constants[0]-2.05000)/0.295000))) constants[67] = ((constants[1]*constants[2])/constants[3])*log(constants[8]/constants[38]) constants[68] = ((constants[1]*constants[2])/constants[3])*log(constants[45]/constants[46]) constants[69] = ((constants[1]*constants[2])/constants[3])*log((constants[45]+0.120000*constants[8])/(constants[46]+0.120000*constants[38])) constants[70] = ((constants[1]*constants[2])/(2.00000*constants[3]))*log(constants[40]/constants[39]) constants[71] = constants[4]+constants[66]*(constants[5]-constants[4]) constants[72] = constants[6]+constants[66]*(constants[7]-constants[6]) constants[73] = constants[9]+constants[66]*(constants[10]-constants[9]) constants[74] = constants[12]+constants[66]*(constants[13]-constants[12]) constants[75] = constants[15]+constants[66]*(constants[16]-constants[15]) constants[76] = constants[17]+constants[66]*(constants[18]-constants[17]) constants[77] = constants[19]+constants[66]*(constants[20]-constants[19]) constants[78] = constants[22]+constants[66]*(constants[23]-constants[22]) constants[79] = constants[24]+constants[66]*(constants[25]-constants[24]) constants[80] = constants[26]+constants[66]*(constants[27]-constants[26]) constants[81] = constants[28]+constants[66]*(constants[29]-constants[28]) constants[82] = constants[30]+constants[66]*(constants[31]-constants[30]) constants[83] = constants[32]+constants[66]*(constants[33]-constants[32]) constants[84] = constants[34]+constants[66]*(constants[35]-constants[34]) constants[85] = constants[43]+constants[66]*(constants[44]-constants[43]) constants[86] = constants[59]*constants[53] constants[87] = constants[58]*constants[53] constants[88] = constants[57]*constants[53] constants[89] = constants[53]-(constants[86]+constants[88]) return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic rates[21] = -constants[61]*states[17]*states[21]+constants[65]*(1.00000-states[21]) algebraic[11] = 1.00000/(1.00000+exp((states[0]+18.6000)/10.1000)) rates[12] = (algebraic[11]-states[12])/constants[21] algebraic[2] = power(1.00000/(1.00000+exp(-states[0]/5.46000)), 1.00000/3.00000) algebraic[18] = 0.000624700/(0.832000*exp(-0.335000*(states[0]+56.7000))+0.627000*exp(0.0820000*(states[0]+65.0100)))+4.00000e-05 rates[1] = (algebraic[2]-states[1])/algebraic[18] algebraic[3] = 1.00000/(1.00000+exp((states[0]+66.1000)/6.40000)) algebraic[20] = (3.71700e-06*exp(-0.281500*(states[0]+17.1100)))/(1.00000+0.00373200*exp(-0.342600*(states[0]+37.7600)))+0.000597700 rates[2] = (algebraic[3]-states[2])/algebraic[20] algebraic[8] = 1.00000/(1.00000+exp((states[0]+59.3700)/13.1000)) algebraic[25] = 0.0101000+0.0651700/(0.570000*exp(-0.0800000*(states[0]+49.0000)))+2.40000e-05*exp(0.100000*(states[0]+50.9300)) rates[8] = (algebraic[8]-states[8])/algebraic[25] algebraic[9] = 1.00000/(1.00000+exp(-(states[0]-10.9300)/19.7000)) algebraic[26] = 0.00100000*(2.98000+15.5900/(1.03700*exp(0.0900000*(states[0]+30.6100))+0.369000*exp(-0.120000*(states[0]+23.8400)))) rates[9] = (algebraic[9]-states[9])/algebraic[26] algebraic[10] = 1.00000/(1.00000+exp(-(states[0]+14.2000)/10.6000)) algebraic[27] = 1.00000/(37.2000*exp((states[0]-9.00000)/15.9000)+0.960000*exp(-(states[0]-9.00000)/22.5000)) rates[10] = (algebraic[10]-states[10])/algebraic[27] algebraic[12] = 14.0000/(1.00000+exp(-(states[0]-40.0000)/9.00000)) algebraic[29] = 1.00000*exp(-states[0]/45.0000) rates[13] = algebraic[12]*(1.00000-states[13])-algebraic[29]*states[13] algebraic[13] = 1.00000*exp(-(states[0]+78.9100)/26.6200) algebraic[30] = 1.00000*exp((states[0]+75.1300)/21.2500) rates[14] = algebraic[13]*(1.00000-states[14])-algebraic[30]*states[14] algebraic[19] = algebraic[3] algebraic[34] = (3.18600e-08*exp(-0.621900*(states[0]+18.8000)))/(1.00000+7.18900e-05*exp(-0.668300*(states[0]+34.0700)))+0.00355600 rates[3] = (algebraic[19]-states[3])/algebraic[34] algebraic[28] = algebraic[10] algebraic[39] = 1.00000/(4.20000*exp((states[0]-9.00000)/17.0000)+0.150000*exp(-(states[0]-9.00000)/21.6000)) rates[11] = (algebraic[28]-states[11])/algebraic[39] algebraic[43] = 1.00000/(1.00000+exp(-(states[0]+23.1000)/6.00000)) algebraic[4] = (-28.3800*(states[0]+35.0000))/(exp(-(states[0]+35.0000)/2.50000)-1.00000)-(84.9000*states[0])/(exp(-0.208000*states[0])-1.00000) algebraic[21] = (11.4200*(states[0]-5.00000))/(exp(0.400000*(states[0]-5.00000))-1.00000) algebraic[35] = 2.00000/(algebraic[4]+algebraic[21]) rates[4] = (algebraic[43]-states[4])/algebraic[35] algebraic[44] = 1.00000/(1.00000+exp((states[0]+45.0000)/5.00000)) algebraic[5] = (3.12000*(states[0]+28.0000))/(exp((states[0]+28.0000)/4.00000)-1.00000) algebraic[22] = 25.0000/(1.00000+exp(-(states[0]+28.0000)/4.00000)) algebraic[36] = 1.00000/(algebraic[5]+algebraic[22]) rates[5] = (algebraic[44]-states[5])/algebraic[36] algebraic[45] = 1.00000/(1.00000+exp(-(states[0]+37.0000)/6.80000)) algebraic[6] = 1068.00*exp((states[0]+26.3000)/30.0000) algebraic[23] = 1068.00*exp(-(states[0]+26.3000)/30.0000) algebraic[37] = 1.00000/(algebraic[6]+algebraic[23]) rates[6] = (algebraic[45]-states[6])/algebraic[37] algebraic[46] = 1.00000/(1.00000+exp((states[0]+71.0000)/9.00000)) algebraic[7] = 15.3000*exp(-(states[0]+71.7000)/83.3000) algebraic[24] = 15.0000*exp((states[0]+71.7000)/15.3800) algebraic[38] = 1.00000/(algebraic[7]+algebraic[24]) rates[7] = (algebraic[46]-states[7])/algebraic[38] algebraic[14] = 1000.00/(0.150000*exp(-states[0]/11.0000)+0.200000*exp(-states[0]/700.000)) algebraic[31] = 1000.00/(16.0000*exp(states[0]/8.00000)+0.200000*exp(states[0]/50.0000)) algebraic[47] = algebraic[14]/(algebraic[14]+algebraic[31]) algebraic[40] = 1.00000/(algebraic[14]+algebraic[31]) rates[15] = (algebraic[47]-states[15])/algebraic[40] algebraic[15] = 1000.00/(3100.00*exp(-states[0]/13.0000)+700.000*exp(-states[0]/70.0000)) algebraic[32] = 1000.00/(16.0000*exp(states[0]/8.00000)+0.200000*exp(states[0]/50.0000)) algebraic[48] = algebraic[15]/(algebraic[15]+algebraic[32]) algebraic[41] = 1.00000/(algebraic[15]+algebraic[32]) rates[16] = (algebraic[48]-states[16])/algebraic[41] algebraic[0] = (0.0952000*exp(-0.0630000*(states[0]+34.4000)))/(1.00000+1.66000*exp(-0.225000*(states[0]+63.7000)))+0.0869000 algebraic[17] = (1.00000-algebraic[0])*states[2]+algebraic[0]*states[3] algebraic[33] = ((((constants[72]*(power(states[1], 3.00000))*algebraic[17]*constants[8]*(power(constants[3], 2.00000)))/(constants[1]*constants[2]))*(exp(((states[0]-constants[67])*constants[3])/(constants[1]*constants[2]))-1.00000))/(exp((states[0]*constants[3])/(constants[1]*constants[2]))-1.00000))*states[0] algebraic[42] = constants[73]*(states[5]*states[4]+0.00600000/(1.00000+exp(-(states[0]+14.1000)/6.00000)))*(states[0]-constants[11]) algebraic[49] = constants[74]*states[6]*states[7]*(states[0]-constants[14]) algebraic[50] = constants[75]*states[8]*states[9]*(states[0]-constants[68]) algebraic[51] = constants[76]*states[9]*(states[0]-constants[68]) algebraic[52] = 0.600000*states[10]+0.400000*states[11] algebraic[53] = constants[77]*algebraic[52]*states[12]*(states[0]-constants[68]) algebraic[54] = constants[78]*(power(states[13], 2.00000))*(states[0]-constants[69]) algebraic[55] = constants[79]*states[14]*(states[0]-constants[67]) algebraic[56] = constants[80]*states[14]*(states[0]-constants[68]) algebraic[57] = constants[81]*(states[0]-constants[67]) algebraic[59] = constants[83]*(states[0]-constants[70]) algebraic[58] = constants[82]*(states[0]-constants[68]) algebraic[60] = (constants[84]*((power(constants[38], 3.00000))*constants[40]*exp(0.0374300*states[0]*constants[37])-(power(constants[8], 3.00000))*constants[39]*exp(0.0374000*states[0]*(constants[37]-1.00000))))/(1.00000+constants[36]*(constants[39]*(power(constants[8], 3.00000))+constants[40]*(power(constants[38], 3.00000)))) algebraic[61] = (constants[85]*(power(constants[38]/(constants[41]+constants[38]), 3.00000))*(power(constants[45]/(constants[42]+constants[45]), 2.00000))*1.60000)/(1.50000+exp(-(states[0]+60.0000)/40.0000)) algebraic[63] = constants[48]*(states[18]/(states[18]+0.000400000)) rates[0] = (-1.00000/constants[71])*(algebraic[33]+algebraic[42]+algebraic[49]+algebraic[50]+algebraic[51]+algebraic[53]+algebraic[54]+algebraic[55]+algebraic[56]+algebraic[57]+algebraic[59]+algebraic[58]+algebraic[60]+algebraic[61]+algebraic[63]) algebraic[65] = constants[63]*states[21]*((power(states[17], 2.00000))/(power(constants[55], 2.00000)+power(states[17], 2.00000)))*constants[87]*states[20] algebraic[68] = constants[64]*constants[86]*(states[19]-states[20]) rates[20] = (algebraic[68]-algebraic[65])/constants[87] algebraic[67] = constants[50]*((power(states[18], 2.00000))/(power(constants[56], 2.00000)+power(states[18], 2.00000))) algebraic[69] = constants[62]*constants[86]*states[19] rates[19] = (algebraic[67]-(algebraic[69]+algebraic[68]))/constants[86] algebraic[62] = 1.00000-constants[51]/(constants[54]+states[17]+constants[51]) algebraic[64] = constants[60]*constants[88]*(states[17]-states[18]) algebraic[70] = algebraic[42]+algebraic[49] rates[17] = (algebraic[62]/constants[88])*(algebraic[64]-(0.950000*algebraic[70])/(2.00000*constants[3])) algebraic[66] = 1.00000-constants[52]/(constants[54]+states[18]+constants[52]) rates[18] = (algebraic[66]/constants[89])*((algebraic[64]-(((0.0500000*algebraic[70]-2.00000*algebraic[60])+algebraic[59])/(2.00000*constants[3])+algebraic[67]))+algebraic[65]+algebraic[69]) return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[11] = 1.00000/(1.00000+exp((states[0]+18.6000)/10.1000)) algebraic[2] = power(1.00000/(1.00000+exp(-states[0]/5.46000)), 1.00000/3.00000) algebraic[18] = 0.000624700/(0.832000*exp(-0.335000*(states[0]+56.7000))+0.627000*exp(0.0820000*(states[0]+65.0100)))+4.00000e-05 algebraic[3] = 1.00000/(1.00000+exp((states[0]+66.1000)/6.40000)) algebraic[20] = (3.71700e-06*exp(-0.281500*(states[0]+17.1100)))/(1.00000+0.00373200*exp(-0.342600*(states[0]+37.7600)))+0.000597700 algebraic[8] = 1.00000/(1.00000+exp((states[0]+59.3700)/13.1000)) algebraic[25] = 0.0101000+0.0651700/(0.570000*exp(-0.0800000*(states[0]+49.0000)))+2.40000e-05*exp(0.100000*(states[0]+50.9300)) algebraic[9] = 1.00000/(1.00000+exp(-(states[0]-10.9300)/19.7000)) algebraic[26] = 0.00100000*(2.98000+15.5900/(1.03700*exp(0.0900000*(states[0]+30.6100))+0.369000*exp(-0.120000*(states[0]+23.8400)))) algebraic[10] = 1.00000/(1.00000+exp(-(states[0]+14.2000)/10.6000)) algebraic[27] = 1.00000/(37.2000*exp((states[0]-9.00000)/15.9000)+0.960000*exp(-(states[0]-9.00000)/22.5000)) algebraic[12] = 14.0000/(1.00000+exp(-(states[0]-40.0000)/9.00000)) algebraic[29] = 1.00000*exp(-states[0]/45.0000) algebraic[13] = 1.00000*exp(-(states[0]+78.9100)/26.6200) algebraic[30] = 1.00000*exp((states[0]+75.1300)/21.2500) algebraic[19] = algebraic[3] algebraic[34] = (3.18600e-08*exp(-0.621900*(states[0]+18.8000)))/(1.00000+7.18900e-05*exp(-0.668300*(states[0]+34.0700)))+0.00355600 algebraic[28] = algebraic[10] algebraic[39] = 1.00000/(4.20000*exp((states[0]-9.00000)/17.0000)+0.150000*exp(-(states[0]-9.00000)/21.6000)) algebraic[43] = 1.00000/(1.00000+exp(-(states[0]+23.1000)/6.00000)) algebraic[4] = (-28.3800*(states[0]+35.0000))/(exp(-(states[0]+35.0000)/2.50000)-1.00000)-(84.9000*states[0])/(exp(-0.208000*states[0])-1.00000) algebraic[21] = (11.4200*(states[0]-5.00000))/(exp(0.400000*(states[0]-5.00000))-1.00000) algebraic[35] = 2.00000/(algebraic[4]+algebraic[21]) algebraic[44] = 1.00000/(1.00000+exp((states[0]+45.0000)/5.00000)) algebraic[5] = (3.12000*(states[0]+28.0000))/(exp((states[0]+28.0000)/4.00000)-1.00000) algebraic[22] = 25.0000/(1.00000+exp(-(states[0]+28.0000)/4.00000)) algebraic[36] = 1.00000/(algebraic[5]+algebraic[22]) algebraic[45] = 1.00000/(1.00000+exp(-(states[0]+37.0000)/6.80000)) algebraic[6] = 1068.00*exp((states[0]+26.3000)/30.0000) algebraic[23] = 1068.00*exp(-(states[0]+26.3000)/30.0000) algebraic[37] = 1.00000/(algebraic[6]+algebraic[23]) algebraic[46] = 1.00000/(1.00000+exp((states[0]+71.0000)/9.00000)) algebraic[7] = 15.3000*exp(-(states[0]+71.7000)/83.3000) algebraic[24] = 15.0000*exp((states[0]+71.7000)/15.3800) algebraic[38] = 1.00000/(algebraic[7]+algebraic[24]) algebraic[14] = 1000.00/(0.150000*exp(-states[0]/11.0000)+0.200000*exp(-states[0]/700.000)) algebraic[31] = 1000.00/(16.0000*exp(states[0]/8.00000)+0.200000*exp(states[0]/50.0000)) algebraic[47] = algebraic[14]/(algebraic[14]+algebraic[31]) algebraic[40] = 1.00000/(algebraic[14]+algebraic[31]) algebraic[15] = 1000.00/(3100.00*exp(-states[0]/13.0000)+700.000*exp(-states[0]/70.0000)) algebraic[32] = 1000.00/(16.0000*exp(states[0]/8.00000)+0.200000*exp(states[0]/50.0000)) algebraic[48] = algebraic[15]/(algebraic[15]+algebraic[32]) algebraic[41] = 1.00000/(algebraic[15]+algebraic[32]) algebraic[0] = (0.0952000*exp(-0.0630000*(states[0]+34.4000)))/(1.00000+1.66000*exp(-0.225000*(states[0]+63.7000)))+0.0869000 algebraic[17] = (1.00000-algebraic[0])*states[2]+algebraic[0]*states[3] algebraic[33] = ((((constants[72]*(power(states[1], 3.00000))*algebraic[17]*constants[8]*(power(constants[3], 2.00000)))/(constants[1]*constants[2]))*(exp(((states[0]-constants[67])*constants[3])/(constants[1]*constants[2]))-1.00000))/(exp((states[0]*constants[3])/(constants[1]*constants[2]))-1.00000))*states[0] algebraic[42] = constants[73]*(states[5]*states[4]+0.00600000/(1.00000+exp(-(states[0]+14.1000)/6.00000)))*(states[0]-constants[11]) algebraic[49] = constants[74]*states[6]*states[7]*(states[0]-constants[14]) algebraic[50] = constants[75]*states[8]*states[9]*(states[0]-constants[68]) algebraic[51] = constants[76]*states[9]*(states[0]-constants[68]) algebraic[52] = 0.600000*states[10]+0.400000*states[11] algebraic[53] = constants[77]*algebraic[52]*states[12]*(states[0]-constants[68]) algebraic[54] = constants[78]*(power(states[13], 2.00000))*(states[0]-constants[69]) algebraic[55] = constants[79]*states[14]*(states[0]-constants[67]) algebraic[56] = constants[80]*states[14]*(states[0]-constants[68]) algebraic[57] = constants[81]*(states[0]-constants[67]) algebraic[59] = constants[83]*(states[0]-constants[70]) algebraic[58] = constants[82]*(states[0]-constants[68]) algebraic[60] = (constants[84]*((power(constants[38], 3.00000))*constants[40]*exp(0.0374300*states[0]*constants[37])-(power(constants[8], 3.00000))*constants[39]*exp(0.0374000*states[0]*(constants[37]-1.00000))))/(1.00000+constants[36]*(constants[39]*(power(constants[8], 3.00000))+constants[40]*(power(constants[38], 3.00000)))) algebraic[61] = (constants[85]*(power(constants[38]/(constants[41]+constants[38]), 3.00000))*(power(constants[45]/(constants[42]+constants[45]), 2.00000))*1.60000)/(1.50000+exp(-(states[0]+60.0000)/40.0000)) algebraic[63] = constants[48]*(states[18]/(states[18]+0.000400000)) algebraic[65] = constants[63]*states[21]*((power(states[17], 2.00000))/(power(constants[55], 2.00000)+power(states[17], 2.00000)))*constants[87]*states[20] algebraic[68] = constants[64]*constants[86]*(states[19]-states[20]) algebraic[67] = constants[50]*((power(states[18], 2.00000))/(power(constants[56], 2.00000)+power(states[18], 2.00000))) algebraic[69] = constants[62]*constants[86]*states[19] algebraic[62] = 1.00000-constants[51]/(constants[54]+states[17]+constants[51]) algebraic[64] = constants[60]*constants[88]*(states[17]-states[18]) algebraic[70] = algebraic[42]+algebraic[49] algebraic[66] = 1.00000-constants[52]/(constants[54]+states[18]+constants[52]) algebraic[1] = constants[47]*states[15]*states[16]*(states[0]-18.0000) algebraic[16] = constants[49]*(states[18]/(states[18]+0.000400000)) 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)