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 = 65
sizeStates = 34
sizeConstants = 155
from math import *
from numpy import *

def createLegends():
    legend_states = [""] * sizeStates
    legend_rates = [""] * sizeStates
    legend_algebraic = [""] * sizeAlgebraic
    legend_voi = ""
    legend_constants = [""] * sizeConstants
    legend_constants[0] = "t_ss in component Clamp_parameters (ms)"
    legend_constants[1] = "V_actHolding in component Clamp_parameters (mV)"
    legend_constants[2] = "V_actTest in component Clamp_parameters (mV)"
    legend_constants[3] = "Cai in component Clamp_parameters (mM)"
    legend_constants[4] = "Ki in component Clamp_parameters (mM)"
    legend_constants[5] = "Nai in component Clamp_parameters (mM)"
    legend_voi = "time in component time (ms)"
    legend_algebraic[0] = "V in component Patch_clamp_protocol (mV)"
    legend_algebraic[50] = "I_ion in component Clamped_current_Xi (pA)"
    legend_algebraic[22] = "I in component Ionic_currents (pA)"
    legend_algebraic[26] = "I in component Ionic_currents (pA)"
    legend_algebraic[30] = "I in component Ionic_currents (pA)"
    legend_algebraic[34] = "I in component Ionic_currents (pA)"
    legend_algebraic[38] = "I in component Ionic_currents (pA)"
    legend_algebraic[14] = "I_NCX in component INCX (pA)"
    legend_algebraic[18] = "I_NaK in component INaK (pA)"
    legend_algebraic[42] = "I in component Ionic_currents (pA)"
    legend_algebraic[46] = "I in component Ionic_currents (pA)"
    legend_states[0] = "O_CaL in component ICaL_channel_states (dimensionless)"
    legend_algebraic[1] = "P_CaT in component ICaT (dimensionless)"
    legend_states[1] = "O4 in component IBK_channel_states (dimensionless)"
    legend_algebraic[9] = "P_Kv in component IKv (dimensionless)"
    legend_states[2] = "O_Na in component INa_channel_states (dimensionless)"
    legend_states[3] = "X in component gating_kinetics (dimensionless)"
    legend_states[4] = "X in component gating_kinetics (dimensionless)"
    legend_states[5] = "X in component gating_kinetics (dimensionless)"
    legend_states[6] = "X in component gating_kinetics (dimensionless)"
    legend_constants[6] = "g_CaL in component model_parameters (nS)"
    legend_constants[7] = "R in component model_parameters (J_per_K_mol)"
    legend_constants[8] = "T in component model_parameters (kelvin)"
    legend_constants[9] = "F in component model_parameters (C_per_mmol)"
    legend_constants[10] = "T0CaL in component model_parameters (kelvin)"
    legend_constants[11] = "T0CaT in component model_parameters (kelvin)"
    legend_constants[12] = "Q10Ca in component model_parameters (dimensionless)"
    legend_constants[13] = "Cao in component model_parameters (mM)"
    legend_constants[14] = "C0_init in component initial_conditions (dimensionless)"
    legend_constants[15] = "C1_init in component initial_conditions (dimensionless)"
    legend_constants[16] = "C2_init in component initial_conditions (dimensionless)"
    legend_constants[17] = "C3_init in component initial_conditions (dimensionless)"
    legend_constants[18] = "C0Ca_init in component initial_conditions (dimensionless)"
    legend_constants[19] = "C1Ca_init in component initial_conditions (dimensionless)"
    legend_constants[20] = "C2Ca_init in component initial_conditions (dimensionless)"
    legend_constants[21] = "C3Ca_init in component initial_conditions (dimensionless)"
    legend_constants[22] = "ICa_init in component initial_conditions (dimensionless)"
    legend_constants[23] = "IVs_init in component initial_conditions (dimensionless)"
    legend_constants[24] = "IVf_init in component initial_conditions (dimensionless)"
    legend_constants[25] = "IVfCa_init in component initial_conditions (dimensionless)"
    legend_constants[26] = "IVsCa_init in component initial_conditions (dimensionless)"
    legend_constants[27] = "O_CaL_init in component initial_conditions (dimensionless)"
    legend_constants[28] = "g_CaT in component model_parameters (nS)"
    legend_constants[29] = "d_CaT_init in component initial_conditions (dimensionless)"
    legend_constants[30] = "f_CaT_init in component initial_conditions (dimensionless)"
    legend_constants[31] = "tau_dCaT in component model_parameters (ms)"
    legend_constants[32] = "g_Kv in component model_parameters (nS)"
    legend_constants[33] = "T0K in component model_parameters (kelvin)"
    legend_constants[34] = "Q10K in component model_parameters (dimensionless)"
    legend_constants[35] = "Ko in component model_parameters (mM)"
    legend_constants[36] = "x_Kv_init in component initial_conditions (dimensionless)"
    legend_constants[37] = "y_Kv_init in component initial_conditions (dimensionless)"
    legend_constants[38] = "tau_xKv in component model_parameters (ms)"
    legend_constants[39] = "tau_yKv in component model_parameters (ms)"
    legend_constants[40] = "g_BK in component model_parameters (nS)"
    legend_constants[41] = "BK_C0_init in component initial_conditions (dimensionless)"
    legend_constants[42] = "BK_C1_init in component initial_conditions (dimensionless)"
    legend_constants[43] = "BK_C2_init in component initial_conditions (dimensionless)"
    legend_constants[44] = "BK_C3_init in component initial_conditions (dimensionless)"
    legend_constants[45] = "BK_C4_init in component initial_conditions (dimensionless)"
    legend_constants[46] = "O0_init in component initial_conditions (dimensionless)"
    legend_constants[47] = "O1_init in component initial_conditions (dimensionless)"
    legend_constants[48] = "O2_init in component initial_conditions (dimensionless)"
    legend_constants[49] = "O3_init in component initial_conditions (dimensionless)"
    legend_constants[50] = "O4_init in component initial_conditions (dimensionless)"
    legend_constants[51] = "k_on in component model_parameters (per_ms)"
    legend_constants[52] = "k_off_C in component model_parameters (per_ms)"
    legend_constants[53] = "k_off_O in component model_parameters (per_ms)"
    legend_constants[54] = "g_Na in component model_parameters (nS)"
    legend_constants[55] = "T0Na in component model_parameters (kelvin)"
    legend_constants[56] = "Q10Na in component model_parameters (dimensionless)"
    legend_constants[57] = "Nao in component model_parameters (mM)"
    legend_constants[58] = "Na_C1_init in component initial_conditions (dimensionless)"
    legend_constants[59] = "Na_C2_init in component initial_conditions (dimensionless)"
    legend_constants[60] = "Na_C3_init in component initial_conditions (dimensionless)"
    legend_constants[61] = "I1_init in component initial_conditions (dimensionless)"
    legend_constants[62] = "I2_init in component initial_conditions (dimensionless)"
    legend_constants[63] = "O_Na_init in component initial_conditions (dimensionless)"
    legend_constants[64] = "K_mCa in component model_parameters (mM)"
    legend_constants[65] = "K_mNai in component model_parameters (mM)"
    legend_constants[66] = "k_sat in component model_parameters (dimensionless)"
    legend_constants[67] = "gamma in component model_parameters (dimensionless)"
    legend_constants[68] = "P_NCX in component model_parameters (pA)"
    legend_constants[69] = "K_mK in component model_parameters (mM)"
    legend_constants[70] = "K_mNa in component model_parameters (mM)"
    legend_constants[71] = "P_NaK in component model_parameters (pA)"
    legend_constants[72] = "g_NsNa in component model_parameters (nS)"
    legend_constants[73] = "g_NsK in component model_parameters (nS)"
    legend_constants[74] = "Cm in component model_parameters (pF)"
    legend_constants[75] = "V_cell in component model_parameters (litre)"
    legend_constants[76] = "n_CRT in component model_parameters (dimensionless)"
    legend_constants[77] = "n_CaM in component model_parameters (dimensionless)"
    legend_constants[78] = "CRT_total in component model_parameters (mM)"
    legend_constants[79] = "CaM_total in component model_parameters (mM)"
    legend_constants[80] = "K_D_CRT in component model_parameters (mM)"
    legend_constants[81] = "K_D_CaM in component model_parameters (mM4)"
    legend_constants[82] = "V_init in component initial_conditions (mV)"
    legend_constants[83] = "Cai_total_init in component initial_conditions (mM)"
    legend_constants[84] = "Cai_init in component initial_conditions (mM)"
    legend_constants[85] = "Ki_init in component initial_conditions (mM)"
    legend_constants[86] = "Nai_init in component initial_conditions (mM)"
    legend_algebraic[54] = "norm in component IBK_channel_states (dimensionless)"
    legend_algebraic[55] = "norm in component INa_channel_states (dimensionless)"
    legend_constants[87] = "PO in component INS_Na (dimensionless)"
    legend_constants[88] = "PO in component INS_K (dimensionless)"
    legend_constants[125] = "E in component Nernst_potential (mV)"
    legend_states[7] = "C0 in component ICaL_channel_states (dimensionless)"
    legend_states[8] = "C1 in component ICaL_channel_states (dimensionless)"
    legend_states[9] = "C2 in component ICaL_channel_states (dimensionless)"
    legend_states[10] = "C3 in component ICaL_channel_states (dimensionless)"
    legend_states[11] = "C0Ca in component ICaL_channel_states (dimensionless)"
    legend_states[12] = "C1Ca in component ICaL_channel_states (dimensionless)"
    legend_states[13] = "C2Ca in component ICaL_channel_states (dimensionless)"
    legend_states[14] = "C3Ca in component ICaL_channel_states (dimensionless)"
    legend_states[15] = "ICa in component ICaL_channel_states (dimensionless)"
    legend_states[16] = "IVs in component ICaL_channel_states (dimensionless)"
    legend_states[17] = "IVf in component ICaL_channel_states (dimensionless)"
    legend_states[18] = "IVfCa in component ICaL_channel_states (dimensionless)"
    legend_states[19] = "IVsCa in component ICaL_channel_states (dimensionless)"
    legend_algebraic[2] = "alpha in component ICaL_channel_states (per_ms)"
    legend_algebraic[10] = "beta in component ICaL_channel_states (per_ms)"
    legend_algebraic[15] = "alpha_0 in component ICaL_channel_states (per_ms)"
    legend_algebraic[19] = "alpha_1 in component ICaL_channel_states (per_ms)"
    legend_algebraic[23] = "alpha_2 in component ICaL_channel_states (per_ms)"
    legend_algebraic[27] = "alpha_3 in component ICaL_channel_states (per_ms)"
    legend_algebraic[32] = "beta_0 in component ICaL_channel_states (per_ms)"
    legend_algebraic[37] = "beta_1 in component ICaL_channel_states (per_ms)"
    legend_algebraic[41] = "beta_2 in component ICaL_channel_states (per_ms)"
    legend_algebraic[45] = "beta_3 in component ICaL_channel_states (per_ms)"
    legend_constants[126] = "delta in component ICaL_channel_states (per_ms)"
    legend_constants[127] = "theta in component ICaL_channel_states (per_ms)"
    legend_algebraic[53] = "phi_s in component ICaL_channel_states (per_ms)"
    legend_algebraic[49] = "phi_f in component ICaL_channel_states (per_ms)"
    legend_algebraic[61] = "omega_s in component ICaL_channel_states (per_ms)"
    legend_algebraic[60] = "omega_f in component ICaL_channel_states (per_ms)"
    legend_algebraic[63] = "omega_fs in component ICaL_channel_states (per_ms)"
    legend_algebraic[62] = "omega_sf in component ICaL_channel_states (per_ms)"
    legend_algebraic[59] = "psi_s in component ICaL_channel_states (per_ms)"
    legend_algebraic[58] = "psi_f in component ICaL_channel_states (per_ms)"
    legend_algebraic[57] = "xi_s in component ICaL_channel_states (per_ms)"
    legend_algebraic[56] = "xi_f in component ICaL_channel_states (per_ms)"
    legend_algebraic[64] = "norm in component ICaL_channel_states (dimensionless)"
    legend_constants[124] = "phi in component temperature_factor (dimensionless)"
    legend_constants[150] = "E in component Nernst_potential (mV)"
    legend_algebraic[3] = "X_inf in component d_inf (dimensionless)"
    legend_constants[128] = "phi in component temperature_factor (dimensionless)"
    legend_algebraic[4] = "X_inf in component f_inf (dimensionless)"
    legend_algebraic[11] = "tau in component tau_f (ms)"
    legend_constants[129] = "phi in component temperature_factor (dimensionless)"
    legend_constants[151] = "E in component Nernst_potential (mV)"
    legend_algebraic[5] = "X_inf in component x_inf (dimensionless)"
    legend_constants[130] = "phi in component temperature_factor (dimensionless)"
    legend_algebraic[6] = "X_inf in component y_inf (dimensionless)"
    legend_constants[131] = "phi in component temperature_factor (dimensionless)"
    legend_constants[132] = "E in component Nernst_potential (mV)"
    legend_states[20] = "C0 in component IBK_channel_states (dimensionless)"
    legend_states[21] = "C1 in component IBK_channel_states (dimensionless)"
    legend_states[22] = "C2 in component IBK_channel_states (dimensionless)"
    legend_states[23] = "C3 in component IBK_channel_states (dimensionless)"
    legend_states[24] = "C4 in component IBK_channel_states (dimensionless)"
    legend_states[25] = "O0 in component IBK_channel_states (dimensionless)"
    legend_states[26] = "O1 in component IBK_channel_states (dimensionless)"
    legend_states[27] = "O2 in component IBK_channel_states (dimensionless)"
    legend_states[28] = "O3 in component IBK_channel_states (dimensionless)"
    legend_algebraic[7] = "alpha in component IBK_channel_states (per_ms)"
    legend_algebraic[12] = "beta in component IBK_channel_states (per_ms)"
    legend_algebraic[16] = "k_C0O0 in component IBK_channel_states (per_ms)"
    legend_algebraic[20] = "k_C1O1 in component IBK_channel_states (per_ms)"
    legend_algebraic[24] = "k_C2O2 in component IBK_channel_states (per_ms)"
    legend_algebraic[28] = "k_C3O3 in component IBK_channel_states (per_ms)"
    legend_algebraic[33] = "k_C4O4 in component IBK_channel_states (per_ms)"
    legend_algebraic[35] = "k_O0C0 in component IBK_channel_states (per_ms)"
    legend_algebraic[39] = "k_O1C1 in component IBK_channel_states (per_ms)"
    legend_algebraic[43] = "k_O2C2 in component IBK_channel_states (per_ms)"
    legend_algebraic[47] = "k_O3C3 in component IBK_channel_states (per_ms)"
    legend_algebraic[51] = "k_O4C4 in component IBK_channel_states (per_ms)"
    legend_constants[133] = "k_C0C1 in component IBK_channel_states (per_ms)"
    legend_constants[134] = "k_C1C2 in component IBK_channel_states (per_ms)"
    legend_constants[135] = "k_C2C3 in component IBK_channel_states (per_ms)"
    legend_constants[136] = "k_C3C4 in component IBK_channel_states (per_ms)"
    legend_constants[137] = "k_C4C3 in component IBK_channel_states (per_ms)"
    legend_constants[138] = "k_C3C2 in component IBK_channel_states (per_ms)"
    legend_constants[139] = "k_C2C1 in component IBK_channel_states (per_ms)"
    legend_constants[140] = "k_C1C0 in component IBK_channel_states (per_ms)"
    legend_constants[141] = "k_O0O1 in component IBK_channel_states (per_ms)"
    legend_constants[142] = "k_O1O2 in component IBK_channel_states (per_ms)"
    legend_constants[143] = "k_O2O3 in component IBK_channel_states (per_ms)"
    legend_constants[144] = "k_O3O4 in component IBK_channel_states (per_ms)"
    legend_constants[145] = "k_O4O3 in component IBK_channel_states (per_ms)"
    legend_constants[146] = "k_O3O2 in component IBK_channel_states (per_ms)"
    legend_constants[147] = "k_O2O1 in component IBK_channel_states (per_ms)"
    legend_constants[148] = "k_O1O0 in component IBK_channel_states (per_ms)"
    legend_constants[149] = "E in component Nernst_potential (mV)"
    legend_states[29] = "C1 in component INa_channel_states (dimensionless)"
    legend_states[30] = "C2 in component INa_channel_states (dimensionless)"
    legend_states[31] = "C3 in component INa_channel_states (dimensionless)"
    legend_states[32] = "I1 in component INa_channel_states (dimensionless)"
    legend_states[33] = "I2 in component INa_channel_states (dimensionless)"
    legend_algebraic[8] = "k_I2I1 in component INa_channel_states (per_ms)"
    legend_algebraic[13] = "k_I1O in component INa_channel_states (per_ms)"
    legend_algebraic[17] = "k_OC1 in component INa_channel_states (per_ms)"
    legend_algebraic[21] = "k_C1C2 in component INa_channel_states (per_ms)"
    legend_algebraic[25] = "k_C2C3 in component INa_channel_states (per_ms)"
    legend_algebraic[29] = "k_C3C2 in component INa_channel_states (per_ms)"
    legend_algebraic[31] = "k_C2C1 in component INa_channel_states (per_ms)"
    legend_algebraic[36] = "k_C1O in component INa_channel_states (per_ms)"
    legend_algebraic[40] = "k_OI1 in component INa_channel_states (per_ms)"
    legend_algebraic[44] = "k_I1I2 in component INa_channel_states (per_ms)"
    legend_algebraic[48] = "k_I1C1 in component INa_channel_states (per_ms)"
    legend_algebraic[52] = "k_C1I1 in component INa_channel_states (per_ms)"
    legend_constants[152] = "phi in component temperature_factor (dimensionless)"
    legend_constants[153] = "E in component Nernst_potential (mV)"
    legend_constants[154] = "E in component Nernst_potential (mV)"
    legend_constants[89] = "R in component constants (J_per_K_mol)"
    legend_constants[90] = "F in component constants (C_per_mmol)"
    legend_constants[91] = "z_Ca in component constants (dimensionless)"
    legend_constants[92] = "z_Na in component constants (dimensionless)"
    legend_constants[93] = "z_K in component constants (dimensionless)"
    legend_constants[94] = "R in component constants (J_per_K_mol)"
    legend_constants[95] = "F in component constants (C_per_mmol)"
    legend_constants[96] = "z_Ca in component constants (dimensionless)"
    legend_constants[97] = "z_Na in component constants (dimensionless)"
    legend_constants[98] = "z_K in component constants (dimensionless)"
    legend_constants[99] = "R in component constants (J_per_K_mol)"
    legend_constants[100] = "F in component constants (C_per_mmol)"
    legend_constants[101] = "z_K in component constants (dimensionless)"
    legend_constants[102] = "z_Na in component constants (dimensionless)"
    legend_constants[103] = "z_Ca in component constants (dimensionless)"
    legend_constants[104] = "R in component constants (J_per_K_mol)"
    legend_constants[105] = "F in component constants (C_per_mmol)"
    legend_constants[106] = "z_K in component constants (dimensionless)"
    legend_constants[107] = "z_Na in component constants (dimensionless)"
    legend_constants[108] = "z_Ca in component constants (dimensionless)"
    legend_constants[109] = "R in component constants (J_per_K_mol)"
    legend_constants[110] = "F in component constants (C_per_mmol)"
    legend_constants[111] = "z_Na in component constants (dimensionless)"
    legend_constants[112] = "z_Ca in component constants (dimensionless)"
    legend_constants[113] = "z_K in component constants (dimensionless)"
    legend_constants[114] = "R in component constants (J_per_K_mol)"
    legend_constants[115] = "F in component constants (C_per_mmol)"
    legend_constants[116] = "z_Na in component constants (dimensionless)"
    legend_constants[117] = "z_Ca in component constants (dimensionless)"
    legend_constants[118] = "z_K in component constants (dimensionless)"
    legend_constants[119] = "R in component constants (J_per_K_mol)"
    legend_constants[120] = "F in component constants (C_per_mmol)"
    legend_constants[121] = "z_K in component constants (dimensionless)"
    legend_constants[122] = "z_Na in component constants (dimensionless)"
    legend_constants[123] = "z_Ca in component constants (dimensionless)"
    legend_rates[10] = "d/dt C3 in component ICaL_channel_states (dimensionless)"
    legend_rates[9] = "d/dt C2 in component ICaL_channel_states (dimensionless)"
    legend_rates[8] = "d/dt C1 in component ICaL_channel_states (dimensionless)"
    legend_rates[7] = "d/dt C0 in component ICaL_channel_states (dimensionless)"
    legend_rates[14] = "d/dt C3Ca in component ICaL_channel_states (dimensionless)"
    legend_rates[13] = "d/dt C2Ca in component ICaL_channel_states (dimensionless)"
    legend_rates[12] = "d/dt C1Ca in component ICaL_channel_states (dimensionless)"
    legend_rates[11] = "d/dt C0Ca in component ICaL_channel_states (dimensionless)"
    legend_rates[0] = "d/dt O_CaL in component ICaL_channel_states (dimensionless)"
    legend_rates[15] = "d/dt ICa in component ICaL_channel_states (dimensionless)"
    legend_rates[16] = "d/dt IVs in component ICaL_channel_states (dimensionless)"
    legend_rates[17] = "d/dt IVf in component ICaL_channel_states (dimensionless)"
    legend_rates[19] = "d/dt IVsCa in component ICaL_channel_states (dimensionless)"
    legend_rates[18] = "d/dt IVfCa in component ICaL_channel_states (dimensionless)"
    legend_rates[3] = "d/dt X in component gating_kinetics (dimensionless)"
    legend_rates[4] = "d/dt X in component gating_kinetics (dimensionless)"
    legend_rates[5] = "d/dt X in component gating_kinetics (dimensionless)"
    legend_rates[6] = "d/dt X in component gating_kinetics (dimensionless)"
    legend_rates[24] = "d/dt C4 in component IBK_channel_states (dimensionless)"
    legend_rates[23] = "d/dt C3 in component IBK_channel_states (dimensionless)"
    legend_rates[22] = "d/dt C2 in component IBK_channel_states (dimensionless)"
    legend_rates[21] = "d/dt C1 in component IBK_channel_states (dimensionless)"
    legend_rates[20] = "d/dt C0 in component IBK_channel_states (dimensionless)"
    legend_rates[1] = "d/dt O4 in component IBK_channel_states (dimensionless)"
    legend_rates[28] = "d/dt O3 in component IBK_channel_states (dimensionless)"
    legend_rates[27] = "d/dt O2 in component IBK_channel_states (dimensionless)"
    legend_rates[26] = "d/dt O1 in component IBK_channel_states (dimensionless)"
    legend_rates[25] = "d/dt O0 in component IBK_channel_states (dimensionless)"
    legend_rates[31] = "d/dt C3 in component INa_channel_states (dimensionless)"
    legend_rates[30] = "d/dt C2 in component INa_channel_states (dimensionless)"
    legend_rates[29] = "d/dt C1 in component INa_channel_states (dimensionless)"
    legend_rates[2] = "d/dt O_Na in component INa_channel_states (dimensionless)"
    legend_rates[33] = "d/dt I2 in component INa_channel_states (dimensionless)"
    legend_rates[32] = "d/dt I1 in component INa_channel_states (dimensionless)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 1000
    constants[1] = -100
    constants[2] = -90
    constants[3] = 5.38843941249284e-5
    constants[4] = 153.604280337996
    constants[5] = 10.5731241425458
    constants[6] = 1.44
    constants[7] = 8.314
    constants[8] = 310
    constants[9] = 96.48534
    constants[10] = 310
    constants[11] = 297
    constants[12] = 2.1
    constants[13] = 2
    constants[14] = 0.815464741971086
    constants[15] = 0.152399266235657
    constants[16] = 0.0106805060777161
    constants[17] = 0.000332673548872087
    constants[18] = 0.0175888495282545
    constants[19] = 0.00328711668724504
    constants[20] = 0.000230369020877669
    constants[21] = 7.1754726923539e-6
    constants[22] = 8.38123983500905e-8
    constants[23] = 1.1193313274705e-6
    constants[24] = 4.0998751301597e-6
    constants[25] = 8.84306615061238e-8
    constants[26] = 2.41429816075123e-8
    constants[27] = 3.88576045134351e-6
    constants[28] = 0.0425
    constants[29] = 0.0791635737410974
    constants[30] = 0.377831534375835
    constants[31] = 1.9508
    constants[32] = 1.0217
    constants[33] = 297
    constants[34] = 3.1
    constants[35] = 5.4
    constants[36] = 0.14714161078933
    constants[37] = 0.99994773314105
    constants[38] = 4.7803
    constants[39] = 763.7564
    constants[40] = 80
    constants[41] = 0.48379087935899
    constants[42] = 0.385183559520031
    constants[43] = 0.115002824567753
    constants[44] = 0.0152602714149774
    constants[45] = 0.000759264410974374
    constants[46] = 6.94960798375172e-7
    constants[47] = 5.55636826398253e-8
    constants[48] = 2.85143702125325e-8
    constants[49] = 1.59832806123435e-6
    constants[50] = 1.82113764497095e-6
    constants[51] = 40633
    constants[52] = 11
    constants[53] = 1.1
    constants[54] = 25.1
    constants[55] = 297
    constants[56] = 2.45
    constants[57] = 140
    constants[58] = 0.0119443135223679
    constants[59] = 0.0109545368437155
    constants[60] = 0.973782548650071
    constants[61] = 0.000126882921013389
    constants[62] = 0.00318975045717667
    constants[63] = 1.96760342050475e-6
    constants[64] = 1.38
    constants[65] = 87.5
    constants[66] = 0.1
    constants[67] = 0.35
    constants[68] = 1992.1865
    constants[69] = 1
    constants[70] = 40
    constants[71] = 16.197
    constants[72] = 0.022488
    constants[73] = 0.017512
    constants[74] = 50
    constants[75] = 3.5e-12
    constants[76] = 1
    constants[77] = 4
    constants[78] = 0.034
    constants[79] = 0.012
    constants[80] = 0.0009
    constants[81] = 0.0001
    constants[82] = -73.5049651455872
    constants[83] = 0.004914
    constants[84] = 5.38843941249284e-5
    constants[85] = 153.604280337996
    constants[86] = 10.5731241425458
    constants[87] = 1
    constants[88] = 1
    constants[89] = 8.314
    constants[90] = 96.48534
    constants[91] = 2
    constants[92] = 1
    constants[93] = 1
    constants[94] = 8.314
    constants[95] = 96.48534
    constants[96] = 2
    constants[97] = 1
    constants[98] = 1
    constants[99] = 8.314
    constants[100] = 96.48534
    constants[101] = 1
    constants[102] = 1
    constants[103] = 2
    constants[104] = 8.314
    constants[105] = 96.48534
    constants[106] = 1
    constants[107] = 1
    constants[108] = 2
    constants[109] = 8.314
    constants[110] = 96.48534
    constants[111] = 1
    constants[112] = 2
    constants[113] = 1
    constants[114] = 8.314
    constants[115] = 96.48534
    constants[116] = 1
    constants[117] = 2
    constants[118] = 1
    constants[119] = 8.314
    constants[120] = 96.48534
    constants[121] = 1
    constants[122] = 1
    constants[123] = 2
    constants[124] = power(constants[12], (constants[8]-constants[10])/10.0000)
    constants[125] = ((constants[89]*constants[8])/(constants[91]*constants[90]))*log(constants[13]/constants[3])
    constants[126] = 0.00000
    constants[127] = 0.00000
    constants[128] = power(constants[12], (constants[8]-constants[11])/10.0000)
    constants[129] = power(constants[12], (constants[8]-constants[11])/10.0000)
    constants[130] = power(constants[34], (constants[8]-constants[33])/10.0000)
    constants[131] = power(constants[34], (constants[8]-constants[33])/10.0000)
    constants[132] = ((constants[104]*constants[8])/(constants[106]*constants[105]))*log(constants[35]/constants[4])
    constants[133] = 4.00000*constants[51]*constants[3]
    constants[134] = 3.00000*constants[51]*constants[3]
    constants[135] = 2.00000*constants[51]*constants[3]
    constants[136] = 1.00000*constants[51]*constants[3]
    constants[137] = 4.00000*constants[52]
    constants[138] = 3.00000*constants[52]
    constants[139] = 2.00000*constants[52]
    constants[140] = 1.00000*constants[52]
    constants[141] = 4.00000*constants[51]*constants[3]
    constants[142] = 3.00000*constants[51]*constants[3]
    constants[143] = 2.00000*constants[51]*constants[3]
    constants[144] = 1.00000*constants[51]*constants[3]
    constants[145] = 4.00000*constants[53]
    constants[146] = 3.00000*constants[53]
    constants[147] = 2.00000*constants[53]
    constants[148] = 1.00000*constants[53]
    constants[149] = ((constants[109]*constants[8])/(constants[111]*constants[110]))*log(constants[57]/constants[5])
    constants[150] = ((constants[94]*constants[8])/(constants[96]*constants[95]))*log(constants[13]/constants[3])
    constants[151] = ((constants[99]*constants[8])/(constants[101]*constants[100]))*log(constants[35]/constants[4])
    constants[152] = power(constants[56], (constants[8]-constants[55])/10.0000)
    constants[153] = ((constants[114]*constants[8])/(constants[116]*constants[115]))*log(constants[57]/constants[5])
    constants[154] = ((constants[119]*constants[8])/(constants[121]*constants[120]))*log(constants[35]/constants[4])
    states[0] = constants[27]
    states[1] = constants[50]
    states[2] = constants[63]
    states[3] = constants[29]
    states[4] = constants[30]
    states[5] = constants[36]
    states[6] = constants[37]
    states[7] = constants[14]
    states[8] = constants[15]
    states[9] = constants[16]
    states[10] = constants[17]
    states[11] = constants[18]
    states[12] = constants[19]
    states[13] = constants[20]
    states[14] = constants[21]
    states[15] = constants[22]
    states[16] = constants[23]
    states[17] = constants[24]
    states[18] = constants[25]
    states[19] = constants[25]
    states[20] = constants[41]
    states[21] = constants[42]
    states[22] = constants[43]
    states[23] = constants[44]
    states[24] = constants[45]
    states[25] = constants[46]
    states[26] = constants[47]
    states[27] = constants[48]
    states[28] = constants[49]
    states[29] = constants[58]
    states[30] = constants[59]
    states[31] = constants[60]
    states[32] = constants[61]
    states[33] = constants[62]
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[0] = custom_piecewise([less(voi , constants[0]), constants[1] , True, constants[2]])
    algebraic[3] = 1.00000/(1.00000+exp(-(algebraic[0]+60.5000)/5.30000))
    rates[3] = ((algebraic[3]-states[3])/constants[31])*constants[128]
    algebraic[5] = 1.00000/(1.00000+exp(-(algebraic[0]+43.0000)/17.3600))
    rates[5] = ((algebraic[5]-states[5])/constants[38])*constants[130]
    algebraic[6] = 1.00000/(1.00000+exp((algebraic[0]-44.9000)/12.0096))
    rates[6] = ((algebraic[6]-states[6])/constants[39])*constants[131]
    algebraic[4] = 1.00000/(1.00000+exp((algebraic[0]+75.5000)/4.00000))
    algebraic[11] = 0.381170*(8.60000+14.7000*exp(-(power(algebraic[0]+50.0000, 2.00000))/(900.000*1.00000)))
    rates[4] = ((algebraic[4]-states[4])/algebraic[11])*constants[129]
    algebraic[54] = states[20]+states[21]+states[22]+states[23]+states[24]+states[25]+states[26]+states[27]+states[28]+states[1]
    algebraic[7] = 1.00000*exp((8.47188*algebraic[0])/(1.00000*constants[8]))
    algebraic[33] = 0.0443240*algebraic[7]
    algebraic[12] = 1.00000*exp((-7.77556*algebraic[0])/(1.00000*constants[8]))
    algebraic[51] = 0.000106000*algebraic[12]
    rates[24] = (-(constants[137]+algebraic[33])*states[24])/algebraic[54]+(constants[136]*states[23])/algebraic[54]+(algebraic[51]*states[1])/algebraic[54]
    algebraic[28] = 0.000781000*algebraic[7]
    algebraic[47] = 0.0953120*algebraic[12]
    rates[23] = (-(constants[138]+algebraic[28]+constants[136])*states[23])/algebraic[54]+(constants[135]*states[22])/algebraic[54]+(algebraic[47]*states[28])/algebraic[54]+(constants[137]*states[24])/algebraic[54]
    algebraic[24] = 2.81000e-05*algebraic[7]
    algebraic[43] = 32.6594*algebraic[12]
    rates[22] = (-(constants[139]+algebraic[24]+constants[135])*states[22])/algebraic[54]+(constants[134]*states[21])/algebraic[54]+(algebraic[43]*states[27])/algebraic[54]+(constants[138]*states[23])/algebraic[54]
    algebraic[20] = 0.000869000*algebraic[7]
    algebraic[39] = 144.174*algebraic[12]
    rates[21] = (-(constants[140]+algebraic[20]+constants[134])*states[21])/algebraic[54]+(constants[133]*states[20])/algebraic[54]+(algebraic[39]*states[26])/algebraic[54]+(constants[139]*states[22])/algebraic[54]
    algebraic[16] = 0.0216200*algebraic[7]
    algebraic[35] = 318.108*algebraic[12]
    rates[20] = (-(constants[133]+algebraic[16])*states[20])/algebraic[54]+(constants[140]*states[21])/algebraic[54]+(algebraic[35]*states[25])/algebraic[54]
    rates[1] = (-(constants[145]+algebraic[51])*states[1])/algebraic[54]+(constants[144]*states[28])/algebraic[54]+(algebraic[33]*states[24])/algebraic[54]
    rates[28] = (-(constants[146]+algebraic[47]+constants[144])*states[28])/algebraic[54]+(constants[143]*states[27])/algebraic[54]+(algebraic[28]*states[23])/algebraic[54]+(constants[145]*states[1])/algebraic[54]
    rates[27] = (-(constants[147]+algebraic[43]+constants[143])*states[27])/algebraic[54]+(constants[142]*states[26])/algebraic[54]+(algebraic[24]*states[22])/algebraic[54]+(constants[146]*states[28])/algebraic[54]
    rates[26] = (-(constants[148]+algebraic[39]+constants[142])*states[26])/algebraic[54]+(constants[141]*states[25])/algebraic[54]+(algebraic[20]*states[21])/algebraic[54]+(constants[147]*states[27])/algebraic[54]
    rates[25] = (-(constants[141]+algebraic[35])*states[25])/algebraic[54]+(constants[148]*states[26])/algebraic[54]+(algebraic[16]*states[20])/algebraic[54]
    algebraic[55] = states[2]+states[29]+states[30]+states[31]+states[32]+states[33]
    algebraic[25] = constants[152]*0.554320*exp(-0.0990740+0.0364410*algebraic[0])
    algebraic[29] = constants[152]*0.000525480*exp(-0.0691020+0.00319450*algebraic[0])
    rates[31] = (-algebraic[29]*states[31])/algebraic[55]+(algebraic[25]*states[30])/algebraic[55]
    algebraic[21] = constants[152]*3.15660*exp(0.363520+0.0771930*algebraic[0])
    algebraic[31] = constants[152]*1.44960*exp(-0.156600+0.0583530*algebraic[0])
    rates[30] = (-(algebraic[31]+algebraic[25])*states[30])/algebraic[55]+(algebraic[21]*states[29])/algebraic[55]+(algebraic[29]*states[31])/algebraic[55]
    algebraic[17] = constants[152]*2.39100*exp(-13.3350-0.252890*algebraic[0])
    algebraic[36] = constants[152]*1.53290*exp(0.00931930+0.0410750*algebraic[0])
    algebraic[48] = constants[152]*1.90460*exp(-2.48400+0.0204060*algebraic[0])
    algebraic[52] = constants[152]*0.000216880*exp(-0.0634380+0.00466830*algebraic[0])
    rates[29] = (-(algebraic[21]+algebraic[36]+algebraic[52])*states[29])/algebraic[55]+(algebraic[17]*states[2])/algebraic[55]+(algebraic[31]*states[30])/algebraic[55]+(algebraic[48]*states[32])/algebraic[55]
    algebraic[13] = constants[152]*0.120520*exp(-9.60280+0.0830250*algebraic[0])
    algebraic[40] = constants[152]*1.61640*exp(0.307630+0.00605350*algebraic[0])
    rates[2] = (-(algebraic[17]+algebraic[40])*states[2])/algebraic[55]+(algebraic[36]*states[29])/algebraic[55]+(algebraic[13]*states[32])/algebraic[55]
    algebraic[8] = constants[152]*0.00392390*exp(2.67930+0.00614680*algebraic[0])
    algebraic[44] = constants[152]*0.0277350*exp(0.0514900-0.0468650*algebraic[0])
    rates[33] = (-algebraic[8]*states[33])/algebraic[55]+(algebraic[44]*states[32])/algebraic[55]
    rates[32] = (-(algebraic[13]+algebraic[44]+algebraic[48])*states[32])/algebraic[55]+(algebraic[8]*states[33])/algebraic[55]+(algebraic[52]*states[29])/algebraic[55]+(algebraic[40]*states[2])/algebraic[55]
    algebraic[2] = constants[124]*0.731000*exp(algebraic[0]/30.0000)
    algebraic[23] = 2.00000*algebraic[2]
    algebraic[27] = 1.00000*algebraic[2]
    algebraic[10] = constants[124]*0.214900*exp(-algebraic[0]/40.0000)
    algebraic[41] = 3.00000*algebraic[10]
    algebraic[45] = 4.00000*algebraic[10]
    algebraic[53] = constants[124]*0.00595600*exp(-algebraic[0]/40.0000)
    algebraic[49] = constants[124]*0.474200*exp(algebraic[0]/10.0000)
    algebraic[59] = constants[124]*0.00232000*exp(-algebraic[0]/280.000)
    algebraic[57] = constants[124]*0.0121300*exp(algebraic[0]/500.000)
    algebraic[61] = (algebraic[45]*algebraic[57]*algebraic[53])/(algebraic[27]*algebraic[59])
    algebraic[58] = constants[124]*0.0219700*exp(algebraic[0]/500.000)
    algebraic[56] = constants[124]*0.0140700*exp(-algebraic[0]/300.000)
    algebraic[60] = (algebraic[45]*algebraic[56]*algebraic[49])/(algebraic[27]*algebraic[58])
    algebraic[64] = states[10]+states[9]+states[8]+states[7]+states[14]+states[13]+states[12]+states[11]+states[0]+states[15]+states[16]+states[17]+states[19]+states[18]
    rates[10] = ((algebraic[23]*states[9])/algebraic[64]-((algebraic[27]+algebraic[41]+algebraic[53]+algebraic[49]+constants[127])*states[10])/algebraic[64])+(algebraic[45]*states[0])/algebraic[64]+(algebraic[60]*states[17])/algebraic[64]+(algebraic[61]*states[16])/algebraic[64]+(constants[126]*states[14])/algebraic[64]
    algebraic[19] = 3.00000*algebraic[2]
    algebraic[37] = 2.00000*algebraic[10]
    rates[9] = ((algebraic[19]*states[8])/algebraic[64]-((algebraic[23]+algebraic[37]+constants[127])*states[9])/algebraic[64])+(algebraic[41]*states[10])/algebraic[64]+(constants[126]*states[13])/algebraic[64]
    algebraic[15] = 4.00000*algebraic[2]
    algebraic[32] = 1.00000*algebraic[10]
    rates[8] = ((algebraic[15]*states[7])/algebraic[64]-((algebraic[19]+algebraic[32]+constants[127])*states[8])/algebraic[64])+(algebraic[37]*states[9])/algebraic[64]+(constants[126]*states[12])/algebraic[64]
    rates[7] = (-(algebraic[15]+constants[127])*states[7])/algebraic[64]+(algebraic[32]*states[8])/algebraic[64]+(constants[126]*states[11])/algebraic[64]
    rates[14] = (((constants[127]*states[10])/algebraic[64]+(algebraic[23]*states[13])/algebraic[64])-((algebraic[27]+algebraic[41]+algebraic[49]+algebraic[53]+constants[126])*states[14])/algebraic[64])+(algebraic[45]*states[15])/algebraic[64]+(algebraic[60]*states[18])/algebraic[64]+(algebraic[61]*states[19])/algebraic[64]
    rates[13] = (((constants[127]*states[9])/algebraic[64]+(algebraic[19]*states[12])/algebraic[64])-((algebraic[23]+algebraic[37]+constants[126])*states[13])/algebraic[64])+(algebraic[41]*states[14])/algebraic[64]
    rates[12] = (((constants[127]*states[8])/algebraic[64]+(algebraic[15]*states[11])/algebraic[64])-((algebraic[19]+algebraic[32]+constants[126])*states[12])/algebraic[64])+(algebraic[37]*states[13])/algebraic[64]
    rates[11] = ((constants[127]*states[7])/algebraic[64]-((algebraic[15]+constants[126])*states[11])/algebraic[64])+(algebraic[32]*states[12])/algebraic[64]
    rates[0] = ((algebraic[27]*states[10])/algebraic[64]-((algebraic[45]+algebraic[58]+algebraic[59]+constants[127])*states[0])/algebraic[64])+(algebraic[56]*states[17])/algebraic[64]+(algebraic[57]*states[16])/algebraic[64]+(constants[126]*states[15])/algebraic[64]
    rates[15] = (((constants[127]*states[0])/algebraic[64]+(algebraic[27]*states[14])/algebraic[64])-((algebraic[45]+algebraic[58]+algebraic[59]+constants[126])*states[15])/algebraic[64])+(algebraic[56]*states[18])/algebraic[64]+(algebraic[57]*states[19])/algebraic[64]
    algebraic[63] = algebraic[59]
    algebraic[62] = (algebraic[57]*algebraic[58])/algebraic[56]
    rates[16] = (((algebraic[53]*states[10])/algebraic[64]+(algebraic[59]*states[0])/algebraic[64]+(algebraic[63]*states[17])/algebraic[64])-((algebraic[61]+algebraic[57]+algebraic[62]+constants[127])*states[16])/algebraic[64])+(constants[126]*states[19])/algebraic[64]
    rates[17] = (((algebraic[49]*states[10])/algebraic[64]+(algebraic[58]*states[0])/algebraic[64])-((algebraic[60]+algebraic[56]+algebraic[63]+constants[127])*states[17])/algebraic[64])+(algebraic[62]*states[16])/algebraic[64]+(constants[126]*states[18])/algebraic[64]
    rates[19] = ((constants[127]*states[16])/algebraic[64]+(algebraic[53]*states[14])/algebraic[64]+(algebraic[59]*states[15])/algebraic[64]+(algebraic[63]*states[18])/algebraic[64])-((algebraic[61]+algebraic[57]+algebraic[62]+constants[126])*states[19])/algebraic[64]
    rates[18] = (((constants[127]*states[17])/algebraic[64]+(algebraic[49]*states[14])/algebraic[64]+(algebraic[58]*states[15])/algebraic[64])-((algebraic[60]+algebraic[56]+algebraic[63]+constants[126])*states[18])/algebraic[64])+(algebraic[62]*states[19])/algebraic[64]
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[0] = custom_piecewise([less(voi , constants[0]), constants[1] , True, constants[2]])
    algebraic[3] = 1.00000/(1.00000+exp(-(algebraic[0]+60.5000)/5.30000))
    algebraic[5] = 1.00000/(1.00000+exp(-(algebraic[0]+43.0000)/17.3600))
    algebraic[6] = 1.00000/(1.00000+exp((algebraic[0]-44.9000)/12.0096))
    algebraic[4] = 1.00000/(1.00000+exp((algebraic[0]+75.5000)/4.00000))
    algebraic[11] = 0.381170*(8.60000+14.7000*exp(-(power(algebraic[0]+50.0000, 2.00000))/(900.000*1.00000)))
    algebraic[54] = states[20]+states[21]+states[22]+states[23]+states[24]+states[25]+states[26]+states[27]+states[28]+states[1]
    algebraic[7] = 1.00000*exp((8.47188*algebraic[0])/(1.00000*constants[8]))
    algebraic[33] = 0.0443240*algebraic[7]
    algebraic[12] = 1.00000*exp((-7.77556*algebraic[0])/(1.00000*constants[8]))
    algebraic[51] = 0.000106000*algebraic[12]
    algebraic[28] = 0.000781000*algebraic[7]
    algebraic[47] = 0.0953120*algebraic[12]
    algebraic[24] = 2.81000e-05*algebraic[7]
    algebraic[43] = 32.6594*algebraic[12]
    algebraic[20] = 0.000869000*algebraic[7]
    algebraic[39] = 144.174*algebraic[12]
    algebraic[16] = 0.0216200*algebraic[7]
    algebraic[35] = 318.108*algebraic[12]
    algebraic[55] = states[2]+states[29]+states[30]+states[31]+states[32]+states[33]
    algebraic[25] = constants[152]*0.554320*exp(-0.0990740+0.0364410*algebraic[0])
    algebraic[29] = constants[152]*0.000525480*exp(-0.0691020+0.00319450*algebraic[0])
    algebraic[21] = constants[152]*3.15660*exp(0.363520+0.0771930*algebraic[0])
    algebraic[31] = constants[152]*1.44960*exp(-0.156600+0.0583530*algebraic[0])
    algebraic[17] = constants[152]*2.39100*exp(-13.3350-0.252890*algebraic[0])
    algebraic[36] = constants[152]*1.53290*exp(0.00931930+0.0410750*algebraic[0])
    algebraic[48] = constants[152]*1.90460*exp(-2.48400+0.0204060*algebraic[0])
    algebraic[52] = constants[152]*0.000216880*exp(-0.0634380+0.00466830*algebraic[0])
    algebraic[13] = constants[152]*0.120520*exp(-9.60280+0.0830250*algebraic[0])
    algebraic[40] = constants[152]*1.61640*exp(0.307630+0.00605350*algebraic[0])
    algebraic[8] = constants[152]*0.00392390*exp(2.67930+0.00614680*algebraic[0])
    algebraic[44] = constants[152]*0.0277350*exp(0.0514900-0.0468650*algebraic[0])
    algebraic[2] = constants[124]*0.731000*exp(algebraic[0]/30.0000)
    algebraic[23] = 2.00000*algebraic[2]
    algebraic[27] = 1.00000*algebraic[2]
    algebraic[10] = constants[124]*0.214900*exp(-algebraic[0]/40.0000)
    algebraic[41] = 3.00000*algebraic[10]
    algebraic[45] = 4.00000*algebraic[10]
    algebraic[53] = constants[124]*0.00595600*exp(-algebraic[0]/40.0000)
    algebraic[49] = constants[124]*0.474200*exp(algebraic[0]/10.0000)
    algebraic[59] = constants[124]*0.00232000*exp(-algebraic[0]/280.000)
    algebraic[57] = constants[124]*0.0121300*exp(algebraic[0]/500.000)
    algebraic[61] = (algebraic[45]*algebraic[57]*algebraic[53])/(algebraic[27]*algebraic[59])
    algebraic[58] = constants[124]*0.0219700*exp(algebraic[0]/500.000)
    algebraic[56] = constants[124]*0.0140700*exp(-algebraic[0]/300.000)
    algebraic[60] = (algebraic[45]*algebraic[56]*algebraic[49])/(algebraic[27]*algebraic[58])
    algebraic[64] = states[10]+states[9]+states[8]+states[7]+states[14]+states[13]+states[12]+states[11]+states[0]+states[15]+states[16]+states[17]+states[19]+states[18]
    algebraic[19] = 3.00000*algebraic[2]
    algebraic[37] = 2.00000*algebraic[10]
    algebraic[15] = 4.00000*algebraic[2]
    algebraic[32] = 1.00000*algebraic[10]
    algebraic[63] = algebraic[59]
    algebraic[62] = (algebraic[57]*algebraic[58])/algebraic[56]
    algebraic[1] = states[3]*states[4]
    algebraic[9] = states[5]*states[6]
    algebraic[14] = (constants[68]*(exp((constants[67]*algebraic[0]*constants[9])/(constants[7]*constants[8]))*(power(constants[5], 3.00000))*constants[13]-2.50000*exp(((constants[67]-1.00000)*algebraic[0]*constants[9])/(constants[7]*constants[8]))*(power(constants[57], 3.00000))*constants[3]))/((power(constants[65], 3.00000)+power(constants[57], 3.00000))*(constants[64]+constants[13])*(1.00000+constants[66]*exp(((constants[67]-1.00000)*algebraic[0]*constants[9])/(constants[7]*constants[8]))))
    algebraic[18] = (constants[71]*constants[35]*constants[5])/((constants[35]+constants[69])*(constants[70]+constants[5])*(1.00000+0.124500*exp((-0.100000*algebraic[0]*constants[9])/(constants[7]*constants[8]))+0.0353000*exp((-algebraic[0]*constants[9])/(constants[7]*constants[8]))))
    algebraic[22] = constants[6]*states[0]*(algebraic[0]-constants[125])
    algebraic[26] = constants[28]*algebraic[1]*(algebraic[0]-constants[150])
    algebraic[30] = constants[32]*algebraic[9]*(algebraic[0]-constants[151])
    algebraic[34] = constants[40]*states[1]*(algebraic[0]-constants[132])
    algebraic[38] = constants[54]*states[2]*(algebraic[0]-constants[149])
    algebraic[42] = constants[72]*constants[87]*(algebraic[0]-constants[153])
    algebraic[46] = constants[73]*constants[88]*(algebraic[0]-constants[154])
    algebraic[50] = algebraic[22]+algebraic[26]+algebraic[30]+algebraic[34]+algebraic[38]+algebraic[14]+algebraic[18]+algebraic[42]+algebraic[46]
    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)