# Size of variable arrays: sizeAlgebraic = 85 sizeStates = 18 sizeConstants = 71 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 (ms)" legend_states[0] = "V in component membrane (mV)" legend_constants[0] = "R in component membrane (millijoule_per_mole_kelvin)" legend_constants[1] = "T in component membrane (kelvin)" legend_constants[2] = "F in component membrane (coulomb_per_mole)" legend_constants[3] = "Cm in component membrane (uF)" legend_algebraic[22] = "i_Na in component sodium_current (uA)" legend_algebraic[24] = "i_t in component Ca_independent_transient_outward_K_current (uA)" legend_algebraic[25] = "i_ss in component steady_state_outward_K_current (uA)" legend_algebraic[26] = "i_K1 in component inward_rectifier (uA)" legend_algebraic[29] = "i_f in component hyperpolarisation_activated_current (uA)" legend_algebraic[30] = "i_B_Na in component background_currents (uA)" legend_algebraic[31] = "i_B_K in component background_currents (uA)" legend_algebraic[34] = "i_NaK in component sodium_potassium_pump (uA)" legend_algebraic[75] = "i_Ncx2 in component Na_Ca_Exchanger (uA)" legend_algebraic[78] = "i_pCa2 in component SarcolemMal_Ca_pump (uA)" legend_algebraic[72] = "i_LCC2 in component LCC_current (uA)" legend_algebraic[81] = "i_CaB2 in component Background_Ca_current (uA)" legend_algebraic[20] = "i_Stim in component membrane (uA)" legend_constants[4] = "stim_period in component membrane (ms)" legend_constants[5] = "stim_duration in component membrane (ms)" legend_constants[6] = "stim_amplitude in component membrane (uA)" legend_algebraic[0] = "FVRT in component membrane (dimensionless)" legend_algebraic[19] = "FVRT_Ca in component membrane (dimensionless)" legend_constants[7] = "Vmyo in component cell_geometry (um3)" legend_constants[8] = "Vmyo_uL in component cell_geometry (uL)" legend_constants[9] = "VSR_uL in component cell_geometry (uL)" legend_algebraic[21] = "E_Na in component sodium_current (mV)" legend_constants[10] = "g_Na in component sodium_current (mSi)" legend_states[1] = "Na_i in component intracellular_ion_concentrations (mM)" legend_constants[11] = "Na_o in component extracellular_ion_concentrations (mM)" legend_states[2] = "m in component sodium_current_m_gate (dimensionless)" legend_states[3] = "h in component sodium_current_h_gate (dimensionless)" legend_states[4] = "j in component sodium_current_j_gate (dimensionless)" legend_algebraic[1] = "m_infinity in component sodium_current_m_gate (dimensionless)" legend_algebraic[11] = "tau_m in component sodium_current_m_gate (ms)" legend_algebraic[2] = "h_infinity in component sodium_current_h_gate (dimensionless)" legend_algebraic[12] = "tau_h in component sodium_current_h_gate (ms)" legend_algebraic[3] = "j_infinity in component sodium_current_j_gate (dimensionless)" legend_algebraic[13] = "tau_j in component sodium_current_j_gate (ms)" legend_algebraic[23] = "E_K in component Ca_independent_transient_outward_K_current (mV)" legend_constants[12] = "g_t in component Ca_independent_transient_outward_K_current (mSi)" legend_constants[13] = "a in component Ca_independent_transient_outward_K_current (dimensionless)" legend_constants[14] = "b in component Ca_independent_transient_outward_K_current (dimensionless)" legend_constants[15] = "K_o in component extracellular_ion_concentrations (mM)" legend_states[5] = "K_i in component intracellular_ion_concentrations (mM)" legend_states[6] = "r in component Ca_independent_transient_outward_K_current_r_gate (dimensionless)" legend_states[7] = "s in component Ca_independent_transient_outward_K_current_s_gate (dimensionless)" legend_states[8] = "s_slow in component Ca_independent_transient_outward_K_current_s_slow_gate (dimensionless)" legend_algebraic[14] = "tau_r in component Ca_independent_transient_outward_K_current_r_gate (ms)" legend_algebraic[4] = "r_infinity in component Ca_independent_transient_outward_K_current_r_gate (dimensionless)" legend_algebraic[15] = "tau_s in component Ca_independent_transient_outward_K_current_s_gate (ms)" legend_algebraic[5] = "s_infinity in component Ca_independent_transient_outward_K_current_s_gate (dimensionless)" legend_algebraic[16] = "tau_s_slow in component Ca_independent_transient_outward_K_current_s_slow_gate (ms)" legend_algebraic[6] = "s_slow_infinity in component Ca_independent_transient_outward_K_current_s_slow_gate (dimensionless)" legend_constants[16] = "g_ss in component steady_state_outward_K_current (mSi)" legend_states[9] = "r_ss in component steady_state_outward_K_current_r_ss_gate (dimensionless)" legend_states[10] = "s_ss in component steady_state_outward_K_current_s_ss_gate (dimensionless)" legend_algebraic[17] = "tau_r_ss in component steady_state_outward_K_current_r_ss_gate (ms)" legend_algebraic[7] = "r_ss_infinity in component steady_state_outward_K_current_r_ss_gate (dimensionless)" legend_constants[67] = "tau_s_ss in component steady_state_outward_K_current_s_ss_gate (ms)" legend_algebraic[8] = "s_ss_infinity in component steady_state_outward_K_current_s_ss_gate (dimensionless)" legend_constants[17] = "g_K1 in component inward_rectifier (mSi)" legend_algebraic[27] = "i_f_Na in component hyperpolarisation_activated_current (uA)" legend_algebraic[28] = "i_f_K in component hyperpolarisation_activated_current (uA)" legend_constants[18] = "g_f in component hyperpolarisation_activated_current (mSi)" legend_constants[19] = "f_Na in component hyperpolarisation_activated_current (dimensionless)" legend_constants[68] = "f_K in component hyperpolarisation_activated_current (dimensionless)" legend_states[11] = "y in component hyperpolarisation_activated_current_y_gate (dimensionless)" legend_algebraic[18] = "tau_y in component hyperpolarisation_activated_current_y_gate (ms)" legend_algebraic[9] = "y_infinity in component hyperpolarisation_activated_current_y_gate (dimensionless)" legend_algebraic[32] = "i_B in component background_currents (uA)" legend_constants[20] = "g_B_Na in component background_currents (mSi)" legend_constants[21] = "g_B_K in component background_currents (mSi)" legend_constants[22] = "i_NaK_max in component sodium_potassium_pump (uA)" legend_algebraic[33] = "nu_1 in component sodium_potassium_pump (dimensionless)" legend_constants[23] = "gamma1 in component sodium_potassium_pump (dimensionless)" legend_constants[24] = "KdNaio in component sodium_potassium_pump (mM)" legend_constants[25] = "KdNais in component sodium_potassium_pump (mM)" legend_constants[26] = "KdNaes in component sodium_potassium_pump (mM)" legend_constants[27] = "Delta in component sodium_potassium_pump (dimensionless)" legend_constants[28] = "alpha in component sodium_potassium_pump (mM)" legend_constants[29] = "Ca_o in component extracellular_ion_concentrations (mM)" legend_constants[30] = "g_D in component CaRU (um3_per_ms)" legend_constants[31] = "J_R in component CaRU (um3_per_ms)" legend_constants[32] = "J_L in component CaRU (um3_per_ms)" legend_constants[33] = "N in component CaRU (dimensionless)" legend_states[12] = "Ca_i in component intracellular_ion_concentrations (mM)" legend_states[13] = "Ca_SR in component intracellular_ion_concentrations (mM)" legend_algebraic[64] = "i_RyR2 in component RyR_current (mM_per_ms)" legend_algebraic[44] = "C_oc in component DS_Calcium_Concentrations (mM)" legend_algebraic[42] = "C_co in component DS_Calcium_Concentrations (mM)" legend_constants[34] = "V_L in component CaRU_Transitions (mV)" legend_constants[35] = "del_VL in component CaRU_Transitions (mV)" legend_constants[36] = "phi_L in component CaRU_Transitions (dimensionless)" legend_constants[37] = "t_L in component CaRU_Transitions (ms)" legend_constants[38] = "tau_L in component CaRU_Transitions (ms)" legend_constants[39] = "t_R in component CaRU_Transitions (ms)" legend_constants[40] = "tau_R in component CaRU_Transitions (ms)" legend_constants[41] = "phi_R in component CaRU_Transitions (dimensionless)" legend_constants[42] = "theta_R in component CaRU_Transitions (dimensionless)" legend_constants[43] = "K_RyR in component CaRU_Transitions (mM)" legend_constants[44] = "K_L in component CaRU_Transitions (mM)" legend_constants[45] = "a1 in component CaRU_Transitions (dimensionless)" legend_constants[46] = "b1 in component CaRU_Transitions (dimensionless)" legend_constants[47] = "c in component CaRU_Transitions (dimensionless)" legend_constants[48] = "d in component CaRU_Transitions (dimensionless)" legend_algebraic[35] = "expVL in component CaRU_Transitions (dimensionless)" legend_algebraic[36] = "alpha_p in component CaRU_Transitions (per_ms)" legend_constants[69] = "alpha_m in component CaRU_Transitions (per_ms)" legend_algebraic[45] = "beta_poc in component CaRU_Transitions (per_ms)" legend_algebraic[37] = "beta_pcc in component CaRU_Transitions (per_ms)" legend_constants[70] = "beta_m in component CaRU_Transitions (per_ms)" legend_algebraic[43] = "epsilon_pco in component CaRU_Transitions (per_ms)" legend_algebraic[38] = "epsilon_pcc in component CaRU_Transitions (per_ms)" legend_algebraic[39] = "epsilon_m in component CaRU_Transitions (per_ms)" legend_algebraic[46] = "mu_poc in component CaRU_Transitions (per_ms)" legend_algebraic[40] = "mu_pcc in component CaRU_Transitions (per_ms)" legend_algebraic[47] = "mu_moc in component CaRU_Transitions (per_ms)" legend_algebraic[41] = "mu_mcc in component CaRU_Transitions (per_ms)" legend_algebraic[10] = "C_cc in component DS_Calcium_Concentrations (mM)" legend_algebraic[51] = "J_Loo in component LCC_and_RyR_fluxes (um3_mM_per_ms)" legend_algebraic[50] = "J_Loc in component LCC_and_RyR_fluxes (um3_mM_per_ms)" legend_algebraic[48] = "J_Rco in component LCC_and_RyR_fluxes (um3_mM_per_ms)" legend_algebraic[49] = "J_Roo in component LCC_and_RyR_fluxes (um3_mM_per_ms)" legend_algebraic[52] = "denom in component CaRU_states (per_ms3)" legend_algebraic[53] = "P1 in component CaRU_states (dimensionless)" legend_algebraic[54] = "P2 in component CaRU_states (dimensionless)" legend_algebraic[55] = "P3 in component CaRU_states (dimensionless)" legend_algebraic[56] = "P4 in component CaRU_states (dimensionless)" legend_algebraic[57] = "r_1 in component CaRU_reduced_states (per_ms)" legend_algebraic[59] = "r_2 in component CaRU_reduced_states (per_ms)" legend_algebraic[61] = "r_3 in component CaRU_reduced_states (per_ms)" legend_algebraic[63] = "r_4 in component CaRU_reduced_states (per_ms)" legend_algebraic[65] = "r_5 in component CaRU_reduced_states (per_ms)" legend_algebraic[67] = "r_6 in component CaRU_reduced_states (per_ms)" legend_algebraic[69] = "r_7 in component CaRU_reduced_states (per_ms)" legend_algebraic[71] = "r_8 in component CaRU_reduced_states (per_ms)" legend_states[14] = "z_1 in component CaRU_reduced_states (dimensionless)" legend_states[15] = "z_2 in component CaRU_reduced_states (dimensionless)" legend_states[16] = "z_3 in component CaRU_reduced_states (dimensionless)" legend_algebraic[73] = "z_4 in component CaRU_reduced_states (dimensionless)" legend_algebraic[58] = "J_R1 in component RyR_current (um3_mM_per_ms)" legend_algebraic[60] = "J_R3 in component RyR_current (um3_mM_per_ms)" legend_algebraic[62] = "i_RyR1 in component RyR_current (mM_per_ms)" legend_algebraic[66] = "J_L1 in component LCC_current (um3_mM_per_ms)" legend_algebraic[68] = "J_L2 in component LCC_current (um3_mM_per_ms)" legend_algebraic[70] = "i_LCC1 in component LCC_current (mM_per_ms)" legend_constants[49] = "K_mNa in component Na_Ca_Exchanger (mM)" legend_constants[50] = "K_mCa in component Na_Ca_Exchanger (mM)" legend_constants[51] = "eta in component Na_Ca_Exchanger (dimensionless)" legend_constants[52] = "k_sat in component Na_Ca_Exchanger (dimensionless)" legend_constants[53] = "g_NCX in component Na_Ca_Exchanger (mM_per_ms)" legend_algebraic[74] = "i_Ncx1 in component Na_Ca_Exchanger (mM_per_ms)" legend_constants[54] = "g_SERCA in component SERCA (mM_per_ms)" legend_constants[55] = "K_SERCA in component SERCA (mM)" legend_algebraic[76] = "i_SERCA in component SERCA (mM_per_ms)" legend_constants[56] = "g_pCa in component SarcolemMal_Ca_pump (mM_per_ms)" legend_constants[57] = "K_mpCa in component SarcolemMal_Ca_pump (mM)" legend_algebraic[77] = "i_pCa1 in component SarcolemMal_Ca_pump (mM_per_ms)" legend_algebraic[79] = "E_Ca in component Background_Ca_current (mV)" legend_constants[58] = "g_CaB in component Background_Ca_current (mM_per_mV_ms)" legend_algebraic[80] = "i_CaB1 in component Background_Ca_current (mM_per_ms)" legend_constants[59] = "g_SRl in component SR_Ca_leak_current (per_ms)" legend_algebraic[82] = "i_SR in component SR_Ca_leak_current (mM_per_ms)" legend_constants[60] = "k_m_TRPN in component troponin_Ca_buffer (per_ms)" legend_constants[61] = "k_p_TRPN in component troponin_Ca_buffer (per_mM_ms)" legend_constants[62] = "B_TRPN in component troponin_Ca_buffer (mM)" legend_states[17] = "TRPN in component intracellular_ion_concentrations (mM)" legend_algebraic[83] = "i_TRPN in component troponin_Ca_buffer (mM_per_ms)" legend_constants[63] = "k_CMDN in component calmodulin_Ca_buffer (mM)" legend_constants[64] = "B_CMDN in component calmodulin_Ca_buffer (mM)" legend_algebraic[84] = "beta_CMDN in component calmodulin_Ca_buffer (dimensionless)" legend_constants[65] = "EGTA_tot in component calmodulin_Ca_buffer (mM)" legend_constants[66] = "KmEGTA in component calmodulin_Ca_buffer (mM)" legend_rates[0] = "d/dt V in component membrane (mV)" legend_rates[2] = "d/dt m in component sodium_current_m_gate (dimensionless)" legend_rates[3] = "d/dt h in component sodium_current_h_gate (dimensionless)" legend_rates[4] = "d/dt j in component sodium_current_j_gate (dimensionless)" legend_rates[6] = "d/dt r in component Ca_independent_transient_outward_K_current_r_gate (dimensionless)" legend_rates[7] = "d/dt s in component Ca_independent_transient_outward_K_current_s_gate (dimensionless)" legend_rates[8] = "d/dt s_slow in component Ca_independent_transient_outward_K_current_s_slow_gate (dimensionless)" legend_rates[9] = "d/dt r_ss in component steady_state_outward_K_current_r_ss_gate (dimensionless)" legend_rates[10] = "d/dt s_ss in component steady_state_outward_K_current_s_ss_gate (dimensionless)" legend_rates[11] = "d/dt y in component hyperpolarisation_activated_current_y_gate (dimensionless)" legend_rates[14] = "d/dt z_1 in component CaRU_reduced_states (dimensionless)" legend_rates[15] = "d/dt z_2 in component CaRU_reduced_states (dimensionless)" legend_rates[16] = "d/dt z_3 in component CaRU_reduced_states (dimensionless)" legend_rates[1] = "d/dt Na_i in component intracellular_ion_concentrations (mM)" legend_rates[5] = "d/dt K_i in component intracellular_ion_concentrations (mM)" legend_rates[17] = "d/dt TRPN in component intracellular_ion_concentrations (mM)" legend_rates[12] = "d/dt Ca_i in component intracellular_ion_concentrations (mM)" legend_rates[13] = "d/dt Ca_SR in component intracellular_ion_concentrations (mM)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; states[0] = -85.1221681609219 constants[0] = 8314 constants[1] = 310 constants[2] = 96487 constants[3] = 0.0001 constants[4] = 1000 constants[5] = 3 constants[6] = -0.0012 constants[7] = 25850 constants[8] = 2.585e-5 constants[9] = 2.098e-6 constants[10] = 0.0007 states[1] = 8.46899983583716 constants[11] = 140 states[2] = 0.00208137744708665 states[3] = 0.815520320018128 states[4] = 0.815471795073686 constants[12] = 2e-5 constants[13] = 0.883 constants[14] = 0.117 constants[15] = 5.4 states[5] = 142.919492013701 states[6] = 0.00146331830465093 states[7] = 0.996934138278418 states[8] = 0.78841193673441 constants[16] = 1.3e-5 states[9] = 0.0019683140031203 states[10] = 0.416987850222633 constants[17] = 4e-5 constants[18] = 1.45e-6 constants[19] = 0.2 states[11] = 0.00566123148325894 constants[20] = 8.015e-8 constants[21] = 1.38e-7 constants[22] = 0.00138 constants[23] = 3.6 constants[24] = 19 constants[25] = 22 constants[26] = 880 constants[27] = 0.3 constants[28] = 1.8 constants[29] = 1.8 constants[30] = 0.1 constants[31] = 0.02 constants[32] = 0.0008 constants[33] = 50000 states[12] = 0.000103020385969363 states[13] = 0.96268028201207 constants[34] = -9 constants[35] = 7 constants[36] = 11.5 constants[37] = 1 constants[38] = 1550 constants[39] = 1.17 constants[40] = 2.4 constants[41] = 0.05 constants[42] = 0.012 constants[43] = 0.065 constants[44] = 0.00038 constants[45] = 0.0625 constants[46] = 14 constants[47] = 0.01 constants[48] = 100 states[14] = 0.990016532916529 states[15] = 0.00845823628523856 states[16] = 0.00151233172289407 constants[49] = 87.5 constants[50] = 1.38 constants[51] = 0.35 constants[52] = 0.1 constants[53] = 0.0234 constants[54] = 0.000235 constants[55] = 0.0004968 constants[56] = 5e-6 constants[57] = 0.00035 constants[58] = 2e-8 constants[59] = 1e-6 constants[60] = 0.04 constants[61] = 40 constants[62] = 0.07 states[17] = 0.0633670056927004 constants[63] = 0.002382 constants[64] = 0.05 constants[65] = 0 constants[66] = 0.00015 constants[67] = 2100.00 constants[68] = 1.00000-constants[19] constants[69] = constants[36]/constants[37] constants[70] = constants[41]/constants[39] return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic algebraic[8] = 1.00000/(1.00000+exp((states[0]+87.5000)/10.3000)) rates[10] = (algebraic[8]-states[10])/constants[67] algebraic[1] = 1.00000/(1.00000+exp((states[0]+45.0000)/-6.50000)) algebraic[11] = 1.36000/((0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))+0.0800000*exp(-states[0]/11.0000)) rates[2] = (algebraic[1]-states[2])/algebraic[11] algebraic[2] = 1.00000/(1.00000+exp((states[0]+76.1000)/6.07000)) algebraic[12] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.453700*(1.00000+exp(-(states[0]+10.6600)/11.1000)) , True, 3.49000/(0.135000*exp(-(states[0]+80.0000)/6.80000)+3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0]))]) rates[3] = (algebraic[2]-states[3])/algebraic[12] algebraic[3] = 1.00000/(1.00000+exp((states[0]+76.1000)/6.07000)) algebraic[13] = custom_piecewise([greater_equal(states[0] , -40.0000), (11.6300*(1.00000+exp(-0.100000*(states[0]+32.0000))))/exp(-2.53500e-07*states[0]) , True, 3.49000/(((states[0]+37.7800)/(1.00000+exp(0.311000*(states[0]+79.2300))))*(-127140.*exp(0.244400*states[0])-3.47400e-05*exp(-0.0439100*states[0]))+(0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400))))]) rates[4] = (algebraic[3]-states[4])/algebraic[13] algebraic[14] = 100.000/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000))) algebraic[4] = 1.00000/(1.00000+exp((states[0]+10.6000)/-11.4200)) rates[6] = (algebraic[4]-states[6])/algebraic[14] algebraic[15] = 20.0000*exp(-(power((states[0]+70.0000)/25.0000, 2.00000)))+35.0000 algebraic[5] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410)) rates[7] = (algebraic[5]-states[7])/algebraic[15] algebraic[16] = 1300.00*exp(-(power((states[0]+70.0000)/30.0000, 2.00000)))+35.0000 algebraic[6] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410)) rates[8] = (algebraic[6]-states[8])/algebraic[16] algebraic[17] = 10000.0/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000))) algebraic[7] = 1.00000/(1.00000+exp((states[0]+11.5000)/-11.8200)) rates[9] = (algebraic[7]-states[9])/algebraic[17] algebraic[18] = 1000.00/(0.118850*exp((states[0]+80.0000)/28.3700)+0.562300*exp((states[0]+80.0000)/-14.1900)) algebraic[9] = 1.00000/(1.00000+exp((states[0]+138.600)/10.4800)) rates[11] = (algebraic[9]-states[11])/algebraic[18] algebraic[23] = ((constants[0]*constants[1])/constants[2])*log(constants[15]/states[5]) algebraic[24] = constants[12]*states[6]*(constants[13]*states[7]+constants[14]*states[8])*(states[0]-algebraic[23]) algebraic[25] = constants[16]*states[9]*states[10]*(states[0]-algebraic[23]) algebraic[26] = ((0.0480000/(exp((states[0]+37.0000)/25.0000)+exp((states[0]+37.0000)/-25.0000))+0.0100000)*0.00100000)/(1.00000+exp((states[0]-(algebraic[23]+76.7700))/-17.0000))+(constants[17]*(states[0]-(algebraic[23]+1.73000)))/((1.00000+exp((1.61300*constants[2]*(states[0]-(algebraic[23]+1.73000)))/(constants[0]*constants[1])))*(1.00000+exp((constants[15]-0.998800)/-0.124000))) algebraic[31] = constants[21]*(states[0]-algebraic[23]) algebraic[33] = constants[23]*(power(1.00000+constants[24]/states[1], 2.00000))*(1.00000+(constants[25]/states[1])*exp(((-constants[27]*constants[2]*states[0])/constants[0])/constants[1]))+(power(1.00000+constants[28]/constants[15], 2.00000))*(1.00000+(constants[11]/constants[26])*exp(((-(1.00000-constants[27])*constants[2]*states[0])/constants[0])/constants[1])) algebraic[34] = (constants[22]*(constants[23]+1.00000))/algebraic[33] algebraic[20] = custom_piecewise([greater_equal(voi-floor(voi/constants[4])*constants[4] , 0.00000) & less_equal(voi-floor(voi/constants[4])*constants[4] , constants[5]), constants[6] , True, 0.00000]) algebraic[28] = constants[18]*states[11]*constants[68]*(states[0]-algebraic[23]) rates[5] = (-(algebraic[20]+algebraic[25]+algebraic[31]+algebraic[24]+algebraic[26]+algebraic[28]+-2.00000*algebraic[34])*1.00000)/(constants[8]*constants[2]) algebraic[0] = (constants[2]*states[0])/(constants[0]*constants[1]) algebraic[19] = 2.00000*algebraic[0] algebraic[44] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-09), (states[12]+((constants[32]/constants[30])*constants[29]*algebraic[19]*exp(-algebraic[19]))/(1.00000-exp(-algebraic[19])))/(1.00000+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19]))) , True, (states[12]+(constants[32]/constants[30])*constants[29])/(1.00000+constants[32]/constants[30])]) algebraic[46] = (power(algebraic[44], 2.00000)+constants[47]*(power(constants[43], 2.00000)))/(constants[40]*(power(algebraic[44], 2.00000)+power(constants[43], 2.00000))) algebraic[40] = (power(states[12], 2.00000)+constants[47]*(power(constants[43], 2.00000)))/(constants[40]*(power(states[12], 2.00000)+power(constants[43], 2.00000))) algebraic[35] = exp((states[0]-constants[34])/constants[35]) algebraic[36] = algebraic[35]/(constants[37]*(algebraic[35]+1.00000)) algebraic[37] = (power(states[12], 2.00000))/(constants[39]*(power(states[12], 2.00000)+power(constants[43], 2.00000))) algebraic[45] = (power(algebraic[44], 2.00000))/(constants[39]*(power(algebraic[44], 2.00000)+power(constants[43], 2.00000))) algebraic[52] = (algebraic[36]+constants[69])*((constants[69]+constants[70]+algebraic[45])*(constants[70]+algebraic[37])+algebraic[36]*(constants[70]+algebraic[45])) algebraic[53] = (algebraic[36]*constants[70]*(algebraic[36]+constants[69]+constants[70]+algebraic[37]))/algebraic[52] algebraic[56] = (constants[69]*constants[70]*(constants[69]+algebraic[36]+constants[70]+algebraic[45]))/algebraic[52] algebraic[57] = algebraic[53]*algebraic[46]+algebraic[56]*algebraic[40] algebraic[47] = (constants[42]*constants[48]*(power(algebraic[44], 2.00000)+constants[47]*(power(constants[43], 2.00000))))/(constants[40]*(constants[48]*(power(algebraic[44], 2.00000))+constants[47]*(power(constants[43], 2.00000)))) algebraic[41] = (constants[42]*constants[48]*(power(states[12], 2.00000)+constants[47]*(power(constants[43], 2.00000))))/(constants[40]*(constants[48]*(power(states[12], 2.00000))+constants[47]*(power(constants[43], 2.00000)))) algebraic[59] = (algebraic[36]*algebraic[47]+constants[69]*algebraic[41])/(algebraic[36]+constants[69]) algebraic[42] = (states[12]+(constants[31]/constants[30])*states[13])/(1.00000+constants[31]/constants[30]) algebraic[43] = (algebraic[42]*(algebraic[35]+constants[45]))/(constants[38]*constants[44]*(algebraic[35]+1.00000)) algebraic[38] = (states[12]*(algebraic[35]+constants[45]))/(constants[38]*constants[44]*(algebraic[35]+1.00000)) algebraic[54] = (constants[69]*(algebraic[37]*(constants[69]+constants[70]+algebraic[45])+algebraic[45]*algebraic[36]))/algebraic[52] algebraic[65] = algebraic[54]*algebraic[43]+algebraic[56]*algebraic[38] algebraic[39] = (constants[46]*(algebraic[35]+constants[45]))/(constants[38]*(constants[46]*algebraic[35]+constants[45])) algebraic[67] = algebraic[39] rates[14] = -(algebraic[57]+algebraic[65])*states[14]+algebraic[59]*states[15]+algebraic[67]*states[16] algebraic[69] = (constants[69]*algebraic[38])/(algebraic[36]+constants[69]) algebraic[71] = algebraic[39] algebraic[73] = ((1.00000-states[14])-states[15])-states[16] rates[15] = (algebraic[57]*states[14]-(algebraic[59]+algebraic[69])*states[15])+algebraic[71]*algebraic[73] algebraic[61] = (constants[70]*algebraic[40])/(constants[70]+algebraic[37]) algebraic[63] = algebraic[41] rates[16] = (algebraic[65]*states[14]-(algebraic[67]+algebraic[61])*states[16])+algebraic[63]*algebraic[73] algebraic[21] = ((constants[0]*constants[1])/constants[2])*log(constants[11]/states[1]) algebraic[22] = constants[10]*(power(states[2], 3.00000))*states[3]*states[4]*(states[0]-algebraic[21]) algebraic[30] = constants[20]*(states[0]-algebraic[21]) algebraic[74] = (constants[53]*(exp(constants[51]*algebraic[0])*(power(states[1], 3.00000))*constants[29]-exp((constants[51]-1.00000)*algebraic[0])*(power(constants[11], 3.00000))*states[12]))/((power(constants[11], 3.00000)+power(constants[49], 3.00000))*(constants[29]+constants[50])*(1.00000+constants[52]*exp((constants[51]-1.00000)*algebraic[0]))) algebraic[75] = algebraic[74]*constants[2]*constants[8] algebraic[27] = constants[18]*states[11]*constants[19]*(states[0]-algebraic[21]) rates[1] = (-(algebraic[22]+algebraic[30]+algebraic[75]*3.00000+algebraic[34]*3.00000+algebraic[27])*1.00000)/(constants[8]*constants[2]) algebraic[29] = algebraic[27]+algebraic[28] algebraic[77] = (constants[56]*states[12])/(constants[57]+states[12]) algebraic[78] = algebraic[77]*2.00000*constants[2]*constants[8] algebraic[51] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-05), (((constants[32]*algebraic[19])/(1.00000-exp(-algebraic[19])))*((constants[29]*exp(-algebraic[19])-states[12])+(constants[31]/constants[30])*(constants[29]*exp(-algebraic[19])-states[13])))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(algebraic[19]))) , True, (((constants[32]*1.00000e-05)/(1.00000-exp(-1.00000e-05)))*((constants[29]*exp(-1.00000e-05)-states[12])+(constants[31]/constants[30])*(constants[29]*exp(-1.00000e-05)-states[13])))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))]) algebraic[50] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-05), (((constants[32]*algebraic[19])/(1.00000-exp(-algebraic[19])))*(constants[29]*exp(-algebraic[19])-states[12]))/(1.00000+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19]))) , True, (((constants[32]*1.00000e-05)/(1.00000-exp(-1.00000e-05)))*(constants[29]*exp(-1.00000e-05)-states[12]))/(1.00000+((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))]) algebraic[55] = (algebraic[36]*(algebraic[45]*(algebraic[36]+constants[70]+algebraic[37])+algebraic[37]*constants[69]))/algebraic[52] algebraic[66] = algebraic[51]*algebraic[55]+algebraic[50]*algebraic[53] algebraic[68] = (algebraic[50]*algebraic[36])/(algebraic[36]+constants[69]) algebraic[70] = ((states[14]*algebraic[66]+states[15]*algebraic[68])*constants[33])/constants[7] algebraic[72] = -algebraic[70]*2.00000*constants[2]*constants[8] algebraic[79] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[29]/states[12]) algebraic[80] = constants[58]*(algebraic[79]-states[0]) algebraic[81] = -algebraic[80]*2.00000*constants[2]*constants[8] rates[0] = -(algebraic[22]+algebraic[24]+algebraic[25]+algebraic[29]+algebraic[26]+algebraic[30]+algebraic[31]+algebraic[34]+algebraic[81]+algebraic[75]+algebraic[78]+algebraic[72]+algebraic[20])/constants[3] algebraic[48] = (constants[31]*(states[13]-states[12]))/(1.00000+constants[31]/constants[30]) algebraic[49] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-05), (constants[31]*((states[13]-states[12])+(((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19])))*(states[13]-constants[29]*exp(-algebraic[19]))))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19]))) , True, (constants[31]*((states[13]-states[12])+(((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))*(states[13]-constants[29]*exp(-1.00000e-05))))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))]) algebraic[58] = algebraic[55]*algebraic[49]+algebraic[48]*algebraic[54] algebraic[60] = (algebraic[48]*algebraic[37])/(constants[70]+algebraic[37]) algebraic[62] = ((states[14]*algebraic[58]+states[16]*algebraic[60])*constants[33])/constants[7] algebraic[64] = algebraic[62] algebraic[76] = (constants[54]*(power(states[12], 2.00000)))/(power(constants[55], 2.00000)+power(states[12], 2.00000)) algebraic[82] = constants[59]*(states[13]-states[12]) rates[13] = (constants[8]/constants[9])*((-algebraic[64]+algebraic[76])-algebraic[82]) algebraic[83] = constants[60]*(constants[62]-states[17])-constants[61]*states[17]*states[12] rates[17] = algebraic[83] algebraic[84] = power(1.00000+(constants[63]*constants[64])/(power(constants[63]+states[12], 2.00000))+(constants[65]*constants[66])/(power(constants[66]+states[12], 2.00000)), -1.00000) rates[12] = algebraic[84]*(((algebraic[64]-algebraic[76])+algebraic[82]+algebraic[83])-(-2.00000*algebraic[75]+algebraic[72]+algebraic[78]+algebraic[81])/(2.00000*constants[8]*constants[2])) return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[8] = 1.00000/(1.00000+exp((states[0]+87.5000)/10.3000)) algebraic[1] = 1.00000/(1.00000+exp((states[0]+45.0000)/-6.50000)) algebraic[11] = 1.36000/((0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))+0.0800000*exp(-states[0]/11.0000)) algebraic[2] = 1.00000/(1.00000+exp((states[0]+76.1000)/6.07000)) algebraic[12] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.453700*(1.00000+exp(-(states[0]+10.6600)/11.1000)) , True, 3.49000/(0.135000*exp(-(states[0]+80.0000)/6.80000)+3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0]))]) algebraic[3] = 1.00000/(1.00000+exp((states[0]+76.1000)/6.07000)) algebraic[13] = custom_piecewise([greater_equal(states[0] , -40.0000), (11.6300*(1.00000+exp(-0.100000*(states[0]+32.0000))))/exp(-2.53500e-07*states[0]) , True, 3.49000/(((states[0]+37.7800)/(1.00000+exp(0.311000*(states[0]+79.2300))))*(-127140.*exp(0.244400*states[0])-3.47400e-05*exp(-0.0439100*states[0]))+(0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400))))]) algebraic[14] = 100.000/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000))) algebraic[4] = 1.00000/(1.00000+exp((states[0]+10.6000)/-11.4200)) algebraic[15] = 20.0000*exp(-(power((states[0]+70.0000)/25.0000, 2.00000)))+35.0000 algebraic[5] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410)) algebraic[16] = 1300.00*exp(-(power((states[0]+70.0000)/30.0000, 2.00000)))+35.0000 algebraic[6] = 1.00000/(1.00000+exp((states[0]+45.3000)/6.88410)) algebraic[17] = 10000.0/(45.1600*exp(0.0357700*(states[0]+50.0000))+98.9000*exp(-0.100000*(states[0]+38.0000))) algebraic[7] = 1.00000/(1.00000+exp((states[0]+11.5000)/-11.8200)) algebraic[18] = 1000.00/(0.118850*exp((states[0]+80.0000)/28.3700)+0.562300*exp((states[0]+80.0000)/-14.1900)) algebraic[9] = 1.00000/(1.00000+exp((states[0]+138.600)/10.4800)) algebraic[23] = ((constants[0]*constants[1])/constants[2])*log(constants[15]/states[5]) algebraic[24] = constants[12]*states[6]*(constants[13]*states[7]+constants[14]*states[8])*(states[0]-algebraic[23]) algebraic[25] = constants[16]*states[9]*states[10]*(states[0]-algebraic[23]) algebraic[26] = ((0.0480000/(exp((states[0]+37.0000)/25.0000)+exp((states[0]+37.0000)/-25.0000))+0.0100000)*0.00100000)/(1.00000+exp((states[0]-(algebraic[23]+76.7700))/-17.0000))+(constants[17]*(states[0]-(algebraic[23]+1.73000)))/((1.00000+exp((1.61300*constants[2]*(states[0]-(algebraic[23]+1.73000)))/(constants[0]*constants[1])))*(1.00000+exp((constants[15]-0.998800)/-0.124000))) algebraic[31] = constants[21]*(states[0]-algebraic[23]) algebraic[33] = constants[23]*(power(1.00000+constants[24]/states[1], 2.00000))*(1.00000+(constants[25]/states[1])*exp(((-constants[27]*constants[2]*states[0])/constants[0])/constants[1]))+(power(1.00000+constants[28]/constants[15], 2.00000))*(1.00000+(constants[11]/constants[26])*exp(((-(1.00000-constants[27])*constants[2]*states[0])/constants[0])/constants[1])) algebraic[34] = (constants[22]*(constants[23]+1.00000))/algebraic[33] algebraic[20] = custom_piecewise([greater_equal(voi-floor(voi/constants[4])*constants[4] , 0.00000) & less_equal(voi-floor(voi/constants[4])*constants[4] , constants[5]), constants[6] , True, 0.00000]) algebraic[28] = constants[18]*states[11]*constants[68]*(states[0]-algebraic[23]) algebraic[0] = (constants[2]*states[0])/(constants[0]*constants[1]) algebraic[19] = 2.00000*algebraic[0] algebraic[44] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-09), (states[12]+((constants[32]/constants[30])*constants[29]*algebraic[19]*exp(-algebraic[19]))/(1.00000-exp(-algebraic[19])))/(1.00000+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19]))) , True, (states[12]+(constants[32]/constants[30])*constants[29])/(1.00000+constants[32]/constants[30])]) algebraic[46] = (power(algebraic[44], 2.00000)+constants[47]*(power(constants[43], 2.00000)))/(constants[40]*(power(algebraic[44], 2.00000)+power(constants[43], 2.00000))) algebraic[40] = (power(states[12], 2.00000)+constants[47]*(power(constants[43], 2.00000)))/(constants[40]*(power(states[12], 2.00000)+power(constants[43], 2.00000))) algebraic[35] = exp((states[0]-constants[34])/constants[35]) algebraic[36] = algebraic[35]/(constants[37]*(algebraic[35]+1.00000)) algebraic[37] = (power(states[12], 2.00000))/(constants[39]*(power(states[12], 2.00000)+power(constants[43], 2.00000))) algebraic[45] = (power(algebraic[44], 2.00000))/(constants[39]*(power(algebraic[44], 2.00000)+power(constants[43], 2.00000))) algebraic[52] = (algebraic[36]+constants[69])*((constants[69]+constants[70]+algebraic[45])*(constants[70]+algebraic[37])+algebraic[36]*(constants[70]+algebraic[45])) algebraic[53] = (algebraic[36]*constants[70]*(algebraic[36]+constants[69]+constants[70]+algebraic[37]))/algebraic[52] algebraic[56] = (constants[69]*constants[70]*(constants[69]+algebraic[36]+constants[70]+algebraic[45]))/algebraic[52] algebraic[57] = algebraic[53]*algebraic[46]+algebraic[56]*algebraic[40] algebraic[47] = (constants[42]*constants[48]*(power(algebraic[44], 2.00000)+constants[47]*(power(constants[43], 2.00000))))/(constants[40]*(constants[48]*(power(algebraic[44], 2.00000))+constants[47]*(power(constants[43], 2.00000)))) algebraic[41] = (constants[42]*constants[48]*(power(states[12], 2.00000)+constants[47]*(power(constants[43], 2.00000))))/(constants[40]*(constants[48]*(power(states[12], 2.00000))+constants[47]*(power(constants[43], 2.00000)))) algebraic[59] = (algebraic[36]*algebraic[47]+constants[69]*algebraic[41])/(algebraic[36]+constants[69]) algebraic[42] = (states[12]+(constants[31]/constants[30])*states[13])/(1.00000+constants[31]/constants[30]) algebraic[43] = (algebraic[42]*(algebraic[35]+constants[45]))/(constants[38]*constants[44]*(algebraic[35]+1.00000)) algebraic[38] = (states[12]*(algebraic[35]+constants[45]))/(constants[38]*constants[44]*(algebraic[35]+1.00000)) algebraic[54] = (constants[69]*(algebraic[37]*(constants[69]+constants[70]+algebraic[45])+algebraic[45]*algebraic[36]))/algebraic[52] algebraic[65] = algebraic[54]*algebraic[43]+algebraic[56]*algebraic[38] algebraic[39] = (constants[46]*(algebraic[35]+constants[45]))/(constants[38]*(constants[46]*algebraic[35]+constants[45])) algebraic[67] = algebraic[39] algebraic[69] = (constants[69]*algebraic[38])/(algebraic[36]+constants[69]) algebraic[71] = algebraic[39] algebraic[73] = ((1.00000-states[14])-states[15])-states[16] algebraic[61] = (constants[70]*algebraic[40])/(constants[70]+algebraic[37]) algebraic[63] = algebraic[41] algebraic[21] = ((constants[0]*constants[1])/constants[2])*log(constants[11]/states[1]) algebraic[22] = constants[10]*(power(states[2], 3.00000))*states[3]*states[4]*(states[0]-algebraic[21]) algebraic[30] = constants[20]*(states[0]-algebraic[21]) algebraic[74] = (constants[53]*(exp(constants[51]*algebraic[0])*(power(states[1], 3.00000))*constants[29]-exp((constants[51]-1.00000)*algebraic[0])*(power(constants[11], 3.00000))*states[12]))/((power(constants[11], 3.00000)+power(constants[49], 3.00000))*(constants[29]+constants[50])*(1.00000+constants[52]*exp((constants[51]-1.00000)*algebraic[0]))) algebraic[75] = algebraic[74]*constants[2]*constants[8] algebraic[27] = constants[18]*states[11]*constants[19]*(states[0]-algebraic[21]) algebraic[29] = algebraic[27]+algebraic[28] algebraic[77] = (constants[56]*states[12])/(constants[57]+states[12]) algebraic[78] = algebraic[77]*2.00000*constants[2]*constants[8] algebraic[51] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-05), (((constants[32]*algebraic[19])/(1.00000-exp(-algebraic[19])))*((constants[29]*exp(-algebraic[19])-states[12])+(constants[31]/constants[30])*(constants[29]*exp(-algebraic[19])-states[13])))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(algebraic[19]))) , True, (((constants[32]*1.00000e-05)/(1.00000-exp(-1.00000e-05)))*((constants[29]*exp(-1.00000e-05)-states[12])+(constants[31]/constants[30])*(constants[29]*exp(-1.00000e-05)-states[13])))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))]) algebraic[50] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-05), (((constants[32]*algebraic[19])/(1.00000-exp(-algebraic[19])))*(constants[29]*exp(-algebraic[19])-states[12]))/(1.00000+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19]))) , True, (((constants[32]*1.00000e-05)/(1.00000-exp(-1.00000e-05)))*(constants[29]*exp(-1.00000e-05)-states[12]))/(1.00000+((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))]) algebraic[55] = (algebraic[36]*(algebraic[45]*(algebraic[36]+constants[70]+algebraic[37])+algebraic[37]*constants[69]))/algebraic[52] algebraic[66] = algebraic[51]*algebraic[55]+algebraic[50]*algebraic[53] algebraic[68] = (algebraic[50]*algebraic[36])/(algebraic[36]+constants[69]) algebraic[70] = ((states[14]*algebraic[66]+states[15]*algebraic[68])*constants[33])/constants[7] algebraic[72] = -algebraic[70]*2.00000*constants[2]*constants[8] algebraic[79] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[29]/states[12]) algebraic[80] = constants[58]*(algebraic[79]-states[0]) algebraic[81] = -algebraic[80]*2.00000*constants[2]*constants[8] algebraic[48] = (constants[31]*(states[13]-states[12]))/(1.00000+constants[31]/constants[30]) algebraic[49] = custom_piecewise([greater(fabs(algebraic[19]) , 1.00000e-05), (constants[31]*((states[13]-states[12])+(((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19])))*(states[13]-constants[29]*exp(-algebraic[19]))))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*algebraic[19])/(1.00000-exp(-algebraic[19]))) , True, (constants[31]*((states[13]-states[12])+(((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))*(states[13]-constants[29]*exp(-1.00000e-05))))/(1.00000+constants[31]/constants[30]+((constants[32]/constants[30])*1.00000e-05)/(1.00000-exp(-1.00000e-05)))]) algebraic[58] = algebraic[55]*algebraic[49]+algebraic[48]*algebraic[54] algebraic[60] = (algebraic[48]*algebraic[37])/(constants[70]+algebraic[37]) algebraic[62] = ((states[14]*algebraic[58]+states[16]*algebraic[60])*constants[33])/constants[7] algebraic[64] = algebraic[62] algebraic[76] = (constants[54]*(power(states[12], 2.00000)))/(power(constants[55], 2.00000)+power(states[12], 2.00000)) algebraic[82] = constants[59]*(states[13]-states[12]) algebraic[83] = constants[60]*(constants[62]-states[17])-constants[61]*states[17]*states[12] algebraic[84] = power(1.00000+(constants[63]*constants[64])/(power(constants[63]+states[12], 2.00000))+(constants[65]*constants[66])/(power(constants[66]+states[12], 2.00000)), -1.00000) algebraic[10] = states[12] algebraic[32] = algebraic[30]+algebraic[31] 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)