# Size of variable arrays: sizeAlgebraic = 85 sizeStates = 25 sizeConstants = 81 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[28] = "i_Na in component fast_sodium_current (microA_per_microF)" legend_algebraic[45] = "i_Ca_L in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[67] = "i_Ca_T in component T_type_Ca_channel (microA_per_microF)" legend_algebraic[51] = "i_Kr in component rapid_delayed_rectifier_potassium_current (microA_per_microF)" legend_algebraic[49] = "i_Ks in component slow_delayed_rectifier_potassium_current (microA_per_microF)" legend_algebraic[60] = "i_K_Na in component sodium_activated_potassium_current (microA_per_microF)" legend_algebraic[61] = "i_K_ATP in component ATP_sensitive_potassium_current (microA_per_microF)" legend_algebraic[63] = "i_to in component transient_outward_current (microA_per_microF)" legend_algebraic[76] = "i_NaCa in component Na_Ca_exchanger (microA_per_microF)" legend_algebraic[55] = "i_K1 in component time_independent_potassium_current (microA_per_microF)" legend_algebraic[57] = "i_Kp in component plateau_potassium_current (microA_per_microF)" legend_algebraic[64] = "i_p_Ca in component sarcolemmal_calcium_pump (microA_per_microF)" legend_algebraic[65] = "i_Na_b in component sodium_background_current (microA_per_microF)" legend_algebraic[68] = "i_Ca_b in component calcium_background_current (microA_per_microF)" legend_algebraic[70] = "i_NaK in component sodium_potassium_pump (microA_per_microF)" legend_algebraic[75] = "i_ns_Ca in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[77] = "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[17] = "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[14] = "alpha_m in component fast_sodium_current_m_gate (per_ms)" legend_algebraic[27] = "beta_m in component fast_sodium_current_m_gate (per_ms)" legend_constants[10] = "delta_m in component fast_sodium_current_m_gate (millivolt)" 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[15] = "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[16] = "beta_j in component fast_sodium_current_j_gate (per_ms)" legend_algebraic[42] = "i_CaCa in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[44] = "i_CaK in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[43] = "i_CaNa in component L_type_Ca_channel (microA_per_microF)" legend_constants[11] = "gamma_Nai in component L_type_Ca_channel (dimensionless)" legend_constants[12] = "gamma_Nao in component L_type_Ca_channel (dimensionless)" legend_constants[13] = "gamma_Ki in component L_type_Ca_channel (dimensionless)" legend_constants[14] = "gamma_Ko in component L_type_Ca_channel (dimensionless)" legend_constants[15] = "gamma_Cai in component L_type_Ca_channel (dimensionless)" legend_constants[16] = "gamma_Cao in component L_type_Ca_channel (dimensionless)" legend_algebraic[33] = "I_CaCa in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[40] = "I_CaK in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[38] = "I_CaNa in component L_type_Ca_channel (microA_per_microF)" legend_constants[17] = "P_Ca in component L_type_Ca_channel (litre_per_farad_millisecond)" legend_constants[18] = "P_Na in component L_type_Ca_channel (litre_per_farad_millisecond)" legend_constants[19] = "P_K in component L_type_Ca_channel (litre_per_farad_millisecond)" legend_states[5] = "Cai in component calcium_dynamics (millimolar)" legend_constants[20] = "Cao in component calcium_dynamics (millimolar)" legend_constants[21] = "Ko in component ionic_concentrations (millimolar)" legend_states[6] = "Ki in component ionic_concentrations (millimolar)" legend_states[7] = "d in component L_type_Ca_channel_d_gate (dimensionless)" legend_states[8] = "f in component L_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[41] = "f_Ca in component L_type_Ca_channel_f_Ca_gate (dimensionless)" legend_algebraic[34] = "alpha_d in component L_type_Ca_channel_d_gate (per_ms)" legend_algebraic[39] = "beta_d in component L_type_Ca_channel_d_gate (per_ms)" legend_algebraic[18] = "d_infinity in component L_type_Ca_channel_d_gate (dimensionless)" legend_algebraic[29] = "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[30] = "alpha_f in component L_type_Ca_channel_f_gate (per_ms)" legend_algebraic[35] = "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[19] = "tau_f in component L_type_Ca_channel_f_gate (ms)" legend_constants[22] = "Km_Ca in component L_type_Ca_channel_f_Ca_gate (millimolar)" legend_constants[23] = "g_CaT in component T_type_Ca_channel (milliS_per_microF)" legend_algebraic[66] = "E_Ca in component calcium_background_current (millivolt)" legend_states[9] = "b in component T_type_Ca_channel_b_gate (dimensionless)" legend_states[10] = "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[20] = "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[21] = "tau_g in component T_type_Ca_channel_g_gate (ms)" legend_constants[69] = "g_Kr in component rapid_delayed_rectifier_potassium_current (milliS_per_microF)" legend_constants[24] = "G_Kr in component rapid_delayed_rectifier_potassium_current (milliS_per_microF)" legend_algebraic[46] = "Rect in component rapid_delayed_rectifier_potassium_current (dimensionless)" legend_algebraic[50] = "E_K in component time_independent_potassium_current (millivolt)" legend_states[11] = "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[22] = "tau_xr in component rapid_delayed_rectifier_potassium_current_xr_gate (ms)" legend_algebraic[48] = "g_Ks in component slow_delayed_rectifier_potassium_current (milliS_per_microF)" legend_constants[25] = "G_Ks in component slow_delayed_rectifier_potassium_current (milliS_per_microF)" legend_algebraic[47] = "E_Ks in component slow_delayed_rectifier_potassium_current (millivolt)" legend_constants[26] = "PNaK in component slow_delayed_rectifier_potassium_current (dimensionless)" legend_states[12] = "xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_states[13] = "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[23] = "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[24] = "tau_xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (ms)" legend_constants[70] = "g_K1 in component time_independent_potassium_current (milliS_per_microF)" legend_constants[27] = "G_K1 in component time_independent_potassium_current (milliS_per_microF)" legend_algebraic[54] = "K1_infinity in component time_independent_potassium_current_K1_gate (dimensionless)" legend_algebraic[52] = "alpha_K1 in component time_independent_potassium_current_K1_gate (per_ms)" legend_algebraic[53] = "beta_K1 in component time_independent_potassium_current_K1_gate (per_ms)" legend_constants[28] = "g_Kp in component plateau_potassium_current (milliS_per_microF)" legend_algebraic[56] = "Kp in component plateau_potassium_current (dimensionless)" legend_constants[29] = "g_K_Na in component sodium_activated_potassium_current (milliS_per_microF)" legend_constants[30] = "nKNa in component sodium_activated_potassium_current (dimensionless)" legend_algebraic[58] = "pona in component sodium_activated_potassium_current (dimensionless)" legend_algebraic[59] = "pov in component sodium_activated_potassium_current (dimensionless)" legend_constants[31] = "kdKNa in component sodium_activated_potassium_current (millimolar)" legend_constants[71] = "g_K_ATP in component ATP_sensitive_potassium_current (milliS_per_microF)" legend_constants[32] = "i_K_ATP_on in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[33] = "nATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[34] = "nicholsarea in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[35] = "ATPi in component ATP_sensitive_potassium_current (millimolar)" legend_constants[36] = "hATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[37] = "kATP in component ATP_sensitive_potassium_current (millimolar)" legend_constants[77] = "pATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[79] = "GKbaraATP in component ATP_sensitive_potassium_current (milliS_per_microF)" legend_constants[72] = "g_to in component transient_outward_current (milliS_per_microF)" legend_algebraic[62] = "rvdv in component transient_outward_current (dimensionless)" legend_states[14] = "zdv in component transient_outward_current_zdv_gate (dimensionless)" legend_states[15] = "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[25] = "beta_zdv in component transient_outward_current_zdv_gate (per_ms)" legend_algebraic[31] = "tau_zdv in component transient_outward_current_zdv_gate (ms)" legend_algebraic[36] = "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[26] = "beta_ydv in component transient_outward_current_ydv_gate (per_ms)" legend_algebraic[32] = "tau_ydv in component transient_outward_current_ydv_gate (ms)" legend_algebraic[37] = "ydv_ss in component transient_outward_current_ydv_gate (dimensionless)" legend_constants[38] = "K_mpCa in component sarcolemmal_calcium_pump (millimolar)" legend_constants[39] = "I_pCa in component sarcolemmal_calcium_pump (microA_per_microF)" legend_constants[40] = "g_Nab in component sodium_background_current (milliS_per_microF)" legend_constants[41] = "g_Cab in component calcium_background_current (milliS_per_microF)" legend_constants[42] = "I_NaK in component sodium_potassium_pump (microA_per_microF)" legend_algebraic[69] = "f_NaK in component sodium_potassium_pump (dimensionless)" legend_constants[43] = "K_mNai in component sodium_potassium_pump (millimolar)" legend_constants[44] = "K_mKo in component sodium_potassium_pump (millimolar)" legend_constants[73] = "sigma in component sodium_potassium_pump (dimensionless)" legend_algebraic[73] = "i_ns_Na in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[74] = "i_ns_K in component non_specific_calcium_activated_current (microA_per_microF)" legend_constants[74] = "P_ns_Ca in component non_specific_calcium_activated_current (litre_per_farad_millisecond)" legend_algebraic[71] = "I_ns_Na in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[72] = "I_ns_K in component non_specific_calcium_activated_current (microA_per_microF)" legend_constants[45] = "K_m_ns_Ca in component non_specific_calcium_activated_current (millimolar)" legend_constants[46] = "c1 in component Na_Ca_exchanger (microA_per_microF)" legend_constants[47] = "c2 in component Na_Ca_exchanger (dimensionless)" legend_constants[48] = "gamma in component Na_Ca_exchanger (dimensionless)" legend_algebraic[81] = "i_rel in component calcium_dynamics (millimolar_per_ms)" legend_algebraic[82] = "i_up in component calcium_dynamics (millimolar_per_ms)" legend_algebraic[83] = "i_leak in component calcium_dynamics (millimolar_per_ms)" legend_algebraic[84] = "i_tr in component calcium_dynamics (millimolar_per_ms)" legend_algebraic[80] = "G_rel in component calcium_dynamics (per_ms)" legend_algebraic[13] = "G_rel_Viswanathan in component calcium_dynamics (per_ms)" legend_constants[49] = "G_rel_max in component calcium_dynamics (per_ms)" legend_constants[50] = "G_rel_overload in component calcium_dynamics (per_ms)" legend_constants[51] = "tau_tr in component calcium_dynamics (ms)" legend_constants[52] = "K_mrel in component calcium_dynamics (millimolar)" legend_constants[53] = "delta_Ca_ith in component calcium_dynamics (millimolar)" legend_constants[54] = "CSQN_max in component calcium_dynamics (millimolar)" legend_constants[55] = "K_mCSQN in component calcium_dynamics (millimolar)" legend_constants[56] = "K_mup in component calcium_dynamics (millimolar)" legend_constants[75] = "K_leak in component calcium_dynamics (per_ms)" legend_constants[57] = "I_up in component calcium_dynamics (millimolar_per_ms)" legend_constants[58] = "Ca_NSR_max in component calcium_dynamics (millimolar)" legend_states[16] = "Ca_JSR in component calcium_dynamics (millimolar)" legend_states[17] = "Ca_NSR in component calcium_dynamics (millimolar)" legend_constants[76] = "V_myo in component geometry (micro_litre)" legend_constants[59] = "A_cap in component geometry (cm2)" legend_constants[78] = "V_JSR in component geometry (micro_litre)" legend_constants[80] = "V_NSR in component geometry (micro_litre)" legend_constants[60] = "K_mTn in component calcium_dynamics (millimolar)" legend_constants[61] = "K_mCMDN in component calcium_dynamics (millimolar)" legend_constants[62] = "Tn_max in component calcium_dynamics (millimolar)" legend_constants[63] = "CMDN_max in component calcium_dynamics (millimolar)" legend_states[18] = "APtrack in component calcium_dynamics (dimensionless)" legend_states[19] = "APtrack2 in component calcium_dynamics (dimensionless)" legend_states[20] = "APtrack3 in component calcium_dynamics (dimensionless)" legend_states[21] = "Cainfluxtrack in component calcium_dynamics (millimolar)" legend_states[22] = "OVRLDtrack in component calcium_dynamics (dimensionless)" legend_states[23] = "OVRLDtrack2 in component calcium_dynamics (dimensionless)" legend_states[24] = "OVRLDtrack3 in component calcium_dynamics (dimensionless)" legend_constants[64] = "CSQNthresh in component calcium_dynamics (dimensionless)" legend_constants[65] = "Logicthresh in component calcium_dynamics (dimensionless)" legend_algebraic[78] = "RyRopen in component calcium_dynamics (dimensionless)" legend_algebraic[79] = "RyRclose in component calcium_dynamics (dimensionless)" legend_constants[66] = "preplength in component geometry (mm)" legend_constants[67] = "radius in component geometry (mm)" legend_constants[68] = "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[7] = "d/dt d in component L_type_Ca_channel_d_gate (dimensionless)" legend_rates[8] = "d/dt f in component L_type_Ca_channel_f_gate (dimensionless)" legend_rates[9] = "d/dt b in component T_type_Ca_channel_b_gate (dimensionless)" legend_rates[10] = "d/dt g in component T_type_Ca_channel_g_gate (dimensionless)" legend_rates[11] = "d/dt xr in component rapid_delayed_rectifier_potassium_current_xr_gate (dimensionless)" legend_rates[12] = "d/dt xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_rates[13] = "d/dt xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (dimensionless)" legend_rates[14] = "d/dt zdv in component transient_outward_current_zdv_gate (dimensionless)" legend_rates[15] = "d/dt ydv in component transient_outward_current_ydv_gate (dimensionless)" legend_rates[18] = "d/dt APtrack in component calcium_dynamics (dimensionless)" legend_rates[19] = "d/dt APtrack2 in component calcium_dynamics (dimensionless)" legend_rates[20] = "d/dt APtrack3 in component calcium_dynamics (dimensionless)" legend_rates[21] = "d/dt Cainfluxtrack in component calcium_dynamics (millimolar)" legend_rates[22] = "d/dt OVRLDtrack in component calcium_dynamics (dimensionless)" legend_rates[23] = "d/dt OVRLDtrack2 in component calcium_dynamics (dimensionless)" legend_rates[24] = "d/dt OVRLDtrack3 in component calcium_dynamics (dimensionless)" legend_rates[16] = "d/dt Ca_JSR in component calcium_dynamics (millimolar)" legend_rates[17] = "d/dt Ca_NSR in component calcium_dynamics (millimolar)" legend_rates[5] = "d/dt Cai in component calcium_dynamics (millimolar)" legend_rates[1] = "d/dt Nai in component ionic_concentrations (millimolar)" legend_rates[6] = "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.2132259244751 constants[0] = 8314 constants[1] = 310 constants[2] = 96485 constants[3] = 100 constants[4] = 9000000 constants[5] = 1000 constants[6] = 2 constants[7] = -25.5 constants[8] = 16 states[1] = 13.2866380281237 constants[9] = 140 states[2] = 0.00149150667653466 states[3] = 0.98560077662336 states[4] = 0.990900988999238 constants[10] = 1e-5 constants[11] = 0.75 constants[12] = 0.75 constants[13] = 0.75 constants[14] = 0.75 constants[15] = 1 constants[16] = 0.341 constants[17] = 0.00054 constants[18] = 6.75e-7 constants[19] = 1.93e-7 states[5] = 0.000115992251742132 constants[20] = 1.8 constants[21] = 5.4 states[6] = 141.139802226909 states[7] = 5.82475230952394e-06 states[8] = 0.997765766850281 constants[22] = 0.0006 constants[23] = 0.056 states[9] = 0.00087306703919284 states[10] = 0.964644023670238 constants[24] = 0.02614 states[11] = 0.000204664013529778 constants[25] = 0.433 constants[26] = 0.01833 states[12] = 0.00661079879810885 states[13] = 0.0302962988340647 constants[27] = 0.75 constants[28] = 0.00552 constants[29] = 0.12848 constants[30] = 2.8 constants[31] = 66 constants[32] = 1 constants[33] = 0.24 constants[34] = 5e-5 constants[35] = 3 constants[36] = 2 constants[37] = 0.00025 states[14] = 0.0144611004317138 states[15] = 0.999945263077137 constants[38] = 0.0005 constants[39] = 1.15 constants[40] = 0.004 constants[41] = 0.003016 constants[42] = 2.25 constants[43] = 10 constants[44] = 1.5 constants[45] = 0.0012 constants[46] = 0.00025 constants[47] = 0.0001 constants[48] = 0.15 constants[49] = 60 constants[50] = 4 constants[51] = 180 constants[52] = 0.0008 constants[53] = 0.00018 constants[54] = 10 constants[55] = 0.8 constants[56] = 0.00092 constants[57] = 0.00875 constants[58] = 15 states[16] = 1.10786985002835 states[17] = 1.74647588622419 constants[59] = 0.0001534 constants[60] = 0.0005 constants[61] = 0.00238 constants[62] = 0.07 constants[63] = 0.05 states[18] = 1.05741719313009e-195 states[19] = 5.84534012971144e-195 states[20] = 0.000129513799736416 states[21] = 2.82367737273297e-196 states[22] = 0 states[23] = 0 states[24] = 0 constants[64] = 0.7 constants[65] = 0.98 constants[66] = 0.1 constants[67] = 0.011 constants[68] = pi*constants[66]*(power(constants[67], 2.00000)) constants[69] = constants[24]*(power(constants[21]/5.40000, 1.0/2)) constants[70] = constants[27]*(power(constants[21]/5.40000, 1.0/2)) constants[71] = (constants[32]*0.000193000)/constants[34] constants[72] = 0.00000*0.500000 constants[73] = (1.00000/7.00000)*(exp(constants[9]/67.3000)-1.00000) constants[74] = 1.75000e-07 constants[75] = constants[57]/constants[58] constants[76] = 0.680000*constants[68] constants[77] = 1.00000/(1.00000+power(constants[35]/constants[37], constants[36])) constants[78] = 0.00480000*constants[68] constants[79] = constants[71]*constants[77]*(power(constants[21]/4.00000, constants[33])) constants[80] = 0.0552000*constants[68] return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic rates[19] = custom_piecewise([less(states[18] , 0.200000) & greater(states[18] , 0.180000), 100.000*(1.00000-states[19])-0.500000*states[19] , True, -0.500000*states[19]]) rates[20] = custom_piecewise([less(states[18] , 0.200000) & greater(states[18] , 0.180000), 100.000*(1.00000-states[20])-0.500000*states[20] , True, -0.0100000*states[20]]) rates[22] = custom_piecewise([greater(1.00000/(1.00000+constants[55]/states[16]) , constants[64]) & less(states[24] , 0.370000) & less(states[20] , 0.370000), 50.0000*(1.00000-states[22]) , True, -0.500000*states[22]]) rates[23] = custom_piecewise([greater(states[22] , constants[65]) & less(states[23] , constants[65]), 50.0000*(1.00000-states[23]) , True, -0.500000*states[23]]) rates[24] = custom_piecewise([greater(states[22] , constants[65]) & less(states[24] , constants[65]), 50.0000*(1.00000-states[24]) , True, -0.0100000*states[24]]) algebraic[1] = custom_piecewise([less(states[0] , -40.0000), 0.135000*exp((80.0000+states[0])/-6.80000) , True, 0.00000]) algebraic[15] = 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[15]*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[16] = 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[16]*states[4] algebraic[6] = 1.00000/(1.00000+exp(-(states[0]+50.0000)/5.00000)) algebraic[20] = 5.00000/(1.06800*exp((states[0]+16.3000)/30.0000)+1.06800*exp(-(states[0]+16.3000)/30.0000)) rates[9] = (algebraic[6]-states[9])/algebraic[20] algebraic[7] = 1.00000/(1.00000+exp((states[0]+61.0000)/5.00000)) algebraic[21] = 5.00000/(0.0150000*exp(-(states[0]+71.7000)/83.3000)+0.0150000*exp((states[0]+71.7000)/15.4000)) rates[10] = (algebraic[7]-states[10])/algebraic[21] algebraic[8] = 1.00000/(1.00000+exp(-(states[0]+21.5000)/7.50000)) algebraic[22] = 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[11] = (algebraic[8]-states[11])/algebraic[22] algebraic[9] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[23] = 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[12] = (algebraic[9]-states[12])/algebraic[23] algebraic[10] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[24] = 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[13] = (algebraic[10]-states[13])/algebraic[24] algebraic[0] = states[0]+47.1300 algebraic[14] = custom_piecewise([greater_equal(fabs(algebraic[0]) , constants[10]), (0.320000*algebraic[0])/(1.00000-exp(-0.100000*algebraic[0])) , True, 3.20000]) algebraic[27] = 0.0800000*exp(-states[0]/11.0000) rates[2] = algebraic[14]*(1.00000-states[2])-algebraic[27]*states[2] algebraic[5] = 1.00000/(1.00000+exp((states[0]+35.0600)/8.60000))+0.600000/(1.00000+exp((50.0000-states[0])/20.0000)) algebraic[19] = 1.00000/(0.0197000*exp(-(power(0.0337000*(states[0]+10.0000), 2.00000)))+0.0200000) algebraic[30] = algebraic[5]/algebraic[19] algebraic[35] = (1.00000-algebraic[5])/algebraic[19] rates[8] = algebraic[30]*(1.00000-states[8])-algebraic[35]*states[8] algebraic[11] = (10.0000*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000)) algebraic[25] = (10.0000*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000)) algebraic[31] = 1.00000/(algebraic[11]+algebraic[25]) algebraic[36] = algebraic[11]/(algebraic[11]+algebraic[25]) rates[14] = (algebraic[36]-states[14])/algebraic[31] algebraic[12] = 0.0150000/(1.00000+exp((states[0]+60.0000)/5.00000)) algebraic[26] = (0.100000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000)) algebraic[32] = 1.00000/(algebraic[12]+algebraic[26]) algebraic[37] = algebraic[12]/(algebraic[12]+algebraic[26]) rates[15] = (algebraic[37]-states[15])/algebraic[32] algebraic[4] = states[0]+10.0000 algebraic[18] = 1.00000/(1.00000+exp(-algebraic[4]/6.24000)) algebraic[29] = custom_piecewise([less(fabs(algebraic[4]) , 1.00000e-05), 1.00000/(0.0350000*6.24000*2.00000) , True, (1.00000*algebraic[18]*(1.00000-exp(-algebraic[4]/6.24000)))/(0.0350000*algebraic[4])]) algebraic[34] = algebraic[18]/algebraic[29] algebraic[39] = (1.00000-algebraic[18])/algebraic[29] rates[7] = algebraic[34]*(1.00000-states[7])-algebraic[39]*states[7] 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[46] = 1.00000/(1.00000+exp((states[0]+9.00000)/22.4000)) algebraic[50] = ((constants[0]*constants[1])/constants[2])*log(constants[21]/states[6]) algebraic[51] = constants[69]*states[11]*algebraic[46]*(states[0]-algebraic[50]) algebraic[48] = constants[25]*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[5], 1.40000))) algebraic[47] = ((constants[0]*constants[1])/constants[2])*log((constants[21]+constants[26]*constants[9])/(states[6]+constants[26]*states[1])) algebraic[49] = algebraic[48]*states[12]*states[13]*(states[0]-algebraic[47]) algebraic[58] = 0.850000/(1.00000+power(constants[31]/states[1], constants[30])) algebraic[59] = 0.800000-0.650000/(1.00000+exp((states[0]+125.000)/15.0000)) algebraic[60] = constants[29]*algebraic[58]*algebraic[59]*(states[0]-algebraic[50]) algebraic[61] = constants[79]*(states[0]-algebraic[50]) algebraic[62] = exp(states[0]/100.000) algebraic[63] = constants[72]*(power(states[14], 3.00000))*states[15]*algebraic[62]*(states[0]-algebraic[50]) algebraic[52] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[50])-59.2150))) algebraic[53] = (1.00000*(0.491240*exp(0.0803200*((states[0]-algebraic[50])+5.47600))+exp(0.0617500*((states[0]-algebraic[50])-594.310))))/(1.00000+exp(-0.514300*((states[0]-algebraic[50])+4.75300))) algebraic[54] = algebraic[52]/(algebraic[52]+algebraic[53]) algebraic[55] = constants[70]*algebraic[54]*(states[0]-algebraic[50]) algebraic[56] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000)) algebraic[57] = constants[28]*algebraic[56]*(states[0]-algebraic[50]) algebraic[69] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0365000*constants[73]*exp((-states[0]*constants[2])/(constants[0]*constants[1]))) algebraic[70] = (((constants[42]*algebraic[69]*1.00000)/(1.00000+power(constants[43]/states[1], 2.00000)))*constants[21])/(constants[21]+constants[44]) algebraic[40] = (((constants[19]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[6]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[14]*constants[21]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[41] = 1.00000/(1.00000+states[5]/constants[22]) algebraic[44] = states[7]*states[8]*algebraic[41]*algebraic[40] algebraic[72] = (((constants[74]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[6]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[14]*constants[21]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[74] = (algebraic[72]*1.00000)/(1.00000+power(constants[45]/states[5], 3.00000)) rates[6] = (-1.00000*(algebraic[3]+algebraic[44]+algebraic[51]+algebraic[49]+algebraic[55]+algebraic[57]+algebraic[60]+algebraic[61]+algebraic[63]+algebraic[74]+-algebraic[70]*2.00000)*constants[59])/(constants[76]*constants[2]) algebraic[66] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[20]/states[5]) algebraic[67] = constants[23]*states[9]*states[9]*states[10]*(states[0]-algebraic[66]) algebraic[76] = (constants[46]*exp(((constants[48]-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[20]-(power(constants[9], 3.00000))*states[5]))/(1.00000+constants[47]*exp(((constants[48]-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[20]+(power(constants[9], 3.00000))*states[5])) algebraic[64] = (constants[39]*states[5])/(constants[38]+states[5]) algebraic[68] = constants[41]*(states[0]-algebraic[66]) algebraic[33] = (((constants[17]*(power(2.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[15]*states[5]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[16]*constants[20]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[42] = states[7]*states[8]*algebraic[41]*algebraic[33] rates[21] = custom_piecewise([greater(states[18] , 0.200000), (-1.00000*constants[59]*(((algebraic[42]+algebraic[67])-2.00000*algebraic[76])+algebraic[64]+algebraic[68]))/(2.00000*constants[76]*constants[2]) , greater(states[19] , 0.0100000) & less_equal(states[18] , 0.200000), 0.00000 , True, -0.500000*states[21]]) algebraic[17] = ((constants[0]*constants[1])/constants[2])*log(constants[9]/states[1]) algebraic[28] = constants[8]*(power(states[2], 3.00000))*states[3]*states[4]*(states[0]-algebraic[17]) algebraic[65] = constants[40]*(states[0]-algebraic[17]) algebraic[38] = (((constants[18]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[11]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[12]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[43] = states[7]*states[8]*algebraic[41]*algebraic[38] algebraic[71] = (((constants[74]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[11]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[12]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[73] = (algebraic[71]*1.00000)/(1.00000+power(constants[45]/states[5], 3.00000)) rates[1] = (-1.00000*(algebraic[28]+algebraic[43]+algebraic[65]+algebraic[73]+algebraic[76]*3.00000+algebraic[70]*3.00000)*constants[59])/(constants[76]*constants[2]) algebraic[45] = algebraic[42]+algebraic[44]+algebraic[43] algebraic[75] = algebraic[73]+algebraic[74] algebraic[77] = -(algebraic[28]+algebraic[45]+algebraic[67]+algebraic[51]+algebraic[49]+algebraic[60]+algebraic[61]+algebraic[63]+algebraic[55]+algebraic[57]+algebraic[76]+algebraic[64]+algebraic[65]+algebraic[68]+algebraic[70]+algebraic[75]+algebraic[3]) rates[0] = algebraic[77] rates[18] = custom_piecewise([greater(algebraic[77] , 150.000), 100.000*(1.00000-states[18])-0.500000*states[18] , True, -0.500000*states[18]]) algebraic[78] = 1.00000/(1.00000+exp(2.00000)*states[19]) algebraic[79] = 1.00000-algebraic[78] algebraic[80] = (algebraic[78]*algebraic[79]*150.000)/(1.00000+exp((((algebraic[42]+algebraic[67])-2.00000*algebraic[76])+algebraic[64]+algebraic[68]+5.00000)/0.900000)) algebraic[81] = algebraic[80]*(states[16]-states[5]) algebraic[82] = (constants[57]*states[5])/(states[5]+constants[56]) algebraic[83] = constants[75]*states[17] rates[5] = (1.00000/(1.00000+(constants[63]*constants[61])/(power(constants[61]+states[5], 2.00000))+(constants[62]*constants[60])/(power(constants[60]+states[5], 2.00000))))*((-1.00000*constants[59]*(((algebraic[42]+algebraic[67])-2.00000*algebraic[76])+algebraic[64]+algebraic[68]))/(2.00000*constants[76]*constants[2])+(algebraic[81]*constants[78])/constants[76]+((algebraic[83]-algebraic[82])*constants[80])/constants[76]) algebraic[84] = (states[17]-states[16])/constants[51] rates[16] = (1.00000/(1.00000+(constants[54]*constants[55])/(power(constants[55]+states[16], 2.00000))))*(algebraic[84]-algebraic[81]) rates[17] = ((-algebraic[84]*constants[78])/constants[80]-algebraic[83])+algebraic[82] 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[15] = 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[16] = 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]+50.0000)/5.00000)) algebraic[20] = 5.00000/(1.06800*exp((states[0]+16.3000)/30.0000)+1.06800*exp(-(states[0]+16.3000)/30.0000)) algebraic[7] = 1.00000/(1.00000+exp((states[0]+61.0000)/5.00000)) algebraic[21] = 5.00000/(0.0150000*exp(-(states[0]+71.7000)/83.3000)+0.0150000*exp((states[0]+71.7000)/15.4000)) algebraic[8] = 1.00000/(1.00000+exp(-(states[0]+21.5000)/7.50000)) algebraic[22] = 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[23] = 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[24] = 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[14] = custom_piecewise([greater_equal(fabs(algebraic[0]) , constants[10]), (0.320000*algebraic[0])/(1.00000-exp(-0.100000*algebraic[0])) , True, 3.20000]) algebraic[27] = 0.0800000*exp(-states[0]/11.0000) algebraic[5] = 1.00000/(1.00000+exp((states[0]+35.0600)/8.60000))+0.600000/(1.00000+exp((50.0000-states[0])/20.0000)) algebraic[19] = 1.00000/(0.0197000*exp(-(power(0.0337000*(states[0]+10.0000), 2.00000)))+0.0200000) algebraic[30] = algebraic[5]/algebraic[19] algebraic[35] = (1.00000-algebraic[5])/algebraic[19] algebraic[11] = (10.0000*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000)) algebraic[25] = (10.0000*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000)) algebraic[31] = 1.00000/(algebraic[11]+algebraic[25]) algebraic[36] = algebraic[11]/(algebraic[11]+algebraic[25]) algebraic[12] = 0.0150000/(1.00000+exp((states[0]+60.0000)/5.00000)) algebraic[26] = (0.100000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000)) algebraic[32] = 1.00000/(algebraic[12]+algebraic[26]) algebraic[37] = algebraic[12]/(algebraic[12]+algebraic[26]) algebraic[4] = states[0]+10.0000 algebraic[18] = 1.00000/(1.00000+exp(-algebraic[4]/6.24000)) algebraic[29] = custom_piecewise([less(fabs(algebraic[4]) , 1.00000e-05), 1.00000/(0.0350000*6.24000*2.00000) , True, (1.00000*algebraic[18]*(1.00000-exp(-algebraic[4]/6.24000)))/(0.0350000*algebraic[4])]) algebraic[34] = algebraic[18]/algebraic[29] algebraic[39] = (1.00000-algebraic[18])/algebraic[29] 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[46] = 1.00000/(1.00000+exp((states[0]+9.00000)/22.4000)) algebraic[50] = ((constants[0]*constants[1])/constants[2])*log(constants[21]/states[6]) algebraic[51] = constants[69]*states[11]*algebraic[46]*(states[0]-algebraic[50]) algebraic[48] = constants[25]*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[5], 1.40000))) algebraic[47] = ((constants[0]*constants[1])/constants[2])*log((constants[21]+constants[26]*constants[9])/(states[6]+constants[26]*states[1])) algebraic[49] = algebraic[48]*states[12]*states[13]*(states[0]-algebraic[47]) algebraic[58] = 0.850000/(1.00000+power(constants[31]/states[1], constants[30])) algebraic[59] = 0.800000-0.650000/(1.00000+exp((states[0]+125.000)/15.0000)) algebraic[60] = constants[29]*algebraic[58]*algebraic[59]*(states[0]-algebraic[50]) algebraic[61] = constants[79]*(states[0]-algebraic[50]) algebraic[62] = exp(states[0]/100.000) algebraic[63] = constants[72]*(power(states[14], 3.00000))*states[15]*algebraic[62]*(states[0]-algebraic[50]) algebraic[52] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[50])-59.2150))) algebraic[53] = (1.00000*(0.491240*exp(0.0803200*((states[0]-algebraic[50])+5.47600))+exp(0.0617500*((states[0]-algebraic[50])-594.310))))/(1.00000+exp(-0.514300*((states[0]-algebraic[50])+4.75300))) algebraic[54] = algebraic[52]/(algebraic[52]+algebraic[53]) algebraic[55] = constants[70]*algebraic[54]*(states[0]-algebraic[50]) algebraic[56] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000)) algebraic[57] = constants[28]*algebraic[56]*(states[0]-algebraic[50]) algebraic[69] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0365000*constants[73]*exp((-states[0]*constants[2])/(constants[0]*constants[1]))) algebraic[70] = (((constants[42]*algebraic[69]*1.00000)/(1.00000+power(constants[43]/states[1], 2.00000)))*constants[21])/(constants[21]+constants[44]) algebraic[40] = (((constants[19]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[6]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[14]*constants[21]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[41] = 1.00000/(1.00000+states[5]/constants[22]) algebraic[44] = states[7]*states[8]*algebraic[41]*algebraic[40] algebraic[72] = (((constants[74]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[6]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[14]*constants[21]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[74] = (algebraic[72]*1.00000)/(1.00000+power(constants[45]/states[5], 3.00000)) algebraic[66] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[20]/states[5]) algebraic[67] = constants[23]*states[9]*states[9]*states[10]*(states[0]-algebraic[66]) algebraic[76] = (constants[46]*exp(((constants[48]-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[20]-(power(constants[9], 3.00000))*states[5]))/(1.00000+constants[47]*exp(((constants[48]-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[20]+(power(constants[9], 3.00000))*states[5])) algebraic[64] = (constants[39]*states[5])/(constants[38]+states[5]) algebraic[68] = constants[41]*(states[0]-algebraic[66]) algebraic[33] = (((constants[17]*(power(2.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[15]*states[5]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[16]*constants[20]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[42] = states[7]*states[8]*algebraic[41]*algebraic[33] algebraic[17] = ((constants[0]*constants[1])/constants[2])*log(constants[9]/states[1]) algebraic[28] = constants[8]*(power(states[2], 3.00000))*states[3]*states[4]*(states[0]-algebraic[17]) algebraic[65] = constants[40]*(states[0]-algebraic[17]) algebraic[38] = (((constants[18]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[11]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[12]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[43] = states[7]*states[8]*algebraic[41]*algebraic[38] algebraic[71] = (((constants[74]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[11]*states[1]*exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[12]*constants[9]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[73] = (algebraic[71]*1.00000)/(1.00000+power(constants[45]/states[5], 3.00000)) algebraic[45] = algebraic[42]+algebraic[44]+algebraic[43] algebraic[75] = algebraic[73]+algebraic[74] algebraic[77] = -(algebraic[28]+algebraic[45]+algebraic[67]+algebraic[51]+algebraic[49]+algebraic[60]+algebraic[61]+algebraic[63]+algebraic[55]+algebraic[57]+algebraic[76]+algebraic[64]+algebraic[65]+algebraic[68]+algebraic[70]+algebraic[75]+algebraic[3]) algebraic[78] = 1.00000/(1.00000+exp(2.00000)*states[19]) algebraic[79] = 1.00000-algebraic[78] algebraic[80] = (algebraic[78]*algebraic[79]*150.000)/(1.00000+exp((((algebraic[42]+algebraic[67])-2.00000*algebraic[76])+algebraic[64]+algebraic[68]+5.00000)/0.900000)) algebraic[81] = algebraic[80]*(states[16]-states[5]) algebraic[82] = (constants[57]*states[5])/(states[5]+constants[56]) algebraic[83] = constants[75]*states[17] algebraic[84] = (states[17]-states[16])/constants[51] algebraic[13] = custom_piecewise([greater(states[21] , constants[53]), ((constants[49]*(states[21]-constants[53]))/((constants[52]+states[21])-constants[53]))*(1.00000-states[19])*states[19] , less_equal(states[21] , constants[53]) & greater(states[23] , 0.00000), constants[50]*(1.00000-states[23])*states[23] , True, 0.00000]) 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)