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 = 128
sizeStates = 48
sizeConstants = 94
from math import *
from numpy import *

def createLegends():
    legend_states = [""] * sizeStates
    legend_rates = [""] * sizeStates
    legend_algebraic = [""] * sizeAlgebraic
    legend_voi = ""
    legend_constants = [""] * sizeConstants
    legend_voi = "time in component environment (ms)"
    legend_constants[0] = "F in component model_parameters (C_per_mole)"
    legend_constants[1] = "T in component model_parameters (kelvin)"
    legend_constants[2] = "R in component model_parameters (J_per_kmole_K)"
    legend_constants[3] = "K_o in component model_parameters (mM)"
    legend_constants[4] = "Ca_o in component model_parameters (mM)"
    legend_constants[5] = "Na_o in component model_parameters (mM)"
    legend_constants[6] = "Cl_o in component model_parameters (mM)"
    legend_constants[88] = "Vmyo in component cell_geometry (uL)"
    legend_constants[89] = "Vnsr in component cell_geometry (uL)"
    legend_constants[84] = "Vsr in component cell_geometry (uL)"
    legend_constants[90] = "Vjsr in component cell_geometry (uL)"
    legend_constants[91] = "Vss_sr in component cell_geometry (uL)"
    legend_constants[92] = "Vss_CaL in component cell_geometry (uL)"
    legend_constants[86] = "Acap in component cell_geometry (cm2)"
    legend_constants[87] = "AF in component cell_geometry (uF_mole_per_C)"
    legend_constants[7] = "l in component cell_geometry (cm)"
    legend_constants[8] = "a in component cell_geometry (cm)"
    legend_constants[81] = "vcell in component cell_geometry (uL)"
    legend_constants[85] = "ageo in component cell_geometry (cm2)"
    legend_states[0] = "Vm in component membrane (mV)"
    legend_algebraic[12] = "i_Stim in component membrane (uA_per_uF)"
    legend_constants[9] = "stim_offset in component membrane (ms)"
    legend_constants[10] = "stim_period in component membrane (ms)"
    legend_constants[11] = "stim_duration in component membrane (ms)"
    legend_constants[12] = "stim_amplitude in component membrane (uA_per_uF)"
    legend_algebraic[0] = "past in component membrane (ms)"
    legend_algebraic[110] = "caiont in component membrane (uA_per_uF)"
    legend_algebraic[113] = "naiont in component membrane (uA_per_uF)"
    legend_algebraic[80] = "kiont in component membrane (uA_per_uF)"
    legend_algebraic[71] = "clont in component membrane (uA_per_uF)"
    legend_algebraic[51] = "INa in component INa (uA_per_uF)"
    legend_algebraic[98] = "ICaL in component ICaL (uA_per_uF)"
    legend_algebraic[61] = "IK1 in component IK1 (uA_per_uF)"
    legend_algebraic[54] = "IKp in component IKp (uA_per_uF)"
    legend_algebraic[79] = "IKs in component IKs (uA_per_uF)"
    legend_algebraic[65] = "IKr in component IKr (uA_per_uF)"
    legend_algebraic[86] = "IpCa in component IpCa (uA_per_uF)"
    legend_algebraic[87] = "ICab in component ICab (uA_per_uF)"
    legend_algebraic[85] = "INaCa in component INaCa (uA_per_uF)"
    legend_algebraic[109] = "INaCa_ss_sr in component INaCa (uA_per_uF)"
    legend_algebraic[44] = "INaK in component INaK (uA_per_uF)"
    legend_algebraic[67] = "Ito1 in component Ito1 (uA_per_uF)"
    legend_algebraic[70] = "Ito2 in component Ito2 (uA_per_uF)"
    legend_algebraic[57] = "IClb in component IClb (uA_per_uF)"
    legend_algebraic[52] = "INaL in component INaL (uA_per_uF)"
    legend_algebraic[49] = "INab in component INab (uA_per_uF)"
    legend_algebraic[78] = "gKs in component IKs (mS_per_uF)"
    legend_states[1] = "C1 in component IKs (dimensionless)"
    legend_states[2] = "C2 in component IKs (dimensionless)"
    legend_states[3] = "C3 in component IKs (dimensionless)"
    legend_states[4] = "C4 in component IKs (dimensionless)"
    legend_states[5] = "C5 in component IKs (dimensionless)"
    legend_states[6] = "C6 in component IKs (dimensionless)"
    legend_states[7] = "C7 in component IKs (dimensionless)"
    legend_states[8] = "C8 in component IKs (dimensionless)"
    legend_states[9] = "C9 in component IKs (dimensionless)"
    legend_states[10] = "C10 in component IKs (dimensionless)"
    legend_states[11] = "C11 in component IKs (dimensionless)"
    legend_states[12] = "C12 in component IKs (dimensionless)"
    legend_states[13] = "C13 in component IKs (dimensionless)"
    legend_states[14] = "C14 in component IKs (dimensionless)"
    legend_states[15] = "C15 in component IKs (dimensionless)"
    legend_states[16] = "O1 in component IKs (dimensionless)"
    legend_states[17] = "O2 in component IKs (dimensionless)"
    legend_algebraic[23] = "OKs in component IKs (dimensionless)"
    legend_algebraic[1] = "alpha in component IKs (per_ms)"
    legend_algebraic[13] = "beta in component IKs (per_ms)"
    legend_algebraic[28] = "delta in component IKs (per_ms)"
    legend_algebraic[24] = "gamma in component IKs (per_ms)"
    legend_algebraic[31] = "eta in component IKs (per_ms)"
    legend_constants[80] = "theta in component IKs (per_ms)"
    legend_algebraic[33] = "omega in component IKs (per_ms)"
    legend_algebraic[35] = "psi in component IKs (per_ms)"
    legend_algebraic[55] = "EKs in component reversal_potentials (mV)"
    legend_algebraic[77] = "Ca_i in component Ca_buffering (mM)"
    legend_algebraic[96] = "ICaL_max in component ICaL (uA_per_uF)"
    legend_constants[13] = "PCa in component ICaL (L_per_F_ms)"
    legend_states[18] = "C in component ICaL (dimensionless)"
    legend_states[19] = "O in component ICaL (dimensionless)"
    legend_states[20] = "C_star in component ICaL (dimensionless)"
    legend_states[21] = "O_star in component ICaL (dimensionless)"
    legend_states[22] = "CI in component ICaL (dimensionless)"
    legend_states[23] = "OI in component ICaL (dimensionless)"
    legend_states[24] = "CI_star in component ICaL (dimensionless)"
    legend_states[25] = "OI_star in component ICaL (dimensionless)"
    legend_algebraic[27] = "ACT_tau in component ICaL (ms)"
    legend_algebraic[37] = "IV_tau in component ICaL (ms)"
    legend_algebraic[99] = "IV_tau_star in component ICaL (ms)"
    legend_algebraic[30] = "ACT_infinity in component ICaL (dimensionless)"
    legend_algebraic[36] = "IV_infinity in component ICaL (dimensionless)"
    legend_algebraic[40] = "IV_infinity_star in component ICaL (dimensionless)"
    legend_algebraic[97] = "IV_beta_star in component ICaL (dimensionless)"
    legend_algebraic[95] = "IV_beta_infinity_star in component ICaL (dimensionless)"
    legend_algebraic[32] = "alpha in component ICaL (per_ms)"
    legend_algebraic[34] = "beta in component ICaL (per_ms)"
    legend_algebraic[105] = "delta in component ICaL (per_ms)"
    legend_algebraic[38] = "x in component ICaL (per_ms)"
    legend_algebraic[39] = "y in component ICaL (per_ms)"
    legend_constants[14] = "theta in component ICaL (per_ms)"
    legend_algebraic[107] = "delta_I in component ICaL (per_ms)"
    legend_algebraic[101] = "x_star in component ICaL (per_ms)"
    legend_algebraic[103] = "y_star in component ICaL (per_ms)"
    legend_constants[15] = "theta_I in component ICaL (per_ms)"
    legend_constants[16] = "gamma_Cai in component ICaL (dimensionless)"
    legend_constants[17] = "gamma_Cao in component ICaL (dimensionless)"
    legend_algebraic[94] = "Ca_ss_CaL in component Ca_ss_buffering (mM)"
    legend_constants[18] = "g_Na in component INa (mS_per_uF)"
    legend_algebraic[50] = "ENa in component reversal_potentials (mV)"
    legend_states[26] = "m in component INa_m_gate (dimensionless)"
    legend_states[27] = "h in component INa_h_gate (dimensionless)"
    legend_states[28] = "j in component INa_j_gate (dimensionless)"
    legend_algebraic[2] = "am in component INa_m_gate (per_ms)"
    legend_algebraic[14] = "bm in component INa_m_gate (per_ms)"
    legend_algebraic[3] = "ah in component INa_h_gate (per_ms)"
    legend_algebraic[15] = "bh in component INa_h_gate (per_ms)"
    legend_algebraic[4] = "aj in component INa_j_gate (per_ms)"
    legend_algebraic[16] = "bj in component INa_j_gate (per_ms)"
    legend_constants[19] = "kmnai in component INaK (mM)"
    legend_constants[20] = "kmko in component INaK (mM)"
    legend_constants[21] = "ibarnak in component INaK (uA_per_uF)"
    legend_constants[22] = "sigma in component INaK (dimensionless)"
    legend_constants[23] = "V_half in component INaK (mV)"
    legend_algebraic[41] = "phi in component INaK (dimensionless)"
    legend_algebraic[42] = "fv in component INaK (dimensionless)"
    legend_constants[93] = "PK in component INaK (dimensionless)"
    legend_algebraic[43] = "PNa in component INaK (dimensionless)"
    legend_states[29] = "Na_i in component Na (mM)"
    legend_constants[24] = "KmCa_act in component INaCa (mM)"
    legend_constants[25] = "Vmax in component INaCa (uA_per_uF)"
    legend_constants[26] = "ksat in component INaCa (dimensionless)"
    legend_constants[27] = "eta in component INaCa (dimensionless)"
    legend_constants[28] = "KmNai in component INaCa (mM)"
    legend_constants[29] = "KmNao in component INaCa (mM)"
    legend_constants[30] = "KmCai in component INaCa (mM)"
    legend_constants[31] = "KmCao in component INaCa (mM)"
    legend_algebraic[100] = "Ca_ss_sr in component Ca_ss_buffering (mM)"
    legend_states[30] = "Na_ss_sr in component Na (mM)"
    legend_algebraic[81] = "num in component INaCa (mM4_uA_per_uF)"
    legend_algebraic[102] = "num_ss in component INaCa (mM4_uA_per_uF)"
    legend_algebraic[82] = "denom_1 in component INaCa (dimensionless)"
    legend_algebraic[45] = "denom_2 in component INaCa (dimensionless)"
    legend_algebraic[83] = "denom_3 in component INaCa (mM4)"
    legend_algebraic[84] = "denom_4 in component INaCa (mM4)"
    legend_algebraic[104] = "denom_ss_1 in component INaCa (dimensionless)"
    legend_algebraic[46] = "denom_ss_2 in component INaCa (dimensionless)"
    legend_algebraic[106] = "denom_ss_3 in component INaCa (mM4)"
    legend_algebraic[108] = "denom_ss_4 in component INaCa (mM4)"
    legend_constants[32] = "gKp in component IKp (mS_per_uF)"
    legend_algebraic[47] = "Kp in component IKp (dimensionless)"
    legend_algebraic[53] = "EK in component reversal_potentials (mV)"
    legend_constants[33] = "gpCa in component IpCa (uA_per_uF)"
    legend_constants[34] = "KmpCa in component IpCa (mM)"
    legend_constants[35] = "PCab in component ICab (L_per_F_ms)"
    legend_constants[36] = "gamma_Ca_i in component ICab (dimensionless)"
    legend_constants[37] = "gamma_Ca_o in component ICab (dimensionless)"
    legend_constants[38] = "PNab in component INab (L_per_F_ms)"
    legend_algebraic[48] = "phi in component INab (dimensionless)"
    legend_constants[39] = "gClb in component IClb (mS_per_uF)"
    legend_algebraic[56] = "ECl in component reversal_potentials (mV)"
    legend_constants[40] = "gNaL in component INaL (mS_per_uF)"
    legend_states[31] = "mL in component INaL_mL_gate (dimensionless)"
    legend_states[32] = "hL in component INaL_hL_gate (dimensionless)"
    legend_algebraic[5] = "amL in component INaL_mL_gate (per_ms)"
    legend_algebraic[17] = "bmL in component INaL_mL_gate (per_ms)"
    legend_constants[41] = "tau_hL in component INaL_hL_gate (ms)"
    legend_algebraic[6] = "hL_infinity in component INaL_hL_gate (dimensionless)"
    legend_constants[42] = "prnak in component reversal_potentials (dimensionless)"
    legend_states[33] = "K_i in component K (mM)"
    legend_states[34] = "Cl_i in component Cl (mM)"
    legend_constants[82] = "gK1 in component IK1 (mS_per_uF)"
    legend_algebraic[60] = "K1 in component IK1_K1_gate (dimensionless)"
    legend_algebraic[58] = "alpha_k1 in component IK1_K1_gate (dimensionless)"
    legend_algebraic[59] = "beta_k1 in component IK1_K1_gate (dimensionless)"
    legend_algebraic[62] = "CT_Na_Cl in component CT_Na_Cl (mM_per_ms)"
    legend_constants[43] = "CT_Na_Cl_max in component CT_Na_Cl (mM_per_ms)"
    legend_algebraic[63] = "CT_K_Cl in component CT_K_Cl (mM_per_ms)"
    legend_constants[44] = "CT_K_Cl_max in component CT_K_Cl (mM_per_ms)"
    legend_constants[83] = "gKr in component IKr (mS_per_uF)"
    legend_algebraic[64] = "r in component IKr_r_gate (dimensionless)"
    legend_states[35] = "xr in component IKr_xr_gate (dimensionless)"
    legend_algebraic[7] = "xr_infinity in component IKr_xr_gate (dimensionless)"
    legend_algebraic[18] = "tau_xr in component IKr_xr_gate (ms)"
    legend_constants[45] = "gto1 in component Ito1 (mS_per_uF)"
    legend_algebraic[66] = "rto1 in component Ito1 (dimensionless)"
    legend_states[36] = "a in component Ito1_a_gate (dimensionless)"
    legend_states[37] = "i1f in component Ito1_i1f_gate (dimensionless)"
    legend_states[38] = "i1s in component Ito1_i1s_gate (dimensionless)"
    legend_algebraic[8] = "alpha_a in component Ito1_a_gate (per_ms)"
    legend_algebraic[19] = "beta_a in component Ito1_a_gate (per_ms)"
    legend_algebraic[25] = "tau_a in component Ito1_a_gate (ms)"
    legend_algebraic[29] = "a_infinity in component Ito1_a_gate (dimensionless)"
    legend_algebraic[20] = "alpha_i1f in component Ito1_i1f_gate (per_ms)"
    legend_algebraic[9] = "beta_i1f in component Ito1_i1f_gate (per_ms)"
    legend_algebraic[21] = "alpha_i1s in component Ito1_i1s_gate (per_ms)"
    legend_algebraic[10] = "beta_i1s in component Ito1_i1s_gate (per_ms)"
    legend_constants[46] = "PCl in component Ito2 (L_per_F_ms)"
    legend_constants[47] = "zCl in component Ito2 (dimensionless)"
    legend_algebraic[68] = "Ito2_max in component Ito2 (uA_per_uF)"
    legend_algebraic[69] = "KCa_ito2 in component Ito2 (dimensionless)"
    legend_constants[48] = "kCa_ito2 in component Ito2 (mM_per_ms)"
    legend_states[39] = "Irel in component Irel (mM_per_ms)"
    legend_states[40] = "i2f in component Ito2_i2f_gate (dimensionless)"
    legend_algebraic[22] = "alpha_i2f in component Ito2_i2f_gate (per_ms)"
    legend_algebraic[11] = "beta_i2f in component Ito2_i2f_gate (per_ms)"
    legend_algebraic[26] = "i2f_infinity in component Ito2_i2f_gate (dimensionless)"
    legend_constants[49] = "tau_i2f in component Ito2_i2f_gate (ms)"
    legend_algebraic[127] = "rel_infinity in component Irel (mM_per_ms)"
    legend_algebraic[126] = "tau_rel in component Irel (ms)"
    legend_constants[50] = "Krel_infinity in component Irel (mM)"
    legend_algebraic[124] = "alpha_rel in component Irel (mM_per_uA_per_uF_per_ms)"
    legend_algebraic[122] = "beta_tau in component Irel (ms)"
    legend_constants[51] = "beta_0 in component Irel (ms)"
    legend_constants[52] = "kappa in component Irel (mM_per_uA_per_uF_per_ms_per_ms)"
    legend_constants[53] = "h_rel in component Irel (dimensionless)"
    legend_constants[54] = "h_beta in component Irel (dimensionless)"
    legend_algebraic[120] = "delta_beta_CaMK in component Irel (dimensionless)"
    legend_constants[55] = "delta_beta_0 in component Irel (dimensionless)"
    legend_constants[56] = "K_beta in component Irel (mM)"
    legend_constants[57] = "Krel_tau in component Irel (mM)"
    legend_algebraic[117] = "Ca_JSR in component Ca_JSR_buffering (mM)"
    legend_algebraic[119] = "CaMK_active in component CaMK_active (dimensionless)"
    legend_algebraic[125] = "Iup in component Iup (mM_per_ms)"
    legend_constants[58] = "kmup in component Iup (mM)"
    legend_algebraic[123] = "delta_kmPLB in component Iup (mM)"
    legend_constants[59] = "delta_kmPLB_bar in component Iup (mM)"
    legend_constants[60] = "iupbar in component Iup (mM_per_ms)"
    legend_algebraic[121] = "delta_iupCaMK in component Iup (dimensionless)"
    legend_constants[61] = "delta_iupCaMK_bar in component Iup (dimensionless)"
    legend_constants[62] = "kmCaMK in component CaMK_active (mM)"
    legend_algebraic[73] = "Ileak in component Ileak (mM_per_ms)"
    legend_constants[63] = "nsrbar in component Ileak (mM)"
    legend_states[41] = "Ca_NSR in component Ca (mM)"
    legend_algebraic[118] = "Itr in component Itr (mM_per_ms)"
    legend_constants[64] = "tautr in component Itr (ms)"
    legend_states[42] = "Ca_JSR_0 in component Ca (mM)"
    legend_states[43] = "Ca_i_0 in component Ca (mM)"
    legend_states[44] = "Ca_ss_sr_0 in component Ca (mM)"
    legend_states[45] = "Ca_ss_CaL_0 in component Ca (mM)"
    legend_constants[65] = "tau_diff_ss in component Ca (ms)"
    legend_constants[66] = "tau_diff in component Ca (ms)"
    legend_algebraic[111] = "Idiff in component Ca (mM_per_ms)"
    legend_algebraic[115] = "Idiff_ss in component Ca (mM_per_ms)"
    legend_algebraic[74] = "b_myo in component Ca_buffering (mM)"
    legend_algebraic[75] = "c_myo in component Ca_buffering (mM2)"
    legend_algebraic[76] = "d_myo in component Ca_buffering (mM3)"
    legend_constants[67] = "cmdn_bar in component Ca_buffering (mM)"
    legend_constants[68] = "trpn_bar in component Ca_buffering (mM)"
    legend_constants[69] = "km_cmdn in component Ca_buffering (mM)"
    legend_constants[70] = "km_trpn in component Ca_buffering (mM)"
    legend_algebraic[88] = "b_myo1 in component Ca_ss_buffering (mM)"
    legend_algebraic[89] = "c_myo1 in component Ca_ss_buffering (mM2)"
    legend_algebraic[90] = "d_myo1 in component Ca_ss_buffering (mM3)"
    legend_algebraic[91] = "b_myo2 in component Ca_ss_buffering (mM)"
    legend_algebraic[92] = "c_myo2 in component Ca_ss_buffering (mM2)"
    legend_algebraic[93] = "d_myo2 in component Ca_ss_buffering (mM3)"
    legend_constants[71] = "BSL_max in component Ca_ss_buffering (mM)"
    legend_constants[72] = "BSR_max in component Ca_ss_buffering (mM)"
    legend_constants[73] = "Km_BSR in component Ca_ss_buffering (mM)"
    legend_constants[74] = "Km_BSL in component Ca_ss_buffering (mM)"
    legend_algebraic[114] = "b in component Ca_JSR_buffering (mM)"
    legend_algebraic[116] = "c in component Ca_JSR_buffering (mM2)"
    legend_constants[75] = "csqn_bar in component Ca_JSR_buffering (mM)"
    legend_constants[76] = "km_csqn in component Ca_JSR_buffering (mM)"
    legend_algebraic[112] = "Idiff_Na in component Na (mM_per_ms)"
    legend_states[46] = "Cl_ss in component Cl (mM)"
    legend_algebraic[72] = "Idiff_Cl in component Cl (mM_per_ms)"
    legend_states[47] = "CaMK_trap in component CaMK_active (dimensionless)"
    legend_constants[77] = "alpha_CaMK in component CaMK_active (per_ms)"
    legend_constants[78] = "beta_CaMK in component CaMK_active (per_ms)"
    legend_constants[79] = "CaMK_0 in component CaMK_active (dimensionless)"
    legend_rates[0] = "d/dt Vm in component membrane (mV)"
    legend_rates[1] = "d/dt C1 in component IKs (dimensionless)"
    legend_rates[2] = "d/dt C2 in component IKs (dimensionless)"
    legend_rates[3] = "d/dt C3 in component IKs (dimensionless)"
    legend_rates[4] = "d/dt C4 in component IKs (dimensionless)"
    legend_rates[5] = "d/dt C5 in component IKs (dimensionless)"
    legend_rates[6] = "d/dt C6 in component IKs (dimensionless)"
    legend_rates[7] = "d/dt C7 in component IKs (dimensionless)"
    legend_rates[8] = "d/dt C8 in component IKs (dimensionless)"
    legend_rates[9] = "d/dt C9 in component IKs (dimensionless)"
    legend_rates[10] = "d/dt C10 in component IKs (dimensionless)"
    legend_rates[11] = "d/dt C11 in component IKs (dimensionless)"
    legend_rates[12] = "d/dt C12 in component IKs (dimensionless)"
    legend_rates[13] = "d/dt C13 in component IKs (dimensionless)"
    legend_rates[14] = "d/dt C14 in component IKs (dimensionless)"
    legend_rates[15] = "d/dt C15 in component IKs (dimensionless)"
    legend_rates[16] = "d/dt O1 in component IKs (dimensionless)"
    legend_rates[17] = "d/dt O2 in component IKs (dimensionless)"
    legend_rates[18] = "d/dt C in component ICaL (dimensionless)"
    legend_rates[19] = "d/dt O in component ICaL (dimensionless)"
    legend_rates[20] = "d/dt C_star in component ICaL (dimensionless)"
    legend_rates[21] = "d/dt O_star in component ICaL (dimensionless)"
    legend_rates[22] = "d/dt CI in component ICaL (dimensionless)"
    legend_rates[23] = "d/dt OI in component ICaL (dimensionless)"
    legend_rates[24] = "d/dt CI_star in component ICaL (dimensionless)"
    legend_rates[25] = "d/dt OI_star in component ICaL (dimensionless)"
    legend_rates[26] = "d/dt m in component INa_m_gate (dimensionless)"
    legend_rates[27] = "d/dt h in component INa_h_gate (dimensionless)"
    legend_rates[28] = "d/dt j in component INa_j_gate (dimensionless)"
    legend_rates[31] = "d/dt mL in component INaL_mL_gate (dimensionless)"
    legend_rates[32] = "d/dt hL in component INaL_hL_gate (dimensionless)"
    legend_rates[35] = "d/dt xr in component IKr_xr_gate (dimensionless)"
    legend_rates[36] = "d/dt a in component Ito1_a_gate (dimensionless)"
    legend_rates[37] = "d/dt i1f in component Ito1_i1f_gate (dimensionless)"
    legend_rates[38] = "d/dt i1s in component Ito1_i1s_gate (dimensionless)"
    legend_rates[40] = "d/dt i2f in component Ito2_i2f_gate (dimensionless)"
    legend_rates[39] = "d/dt Irel in component Irel (mM_per_ms)"
    legend_rates[43] = "d/dt Ca_i_0 in component Ca (mM)"
    legend_rates[44] = "d/dt Ca_ss_sr_0 in component Ca (mM)"
    legend_rates[45] = "d/dt Ca_ss_CaL_0 in component Ca (mM)"
    legend_rates[41] = "d/dt Ca_NSR in component Ca (mM)"
    legend_rates[42] = "d/dt Ca_JSR_0 in component Ca (mM)"
    legend_rates[29] = "d/dt Na_i in component Na (mM)"
    legend_rates[30] = "d/dt Na_ss_sr in component Na (mM)"
    legend_rates[34] = "d/dt Cl_i in component Cl (mM)"
    legend_rates[46] = "d/dt Cl_ss in component Cl (mM)"
    legend_rates[33] = "d/dt K_i in component K (mM)"
    legend_rates[47] = "d/dt CaMK_trap in component CaMK_active (dimensionless)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 96487
    constants[1] = 310
    constants[2] = 8314
    constants[3] = 5.4
    constants[4] = 1.8
    constants[5] = 140
    constants[6] = 100
    constants[7] = 0.01
    constants[8] = 0.0011
    states[0] = -87.472528
    constants[9] = 0
    constants[10] = 1e3
    constants[11] = 0.5
    constants[12] = -80
    states[1] = 0.476653873938053
    states[2] = 0.2551771850026437
    states[3] = 0.05122852186842027
    states[4] = 0.004570874421666423
    states[5] = 0.0001529389211563687
    states[6] = 0.1328281770413747
    states[7] = 0.05333228495514583
    states[8] = 0.007137874613383642
    states[9] = 0.0003184390970637536
    states[10] = 0.01388061042363991
    states[11] = 0.003715500164470033
    states[12] = 0.0002486371465457659
    states[13] = 0.0006446803014431032
    states[14] = 8.628258026770862e-5
    states[15] = 1.122823524761588e-5
    states[16] = 1.051906959485266e-5
    states[17] = 2.372219883411999e-6
    constants[13] = 1.5552e-4
    states[18] = 0.9999613782488198
    states[19] = 2.27419494597377e-5
    states[20] = 5.936477396599124e-11
    states[21] = 1.350122566369778e-15
    states[22] = 1.587938121237188e-5
    states[23] = 3.611420243201921e-10
    states[24] = 0
    states[25] = 0
    constants[14] = 1
    constants[15] = 0.000001
    constants[16] = 1
    constants[17] = 0.341
    constants[18] = 9.075
    states[26] = 0.001022252813581797
    states[27] = 0.9913109066867
    states[28] = 0.9970771239754529
    constants[19] = 2.6
    constants[20] = 1.5
    constants[21] = 1.4
    constants[22] = 1
    constants[23] = -92
    states[29] = 6.935575
    constants[24] = 1.25e-4
    constants[25] = 4.5
    constants[26] = 0.32
    constants[27] = 0.27
    constants[28] = 12.3
    constants[29] = 87.5
    constants[30] = 0.0036
    constants[31] = 1.3
    states[30] = 6.935607
    constants[32] = 0.00276
    constants[33] = 0.0575
    constants[34] = 0.5e-3
    constants[35] = 1.995084e-7
    constants[36] = 1
    constants[37] = 0.341
    constants[38] = 0.32e-8
    constants[39] = 2.25e-4
    constants[40] = 0.0065
    states[31] = 0.001022252813581797
    states[32] = 0.3593255076983574
    constants[41] = 600
    constants[42] = 0.01833
    states[33] = 145.5689
    states[34] = 20.26842
    constants[43] = 2.46108e-5
    constants[44] = 1.77e-5
    states[35] = 1.235996442041028e-8
    constants[45] = 0.4975
    states[36] = 1.773318268499115e-5
    states[37] = 0.9979722
    states[38] = 0.9874435
    constants[46] = 9e-7
    constants[47] = -1
    constants[48] = 0.4
    states[39] = 0.00107332
    states[40] = 0.9960352
    constants[49] = 8
    constants[50] = 1
    constants[51] = 4.75
    constants[52] = 0.1125
    constants[53] = 8
    constants[54] = 10
    constants[55] = 1
    constants[56] = 0.28
    constants[57] = 0.0123
    constants[58] = 0.00092
    constants[59] = 1.7e-4
    constants[60] = 0.004375
    constants[61] = 0.75
    constants[62] = 0.15
    constants[63] = 15
    states[41] = 1.159939
    constants[64] = 25
    states[42] = 6.99469048
    states[43] = 0.013408
    states[44] = 0.02414815
    states[45] = 0.02510283
    constants[65] = 2
    constants[66] = 0.2
    constants[67] = 0.05
    constants[68] = 0.07
    constants[69] = 0.00238
    constants[70] = 0.0005
    constants[71] = 1.124
    constants[72] = 0.047
    constants[73] = 0.00087
    constants[74] = 0.0087
    constants[75] = 10
    constants[76] = 0.8
    states[46] = 20.26842
    states[47] = 0.0018861341
    constants[77] = 0.05
    constants[78] = 0.00068
    constants[79] = 0.05
    constants[80] = 0.0895380
    constants[81] = 1000.00* pi*constants[8]*constants[8]*constants[7]
    constants[82] = 0.500000*(power(constants[3]/5.40000, 1.0/2))
    constants[83] = 0.0138542*(power(constants[3]/5.40000, 1.0/2))
    constants[84] = constants[81]*0.0600000
    constants[85] = 2.00000* pi*constants[8]*constants[8]+2.00000* pi*constants[8]*constants[7]
    constants[86] = constants[85]*2.00000
    constants[87] = (1.00000*1.00000*constants[86])/(constants[0]*1.00000)
    constants[88] = constants[81]*0.678000
    constants[89] = constants[81]*0.0552000
    constants[90] = constants[81]*0.00480000
    constants[91] = constants[81]*0.0200000
    constants[92] = constants[81]*0.00200000
    constants[93] = constants[3]/(constants[3]+constants[20])
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[6] = 1.00000/(1.00000+exp((states[0]+91.0000)/6.10000))
    rates[32] = (algebraic[6]-states[32])/constants[41]
    algebraic[1] = 0.0148640*exp((0.0298770*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[13] = 0.0839860*exp((-0.0554610*states[0]*constants[0])/(constants[2]*constants[1]))
    rates[1] = -4.00000*algebraic[1]*states[1]+algebraic[13]*states[2]
    algebraic[2] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[14] = 0.0800000*exp(-states[0]/11.0000)
    rates[26] = algebraic[2]*(1.00000-states[26])-algebraic[14]*states[26]
    algebraic[3] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, 0.135000*exp((80.0000+states[0])/-6.80000)])
    algebraic[15] = custom_piecewise([greater_equal(states[0] , -40.0000), 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000))) , True, 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0])])
    rates[27] = algebraic[3]*(1.00000-states[27])-algebraic[15]*states[27]
    algebraic[4] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, ((-127140.*exp(0.244400*states[0])-6.94800e-05*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300)))])
    algebraic[16] = custom_piecewise([greater_equal(states[0] , -40.0000), (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000))) , True, (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400)))])
    rates[28] = algebraic[4]*(1.00000-states[28])-algebraic[16]*states[28]
    algebraic[5] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[17] = 0.0800000*exp(-states[0]/11.0000)
    rates[31] = algebraic[5]*(1.00000-states[31])-algebraic[17]*states[31]
    algebraic[7] = 1.00000/(1.00000+exp(-(states[0]+10.0850)/4.25000))
    algebraic[18] = 1.00000/((0.000600000*(states[0]-1.73840))/(1.00000-exp(-0.136000*(states[0]-1.73840)))+(0.000300000*(states[0]+38.3608))/(exp(0.152200*(states[0]+38.3608))-1.00000))
    rates[35] = (algebraic[7]-states[35])/algebraic[18]
    algebraic[20] = 0.0250000/(1.00000+exp((states[0]+58.0000)/5.00000))
    algebraic[9] = 1.00000/(9.79530*(1.00000+exp((states[0]+19.0000)/-9.00000)))
    rates[37] = algebraic[20]*(1.00000-states[37])-algebraic[9]*states[37]
    algebraic[21] = 1.00000/(250.000*(1.00000+exp((states[0]+60.0000)/5.00000)))
    algebraic[10] = 1.00000/(9.79530*(1.00000+exp((states[0]+19.0000)/-9.00000)))
    rates[38] = algebraic[21]*(1.00000-states[38])-algebraic[10]*states[38]
    algebraic[22] = 0.0250000/(1.00000+exp((states[0]+58.0000)/5.00000))
    algebraic[11] = 1.00000/(5.00000*(1.00000+exp((states[0]+19.0000)/-9.00000)))
    algebraic[26] = algebraic[22]/(algebraic[22]+algebraic[11])
    rates[40] = (algebraic[26]-states[40])/constants[49]
    algebraic[28] = 0.00311730*exp((-0.426250*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[24] = 0.0146010*exp((0.244650*states[0]*constants[0])/(constants[2]*constants[1]))
    rates[2] = -(3.00000*algebraic[1]+algebraic[13]+algebraic[24])*states[2]+4.00000*algebraic[1]*states[1]+2.00000*algebraic[13]*states[3]+algebraic[28]*states[6]
    rates[3] = -(2.00000*algebraic[1]+2.00000*algebraic[13]+2.00000*algebraic[24])*states[3]+3.00000*algebraic[1]*states[2]+3.00000*algebraic[13]*states[4]+algebraic[28]*states[7]
    rates[4] = -(algebraic[1]+3.00000*algebraic[13]+3.00000*algebraic[24])*states[4]+2.00000*algebraic[1]*states[3]+4.00000*algebraic[13]*states[5]+algebraic[28]*states[8]
    rates[5] = -(4.00000*algebraic[13]+4.00000*algebraic[24])*states[5]+algebraic[1]*states[4]+algebraic[28]*states[9]
    rates[6] = -(3.00000*algebraic[1]+algebraic[28])*states[6]+algebraic[13]*states[7]+algebraic[24]*states[2]
    rates[7] = -(2.00000*algebraic[1]+algebraic[13]+algebraic[24]+algebraic[28])*states[7]+3.00000*algebraic[1]*states[6]+2.00000*algebraic[13]*states[8]+2.00000*algebraic[24]*states[3]+2.00000*algebraic[28]*states[10]
    rates[8] = -(algebraic[1]+2.00000*algebraic[13]+2.00000*algebraic[24]+algebraic[28])*states[8]+2.00000*algebraic[1]*states[7]+3.00000*algebraic[13]*states[9]+3.00000*algebraic[24]*states[4]+2.00000*algebraic[28]*states[11]
    rates[9] = -(3.00000*algebraic[13]+3.00000*algebraic[24]+algebraic[28])*states[9]+algebraic[1]*states[8]+4.00000*algebraic[24]*states[5]+2.00000*algebraic[28]*states[12]
    rates[10] = -(2.00000*algebraic[1]+2.00000*algebraic[28])*states[10]+algebraic[13]*states[11]+algebraic[24]*states[7]
    rates[11] = -(algebraic[1]+algebraic[13]+algebraic[24]+2.00000*algebraic[28])*states[11]+2.00000*algebraic[1]*states[10]+2.00000*algebraic[13]*states[12]+2.00000*algebraic[24]*states[8]+3.00000*algebraic[28]*states[13]
    rates[12] = -(2.00000*algebraic[13]+2.00000*algebraic[24]+2.00000*algebraic[28])*states[12]+algebraic[1]*states[11]+3.00000*algebraic[24]*states[9]+3.00000*algebraic[28]*states[14]
    rates[13] = -(algebraic[1]+3.00000*algebraic[28])*states[13]+algebraic[13]*states[14]+algebraic[24]*states[11]
    rates[14] = -(algebraic[13]+algebraic[24]+3.00000*algebraic[28])*states[14]+algebraic[1]*states[13]+2.00000*algebraic[24]*states[12]+4.00000*algebraic[28]*states[15]
    algebraic[8] = 1.00000/(1.20890*(1.00000+exp((states[0]-18.4099)/-29.3814)))
    algebraic[19] = 3.50000/(1.00000+exp((states[0]+100.000)/29.3814))
    algebraic[25] = 1.00000/(algebraic[8]+algebraic[19])
    algebraic[29] = 1.00000/(1.00000+exp((states[0]+9.43700)/-7.13300))
    rates[36] = (algebraic[29]-states[36])/algebraic[25]
    algebraic[31] = 0.0773200*exp((-0.0647260*states[0]*constants[0])/(constants[2]*constants[1]))
    rates[15] = -(4.00000*algebraic[28]+constants[80])*states[15]+algebraic[24]*states[14]+algebraic[31]*states[16]
    algebraic[33] = 0.794050*exp((-0.0801740*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[35] = 0.586380*exp((0.282060*states[0]*constants[0])/(constants[2]*constants[1]))
    rates[16] = -(algebraic[31]+algebraic[35])*states[16]+algebraic[33]*states[17]+constants[80]*states[15]
    rates[17] = -algebraic[33]*states[17]+algebraic[35]*states[16]
    algebraic[56] = ((-constants[2]*constants[1])/constants[0])*log(constants[6]/states[34])
    algebraic[57] = constants[39]*(states[0]-algebraic[56])
    algebraic[50] = ((constants[2]*constants[1])/constants[0])*log(constants[5]/states[29])
    algebraic[62] = (constants[43]*(power(algebraic[50]-algebraic[56], 4.00000)))/(power(algebraic[50]-algebraic[56], 4.00000)+power(87.8251, 4.00000))
    algebraic[53] = ((constants[2]*constants[1])/constants[0])*log(constants[3]/states[33])
    algebraic[63] = (constants[44]*(algebraic[53]-algebraic[56]))/((algebraic[53]+87.8251)-algebraic[56])
    algebraic[72] = (states[46]-states[34])/constants[66]
    rates[34] = -((algebraic[57]*constants[87])/(-1.00000*constants[88])-(algebraic[62]+algebraic[63]+(algebraic[72]*constants[91])/constants[88]))
    algebraic[68] = (((constants[46]*(power(constants[47], 2.00000))*states[0]*(power(constants[0], 2.00000)))/(constants[2]*constants[1]))*(states[34]-constants[6]*exp((states[0]*constants[0])/(constants[2]*constants[1]))))/(1.00000-exp((states[0]*constants[0])/(constants[2]*constants[1])))
    algebraic[69] = 1.00000-1.00000/(1.00000+power(states[39]/constants[48], 2.00000))
    algebraic[70] = algebraic[68]*states[40]*algebraic[69]
    rates[46] = -((algebraic[70]*constants[87])/(-1.00000*constants[91])+algebraic[72])
    algebraic[0] = floor(voi/constants[10])*constants[10]
    algebraic[12] = custom_piecewise([greater_equal(voi-algebraic[0] , constants[9]) & less_equal(voi-algebraic[0] , constants[9]+constants[11]), constants[12] , True, 0.00000])
    algebraic[58] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[53])-59.2150)))
    algebraic[59] = (0.491240*exp(0.0803200*((states[0]-algebraic[53])+5.47600))+exp(0.0617500*((states[0]-algebraic[53])-594.310)))/(1.00000+exp(-0.514300*((states[0]-algebraic[53])+4.75300)))
    algebraic[60] = algebraic[58]/(algebraic[58]+algebraic[59])
    algebraic[61] = constants[82]*algebraic[60]*(states[0]-algebraic[53])
    algebraic[47] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000))
    algebraic[54] = constants[32]*algebraic[47]*(states[0]-algebraic[53])
    algebraic[74] = ((constants[67]+constants[68])-states[43])+constants[70]+constants[69]
    algebraic[75] = (constants[70]*constants[69]-states[43]*(constants[70]+constants[69]))+constants[68]*constants[69]+constants[67]*constants[70]
    algebraic[76] = -constants[70]*constants[69]*states[43]
    algebraic[77] = ((2.00000*(power(power(algebraic[74], 2.00000)-3.00000*algebraic[75], 1.0/2)))/3.00000)*cos(arccos(((9.00000*algebraic[74]*algebraic[75]-2.00000*(power(algebraic[74], 3.00000)))-27.0000*algebraic[76])/(2.00000*(power(power(algebraic[74], 2.00000)-3.00000*algebraic[75], 1.50000))))/3.00000)-algebraic[74]/3.00000
    algebraic[78] = 0.0826000*(1.00000+0.600000/(1.00000+power(3.80000e-05/algebraic[77], 1.40000)))
    algebraic[23] = states[16]+states[17]
    algebraic[55] = ((constants[2]*constants[1])/constants[0])*log((constants[3]+constants[42]*constants[5])/(states[33]+constants[42]*states[29]))
    algebraic[79] = algebraic[78]*algebraic[23]*(states[0]-algebraic[55])
    algebraic[64] = 1.00000/(1.00000+exp((states[0]+10.0000)/15.4000))
    algebraic[65] = constants[83]*states[35]*algebraic[64]*(states[0]-algebraic[53])
    algebraic[41] = (constants[22]*(states[0]-constants[23])*constants[0])/(constants[2]*constants[1])
    algebraic[42] = 1.00000/(1.00000+exp(-algebraic[41]))
    algebraic[43] = power(states[29]/(states[29]+constants[19]), 3.00000)
    algebraic[44] = constants[21]*algebraic[42]*constants[93]*algebraic[43]
    algebraic[66] = exp(states[0]/550.000)
    algebraic[67] = constants[45]*(power(states[36], 3.00000))*states[37]*states[38]*algebraic[66]*(states[0]-algebraic[53])
    rates[33] = -((((algebraic[79]+algebraic[65]+algebraic[61]+algebraic[67]+algebraic[54]+algebraic[12])-2.00000*algebraic[44])*constants[87])/constants[88]-algebraic[63])
    algebraic[27] = 0.590000+(0.800000*exp(0.0520000*(states[0]+13.0000)))/(1.00000+exp(0.132000*(states[0]+13.0000)))
    algebraic[30] = 1.00000/(1.00000+exp(-(states[0]-13.5600)/9.45000))
    algebraic[32] = algebraic[30]/algebraic[27]
    algebraic[34] = (1.00000-algebraic[30])/algebraic[27]
    algebraic[88] = ((constants[71]+constants[72])-states[45])+constants[73]+constants[74]
    algebraic[89] = (constants[74]*constants[73]-states[45]*(constants[73]+constants[74]))+constants[72]*constants[74]+constants[71]*constants[73]
    algebraic[90] = -constants[73]*constants[74]*states[45]
    algebraic[94] = ((2.00000*(power(power(algebraic[88], 2.00000)-3.00000*algebraic[89], 1.0/2)))/3.00000)*cos(arccos(((9.00000*algebraic[88]*algebraic[89]-2.00000*(power(algebraic[88], 3.00000)))-27.0000*algebraic[90])/(2.00000*(power(power(algebraic[88], 2.00000)-3.00000*algebraic[89], 1.50000))))/3.00000)-algebraic[88]/3.00000
    algebraic[105] = 3.00000/(1.00000+power(0.00300000/algebraic[94], 4.00000))
    algebraic[37] = 1.00000/(1.00000/(24.8280*(1.00000+exp((states[0]+49.1000)/10.3490)))+1.00000/(30.5530*(1.00000+exp(-(states[0]+0.213000)/10.8070))))
    algebraic[36] = (1.00000/(1.00000+exp((states[0]+17.5000)/3.00000))+0.250000)/1.25000
    algebraic[38] = algebraic[36]/algebraic[37]
    algebraic[39] = (1.00000-algebraic[36])/algebraic[37]
    rates[18] = -(algebraic[32]+algebraic[105]+algebraic[39])*states[18]+algebraic[34]*states[19]+constants[14]*states[20]+algebraic[38]*states[22]
    rates[19] = -(algebraic[34]+algebraic[105]+algebraic[39])*states[19]+algebraic[32]*states[18]+constants[14]*states[21]+algebraic[38]*states[23]
    algebraic[95] = 25.0000-17.5000/(1.00000+power(0.00300000/algebraic[94], 4.00000))
    algebraic[97] = 1.00000/(algebraic[95]*(1.00000+exp(-(states[0]+0.213000)/10.8070)))
    algebraic[99] = 1.00000/(1.00000/(24.8280*(1.00000+exp((states[0]+49.1000)/10.3490)))+algebraic[97])
    algebraic[40] = (1.00000/(1.00000+exp((states[0]+17.5000)/3.00000))+0.000100000)/1.00010
    algebraic[101] = algebraic[40]/algebraic[99]
    algebraic[103] = (1.00000-algebraic[40])/algebraic[99]
    rates[20] = -(algebraic[32]+constants[14]+algebraic[103])*states[20]+algebraic[105]*states[18]+algebraic[34]*states[21]+algebraic[101]*states[24]
    rates[21] = -(algebraic[34]+constants[14]+algebraic[103])*states[21]+algebraic[105]*states[19]+algebraic[32]*states[20]+algebraic[101]*states[25]
    algebraic[107] = (constants[15]*algebraic[38]*algebraic[103]*algebraic[105])/(algebraic[39]*algebraic[101]*constants[14])
    rates[22] = -(algebraic[32]+algebraic[107]+algebraic[38])*states[22]+algebraic[39]*states[18]+constants[15]*states[24]+algebraic[34]*states[23]
    rates[23] = -(algebraic[34]+algebraic[107]+algebraic[38])*states[23]+algebraic[39]*states[19]+constants[15]*states[25]+algebraic[32]*states[22]
    rates[24] = -(algebraic[32]+constants[15]+algebraic[101])*states[24]+algebraic[107]*states[22]+algebraic[103]*states[20]+algebraic[34]*states[25]
    rates[25] = -(algebraic[34]+constants[15]+algebraic[101])*states[25]+algebraic[107]*states[23]+algebraic[103]*states[21]+algebraic[32]*states[24]
    algebraic[51] = constants[18]*(power(states[26], 3.00000))*states[27]*states[28]*(states[0]-algebraic[50])
    algebraic[81] = 0.800000*constants[25]*((power(states[29], 3.00000))*constants[4]*exp((constants[27]*states[0]*constants[0])/(constants[2]*constants[1]))-(power(constants[5], 3.00000))*algebraic[77]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1])))
    algebraic[82] = 1.00000+power(constants[24]/algebraic[77], 2.00000)
    algebraic[45] = 1.00000+constants[26]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[83] = constants[31]*(power(states[29], 3.00000))+(power(constants[29], 3.00000))*algebraic[77]+(power(constants[28], 3.00000))*constants[4]*(1.00000+algebraic[77]/constants[30])
    algebraic[84] = constants[30]*(power(constants[5], 3.00000))*(1.00000+power(states[29]/constants[28], 3.00000))+(power(states[29], 3.00000))*constants[4]+(power(constants[5], 3.00000))*algebraic[77]
    algebraic[85] = algebraic[81]/(algebraic[82]*algebraic[45]*(algebraic[83]+algebraic[84]))
    algebraic[52] = constants[40]*(power(states[31], 3.00000))*states[32]*(states[0]-algebraic[50])
    algebraic[48] = (constants[0]*states[0])/(constants[2]*constants[1])
    algebraic[49] = (constants[0]*constants[38]*algebraic[48]*(states[29]*exp(algebraic[48])-constants[5]))/(exp(algebraic[48])-1.00000)
    algebraic[112] = (states[30]-states[29])/constants[66]
    rates[29] = -(((3.00000*algebraic[85]+3.00000*algebraic[44]+algebraic[51]+algebraic[52]+algebraic[49])*constants[87])/constants[88]-(algebraic[62]+(algebraic[112]*constants[91])/constants[88]))
    algebraic[91] = ((constants[71]+constants[72])-states[44])+constants[73]+constants[74]
    algebraic[92] = (constants[74]*constants[73]-states[44]*(constants[73]+constants[74]))+constants[72]*constants[74]+constants[71]*constants[73]
    algebraic[93] = -constants[73]*constants[74]*states[44]
    algebraic[100] = ((2.00000*(power(power(algebraic[91], 2.00000)-3.00000*algebraic[92], 1.0/2)))/3.00000)*cos(arccos(((9.00000*algebraic[91]*algebraic[92]-2.00000*(power(algebraic[91], 3.00000)))-27.0000*algebraic[93])/(2.00000*(power(power(algebraic[91], 2.00000)-3.00000*algebraic[92], 1.50000))))/3.00000)-algebraic[91]/3.00000
    algebraic[102] = 0.200000*constants[25]*((power(states[30], 3.00000))*constants[4]*exp((constants[27]*states[0]*constants[0])/(constants[2]*constants[1]))-(power(constants[5], 3.00000))*algebraic[100]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1])))
    algebraic[104] = 1.00000+power(constants[24]/algebraic[100], 2.00000)
    algebraic[46] = 1.00000+constants[26]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[106] = constants[31]*(power(states[30], 3.00000))+(power(constants[29], 3.00000))*algebraic[100]+(power(constants[28], 3.00000))*constants[4]*(1.00000+algebraic[100]/constants[30])
    algebraic[108] = constants[30]*(power(constants[5], 3.00000))*(1.00000+power(states[30]/constants[28], 3.00000))+(power(states[30], 3.00000))*constants[4]+(power(constants[5], 3.00000))*algebraic[100]
    algebraic[109] = algebraic[102]/(algebraic[104]*algebraic[46]*(algebraic[106]+algebraic[108]))
    rates[30] = -((3.00000*algebraic[109]*constants[87])/constants[91]+algebraic[112])
    algebraic[96] = (((constants[13]*4.00000*states[0]*(power(constants[0], 2.00000)))/(constants[2]*constants[1]))*(constants[16]*algebraic[94]*exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-constants[17]*constants[4]))/(exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-1.00000)
    algebraic[98] = algebraic[96]*(states[19]+states[21])
    algebraic[86] = (constants[33]*algebraic[77])/(constants[34]+algebraic[77])
    algebraic[87] = (((constants[35]*4.00000*states[0]*(power(constants[0], 2.00000)))/(constants[2]*constants[1]))*(constants[36]*algebraic[77]*exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-constants[37]*constants[4]))/(exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-1.00000)
    algebraic[110] = (algebraic[98]+algebraic[87]+algebraic[86])-2.00000*(algebraic[85]+algebraic[109])
    algebraic[113] = algebraic[51]+3.00000*(algebraic[85]+algebraic[109])+3.00000*algebraic[44]+algebraic[52]+algebraic[49]
    algebraic[80] = algebraic[65]+algebraic[79]+algebraic[61]+algebraic[54]+-2.00000*algebraic[44]+algebraic[67]+algebraic[12]
    algebraic[71] = algebraic[57]+algebraic[70]
    rates[0] = -(algebraic[113]+algebraic[80]+algebraic[110]+algebraic[71])
    algebraic[111] = (algebraic[100]-algebraic[77])/constants[66]
    algebraic[115] = (algebraic[100]-algebraic[94])/constants[65]
    rates[44] = -((algebraic[111]+algebraic[115])-((2.00000*algebraic[109]*constants[87])/(2.00000*constants[91])+(states[39]*constants[90])/constants[91]))
    rates[45] = -((algebraic[98]*constants[87])/(2.00000*constants[92])-(algebraic[115]*constants[91])/constants[92])
    algebraic[114] = (constants[75]+constants[76])-states[42]
    algebraic[116] = states[42]*constants[76]
    algebraic[117] = -algebraic[114]/2.00000+(power(power(algebraic[114], 2.00000)+4.00000*algebraic[116], 1.0/2))/2.00000
    algebraic[118] = (states[41]-algebraic[117])/constants[64]
    rates[42] = algebraic[118]-states[39]
    algebraic[119] = (constants[79]*(1.00000-states[47])*1.00000)/(1.00000+constants[62]/algebraic[100])
    rates[47] = constants[77]*algebraic[119]*(algebraic[119]-states[47])-constants[78]*states[47]
    algebraic[123] = (constants[59]*algebraic[119]*1.00000)/(constants[62]+algebraic[119]*1.00000)
    algebraic[121] = (constants[61]*algebraic[119]*1.00000)/(constants[62]+algebraic[119]*1.00000)
    algebraic[125] = ((algebraic[121]+1.00000)*constants[60]*algebraic[77])/((algebraic[77]+constants[58])-algebraic[123])
    algebraic[73] = (0.00437500/constants[63])*states[41]
    rates[43] = ((-((algebraic[87]+algebraic[86])-2.00000*algebraic[85])*constants[87])/(2.00000*constants[88])+((algebraic[125]-algebraic[73])*constants[89])/constants[88])-(algebraic[111]*constants[91])/constants[88]
    rates[41] = algebraic[125]-(algebraic[73]+(algebraic[118]*constants[90])/constants[89])
    algebraic[120] = constants[55]/(1.00000+power(constants[56]/(1.00000*algebraic[119]), constants[54]))
    algebraic[122] = constants[51]*(1.00000+algebraic[120])
    algebraic[124] = algebraic[122]*constants[52]
    algebraic[127] = (algebraic[98]*algebraic[124])/(1.00000+power(constants[50]/algebraic[117], constants[53]))
    algebraic[126] = algebraic[122]/(1.00000+constants[57]/algebraic[117])
    rates[39] = -(algebraic[127]+states[39])/algebraic[126]
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[6] = 1.00000/(1.00000+exp((states[0]+91.0000)/6.10000))
    algebraic[1] = 0.0148640*exp((0.0298770*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[13] = 0.0839860*exp((-0.0554610*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[2] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[14] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[3] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, 0.135000*exp((80.0000+states[0])/-6.80000)])
    algebraic[15] = custom_piecewise([greater_equal(states[0] , -40.0000), 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000))) , True, 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0])])
    algebraic[4] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, ((-127140.*exp(0.244400*states[0])-6.94800e-05*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300)))])
    algebraic[16] = custom_piecewise([greater_equal(states[0] , -40.0000), (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000))) , True, (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400)))])
    algebraic[5] = (0.320000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[17] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[7] = 1.00000/(1.00000+exp(-(states[0]+10.0850)/4.25000))
    algebraic[18] = 1.00000/((0.000600000*(states[0]-1.73840))/(1.00000-exp(-0.136000*(states[0]-1.73840)))+(0.000300000*(states[0]+38.3608))/(exp(0.152200*(states[0]+38.3608))-1.00000))
    algebraic[20] = 0.0250000/(1.00000+exp((states[0]+58.0000)/5.00000))
    algebraic[9] = 1.00000/(9.79530*(1.00000+exp((states[0]+19.0000)/-9.00000)))
    algebraic[21] = 1.00000/(250.000*(1.00000+exp((states[0]+60.0000)/5.00000)))
    algebraic[10] = 1.00000/(9.79530*(1.00000+exp((states[0]+19.0000)/-9.00000)))
    algebraic[22] = 0.0250000/(1.00000+exp((states[0]+58.0000)/5.00000))
    algebraic[11] = 1.00000/(5.00000*(1.00000+exp((states[0]+19.0000)/-9.00000)))
    algebraic[26] = algebraic[22]/(algebraic[22]+algebraic[11])
    algebraic[28] = 0.00311730*exp((-0.426250*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[24] = 0.0146010*exp((0.244650*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[8] = 1.00000/(1.20890*(1.00000+exp((states[0]-18.4099)/-29.3814)))
    algebraic[19] = 3.50000/(1.00000+exp((states[0]+100.000)/29.3814))
    algebraic[25] = 1.00000/(algebraic[8]+algebraic[19])
    algebraic[29] = 1.00000/(1.00000+exp((states[0]+9.43700)/-7.13300))
    algebraic[31] = 0.0773200*exp((-0.0647260*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[33] = 0.794050*exp((-0.0801740*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[35] = 0.586380*exp((0.282060*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[56] = ((-constants[2]*constants[1])/constants[0])*log(constants[6]/states[34])
    algebraic[57] = constants[39]*(states[0]-algebraic[56])
    algebraic[50] = ((constants[2]*constants[1])/constants[0])*log(constants[5]/states[29])
    algebraic[62] = (constants[43]*(power(algebraic[50]-algebraic[56], 4.00000)))/(power(algebraic[50]-algebraic[56], 4.00000)+power(87.8251, 4.00000))
    algebraic[53] = ((constants[2]*constants[1])/constants[0])*log(constants[3]/states[33])
    algebraic[63] = (constants[44]*(algebraic[53]-algebraic[56]))/((algebraic[53]+87.8251)-algebraic[56])
    algebraic[72] = (states[46]-states[34])/constants[66]
    algebraic[68] = (((constants[46]*(power(constants[47], 2.00000))*states[0]*(power(constants[0], 2.00000)))/(constants[2]*constants[1]))*(states[34]-constants[6]*exp((states[0]*constants[0])/(constants[2]*constants[1]))))/(1.00000-exp((states[0]*constants[0])/(constants[2]*constants[1])))
    algebraic[69] = 1.00000-1.00000/(1.00000+power(states[39]/constants[48], 2.00000))
    algebraic[70] = algebraic[68]*states[40]*algebraic[69]
    algebraic[0] = floor(voi/constants[10])*constants[10]
    algebraic[12] = custom_piecewise([greater_equal(voi-algebraic[0] , constants[9]) & less_equal(voi-algebraic[0] , constants[9]+constants[11]), constants[12] , True, 0.00000])
    algebraic[58] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[53])-59.2150)))
    algebraic[59] = (0.491240*exp(0.0803200*((states[0]-algebraic[53])+5.47600))+exp(0.0617500*((states[0]-algebraic[53])-594.310)))/(1.00000+exp(-0.514300*((states[0]-algebraic[53])+4.75300)))
    algebraic[60] = algebraic[58]/(algebraic[58]+algebraic[59])
    algebraic[61] = constants[82]*algebraic[60]*(states[0]-algebraic[53])
    algebraic[47] = 1.00000/(1.00000+exp((7.48800-states[0])/5.98000))
    algebraic[54] = constants[32]*algebraic[47]*(states[0]-algebraic[53])
    algebraic[74] = ((constants[67]+constants[68])-states[43])+constants[70]+constants[69]
    algebraic[75] = (constants[70]*constants[69]-states[43]*(constants[70]+constants[69]))+constants[68]*constants[69]+constants[67]*constants[70]
    algebraic[76] = -constants[70]*constants[69]*states[43]
    algebraic[77] = ((2.00000*(power(power(algebraic[74], 2.00000)-3.00000*algebraic[75], 1.0/2)))/3.00000)*cos(arccos(((9.00000*algebraic[74]*algebraic[75]-2.00000*(power(algebraic[74], 3.00000)))-27.0000*algebraic[76])/(2.00000*(power(power(algebraic[74], 2.00000)-3.00000*algebraic[75], 1.50000))))/3.00000)-algebraic[74]/3.00000
    algebraic[78] = 0.0826000*(1.00000+0.600000/(1.00000+power(3.80000e-05/algebraic[77], 1.40000)))
    algebraic[23] = states[16]+states[17]
    algebraic[55] = ((constants[2]*constants[1])/constants[0])*log((constants[3]+constants[42]*constants[5])/(states[33]+constants[42]*states[29]))
    algebraic[79] = algebraic[78]*algebraic[23]*(states[0]-algebraic[55])
    algebraic[64] = 1.00000/(1.00000+exp((states[0]+10.0000)/15.4000))
    algebraic[65] = constants[83]*states[35]*algebraic[64]*(states[0]-algebraic[53])
    algebraic[41] = (constants[22]*(states[0]-constants[23])*constants[0])/(constants[2]*constants[1])
    algebraic[42] = 1.00000/(1.00000+exp(-algebraic[41]))
    algebraic[43] = power(states[29]/(states[29]+constants[19]), 3.00000)
    algebraic[44] = constants[21]*algebraic[42]*constants[93]*algebraic[43]
    algebraic[66] = exp(states[0]/550.000)
    algebraic[67] = constants[45]*(power(states[36], 3.00000))*states[37]*states[38]*algebraic[66]*(states[0]-algebraic[53])
    algebraic[27] = 0.590000+(0.800000*exp(0.0520000*(states[0]+13.0000)))/(1.00000+exp(0.132000*(states[0]+13.0000)))
    algebraic[30] = 1.00000/(1.00000+exp(-(states[0]-13.5600)/9.45000))
    algebraic[32] = algebraic[30]/algebraic[27]
    algebraic[34] = (1.00000-algebraic[30])/algebraic[27]
    algebraic[88] = ((constants[71]+constants[72])-states[45])+constants[73]+constants[74]
    algebraic[89] = (constants[74]*constants[73]-states[45]*(constants[73]+constants[74]))+constants[72]*constants[74]+constants[71]*constants[73]
    algebraic[90] = -constants[73]*constants[74]*states[45]
    algebraic[94] = ((2.00000*(power(power(algebraic[88], 2.00000)-3.00000*algebraic[89], 1.0/2)))/3.00000)*cos(arccos(((9.00000*algebraic[88]*algebraic[89]-2.00000*(power(algebraic[88], 3.00000)))-27.0000*algebraic[90])/(2.00000*(power(power(algebraic[88], 2.00000)-3.00000*algebraic[89], 1.50000))))/3.00000)-algebraic[88]/3.00000
    algebraic[105] = 3.00000/(1.00000+power(0.00300000/algebraic[94], 4.00000))
    algebraic[37] = 1.00000/(1.00000/(24.8280*(1.00000+exp((states[0]+49.1000)/10.3490)))+1.00000/(30.5530*(1.00000+exp(-(states[0]+0.213000)/10.8070))))
    algebraic[36] = (1.00000/(1.00000+exp((states[0]+17.5000)/3.00000))+0.250000)/1.25000
    algebraic[38] = algebraic[36]/algebraic[37]
    algebraic[39] = (1.00000-algebraic[36])/algebraic[37]
    algebraic[95] = 25.0000-17.5000/(1.00000+power(0.00300000/algebraic[94], 4.00000))
    algebraic[97] = 1.00000/(algebraic[95]*(1.00000+exp(-(states[0]+0.213000)/10.8070)))
    algebraic[99] = 1.00000/(1.00000/(24.8280*(1.00000+exp((states[0]+49.1000)/10.3490)))+algebraic[97])
    algebraic[40] = (1.00000/(1.00000+exp((states[0]+17.5000)/3.00000))+0.000100000)/1.00010
    algebraic[101] = algebraic[40]/algebraic[99]
    algebraic[103] = (1.00000-algebraic[40])/algebraic[99]
    algebraic[107] = (constants[15]*algebraic[38]*algebraic[103]*algebraic[105])/(algebraic[39]*algebraic[101]*constants[14])
    algebraic[51] = constants[18]*(power(states[26], 3.00000))*states[27]*states[28]*(states[0]-algebraic[50])
    algebraic[81] = 0.800000*constants[25]*((power(states[29], 3.00000))*constants[4]*exp((constants[27]*states[0]*constants[0])/(constants[2]*constants[1]))-(power(constants[5], 3.00000))*algebraic[77]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1])))
    algebraic[82] = 1.00000+power(constants[24]/algebraic[77], 2.00000)
    algebraic[45] = 1.00000+constants[26]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[83] = constants[31]*(power(states[29], 3.00000))+(power(constants[29], 3.00000))*algebraic[77]+(power(constants[28], 3.00000))*constants[4]*(1.00000+algebraic[77]/constants[30])
    algebraic[84] = constants[30]*(power(constants[5], 3.00000))*(1.00000+power(states[29]/constants[28], 3.00000))+(power(states[29], 3.00000))*constants[4]+(power(constants[5], 3.00000))*algebraic[77]
    algebraic[85] = algebraic[81]/(algebraic[82]*algebraic[45]*(algebraic[83]+algebraic[84]))
    algebraic[52] = constants[40]*(power(states[31], 3.00000))*states[32]*(states[0]-algebraic[50])
    algebraic[48] = (constants[0]*states[0])/(constants[2]*constants[1])
    algebraic[49] = (constants[0]*constants[38]*algebraic[48]*(states[29]*exp(algebraic[48])-constants[5]))/(exp(algebraic[48])-1.00000)
    algebraic[112] = (states[30]-states[29])/constants[66]
    algebraic[91] = ((constants[71]+constants[72])-states[44])+constants[73]+constants[74]
    algebraic[92] = (constants[74]*constants[73]-states[44]*(constants[73]+constants[74]))+constants[72]*constants[74]+constants[71]*constants[73]
    algebraic[93] = -constants[73]*constants[74]*states[44]
    algebraic[100] = ((2.00000*(power(power(algebraic[91], 2.00000)-3.00000*algebraic[92], 1.0/2)))/3.00000)*cos(arccos(((9.00000*algebraic[91]*algebraic[92]-2.00000*(power(algebraic[91], 3.00000)))-27.0000*algebraic[93])/(2.00000*(power(power(algebraic[91], 2.00000)-3.00000*algebraic[92], 1.50000))))/3.00000)-algebraic[91]/3.00000
    algebraic[102] = 0.200000*constants[25]*((power(states[30], 3.00000))*constants[4]*exp((constants[27]*states[0]*constants[0])/(constants[2]*constants[1]))-(power(constants[5], 3.00000))*algebraic[100]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1])))
    algebraic[104] = 1.00000+power(constants[24]/algebraic[100], 2.00000)
    algebraic[46] = 1.00000+constants[26]*exp(((constants[27]-1.00000)*states[0]*constants[0])/(constants[2]*constants[1]))
    algebraic[106] = constants[31]*(power(states[30], 3.00000))+(power(constants[29], 3.00000))*algebraic[100]+(power(constants[28], 3.00000))*constants[4]*(1.00000+algebraic[100]/constants[30])
    algebraic[108] = constants[30]*(power(constants[5], 3.00000))*(1.00000+power(states[30]/constants[28], 3.00000))+(power(states[30], 3.00000))*constants[4]+(power(constants[5], 3.00000))*algebraic[100]
    algebraic[109] = algebraic[102]/(algebraic[104]*algebraic[46]*(algebraic[106]+algebraic[108]))
    algebraic[96] = (((constants[13]*4.00000*states[0]*(power(constants[0], 2.00000)))/(constants[2]*constants[1]))*(constants[16]*algebraic[94]*exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-constants[17]*constants[4]))/(exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-1.00000)
    algebraic[98] = algebraic[96]*(states[19]+states[21])
    algebraic[86] = (constants[33]*algebraic[77])/(constants[34]+algebraic[77])
    algebraic[87] = (((constants[35]*4.00000*states[0]*(power(constants[0], 2.00000)))/(constants[2]*constants[1]))*(constants[36]*algebraic[77]*exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-constants[37]*constants[4]))/(exp((2.00000*states[0]*constants[0])/(constants[2]*constants[1]))-1.00000)
    algebraic[110] = (algebraic[98]+algebraic[87]+algebraic[86])-2.00000*(algebraic[85]+algebraic[109])
    algebraic[113] = algebraic[51]+3.00000*(algebraic[85]+algebraic[109])+3.00000*algebraic[44]+algebraic[52]+algebraic[49]
    algebraic[80] = algebraic[65]+algebraic[79]+algebraic[61]+algebraic[54]+-2.00000*algebraic[44]+algebraic[67]+algebraic[12]
    algebraic[71] = algebraic[57]+algebraic[70]
    algebraic[111] = (algebraic[100]-algebraic[77])/constants[66]
    algebraic[115] = (algebraic[100]-algebraic[94])/constants[65]
    algebraic[114] = (constants[75]+constants[76])-states[42]
    algebraic[116] = states[42]*constants[76]
    algebraic[117] = -algebraic[114]/2.00000+(power(power(algebraic[114], 2.00000)+4.00000*algebraic[116], 1.0/2))/2.00000
    algebraic[118] = (states[41]-algebraic[117])/constants[64]
    algebraic[119] = (constants[79]*(1.00000-states[47])*1.00000)/(1.00000+constants[62]/algebraic[100])
    algebraic[123] = (constants[59]*algebraic[119]*1.00000)/(constants[62]+algebraic[119]*1.00000)
    algebraic[121] = (constants[61]*algebraic[119]*1.00000)/(constants[62]+algebraic[119]*1.00000)
    algebraic[125] = ((algebraic[121]+1.00000)*constants[60]*algebraic[77])/((algebraic[77]+constants[58])-algebraic[123])
    algebraic[73] = (0.00437500/constants[63])*states[41]
    algebraic[120] = constants[55]/(1.00000+power(constants[56]/(1.00000*algebraic[119]), constants[54]))
    algebraic[122] = constants[51]*(1.00000+algebraic[120])
    algebraic[124] = algebraic[122]*constants[52]
    algebraic[127] = (algebraic[98]*algebraic[124])/(1.00000+power(constants[50]/algebraic[117], constants[53]))
    algebraic[126] = algebraic[122]/(1.00000+constants[57]/algebraic[117])
    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)