# Generated Code

The following is python code generated by the CellML API from this CellML file. (Back to language selection)

The raw code is available.

# Size of variable arrays: sizeAlgebraic = 80 sizeStates = 38 sizeConstants = 65 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 (millisecond)" legend_states[0] = "V in component membrane (millivolt)" legend_constants[0] = "R in component membrane (joule_per_mole_kelvin)" legend_constants[1] = "T in component membrane (kelvin)" legend_constants[2] = "F in component membrane (coulomb_per_millimole)" legend_constants[3] = "Cm in component membrane (picoF)" legend_algebraic[13] = "I_stim in component I_stim (picoA)" legend_algebraic[53] = "i_Na in component sodium_current (picoA)" legend_algebraic[21] = "i_Ca_L in component L_type_Ca_channel (picoA)" legend_algebraic[29] = "i_Ca_T in component T_type_Ca_channel (picoA)" legend_algebraic[37] = "i_Kv in component voltage_dep_K_channel (picoA)" legend_algebraic[45] = "i_BK in component Calcium_voltage_activated_potassium_channel (picoA)" legend_algebraic[57] = "i_NCX in component Na_Ca_exchanger (picoA)" legend_algebraic[60] = "i_NaK in component sodium_potassium_pump (picoA)" legend_algebraic[72] = "i_NsK in component non_specific_K_current (picoA)" legend_algebraic[66] = "i_NsNa in component non_specific_Na_current (picoA)" legend_algebraic[8] = "local_time in component I_stim (millisecond)" legend_constants[4] = "period in component I_stim (millisecond)" legend_algebraic[0] = "stim_start in component I_stim (millisecond)" legend_constants[5] = "Gcouple in component I_stim (nanoS)" legend_constants[6] = "t_ICCpeak in component I_stim (millisecond)" legend_constants[7] = "t_ICCplateau in component I_stim (millisecond)" legend_constants[8] = "t_slope in component I_stim (millisecond)" legend_constants[9] = "f_1 in component I_stim (millisecond)" legend_constants[10] = "f_2 in component I_stim (millisecond)" legend_constants[11] = "V_ICCrest in component I_stim (millivolt)" legend_constants[12] = "V_ICCamp in component I_stim (millivolt)" legend_algebraic[17] = "E_Ca in component L_type_Ca_channel (millivolt)" legend_constants[13] = "g_CaL in component L_type_Ca_channel (nanoS)" legend_constants[14] = "Cao in component ionic_concentrations (millimolar)" legend_states[1] = "Cai in component ionic_concentrations (millimolar)" legend_states[2] = "O_CaL in component L_type_Ca_channel_states (dimensionless)" legend_states[3] = "C0 in component L_type_Ca_channel_states (dimensionless)" legend_states[4] = "C1 in component L_type_Ca_channel_states (dimensionless)" legend_states[5] = "C2 in component L_type_Ca_channel_states (dimensionless)" legend_states[6] = "C3 in component L_type_Ca_channel_states (dimensionless)" legend_states[7] = "C0Ca in component L_type_Ca_channel_states (dimensionless)" legend_states[8] = "C1Ca in component L_type_Ca_channel_states (dimensionless)" legend_states[9] = "C2Ca in component L_type_Ca_channel_states (dimensionless)" legend_states[10] = "C3Ca in component L_type_Ca_channel_states (dimensionless)" legend_states[11] = "ICa in component L_type_Ca_channel_states (dimensionless)" legend_states[12] = "IVs in component L_type_Ca_channel_states (dimensionless)" legend_states[13] = "IVf in component L_type_Ca_channel_states (dimensionless)" legend_states[14] = "IVfCa in component L_type_Ca_channel_states (dimensionless)" legend_states[15] = "IVsCa in component L_type_Ca_channel_states (dimensionless)" legend_algebraic[1] = "alpha in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[9] = "beta in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[14] = "alpha_0 in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[18] = "alpha_1 in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[22] = "alpha_2 in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[26] = "alpha_3 in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[30] = "beta_0 in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[34] = "beta_1 in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[38] = "beta_2 in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[42] = "beta_3 in component L_type_Ca_channel_states (per_millisecond)" legend_constants[53] = "delta in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[77] = "theta in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[50] = "phi_s in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[46] = "phi_f in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[70] = "omega_s in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[67] = "omega_f in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[75] = "omega_fs in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[73] = "omega_sf in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[64] = "psi_s in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[61] = "psi_f in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[58] = "xi_s in component L_type_Ca_channel_states (per_millisecond)" legend_algebraic[54] = "xi_f in component L_type_Ca_channel_states (per_millisecond)" legend_constants[44] = "T_correction_Ca in component L_type_Ca_channel_states (dimensionless)" legend_constants[15] = "Q10Ca in component L_type_Ca_channel_states (dimensionless)" legend_algebraic[79] = "norm in component L_type_Ca_channel_states (dimensionless)" legend_constants[16] = "g_CaT in component T_type_Ca_channel (nanoS)" legend_algebraic[25] = "E_Ca in component T_type_Ca_channel (millivolt)" legend_states[16] = "d_CaT in component T_type_Ca_channel_d_gate (dimensionless)" legend_states[17] = "f_CaT in component T_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[2] = "d_CaT_inf in component T_type_Ca_channel_d_gate (dimensionless)" legend_constants[54] = "tau_d_CaT in component T_type_Ca_channel_d_gate (millisecond)" legend_constants[45] = "T_correction_Ca in component T_type_Ca_channel_d_gate (dimensionless)" legend_constants[17] = "Q10Ca in component T_type_Ca_channel_d_gate (dimensionless)" legend_algebraic[3] = "f_CaT_inf in component T_type_Ca_channel_f_gate (dimensionless)" legend_algebraic[10] = "tau_f_CaT in component T_type_Ca_channel_f_gate (millisecond)" legend_constants[46] = "T_correction_Ca in component T_type_Ca_channel_f_gate (dimensionless)" legend_constants[18] = "Q10Ca in component T_type_Ca_channel_f_gate (dimensionless)" legend_constants[19] = "g_Kv in component voltage_dep_K_channel (nanoS)" legend_algebraic[33] = "E_K in component voltage_dep_K_channel (millivolt)" legend_states[18] = "x_Kv in component voltage_dep_K_channel_x_gate (dimensionless)" legend_states[19] = "y_Kv in component voltage_dep_K_channel_y_gate (dimensionless)" legend_constants[20] = "Ko in component ionic_concentrations (millimolar)" legend_states[20] = "Ki in component ionic_concentrations (millimolar)" legend_algebraic[4] = "x_Kv_inf in component voltage_dep_K_channel_x_gate (dimensionless)" legend_constants[55] = "tau_x_Kv in component voltage_dep_K_channel_x_gate (millisecond)" legend_constants[47] = "T_correction_K in component voltage_dep_K_channel_x_gate (dimensionless)" legend_constants[21] = "Q10K in component voltage_dep_K_channel_x_gate (dimensionless)" legend_algebraic[5] = "y_Kv_inf in component voltage_dep_K_channel_y_gate (dimensionless)" legend_constants[56] = "tau_y_Kv in component voltage_dep_K_channel_y_gate (millisecond)" legend_constants[48] = "T_correction_K in component voltage_dep_K_channel_y_gate (dimensionless)" legend_constants[22] = "Q10K in component voltage_dep_K_channel_y_gate (dimensionless)" legend_algebraic[41] = "E_K in component Calcium_voltage_activated_potassium_channel (millivolt)" legend_constants[23] = "g_BK in component Calcium_voltage_activated_potassium_channel (nanoS)" legend_states[21] = "O4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[22] = "C0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[23] = "C1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[24] = "C2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[25] = "C3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[26] = "C4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[27] = "O0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[28] = "O1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[29] = "O2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_states[30] = "O3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_algebraic[6] = "alpha in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[11] = "beta in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[49] = "k_on in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[50] = "k_off_C in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[51] = "k_off_O in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[15] = "k_C0O0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[19] = "k_C1O1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[23] = "k_C2O2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[27] = "k_C3O3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[31] = "k_C4O4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[35] = "k_O0C0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[39] = "k_O1C1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[43] = "k_O2C2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[47] = "k_O3C3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[51] = "k_O4C4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[55] = "k_C0C1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[59] = "k_C1C2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[62] = "k_C2C3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[65] = "k_C3C4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[57] = "k_C4C3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[58] = "k_C3C2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[59] = "k_C2C1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[60] = "k_C1C0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[68] = "k_O0O1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[71] = "k_O1O2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[74] = "k_O2O3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[76] = "k_O3O4 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[61] = "k_O4O3 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[62] = "k_O3O2 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[63] = "k_O2O1 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_constants[64] = "k_O1O0 in component Calcium_voltage_activated_potassium_channel_states (per_millisecond)" legend_algebraic[78] = "norm in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_algebraic[49] = "E_Na in component sodium_current (millivolt)" legend_constants[24] = "g_Na in component sodium_current (nanoS)" legend_constants[25] = "Nao in component ionic_concentrations (millimolar)" legend_states[31] = "Nai in component ionic_concentrations (millimolar)" legend_states[32] = "O_Na in component Na_channel_states (dimensionless)" legend_states[33] = "C1 in component Na_channel_states (dimensionless)" legend_states[34] = "C2 in component Na_channel_states (dimensionless)" legend_states[35] = "C3 in component Na_channel_states (dimensionless)" legend_states[36] = "I1 in component Na_channel_states (dimensionless)" legend_states[37] = "I2 in component Na_channel_states (dimensionless)" legend_algebraic[7] = "k_I2I1 in component Na_channel_states (per_millisecond)" legend_algebraic[12] = "k_I1O in component Na_channel_states (per_millisecond)" legend_algebraic[16] = "k_OC1 in component Na_channel_states (per_millisecond)" legend_algebraic[20] = "k_C1C2 in component Na_channel_states (per_millisecond)" legend_algebraic[24] = "k_C2C3 in component Na_channel_states (per_millisecond)" legend_algebraic[28] = "k_C3C2 in component Na_channel_states (per_millisecond)" legend_algebraic[32] = "k_C2C1 in component Na_channel_states (per_millisecond)" legend_algebraic[36] = "k_C1O in component Na_channel_states (per_millisecond)" legend_algebraic[40] = "k_OI1 in component Na_channel_states (per_millisecond)" legend_algebraic[44] = "k_I1I2 in component Na_channel_states (per_millisecond)" legend_algebraic[48] = "k_I1C1 in component Na_channel_states (per_millisecond)" legend_algebraic[52] = "k_C1I1 in component Na_channel_states (per_millisecond)" legend_algebraic[56] = "norm in component Na_channel_states (dimensionless)" legend_constants[52] = "T_correction_Na in component Na_channel_states (dimensionless)" legend_constants[26] = "Q10Na in component Na_channel_states (dimensionless)" legend_constants[27] = "P_NCX in component Na_Ca_exchanger (picoA)" legend_constants[28] = "K_mCa in component Na_Ca_exchanger (millimolar)" legend_constants[29] = "K_mNai in component Na_Ca_exchanger (millimolar)" legend_constants[30] = "k_sat in component Na_Ca_exchanger (dimensionless)" legend_constants[31] = "gamma in component Na_Ca_exchanger (dimensionless)" legend_constants[32] = "P_NaK in component sodium_potassium_pump (picoA)" legend_constants[33] = "K_mK in component sodium_potassium_pump (millimolar)" legend_constants[34] = "K_mNa in component sodium_potassium_pump (millimolar)" legend_constants[35] = "g_NsNa in component non_specific_Na_current (nanoS)" legend_algebraic[63] = "E_Na in component non_specific_Na_current (millivolt)" legend_constants[36] = "g_NsK in component non_specific_K_current (nanoS)" legend_algebraic[69] = "E_K in component non_specific_K_current (millivolt)" legend_constants[37] = "CRT_total in component ionic_concentrations (millimolar)" legend_constants[38] = "CaM_total in component ionic_concentrations (millimolar)" legend_constants[39] = "K_D_CRT in component ionic_concentrations (millimolar)" legend_constants[40] = "K_D_CaM in component ionic_concentrations (millimolar4)" legend_constants[41] = "n_CRT in component ionic_concentrations (dimensionless)" legend_constants[42] = "n_CaM in component ionic_concentrations (dimensionless)" legend_constants[43] = "V_myo in component ionic_concentrations (litre)" legend_rates[0] = "d/dt V in component membrane (millivolt)" legend_rates[6] = "d/dt C3 in component L_type_Ca_channel_states (dimensionless)" legend_rates[5] = "d/dt C2 in component L_type_Ca_channel_states (dimensionless)" legend_rates[4] = "d/dt C1 in component L_type_Ca_channel_states (dimensionless)" legend_rates[3] = "d/dt C0 in component L_type_Ca_channel_states (dimensionless)" legend_rates[10] = "d/dt C3Ca in component L_type_Ca_channel_states (dimensionless)" legend_rates[9] = "d/dt C2Ca in component L_type_Ca_channel_states (dimensionless)" legend_rates[8] = "d/dt C1Ca in component L_type_Ca_channel_states (dimensionless)" legend_rates[7] = "d/dt C0Ca in component L_type_Ca_channel_states (dimensionless)" legend_rates[2] = "d/dt O_CaL in component L_type_Ca_channel_states (dimensionless)" legend_rates[11] = "d/dt ICa in component L_type_Ca_channel_states (dimensionless)" legend_rates[12] = "d/dt IVs in component L_type_Ca_channel_states (dimensionless)" legend_rates[13] = "d/dt IVf in component L_type_Ca_channel_states (dimensionless)" legend_rates[15] = "d/dt IVsCa in component L_type_Ca_channel_states (dimensionless)" legend_rates[14] = "d/dt IVfCa in component L_type_Ca_channel_states (dimensionless)" legend_rates[16] = "d/dt d_CaT in component T_type_Ca_channel_d_gate (dimensionless)" legend_rates[17] = "d/dt f_CaT in component T_type_Ca_channel_f_gate (dimensionless)" legend_rates[18] = "d/dt x_Kv in component voltage_dep_K_channel_x_gate (dimensionless)" legend_rates[19] = "d/dt y_Kv in component voltage_dep_K_channel_y_gate (dimensionless)" legend_rates[26] = "d/dt C4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[25] = "d/dt C3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[24] = "d/dt C2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[23] = "d/dt C1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[22] = "d/dt C0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[21] = "d/dt O4 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[30] = "d/dt O3 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[29] = "d/dt O2 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[28] = "d/dt O1 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[27] = "d/dt O0 in component Calcium_voltage_activated_potassium_channel_states (dimensionless)" legend_rates[35] = "d/dt C3 in component Na_channel_states (dimensionless)" legend_rates[34] = "d/dt C2 in component Na_channel_states (dimensionless)" legend_rates[33] = "d/dt C1 in component Na_channel_states (dimensionless)" legend_rates[32] = "d/dt O_Na in component Na_channel_states (dimensionless)" legend_rates[37] = "d/dt I2 in component Na_channel_states (dimensionless)" legend_rates[36] = "d/dt I1 in component Na_channel_states (dimensionless)" legend_rates[31] = "d/dt Nai in component ionic_concentrations (millimolar)" legend_rates[20] = "d/dt Ki in component ionic_concentrations (millimolar)" legend_rates[1] = "d/dt Cai 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] = -73.5049651455872 constants[0] = 8.314 constants[1] = 310 constants[2] = 96.48534 constants[3] = 50 constants[4] = 10000 constants[5] = 2.6 constants[6] = 300 constants[7] = 9700 constants[8] = 600 constants[9] = 12000 constants[10] = 300 constants[11] = -57 constants[12] = 33.5 constants[13] = 1.44 constants[14] = 2 states[1] = 5.38843941249284e-5 states[2] = 3.88576045134351e-6 states[3] = 0.815464741971086 states[4] = 0.152399266235657 states[5] = 0.0106805060777161 states[6] = 0.000332673548872087 states[7] = 0.0175888495282545 states[8] = 0.00328711668724504 states[9] = 0.000230369020877669 states[10] = 7.1754726923539e-6 states[11] = 8.38123983500905e-8 states[12] = 1.1193313274705e-6 states[13] = 4.0998751301597e-6 states[14] = 8.84306615061238e-8 states[15] = 2.41429816075123e-8 constants[15] = 2.1 constants[16] = 0.0425 states[16] = 0.0791635737410974 states[17] = 0.377831534375835 constants[17] = 2.1 constants[18] = 2.1 constants[19] = 1.0217 states[18] = 0.14714161078933 states[19] = 0.99994773314105 constants[20] = 5.4 states[20] = 153.604280337996 constants[21] = 3.1 constants[22] = 3.1 constants[23] = 80 states[21] = 1.82113764497095e-6 states[22] = 0.48379087935899 states[23] = 0.385183559520031 states[24] = 0.115002824567753 states[25] = 0.0152602714149774 states[26] = 0.000759264410974374 states[27] = 6.94960798375172e-7 states[28] = 5.55636826398253e-8 states[29] = 2.85143702125325e-8 states[30] = 1.59832806123435e-6 constants[24] = 25.1 constants[25] = 140 states[31] = 10.5731241425458 states[32] = 1.96760342050475e-6 states[33] = 0.0119443135223679 states[34] = 0.0109545368437155 states[35] = 0.973782548650071 states[36] = 0.000126882921013389 states[37] = 0.00318975045717667 constants[26] = 2.45 constants[27] = 1992.335 constants[28] = 1.38 constants[29] = 87.5 constants[30] = 0.1 constants[31] = 0.35 constants[32] = 9.26 constants[33] = 1 constants[34] = 40 constants[35] = 0.022488 constants[36] = 0.017512 constants[37] = 0.034 constants[38] = 0.012 constants[39] = 0.0009 constants[40] = 0.0001 constants[41] = 1 constants[42] = 4 constants[43] = 3.50000e-12 constants[44] = power(constants[15], (constants[1]-310.000)/10.0000) constants[45] = power(constants[17], (constants[1]-297.000)/10.0000) constants[46] = power(constants[18], (constants[1]-297.000)/10.0000) constants[47] = power(constants[21], (constants[1]-297.000)/10.0000) constants[48] = power(constants[22], (constants[1]-297.000)/10.0000) constants[49] = 40633.0 constants[50] = 11.0000 constants[51] = 1.10000 constants[52] = 1.00000*(power(constants[26], (constants[1]-297.000)/10.0000)) constants[53] = constants[44]*0.0100000 constants[54] = 1.90580/constants[45] constants[55] = 4.78030/constants[47] constants[56] = 763.756/constants[48] constants[57] = 4.00000*constants[50] constants[58] = 3.00000*constants[50] constants[59] = 2.00000*constants[50] constants[60] = 1.00000*constants[50] constants[61] = 4.00000*constants[51] constants[62] = 3.00000*constants[51] constants[63] = 2.00000*constants[51] constants[64] = 1.00000*constants[51] return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic algebraic[2] = 1.00000/(1.00000+exp(-(states[0]+60.5000)/5.30000)) rates[16] = (algebraic[2]-states[16])/constants[54] algebraic[4] = 1.00000/(1.00000+exp(-(states[0]+43.0000)/17.3600)) rates[18] = (algebraic[4]-states[18])/constants[55] algebraic[5] = 1.00000/(1.00000+exp((states[0]-44.9000)/12.0096)) rates[19] = (algebraic[5]-states[19])/constants[56] algebraic[3] = 1.00000/(1.00000+exp((states[0]+75.5000)/4.00000)) algebraic[10] = (0.381170*(8.60000+14.7000*exp((-(states[0]+50.0000)*(states[0]+50.0000))/900.000)))/constants[46] rates[17] = (algebraic[3]-states[17])/algebraic[10] algebraic[24] = constants[52]*0.554320*exp(-0.0990740+0.0364410*states[0]) algebraic[28] = constants[52]*0.000525480*exp(-0.0691020+0.00319450*states[0]) algebraic[56] = states[32]+states[33]+states[34]+states[35]+states[36]+states[37] rates[35] = (-algebraic[28]*states[35])/algebraic[56]+(algebraic[24]*states[34])/algebraic[56] algebraic[20] = constants[52]*3.15660*exp(0.363520+0.0771930*states[0]) algebraic[32] = constants[52]*1.44960*exp(-0.156600+0.0583530*states[0]) rates[34] = (-(algebraic[32]+algebraic[24])*states[34])/algebraic[56]+(algebraic[20]*states[33])/algebraic[56]+(algebraic[28]*states[35])/algebraic[56] algebraic[16] = constants[52]*2.39100*exp(-13.3350-0.252890*states[0]) algebraic[36] = constants[52]*1.53290*exp(0.00931930+0.0410750*states[0]) algebraic[48] = constants[52]*1.90460*exp(-2.48400+0.0204060*states[0]) algebraic[52] = constants[52]*0.000216880*exp(-0.0634380+0.00466830*states[0]) rates[33] = (-(algebraic[20]+algebraic[36]+algebraic[52])*states[33])/algebraic[56]+(algebraic[16]*states[32])/algebraic[56]+(algebraic[32]*states[34])/algebraic[56]+(algebraic[48]*states[36])/algebraic[56] algebraic[12] = constants[52]*0.120520*exp(-9.60280+0.0830250*states[0]) algebraic[40] = constants[52]*1.61640*exp(0.307630+0.00605350*states[0]) rates[32] = (-(algebraic[16]+algebraic[40])*states[32])/algebraic[56]+(algebraic[36]*states[33])/algebraic[56]+(algebraic[12]*states[36])/algebraic[56] algebraic[7] = constants[52]*0.00392390*exp(2.67930+0.00614680*states[0]) algebraic[44] = constants[52]*0.0277350*exp(0.0514900-0.0468650*states[0]) rates[37] = (-algebraic[7]*states[37])/algebraic[56]+(algebraic[44]*states[36])/algebraic[56] rates[36] = (-(algebraic[12]+algebraic[44]+algebraic[48])*states[36])/algebraic[56]+(algebraic[7]*states[37])/algebraic[56]+(algebraic[52]*states[33])/algebraic[56]+(algebraic[40]*states[32])/algebraic[56] algebraic[17] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[14]/states[1]) algebraic[21] = constants[13]*states[2]*(states[0]-algebraic[17]) algebraic[25] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[14]/states[1]) algebraic[29] = constants[16]*states[16]*states[17]*(states[0]-algebraic[25]) algebraic[57] = (constants[27]*(exp((constants[31]*states[0]*constants[2])/(constants[0]*constants[1]))*(power(states[31], 3.00000))*constants[14]-2.50000*exp(((constants[31]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1]))*(power(constants[25], 3.00000))*states[1]))/((power(constants[29], 3.00000)+power(constants[25], 3.00000))*(constants[28]+constants[14])*(1.00000+constants[30]*exp(((constants[31]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1])))) rates[1] = ((-1.00000e-15*((algebraic[21]+algebraic[29])-algebraic[57]*2.00000))/(2.00000*constants[43]*constants[2]))/(1.00000+(constants[41]*constants[37]*constants[39]*(power(states[1], constants[41]-1.00000)))/(power(power(states[1], constants[41])+constants[39], 2.00000))+(constants[42]*constants[38]*constants[40]*(power(states[1], constants[42]-1.00000)))/(power(power(states[1], constants[42])+constants[40], 2.00000))) algebraic[49] = ((constants[0]*constants[1])/constants[2])*log(constants[25]/states[31]) algebraic[53] = constants[24]*states[32]*(states[0]-algebraic[49]) algebraic[60] = (constants[32]*constants[20]*states[31])/((constants[20]+constants[33])*(constants[34]+states[31])*(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0353000*exp((-states[0]*constants[2])/(constants[0]*constants[1])))) algebraic[63] = ((constants[0]*constants[1])/constants[2])*log(constants[25]/states[31]) algebraic[66] = constants[35]*(states[0]-algebraic[63]) rates[31] = ((-1.00000/1.00000e+15)*(algebraic[53]+algebraic[66]+algebraic[57]*3.00000+algebraic[60]*3.00000))/(constants[43]*constants[2]) algebraic[0] = custom_piecewise([greater_equal(voi , constants[4]*0.00000) & less_equal(voi , constants[4]*1.00000), constants[4]*0.00000 , greater_equal(voi , constants[4]*1.00000) & less_equal(voi , constants[4]*2.00000), constants[4]*1.00000 , greater_equal(voi , constants[4]*2.00000) & less(voi , constants[4]*3.00000), constants[4]*2.00000 , greater_equal(voi , constants[4]*3.00000) & less(voi , constants[4]*4.00000), constants[4]*3.00000 , True, 0.00000]) algebraic[8] = voi-algebraic[0] algebraic[13] = custom_piecewise([less(algebraic[8] , constants[6]), constants[5]*(states[0]-(constants[11]+(constants[12]*algebraic[8])/constants[10])) , True, constants[5]*(states[0]-(constants[11]+(constants[12]*(1.00000+exp(-constants[9]/(2.00000*constants[8])))*1.00000)/(1.00000+exp(((algebraic[8]-constants[10])-0.500000*constants[9])/constants[8]))))]) algebraic[33] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[20]) algebraic[37] = constants[19]*states[18]*states[19]*(states[0]-algebraic[33]) algebraic[41] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[20]) algebraic[45] = constants[23]*states[21]*(states[0]-algebraic[41]) algebraic[69] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[20]) algebraic[72] = constants[36]*(states[0]-algebraic[69]) rates[0] = (-1.00000/constants[3])*(algebraic[53]+algebraic[21]+algebraic[29]+algebraic[37]+algebraic[45]+algebraic[57]+algebraic[60]+algebraic[72]+algebraic[66]+algebraic[13]) rates[20] = (-1.00000e-15*((algebraic[37]+algebraic[45]+algebraic[72]+algebraic[13])-algebraic[60]*2.00000))/(constants[43]*constants[2]) algebraic[6] = 1.00000*exp((8.47188*states[0])/(1.00000*constants[1])) algebraic[31] = 0.0443240*algebraic[6] algebraic[11] = 1.00000*exp((-7.77556*states[0])/(1.00000*constants[1])) algebraic[51] = 0.000106000*algebraic[11] algebraic[65] = 1.00000*constants[49]*states[1] algebraic[78] = states[22]+states[23]+states[24]+states[25]+states[26]+states[27]+states[28]+states[29]+states[30]+states[21] rates[26] = (-(constants[57]+algebraic[31])*states[26])/algebraic[78]+(algebraic[65]*states[25])/algebraic[78]+(algebraic[51]*states[21])/algebraic[78] algebraic[27] = 0.000781000*algebraic[6] algebraic[47] = 0.0953120*algebraic[11] algebraic[62] = 2.00000*constants[49]*states[1] rates[25] = (-(constants[58]+algebraic[27]+algebraic[65])*states[25])/algebraic[78]+(algebraic[62]*states[24])/algebraic[78]+(algebraic[47]*states[30])/algebraic[78]+(constants[57]*states[26])/algebraic[78] algebraic[23] = 2.81000e-05*algebraic[6] algebraic[43] = 32.6594*algebraic[11] algebraic[59] = 3.00000*constants[49]*states[1] rates[24] = (-(constants[59]+algebraic[23]+algebraic[62])*states[24])/algebraic[78]+(algebraic[59]*states[23])/algebraic[78]+(algebraic[43]*states[29])/algebraic[78]+(constants[58]*states[25])/algebraic[78] algebraic[19] = 0.000869000*algebraic[6] algebraic[39] = 144.174*algebraic[11] algebraic[55] = 4.00000*constants[49]*states[1] rates[23] = (-(constants[60]+algebraic[19]+algebraic[59])*states[23])/algebraic[78]+(algebraic[55]*states[22])/algebraic[78]+(algebraic[39]*states[28])/algebraic[78]+(constants[59]*states[24])/algebraic[78] algebraic[15] = 0.0216200*algebraic[6] algebraic[35] = 318.108*algebraic[11] rates[22] = (-(algebraic[55]+algebraic[15])*states[22])/algebraic[78]+(constants[60]*states[23])/algebraic[78]+(algebraic[35]*states[27])/algebraic[78] algebraic[76] = 1.00000*constants[49]*states[1] rates[21] = (-(constants[61]+algebraic[51])*states[21])/algebraic[78]+(algebraic[76]*states[30])/algebraic[78]+(algebraic[31]*states[26])/algebraic[78] algebraic[74] = 2.00000*constants[49]*states[1] rates[30] = (-(constants[62]+algebraic[47]+algebraic[76])*states[30])/algebraic[78]+(algebraic[74]*states[29])/algebraic[78]+(algebraic[27]*states[25])/algebraic[78]+(constants[61]*states[21])/algebraic[78] algebraic[71] = 3.00000*constants[49]*states[1] rates[29] = (-(constants[63]+algebraic[43]+algebraic[74])*states[29])/algebraic[78]+(algebraic[71]*states[28])/algebraic[78]+(algebraic[23]*states[24])/algebraic[78]+(constants[62]*states[30])/algebraic[78] algebraic[68] = 4.00000*constants[49]*states[1] rates[28] = (-(constants[64]+algebraic[39]+algebraic[71])*states[28])/algebraic[78]+(algebraic[68]*states[27])/algebraic[78]+(algebraic[19]*states[23])/algebraic[78]+(constants[63]*states[29])/algebraic[78] rates[27] = (-(algebraic[68]+algebraic[35])*states[27])/algebraic[78]+(constants[64]*states[28])/algebraic[78]+(algebraic[15]*states[22])/algebraic[78] algebraic[1] = constants[44]*0.731000*exp(states[0]/30.0000) algebraic[22] = 2.00000*algebraic[1] algebraic[26] = 1.00000*algebraic[1] algebraic[9] = constants[44]*0.214900*exp(-states[0]/40.0000) algebraic[38] = 3.00000*algebraic[9] algebraic[42] = 4.00000*algebraic[9] algebraic[77] = (constants[44]*4.00000)/(1.00000+1.00000/states[1]) algebraic[50] = constants[44]*0.0595600*exp(-states[0]/40.0000) algebraic[46] = constants[44]*0.474200*exp(states[0]/10.0000) algebraic[64] = constants[44]*0.00232000*exp(-states[0]/280.000) algebraic[58] = constants[44]*0.0121300*exp(states[0]/500.000) algebraic[70] = (algebraic[42]*algebraic[58]*algebraic[50])/(algebraic[26]*algebraic[64]) algebraic[61] = constants[44]*0.0219700*exp(states[0]/500.000) algebraic[54] = constants[44]*0.0140700*exp(-states[0]/300.000) algebraic[67] = (algebraic[42]*algebraic[54]*algebraic[46])/(algebraic[26]*algebraic[61]) algebraic[79] = states[6]+states[5]+states[4]+states[3]+states[10]+states[9]+states[8]+states[7]+states[2]+states[11]+states[12]+states[13]+states[15]+states[14] rates[6] = ((algebraic[22]*states[5])/algebraic[79]-((algebraic[26]+algebraic[38]+algebraic[50]+algebraic[46]+algebraic[77])*states[6])/algebraic[79])+(algebraic[42]*states[2])/algebraic[79]+(algebraic[67]*states[13])/algebraic[79]+(algebraic[70]*states[12])/algebraic[79]+(constants[53]*states[10])/algebraic[79] algebraic[18] = 3.00000*algebraic[1] algebraic[34] = 2.00000*algebraic[9] rates[5] = ((algebraic[18]*states[4])/algebraic[79]-((algebraic[22]+algebraic[34]+algebraic[77])*states[5])/algebraic[79])+(algebraic[38]*states[6])/algebraic[79]+(constants[53]*states[9])/algebraic[79] algebraic[14] = 4.00000*algebraic[1] algebraic[30] = 1.00000*algebraic[9] rates[4] = ((algebraic[14]*states[3])/algebraic[79]-((algebraic[18]+algebraic[30]+algebraic[77])*states[4])/algebraic[79])+(algebraic[34]*states[5])/algebraic[79]+(constants[53]*states[8])/algebraic[79] rates[3] = (-(algebraic[14]+algebraic[77])*states[3])/algebraic[79]+(algebraic[30]*states[4])/algebraic[79]+(constants[53]*states[7])/algebraic[79] rates[10] = (((algebraic[77]*states[6])/algebraic[79]+(algebraic[22]*states[9])/algebraic[79])-((algebraic[26]+algebraic[38]+algebraic[46]+algebraic[50]+constants[53])*states[10])/algebraic[79])+(algebraic[42]*states[11])/algebraic[79]+(algebraic[67]*states[14])/algebraic[79]+(algebraic[70]*states[15])/algebraic[79] rates[9] = (((algebraic[77]*states[5])/algebraic[79]+(algebraic[18]*states[8])/algebraic[79])-((algebraic[22]+algebraic[34]+constants[53])*states[9])/algebraic[79])+(algebraic[38]*states[10])/algebraic[79] rates[8] = (((algebraic[77]*states[4])/algebraic[79]+(algebraic[14]*states[7])/algebraic[79])-((algebraic[18]+algebraic[30]+constants[53])*states[8])/algebraic[79])+(algebraic[34]*states[9])/algebraic[79] rates[7] = ((algebraic[77]*states[3])/algebraic[79]-((algebraic[14]+constants[53])*states[7])/algebraic[79])+(algebraic[30]*states[8])/algebraic[79] rates[2] = ((algebraic[26]*states[6])/algebraic[79]-((algebraic[42]+algebraic[61]+algebraic[64]+algebraic[77])*states[2])/algebraic[79])+(algebraic[54]*states[13])/algebraic[79]+(algebraic[58]*states[12])/algebraic[79]+(constants[53]*states[11])/algebraic[79] rates[11] = (((algebraic[77]*states[2])/algebraic[79]+(algebraic[26]*states[10])/algebraic[79])-((algebraic[42]+algebraic[61]+algebraic[64]+constants[53])*states[11])/algebraic[79])+(algebraic[54]*states[14])/algebraic[79]+(algebraic[58]*states[15])/algebraic[79] algebraic[75] = algebraic[64] algebraic[73] = (algebraic[58]*algebraic[61])/algebraic[54] rates[12] = (((algebraic[50]*states[6])/algebraic[79]+(algebraic[64]*states[2])/algebraic[79]+(algebraic[75]*states[13])/algebraic[79])-((algebraic[70]+algebraic[58]+algebraic[73]+algebraic[77])*states[12])/algebraic[79])+(constants[53]*states[15])/algebraic[79] rates[13] = (((algebraic[46]*states[6])/algebraic[79]+(algebraic[61]*states[2])/algebraic[79])-((algebraic[67]+algebraic[54]+algebraic[75]+algebraic[77])*states[13])/algebraic[79])+(algebraic[73]*states[12])/algebraic[79]+(constants[53]*states[14])/algebraic[79] rates[15] = ((algebraic[77]*states[12])/algebraic[79]+(algebraic[50]*states[10])/algebraic[79]+(algebraic[64]*states[11])/algebraic[79]+(algebraic[75]*states[14])/algebraic[79])-((algebraic[70]+algebraic[58]+algebraic[73]+constants[53])*states[15])/algebraic[79] rates[14] = (((algebraic[77]*states[13])/algebraic[79]+(algebraic[46]*states[10])/algebraic[79]+(algebraic[61]*states[11])/algebraic[79])-((algebraic[67]+algebraic[54]+algebraic[75]+constants[53])*states[14])/algebraic[79])+(algebraic[73]*states[15])/algebraic[79] return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[2] = 1.00000/(1.00000+exp(-(states[0]+60.5000)/5.30000)) algebraic[4] = 1.00000/(1.00000+exp(-(states[0]+43.0000)/17.3600)) algebraic[5] = 1.00000/(1.00000+exp((states[0]-44.9000)/12.0096)) algebraic[3] = 1.00000/(1.00000+exp((states[0]+75.5000)/4.00000)) algebraic[10] = (0.381170*(8.60000+14.7000*exp((-(states[0]+50.0000)*(states[0]+50.0000))/900.000)))/constants[46] algebraic[24] = constants[52]*0.554320*exp(-0.0990740+0.0364410*states[0]) algebraic[28] = constants[52]*0.000525480*exp(-0.0691020+0.00319450*states[0]) algebraic[56] = states[32]+states[33]+states[34]+states[35]+states[36]+states[37] algebraic[20] = constants[52]*3.15660*exp(0.363520+0.0771930*states[0]) algebraic[32] = constants[52]*1.44960*exp(-0.156600+0.0583530*states[0]) algebraic[16] = constants[52]*2.39100*exp(-13.3350-0.252890*states[0]) algebraic[36] = constants[52]*1.53290*exp(0.00931930+0.0410750*states[0]) algebraic[48] = constants[52]*1.90460*exp(-2.48400+0.0204060*states[0]) algebraic[52] = constants[52]*0.000216880*exp(-0.0634380+0.00466830*states[0]) algebraic[12] = constants[52]*0.120520*exp(-9.60280+0.0830250*states[0]) algebraic[40] = constants[52]*1.61640*exp(0.307630+0.00605350*states[0]) algebraic[7] = constants[52]*0.00392390*exp(2.67930+0.00614680*states[0]) algebraic[44] = constants[52]*0.0277350*exp(0.0514900-0.0468650*states[0]) algebraic[17] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[14]/states[1]) algebraic[21] = constants[13]*states[2]*(states[0]-algebraic[17]) algebraic[25] = ((constants[0]*constants[1])/(2.00000*constants[2]))*log(constants[14]/states[1]) algebraic[29] = constants[16]*states[16]*states[17]*(states[0]-algebraic[25]) algebraic[57] = (constants[27]*(exp((constants[31]*states[0]*constants[2])/(constants[0]*constants[1]))*(power(states[31], 3.00000))*constants[14]-2.50000*exp(((constants[31]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1]))*(power(constants[25], 3.00000))*states[1]))/((power(constants[29], 3.00000)+power(constants[25], 3.00000))*(constants[28]+constants[14])*(1.00000+constants[30]*exp(((constants[31]-1.00000)*states[0]*constants[2])/(constants[0]*constants[1])))) algebraic[49] = ((constants[0]*constants[1])/constants[2])*log(constants[25]/states[31]) algebraic[53] = constants[24]*states[32]*(states[0]-algebraic[49]) algebraic[60] = (constants[32]*constants[20]*states[31])/((constants[20]+constants[33])*(constants[34]+states[31])*(1.00000+0.124500*exp((-0.100000*states[0]*constants[2])/(constants[0]*constants[1]))+0.0353000*exp((-states[0]*constants[2])/(constants[0]*constants[1])))) algebraic[63] = ((constants[0]*constants[1])/constants[2])*log(constants[25]/states[31]) algebraic[66] = constants[35]*(states[0]-algebraic[63]) algebraic[0] = custom_piecewise([greater_equal(voi , constants[4]*0.00000) & less_equal(voi , constants[4]*1.00000), constants[4]*0.00000 , greater_equal(voi , constants[4]*1.00000) & less_equal(voi , constants[4]*2.00000), constants[4]*1.00000 , greater_equal(voi , constants[4]*2.00000) & less(voi , constants[4]*3.00000), constants[4]*2.00000 , greater_equal(voi , constants[4]*3.00000) & less(voi , constants[4]*4.00000), constants[4]*3.00000 , True, 0.00000]) algebraic[8] = voi-algebraic[0] algebraic[13] = custom_piecewise([less(algebraic[8] , constants[6]), constants[5]*(states[0]-(constants[11]+(constants[12]*algebraic[8])/constants[10])) , True, constants[5]*(states[0]-(constants[11]+(constants[12]*(1.00000+exp(-constants[9]/(2.00000*constants[8])))*1.00000)/(1.00000+exp(((algebraic[8]-constants[10])-0.500000*constants[9])/constants[8]))))]) algebraic[33] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[20]) algebraic[37] = constants[19]*states[18]*states[19]*(states[0]-algebraic[33]) algebraic[41] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[20]) algebraic[45] = constants[23]*states[21]*(states[0]-algebraic[41]) algebraic[69] = ((constants[0]*constants[1])/constants[2])*log(constants[20]/states[20]) algebraic[72] = constants[36]*(states[0]-algebraic[69]) algebraic[6] = 1.00000*exp((8.47188*states[0])/(1.00000*constants[1])) algebraic[31] = 0.0443240*algebraic[6] algebraic[11] = 1.00000*exp((-7.77556*states[0])/(1.00000*constants[1])) algebraic[51] = 0.000106000*algebraic[11] algebraic[65] = 1.00000*constants[49]*states[1] algebraic[78] = states[22]+states[23]+states[24]+states[25]+states[26]+states[27]+states[28]+states[29]+states[30]+states[21] algebraic[27] = 0.000781000*algebraic[6] algebraic[47] = 0.0953120*algebraic[11] algebraic[62] = 2.00000*constants[49]*states[1] algebraic[23] = 2.81000e-05*algebraic[6] algebraic[43] = 32.6594*algebraic[11] algebraic[59] = 3.00000*constants[49]*states[1] algebraic[19] = 0.000869000*algebraic[6] algebraic[39] = 144.174*algebraic[11] algebraic[55] = 4.00000*constants[49]*states[1] algebraic[15] = 0.0216200*algebraic[6] algebraic[35] = 318.108*algebraic[11] algebraic[76] = 1.00000*constants[49]*states[1] algebraic[74] = 2.00000*constants[49]*states[1] algebraic[71] = 3.00000*constants[49]*states[1] algebraic[68] = 4.00000*constants[49]*states[1] algebraic[1] = constants[44]*0.731000*exp(states[0]/30.0000) algebraic[22] = 2.00000*algebraic[1] algebraic[26] = 1.00000*algebraic[1] algebraic[9] = constants[44]*0.214900*exp(-states[0]/40.0000) algebraic[38] = 3.00000*algebraic[9] algebraic[42] = 4.00000*algebraic[9] algebraic[77] = (constants[44]*4.00000)/(1.00000+1.00000/states[1]) algebraic[50] = constants[44]*0.0595600*exp(-states[0]/40.0000) algebraic[46] = constants[44]*0.474200*exp(states[0]/10.0000) algebraic[64] = constants[44]*0.00232000*exp(-states[0]/280.000) algebraic[58] = constants[44]*0.0121300*exp(states[0]/500.000) algebraic[70] = (algebraic[42]*algebraic[58]*algebraic[50])/(algebraic[26]*algebraic[64]) algebraic[61] = constants[44]*0.0219700*exp(states[0]/500.000) algebraic[54] = constants[44]*0.0140700*exp(-states[0]/300.000) algebraic[67] = (algebraic[42]*algebraic[54]*algebraic[46])/(algebraic[26]*algebraic[61]) algebraic[79] = states[6]+states[5]+states[4]+states[3]+states[10]+states[9]+states[8]+states[7]+states[2]+states[11]+states[12]+states[13]+states[15]+states[14] algebraic[18] = 3.00000*algebraic[1] algebraic[34] = 2.00000*algebraic[9] algebraic[14] = 4.00000*algebraic[1] algebraic[30] = 1.00000*algebraic[9] algebraic[75] = algebraic[64] algebraic[73] = (algebraic[58]*algebraic[61])/algebraic[54] 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)