# Size of variable arrays: sizeAlgebraic = 95 sizeStates = 39 sizeConstants = 80 from math import * from numpy import * def createLegends(): legend_states = [""] * sizeStates legend_rates = [""] * sizeStates legend_algebraic = [""] * sizeAlgebraic legend_voi = "" legend_constants = [""] * sizeConstants legend_voi = "time in component environment (second)" legend_states[0] = "V in component membrane (millivolt)" legend_constants[0] = "R in component membrane (joule_per_kilomole_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 (microF)" legend_algebraic[11] = "I_st in component membrane (microA_per_microF)" legend_algebraic[37] = "i_Na in component fast_sodium_current (microA_per_microF)" legend_algebraic[55] = "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[59] = "i_Kr in component rapid_delayed_rectifier_potassium_current (microA_per_microF)" legend_algebraic[62] = "i_Ks in component slow_delayed_rectifier_potassium_current (microA_per_microF)" legend_algebraic[72] = "i_K_Na in component sodium_activated_potassium_current (microA_per_microF)" legend_algebraic[73] = "i_K_ATP in component ATP_sensitive_potassium_current (microA_per_microF)" legend_algebraic[75] = "i_to in component transient_outward_current (microA_per_microF)" legend_algebraic[88] = "i_NaCa in component Na_Ca_exchanger (microA_per_microF)" legend_algebraic[67] = "i_K1 in component time_independent_potassium_current (microA_per_microF)" legend_algebraic[69] = "i_Kp in component plateau_potassium_current (microA_per_microF)" legend_algebraic[76] = "i_p_Ca in component sarcolemmal_calcium_pump (microA_per_microF)" legend_algebraic[77] = "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[82] = "i_NaK in component sodium_potassium_pump (microA_per_microF)" legend_algebraic[87] = "i_ns_Ca in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[89] = "dVdt in component membrane (dimensionless)" legend_constants[4] = "stim_start in component membrane (second)" legend_constants[5] = "stim_end in component membrane (second)" legend_constants[6] = "stim_period in component membrane (dimensionless)" legend_constants[7] = "stim_duration in component membrane (second)" legend_constants[8] = "stim_amplitude in component membrane (microA_per_microF)" legend_algebraic[23] = "E_Na in component fast_sodium_current (millivolt)" legend_constants[9] = "g_Na in component fast_sodium_current (milliS_per_microF)" legend_constants[10] = "Nao in component ionic_concentrations (millimolar)" legend_states[1] = "Nai in component ionic_concentrations (millimolar)" legend_algebraic[30] = "P_O_Na in component Na_channel_states (dimensionless)" legend_states[2] = "P_LO in component Na_channel_states (dimensionless)" legend_states[3] = "P_UO in component Na_channel_states (dimensionless)" legend_states[4] = "P_LC1 in component Na_channel_states (dimensionless)" legend_states[5] = "P_LC2 in component Na_channel_states (dimensionless)" legend_states[6] = "P_LC3 in component Na_channel_states (dimensionless)" legend_states[7] = "P_UIF in component Na_channel_states (dimensionless)" legend_states[8] = "P_UC1 in component Na_channel_states (dimensionless)" legend_states[9] = "P_UC2 in component Na_channel_states (dimensionless)" legend_states[10] = "P_UC3 in component Na_channel_states (dimensionless)" legend_states[11] = "P_UIC3 in component Na_channel_states (dimensionless)" legend_states[12] = "P_UIC2 in component Na_channel_states (dimensionless)" legend_states[13] = "P_UIM1 in component Na_channel_states (dimensionless)" legend_states[14] = "P_UIM2 in component Na_channel_states (dimensionless)" legend_algebraic[0] = "alpha_11 in component Na_channel_states (per_second)" legend_algebraic[31] = "beta_11 in component Na_channel_states (per_second)" legend_algebraic[12] = "alpha_12 in component Na_channel_states (per_second)" legend_algebraic[38] = "beta_12 in component Na_channel_states (per_second)" legend_algebraic[24] = "alpha_13 in component Na_channel_states (per_second)" legend_algebraic[42] = "beta_13 in component Na_channel_states (per_second)" legend_algebraic[44] = "alpha_2 in component Na_channel_states (per_second)" legend_algebraic[50] = "beta_2 in component Na_channel_states (per_second)" legend_algebraic[46] = "alpha_3 in component Na_channel_states (per_second)" legend_algebraic[48] = "beta_3 in component Na_channel_states (per_second)" legend_algebraic[52] = "alpha_4 in component Na_channel_states (per_second)" legend_algebraic[54] = "beta_4 in component Na_channel_states (per_second)" legend_algebraic[56] = "alpha_5 in component Na_channel_states (per_second)" legend_algebraic[58] = "beta_5 in component Na_channel_states (per_second)" legend_algebraic[49] = "i_CaCa in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[53] = "i_CaK in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[51] = "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_algebraic[41] = "I_CaCa in component L_type_Ca_channel (microA_per_microF)" legend_algebraic[45] = "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[15] = "P_Ca in component L_type_Ca_channel (cm_per_second)" legend_constants[16] = "P_Na in component L_type_Ca_channel (cm_per_second)" legend_constants[17] = "P_K in component L_type_Ca_channel (cm_per_second)" legend_constants[18] = "gamma_Cai in component L_type_Ca_channel (dimensionless)" legend_constants[19] = "gamma_Cao in component L_type_Ca_channel (dimensionless)" legend_states[15] = "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[16] = "Ki in component ionic_concentrations (millimolar)" legend_states[17] = "d in component L_type_Ca_channel_d_gate (dimensionless)" legend_states[18] = "f in component L_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[47] = "f_Ca in component L_type_Ca_channel_f_Ca_gate (dimensionless)" legend_algebraic[32] = "alpha_d in component L_type_Ca_channel_d_gate (per_second)" legend_algebraic[39] = "beta_d in component L_type_Ca_channel_d_gate (per_second)" legend_algebraic[13] = "d_infinity in component L_type_Ca_channel_d_gate (dimensionless)" legend_algebraic[25] = "tau_d in component L_type_Ca_channel_d_gate (second)" legend_algebraic[1] = "E0_d in component L_type_Ca_channel_d_gate (millivolt)" legend_algebraic[26] = "alpha_f in component L_type_Ca_channel_f_gate (per_second)" legend_algebraic[33] = "beta_f in component L_type_Ca_channel_f_gate (per_second)" legend_algebraic[2] = "f_infinity in component L_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[14] = "tau_f in component L_type_Ca_channel_f_gate (second)" 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[78] = "E_Ca in component calcium_background_current (millivolt)" legend_states[19] = "b in component T_type_Ca_channel_b_gate (dimensionless)" legend_states[20] = "g in component T_type_Ca_channel_g_gate (dimensionless)" legend_algebraic[3] = "b_inf in component T_type_Ca_channel_b_gate (dimensionless)" legend_algebraic[15] = "tau_b in component T_type_Ca_channel_b_gate (second)" legend_algebraic[4] = "g_inf in component T_type_Ca_channel_g_gate (dimensionless)" legend_algebraic[16] = "tau_g in component T_type_Ca_channel_g_gate (second)" legend_constants[66] = "g_Kr in component rapid_delayed_rectifier_potassium_current (milliS_per_microF)" legend_algebraic[57] = "E_Kr in component rapid_delayed_rectifier_potassium_current (millivolt)" legend_states[21] = "P_O in component Kr_channel_states (dimensionless)" legend_states[22] = "P_C1 in component Kr_channel_states (dimensionless)" legend_states[23] = "P_C2 in component Kr_channel_states (dimensionless)" legend_states[24] = "P_C3 in component Kr_channel_states (dimensionless)" legend_states[25] = "P_I in component Kr_channel_states (dimensionless)" legend_algebraic[5] = "alpha in component Kr_channel_states (per_second)" legend_algebraic[17] = "beta in component Kr_channel_states (per_second)" legend_constants[24] = "alpha_in in component Kr_channel_states (per_second)" legend_constants[25] = "beta_in in component Kr_channel_states (per_second)" legend_algebraic[6] = "alpha_alpha in component Kr_channel_states (per_second)" legend_algebraic[18] = "beta_beta in component Kr_channel_states (per_second)" legend_algebraic[27] = "alpha_i in component Kr_channel_states (per_second)" legend_algebraic[34] = "beta_i in component Kr_channel_states (per_second)" legend_algebraic[40] = "mu in component Kr_channel_states (per_second)" legend_algebraic[61] = "g_Ks in component slow_delayed_rectifier_potassium_current (milliS_per_microF)" legend_algebraic[60] = "E_Ks in component slow_delayed_rectifier_potassium_current (millivolt)" legend_constants[26] = "PNaK in component slow_delayed_rectifier_potassium_current (dimensionless)" legend_states[26] = "xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_states[27] = "xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (dimensionless)" legend_algebraic[7] = "xs1_infinity in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_algebraic[19] = "tau_xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (second)" legend_algebraic[8] = "xs2_infinity in component slow_delayed_rectifier_potassium_current_xs2_gate (dimensionless)" legend_algebraic[20] = "tau_xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (second)" legend_algebraic[63] = "E_K in component time_independent_potassium_current (millivolt)" legend_constants[67] = "g_K1 in component time_independent_potassium_current (milliS_per_cm2)" legend_algebraic[66] = "K1_infinity in component time_independent_potassium_current_K1_gate (dimensionless)" legend_algebraic[64] = "alpha_K1 in component time_independent_potassium_current_K1_gate (per_second)" legend_algebraic[65] = "beta_K1 in component time_independent_potassium_current_K1_gate (per_second)" legend_constants[27] = "g_Kp in component plateau_potassium_current (milliS_per_microF)" legend_algebraic[68] = "Kp in component plateau_potassium_current (dimensionless)" legend_constants[68] = "g_K_Na in component sodium_activated_potassium_current (milliS_per_microF)" legend_constants[28] = "nKNa in component sodium_activated_potassium_current (dimensionless)" legend_algebraic[70] = "pona in component sodium_activated_potassium_current (dimensionless)" legend_algebraic[71] = "pov in component sodium_activated_potassium_current (dimensionless)" legend_constants[29] = "kdKNa in component sodium_activated_potassium_current (millimolar)" legend_constants[69] = "g_K_ATP in component ATP_sensitive_potassium_current (milliS_per_microF)" legend_constants[30] = "i_K_ATP_on in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[31] = "nATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[32] = "nicholsarea in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[33] = "ATPi in component ATP_sensitive_potassium_current (millimolar)" legend_constants[34] = "hATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[35] = "kATP in component ATP_sensitive_potassium_current (millimolar)" legend_constants[75] = "pATP in component ATP_sensitive_potassium_current (dimensionless)" legend_constants[77] = "GKbaraATP in component ATP_sensitive_potassium_current (milliS_per_microF)" legend_constants[70] = "g_to in component transient_outward_current (milliS_per_microF)" legend_algebraic[74] = "rvdv in component transient_outward_current (dimensionless)" legend_states[28] = "zdv in component transient_outward_current_zdv_gate (dimensionless)" legend_states[29] = "ydv in component transient_outward_current_ydv_gate (dimensionless)" legend_algebraic[9] = "alpha_zdv in component transient_outward_current_zdv_gate (per_second)" legend_algebraic[21] = "beta_zdv in component transient_outward_current_zdv_gate (per_second)" legend_algebraic[28] = "tau_zdv in component transient_outward_current_zdv_gate (second)" legend_algebraic[35] = "zdv_ss in component transient_outward_current_zdv_gate (dimensionless)" legend_algebraic[10] = "alpha_ydv in component transient_outward_current_ydv_gate (per_second)" legend_algebraic[22] = "beta_ydv in component transient_outward_current_ydv_gate (per_second)" legend_algebraic[29] = "tau_ydv in component transient_outward_current_ydv_gate (second)" legend_algebraic[36] = "ydv_ss in component transient_outward_current_ydv_gate (dimensionless)" legend_constants[36] = "K_mpCa in component sarcolemmal_calcium_pump (millimolar)" legend_constants[37] = "I_pCa in component sarcolemmal_calcium_pump (microA_per_microF)" legend_constants[38] = "g_Nab in component sodium_background_current (milliS_per_microF)" legend_constants[39] = "g_Cab in component calcium_background_current (milliS_per_microF)" legend_constants[40] = "I_NaK in component sodium_potassium_pump (microA_per_microF)" legend_algebraic[81] = "f_NaK in component sodium_potassium_pump (dimensionless)" legend_constants[41] = "K_mNai in component sodium_potassium_pump (millimolar)" legend_constants[42] = "K_mKo in component sodium_potassium_pump (millimolar)" legend_constants[71] = "sigma in component sodium_potassium_pump (dimensionless)" legend_algebraic[85] = "i_ns_Na in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[86] = "i_ns_K in component non_specific_calcium_activated_current (microA_per_microF)" legend_constants[72] = "P_ns_Ca in component non_specific_calcium_activated_current (cm_per_second)" legend_algebraic[83] = "I_ns_Na in component non_specific_calcium_activated_current (microA_per_microF)" legend_algebraic[84] = "I_ns_K in component non_specific_calcium_activated_current (microA_per_microF)" legend_constants[43] = "K_m_ns_Ca in component non_specific_calcium_activated_current (millimolar)" legend_constants[44] = "c1 in component Na_Ca_exchanger (microA_per_microF)" legend_constants[45] = "c2 in component Na_Ca_exchanger (millimolar)" legend_constants[46] = "gamma in component Na_Ca_exchanger (dimensionless)" legend_algebraic[91] = "i_rel in component calcium_dynamics (millimolar_per_second)" legend_algebraic[92] = "i_up in component calcium_dynamics (millimolar_per_second)" legend_algebraic[93] = "i_leak in component calcium_dynamics (millimolar_per_second)" legend_algebraic[94] = "i_tr in component calcium_dynamics (millimolar_per_second)" legend_algebraic[90] = "G_rel in component calcium_dynamics (per_second)" legend_constants[47] = "G_rel_max in component calcium_dynamics (per_second)" legend_constants[48] = "G_rel_overload in component calcium_dynamics (per_second)" legend_constants[49] = "tau_tr in component calcium_dynamics (second)" legend_constants[50] = "K_mrel in component calcium_dynamics (millimolar)" legend_constants[51] = "delta_Ca_ith in component calcium_dynamics (millimolar)" legend_constants[52] = "CSQN_max in component calcium_dynamics (millimolar)" legend_constants[53] = "K_mCSQN in component calcium_dynamics (millimolar)" legend_constants[54] = "K_mup in component calcium_dynamics (millimolar)" legend_constants[73] = "K_leak in component calcium_dynamics (per_second)" legend_constants[55] = "I_up in component calcium_dynamics (millimolar_per_second)" legend_constants[56] = "Ca_NSR_max in component calcium_dynamics (millimolar)" legend_states[30] = "Ca_JSR in component calcium_dynamics (millimolar)" legend_states[31] = "Ca_NSR in component calcium_dynamics (millimolar)" legend_constants[76] = "V_myo in component ionic_concentrations (micro_litre)" legend_constants[57] = "A_cap in component ionic_concentrations (mm2)" legend_constants[78] = "V_JSR in component calcium_dynamics (micro_litre)" legend_constants[79] = "V_NSR in component calcium_dynamics (micro_litre)" legend_constants[58] = "K_mTn in component calcium_dynamics (millimolar)" legend_constants[59] = "K_mCMDN in component calcium_dynamics (millimolar)" legend_constants[60] = "Tn_max in component calcium_dynamics (millimolar)" legend_constants[61] = "CMDN_max in component calcium_dynamics (millimolar)" legend_states[32] = "APtrack in component calcium_dynamics (dimensionless)" legend_states[33] = "APtrack2 in component calcium_dynamics (dimensionless)" legend_states[34] = "APtrack3 in component calcium_dynamics (dimensionless)" legend_states[35] = "Cainfluxtrack in component calcium_dynamics (dimensionless)" legend_states[36] = "OVRLDtrack in component calcium_dynamics (dimensionless)" legend_states[37] = "OVRLDtrack2 in component calcium_dynamics (dimensionless)" legend_states[38] = "OVRLDtrack3 in component calcium_dynamics (dimensionless)" legend_constants[62] = "CSQNthresh in component calcium_dynamics (millimolar)" legend_constants[63] = "Logicthresh in component calcium_dynamics (dimensionless)" legend_constants[64] = "preplength in component ionic_concentrations (mm)" legend_constants[65] = "radius in component ionic_concentrations (mm)" legend_constants[74] = "volume in component ionic_concentrations (micro_litre)" legend_rates[0] = "d/dt V in component membrane (millivolt)" legend_rates[6] = "d/dt P_LC3 in component Na_channel_states (dimensionless)" legend_rates[5] = "d/dt P_LC2 in component Na_channel_states (dimensionless)" legend_rates[4] = "d/dt P_LC1 in component Na_channel_states (dimensionless)" legend_rates[2] = "d/dt P_LO in component Na_channel_states (dimensionless)" legend_rates[7] = "d/dt P_UIF in component Na_channel_states (dimensionless)" legend_rates[11] = "d/dt P_UIC3 in component Na_channel_states (dimensionless)" legend_rates[12] = "d/dt P_UIC2 in component Na_channel_states (dimensionless)" legend_rates[13] = "d/dt P_UIM1 in component Na_channel_states (dimensionless)" legend_rates[14] = "d/dt P_UIM2 in component Na_channel_states (dimensionless)" legend_rates[10] = "d/dt P_UC3 in component Na_channel_states (dimensionless)" legend_rates[9] = "d/dt P_UC2 in component Na_channel_states (dimensionless)" legend_rates[8] = "d/dt P_UC1 in component Na_channel_states (dimensionless)" legend_rates[3] = "d/dt P_UO in component Na_channel_states (dimensionless)" legend_rates[17] = "d/dt d in component L_type_Ca_channel_d_gate (dimensionless)" legend_rates[18] = "d/dt f in component L_type_Ca_channel_f_gate (dimensionless)" legend_rates[19] = "d/dt b in component T_type_Ca_channel_b_gate (dimensionless)" legend_rates[20] = "d/dt g in component T_type_Ca_channel_g_gate (dimensionless)" legend_rates[24] = "d/dt P_C3 in component Kr_channel_states (dimensionless)" legend_rates[23] = "d/dt P_C2 in component Kr_channel_states (dimensionless)" legend_rates[22] = "d/dt P_C1 in component Kr_channel_states (dimensionless)" legend_rates[21] = "d/dt P_O in component Kr_channel_states (dimensionless)" legend_rates[25] = "d/dt P_I in component Kr_channel_states (dimensionless)" legend_rates[26] = "d/dt xs1 in component slow_delayed_rectifier_potassium_current_xs1_gate (dimensionless)" legend_rates[27] = "d/dt xs2 in component slow_delayed_rectifier_potassium_current_xs2_gate (dimensionless)" legend_rates[28] = "d/dt zdv in component transient_outward_current_zdv_gate (dimensionless)" legend_rates[29] = "d/dt ydv in component transient_outward_current_ydv_gate (dimensionless)" legend_rates[32] = "d/dt APtrack in component calcium_dynamics (dimensionless)" legend_rates[33] = "d/dt APtrack2 in component calcium_dynamics (dimensionless)" legend_rates[34] = "d/dt APtrack3 in component calcium_dynamics (dimensionless)" legend_rates[35] = "d/dt Cainfluxtrack in component calcium_dynamics (dimensionless)" legend_rates[36] = "d/dt OVRLDtrack in component calcium_dynamics (dimensionless)" legend_rates[37] = "d/dt OVRLDtrack2 in component calcium_dynamics (dimensionless)" legend_rates[38] = "d/dt OVRLDtrack3 in component calcium_dynamics (dimensionless)" legend_rates[30] = "d/dt Ca_JSR in component calcium_dynamics (millimolar)" legend_rates[31] = "d/dt Ca_NSR in component calcium_dynamics (millimolar)" legend_rates[15] = "d/dt Cai in component calcium_dynamics (millimolar)" legend_rates[1] = "d/dt Nai in component ionic_concentrations (millimolar)" legend_rates[16] = "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] = -89.179 constants[0] = 8314 constants[1] = 310 constants[2] = 96485 constants[3] = 0.001 constants[4] = 3 constants[5] = 9 constants[6] = 1 constants[7] = 0.002 constants[8] = -50 constants[9] = 23.5 constants[10] = 132 states[1] = 12.3 states[2] = 4.128e-17 states[3] = 3.923e-13 states[4] = 5.498e-14 states[5] = 1.186e-11 states[6] = 9.604e-10 states[7] = 2.127e-10 states[8] = 5.224e-10 states[9] = 1.127e-7 states[10] = 9.126e-6 states[11] = 3.715e-6 states[12] = 4.589e-8 states[13] = 5.952e-11 states[14] = 9.56e-13 constants[11] = 0.75 constants[12] = 0.75 constants[13] = 0.75 constants[14] = 0.75 constants[15] = 0.00054 constants[16] = 6.75e-7 constants[17] = 1.93e-7 constants[18] = 1 constants[19] = 0.341 states[15] = 0.000123 constants[20] = 1.8 constants[21] = 4.5 states[16] = 140.22 states[17] = 3.085e-6 states[18] = 0.9998 constants[22] = 0.0006 constants[23] = 0.05 states[19] = 0.00095 states[20] = 0.9946 states[21] = 1.032e-10 states[22] = 3.286e-8 states[23] = 1.63e-8 states[24] = 4.95e-6 states[25] = 3.135e-11 constants[24] = 2172 constants[25] = 1077 constants[26] = 0.01833 states[26] = 0.00437 states[27] = 0.00437 constants[27] = 0.00552 constants[28] = 2.8 constants[29] = 66 constants[30] = 1 constants[31] = 0.24 constants[32] = 5e-5 constants[33] = 3 constants[34] = 2 constants[35] = 0.00025 states[28] = 0.0114 states[29] = 0.99998 constants[36] = 0.0005 constants[37] = 1.15 constants[38] = 0.004 constants[39] = 0.003016 constants[40] = 2.25 constants[41] = 10 constants[42] = 1.5 constants[43] = 0.0012 constants[44] = 0.00025 constants[45] = 0.0001 constants[46] = 0.15 constants[47] = 60000 constants[48] = 4000 constants[49] = 0.18 constants[50] = 0.0008 constants[51] = 0.00018 constants[52] = 10 constants[53] = 0.8 constants[54] = 0.00092 constants[55] = 8.75 constants[56] = 15 states[30] = 1.762 states[31] = 1.764 constants[57] = 1.434e-7 constants[58] = 0.0005 constants[59] = 0.00238 constants[60] = 0.07 constants[61] = 0.05 states[32] = 0 states[33] = 0 states[34] = 0 states[35] = 0 states[36] = 0 states[37] = 0 states[38] = 0 constants[62] = 0.7 constants[63] = 0.98 constants[64] = 0.001 constants[65] = 1.1e-4 constants[66] = 0.0135000*(power(constants[21], 0.590000)) constants[67] = 0.750000*(power(constants[21]/5.40000, 1.0/2)) constants[68] = 0.00000*0.128480 constants[69] = (constants[30]*0.000193000)/constants[32] constants[70] = 0.0500000 constants[71] = (1.00000/7.00000)*(exp(constants[10]/67.3000)-1.00000) constants[72] = 0.00000*1.75000e-07 constants[73] = constants[55]/constants[56] constants[74] = pi*constants[64]*(power(constants[65], 2.00000)) constants[75] = 1.00000/(1.00000+power(constants[33]/constants[35], constants[34])) constants[76] = 0.680000*constants[74] constants[77] = constants[69]*constants[75]*(power(constants[21]/4.00000, constants[31])) constants[78] = (0.00480000/0.680000)*constants[76] constants[79] = (0.0552000/0.680000)*constants[76] return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic rates[33] = custom_piecewise([less(states[32] , 0.200000) & greater(states[32] , 0.180000), 100000.*(1.00000-states[33])-500.000*states[33] , True, -500.000*states[33]]) rates[34] = custom_piecewise([less(states[32] , 0.200000) & greater(states[32] , 0.180000), 100000.*(1.00000-states[34])-500.000*states[34] , True, -10.0000*states[34]]) rates[36] = custom_piecewise([greater(1.00000/(1.00000+constants[53]/states[31]) , constants[62]) & less(states[38] , 0.370000) & less(states[34] , 0.370000), 50000.0*(1.00000-states[36]) , True, -500.000*states[36]]) rates[37] = custom_piecewise([greater(states[36] , constants[63]) & less(states[37] , constants[63]), 50000.0*(1.00000-states[37]) , True, -500.000*states[37]]) rates[38] = custom_piecewise([greater(states[36] , constants[63]) & less(states[38] , constants[63]), 50000.0*(1.00000-states[38]) , True, -10.0000*states[38]]) algebraic[3] = 1.00000/(1.00000+exp(-(states[0]+14.0000)/10.8000)) algebraic[15] = 0.00370000+0.00610000/(1.00000+exp((states[0]+25.0000)/4.50000)) rates[19] = (algebraic[3]-states[19])/algebraic[15] algebraic[4] = 1.00000/(1.00000+exp((states[0]+60.0000)/5.60000)) algebraic[16] = custom_piecewise([less_equal(states[0] , 0.00000), -0.000875000*states[0]+0.0120000 , True, 0.0120000]) rates[20] = (algebraic[4]-states[20])/algebraic[16] algebraic[5] = 55.5000*exp(0.0554715*(states[0]-12.0000)) algebraic[17] = 2.35700*exp(-0.0365880*states[0]) rates[24] = algebraic[17]*states[23]-algebraic[5]*states[24] rates[23] = -(algebraic[17]+constants[24])*states[23]+algebraic[5]*states[24]+constants[25]*states[22] algebraic[7] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[19] = 0.00100000/((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[26] = (algebraic[7]-states[26])/algebraic[19] algebraic[8] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[20] = (4.00000*0.00100000)/((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[27] = (algebraic[8]-states[27])/algebraic[20] algebraic[0] = 3802.00/(0.102700*exp(-states[0]/17.0000)+0.200000*exp(-states[0]/150.000)) algebraic[31] = 191.700*exp(-states[0]/20.3000) rates[6] = -(0.950000+algebraic[0])*states[6]+0.000100000*states[10]+algebraic[31]*states[5] algebraic[2] = 1.00000/(1.00000+exp((states[0]+32.0000)/8.00000))+0.600000/(1.00000+exp((50.0000-states[0])/20.0000)) algebraic[14] = 0.00100000/(0.0197000*exp(-(power(0.0337000*(states[0]+10.0000), 2.00000)))+0.0200000) algebraic[26] = algebraic[2]/algebraic[14] algebraic[33] = (1.00000-algebraic[2])/algebraic[14] rates[18] = algebraic[26]*(1.00000-states[18])-algebraic[33]*states[18] algebraic[6] = 65.5000*exp(0.0554715*(states[0]-36.0000)) algebraic[18] = 2.93570*exp(-0.0215800*states[0]) algebraic[27] = (439.000*exp(-0.0235200*(states[0]+25.0000))*4.50000)/constants[21] algebraic[34] = (656.000*exp(0.000942000*states[0])*(power(4.50000, 0.300000)))/(power(constants[21], 0.300000)) rates[21] = -(algebraic[18]+algebraic[34])*states[21]+algebraic[6]*states[22]+algebraic[27]*states[25] algebraic[9] = (10000.0*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000)) algebraic[21] = (10000.0*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000)) algebraic[28] = 1.00000/(algebraic[9]+algebraic[21]) algebraic[35] = algebraic[9]/(algebraic[9]+algebraic[21]) rates[28] = (algebraic[35]-states[28])/algebraic[28] algebraic[10] = 15.0000/(1.00000+exp((states[0]+60.0000)/5.00000)) algebraic[22] = (100.000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000)) algebraic[29] = 1.00000/(algebraic[10]+algebraic[22]) algebraic[36] = algebraic[10]/(algebraic[10]+algebraic[22]) rates[29] = (algebraic[36]-states[29])/algebraic[29] algebraic[12] = 3802.00/(0.102700*exp(-states[0]/15.0000)+0.230000*exp(-states[0]/150.000)) algebraic[38] = 200.000*exp(-(states[0]-5.00000)/20.3000) rates[5] = -(algebraic[31]+0.950000+algebraic[12])*states[5]+algebraic[0]*states[6]+algebraic[38]*states[4]+0.000100000*states[9] algebraic[1] = states[0]+10.0000 algebraic[13] = 1.00000/(1.00000+exp(-algebraic[1]/6.24000)) algebraic[25] = custom_piecewise([less(fabs(algebraic[1]) , 1.00000e-05), 0.00100000/(0.0350000*6.24000) , True, (0.00100000*algebraic[13]*(1.00000-exp(-algebraic[1]/6.24000)))/(0.0350000*algebraic[1])]) algebraic[32] = algebraic[13]/algebraic[25] algebraic[39] = (1.00000-algebraic[13])/algebraic[25] rates[17] = algebraic[32]*(1.00000-states[17])-algebraic[39]*states[17] algebraic[40] = (algebraic[27]*algebraic[18]*algebraic[6])/(algebraic[6]*algebraic[34]) rates[22] = -(constants[25]+algebraic[6]+algebraic[6])*states[22]+constants[24]*states[23]+algebraic[18]*states[21]+algebraic[40]*states[25] rates[25] = -(algebraic[40]+algebraic[27])*states[25]+algebraic[6]*states[22]+algebraic[34]*states[21] algebraic[24] = 3802.00/(0.102700*exp(-states[0]/12.0000)+0.250000*exp(-states[0]/150.000)) algebraic[42] = 220.000*exp(-(states[0]-10.0000)/20.3000) rates[4] = -(algebraic[38]+algebraic[24]+0.950000)*states[4]+algebraic[12]*states[5]+algebraic[42]*states[2]+0.000100000*states[8] rates[2] = -(0.950000+algebraic[42])*states[2]+0.000100000*states[3]+algebraic[24]*states[4] algebraic[46] = (0.000379330*exp(-states[0]/7.70000))/2.50000 algebraic[48] = 8.40000+0.0200000*states[0] rates[11] = -(algebraic[46]+algebraic[0])*states[11]+algebraic[48]*states[10]+algebraic[31]*states[12] rates[12] = -(algebraic[46]+algebraic[12]+algebraic[31])*states[12]+algebraic[48]*states[9]+algebraic[38]*states[7]+algebraic[0]*states[11] rates[10] = -(algebraic[48]+algebraic[0]+0.000100000)*states[10]+algebraic[46]*states[11]+algebraic[31]*states[9]+0.950000*states[6] rates[9] = -(algebraic[31]+algebraic[48]+algebraic[12]+0.000100000)*states[9]+algebraic[0]*states[10]+algebraic[38]*states[8]+algebraic[46]*states[12]+0.950000*states[5] rates[8] = -(algebraic[38]+algebraic[24]+algebraic[48]+0.000100000)*states[8]+algebraic[12]*states[9]+algebraic[42]*states[3]+algebraic[46]*states[7]+0.950000*states[4] algebraic[44] = 9178.00*exp(states[0]/29.6800) algebraic[50] = (algebraic[24]*algebraic[44]*algebraic[46])/(algebraic[42]*algebraic[48]) rates[3] = -(algebraic[44]+algebraic[42]+0.000100000)*states[3]+algebraic[50]*states[7]+algebraic[24]*states[8]+0.950000*states[2] algebraic[52] = algebraic[44]/100.000 algebraic[54] = algebraic[46] rates[7] = -(algebraic[50]+algebraic[46]+algebraic[52]+algebraic[38])*states[7]+algebraic[48]*states[8]+algebraic[54]*states[13]+algebraic[44]*states[3]+algebraic[12]*states[12] algebraic[56] = algebraic[44]/35000.0 algebraic[58] = algebraic[46]/20.0000 rates[13] = -(algebraic[56]+algebraic[54])*states[13]+algebraic[58]*states[14]+algebraic[52]*states[7] rates[14] = algebraic[56]*states[13]-algebraic[58]*states[14] algebraic[57] = ((constants[0]*constants[1])/constants[2])*log(constants[21]/states[16]) algebraic[59] = constants[66]*states[21]*(states[0]-algebraic[57]) algebraic[61] = 0.968000*0.433000*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[15], 1.40000))) algebraic[60] = ((constants[0]*constants[1])/constants[2])*log((constants[21]+constants[26]*constants[10])/(states[16]+constants[26]*states[1])) algebraic[62] = algebraic[61]*states[26]*states[27]*(states[0]-algebraic[60]) algebraic[63] = ((constants[0]*constants[1])/constants[2])*log(constants[21]/states[16]) algebraic[70] = 0.850000/(1.00000+power(constants[29]/states[1], constants[28])) algebraic[71] = 0.800000-0.650000/(1.00000+exp((states[0]+125.000)/15.0000)) algebraic[72] = constants[68]*algebraic[70]*algebraic[71]*(states[0]-algebraic[63]) algebraic[73] = constants[77]*(states[0]-algebraic[63]) algebraic[74] = exp(states[0]/100.000) algebraic[75] = constants[70]*(power(states[28], 3.00000))*states[29]*algebraic[74]*(states[0]-algebraic[63]) algebraic[64] = 1020.00/(1.00000+exp(0.238500*((states[0]-algebraic[63])-59.2150))) algebraic[65] = (1000.00*(0.491240*exp(0.0803200*((states[0]-algebraic[63])+5.47600))+exp(0.0617500*((states[0]-algebraic[63])-594.310))))/(1.00000+exp(-0.514300*((states[0]-algebraic[63])+4.75300))) algebraic[66] = algebraic[64]/(algebraic[64]+algebraic[65]) algebraic[67] = constants[67]*algebraic[66]*(states[0]-algebraic[63]) algebraic[68] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000)) algebraic[69] = constants[27]*algebraic[68]*(states[0]-algebraic[63]) algebraic[81] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0365000*constants[71]*exp((-states[0]*constants[2])/(constants[0]*constants[1]))) algebraic[82] = (((constants[40]*algebraic[81]*1.00000)/(1.00000+power(constants[41]/states[1], 2.00000)))*constants[21])/(constants[21]+constants[42]) algebraic[45] = (((constants[17]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[16]*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[47] = 1.00000/(1.00000+states[15]/constants[22]) algebraic[53] = states[17]*states[18]*algebraic[47]*algebraic[45] algebraic[84] = (((constants[72]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[16]*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[86] = (algebraic[84]*1.00000)/(1.00000+power(constants[43]/states[15], 3.00000)) rates[16] = (-(algebraic[53]+algebraic[59]+algebraic[62]+algebraic[67]+algebraic[69]+algebraic[72]+algebraic[73]+algebraic[75]+algebraic[86]+-algebraic[82]*2.00000)*constants[57])/(constants[76]*constants[2]) algebraic[11] = custom_piecewise([greater_equal(voi , constants[4]) & less_equal(voi , constants[5]) & less_equal((voi-constants[4])-floor((voi-constants[4])/constants[6])*constants[6] , constants[7]), constants[8] , True, 0.00000]) algebraic[23] = ((constants[0]*constants[1])/constants[2])*log(constants[10]/states[1]) algebraic[30] = states[2]+states[3] algebraic[37] = constants[9]*algebraic[30]*(states[0]-algebraic[23]) algebraic[41] = (((constants[15]*(power(2.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[18]*states[15]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[19]*constants[20]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[49] = states[17]*states[18]*algebraic[47]*algebraic[41] algebraic[43] = (((constants[16]*(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[10]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[51] = states[17]*states[18]*algebraic[47]*algebraic[43] algebraic[55] = algebraic[49]+algebraic[53]+algebraic[51] algebraic[78] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[20]/states[15]) algebraic[79] = constants[23]*states[19]*states[19]*states[20]*(states[0]-algebraic[78]) algebraic[88] = (constants[44]*exp(((constants[46]-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[10], 3.00000))*states[15]))/(1.00000+constants[45]*exp(((constants[46]-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[10], 3.00000))*states[15])) algebraic[76] = (constants[37]*states[15])/(constants[36]+states[15]) algebraic[77] = constants[38]*(states[0]-algebraic[23]) algebraic[80] = constants[39]*(states[0]-algebraic[78]) algebraic[83] = (((constants[72]*(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[10]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[85] = (algebraic[83]*1.00000)/(1.00000+power(constants[43]/states[15], 3.00000)) algebraic[87] = algebraic[85]+algebraic[86] rates[0] = (-1.00000/constants[3])*(algebraic[37]+algebraic[55]+algebraic[79]+algebraic[59]+algebraic[62]+algebraic[72]+algebraic[73]+algebraic[75]+algebraic[67]+algebraic[69]+algebraic[88]+algebraic[76]+algebraic[77]+algebraic[80]+algebraic[82]+algebraic[87]+algebraic[11]) rates[35] = custom_piecewise([greater(states[32] , 0.200000), (-constants[57]*(((algebraic[49]+algebraic[79])-algebraic[88])+algebraic[76]+algebraic[80]))/(2.00000*constants[76]*constants[2]) , greater(states[33] , 0.0100000) & less_equal(states[32] , 0.200000), 0.00000 , True, -500.000*states[35]]) rates[1] = (-(algebraic[37]+algebraic[51]+algebraic[77]+algebraic[85]+algebraic[88]*3.00000+algebraic[82]*3.00000)*constants[57])/(constants[76]*constants[2]) algebraic[89] = (-1.00000/constants[3])*(algebraic[37]+algebraic[55]+algebraic[79]+algebraic[59]+algebraic[62]+algebraic[72]+algebraic[73]+algebraic[75]+algebraic[67]+algebraic[69]+algebraic[88]+algebraic[76]+algebraic[77]+algebraic[80]+algebraic[82]+algebraic[87]+algebraic[11]) rates[32] = custom_piecewise([greater(algebraic[89] , 150000.), 100000.*(1.00000-states[32])-500.000*states[32] , True, -500.000*states[32]]) algebraic[90] = custom_piecewise([greater(states[35] , constants[51]), ((constants[47]*(states[35]-constants[51]))/((constants[50]+states[35])-constants[51]))*(1.00000-states[33])*states[33] , less_equal(states[35] , constants[51]) & greater(states[37] , 0.00000), constants[48]*(1.00000-states[37])*states[37] , True, 0.00000]) algebraic[91] = algebraic[90]*(states[30]-states[15]) algebraic[92] = (constants[55]*states[15])/(states[15]+constants[54]) algebraic[93] = constants[73]*states[31] rates[15] = (1.00000/(1.00000+(constants[61]*constants[59])/(power(constants[59]+states[15], 2.00000))+(constants[60]*constants[58])/(power(constants[58]+states[15], 2.00000))))*((-constants[57]*(((algebraic[49]+algebraic[79])-2.00000*algebraic[88])+algebraic[76]+algebraic[80]))/(2.00000*constants[76]*constants[2])+(algebraic[91]*constants[78])/constants[76]+((algebraic[93]-algebraic[92])*constants[79])/constants[76]) algebraic[94] = (states[31]-states[30])/constants[49] rates[30] = (1.00000/(1.00000+(constants[52]*constants[53])/(power(constants[53]+states[30], 2.00000))))*(algebraic[94]-algebraic[91]) rates[31] = ((-algebraic[94]*constants[78])/constants[79]-algebraic[93])+algebraic[92] return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[3] = 1.00000/(1.00000+exp(-(states[0]+14.0000)/10.8000)) algebraic[15] = 0.00370000+0.00610000/(1.00000+exp((states[0]+25.0000)/4.50000)) algebraic[4] = 1.00000/(1.00000+exp((states[0]+60.0000)/5.60000)) algebraic[16] = custom_piecewise([less_equal(states[0] , 0.00000), -0.000875000*states[0]+0.0120000 , True, 0.0120000]) algebraic[5] = 55.5000*exp(0.0554715*(states[0]-12.0000)) algebraic[17] = 2.35700*exp(-0.0365880*states[0]) algebraic[7] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[19] = 0.00100000/((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[8] = 1.00000/(1.00000+exp(-(states[0]-1.50000)/16.7000)) algebraic[20] = (4.00000*0.00100000)/((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] = 3802.00/(0.102700*exp(-states[0]/17.0000)+0.200000*exp(-states[0]/150.000)) algebraic[31] = 191.700*exp(-states[0]/20.3000) algebraic[2] = 1.00000/(1.00000+exp((states[0]+32.0000)/8.00000))+0.600000/(1.00000+exp((50.0000-states[0])/20.0000)) algebraic[14] = 0.00100000/(0.0197000*exp(-(power(0.0337000*(states[0]+10.0000), 2.00000)))+0.0200000) algebraic[26] = algebraic[2]/algebraic[14] algebraic[33] = (1.00000-algebraic[2])/algebraic[14] algebraic[6] = 65.5000*exp(0.0554715*(states[0]-36.0000)) algebraic[18] = 2.93570*exp(-0.0215800*states[0]) algebraic[27] = (439.000*exp(-0.0235200*(states[0]+25.0000))*4.50000)/constants[21] algebraic[34] = (656.000*exp(0.000942000*states[0])*(power(4.50000, 0.300000)))/(power(constants[21], 0.300000)) algebraic[9] = (10000.0*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000)) algebraic[21] = (10000.0*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000)) algebraic[28] = 1.00000/(algebraic[9]+algebraic[21]) algebraic[35] = algebraic[9]/(algebraic[9]+algebraic[21]) algebraic[10] = 15.0000/(1.00000+exp((states[0]+60.0000)/5.00000)) algebraic[22] = (100.000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000)) algebraic[29] = 1.00000/(algebraic[10]+algebraic[22]) algebraic[36] = algebraic[10]/(algebraic[10]+algebraic[22]) algebraic[12] = 3802.00/(0.102700*exp(-states[0]/15.0000)+0.230000*exp(-states[0]/150.000)) algebraic[38] = 200.000*exp(-(states[0]-5.00000)/20.3000) algebraic[1] = states[0]+10.0000 algebraic[13] = 1.00000/(1.00000+exp(-algebraic[1]/6.24000)) algebraic[25] = custom_piecewise([less(fabs(algebraic[1]) , 1.00000e-05), 0.00100000/(0.0350000*6.24000) , True, (0.00100000*algebraic[13]*(1.00000-exp(-algebraic[1]/6.24000)))/(0.0350000*algebraic[1])]) algebraic[32] = algebraic[13]/algebraic[25] algebraic[39] = (1.00000-algebraic[13])/algebraic[25] algebraic[40] = (algebraic[27]*algebraic[18]*algebraic[6])/(algebraic[6]*algebraic[34]) algebraic[24] = 3802.00/(0.102700*exp(-states[0]/12.0000)+0.250000*exp(-states[0]/150.000)) algebraic[42] = 220.000*exp(-(states[0]-10.0000)/20.3000) algebraic[46] = (0.000379330*exp(-states[0]/7.70000))/2.50000 algebraic[48] = 8.40000+0.0200000*states[0] algebraic[44] = 9178.00*exp(states[0]/29.6800) algebraic[50] = (algebraic[24]*algebraic[44]*algebraic[46])/(algebraic[42]*algebraic[48]) algebraic[52] = algebraic[44]/100.000 algebraic[54] = algebraic[46] algebraic[56] = algebraic[44]/35000.0 algebraic[58] = algebraic[46]/20.0000 algebraic[57] = ((constants[0]*constants[1])/constants[2])*log(constants[21]/states[16]) algebraic[59] = constants[66]*states[21]*(states[0]-algebraic[57]) algebraic[61] = 0.968000*0.433000*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[15], 1.40000))) algebraic[60] = ((constants[0]*constants[1])/constants[2])*log((constants[21]+constants[26]*constants[10])/(states[16]+constants[26]*states[1])) algebraic[62] = algebraic[61]*states[26]*states[27]*(states[0]-algebraic[60]) algebraic[63] = ((constants[0]*constants[1])/constants[2])*log(constants[21]/states[16]) algebraic[70] = 0.850000/(1.00000+power(constants[29]/states[1], constants[28])) algebraic[71] = 0.800000-0.650000/(1.00000+exp((states[0]+125.000)/15.0000)) algebraic[72] = constants[68]*algebraic[70]*algebraic[71]*(states[0]-algebraic[63]) algebraic[73] = constants[77]*(states[0]-algebraic[63]) algebraic[74] = exp(states[0]/100.000) algebraic[75] = constants[70]*(power(states[28], 3.00000))*states[29]*algebraic[74]*(states[0]-algebraic[63]) algebraic[64] = 1020.00/(1.00000+exp(0.238500*((states[0]-algebraic[63])-59.2150))) algebraic[65] = (1000.00*(0.491240*exp(0.0803200*((states[0]-algebraic[63])+5.47600))+exp(0.0617500*((states[0]-algebraic[63])-594.310))))/(1.00000+exp(-0.514300*((states[0]-algebraic[63])+4.75300))) algebraic[66] = algebraic[64]/(algebraic[64]+algebraic[65]) algebraic[67] = constants[67]*algebraic[66]*(states[0]-algebraic[63]) algebraic[68] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000)) algebraic[69] = constants[27]*algebraic[68]*(states[0]-algebraic[63]) algebraic[81] = 1.00000/(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0365000*constants[71]*exp((-states[0]*constants[2])/(constants[0]*constants[1]))) algebraic[82] = (((constants[40]*algebraic[81]*1.00000)/(1.00000+power(constants[41]/states[1], 2.00000)))*constants[21])/(constants[21]+constants[42]) algebraic[45] = (((constants[17]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[16]*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[47] = 1.00000/(1.00000+states[15]/constants[22]) algebraic[53] = states[17]*states[18]*algebraic[47]*algebraic[45] algebraic[84] = (((constants[72]*(power(1.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[13]*states[16]*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[86] = (algebraic[84]*1.00000)/(1.00000+power(constants[43]/states[15], 3.00000)) algebraic[11] = custom_piecewise([greater_equal(voi , constants[4]) & less_equal(voi , constants[5]) & less_equal((voi-constants[4])-floor((voi-constants[4])/constants[6])*constants[6] , constants[7]), constants[8] , True, 0.00000]) algebraic[23] = ((constants[0]*constants[1])/constants[2])*log(constants[10]/states[1]) algebraic[30] = states[2]+states[3] algebraic[37] = constants[9]*algebraic[30]*(states[0]-algebraic[23]) algebraic[41] = (((constants[15]*(power(2.00000, 2.00000))*states[0]*(power(constants[2], 2.00000)))/(constants[0]*constants[1]))*(constants[18]*states[15]*exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-constants[19]*constants[20]))/(exp((2.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[49] = states[17]*states[18]*algebraic[47]*algebraic[41] algebraic[43] = (((constants[16]*(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[10]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[51] = states[17]*states[18]*algebraic[47]*algebraic[43] algebraic[55] = algebraic[49]+algebraic[53]+algebraic[51] algebraic[78] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[20]/states[15]) algebraic[79] = constants[23]*states[19]*states[19]*states[20]*(states[0]-algebraic[78]) algebraic[88] = (constants[44]*exp(((constants[46]-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[10], 3.00000))*states[15]))/(1.00000+constants[45]*exp(((constants[46]-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[10], 3.00000))*states[15])) algebraic[76] = (constants[37]*states[15])/(constants[36]+states[15]) algebraic[77] = constants[38]*(states[0]-algebraic[23]) algebraic[80] = constants[39]*(states[0]-algebraic[78]) algebraic[83] = (((constants[72]*(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[10]))/(exp((1.00000*states[0]*constants[2])/(constants[0]*constants[1]))-1.00000) algebraic[85] = (algebraic[83]*1.00000)/(1.00000+power(constants[43]/states[15], 3.00000)) algebraic[87] = algebraic[85]+algebraic[86] algebraic[89] = (-1.00000/constants[3])*(algebraic[37]+algebraic[55]+algebraic[79]+algebraic[59]+algebraic[62]+algebraic[72]+algebraic[73]+algebraic[75]+algebraic[67]+algebraic[69]+algebraic[88]+algebraic[76]+algebraic[77]+algebraic[80]+algebraic[82]+algebraic[87]+algebraic[11]) algebraic[90] = custom_piecewise([greater(states[35] , constants[51]), ((constants[47]*(states[35]-constants[51]))/((constants[50]+states[35])-constants[51]))*(1.00000-states[33])*states[33] , less_equal(states[35] , constants[51]) & greater(states[37] , 0.00000), constants[48]*(1.00000-states[37])*states[37] , True, 0.00000]) algebraic[91] = algebraic[90]*(states[30]-states[15]) algebraic[92] = (constants[55]*states[15])/(states[15]+constants[54]) algebraic[93] = constants[73]*states[31] algebraic[94] = (states[31]-states[30])/constants[49] 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)