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 = 115
sizeStates = 30
sizeConstants = 83
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_algebraic[0] = "i_stim in component membrane (microA_per_microF)"
    legend_algebraic[92] = "i_tot in component membrane (microA_per_microF)"
    legend_algebraic[57] = "i_Na in component i_Na (microA_per_microF)"
    legend_algebraic[58] = "i_Na_L in component i_Na_L (microA_per_microF)"
    legend_algebraic[60] = "i_Ca_L in component i_Ca_L (microA_per_microF)"
    legend_algebraic[64] = "i_Ca_T in component i_Ca_T (microA_per_microF)"
    legend_algebraic[67] = "i_to_1 in component i_to_1 (microA_per_microF)"
    legend_algebraic[79] = "i_to_2 in component i_to_2 (microA_per_microF)"
    legend_algebraic[69] = "i_Kr in component i_Kr (microA_per_microF)"
    legend_algebraic[71] = "i_Ks in component i_Ks (microA_per_microF)"
    legend_algebraic[75] = "i_K1 in component i_K1 (microA_per_microF)"
    legend_algebraic[82] = "i_NaCa in component i_NaCa (microA_per_microF)"
    legend_algebraic[84] = "i_NaK in component i_NaK (microA_per_microF)"
    legend_algebraic[88] = "i_Na_b in component background_currents (microA_per_microF)"
    legend_algebraic[91] = "i_Ca_b in component background_currents (microA_per_microF)"
    legend_algebraic[89] = "i_K_b in component background_currents (microA_per_microF)"
    legend_algebraic[90] = "i_Cl_b in component background_currents (microA_per_microF)"
    legend_algebraic[85] = "i_Ca_p in component i_Ca_p (microA_per_microF)"
    legend_algebraic[77] = "i_K_p in component i_K_p (microA_per_microF)"
    legend_constants[0] = "stim_start in component membrane (millisecond)"
    legend_constants[1] = "stim_end in component membrane (millisecond)"
    legend_constants[2] = "stim_amplitude in component membrane (microA_per_microF)"
    legend_algebraic[19] = "E_Na in component equilibrium_potentials (millivolt)"
    legend_algebraic[36] = "E_K in component equilibrium_potentials (millivolt)"
    legend_algebraic[1] = "E_Ca in component equilibrium_potentials (millivolt)"
    legend_algebraic[46] = "E_Cl in component equilibrium_potentials (millivolt)"
    legend_algebraic[56] = "E_Ks in component equilibrium_potentials (millivolt)"
    legend_constants[3] = "r_NaK in component equilibrium_potentials (dimensionless)"
    legend_states[1] = "Na_i in component intracellular_ion_concentrations (millimolar)"
    legend_constants[4] = "Na_o in component model_parameters (millimolar)"
    legend_states[2] = "Ca_i in component Ca_i (millimolar)"
    legend_constants[5] = "Ca_o in component model_parameters (millimolar)"
    legend_states[3] = "K_i in component intracellular_ion_concentrations (millimolar)"
    legend_constants[6] = "K_o in component model_parameters (millimolar)"
    legend_states[4] = "Cl_i in component intracellular_ion_concentrations (millimolar)"
    legend_constants[7] = "Cl_o in component model_parameters (millimolar)"
    legend_constants[8] = "R in component model_parameters (joule_per_kilomole_kelvin)"
    legend_constants[9] = "F in component model_parameters (coulomb_per_mole)"
    legend_constants[10] = "T in component model_parameters (kelvin)"
    legend_constants[11] = "g_Na in component i_Na (milliS_per_microF)"
    legend_states[5] = "m in component i_Na_m_gate (dimensionless)"
    legend_states[6] = "h in component i_Na_h_gate (dimensionless)"
    legend_states[7] = "j in component i_Na_j_gate (dimensionless)"
    legend_algebraic[47] = "tau_m in component i_Na_m_gate (millisecond)"
    legend_algebraic[37] = "m_infinity in component i_Na_m_gate (dimensionless)"
    legend_algebraic[2] = "alpha_m in component i_Na_m_gate (per_millisecond)"
    legend_algebraic[20] = "beta_m in component i_Na_m_gate (per_millisecond)"
    legend_algebraic[48] = "tau_h in component i_Na_h_gate (millisecond)"
    legend_algebraic[38] = "h_infinity in component i_Na_h_gate (dimensionless)"
    legend_algebraic[3] = "alpha_h in component i_Na_h_gate (per_millisecond)"
    legend_algebraic[21] = "beta_h in component i_Na_h_gate (per_millisecond)"
    legend_algebraic[49] = "tau_j in component i_Na_j_gate (millisecond)"
    legend_algebraic[39] = "j_infinity in component i_Na_j_gate (dimensionless)"
    legend_algebraic[4] = "alpha_j in component i_Na_j_gate (per_millisecond)"
    legend_algebraic[22] = "beta_j in component i_Na_j_gate (per_millisecond)"
    legend_constants[12] = "g_Na_L in component i_Na_L (milliS_per_microF)"
    legend_states[8] = "m_L in component i_Na_L_m_L_gate (dimensionless)"
    legend_states[9] = "h_L in component i_Na_L_h_L_gate (dimensionless)"
    legend_algebraic[50] = "tau_m_L in component i_Na_L_m_L_gate (millisecond)"
    legend_algebraic[40] = "m_L_infinity in component i_Na_L_m_L_gate (dimensionless)"
    legend_algebraic[5] = "alpha_m_L in component i_Na_L_m_L_gate (per_millisecond)"
    legend_algebraic[23] = "beta_m_L in component i_Na_L_m_L_gate (per_millisecond)"
    legend_algebraic[24] = "tau_h_L in component i_Na_L_h_L_gate (millisecond)"
    legend_algebraic[6] = "h_L_infinity in component i_Na_L_h_L_gate (dimensionless)"
    legend_constants[13] = "g_Ca_L in component i_Ca_L (dimensionless)"
    legend_algebraic[59] = "i_Ca_L_max in component i_Ca_L (microA_per_microF)"
    legend_constants[14] = "p_Ca in component i_Ca_L (cm_per_second)"
    legend_constants[15] = "z_Ca in component model_parameters (dimensionless)"
    legend_constants[16] = "gamma_Cai in component model_parameters (dimensionless)"
    legend_constants[17] = "gamma_Cao in component model_parameters (dimensionless)"
    legend_states[10] = "Ca_r in component Ca_r (millimolar)"
    legend_algebraic[97] = "Ca_MK_act in component Ca_MK_act (dimensionless)"
    legend_constants[18] = "km_Ca_MK in component Ca_MK_act (millimolar)"
    legend_states[11] = "d in component i_Ca_L_d_gate (dimensionless)"
    legend_states[12] = "f in component i_Ca_L_f_gate (dimensionless)"
    legend_states[13] = "f2 in component i_Ca_L_f2_gate (dimensionless)"
    legend_states[14] = "f_Ca in component i_Ca_L_f_Ca_gate (dimensionless)"
    legend_states[15] = "f_Ca2 in component i_Ca_L_f_Ca2_gate (dimensionless)"
    legend_constants[19] = "Cm in component model_parameters (microF_per_cm2)"
    legend_algebraic[7] = "d_infinity in component i_Ca_L_d_gate (dimensionless)"
    legend_algebraic[25] = "tau_d in component i_Ca_L_d_gate (millisecond)"
    legend_algebraic[8] = "f_infinity in component i_Ca_L_f_gate (dimensionless)"
    legend_algebraic[26] = "tau_f in component i_Ca_L_f_gate (millisecond)"
    legend_algebraic[9] = "f2_infinity in component i_Ca_L_f2_gate (dimensionless)"
    legend_algebraic[27] = "tau_f2 in component i_Ca_L_f2_gate (millisecond)"
    legend_algebraic[61] = "f_Ca_infinity in component i_Ca_L_f_Ca_gate (dimensionless)"
    legend_algebraic[98] = "tau_f_Ca in component i_Ca_L_f_Ca_gate (millisecond)"
    legend_algebraic[62] = "f_Ca2_infinity in component i_Ca_L_f_Ca2_gate (dimensionless)"
    legend_algebraic[65] = "tau_f_Ca2 in component i_Ca_L_f_Ca2_gate (millisecond)"
    legend_constants[20] = "g_Ca_T in component i_Ca_T (milliS_per_microF)"
    legend_states[16] = "b in component i_Ca_T_b_gate (dimensionless)"
    legend_states[17] = "g in component i_Ca_T_g_gate (dimensionless)"
    legend_algebraic[51] = "tau_b in component i_Ca_T_b_gate (millisecond)"
    legend_algebraic[41] = "b_infinity in component i_Ca_T_b_gate (dimensionless)"
    legend_algebraic[10] = "alpha_b in component i_Ca_T_b_gate (per_millisecond)"
    legend_algebraic[28] = "beta_b in component i_Ca_T_b_gate (per_millisecond)"
    legend_algebraic[52] = "tau_g in component i_Ca_T_g_gate (millisecond)"
    legend_algebraic[42] = "g_infinity in component i_Ca_T_g_gate (dimensionless)"
    legend_algebraic[11] = "alpha_g in component i_Ca_T_g_gate (per_millisecond)"
    legend_algebraic[29] = "beta_g in component i_Ca_T_g_gate (per_millisecond)"
    legend_constants[21] = "g_to_1 in component i_to_1 (milliS_per_microF)"
    legend_states[18] = "a in component i_to_1_a_gate (dimensionless)"
    legend_states[19] = "i in component i_to_1_i_gate (dimensionless)"
    legend_states[20] = "i2 in component i_to_1_i2_gate (dimensionless)"
    legend_algebraic[12] = "alpha_a in component i_to_1_a_gate (per_millisecond)"
    legend_algebraic[30] = "beta_a in component i_to_1_a_gate (per_millisecond)"
    legend_algebraic[43] = "tau_a in component i_to_1_a_gate (millisecond)"
    legend_algebraic[53] = "a_infinity in component i_to_1_a_gate (dimensionless)"
    legend_algebraic[13] = "alpha_i in component i_to_1_i_gate (per_millisecond)"
    legend_algebraic[31] = "beta_i in component i_to_1_i_gate (per_millisecond)"
    legend_algebraic[44] = "tau_i in component i_to_1_i_gate (millisecond)"
    legend_algebraic[54] = "i_infinity in component i_to_1_i_gate (dimensionless)"
    legend_algebraic[14] = "alpha_i2 in component i_to_1_i2_gate (per_millisecond)"
    legend_algebraic[32] = "beta_i2 in component i_to_1_i2_gate (per_millisecond)"
    legend_algebraic[45] = "tau_i2 in component i_to_1_i2_gate (millisecond)"
    legend_algebraic[55] = "i2_infinity in component i_to_1_i2_gate (dimensionless)"
    legend_constants[74] = "g_Kr in component i_Kr (milliS_per_microF)"
    legend_algebraic[68] = "rr_infinity in component i_Kr (dimensionless)"
    legend_states[21] = "xr in component i_Kr_xr_gate (dimensionless)"
    legend_algebraic[15] = "tau_xr in component i_Kr_xr_gate (millisecond)"
    legend_algebraic[33] = "xr_infinity in component i_Kr_xr_gate (dimensionless)"
    legend_algebraic[70] = "g_Ks in component i_Ks (milliS_per_microF)"
    legend_states[22] = "xs1 in component i_Ks_xs1_gate (dimensionless)"
    legend_states[23] = "xs2 in component i_Ks_xs2_gate (dimensionless)"
    legend_algebraic[16] = "tau_xs1 in component i_Ks_xs1_gate (millisecond)"
    legend_algebraic[34] = "xs1_infinity in component i_Ks_xs1_gate (dimensionless)"
    legend_algebraic[17] = "tau_xs2 in component i_Ks_xs2_gate (millisecond)"
    legend_algebraic[35] = "xs2_infinity in component i_Ks_xs2_gate (dimensionless)"
    legend_constants[75] = "g_K1 in component i_K1 (milliS_per_microF)"
    legend_algebraic[74] = "xK1 in component i_K1_xK1_gate (dimensionless)"
    legend_algebraic[73] = "alpha_xK1 in component i_K1_xK1_gate (dimensionless)"
    legend_algebraic[72] = "beta_xK1 in component i_K1_xK1_gate (dimensionless)"
    legend_constants[22] = "g_K_p in component i_K_p (milliS_per_microF)"
    legend_algebraic[76] = "kp in component i_K_p (dimensionless)"
    legend_constants[23] = "p_Cl in component i_to_2 (cm_per_second)"
    legend_constants[24] = "z_Cl in component i_to_2 (dimensionless)"
    legend_algebraic[78] = "i_to_2_max in component i_to_2 (microA_per_microF)"
    legend_states[24] = "a in component i_to_2_a_gate (dimensionless)"
    legend_algebraic[18] = "a_infinity in component i_to_2_a_gate (dimensionless)"
    legend_constants[76] = "tau_a in component i_to_2_a_gate (millisecond)"
    legend_constants[25] = "km_to_2 in component i_to_2_a_gate (millimolar)"
    legend_constants[26] = "X_NaCa in component i_NaCa (dimensionless)"
    legend_constants[27] = "i_NaCa_max in component i_NaCa (microA_per_microF)"
    legend_constants[28] = "km_Na_i_1 in component i_NaCa (millimolar)"
    legend_constants[29] = "km_Na_o in component i_NaCa (millimolar)"
    legend_constants[30] = "km_Ca_i in component i_NaCa (millimolar)"
    legend_constants[31] = "km_Ca_o in component i_NaCa (millimolar)"
    legend_constants[32] = "km_Ca_act in component i_NaCa (millimolar)"
    legend_constants[33] = "k_sat in component i_NaCa (dimensionless)"
    legend_algebraic[80] = "dNaCa_1 in component i_NaCa (millimolar4)"
    legend_algebraic[81] = "dNaCa_2 in component i_NaCa (millimolar4)"
    legend_constants[34] = "g_NaK in component i_NaK (microA_per_microF)"
    legend_constants[35] = "km_Na_i_2 in component i_NaK (millimolar)"
    legend_constants[36] = "km_K_o in component i_NaK (millimolar)"
    legend_algebraic[83] = "f_NaK in component i_NaK (dimensionless)"
    legend_constants[77] = "sigma in component i_NaK (dimensionless)"
    legend_constants[37] = "i_Ca_p_max in component i_Ca_p (microA_per_microF)"
    legend_constants[38] = "km_Ca_p in component i_Ca_p (millimolar)"
    legend_algebraic[86] = "CT_K_Cl in component CT_K_Cl (millimolar_per_millisecond)"
    legend_constants[39] = "CT_K_Cl_max in component CT_K_Cl (millimolar_per_millisecond)"
    legend_algebraic[87] = "CT_Na_Cl in component CT_Na_Cl (millimolar_per_millisecond)"
    legend_constants[40] = "CT_Na_Cl_max in component CT_Na_Cl (millimolar_per_millisecond)"
    legend_constants[41] = "g_Na_b in component background_currents (milliS_per_microF)"
    legend_constants[42] = "g_K_b in component background_currents (milliS_per_microF)"
    legend_constants[43] = "p_Ca_b in component background_currents (cm_per_second)"
    legend_constants[44] = "g_Cl_b in component background_currents (milliS_per_microF)"
    legend_constants[79] = "Vol_myo in component model_parameters (microlitre)"
    legend_constants[78] = "a_cap in component model_parameters (cm2)"
    legend_constants[45] = "km_TRPN in component Ca_i (millimolar)"
    legend_constants[46] = "km_CMDN in component Ca_i (millimolar)"
    legend_constants[47] = "TRPN_max in component Ca_i (millimolar)"
    legend_constants[48] = "CMDN_max in component Ca_i (millimolar)"
    legend_algebraic[94] = "TRPN in component Ca_i (dimensionless)"
    legend_algebraic[93] = "CMDN in component Ca_i (dimensionless)"
    legend_algebraic[95] = "b_myo in component Ca_i (dimensionless)"
    legend_constants[80] = "Vol_nsr in component model_parameters (microlitre)"
    legend_constants[82] = "Vol_ss in component model_parameters (microlitre)"
    legend_algebraic[113] = "q_up in component q_up (millimolar_per_millisecond)"
    legend_algebraic[110] = "q_leak in component q_leak (millimolar_per_millisecond)"
    legend_algebraic[99] = "q_diff in component Ca_r (millimolar_per_millisecond)"
    legend_states[25] = "Ca_MK_trap in component Ca_MK_act (dimensionless)"
    legend_algebraic[96] = "Ca_MK_bound in component Ca_MK_act (dimensionless)"
    legend_constants[49] = "alpha_Ca_MK in component Ca_MK_act (per_millisecond)"
    legend_constants[50] = "beta_Ca_MK in component Ca_MK_act (per_millisecond)"
    legend_constants[51] = "Ca_MK_0 in component Ca_MK_act (dimensionless)"
    legend_states[26] = "Ca_NSR in component Ca_NSR (millimolar)"
    legend_constants[81] = "Vol_jsr in component model_parameters (microlitre)"
    legend_algebraic[114] = "q_tr in component q_tr (millimolar_per_millisecond)"
    legend_states[27] = "Ca_JSR in component Ca_JSR (millimolar)"
    legend_constants[52] = "CSQN_max in component Ca_JSR (millimolar)"
    legend_constants[53] = "km_CSQN in component Ca_JSR (millimolar)"
    legend_algebraic[109] = "q_rel in component q_rel (millimolar_per_millisecond)"
    legend_constants[54] = "km_b_SR in component Ca_r (millimolar)"
    legend_constants[55] = "km_b_SL in component Ca_r (millimolar)"
    legend_constants[56] = "b_SR_max in component Ca_r (millimolar)"
    legend_constants[57] = "b_SL_max in component Ca_r (millimolar)"
    legend_constants[58] = "tau_ss in component Ca_r (millisecond)"
    legend_algebraic[103] = "b_SR in component Ca_r (dimensionless)"
    legend_algebraic[101] = "b_SL in component Ca_r (dimensionless)"
    legend_algebraic[105] = "Ca_r_tot in component Ca_r (dimensionless)"
    legend_algebraic[108] = "g_rel in component q_rel (per_millisecond)"
    legend_algebraic[107] = "vg in component q_rel (dimensionless)"
    legend_states[28] = "ri in component q_rel_ri_gate (dimensionless)"
    legend_states[29] = "ro in component q_rel_ro_gate (dimensionless)"
    legend_algebraic[106] = "tau_ri in component q_rel_ri_gate (millisecond)"
    legend_algebraic[104] = "tau_Ca_MK in component q_rel_ri_gate (millisecond)"
    legend_constants[59] = "tau_Ca_MK_max in component q_rel_ri_gate (millisecond)"
    legend_algebraic[100] = "Ca_fac in component q_rel_ri_gate (millimolar)"
    legend_algebraic[102] = "ri_infinity in component q_rel_ri_gate (dimensionless)"
    legend_constants[60] = "tau_ro in component q_rel_ro_gate (millisecond)"
    legend_algebraic[66] = "ro_infinity in component q_rel_ro_gate (dimensionless)"
    legend_algebraic[63] = "ro_infinity_JSR in component q_rel_ro_gate (dimensionless)"
    legend_constants[61] = "q_leak_max in component q_leak (millimolar_per_millisecond)"
    legend_constants[62] = "NSR_max in component q_leak (millimolar)"
    legend_constants[63] = "X_q_up in component q_up (dimensionless)"
    legend_constants[64] = "q_up_max in component q_up (millimolar_per_millisecond)"
    legend_algebraic[111] = "dq_up_Ca_MK in component q_up (dimensionless)"
    legend_constants[65] = "dq_up_Ca_MK_max in component q_up (dimensionless)"
    legend_algebraic[112] = "dkm_plb in component q_up (millimolar)"
    legend_constants[66] = "dkm_plb_max in component q_up (millimolar)"
    legend_constants[67] = "km_up in component q_up (millimolar)"
    legend_constants[68] = "tau_tr in component q_tr (millisecond)"
    legend_constants[69] = "Vol_cell in component model_parameters (microlitre)"
    legend_constants[73] = "a_geo in component model_parameters (cm2)"
    legend_constants[70] = "radius in component model_parameters (cm)"
    legend_constants[71] = "length in component model_parameters (cm)"
    legend_constants[72] = "rcg in component model_parameters (dimensionless)"
    legend_rates[0] = "d/dt V in component membrane (millivolt)"
    legend_rates[5] = "d/dt m in component i_Na_m_gate (dimensionless)"
    legend_rates[6] = "d/dt h in component i_Na_h_gate (dimensionless)"
    legend_rates[7] = "d/dt j in component i_Na_j_gate (dimensionless)"
    legend_rates[8] = "d/dt m_L in component i_Na_L_m_L_gate (dimensionless)"
    legend_rates[9] = "d/dt h_L in component i_Na_L_h_L_gate (dimensionless)"
    legend_rates[11] = "d/dt d in component i_Ca_L_d_gate (dimensionless)"
    legend_rates[12] = "d/dt f in component i_Ca_L_f_gate (dimensionless)"
    legend_rates[13] = "d/dt f2 in component i_Ca_L_f2_gate (dimensionless)"
    legend_rates[14] = "d/dt f_Ca in component i_Ca_L_f_Ca_gate (dimensionless)"
    legend_rates[15] = "d/dt f_Ca2 in component i_Ca_L_f_Ca2_gate (dimensionless)"
    legend_rates[16] = "d/dt b in component i_Ca_T_b_gate (dimensionless)"
    legend_rates[17] = "d/dt g in component i_Ca_T_g_gate (dimensionless)"
    legend_rates[18] = "d/dt a in component i_to_1_a_gate (dimensionless)"
    legend_rates[19] = "d/dt i in component i_to_1_i_gate (dimensionless)"
    legend_rates[20] = "d/dt i2 in component i_to_1_i2_gate (dimensionless)"
    legend_rates[21] = "d/dt xr in component i_Kr_xr_gate (dimensionless)"
    legend_rates[22] = "d/dt xs1 in component i_Ks_xs1_gate (dimensionless)"
    legend_rates[23] = "d/dt xs2 in component i_Ks_xs2_gate (dimensionless)"
    legend_rates[24] = "d/dt a in component i_to_2_a_gate (dimensionless)"
    legend_rates[1] = "d/dt Na_i in component intracellular_ion_concentrations (millimolar)"
    legend_rates[3] = "d/dt K_i in component intracellular_ion_concentrations (millimolar)"
    legend_rates[4] = "d/dt Cl_i in component intracellular_ion_concentrations (millimolar)"
    legend_rates[2] = "d/dt Ca_i in component Ca_i (millimolar)"
    legend_rates[25] = "d/dt Ca_MK_trap in component Ca_MK_act (dimensionless)"
    legend_rates[26] = "d/dt Ca_NSR in component Ca_NSR (millimolar)"
    legend_rates[27] = "d/dt Ca_JSR in component Ca_JSR (millimolar)"
    legend_rates[10] = "d/dt Ca_r in component Ca_r (millimolar)"
    legend_rates[28] = "d/dt ri in component q_rel_ri_gate (dimensionless)"
    legend_rates[29] = "d/dt ro in component q_rel_ro_gate (dimensionless)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    states[0] = -83.43812846286808
    constants[0] = 0
    constants[1] = 1
    constants[2] = -80
    constants[3] = 0.01833
    states[1] = 9.927155552932733
    constants[4] = 140
    states[2] = 0.00022355433459434943
    constants[5] = 1.8
    states[3] = 141.9670801746057
    constants[6] = 5.4
    states[4] = 18.904682470140408
    constants[7] = 100
    constants[8] = 8314
    constants[9] = 96485
    constants[10] = 310
    constants[11] = 8
    states[5] = 0.002003390432234504
    states[6] = 0.9786390933308567
    states[7] = 0.09866447258167589
    constants[12] = 0.037375
    states[8] = 0.002003390432234504
    states[9] = 0.8946968372659203
    constants[13] = 0.3392328
    constants[14] = 0.000243
    constants[15] = 2
    constants[16] = 1
    constants[17] = 0.341
    states[10] = 0.00022418117117903934
    constants[18] = 0.15
    states[11] = 0.000002322223865147363
    states[12] = 0.9985607329462358
    states[13] = 0.8173435436674658
    states[14] = 0.9610551285529658
    states[15] = 0.868690796671854
    constants[19] = 1
    constants[20] = 0.13
    states[16] = 0.0002563937630984438
    states[17] = 0.9720432601848331
    constants[21] = 0.14135944
    states[18] = 0.0004238729429342389
    states[19] = 0.9990935802459496
    states[20] = 0.9777368439681764
    states[21] = 0.07084939408222911
    states[22] = 0.0011737654433043125
    states[23] = 0.001179442867470093
    constants[22] = 0.00276
    constants[23] = 0.0000004
    constants[24] = -1
    states[24] = 0.0014909437525000811
    constants[25] = 0.1502
    constants[26] = 0.4
    constants[27] = 4.5
    constants[28] = 12.3
    constants[29] = 87.5
    constants[30] = 0.0036
    constants[31] = 1.3
    constants[32] = 0.000125
    constants[33] = 0.27
    constants[34] = 0.61875
    constants[35] = 10
    constants[36] = 1.5
    constants[37] = 0.0575
    constants[38] = 0.0005
    constants[39] = 7.0756e-6
    constants[40] = 9.8443e-6
    constants[41] = 0.0025
    constants[42] = 0.005
    constants[43] = 1.995084e-7
    constants[44] = 0.000225
    constants[45] = 0.0005
    constants[46] = 0.00238
    constants[47] = 0.07
    constants[48] = 0.05
    states[25] = 0.000008789168284782809
    constants[49] = 0.05
    constants[50] = 0.00068
    constants[51] = 0.05
    states[26] = 1.2132524695849454
    states[27] = 1.1433050636518596
    constants[52] = 10
    constants[53] = 0.8
    constants[54] = 0.00087
    constants[55] = 0.0087
    constants[56] = 0.047
    constants[57] = 1.124
    constants[58] = 0.2
    states[28] = 0.7802870066567904
    states[29] = 1.2785734760674763e-9
    constants[59] = 10
    constants[60] = 3
    constants[61] = 0.004375
    constants[62] = 15
    constants[63] = 0.5
    constants[64] = 0.004375
    constants[65] = 0.75
    constants[66] = 0.00017
    constants[67] = 0.00092
    constants[68] = 120
    constants[69] = 0.3454
    constants[70] = 0.0011
    constants[71] = 0.01
    constants[72] = 2
    constants[73] = 2.00000*3.14000*(power(constants[70], 2.00000))+2.00000*3.14000*constants[70]*constants[71]
    constants[74] = 0.0400085*(power(constants[6]/5.40000, 1.0/2))
    constants[75] = 0.250000*(power(constants[6]/5.40000, 1.0/2))
    constants[76] = 1.00000
    constants[77] = (1.00000/7.00000)*(exp(constants[4]/67.3000)-1.00000)
    constants[78] = constants[72]*constants[73]
    constants[79] = constants[69]*0.680000
    constants[80] = constants[69]*0.0552000
    constants[81] = constants[69]*0.00480000
    constants[82] = constants[69]*0.0200000
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[18] = 1.00000/(1.00000+constants[25]/states[10])
    rates[24] = (algebraic[18]-states[24])/constants[76]
    algebraic[24] = 175.000+125.000/(1.00000+exp(-(states[0]+25.0000)/6.00000))
    algebraic[6] = 1.00000/(1.00000+exp((states[0]+69.0000)/6.10000))
    rates[9] = (algebraic[6]-states[9])/algebraic[24]
    algebraic[7] = 1.00000/(1.00000+exp(-(states[0]-4.00000)/6.74000))
    algebraic[25] = 0.590000+(0.800000*exp(0.0520000*(states[0]+13.0000)))/(1.00000+exp(0.132000*(states[0]+13.0000)))
    rates[11] = (algebraic[7]-states[11])/algebraic[25]
    algebraic[8] = 1.00000/(1.00000+exp((states[0]+18.0000)/10.0000))
    algebraic[26] = 4.00000+0.00500000*(power(states[0]-2.50000, 2.00000))
    rates[12] = (algebraic[8]-states[12])/algebraic[26]
    algebraic[9] = 1.00000/(1.00000+exp((states[0]+18.0000)/10.0000))
    algebraic[27] = 38.0000+0.0700000*(power(states[0]-18.6000, 2.00000))
    rates[13] = (algebraic[9]-states[13])/algebraic[27]
    algebraic[15] = 900.000/(1.00000+exp(states[0]/5.00000))+100.000
    algebraic[33] = 1.00000/(1.00000+exp(-(states[0]+0.0850000)/12.2500))
    rates[21] = (algebraic[33]-states[21])/algebraic[15]
    algebraic[16] = 1.00000/((7.61000e-05*(states[0]+44.6000))/(1.00000-exp(-9.97000*(states[0]+44.6000)))+(0.000360000*(states[0]-0.550000))/(exp(0.128000*(states[0]-0.550000))-1.00000))
    algebraic[34] = 1.00000/(1.00000+exp(-(states[0]-9.00000)/13.7000))
    rates[22] = (algebraic[34]-states[22])/algebraic[16]
    algebraic[17] = (2.00000*1.00000)/((7.61000e-05*(states[0]+44.6000))/(1.00000-exp(-9.97000*(states[0]+44.6000)))+(0.000360000*(states[0]-0.550000))/(exp(0.128000*(states[0]-0.550000))-1.00000))
    algebraic[35] = 1.00000/(1.00000+exp(-(states[0]-9.00000)/13.7000))
    rates[23] = (algebraic[35]-states[23])/algebraic[17]
    algebraic[2] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[20] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[47] = 1.00000/(algebraic[2]+algebraic[20])
    algebraic[37] = algebraic[2]/(algebraic[2]+algebraic[20])
    rates[5] = (algebraic[37]-states[5])/algebraic[47]
    algebraic[3] = custom_piecewise([less(states[0] , -40.0000), 0.135000*exp((states[0]+80.0000)/-6.80000) , True, 0.00000])
    algebraic[21] = custom_piecewise([less(states[0] , -40.0000), 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0]) , True, 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000)))])
    algebraic[48] = 1.00000/(algebraic[3]+algebraic[21])
    algebraic[38] = algebraic[3]/(algebraic[3]+algebraic[21])
    rates[6] = (algebraic[38]-states[6])/algebraic[48]
    algebraic[4] = custom_piecewise([less(states[0] , -40.0000), ((-127140.*exp(0.244400*states[0])-3.47400e-05*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300))) , True, 0.00000])
    algebraic[22] = custom_piecewise([less(states[0] , -40.0000), (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400))) , True, (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000)))])
    algebraic[49] = 0.100000/(algebraic[4]+algebraic[22])
    algebraic[39] = (0.100000*algebraic[4])/(algebraic[4]+algebraic[22])
    rates[7] = (algebraic[39]-states[7])/algebraic[49]
    algebraic[5] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[23] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[50] = 1.00000/(algebraic[5]+algebraic[23])
    algebraic[40] = algebraic[5]/(algebraic[5]+algebraic[23])
    rates[8] = (algebraic[40]-states[8])/algebraic[50]
    algebraic[10] = 1.06800*exp((states[0]+16.3000)/30.0000)
    algebraic[28] = 1.06800*exp(-(states[0]+16.3000)/30.0000)
    algebraic[51] = 1.00000/(algebraic[10]+algebraic[28])
    algebraic[41] = 1.00000/(1.00000+exp(-(states[0]+33.0000)/6.10000))
    rates[16] = (algebraic[41]-states[16])/algebraic[51]
    algebraic[11] = 0.0150000*exp(-(states[0]+71.7000)/83.3000)
    algebraic[29] = 0.0150000*exp((states[0]+71.7000)/15.4000)
    algebraic[52] = 1.00000/(algebraic[11]+algebraic[29])
    algebraic[42] = 1.00000/(1.00000+exp((states[0]+60.0000)/6.60000))
    rates[17] = (algebraic[42]-states[17])/algebraic[52]
    algebraic[12] = (25.0000*exp((states[0]-76.0000)/20.0000))/(1.00000+exp((states[0]-76.0000)/20.0000))
    algebraic[30] = (25.0000*exp(-(states[0]+54.0000)/20.0000))/(1.00000+exp(-(states[0]+54.0000)/20.0000))
    algebraic[43] = 1.00000/(algebraic[12]+algebraic[30])
    algebraic[53] = algebraic[12]/(algebraic[12]+algebraic[30])
    rates[18] = (algebraic[53]-states[18])/algebraic[43]
    algebraic[44] = 6.00000+5.00000/(1.00000+exp((states[0]-16.5000)/10.0000))
    algebraic[13] = 0.0300000/(1.00000+exp((states[0]+25.0000)/15.0000))
    algebraic[31] = (0.100000*exp((states[0]-40.0000)/15.0000))/(1.00000+exp((states[0]-40.0000)/15.0000))
    algebraic[54] = algebraic[13]/(algebraic[13]+algebraic[31])
    rates[19] = (algebraic[54]-states[19])/algebraic[44]
    algebraic[45] = 21.5000+30.0000/(1.00000+exp((states[0]-25.0000)/10.0000))
    algebraic[14] = 0.00442000/(1.00000+exp((states[0]+26.0000)/15.0000))
    algebraic[32] = (0.0500000*exp((states[0]-10.0000)/15.0000))/(1.00000+exp((states[0]-10.0000)/15.0000))
    algebraic[55] = algebraic[14]/(algebraic[14]+algebraic[32])
    rates[20] = (algebraic[55]-states[20])/algebraic[45]
    algebraic[59] = (((((1.00000*constants[14])/constants[19])*(power(constants[15], 2.00000))*(states[0]-15.0000)*(power(constants[9], 2.00000)))/(constants[8]*constants[10]))*(constants[16]*states[10]*exp((constants[15]*constants[9]*(states[0]-15.0000))/(constants[8]*constants[10]))-constants[17]*constants[5]))/(exp((constants[15]*constants[9]*(states[0]-15.0000))/(constants[8]*constants[10]))-1.00000)
    algebraic[60] = constants[13]*states[11]*states[12]*states[13]*states[14]*states[15]*algebraic[59]
    algebraic[62] = 1.00000/(1.00000-algebraic[60]/0.0100000)
    algebraic[65] = 125.000+300.000/(1.00000+exp((-algebraic[60]-0.175000)/0.0400000))
    rates[15] = (algebraic[62]-states[15])/algebraic[65]
    algebraic[63] = (power(states[27], 1.90000))/(power(states[27], 1.90000)+power((49.2800*states[10])/(states[10]+0.00280000), 1.90000))
    algebraic[66] = (algebraic[63]*(power(algebraic[60], 2.00000)))/(power(algebraic[60], 2.00000)+1.00000)
    rates[29] = (algebraic[66]-states[29])/constants[60]
    algebraic[19] = ((constants[8]*constants[10])/constants[9])*log(constants[4]/states[1])
    algebraic[57] = constants[11]*(power(states[5], 3.00000))*(0.800000*states[6]+0.200000*states[7])*(states[0]-algebraic[19])
    algebraic[58] = constants[12]*(power(states[8], 3.00000))*states[9]*(states[0]-algebraic[19])
    algebraic[80] = constants[31]*(power(states[1], 3.00000))+1.50000*(power(constants[29], 3.00000))*states[2]+(power(constants[28], 3.00000))*constants[5]*(1.00000+(1.50000*states[2])/constants[30])
    algebraic[81] = constants[30]*(power(constants[4], 3.00000))*(1.00000+states[1]/constants[28])+(power(states[1], 3.00000))*constants[5]+1.50000*(power(constants[4], 3.00000))*states[2]
    algebraic[82] = (constants[26]*constants[27]*(power(states[1], 3.00000))*constants[5]*exp((0.350000*constants[9]*states[0])/(constants[8]*constants[10]))-1.50000*(power(constants[4], 3.00000))*states[2]*exp((-0.650000*constants[9]*states[0])/(constants[8]*constants[10])))/((1.00000+power(constants[32]/(1.50000*states[2]), 2.00000))*(1.00000+constants[33]*exp((-0.650000*states[0]*constants[9])/(constants[8]*constants[10])))*(algebraic[80]+algebraic[81]))
    algebraic[83] = 1.00000/(1.00000+0.124500*exp((-0.100000*constants[9]*states[0])/(constants[8]*constants[10]))+0.0365000*constants[77]*exp((-constants[9]*states[0])/(constants[8]*constants[10])))
    algebraic[84] = (((constants[34]*algebraic[83]*1.00000)/(1.00000+power(constants[35]/states[1], 2.00000)))*constants[6])/(constants[6]+constants[36])
    algebraic[88] = constants[41]*(states[0]-algebraic[19])
    algebraic[46] = ((-constants[8]*constants[10])/constants[9])*log(constants[7]/states[4])
    algebraic[87] = (constants[40]*(power(algebraic[19]-algebraic[46], 4.00000)))/(power(algebraic[19]-algebraic[46], 4.00000)+power(87.8251, 4.00000))
    rates[1] = (-constants[19]*(algebraic[57]+algebraic[58]+algebraic[88]+3.00000*algebraic[84]+3.00000*algebraic[82])*constants[78])/(constants[79]*constants[9])+algebraic[87]
    algebraic[36] = ((constants[8]*constants[10])/constants[9])*log(constants[6]/states[3])
    algebraic[67] = constants[21]*states[18]*(0.800000*states[19]+0.200000*states[20])*(states[0]-algebraic[36])
    algebraic[68] = 1.00000/(1.00000+exp((states[0]-5.40000)/20.4000))
    algebraic[69] = constants[74]*states[21]*algebraic[68]*(states[0]-algebraic[36])
    algebraic[56] = ((constants[8]*constants[10])/constants[9])*log((constants[6]+constants[3]*constants[4])/(states[3]+constants[3]*states[1]))
    algebraic[70] = 0.0525813*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[2], 1.40000)))
    algebraic[71] = algebraic[70]*states[22]*states[23]*(states[0]-algebraic[56])
    algebraic[73] = 1.02000/(1.00000+exp(0.238500*(states[0]-(algebraic[36]+59.2150))))
    algebraic[72] = (0.491240*exp(0.0803200*((states[0]+5.47600)-algebraic[36]))+exp(0.0617500*(states[0]-(594.310+algebraic[36]))))/(1.00000+exp(-0.514300*((states[0]+4.75300)-algebraic[36])))
    algebraic[74] = algebraic[73]/(algebraic[73]+algebraic[72])
    algebraic[75] = (constants[75]*algebraic[74]+0.00400000)*(states[0]-algebraic[36])
    algebraic[89] = constants[42]*(states[0]-algebraic[36])
    algebraic[76] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000))
    algebraic[77] = constants[22]*algebraic[76]*(states[0]-algebraic[36])
    algebraic[86] = (constants[39]*(algebraic[36]-algebraic[46]))/((algebraic[36]+87.8251)-algebraic[46])
    rates[3] = (-constants[19]*((algebraic[67]+algebraic[75]+algebraic[69]+algebraic[71]+algebraic[77]+algebraic[89])-2.00000*algebraic[84])*constants[78])/(constants[79]*constants[9])+algebraic[86]
    algebraic[78] = (((((1.00000*constants[23])/constants[19])*(power(constants[24], 2.00000))*states[0]*(power(constants[9], 2.00000)))/(constants[8]*constants[10]))*(states[4]-constants[7]*exp((-constants[24]*states[0]*constants[9])/(constants[8]*constants[10]))))/(1.00000-exp((-constants[24]*states[0]*constants[9])/(constants[8]*constants[10])))
    algebraic[79] = 20.0000*algebraic[78]*states[24]
    algebraic[90] = constants[44]*(states[0]-algebraic[46])
    rates[4] = (-constants[19]*(algebraic[79]+algebraic[90])*constants[78])/(constants[79]*constants[9])+algebraic[87]+algebraic[86]
    algebraic[0] = custom_piecewise([greater_equal(voi , constants[0]) & less_equal(voi , constants[1]), constants[2] , True, 0.00000])
    algebraic[64] = constants[20]*states[16]*states[17]*(states[0]-50.0000)
    algebraic[91] = (((((1.00000*constants[43])/constants[19])*(power(constants[15], 2.00000))*states[0]*(power(constants[9], 2.00000)))/(constants[8]*constants[10]))*(constants[16]*states[2]*exp((constants[15]*states[0]*constants[9])/(constants[8]*constants[10]))-constants[17]*constants[5]))/(exp((constants[15]*states[0]*constants[9])/(constants[8]*constants[10]))-1.00000)
    algebraic[85] = (constants[37]*states[2])/(constants[38]+states[2])
    algebraic[92] = algebraic[57]+algebraic[58]+algebraic[60]+algebraic[64]+algebraic[67]+algebraic[79]+algebraic[69]+algebraic[71]+algebraic[75]+algebraic[82]+algebraic[84]+algebraic[88]+algebraic[89]+algebraic[91]+algebraic[90]+algebraic[85]+algebraic[77]
    rates[0] = -(algebraic[92]+algebraic[0])
    algebraic[96] = (constants[51]*(1.00000-states[25]))/(1.00000+constants[18]/states[10])
    rates[25] = constants[49]*algebraic[96]*(algebraic[96]+states[25])-constants[50]*states[25]
    algebraic[61] = 0.300000/(1.00000-algebraic[60]/0.0500000)+0.550000/(1.00000+states[10]/0.00300000)+0.150000
    algebraic[97] = algebraic[96]+states[25]
    algebraic[98] = 0.500000+(10.0000*1.00000*algebraic[97])/(1.00000*algebraic[97]+constants[18])+1.00000/(1.00000+states[10]/0.00300000)
    rates[14] = (algebraic[61]-states[14])/algebraic[98]
    algebraic[104] = (constants[59]*1.00000*algebraic[97])/(constants[18]+1.00000*algebraic[97])
    algebraic[100] = 1.00000/(1.00000+exp((algebraic[60]+0.0500000)/0.0150000))
    algebraic[106] = (350.000-algebraic[104])/(1.00000+exp(((states[10]-0.00300000)+0.00300000*algebraic[100])/0.000200000))+3.00000+algebraic[104]
    algebraic[102] = 1.00000/(1.00000+exp(((states[10]-0.000400000)+0.00200000*algebraic[100])/2.50000e-05))
    rates[28] = (algebraic[102]-states[28])/algebraic[106]
    algebraic[99] = (states[10]-states[2])/constants[58]
    algebraic[107] = 1.00000/(1.00000+exp((constants[13]*algebraic[59]+13.0000)/5.00000))
    algebraic[108] = 3000.00*algebraic[107]
    algebraic[109] = algebraic[108]*states[29]*states[28]*(states[27]-states[10])
    algebraic[103] = (2.00000*constants[56]*states[10])/(power(states[10]+constants[54], 2.00000))
    algebraic[101] = (2.00000*constants[57]*states[10])/(power(states[10]+constants[55], 2.00000))
    algebraic[105] = 1.00000/(1.00000+algebraic[103]+algebraic[101])
    rates[10] = algebraic[105]*(((-constants[19]*algebraic[60]*constants[78])/(constants[82]*constants[15]*constants[9])+(algebraic[109]*constants[81])/constants[82])-algebraic[99])
    algebraic[94] = (2.00000*constants[47]*states[2])/(power(states[2]+constants[45], 2.00000))
    algebraic[93] = (2.00000*constants[48]*states[2])/(power(states[2]+constants[46], 2.00000))
    algebraic[95] = 1.00000/(1.00000+algebraic[94]+algebraic[93])
    algebraic[111] = (constants[65]*algebraic[97]*1.00000)/(constants[18]+algebraic[97]*1.00000)
    algebraic[112] = (constants[66]*algebraic[97]*1.00000)/(constants[18]+algebraic[97]*1.00000)
    algebraic[113] = (constants[63]*(algebraic[111]+1.00000)*constants[64]*states[2])/((states[2]+constants[67])-algebraic[112])
    algebraic[110] = (constants[61]*states[26])/constants[62]
    rates[2] = -algebraic[95]*(((constants[19]*((algebraic[91]+algebraic[85])-2.00000*algebraic[82])*constants[78])/(2.00000*constants[79]*constants[9])+((algebraic[113]-algebraic[110])*constants[80])/constants[79])-(algebraic[99]*constants[82])/constants[79])
    algebraic[114] = (states[26]-states[27])/constants[68]
    rates[26] = algebraic[113]-(algebraic[110]+(algebraic[114]*constants[81])/constants[80])
    rates[27] = (algebraic[114]-algebraic[109])/(1.00000+(constants[52]*constants[53])/(power(constants[53]+states[27], 2.00000)))
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[18] = 1.00000/(1.00000+constants[25]/states[10])
    algebraic[24] = 175.000+125.000/(1.00000+exp(-(states[0]+25.0000)/6.00000))
    algebraic[6] = 1.00000/(1.00000+exp((states[0]+69.0000)/6.10000))
    algebraic[7] = 1.00000/(1.00000+exp(-(states[0]-4.00000)/6.74000))
    algebraic[25] = 0.590000+(0.800000*exp(0.0520000*(states[0]+13.0000)))/(1.00000+exp(0.132000*(states[0]+13.0000)))
    algebraic[8] = 1.00000/(1.00000+exp((states[0]+18.0000)/10.0000))
    algebraic[26] = 4.00000+0.00500000*(power(states[0]-2.50000, 2.00000))
    algebraic[9] = 1.00000/(1.00000+exp((states[0]+18.0000)/10.0000))
    algebraic[27] = 38.0000+0.0700000*(power(states[0]-18.6000, 2.00000))
    algebraic[15] = 900.000/(1.00000+exp(states[0]/5.00000))+100.000
    algebraic[33] = 1.00000/(1.00000+exp(-(states[0]+0.0850000)/12.2500))
    algebraic[16] = 1.00000/((7.61000e-05*(states[0]+44.6000))/(1.00000-exp(-9.97000*(states[0]+44.6000)))+(0.000360000*(states[0]-0.550000))/(exp(0.128000*(states[0]-0.550000))-1.00000))
    algebraic[34] = 1.00000/(1.00000+exp(-(states[0]-9.00000)/13.7000))
    algebraic[17] = (2.00000*1.00000)/((7.61000e-05*(states[0]+44.6000))/(1.00000-exp(-9.97000*(states[0]+44.6000)))+(0.000360000*(states[0]-0.550000))/(exp(0.128000*(states[0]-0.550000))-1.00000))
    algebraic[35] = 1.00000/(1.00000+exp(-(states[0]-9.00000)/13.7000))
    algebraic[2] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[20] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[47] = 1.00000/(algebraic[2]+algebraic[20])
    algebraic[37] = algebraic[2]/(algebraic[2]+algebraic[20])
    algebraic[3] = custom_piecewise([less(states[0] , -40.0000), 0.135000*exp((states[0]+80.0000)/-6.80000) , True, 0.00000])
    algebraic[21] = custom_piecewise([less(states[0] , -40.0000), 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0]) , True, 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000)))])
    algebraic[48] = 1.00000/(algebraic[3]+algebraic[21])
    algebraic[38] = algebraic[3]/(algebraic[3]+algebraic[21])
    algebraic[4] = custom_piecewise([less(states[0] , -40.0000), ((-127140.*exp(0.244400*states[0])-3.47400e-05*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300))) , True, 0.00000])
    algebraic[22] = custom_piecewise([less(states[0] , -40.0000), (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400))) , True, (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000)))])
    algebraic[49] = 0.100000/(algebraic[4]+algebraic[22])
    algebraic[39] = (0.100000*algebraic[4])/(algebraic[4]+algebraic[22])
    algebraic[5] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[23] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[50] = 1.00000/(algebraic[5]+algebraic[23])
    algebraic[40] = algebraic[5]/(algebraic[5]+algebraic[23])
    algebraic[10] = 1.06800*exp((states[0]+16.3000)/30.0000)
    algebraic[28] = 1.06800*exp(-(states[0]+16.3000)/30.0000)
    algebraic[51] = 1.00000/(algebraic[10]+algebraic[28])
    algebraic[41] = 1.00000/(1.00000+exp(-(states[0]+33.0000)/6.10000))
    algebraic[11] = 0.0150000*exp(-(states[0]+71.7000)/83.3000)
    algebraic[29] = 0.0150000*exp((states[0]+71.7000)/15.4000)
    algebraic[52] = 1.00000/(algebraic[11]+algebraic[29])
    algebraic[42] = 1.00000/(1.00000+exp((states[0]+60.0000)/6.60000))
    algebraic[12] = (25.0000*exp((states[0]-76.0000)/20.0000))/(1.00000+exp((states[0]-76.0000)/20.0000))
    algebraic[30] = (25.0000*exp(-(states[0]+54.0000)/20.0000))/(1.00000+exp(-(states[0]+54.0000)/20.0000))
    algebraic[43] = 1.00000/(algebraic[12]+algebraic[30])
    algebraic[53] = algebraic[12]/(algebraic[12]+algebraic[30])
    algebraic[44] = 6.00000+5.00000/(1.00000+exp((states[0]-16.5000)/10.0000))
    algebraic[13] = 0.0300000/(1.00000+exp((states[0]+25.0000)/15.0000))
    algebraic[31] = (0.100000*exp((states[0]-40.0000)/15.0000))/(1.00000+exp((states[0]-40.0000)/15.0000))
    algebraic[54] = algebraic[13]/(algebraic[13]+algebraic[31])
    algebraic[45] = 21.5000+30.0000/(1.00000+exp((states[0]-25.0000)/10.0000))
    algebraic[14] = 0.00442000/(1.00000+exp((states[0]+26.0000)/15.0000))
    algebraic[32] = (0.0500000*exp((states[0]-10.0000)/15.0000))/(1.00000+exp((states[0]-10.0000)/15.0000))
    algebraic[55] = algebraic[14]/(algebraic[14]+algebraic[32])
    algebraic[59] = (((((1.00000*constants[14])/constants[19])*(power(constants[15], 2.00000))*(states[0]-15.0000)*(power(constants[9], 2.00000)))/(constants[8]*constants[10]))*(constants[16]*states[10]*exp((constants[15]*constants[9]*(states[0]-15.0000))/(constants[8]*constants[10]))-constants[17]*constants[5]))/(exp((constants[15]*constants[9]*(states[0]-15.0000))/(constants[8]*constants[10]))-1.00000)
    algebraic[60] = constants[13]*states[11]*states[12]*states[13]*states[14]*states[15]*algebraic[59]
    algebraic[62] = 1.00000/(1.00000-algebraic[60]/0.0100000)
    algebraic[65] = 125.000+300.000/(1.00000+exp((-algebraic[60]-0.175000)/0.0400000))
    algebraic[63] = (power(states[27], 1.90000))/(power(states[27], 1.90000)+power((49.2800*states[10])/(states[10]+0.00280000), 1.90000))
    algebraic[66] = (algebraic[63]*(power(algebraic[60], 2.00000)))/(power(algebraic[60], 2.00000)+1.00000)
    algebraic[19] = ((constants[8]*constants[10])/constants[9])*log(constants[4]/states[1])
    algebraic[57] = constants[11]*(power(states[5], 3.00000))*(0.800000*states[6]+0.200000*states[7])*(states[0]-algebraic[19])
    algebraic[58] = constants[12]*(power(states[8], 3.00000))*states[9]*(states[0]-algebraic[19])
    algebraic[80] = constants[31]*(power(states[1], 3.00000))+1.50000*(power(constants[29], 3.00000))*states[2]+(power(constants[28], 3.00000))*constants[5]*(1.00000+(1.50000*states[2])/constants[30])
    algebraic[81] = constants[30]*(power(constants[4], 3.00000))*(1.00000+states[1]/constants[28])+(power(states[1], 3.00000))*constants[5]+1.50000*(power(constants[4], 3.00000))*states[2]
    algebraic[82] = (constants[26]*constants[27]*(power(states[1], 3.00000))*constants[5]*exp((0.350000*constants[9]*states[0])/(constants[8]*constants[10]))-1.50000*(power(constants[4], 3.00000))*states[2]*exp((-0.650000*constants[9]*states[0])/(constants[8]*constants[10])))/((1.00000+power(constants[32]/(1.50000*states[2]), 2.00000))*(1.00000+constants[33]*exp((-0.650000*states[0]*constants[9])/(constants[8]*constants[10])))*(algebraic[80]+algebraic[81]))
    algebraic[83] = 1.00000/(1.00000+0.124500*exp((-0.100000*constants[9]*states[0])/(constants[8]*constants[10]))+0.0365000*constants[77]*exp((-constants[9]*states[0])/(constants[8]*constants[10])))
    algebraic[84] = (((constants[34]*algebraic[83]*1.00000)/(1.00000+power(constants[35]/states[1], 2.00000)))*constants[6])/(constants[6]+constants[36])
    algebraic[88] = constants[41]*(states[0]-algebraic[19])
    algebraic[46] = ((-constants[8]*constants[10])/constants[9])*log(constants[7]/states[4])
    algebraic[87] = (constants[40]*(power(algebraic[19]-algebraic[46], 4.00000)))/(power(algebraic[19]-algebraic[46], 4.00000)+power(87.8251, 4.00000))
    algebraic[36] = ((constants[8]*constants[10])/constants[9])*log(constants[6]/states[3])
    algebraic[67] = constants[21]*states[18]*(0.800000*states[19]+0.200000*states[20])*(states[0]-algebraic[36])
    algebraic[68] = 1.00000/(1.00000+exp((states[0]-5.40000)/20.4000))
    algebraic[69] = constants[74]*states[21]*algebraic[68]*(states[0]-algebraic[36])
    algebraic[56] = ((constants[8]*constants[10])/constants[9])*log((constants[6]+constants[3]*constants[4])/(states[3]+constants[3]*states[1]))
    algebraic[70] = 0.0525813*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[2], 1.40000)))
    algebraic[71] = algebraic[70]*states[22]*states[23]*(states[0]-algebraic[56])
    algebraic[73] = 1.02000/(1.00000+exp(0.238500*(states[0]-(algebraic[36]+59.2150))))
    algebraic[72] = (0.491240*exp(0.0803200*((states[0]+5.47600)-algebraic[36]))+exp(0.0617500*(states[0]-(594.310+algebraic[36]))))/(1.00000+exp(-0.514300*((states[0]+4.75300)-algebraic[36])))
    algebraic[74] = algebraic[73]/(algebraic[73]+algebraic[72])
    algebraic[75] = (constants[75]*algebraic[74]+0.00400000)*(states[0]-algebraic[36])
    algebraic[89] = constants[42]*(states[0]-algebraic[36])
    algebraic[76] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000))
    algebraic[77] = constants[22]*algebraic[76]*(states[0]-algebraic[36])
    algebraic[86] = (constants[39]*(algebraic[36]-algebraic[46]))/((algebraic[36]+87.8251)-algebraic[46])
    algebraic[78] = (((((1.00000*constants[23])/constants[19])*(power(constants[24], 2.00000))*states[0]*(power(constants[9], 2.00000)))/(constants[8]*constants[10]))*(states[4]-constants[7]*exp((-constants[24]*states[0]*constants[9])/(constants[8]*constants[10]))))/(1.00000-exp((-constants[24]*states[0]*constants[9])/(constants[8]*constants[10])))
    algebraic[79] = 20.0000*algebraic[78]*states[24]
    algebraic[90] = constants[44]*(states[0]-algebraic[46])
    algebraic[0] = custom_piecewise([greater_equal(voi , constants[0]) & less_equal(voi , constants[1]), constants[2] , True, 0.00000])
    algebraic[64] = constants[20]*states[16]*states[17]*(states[0]-50.0000)
    algebraic[91] = (((((1.00000*constants[43])/constants[19])*(power(constants[15], 2.00000))*states[0]*(power(constants[9], 2.00000)))/(constants[8]*constants[10]))*(constants[16]*states[2]*exp((constants[15]*states[0]*constants[9])/(constants[8]*constants[10]))-constants[17]*constants[5]))/(exp((constants[15]*states[0]*constants[9])/(constants[8]*constants[10]))-1.00000)
    algebraic[85] = (constants[37]*states[2])/(constants[38]+states[2])
    algebraic[92] = algebraic[57]+algebraic[58]+algebraic[60]+algebraic[64]+algebraic[67]+algebraic[79]+algebraic[69]+algebraic[71]+algebraic[75]+algebraic[82]+algebraic[84]+algebraic[88]+algebraic[89]+algebraic[91]+algebraic[90]+algebraic[85]+algebraic[77]
    algebraic[96] = (constants[51]*(1.00000-states[25]))/(1.00000+constants[18]/states[10])
    algebraic[61] = 0.300000/(1.00000-algebraic[60]/0.0500000)+0.550000/(1.00000+states[10]/0.00300000)+0.150000
    algebraic[97] = algebraic[96]+states[25]
    algebraic[98] = 0.500000+(10.0000*1.00000*algebraic[97])/(1.00000*algebraic[97]+constants[18])+1.00000/(1.00000+states[10]/0.00300000)
    algebraic[104] = (constants[59]*1.00000*algebraic[97])/(constants[18]+1.00000*algebraic[97])
    algebraic[100] = 1.00000/(1.00000+exp((algebraic[60]+0.0500000)/0.0150000))
    algebraic[106] = (350.000-algebraic[104])/(1.00000+exp(((states[10]-0.00300000)+0.00300000*algebraic[100])/0.000200000))+3.00000+algebraic[104]
    algebraic[102] = 1.00000/(1.00000+exp(((states[10]-0.000400000)+0.00200000*algebraic[100])/2.50000e-05))
    algebraic[99] = (states[10]-states[2])/constants[58]
    algebraic[107] = 1.00000/(1.00000+exp((constants[13]*algebraic[59]+13.0000)/5.00000))
    algebraic[108] = 3000.00*algebraic[107]
    algebraic[109] = algebraic[108]*states[29]*states[28]*(states[27]-states[10])
    algebraic[103] = (2.00000*constants[56]*states[10])/(power(states[10]+constants[54], 2.00000))
    algebraic[101] = (2.00000*constants[57]*states[10])/(power(states[10]+constants[55], 2.00000))
    algebraic[105] = 1.00000/(1.00000+algebraic[103]+algebraic[101])
    algebraic[94] = (2.00000*constants[47]*states[2])/(power(states[2]+constants[45], 2.00000))
    algebraic[93] = (2.00000*constants[48]*states[2])/(power(states[2]+constants[46], 2.00000))
    algebraic[95] = 1.00000/(1.00000+algebraic[94]+algebraic[93])
    algebraic[111] = (constants[65]*algebraic[97]*1.00000)/(constants[18]+algebraic[97]*1.00000)
    algebraic[112] = (constants[66]*algebraic[97]*1.00000)/(constants[18]+algebraic[97]*1.00000)
    algebraic[113] = (constants[63]*(algebraic[111]+1.00000)*constants[64]*states[2])/((states[2]+constants[67])-algebraic[112])
    algebraic[110] = (constants[61]*states[26])/constants[62]
    algebraic[114] = (states[26]-states[27])/constants[68]
    algebraic[1] = ((constants[8]*constants[10])/(2.00000*constants[9]))*log(constants[5]/states[2])
    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)