# Size of variable arrays: sizeAlgebraic = 89 sizeStates = 19 sizeConstants = 79 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 cell (millivolt)" legend_constants[0] = "R in component cell (joule_per_kilomole_kelvin)" legend_constants[1] = "T in component cell (kelvin)" legend_constants[2] = "F in component cell (coulomb_per_mole)" legend_algebraic[3] = "I_st in component cell (microA_per_microF)" legend_algebraic[27] = "i_Na in component fast_sodium_current (microA_per_microF)" legend_algebraic[74] = "i_Ca_L in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[79] = "i_Ca_T in component T_type_Ca_channel (microA_per_microF)" legend_algebraic[43] = "i_Kr in component rapid_delayed_rectifier_potassium_current (microA_per_microF)" legend_algebraic[76] = "i_Ks in component slow_delayed_rectifier_potassium_current (microA_per_microF)" legend_algebraic[54] = "i_K_Na in component sodium_activated_potassium_current (microA_per_microF)" legend_algebraic[84] = "i_NaCa in component Na_Ca_exchanger (microA_per_microF)" legend_algebraic[49] = "i_K1 in component time_independent_potassium_current (microA_per_microF)" legend_algebraic[44] = "i_K_ATP in component ATP_sensitive_potassium_current (microA_per_microF)" legend_algebraic[45] = "i_to in component transient_outward_current (microA_per_microF)" legend_algebraic[51] = "i_Kp in component plateau_potassium_current (microA_per_microF)" legend_algebraic[77] = "i_p_Ca in component sarcolemmal_calcium_pump (microA_per_microF)" legend_algebraic[55] = "i_Na_b in component sodium_background_current (microA_per_microF)" legend_algebraic[80] = "i_Ca_b in component calcium_background_current (microA_per_microF)" legend_algebraic[57] = "i_NaK in component sodium_potassium_pump (microA_per_microF)" legend_algebraic[83] = "i_ns_Ca in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[85] = "dVdt in component cell (microA_per_microF)" legend_constants[3] = "stim_start in component cell (ms)" legend_constants[4] = "stim_end in component cell (ms)" legend_constants[5] = "stim_period in component cell (ms)" legend_constants[6] = "stim_duration in component cell (ms)" legend_constants[7] = "stim_amplitude in component cell (microA_per_microF)" legend_algebraic[16] = "E_Na in component fast_sodium_current (millivolt)" legend_constants[8] = "g_Na in component fast_sodium_current (milliS_per_microF)" legend_states[1] = "Nai in component ionic_concentrations (millimolar)" legend_constants[9] = "Nao in component ionic_concentrations (millimolar)" legend_states[2] = "m in component fast_sodium_current_m_gate (dimensionless)" legend_states[3] = "h in component fast_sodium_current_h_gate (dimensionless)" legend_states[4] = "j in component fast_sodium_current_j_gate (dimensionless)" legend_algebraic[13] = "alpha_m in component fast_sodium_current_m_gate (per_ms)" legend_algebraic[26] = "beta_m in component fast_sodium_current_m_gate (per_ms)" legend_algebraic[0] = "E0_m in component fast_sodium_current_m_gate (millivolt)" legend_algebraic[1] = "alpha_h in component fast_sodium_current_h_gate (per_ms)" legend_algebraic[14] = "beta_h in component fast_sodium_current_h_gate (per_ms)" legend_algebraic[2] = "alpha_j in component fast_sodium_current_j_gate (per_ms)" legend_algebraic[15] = "beta_j in component fast_sodium_current_j_gate (per_ms)" legend_algebraic[69] = "i_CaCa in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[72] = "i_CaK in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[70] = "i_CaNa in component L_type_Ca_channel (microA_per_microF)" legend_constants[10] = "gamma_Nai in component L_type_Ca_channel (dimensionless)" legend_constants[11] = "gamma_Nao in component L_type_Ca_channel (dimensionless)" legend_constants[12] = "gamma_Ki in component L_type_Ca_channel (dimensionless)" legend_constants[13] = "gamma_Ko in component L_type_Ca_channel (dimensionless)" legend_constants[14] = "gamma_Cai in component L_type_Ca_channel (dimensionless)" legend_constants[15] = "gamma_Cao in component L_type_Ca_channel (dimensionless)" legend_algebraic[67] = "I_CaCa in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[37] = "I_CaK in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[32] = "I_CaNa in component L_type_Ca_channel (microA_per_microF)" legend_constants[16] = "P_Ca in component L_type_Ca_channel (litre_per_farad_millisecond)" legend_constants[17] = "P_Na in component L_type_Ca_channel (litre_per_farad_millisecond)" legend_constants[18] = "P_K in component L_type_Ca_channel (litre_per_farad_millisecond)" legend_algebraic[66] = "Cai in component calcium_dynamics (millimolar)" legend_constants[19] = "Cao in component calcium_dynamics (millimolar)" legend_constants[20] = "Ko in component ionic_concentrations (millimolar)" legend_states[5] = "Ki in component ionic_concentrations (millimolar)" legend_states[6] = "d in component L_type_Ca_channel_d_gate (dimensionless)" legend_states[7] = "f in component L_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[68] = "f_Ca in component L_type_Ca_channel_f_Ca_gate (dimensionless)" legend_algebraic[33] = "alpha_d in component L_type_Ca_channel_d_gate (per_ms)" legend_algebraic[38] = "beta_d in component L_type_Ca_channel_d_gate (per_ms)" legend_algebraic[17] = "d_infinity in component L_type_Ca_channel_d_gate (dimensionless)" legend_algebraic[28] = "tau_d in component L_type_Ca_channel_d_gate (ms)" legend_algebraic[4] = "E0_d in component L_type_Ca_channel_d_gate (millivolt)" legend_algebraic[29] = "alpha_f in component L_type_Ca_channel_f_gate (per_ms)" legend_algebraic[34] = "beta_f in component L_type_Ca_channel_f_gate (per_ms)" legend_algebraic[5] = "f_infinity in component L_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[18] = "tau_f in component L_type_Ca_channel_f_gate (ms)" legend_constants[21] = "Km_Ca in component L_type_Ca_channel_f_Ca_gate (millimolar)" legend_constants[22] = "g_CaT in component T_type_Ca_channel (milliS_per_microF)" legend_algebraic[78] = "E_Ca in component calcium_background_current (millivolt)" legend_states[8] = "b in component T_type_Ca_channel_b_gate (dimensionless)" legend_states[9] = "g in component T_type_Ca_channel_g_gate (dimensionless)" legend_algebraic[6] = "b_inf in component T_type_Ca_channel_b_gate (dimensionless)" legend_algebraic[19] = "tau_b in component T_type_Ca_channel_b_gate (ms)" legend_algebraic[7] = "g_inf in component T_type_Ca_channel_g_gate (dimensionless)" legend_algebraic[20] = "tau_g in component T_type_Ca_channel_g_gate (ms)" legend_constants[66] = "g_Kr in component rapid_delayed_rectifier_potassium_current (milliS_per_microF)" legend_constants[23] = "G_Kr in component rapid_delayed_rectifier_potassium_current (milliS_per_microF)" legend_algebraic[39] = "Rect in component rapid_delayed_rectifier_potassium_current (dimensionless)" legend_algebraic[42] = "E_K in component time_independent_potassium_current (millivolt)" legend_states[10] = "xr in component rapid_delayed_rectifier_potassium_current_xr_gate (dimensionless)" legend_algebraic[8] = "xr_infinity in component rapid_delayed_rectifier_potassium_current_xr_gate (dimensionless)" legend_algebraic[21] = "tau_xr in component rapid_delayed_rectifier_potassium_current_xr_gate (ms)" legend_algebraic[75] = "g_Ks in component slow_delayed_rectifier_potassium_current (milliS_per_microF)" legend_constants[24] = "G_Ks in component slow_delayed_rectifier_potassium_current (milliS_per_microF)" legend_algebraic[40] = "E_Ks in component slow_delayed_rectifier_potassium_current (millivolt)" legend_constants[25] = "PNaK in component slow_delayed_rectifier_potassium_current (dimensionless)" legend_states[11] = "xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_states[12] = "xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (dimensionless)" legend_algebraic[9] = "xs1_infinity in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_algebraic[22] = "tau_xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (ms)" legend_algebraic[10] = "xs2_infinity in component slow_delayed_rectifier_potassium_current_xs2_gate (dimensionless)" legend_algebraic[23] = "tau_xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (ms)" legend_constants[67] = "g_K_ATP in component ATP_sensitive_potassium_current (milliS_per_microF)" legend_constants[26] = "i_K_ATP_on in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[27] = "nATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[28] = "nicholsarea in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[29] = "ATPi in component ATP_sensitive_potassium_current (millimolar)" legend_constants[30] = "hATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[31] = "kATP in component ATP_sensitive_potassium_current (millimolar)" legend_constants[74] = "pATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[76] = "GKbaraATP in component ATP_sensitive_potassium_current (milliS_per_microF)" legend_constants[68] = "g_to in component transient_outward_current (milliS_per_microF)" legend_algebraic[41] = "rvdv in component transient_outward_current (dimensionless)" legend_states[13] = "zdv in component transient_outward_current_zdv_gate (dimensionless)" legend_states[14] = "ydv in component transient_outward_current_ydv_gate (dimensionless)" legend_algebraic[11] = "alpha_zdv in component transient_outward_current_zdv_gate (per_ms)" legend_algebraic[24] = "beta_zdv in component transient_outward_current_zdv_gate (per_ms)" legend_algebraic[30] = "tau_zdv in component transient_outward_current_zdv_gate (ms)" legend_algebraic[35] = "zdv_ss in component transient_outward_current_zdv_gate (dimensionless)" legend_algebraic[12] = "alpha_ydv in component transient_outward_current_ydv_gate (per_ms)" legend_algebraic[25] = "beta_ydv in component transient_outward_current_ydv_gate (per_ms)" legend_algebraic[31] = "tau_ydv in component transient_outward_current_ydv_gate (ms)" legend_algebraic[36] = "ydv_ss in component transient_outward_current_ydv_gate (dimensionless)" legend_constants[69] = "g_K1 in component time_independent_potassium_current (milliS_per_microF)" legend_constants[32] = "G_K1 in component time_independent_potassium_current (milliS_per_microF)" legend_algebraic[48] = "K1_infinity in component time_independent_potassium_current_K1_gate (dimensionless)" legend_algebraic[46] = "alpha_K1 in component time_independent_potassium_current_K1_gate (per_ms)" legend_algebraic[47] = "beta_K1 in component time_independent_potassium_current_K1_gate (per_ms)" legend_constants[33] = "g_Kp in component plateau_potassium_current (milliS_per_microF)" legend_algebraic[50] = "Kp in component plateau_potassium_current (dimensionless)" legend_constants[34] = "g_K_Na in component sodium_activated_potassium_current (milliS_per_microF)" legend_constants[35] = "nKNa in component sodium_activated_potassium_current (dimensionless)" legend_algebraic[52] = "pona in component sodium_activated_potassium_current (dimensionless)" legend_algebraic[53] = "pov in component sodium_activated_potassium_current (dimensionless)" legend_constants[36] = "kdKNa in component sodium_activated_potassium_current (millimolar)" legend_constants[37] = "K_mpCa in component sarcolemmal_calcium_pump (millimolar)" legend_constants[38] = "I_pCa in component sarcolemmal_calcium_pump (microA_per_microF)" legend_constants[39] = "g_Nab in component sodium_background_current (milliS_per_microF)" legend_constants[40] = "g_Cab in component calcium_background_current (milliS_per_microF)" legend_constants[41] = "I_NaK in component sodium_potassium_pump (microA_per_microF)" legend_algebraic[56] = "f_NaK in component sodium_potassium_pump (dimensionless)" legend_constants[42] = "K_mNai in component sodium_potassium_pump (millimolar)" legend_constants[43] = "K_mKo in component sodium_potassium_pump (millimolar)" legend_constants[70] = "sigma in component sodium_potassium_pump (dimensionless)" legend_algebraic[81] = "i_ns_Na in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[82] = "i_ns_K in component non_specific_calcium_activated_current (microA_per_microF)" legend_constants[71] = "P_ns_Ca in component non_specific_calcium_activated_current (litre_per_farad_millisecond)" legend_algebraic[58] = "I_ns_Na in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[59] = "I_ns_K in component non_specific_calcium_activated_current (microA_per_microF)" legend_constants[44] = "K_m_ns_Ca in component non_specific_calcium_activated_current (millimolar)" legend_constants[45] = "c1 in component Na_Ca_exchanger (microA_per_microF)" legend_constants[46] = "c2 in component Na_Ca_exchanger (dimensionless)" legend_constants[47] = "gamma in component Na_Ca_exchanger (dimensionless)" legend_states[15] = "i_rel in component CICR_current (millimolar_per_ms)" legend_algebraic[86] = "i_up in component calcium_dynamics (millimolar_per_ms)" legend_algebraic[87] = "i_leak in component calcium_dynamics (millimolar_per_ms)" legend_algebraic[88] = "i_tr in component calcium_dynamics (millimolar_per_ms)" legend_constants[48] = "tau_tr in component calcium_dynamics (ms)" legend_constants[49] = "CSQN_max in component calcium_dynamics (millimolar)" legend_constants[50] = "K_mCSQN in component calcium_dynamics (millimolar)" legend_constants[51] = "K_mup in component calcium_dynamics (millimolar)" legend_constants[72] = "K_leak in component calcium_dynamics (per_ms)" legend_constants[52] = "I_up in component calcium_dynamics (millimolar_per_ms)" legend_constants[53] = "Ca_NSR_max in component calcium_dynamics (millimolar)" legend_states[16] = "CaT in component calcium_dynamics (millimolar)" legend_algebraic[62] = "Ca_JSR in component calcium_dynamics (millimolar)" legend_states[17] = "JSR in component calcium_dynamics (millimolar)" legend_states[18] = "NSR in component calcium_dynamics (millimolar)" legend_algebraic[60] = "bjsr in component calcium_dynamics (millimolar)" legend_algebraic[61] = "cjsr in component calcium_dynamics (millimolar2)" legend_algebraic[63] = "bmyo in component calcium_dynamics (millimolar)" legend_algebraic[64] = "cmyo in component calcium_dynamics (millimolar2)" legend_algebraic[65] = "dmyo in component calcium_dynamics (millimolar3)" legend_constants[75] = "V_myo in component geometry (micro_litre)" legend_constants[54] = "A_cap in component geometry (cm2)" legend_constants[77] = "V_JSR in component geometry (micro_litre)" legend_constants[78] = "V_NSR in component geometry (micro_litre)" legend_constants[55] = "K_mTRPN in component calcium_dynamics (millimolar)" legend_constants[56] = "K_mCMDN in component calcium_dynamics (millimolar)" legend_constants[57] = "TRPN_max in component calcium_dynamics (millimolar)" legend_constants[58] = "CMDN_max in component calcium_dynamics (millimolar)" legend_constants[59] = "kappa in component CICR_current (mM_per_millivolt_ms)" legend_constants[60] = "tau in component CICR_current (ms)" legend_constants[61] = "K_relss in component CICR_current (millimolar)" legend_constants[62] = "qn in component CICR_current (dimensionless)" legend_constants[65] = "alpha_rel in component CICR_current (millimolar_per_mV)" legend_algebraic[73] = "tau_rel in component CICR_current (ms)" legend_algebraic[71] = "I_relss in component CICR_current (millimolar_per_ms)" legend_constants[63] = "preplength in component geometry (mm)" legend_constants[64] = "radius in component geometry (mm)" legend_constants[73] = "volume in component geometry (micro_litre)" legend_rates[0] = "d/dt V in component cell (millivolt)" legend_rates[2] = "d/dt m in component fast_sodium_current_m_gate (dimensionless)" legend_rates[3] = "d/dt h in component fast_sodium_current_h_gate (dimensionless)" legend_rates[4] = "d/dt j in component fast_sodium_current_j_gate (dimensionless)" legend_rates[6] = "d/dt d in component L_type_Ca_channel_d_gate (dimensionless)" legend_rates[7] = "d/dt f in component L_type_Ca_channel_f_gate (dimensionless)" legend_rates[8] = "d/dt b in component T_type_Ca_channel_b_gate (dimensionless)" legend_rates[9] = "d/dt g in component T_type_Ca_channel_g_gate (dimensionless)" legend_rates[10] = "d/dt xr in component rapid_delayed_rectifier_potassium_current_xr_gate (dimensionless)" legend_rates[11] = "d/dt xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_rates[12] = "d/dt xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (dimensionless)" legend_rates[13] = "d/dt zdv in component transient_outward_current_zdv_gate (dimensionless)" legend_rates[14] = "d/dt ydv in component transient_outward_current_ydv_gate (dimensionless)" legend_rates[17] = "d/dt JSR in component calcium_dynamics (millimolar)" legend_rates[18] = "d/dt NSR in component calcium_dynamics (millimolar)" legend_rates[16] = "d/dt CaT in component calcium_dynamics (millimolar)" legend_rates[15] = "d/dt i_rel in component CICR_current (millimolar_per_ms)" legend_rates[1] = "d/dt Nai in component ionic_concentrations (millimolar)" legend_rates[5] = "d/dt Ki in component ionic_concentrations (millimolar)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; states[0] = -85.126196430406 constants[0] = 8314 constants[1] = 310 constants[2] = 96485 constants[3] = 10 constants[4] = 9e6 constants[5] = 300 constants[6] = 0.5 constants[7] = -80 constants[8] = 16 states[1] = 10 constants[9] = 140 states[2] = 0.001513296212 states[3] = 0.985318710339 states[4] = 0.990731711845 constants[10] = 0.75 constants[11] = 0.75 constants[12] = 0.75 constants[13] = 0.75 constants[14] = 1 constants[15] = 0.341 constants[16] = 0.00054 constants[17] = 6.75e-7 constants[18] = 1.93e-7 constants[19] = 1.8 constants[20] = 5.4 states[5] = 144.473230653346 states[6] = 0.000005906564 states[7] = 0.999390880784 constants[21] = 0.0006 constants[22] = 0.05 states[8] = 0.001378275288 states[9] = 0.988597502434 constants[23] = 0.02614 states[10] = 0.000207067204 constants[24] = 0.433 constants[25] = 0.01833 states[11] = 0.007136102382 states[12] = 0.039518996812 constants[26] = 1 constants[27] = 0.24 constants[28] = 5e-5 constants[29] = 3 constants[30] = 2 constants[31] = 0.00025 states[13] = 0.014537782303 states[14] = 0.99993940527 constants[32] = 0.75 constants[33] = 0.00552 constants[34] = 0.12848 constants[35] = 2.8 constants[36] = 66 constants[37] = 0.0005 constants[38] = 1.15 constants[39] = 0.004 constants[40] = 0.003016 constants[41] = 2.25 constants[42] = 10 constants[43] = 1.5 constants[44] = 0.0012 constants[45] = 0.00025 constants[46] = 0.0001 constants[47] = 0.15 states[15] = -0.000000000000000000474565 constants[48] = 120 constants[49] = 10 constants[50] = 0.8 constants[51] = 0.00092 constants[52] = 0.00875 constants[53] = 15 states[16] = 0.01544711 states[17] = 8.290468 states[18] = 1.516756041281 constants[54] = 1.534e-4 constants[55] = 0.0005 constants[56] = 0.00238 constants[57] = 0.07 constants[58] = 0.05 constants[59] = 0.125 constants[60] = 4.75 constants[61] = 1 constants[62] = 9 constants[63] = 0.1 constants[64] = 0.011 constants[65] = constants[59]*constants[60] constants[66] = constants[23]*(power(constants[20]/5.40000, 1.0/2)) constants[67] = (constants[26]*0.000193000)/constants[28] constants[68] = 0.00000*0.500000 constants[69] = constants[32]*(power(constants[20]/5.40000, 1.0/2)) constants[70] = (1.00000/7.00000)*(exp(constants[9]/67.3000)-1.00000) constants[71] = 1.75000e-07 constants[72] = constants[52]/constants[53] constants[73] = pi*constants[63]*(power(constants[64], 2.00000)) constants[74] = 1.00000/(1.00000+power(constants[29]/constants[31], constants[30])) constants[75] = 0.680000*constants[73] constants[76] = constants[67]*constants[74]*(power(constants[20]/4.00000, constants[27])) constants[77] = 0.00480000*constants[73] constants[78] = 0.0552000*constants[73] return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic algebraic[1] = custom_piecewise([less(states[0] , -40.0000), 0.135000*exp((80.0000+states[0])/-6.80000) , True, 0.00000]) algebraic[14] = custom_piecewise([less(states[0] , -40.0000), 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0]) , True, 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000)))]) rates[3] = algebraic[1]*(1.00000-states[3])-algebraic[14]*states[3] algebraic[2] = custom_piecewise([less(states[0] , -40.0000), (-(127140.*exp(0.244400*states[0])+3.47400e-05*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300))) , True, 0.00000]) algebraic[15] = custom_piecewise([less(states[0] , -40.0000), (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400))) , True, (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000)))]) rates[4] = algebraic[2]*(1.00000-states[4])-algebraic[15]*states[4] algebraic[6] = 1.00000/(1.00000+exp(-(states[0]+14.0000)/10.8000)) algebraic[19] = 3.70000+6.10000/(1.00000+exp((states[0]+25.0000)/4.50000)) rates[8] = (algebraic[6]-states[8])/algebraic[19] algebraic[7] = 1.00000/(1.00000+exp((states[0]+60.0000)/5.60000)) algebraic[20] = custom_piecewise([less_equal(states[0] , 0.00000), -0.875000*states[0]+12.0000 , True, 12.0000]) rates[9] = (algebraic[7]-states[9])/algebraic[20] algebraic[8] = 1.00000/(1.00000+exp(-(states[0]+21.5000)/7.50000)) algebraic[21] = 1.00000/((0.00138000*(states[0]+14.2000))/(1.00000-exp(-0.123000*(states[0]+14.2000)))+(0.000610000*(states[0]+38.9000))/(exp(0.145000*(states[0]+38.9000))-1.00000)) rates[10] = (algebraic[8]-states[10])/algebraic[21] algebraic[9] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[22] = 1.00000/((7.19000e-05*(states[0]+30.0000))/(1.00000-exp(-0.148000*(states[0]+30.0000)))+(0.000131000*(states[0]+30.0000))/(exp(0.0687000*(states[0]+30.0000))-1.00000)) rates[11] = (algebraic[9]-states[11])/algebraic[22] algebraic[10] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[23] = 4.00000/((7.19000e-05*(states[0]+30.0000))/(1.00000-exp(-0.148000*(states[0]+30.0000)))+(0.000131000*(states[0]+30.0000))/(exp(0.0687000*(states[0]+30.0000))-1.00000)) rates[12] = (algebraic[10]-states[12])/algebraic[23] algebraic[0] = states[0]+47.1300 algebraic[13] = (0.320000*algebraic[0])/(1.00000-exp(-0.100000*algebraic[0])) algebraic[26] = 0.0800000*exp(-states[0]/11.0000) rates[2] = algebraic[13]*(1.00000-states[2])-algebraic[26]*states[2] algebraic[5] = 1.00000/(1.00000+exp((states[0]+32.0000)/8.00000))+0.600000/(1.00000+exp((50.0000-states[0])/20.0000)) algebraic[18] = 1.00000/(0.0197000*exp(-(power(0.0337000*(states[0]+10.0000), 2.00000)))+0.0200000) algebraic[29] = algebraic[5]/algebraic[18] algebraic[34] = (1.00000-algebraic[5])/algebraic[18] rates[7] = algebraic[29]*(1.00000-states[7])-algebraic[34]*states[7] algebraic[11] = (10.0000*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000)) algebraic[24] = (10.0000*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000)) algebraic[30] = 1.00000/(algebraic[11]+algebraic[24]) algebraic[35] = algebraic[11]/(algebraic[11]+algebraic[24]) rates[13] = (algebraic[35]-states[13])/algebraic[30] algebraic[12] = 0.0150000/(1.00000+exp((states[0]+60.0000)/5.00000)) algebraic[25] = (0.100000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000)) algebraic[31] = 1.00000/(algebraic[12]+algebraic[25]) algebraic[36] = algebraic[12]/(algebraic[12]+algebraic[25]) rates[14] = (algebraic[36]-states[14])/algebraic[31] algebraic[4] = states[0]+10.0000 algebraic[17] = 1.00000/(1.00000+exp(-algebraic[4]/6.24000)) algebraic[28] = (1.00000*algebraic[17]*(1.00000-exp(-algebraic[4]/6.24000)))/(0.0350000*algebraic[4]) algebraic[33] = algebraic[17]/algebraic[28] algebraic[38] = (1.00000-algebraic[17])/algebraic[28] rates[6] = algebraic[33]*(1.00000-states[6])-algebraic[38]*states[6] algebraic[60] = constants[49]+constants[50]+-states[17] algebraic[61] = constants[50]*states[17] algebraic[62] = (power(power(algebraic[60], 2.00000)+4.00000*algebraic[61], 1.0/2)-algebraic[60])/2.00000 algebraic[73] = constants[60]/(1.00000+0.0123000/algebraic[62]) algebraic[63] = constants[58]+constants[57]+constants[56]+constants[55]+-states[16] algebraic[64] = constants[56]*constants[55]+constants[57]*constants[56]+constants[58]*constants[55]+-states[16]*(constants[55]+constants[56]) algebraic[65] = -constants[55]*constants[56]*states[16] algebraic[66] = (2.00000/3.00000)*(power(power(algebraic[63], 2.00000)-3.00000*algebraic[64], 1.0/2))*cos(arccos((9.00000*algebraic[63]*algebraic[64]-(2.00000*(power(algebraic[63], 3.00000))+27.0000*algebraic[65]))/(2.00000*(power(power(power(algebraic[63], 2.00000)-3.00000*algebraic[64], 3.00000), 1.0/2))))/3.00000)-algebraic[63]/3.00000 algebraic[67] = (((constants[16]*(power(2.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[14]*algebraic[66]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[15]*constants[19]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[68] = 1.00000/(1.00000+algebraic[66]/constants[21]) algebraic[69] = states[6]*states[7]*algebraic[68]*algebraic[67] algebraic[71] = (algebraic[69]*constants[65])/(1.00000+power(constants[61]/algebraic[62], constants[62])) rates[15] = -(algebraic[71]+states[15])/algebraic[73] algebraic[3] = custom_piecewise([greater_equal(voi , constants[3]) & less_equal(voi , constants[4]) & less_equal((voi-constants[3])-floor((voi-constants[3])/constants[5])*constants[5] , constants[6]), constants[7] , True, 0.00000]) algebraic[39] = 1.00000/(1.00000+exp((states[0]+9.00000)/22.4000)) algebraic[42] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[5]) algebraic[43] = constants[66]*states[10]*algebraic[39]*(states[0]-algebraic[42]) algebraic[75] = constants[24]*(1.00000+0.600000/(1.00000+power(3.80000e-05/algebraic[66], 1.40000))) algebraic[40] = ((constants[0]*constants[1])/constants[2])*log((constants[20]+constants[25]*constants[9])/(states[5]+constants[25]*states[1])) algebraic[76] = algebraic[75]*states[11]*states[12]*(states[0]-algebraic[40]) algebraic[52] = 0.850000/(1.00000+power(constants[36]/states[1], constants[35])) algebraic[53] = 0.800000-0.650000/(1.00000+exp((states[0]+125.000)/15.0000)) algebraic[54] = constants[34]*algebraic[52]*algebraic[53]*(states[0]-algebraic[42]) algebraic[46] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[42])-59.2150))) algebraic[47] = (1.00000*(0.491240*exp(0.0803200*((states[0]-algebraic[42])+5.47600))+exp(0.0617500*((states[0]-algebraic[42])-594.310))))/(1.00000+exp(-0.514300*((states[0]-algebraic[42])+4.75300))) algebraic[48] = algebraic[46]/(algebraic[46]+algebraic[47]) algebraic[49] = constants[69]*algebraic[48]*(states[0]-algebraic[42]) algebraic[44] = constants[76]*(states[0]-algebraic[42]) algebraic[41] = exp(states[0]/100.000) algebraic[45] = constants[68]*(power(states[13], 3.00000))*states[14]*algebraic[41]*(states[0]-algebraic[42]) algebraic[50] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000)) algebraic[51] = constants[33]*algebraic[50]*(states[0]-algebraic[42]) algebraic[56] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0365000*constants[70]*exp((-states[0]*constants[2])/(constants[0]*constants[1]))) algebraic[57] = ((constants[41]*algebraic[56])/(1.00000+power(constants[42]/states[1], 2.00000)))/(1.00000+constants[43]/constants[20]) algebraic[37] = (((constants[18]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[12]*states[5]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[13]*constants[20]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[72] = states[6]*states[7]*algebraic[68]*algebraic[37] algebraic[59] = (((constants[71]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[12]*states[5]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[13]*constants[20]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[82] = (algebraic[59]*1.00000)/(1.00000+power(constants[44]/algebraic[66], 3.00000)) rates[5] = (-1.00000*(algebraic[3]+algebraic[72]+algebraic[43]+algebraic[76]+algebraic[49]+algebraic[44]+algebraic[45]+algebraic[51]+algebraic[54]+algebraic[82]+-algebraic[57]*2.00000)*constants[54])/(constants[75]*constants[2]) algebraic[16] = ((constants[0]*constants[1])/constants[2])*log(constants[9]/states[1]) algebraic[27] = constants[8]*(power(states[2], 3.00000))*states[3]*states[4]*(states[0]-algebraic[16]) algebraic[84] = (constants[45]*exp(((constants[47]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1]))*(exp((states[0]*constants[2])/(constants[0]*constants[1]))*(power(states[1], 3.00000))*constants[19]-(power(constants[9], 3.00000))*algebraic[66]))/(1.00000+constants[46]*exp(((constants[47]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1]))*(exp((states[0]*constants[2])/(constants[0]*constants[1]))*(power(states[1], 3.00000))*constants[19]+(power(constants[9], 3.00000))*algebraic[66])) algebraic[55] = constants[39]*(states[0]-algebraic[16]) algebraic[32] = (((constants[17]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[10]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[11]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[70] = states[6]*states[7]*algebraic[68]*algebraic[32] algebraic[58] = (((constants[71]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[10]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[11]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[81] = (algebraic[58]*1.00000)/(1.00000+power(constants[44]/algebraic[66], 3.00000)) rates[1] = (-1.00000*(algebraic[27]+algebraic[70]+algebraic[55]+algebraic[81]+algebraic[84]*3.00000+algebraic[57]*3.00000)*constants[54])/(constants[75]*constants[2]) algebraic[74] = algebraic[69]+algebraic[72]+algebraic[70] algebraic[78] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[19]/algebraic[66]) algebraic[79] = constants[22]*states[8]*states[8]*states[9]*(states[0]-algebraic[78]) algebraic[77] = (constants[38]*algebraic[66])/(constants[37]+algebraic[66]) algebraic[80] = constants[40]*(states[0]-algebraic[78]) algebraic[83] = algebraic[81]+algebraic[82] algebraic[85] = -(algebraic[27]+algebraic[74]+algebraic[79]+algebraic[43]+algebraic[76]+algebraic[54]+algebraic[49]+algebraic[44]+algebraic[45]+algebraic[51]+algebraic[84]+algebraic[77]+algebraic[55]+algebraic[80]+algebraic[57]+algebraic[83]+algebraic[3]) rates[0] = algebraic[85] algebraic[86] = (constants[52]*algebraic[66])/(algebraic[66]+constants[51]) algebraic[87] = constants[72]*states[18] rates[16] = (-1.00000*constants[54]*(algebraic[69]+algebraic[79]+algebraic[77]+algebraic[80]+-2.00000*algebraic[84]))/(2.00000*constants[75]*constants[2])+(states[15]*constants[77])/constants[75]+((algebraic[87]-algebraic[86])*constants[78])/constants[75] algebraic[88] = (states[18]-algebraic[62])/constants[48] rates[17] = algebraic[88]-states[15] rates[18] = ((-algebraic[88]*constants[77])/constants[78]-algebraic[87])+algebraic[86] return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[1] = custom_piecewise([less(states[0] , -40.0000), 0.135000*exp((80.0000+states[0])/-6.80000) , True, 0.00000]) algebraic[14] = custom_piecewise([less(states[0] , -40.0000), 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0]) , True, 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000)))]) algebraic[2] = custom_piecewise([less(states[0] , -40.0000), (-(127140.*exp(0.244400*states[0])+3.47400e-05*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300))) , True, 0.00000]) algebraic[15] = custom_piecewise([less(states[0] , -40.0000), (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400))) , True, (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000)))]) algebraic[6] = 1.00000/(1.00000+exp(-(states[0]+14.0000)/10.8000)) algebraic[19] = 3.70000+6.10000/(1.00000+exp((states[0]+25.0000)/4.50000)) algebraic[7] = 1.00000/(1.00000+exp((states[0]+60.0000)/5.60000)) algebraic[20] = custom_piecewise([less_equal(states[0] , 0.00000), -0.875000*states[0]+12.0000 , True, 12.0000]) algebraic[8] = 1.00000/(1.00000+exp(-(states[0]+21.5000)/7.50000)) algebraic[21] = 1.00000/((0.00138000*(states[0]+14.2000))/(1.00000-exp(-0.123000*(states[0]+14.2000)))+(0.000610000*(states[0]+38.9000))/(exp(0.145000*(states[0]+38.9000))-1.00000)) algebraic[9] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[22] = 1.00000/((7.19000e-05*(states[0]+30.0000))/(1.00000-exp(-0.148000*(states[0]+30.0000)))+(0.000131000*(states[0]+30.0000))/(exp(0.0687000*(states[0]+30.0000))-1.00000)) algebraic[10] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[23] = 4.00000/((7.19000e-05*(states[0]+30.0000))/(1.00000-exp(-0.148000*(states[0]+30.0000)))+(0.000131000*(states[0]+30.0000))/(exp(0.0687000*(states[0]+30.0000))-1.00000)) algebraic[0] = states[0]+47.1300 algebraic[13] = (0.320000*algebraic[0])/(1.00000-exp(-0.100000*algebraic[0])) algebraic[26] = 0.0800000*exp(-states[0]/11.0000) algebraic[5] = 1.00000/(1.00000+exp((states[0]+32.0000)/8.00000))+0.600000/(1.00000+exp((50.0000-states[0])/20.0000)) algebraic[18] = 1.00000/(0.0197000*exp(-(power(0.0337000*(states[0]+10.0000), 2.00000)))+0.0200000) algebraic[29] = algebraic[5]/algebraic[18] algebraic[34] = (1.00000-algebraic[5])/algebraic[18] algebraic[11] = (10.0000*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000)) algebraic[24] = (10.0000*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000)) algebraic[30] = 1.00000/(algebraic[11]+algebraic[24]) algebraic[35] = algebraic[11]/(algebraic[11]+algebraic[24]) algebraic[12] = 0.0150000/(1.00000+exp((states[0]+60.0000)/5.00000)) algebraic[25] = (0.100000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000)) algebraic[31] = 1.00000/(algebraic[12]+algebraic[25]) algebraic[36] = algebraic[12]/(algebraic[12]+algebraic[25]) algebraic[4] = states[0]+10.0000 algebraic[17] = 1.00000/(1.00000+exp(-algebraic[4]/6.24000)) algebraic[28] = (1.00000*algebraic[17]*(1.00000-exp(-algebraic[4]/6.24000)))/(0.0350000*algebraic[4]) algebraic[33] = algebraic[17]/algebraic[28] algebraic[38] = (1.00000-algebraic[17])/algebraic[28] algebraic[60] = constants[49]+constants[50]+-states[17] algebraic[61] = constants[50]*states[17] algebraic[62] = (power(power(algebraic[60], 2.00000)+4.00000*algebraic[61], 1.0/2)-algebraic[60])/2.00000 algebraic[73] = constants[60]/(1.00000+0.0123000/algebraic[62]) algebraic[63] = constants[58]+constants[57]+constants[56]+constants[55]+-states[16] algebraic[64] = constants[56]*constants[55]+constants[57]*constants[56]+constants[58]*constants[55]+-states[16]*(constants[55]+constants[56]) algebraic[65] = -constants[55]*constants[56]*states[16] algebraic[66] = (2.00000/3.00000)*(power(power(algebraic[63], 2.00000)-3.00000*algebraic[64], 1.0/2))*cos(arccos((9.00000*algebraic[63]*algebraic[64]-(2.00000*(power(algebraic[63], 3.00000))+27.0000*algebraic[65]))/(2.00000*(power(power(power(algebraic[63], 2.00000)-3.00000*algebraic[64], 3.00000), 1.0/2))))/3.00000)-algebraic[63]/3.00000 algebraic[67] = (((constants[16]*(power(2.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[14]*algebraic[66]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[15]*constants[19]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[68] = 1.00000/(1.00000+algebraic[66]/constants[21]) algebraic[69] = states[6]*states[7]*algebraic[68]*algebraic[67] algebraic[71] = (algebraic[69]*constants[65])/(1.00000+power(constants[61]/algebraic[62], constants[62])) algebraic[3] = custom_piecewise([greater_equal(voi , constants[3]) & less_equal(voi , constants[4]) & less_equal((voi-constants[3])-floor((voi-constants[3])/constants[5])*constants[5] , constants[6]), constants[7] , True, 0.00000]) algebraic[39] = 1.00000/(1.00000+exp((states[0]+9.00000)/22.4000)) algebraic[42] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[5]) algebraic[43] = constants[66]*states[10]*algebraic[39]*(states[0]-algebraic[42]) algebraic[75] = constants[24]*(1.00000+0.600000/(1.00000+power(3.80000e-05/algebraic[66], 1.40000))) algebraic[40] = ((constants[0]*constants[1])/constants[2])*log((constants[20]+constants[25]*constants[9])/(states[5]+constants[25]*states[1])) algebraic[76] = algebraic[75]*states[11]*states[12]*(states[0]-algebraic[40]) algebraic[52] = 0.850000/(1.00000+power(constants[36]/states[1], constants[35])) algebraic[53] = 0.800000-0.650000/(1.00000+exp((states[0]+125.000)/15.0000)) algebraic[54] = constants[34]*algebraic[52]*algebraic[53]*(states[0]-algebraic[42]) algebraic[46] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[42])-59.2150))) algebraic[47] = (1.00000*(0.491240*exp(0.0803200*((states[0]-algebraic[42])+5.47600))+exp(0.0617500*((states[0]-algebraic[42])-594.310))))/(1.00000+exp(-0.514300*((states[0]-algebraic[42])+4.75300))) algebraic[48] = algebraic[46]/(algebraic[46]+algebraic[47]) algebraic[49] = constants[69]*algebraic[48]*(states[0]-algebraic[42]) algebraic[44] = constants[76]*(states[0]-algebraic[42]) algebraic[41] = exp(states[0]/100.000) algebraic[45] = constants[68]*(power(states[13], 3.00000))*states[14]*algebraic[41]*(states[0]-algebraic[42]) algebraic[50] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000)) algebraic[51] = constants[33]*algebraic[50]*(states[0]-algebraic[42]) algebraic[56] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0365000*constants[70]*exp((-states[0]*constants[2])/(constants[0]*constants[1]))) algebraic[57] = ((constants[41]*algebraic[56])/(1.00000+power(constants[42]/states[1], 2.00000)))/(1.00000+constants[43]/constants[20]) algebraic[37] = (((constants[18]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[12]*states[5]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[13]*constants[20]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[72] = states[6]*states[7]*algebraic[68]*algebraic[37] algebraic[59] = (((constants[71]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[12]*states[5]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[13]*constants[20]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[82] = (algebraic[59]*1.00000)/(1.00000+power(constants[44]/algebraic[66], 3.00000)) algebraic[16] = ((constants[0]*constants[1])/constants[2])*log(constants[9]/states[1]) algebraic[27] = constants[8]*(power(states[2], 3.00000))*states[3]*states[4]*(states[0]-algebraic[16]) algebraic[84] = (constants[45]*exp(((constants[47]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1]))*(exp((states[0]*constants[2])/(constants[0]*constants[1]))*(power(states[1], 3.00000))*constants[19]-(power(constants[9], 3.00000))*algebraic[66]))/(1.00000+constants[46]*exp(((constants[47]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1]))*(exp((states[0]*constants[2])/(constants[0]*constants[1]))*(power(states[1], 3.00000))*constants[19]+(power(constants[9], 3.00000))*algebraic[66])) algebraic[55] = constants[39]*(states[0]-algebraic[16]) algebraic[32] = (((constants[17]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[10]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[11]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[70] = states[6]*states[7]*algebraic[68]*algebraic[32] algebraic[58] = (((constants[71]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[10]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[11]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[81] = (algebraic[58]*1.00000)/(1.00000+power(constants[44]/algebraic[66], 3.00000)) algebraic[74] = algebraic[69]+algebraic[72]+algebraic[70] algebraic[78] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[19]/algebraic[66]) algebraic[79] = constants[22]*states[8]*states[8]*states[9]*(states[0]-algebraic[78]) algebraic[77] = (constants[38]*algebraic[66])/(constants[37]+algebraic[66]) algebraic[80] = constants[40]*(states[0]-algebraic[78]) algebraic[83] = algebraic[81]+algebraic[82] algebraic[85] = -(algebraic[27]+algebraic[74]+algebraic[79]+algebraic[43]+algebraic[76]+algebraic[54]+algebraic[49]+algebraic[44]+algebraic[45]+algebraic[51]+algebraic[84]+algebraic[77]+algebraic[55]+algebraic[80]+algebraic[57]+algebraic[83]+algebraic[3]) algebraic[86] = (constants[52]*algebraic[66])/(algebraic[66]+constants[51]) algebraic[87] = constants[72]*states[18] algebraic[88] = (states[18]-algebraic[62])/constants[48] 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)