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 = 303
sizeStates = 62
sizeConstants = 177
from math import *
from numpy import *

def createLegends():
    legend_states = [""] * sizeStates
    legend_rates = [""] * sizeStates
    legend_algebraic = [""] * sizeAlgebraic
    legend_voi = ""
    legend_constants = [""] * sizeConstants
    legend_constants[0] = "kappa_leak in component BG_parameters (fmol_per_sec)"
    legend_constants[1] = "kappa_R_TRPNCa in component BG_parameters (fmol_per_sec)"
    legend_constants[2] = "kappa_R_BU in component BG_parameters (fmol_per_sec)"
    legend_constants[3] = "kappa_R_UW in component BG_parameters (fmol_per_sec)"
    legend_constants[4] = "kappa_R_WS in component BG_parameters (fmol_per_sec)"
    legend_constants[5] = "kappa_R_SU in component BG_parameters (fmol_per_sec)"
    legend_constants[6] = "kappa_diadDf in component BG_parameters (fmol_per_sec)"
    legend_constants[7] = "kappa_LCC_Ca1 in component BG_parameters (fmol_per_sec)"
    legend_constants[8] = "kappa_LCC_Ca2 in component BG_parameters (fmol_per_sec)"
    legend_constants[9] = "kappa_d000 in component BG_parameters (fmol_per_sec)"
    legend_constants[10] = "kappa_d010 in component BG_parameters (fmol_per_sec)"
    legend_constants[11] = "kappa_d020 in component BG_parameters (fmol_per_sec)"
    legend_constants[12] = "kappa_d001 in component BG_parameters (fmol_per_sec)"
    legend_constants[13] = "kappa_d011 in component BG_parameters (fmol_per_sec)"
    legend_constants[14] = "kappa_d021 in component BG_parameters (fmol_per_sec)"
    legend_constants[15] = "kappa_f1_000 in component BG_parameters (fmol_per_sec)"
    legend_constants[16] = "kappa_f1_100 in component BG_parameters (fmol_per_sec)"
    legend_constants[17] = "kappa_f1_001 in component BG_parameters (fmol_per_sec)"
    legend_constants[18] = "kappa_f1_101 in component BG_parameters (fmol_per_sec)"
    legend_constants[19] = "kappa_f2_000 in component BG_parameters (fmol_per_sec)"
    legend_constants[20] = "kappa_f2_100 in component BG_parameters (fmol_per_sec)"
    legend_constants[21] = "kappa_f2_001 in component BG_parameters (fmol_per_sec)"
    legend_constants[22] = "kappa_f2_101 in component BG_parameters (fmol_per_sec)"
    legend_constants[23] = "kappa_f3_010 in component BG_parameters (fmol_per_sec)"
    legend_constants[24] = "kappa_f3_110 in component BG_parameters (fmol_per_sec)"
    legend_constants[25] = "kappa_f3_011 in component BG_parameters (fmol_per_sec)"
    legend_constants[26] = "kappa_f3_111 in component BG_parameters (fmol_per_sec)"
    legend_constants[27] = "kappa_fCa000 in component BG_parameters (fmol_per_sec)"
    legend_constants[28] = "kappa_fCa100 in component BG_parameters (fmol_per_sec)"
    legend_constants[29] = "kappa_fCa010 in component BG_parameters (fmol_per_sec)"
    legend_constants[30] = "kappa_fCa110 in component BG_parameters (fmol_per_sec)"
    legend_constants[31] = "kappa_fCa020 in component BG_parameters (fmol_per_sec)"
    legend_constants[32] = "kappa_fCa120 in component BG_parameters (fmol_per_sec)"
    legend_constants[33] = "kappa_1_NCX in component BG_parameters (fmol_per_sec)"
    legend_constants[34] = "kappa_2_NCX in component BG_parameters (fmol_per_sec)"
    legend_constants[35] = "kappa_3_NCX in component BG_parameters (fmol_per_sec)"
    legend_constants[36] = "kappa_4_NCX in component BG_parameters (fmol_per_sec)"
    legend_constants[37] = "kappa_5_NCX in component BG_parameters (fmol_per_sec)"
    legend_constants[38] = "kappa_6_NCX in component BG_parameters (fmol_per_sec)"
    legend_constants[39] = "kappa_pCa_R1 in component BG_parameters (fmol_per_sec)"
    legend_constants[40] = "kappa_pCa_R2 in component BG_parameters (fmol_per_sec)"
    legend_constants[41] = "kappa_PLBph1 in component BG_parameters (fmol_per_sec)"
    legend_constants[42] = "kappa_PLBph2 in component BG_parameters (fmol_per_sec)"
    legend_constants[43] = "kappa_PLBd1 in component BG_parameters (fmol_per_sec)"
    legend_constants[44] = "kappa_PLBd2 in component BG_parameters (fmol_per_sec)"
    legend_constants[45] = "kappa_Inh in component BG_parameters (fmol_per_sec)"
    legend_constants[46] = "kappa_RyR in component BG_parameters (fmol_per_sec)"
    legend_constants[47] = "kappa_OC in component BG_parameters (fmol_per_sec)"
    legend_constants[48] = "kappa_CCI in component BG_parameters (fmol_per_sec)"
    legend_constants[49] = "kappa_CII in component BG_parameters (fmol_per_sec)"
    legend_constants[50] = "kappa_IO in component BG_parameters (fmol_per_sec)"
    legend_constants[51] = "kappa_SERCA_R1_2 in component BG_parameters (fmol_per_sec)"
    legend_constants[52] = "kappa_SERCA_R2_4 in component BG_parameters (fmol_per_sec)"
    legend_constants[53] = "kappa_SERCA_R2_2a in component BG_parameters (fmol_per_sec)"
    legend_constants[54] = "kappa_SERCA_R4_5 in component BG_parameters (fmol_per_sec)"
    legend_constants[55] = "kappa_SERCA_R5_6 in component BG_parameters (fmol_per_sec)"
    legend_constants[56] = "kappa_SERCA_R6_8 in component BG_parameters (fmol_per_sec)"
    legend_constants[57] = "kappa_SERCA_R8_9 in component BG_parameters (fmol_per_sec)"
    legend_constants[58] = "kappa_SERCA_R9_10 in component BG_parameters (fmol_per_sec)"
    legend_constants[59] = "kappa_SERCA_R10_1 in component BG_parameters (fmol_per_sec)"
    legend_constants[60] = "K_Ca_SR in component BG_parameters (per_fmol)"
    legend_constants[61] = "K_Ca_i in component BG_parameters (per_fmol)"
    legend_constants[62] = "K_TRPN in component BG_parameters (per_fmol)"
    legend_constants[63] = "K_Ca_TRPN in component BG_parameters (per_fmol)"
    legend_constants[64] = "K_B_XB in component BG_parameters (per_fmol)"
    legend_constants[65] = "K_U_XB in component BG_parameters (per_fmol)"
    legend_constants[66] = "K_W_XB in component BG_parameters (per_fmol)"
    legend_constants[67] = "K_S_XB in component BG_parameters (per_fmol)"
    legend_constants[68] = "K_Ca_D in component BG_parameters (per_fmol)"
    legend_constants[69] = "K_Ca_o in component BG_parameters (per_fmol)"
    legend_constants[70] = "K_000_LCC in component BG_parameters (per_fmol)"
    legend_constants[71] = "K_010_LCC in component BG_parameters (per_fmol)"
    legend_constants[72] = "K_020_LCC in component BG_parameters (per_fmol)"
    legend_constants[73] = "K_100_LCC in component BG_parameters (per_fmol)"
    legend_constants[74] = "K_110_LCC in component BG_parameters (per_fmol)"
    legend_constants[75] = "K_120_LCC in component BG_parameters (per_fmol)"
    legend_constants[76] = "K_001_LCC in component BG_parameters (per_fmol)"
    legend_constants[77] = "K_011_LCC in component BG_parameters (per_fmol)"
    legend_constants[78] = "K_021_LCC in component BG_parameters (per_fmol)"
    legend_constants[79] = "K_101_LCC in component BG_parameters (per_fmol)"
    legend_constants[80] = "K_111_LCC in component BG_parameters (per_fmol)"
    legend_constants[81] = "K_121_LCC in component BG_parameters (per_fmol)"
    legend_constants[82] = "K_1_NCX in component BG_parameters (per_fmol)"
    legend_constants[83] = "K_2_NCX in component BG_parameters (per_fmol)"
    legend_constants[84] = "K_3_NCX in component BG_parameters (per_fmol)"
    legend_constants[85] = "K_4_NCX in component BG_parameters (per_fmol)"
    legend_constants[86] = "K_5_NCX in component BG_parameters (per_fmol)"
    legend_constants[87] = "K_6_NCX in component BG_parameters (per_fmol)"
    legend_constants[88] = "K_Na_i in component BG_parameters (per_fmol)"
    legend_constants[89] = "K_Na_o in component BG_parameters (per_fmol)"
    legend_constants[90] = "K_pCa in component BG_parameters (per_fmol)"
    legend_constants[91] = "K_pCa_Ca in component BG_parameters (per_fmol)"
    legend_constants[92] = "K_PLB in component BG_parameters (per_fmol)"
    legend_constants[93] = "K_PKACI in component BG_parameters (per_fmol)"
    legend_constants[94] = "K_PLB_PKACI in component BG_parameters (per_fmol)"
    legend_constants[95] = "K_PP1 in component BG_parameters (per_fmol)"
    legend_constants[96] = "K_PLBp_PP1 in component BG_parameters (per_fmol)"
    legend_constants[97] = "K_PLBp in component BG_parameters (per_fmol)"
    legend_constants[98] = "K_Ip in component BG_parameters (per_fmol)"
    legend_constants[99] = "K_Ip_PP1 in component BG_parameters (per_fmol)"
    legend_constants[100] = "K_C_RyR in component BG_parameters (per_fmol)"
    legend_constants[101] = "K_CI_RyR in component BG_parameters (per_fmol)"
    legend_constants[102] = "K_I_RyR in component BG_parameters (per_fmol)"
    legend_constants[103] = "K_O_RyR in component BG_parameters (per_fmol)"
    legend_constants[104] = "K_P1_SERCA in component BG_parameters (per_fmol)"
    legend_constants[105] = "K_P2_SERCA in component BG_parameters (per_fmol)"
    legend_constants[106] = "K_P2a_SERCA in component BG_parameters (per_fmol)"
    legend_constants[107] = "K_P4_SERCA in component BG_parameters (per_fmol)"
    legend_constants[108] = "K_P5_SERCA in component BG_parameters (per_fmol)"
    legend_constants[109] = "K_P6_SERCA in component BG_parameters (per_fmol)"
    legend_constants[110] = "K_P8_SERCA in component BG_parameters (per_fmol)"
    legend_constants[111] = "K_P9_SERCA in component BG_parameters (per_fmol)"
    legend_constants[112] = "K_P10_SERCA in component BG_parameters (per_fmol)"
    legend_constants[113] = "K_H in component BG_parameters (per_fmol)"
    legend_constants[114] = "K_MgATP in component BG_parameters (per_fmol)"
    legend_constants[115] = "K_MgADP in component BG_parameters (per_fmol)"
    legend_constants[116] = "K_Pi in component BG_parameters (per_fmol)"
    legend_constants[117] = "z_rCa in component BG_parameters (dimensionless)"
    legend_constants[118] = "z_fd in component BG_parameters (dimensionless)"
    legend_constants[119] = "z_ff1 in component BG_parameters (dimensionless)"
    legend_constants[120] = "z_ff2 in component BG_parameters (dimensionless)"
    legend_constants[121] = "z_ff3 in component BG_parameters (dimensionless)"
    legend_constants[122] = "z_rd in component BG_parameters (dimensionless)"
    legend_constants[123] = "z_rf1 in component BG_parameters (dimensionless)"
    legend_constants[124] = "z_rf2 in component BG_parameters (dimensionless)"
    legend_constants[125] = "z_rf3 in component BG_parameters (dimensionless)"
    legend_constants[126] = "nNa_o_NCX in component BG_parameters (dimensionless)"
    legend_constants[127] = "nNa_i_NCX in component BG_parameters (dimensionless)"
    legend_constants[128] = "zf_NCX in component BG_parameters (dimensionless)"
    legend_constants[129] = "zr_NCX in component BG_parameters (dimensionless)"
    legend_constants[130] = "n_Tm in component BG_parameters (dimensionless)"
    legend_constants[131] = "n_CaTRPN in component BG_parameters (dimensionless)"
    legend_voi = "time in component environment (second)"
    legend_constants[132] = "vol_myo in component environment (pL)"
    legend_constants[133] = "C_m in component environment (fF)"
    legend_states[0] = "q_membrane in component environment (fC)"
    legend_states[1] = "q_Ca_D in component environment (fmol)"
    legend_states[2] = "q_TRPN in component environment (fmol)"
    legend_states[3] = "q_Ca_TRPN in component environment (fmol)"
    legend_states[4] = "q_Ca_i in component environment (fmol)"
    legend_states[5] = "q_Na_i in component environment (fmol)"
    legend_states[6] = "q_Na_o in component environment (fmol)"
    legend_states[7] = "q_B_XB in component environment (fmol)"
    legend_states[8] = "q_U_XB in component environment (fmol)"
    legend_states[9] = "q_W_XB in component environment (fmol)"
    legend_states[10] = "q_S_XB in component environment (fmol)"
    legend_states[11] = "q_Ca_o in component environment (fmol)"
    legend_states[12] = "q_PLB in component environment (fmol)"
    legend_states[13] = "q_PKACI in component environment (fmol)"
    legend_states[14] = "q_PLB_PKACI in component environment (fmol)"
    legend_states[15] = "q_PP1 in component environment (fmol)"
    legend_states[16] = "q_PLBp_PP1 in component environment (fmol)"
    legend_states[17] = "q_PLBp in component environment (fmol)"
    legend_constants[134] = "q_PLBp_baseline in component environment (fmol)"
    legend_states[18] = "q_Ip in component environment (fmol)"
    legend_states[19] = "q_Ip_PP1 in component environment (fmol)"
    legend_states[20] = "q_Ca_SR in component environment (fmol)"
    legend_states[21] = "q_pCa in component environment (fmol)"
    legend_states[22] = "q_pCa_Ca in component environment (fmol)"
    legend_states[23] = "q_H in component environment (fmol)"
    legend_states[24] = "q_Pi in component environment (fmol)"
    legend_states[25] = "q_MgADP in component environment (fmol)"
    legend_states[26] = "q_MgATP in component environment (fmol)"
    legend_states[27] = "q_000_LCC in component environment (fmol)"
    legend_states[28] = "q_010_LCC in component environment (fmol)"
    legend_states[29] = "q_020_LCC in component environment (fmol)"
    legend_states[30] = "q_100_LCC in component environment (fmol)"
    legend_states[31] = "q_110_LCC in component environment (fmol)"
    legend_states[32] = "q_120_LCC in component environment (fmol)"
    legend_states[33] = "q_001_LCC in component environment (fmol)"
    legend_states[34] = "q_011_LCC in component environment (fmol)"
    legend_states[35] = "q_021_LCC in component environment (fmol)"
    legend_states[36] = "q_101_LCC in component environment (fmol)"
    legend_states[37] = "q_111_LCC in component environment (fmol)"
    legend_states[38] = "q_121_LCC in component environment (fmol)"
    legend_states[39] = "q_P1_NCX in component environment (fmol)"
    legend_states[40] = "q_P2_NCX in component environment (fmol)"
    legend_states[41] = "q_P3_NCX in component environment (fmol)"
    legend_states[42] = "q_P4_NCX in component environment (fmol)"
    legend_states[43] = "q_P5_NCX in component environment (fmol)"
    legend_states[44] = "q_P6_NCX in component environment (fmol)"
    legend_states[45] = "q_C_RyR in component environment (fmol)"
    legend_states[46] = "q_CI_RyR in component environment (fmol)"
    legend_states[47] = "q_I_RyR in component environment (fmol)"
    legend_states[48] = "q_O_RyR in component environment (fmol)"
    legend_states[49] = "q_P1_SERCA in component environment (fmol)"
    legend_states[50] = "q_P2_SERCA in component environment (fmol)"
    legend_states[51] = "q_P2a_SERCA in component environment (fmol)"
    legend_states[52] = "q_P4_SERCA in component environment (fmol)"
    legend_states[53] = "q_P5_SERCA in component environment (fmol)"
    legend_states[54] = "q_P6_SERCA in component environment (fmol)"
    legend_states[55] = "q_P8_SERCA in component environment (fmol)"
    legend_states[56] = "q_P9_SERCA in component environment (fmol)"
    legend_states[57] = "q_P10_SERCA in component environment (fmol)"
    legend_algebraic[54] = "v_leak in component Ca_leak (fmol_per_sec)"
    legend_algebraic[66] = "v_R_TRPNCa in component crossbridge_TRPN (fmol_per_sec)"
    legend_algebraic[73] = "v_R_BU in component crossbridge_TRPN (fmol_per_sec)"
    legend_algebraic[75] = "v_R_UW in component crossbridge_TRPN (fmol_per_sec)"
    legend_algebraic[77] = "v_R_WS in component crossbridge_TRPN (fmol_per_sec)"
    legend_algebraic[79] = "v_R_SU in component crossbridge_TRPN (fmol_per_sec)"
    legend_algebraic[59] = "T_total in component crossbridge_TRPN (kPa)"
    legend_states[58] = "SL in component crossbridge_TRPN (metre)"
    legend_algebraic[72] = "v_diadDf in component diadCaDiffusion (fmol_per_sec)"
    legend_algebraic[182] = "v_Ca_D_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[181] = "v_Ca_o_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[180] = "I_mem_LCC in component LCC (fA)"
    legend_algebraic[221] = "v_Ca_o_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[222] = "v_Ca_i_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[214] = "v_Na_o_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[203] = "v_Na_i_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[220] = "I_mem_NCX in component NCX (fA)"
    legend_algebraic[227] = "v_pCa_R1 in component pCa (fmol_per_sec)"
    legend_algebraic[228] = "v_pCa_R2 in component pCa (fmol_per_sec)"
    legend_algebraic[230] = "I_mem_pCa in component pCa (fA)"
    legend_algebraic[55] = "v_PLBph1 in component PLB (fmol_per_sec)"
    legend_algebraic[60] = "v_PLBph2 in component PLB (fmol_per_sec)"
    legend_algebraic[62] = "v_PLBd1 in component PLB (fmol_per_sec)"
    legend_algebraic[65] = "v_PLBd2 in component PLB (fmol_per_sec)"
    legend_algebraic[56] = "v_Inh in component PLB (fmol_per_sec)"
    legend_algebraic[237] = "v_RyR in component RyR (fmol_per_sec)"
    legend_algebraic[246] = "v_RyRgate_Ca_D in component RyR (fmol_per_sec)"
    legend_algebraic[289] = "v_Ca_i_SERCA in component SERCA (fmol_per_sec)"
    legend_algebraic[295] = "v_Ca_SR_SERCA in component SERCA (fmol_per_sec)"
    legend_algebraic[300] = "v_H_SERCA in component SERCA (fmol_per_sec)"
    legend_algebraic[286] = "v_MgADP_SERCA in component SERCA (fmol_per_sec)"
    legend_algebraic[283] = "v_MgATP_SERCA in component SERCA (fmol_per_sec)"
    legend_algebraic[281] = "v_Pi_SERCA in component SERCA (fmol_per_sec)"
    legend_algebraic[1] = "V_m in component environment (volt)"
    legend_algebraic[28] = "I_stim in component environment (fA)"
    legend_constants[135] = "stimPeriod in component environment (second)"
    legend_constants[136] = "stimDuration in component environment (second)"
    legend_algebraic[11] = "tPeriod in component environment (second)"
    legend_algebraic[33] = "v_Ca_stim in component environment (fmol_per_sec)"
    legend_algebraic[232] = "sum_I in component environment (fA)"
    legend_algebraic[2] = "dSL in component environment (m_per_s)"
    legend_constants[137] = "V_max in component environment (m_per_s)"
    legend_constants[138] = "vol_cell in component environment (pL)"
    legend_constants[170] = "vol_SR in component environment (pL)"
    legend_constants[139] = "vol_o in component environment (pL)"
    legend_constants[140] = "vol_D in component environment (pL)"
    legend_algebraic[3] = "cCai in component environment (mM)"
    legend_algebraic[4] = "cCao in component environment (mM)"
    legend_algebraic[5] = "cCaSR in component environment (mM)"
    legend_algebraic[6] = "cCaD in component environment (mM)"
    legend_algebraic[7] = "cNai in component environment (mM)"
    legend_algebraic[8] = "pHi in component environment (dimensionless)"
    legend_algebraic[9] = "Ca_tot in component environment (fmol)"
    legend_constants[141] = "R in component constants (J_per_K_per_mol)"
    legend_constants[142] = "T in component constants (kelvin)"
    legend_constants[143] = "F in component constants (C_per_mol)"
    legend_constants[144] = "zNa in component ion_valences (dimensionless)"
    legend_constants[145] = "zCl in component ion_valences (dimensionless)"
    legend_constants[146] = "zK in component ion_valences (dimensionless)"
    legend_constants[147] = "zCa in component ion_valences (dimensionless)"
    legend_algebraic[38] = "mu_Ca_SR in component Ca_leak (J_per_mol)"
    legend_algebraic[48] = "mu_Ca_i in component Ca_leak (J_per_mol)"
    legend_algebraic[58] = "mu_TRPN in component crossbridge_TRPN (J_per_mol)"
    legend_algebraic[61] = "mu_Ca_i in component crossbridge_TRPN (J_per_mol)"
    legend_algebraic[63] = "mu_Ca_TRPN in component crossbridge_TRPN (J_per_mol)"
    legend_algebraic[64] = "mu_B_XB in component crossbridge_TRPN (J_per_mol)"
    legend_algebraic[67] = "mu_U_XB in component crossbridge_TRPN (J_per_mol)"
    legend_algebraic[69] = "mu_W_XB in component crossbridge_TRPN (J_per_mol)"
    legend_algebraic[71] = "mu_S_XB in component crossbridge_TRPN (J_per_mol)"
    legend_constants[148] = "SL_0 in component crossbridge_TRPN (metre)"
    legend_constants[149] = "q_MS in component crossbridge_TRPN (fmol)"
    legend_constants[150] = "r_s in component crossbridge_TRPN (dimensionless)"
    legend_constants[151] = "r_w in component crossbridge_TRPN (dimensionless)"
    legend_constants[152] = "A_eff in component crossbridge_TRPN (dimensionless)"
    legend_constants[153] = "phi in component crossbridge_TRPN (dimensionless)"
    legend_constants[154] = "k_uw in component crossbridge_TRPN (per_sec)"
    legend_constants[155] = "k_ws in component crossbridge_TRPN (per_sec)"
    legend_states[59] = "G_w in component crossbridge_TRPN (metre)"
    legend_states[60] = "G_s in component crossbridge_TRPN (metre)"
    legend_constants[171] = "c_w in component crossbridge_TRPN (per_sec)"
    legend_constants[172] = "c_s in component crossbridge_TRPN (per_sec)"
    legend_constants[169] = "A_w in component crossbridge_TRPN (dimensionless)"
    legend_constants[175] = "A_s in component crossbridge_TRPN (dimensionless)"
    legend_algebraic[41] = "nu_1 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[30] = "nu_2 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[35] = "nu_3 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[42] = "nu_4 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[31] = "nu_5 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[36] = "nu_6 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[51] = "v_1 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[26] = "v_2 in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[52] = "v_4 in component crossbridge_TRPN (m_per_s)"
    legend_constants[156] = "v_to_mu in component crossbridge_TRPN (Js_per_m2)"
    legend_algebraic[32] = "T_active in component crossbridge_TRPN (kPa)"
    legend_constants[157] = "T_ref in component crossbridge_TRPN (kPa)"
    legend_algebraic[10] = "F_T_S in component crossbridge_TRPN (kPa)"
    legend_algebraic[27] = "F_T_W in component crossbridge_TRPN (kPa)"
    legend_states[61] = "Cdd in component crossbridge_TRPN (metre)"
    legend_algebraic[43] = "eta in component crossbridge_TRPN (second)"
    legend_constants[158] = "eta_l in component crossbridge_TRPN (second)"
    legend_constants[159] = "eta_s in component crossbridge_TRPN (second)"
    legend_constants[160] = "k in component crossbridge_TRPN (dimensionless)"
    legend_constants[161] = "alpha in component crossbridge_TRPN (kPa)"
    legend_algebraic[44] = "v_Cdd in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[45] = "nu_d in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[46] = "nu_k in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[47] = "nu_f in component crossbridge_TRPN (m_per_s)"
    legend_algebraic[53] = "F_d in component crossbridge_TRPN (kPa)"
    legend_algebraic[37] = "F_1 in component crossbridge_TRPN (kPa)"
    legend_algebraic[57] = "T_passive in component crossbridge_TRPN (kPa)"
    legend_constants[162] = "b in component crossbridge_TRPN (dimensionless)"
    legend_algebraic[68] = "mu_Ca_D in component diadCaDiffusion (J_per_mol)"
    legend_algebraic[70] = "mu_Ca_i in component diadCaDiffusion (J_per_mol)"
    legend_algebraic[76] = "mu_Ca_o in component LCC (J_per_mol)"
    legend_algebraic[78] = "mu_Ca_D in component LCC (J_per_mol)"
    legend_algebraic[74] = "V_mem in component LCC (volt)"
    legend_algebraic[88] = "Af_LCC_Ca1 in component LCC (J_per_mol)"
    legend_algebraic[116] = "Ar_LCC_Ca1 in component LCC (J_per_mol)"
    legend_algebraic[114] = "Am_LCC_Ca1 in component LCC (J_per_mol)"
    legend_algebraic[175] = "v_LCC_Ca1 in component LCC (fmol_per_sec)"
    legend_algebraic[89] = "Af_LCC_Ca2 in component LCC (J_per_mol)"
    legend_algebraic[117] = "Ar_LCC_Ca2 in component LCC (J_per_mol)"
    legend_algebraic[115] = "Am_LCC_Ca2 in component LCC (J_per_mol)"
    legend_algebraic[177] = "v_LCC_Ca2 in component LCC (fmol_per_sec)"
    legend_algebraic[108] = "Af_fCa00 in component LCC (J_per_mol)"
    legend_algebraic[154] = "Ar_fCa00 in component LCC (J_per_mol)"
    legend_algebraic[155] = "v_fCa00 in component LCC (fmol_per_sec)"
    legend_algebraic[109] = "Af_fCa01 in component LCC (J_per_mol)"
    legend_algebraic[156] = "Ar_fCa01 in component LCC (J_per_mol)"
    legend_algebraic[159] = "v_fCa01 in component LCC (fmol_per_sec)"
    legend_algebraic[110] = "Af_fCa02 in component LCC (J_per_mol)"
    legend_algebraic[160] = "Ar_fCa02 in component LCC (J_per_mol)"
    legend_algebraic[163] = "v_fCa02 in component LCC (fmol_per_sec)"
    legend_algebraic[111] = "Af_fCa10 in component LCC (J_per_mol)"
    legend_algebraic[164] = "Ar_fCa10 in component LCC (J_per_mol)"
    legend_algebraic[167] = "v_fCa10 in component LCC (fmol_per_sec)"
    legend_algebraic[112] = "Af_fCa11 in component LCC (J_per_mol)"
    legend_algebraic[168] = "Ar_fCa11 in component LCC (J_per_mol)"
    legend_algebraic[171] = "v_fCa11 in component LCC (fmol_per_sec)"
    legend_algebraic[113] = "Af_fCa12 in component LCC (J_per_mol)"
    legend_algebraic[172] = "Ar_fCa12 in component LCC (J_per_mol)"
    legend_algebraic[174] = "v_fCa12 in component LCC (fmol_per_sec)"
    legend_algebraic[80] = "mu_S000_LCC in component LCC (J_per_mol)"
    legend_algebraic[157] = "v_S000_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[81] = "mu_S010_LCC in component LCC (J_per_mol)"
    legend_algebraic[161] = "v_S010_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[82] = "mu_S020_LCC in component LCC (J_per_mol)"
    legend_algebraic[165] = "v_S020_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[83] = "mu_S100_LCC in component LCC (J_per_mol)"
    legend_algebraic[169] = "v_S100_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[84] = "mu_S110_LCC in component LCC (J_per_mol)"
    legend_algebraic[173] = "v_S110_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[86] = "mu_S120_LCC in component LCC (J_per_mol)"
    legend_algebraic[176] = "v_S120_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[12] = "mu_S001_LCC in component LCC (J_per_mol)"
    legend_algebraic[158] = "v_S001_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[13] = "mu_S011_LCC in component LCC (J_per_mol)"
    legend_algebraic[162] = "v_S011_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[14] = "mu_S021_LCC in component LCC (J_per_mol)"
    legend_algebraic[166] = "v_S021_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[15] = "mu_S101_LCC in component LCC (J_per_mol)"
    legend_algebraic[170] = "v_S101_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[85] = "mu_S111_LCC in component LCC (J_per_mol)"
    legend_algebraic[178] = "v_S111_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[87] = "mu_S121_LCC in component LCC (J_per_mol)"
    legend_algebraic[179] = "v_S121_LCC in component LCC (fmol_per_sec)"
    legend_algebraic[90] = "Af_d000 in component LCC (J_per_mol)"
    legend_algebraic[118] = "Ar_d000 in component LCC (J_per_mol)"
    legend_algebraic[119] = "v_d000 in component LCC (fmol_per_sec)"
    legend_algebraic[92] = "Af_d010 in component LCC (J_per_mol)"
    legend_algebraic[122] = "Ar_d010 in component LCC (J_per_mol)"
    legend_algebraic[123] = "v_d010 in component LCC (fmol_per_sec)"
    legend_algebraic[94] = "Af_d020 in component LCC (J_per_mol)"
    legend_algebraic[126] = "Ar_d020 in component LCC (J_per_mol)"
    legend_algebraic[127] = "v_d020 in component LCC (fmol_per_sec)"
    legend_algebraic[96] = "Af_f1_000 in component LCC (J_per_mol)"
    legend_algebraic[130] = "Ar_f1_000 in component LCC (J_per_mol)"
    legend_algebraic[131] = "v_f1_000 in component LCC (fmol_per_sec)"
    legend_algebraic[100] = "Af_f2_000 in component LCC (J_per_mol)"
    legend_algebraic[138] = "Ar_f2_000 in component LCC (J_per_mol)"
    legend_algebraic[139] = "v_f2_000 in component LCC (fmol_per_sec)"
    legend_algebraic[104] = "Af_f3_010 in component LCC (J_per_mol)"
    legend_algebraic[146] = "Ar_f3_010 in component LCC (J_per_mol)"
    legend_algebraic[147] = "v_f3_010 in component LCC (fmol_per_sec)"
    legend_algebraic[98] = "Af_f1_100 in component LCC (J_per_mol)"
    legend_algebraic[134] = "Ar_f1_100 in component LCC (J_per_mol)"
    legend_algebraic[135] = "v_f1_100 in component LCC (fmol_per_sec)"
    legend_algebraic[102] = "Af_f2_100 in component LCC (J_per_mol)"
    legend_algebraic[142] = "Ar_f2_100 in component LCC (J_per_mol)"
    legend_algebraic[143] = "v_f2_100 in component LCC (fmol_per_sec)"
    legend_algebraic[106] = "Af_f3_110 in component LCC (J_per_mol)"
    legend_algebraic[150] = "Ar_f3_110 in component LCC (J_per_mol)"
    legend_algebraic[151] = "v_f3_110 in component LCC (fmol_per_sec)"
    legend_algebraic[91] = "Af_d001 in component LCC (J_per_mol)"
    legend_algebraic[120] = "Ar_d001 in component LCC (J_per_mol)"
    legend_algebraic[121] = "v_d001 in component LCC (fmol_per_sec)"
    legend_algebraic[93] = "Af_d011 in component LCC (J_per_mol)"
    legend_algebraic[124] = "Ar_d011 in component LCC (J_per_mol)"
    legend_algebraic[125] = "v_d011 in component LCC (fmol_per_sec)"
    legend_algebraic[95] = "Af_d021 in component LCC (J_per_mol)"
    legend_algebraic[128] = "Ar_d021 in component LCC (J_per_mol)"
    legend_algebraic[129] = "v_d021 in component LCC (fmol_per_sec)"
    legend_algebraic[97] = "Af_f1_001 in component LCC (J_per_mol)"
    legend_algebraic[132] = "Ar_f1_001 in component LCC (J_per_mol)"
    legend_algebraic[133] = "v_f1_001 in component LCC (fmol_per_sec)"
    legend_algebraic[101] = "Af_f2_001 in component LCC (J_per_mol)"
    legend_algebraic[140] = "Ar_f2_001 in component LCC (J_per_mol)"
    legend_algebraic[141] = "v_f2_001 in component LCC (fmol_per_sec)"
    legend_algebraic[105] = "Af_f3_011 in component LCC (J_per_mol)"
    legend_algebraic[148] = "Ar_f3_011 in component LCC (J_per_mol)"
    legend_algebraic[149] = "v_f3_011 in component LCC (fmol_per_sec)"
    legend_algebraic[99] = "Af_f1_101 in component LCC (J_per_mol)"
    legend_algebraic[136] = "Ar_f1_101 in component LCC (J_per_mol)"
    legend_algebraic[137] = "v_f1_101 in component LCC (fmol_per_sec)"
    legend_algebraic[103] = "Af_f2_101 in component LCC (J_per_mol)"
    legend_algebraic[144] = "Ar_f2_101 in component LCC (J_per_mol)"
    legend_algebraic[145] = "v_f2_101 in component LCC (fmol_per_sec)"
    legend_algebraic[107] = "Af_f3_111 in component LCC (J_per_mol)"
    legend_algebraic[152] = "Ar_f3_111 in component LCC (J_per_mol)"
    legend_algebraic[153] = "v_f3_111 in component LCC (fmol_per_sec)"
    legend_algebraic[16] = "Ca_tot in component LCC (fmol)"
    legend_algebraic[184] = "mu_Ca_o in component NCX (J_per_mol)"
    legend_algebraic[185] = "mu_Ca_i in component NCX (J_per_mol)"
    legend_algebraic[186] = "mu_Na_o in component NCX (J_per_mol)"
    legend_algebraic[187] = "mu_Na_i in component NCX (J_per_mol)"
    legend_algebraic[188] = "mu_P1_NCX in component NCX (J_per_mol)"
    legend_algebraic[189] = "mu_P2_NCX in component NCX (J_per_mol)"
    legend_algebraic[190] = "mu_P3_NCX in component NCX (J_per_mol)"
    legend_algebraic[191] = "mu_P4_NCX in component NCX (J_per_mol)"
    legend_algebraic[192] = "mu_P5_NCX in component NCX (J_per_mol)"
    legend_algebraic[193] = "mu_P6_NCX in component NCX (J_per_mol)"
    legend_algebraic[218] = "v_P1_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[206] = "v_P2_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[209] = "v_P3_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[212] = "v_P4_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[215] = "v_P5_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[219] = "v_P6_NCX in component NCX (fmol_per_sec)"
    legend_algebraic[194] = "Af_r1 in component NCX (J_per_mol)"
    legend_algebraic[200] = "Ar_r1 in component NCX (J_per_mol)"
    legend_algebraic[201] = "v_r1 in component NCX (fmol_per_sec)"
    legend_algebraic[195] = "Af_r2 in component NCX (J_per_mol)"
    legend_algebraic[202] = "Ar_r2 in component NCX (J_per_mol)"
    legend_algebraic[204] = "v_r2 in component NCX (fmol_per_sec)"
    legend_algebraic[196] = "Af_r3 in component NCX (J_per_mol)"
    legend_algebraic[205] = "Ar_r3 in component NCX (J_per_mol)"
    legend_algebraic[207] = "v_r3 in component NCX (fmol_per_sec)"
    legend_algebraic[197] = "Af_r4 in component NCX (J_per_mol)"
    legend_algebraic[208] = "Ar_r4 in component NCX (J_per_mol)"
    legend_algebraic[210] = "v_r4 in component NCX (fmol_per_sec)"
    legend_algebraic[198] = "Af_r5 in component NCX (J_per_mol)"
    legend_algebraic[211] = "Ar_r5 in component NCX (J_per_mol)"
    legend_algebraic[213] = "v_r5 in component NCX (fmol_per_sec)"
    legend_algebraic[199] = "Af_r6 in component NCX (J_per_mol)"
    legend_algebraic[216] = "Ar_r6 in component NCX (J_per_mol)"
    legend_algebraic[217] = "v_r6 in component NCX (fmol_per_sec)"
    legend_algebraic[183] = "V_mem in component NCX (volt)"
    legend_algebraic[223] = "mu_Ca_i in component pCa (J_per_mol)"
    legend_algebraic[224] = "mu_Ca_o in component pCa (J_per_mol)"
    legend_algebraic[225] = "mu_pCa in component pCa (J_per_mol)"
    legend_algebraic[226] = "mu_pCa_Ca in component pCa (J_per_mol)"
    legend_algebraic[0] = "mu_PLB in component PLB (J_per_mol)"
    legend_algebraic[25] = "mu_PKACI in component PLB (J_per_mol)"
    legend_algebraic[29] = "mu_PLB_PKACI in component PLB (J_per_mol)"
    legend_algebraic[34] = "mu_PP1 in component PLB (J_per_mol)"
    legend_algebraic[39] = "mu_PLBp_PP1 in component PLB (J_per_mol)"
    legend_algebraic[49] = "mu_PLBp in component PLB (J_per_mol)"
    legend_algebraic[40] = "mu_Ip in component PLB (J_per_mol)"
    legend_algebraic[50] = "mu_Ip_PP1 in component PLB (J_per_mol)"
    legend_constants[163] = "nCa_1 in component RyR (dimensionless)"
    legend_constants[164] = "nCa_2 in component RyR (dimensionless)"
    legend_algebraic[229] = "mu_Ca_SR in component RyR (J_per_mol)"
    legend_algebraic[231] = "mu_Ca_D in component RyR (J_per_mol)"
    legend_algebraic[17] = "q_Ca_gate_complexes in component RyR (fmol)"
    legend_algebraic[233] = "mu_C_RyR in component RyR (J_per_mol)"
    legend_algebraic[234] = "mu_CI_RyR in component RyR (J_per_mol)"
    legend_algebraic[235] = "mu_I_RyR in component RyR (J_per_mol)"
    legend_algebraic[236] = "mu_O_RyR in component RyR (J_per_mol)"
    legend_algebraic[238] = "v_OC in component RyR (fmol_per_sec)"
    legend_algebraic[240] = "v_CCI in component RyR (fmol_per_sec)"
    legend_algebraic[242] = "v_CII in component RyR (fmol_per_sec)"
    legend_algebraic[244] = "v_IO in component RyR (fmol_per_sec)"
    legend_constants[165] = "n_Ca_i in component SERCA (dimensionless)"
    legend_constants[166] = "n_Ca_SR in component SERCA (dimensionless)"
    legend_constants[167] = "n_H in component SERCA (dimensionless)"
    legend_algebraic[18] = "q_SERCA_Ca_complexes in component SERCA (fmol)"
    legend_algebraic[19] = "c_Ca_i in component SERCA (mM)"
    legend_algebraic[20] = "c_Ca_SR in component SERCA (mM)"
    legend_algebraic[21] = "c_H in component SERCA (mM)"
    legend_algebraic[22] = "c_MgADP in component SERCA (mM)"
    legend_algebraic[23] = "c_MgATP in component SERCA (mM)"
    legend_algebraic[24] = "c_Pi in component SERCA (mM)"
    legend_constants[168] = "vol_i in component SERCA (pL)"
    legend_constants[174] = "vol_sr in component SERCA (pL)"
    legend_constants[176] = "vol_isr in component SERCA (pL)"
    legend_algebraic[239] = "mu_Ca_i in component SERCA (J_per_mol)"
    legend_algebraic[241] = "mu_Ca_SR in component SERCA (J_per_mol)"
    legend_algebraic[243] = "mu_H in component SERCA (J_per_mol)"
    legend_algebraic[245] = "mu_MgADP in component SERCA (J_per_mol)"
    legend_algebraic[247] = "mu_MgATP in component SERCA (J_per_mol)"
    legend_algebraic[249] = "mu_P1 in component SERCA (J_per_mol)"
    legend_algebraic[284] = "v_P1 in component SERCA (fmol_per_sec)"
    legend_algebraic[248] = "mu_Pi in component SERCA (J_per_mol)"
    legend_algebraic[250] = "mu_P2 in component SERCA (J_per_mol)"
    legend_algebraic[291] = "v_P2 in component SERCA (fmol_per_sec)"
    legend_algebraic[251] = "mu_P2a in component SERCA (J_per_mol)"
    legend_algebraic[288] = "v_P2a in component SERCA (fmol_per_sec)"
    legend_algebraic[252] = "mu_P4 in component SERCA (J_per_mol)"
    legend_algebraic[293] = "v_P4 in component SERCA (fmol_per_sec)"
    legend_algebraic[253] = "mu_P5 in component SERCA (J_per_mol)"
    legend_algebraic[294] = "v_P5 in component SERCA (fmol_per_sec)"
    legend_algebraic[255] = "mu_P6 in component SERCA (J_per_mol)"
    legend_algebraic[297] = "v_P6 in component SERCA (fmol_per_sec)"
    legend_algebraic[257] = "mu_P8 in component SERCA (J_per_mol)"
    legend_algebraic[299] = "v_P8 in component SERCA (fmol_per_sec)"
    legend_algebraic[258] = "mu_P9 in component SERCA (J_per_mol)"
    legend_algebraic[301] = "v_P9 in component SERCA (fmol_per_sec)"
    legend_algebraic[254] = "mu_P10 in component SERCA (J_per_mol)"
    legend_algebraic[302] = "v_P10 in component SERCA (fmol_per_sec)"
    legend_algebraic[259] = "mu_PLBp_baseline in component SERCA (J_per_mol)"
    legend_constants[173] = "mu_PLBp in component SERCA (J_per_mol)"
    legend_algebraic[260] = "mu_PLBp_eff in component SERCA (J_per_mol)"
    legend_algebraic[263] = "Af_R1_2 in component SERCA (J_per_mol)"
    legend_algebraic[264] = "Ar_R1_2 in component SERCA (J_per_mol)"
    legend_algebraic[280] = "v_SERCA_R1_2 in component SERCA (fmol_per_sec)"
    legend_algebraic[265] = "Af_R5_6 in component SERCA (J_per_mol)"
    legend_algebraic[266] = "Ar_R5_6 in component SERCA (J_per_mol)"
    legend_algebraic[282] = "v_SERCA_R5_6 in component SERCA (fmol_per_sec)"
    legend_algebraic[267] = "Af_R2_2a in component SERCA (J_per_mol)"
    legend_algebraic[268] = "Ar_R2_2a in component SERCA (J_per_mol)"
    legend_algebraic[285] = "v_SERCA_R2_2a in component SERCA (fmol_per_sec)"
    legend_algebraic[269] = "Af_R2_4 in component SERCA (J_per_mol)"
    legend_algebraic[270] = "Ar_R2_4 in component SERCA (J_per_mol)"
    legend_algebraic[287] = "v_SERCA_R2_4 in component SERCA (fmol_per_sec)"
    legend_algebraic[271] = "Af_R4_5 in component SERCA (J_per_mol)"
    legend_algebraic[272] = "Ar_R4_5 in component SERCA (J_per_mol)"
    legend_algebraic[290] = "v_SERCA_R4_5 in component SERCA (fmol_per_sec)"
    legend_algebraic[273] = "Af_R6_8 in component SERCA (J_per_mol)"
    legend_algebraic[274] = "Ar_R6_8 in component SERCA (J_per_mol)"
    legend_algebraic[292] = "v_SERCA_R6_8 in component SERCA (fmol_per_sec)"
    legend_algebraic[275] = "Af_R8_9 in component SERCA (J_per_mol)"
    legend_algebraic[276] = "Ar_R8_9 in component SERCA (J_per_mol)"
    legend_algebraic[296] = "v_SERCA_R8_9 in component SERCA (fmol_per_sec)"
    legend_algebraic[277] = "Af_R9_10 in component SERCA (J_per_mol)"
    legend_algebraic[278] = "Ar_R9_10 in component SERCA (J_per_mol)"
    legend_algebraic[298] = "v_SERCA_R9_10 in component SERCA (fmol_per_sec)"
    legend_algebraic[261] = "Af_R10_1 in component SERCA (J_per_mol)"
    legend_algebraic[262] = "Ar_R10_1 in component SERCA (J_per_mol)"
    legend_algebraic[279] = "v_SERCA_R10_1 in component SERCA (fmol_per_sec)"
    legend_algebraic[256] = "v_SERCA_R10_1_noPLBp in component SERCA (fmol_per_sec)"
    legend_rates[20] = "d/dt q_Ca_SR in component environment (fmol)"
    legend_rates[4] = "d/dt q_Ca_i in component environment (fmol)"
    legend_rates[2] = "d/dt q_TRPN in component environment (fmol)"
    legend_rates[3] = "d/dt q_Ca_TRPN in component environment (fmol)"
    legend_rates[7] = "d/dt q_B_XB in component environment (fmol)"
    legend_rates[8] = "d/dt q_U_XB in component environment (fmol)"
    legend_rates[9] = "d/dt q_W_XB in component environment (fmol)"
    legend_rates[10] = "d/dt q_S_XB in component environment (fmol)"
    legend_rates[1] = "d/dt q_Ca_D in component environment (fmol)"
    legend_rates[11] = "d/dt q_Ca_o in component environment (fmol)"
    legend_rates[5] = "d/dt q_Na_i in component environment (fmol)"
    legend_rates[6] = "d/dt q_Na_o in component environment (fmol)"
    legend_rates[21] = "d/dt q_pCa in component environment (fmol)"
    legend_rates[22] = "d/dt q_pCa_Ca in component environment (fmol)"
    legend_rates[12] = "d/dt q_PLB in component environment (fmol)"
    legend_rates[13] = "d/dt q_PKACI in component environment (fmol)"
    legend_rates[14] = "d/dt q_PLB_PKACI in component environment (fmol)"
    legend_rates[15] = "d/dt q_PP1 in component environment (fmol)"
    legend_rates[16] = "d/dt q_PLBp_PP1 in component environment (fmol)"
    legend_rates[17] = "d/dt q_PLBp in component environment (fmol)"
    legend_rates[18] = "d/dt q_Ip in component environment (fmol)"
    legend_rates[19] = "d/dt q_Ip_PP1 in component environment (fmol)"
    legend_rates[23] = "d/dt q_H in component environment (fmol)"
    legend_rates[25] = "d/dt q_MgADP in component environment (fmol)"
    legend_rates[26] = "d/dt q_MgATP in component environment (fmol)"
    legend_rates[24] = "d/dt q_Pi in component environment (fmol)"
    legend_rates[0] = "d/dt q_membrane in component environment (fC)"
    legend_rates[59] = "d/dt G_w in component crossbridge_TRPN (metre)"
    legend_rates[58] = "d/dt SL in component crossbridge_TRPN (metre)"
    legend_rates[60] = "d/dt G_s in component crossbridge_TRPN (metre)"
    legend_rates[61] = "d/dt Cdd in component crossbridge_TRPN (metre)"
    legend_rates[27] = "d/dt q_000_LCC in component environment (fmol)"
    legend_rates[28] = "d/dt q_010_LCC in component environment (fmol)"
    legend_rates[29] = "d/dt q_020_LCC in component environment (fmol)"
    legend_rates[30] = "d/dt q_100_LCC in component environment (fmol)"
    legend_rates[31] = "d/dt q_110_LCC in component environment (fmol)"
    legend_rates[32] = "d/dt q_120_LCC in component environment (fmol)"
    legend_rates[33] = "d/dt q_001_LCC in component environment (fmol)"
    legend_rates[34] = "d/dt q_011_LCC in component environment (fmol)"
    legend_rates[35] = "d/dt q_021_LCC in component environment (fmol)"
    legend_rates[36] = "d/dt q_101_LCC in component environment (fmol)"
    legend_rates[37] = "d/dt q_111_LCC in component environment (fmol)"
    legend_rates[38] = "d/dt q_121_LCC in component environment (fmol)"
    legend_rates[39] = "d/dt q_P1_NCX in component environment (fmol)"
    legend_rates[40] = "d/dt q_P2_NCX in component environment (fmol)"
    legend_rates[41] = "d/dt q_P3_NCX in component environment (fmol)"
    legend_rates[42] = "d/dt q_P4_NCX in component environment (fmol)"
    legend_rates[43] = "d/dt q_P5_NCX in component environment (fmol)"
    legend_rates[44] = "d/dt q_P6_NCX in component environment (fmol)"
    legend_rates[48] = "d/dt q_O_RyR in component environment (fmol)"
    legend_rates[45] = "d/dt q_C_RyR in component environment (fmol)"
    legend_rates[46] = "d/dt q_CI_RyR in component environment (fmol)"
    legend_rates[47] = "d/dt q_I_RyR in component environment (fmol)"
    legend_rates[49] = "d/dt q_P1_SERCA in component environment (fmol)"
    legend_rates[50] = "d/dt q_P2_SERCA in component environment (fmol)"
    legend_rates[51] = "d/dt q_P2a_SERCA in component environment (fmol)"
    legend_rates[52] = "d/dt q_P4_SERCA in component environment (fmol)"
    legend_rates[53] = "d/dt q_P5_SERCA in component environment (fmol)"
    legend_rates[57] = "d/dt q_P10_SERCA in component environment (fmol)"
    legend_rates[54] = "d/dt q_P6_SERCA in component environment (fmol)"
    legend_rates[55] = "d/dt q_P8_SERCA in component environment (fmol)"
    legend_rates[56] = "d/dt q_P9_SERCA in component environment (fmol)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 1.19278e-07
    constants[1] = 61.975
    constants[2] = 6.70563
    constants[3] = 0.295103
    constants[4] = 0.00694361
    constants[5] = 124985
    constants[6] = 0.0319966
    constants[7] = 1.45746
    constants[8] = 1.91895
    constants[9] = 306.532
    constants[10] = 15.4798
    constants[11] = 20.3814
    constants[12] = 0.0998404
    constants[13] = 0.00504193
    constants[14] = 0.00663841
    constants[15] = 29.5266
    constants[16] = 146.621
    constants[17] = 0.00961708
    constants[18] = 0.047756
    constants[19] = 1.91912
    constants[20] = 9.52987
    constants[21] = 0.000625075
    constants[22] = 0.00310397
    constants[23] = 4187.14
    constants[24] = 20792.3
    constants[25] = 1.36379
    constants[26] = 6.77224
    constants[27] = 34185.2
    constants[28] = 169755
    constants[29] = 1726.35
    constants[30] = 8572.61
    constants[31] = 2272.98
    constants[32] = 11287.1
    constants[33] = 429216
    constants[34] = 1.06923e+08
    constants[35] = 3622.96
    constants[36] = 1.06923e+08
    constants[37] = 429216
    constants[38] = 0.380974
    constants[39] = 10726.4
    constants[40] = 1.40741e-05
    constants[41] = 12.9276
    constants[42] = 1.86249
    constants[43] = 0.0640148
    constants[44] = 0.200763
    constants[45] = 1269.27
    constants[46] = 1.13157e+06
    constants[47] = 8.50173
    constants[48] = 0.164843
    constants[49] = 626.393
    constants[50] = 52.1994
    constants[51] = 3.59662e-07
    constants[52] = 6.73317
    constants[53] = 32063.4
    constants[54] = 6.73317
    constants[55] = 0.408566
    constants[56] = 313.54
    constants[57] = 6675
    constants[58] = 6675
    constants[59] = 5.05704e-06
    constants[60] = 4.69975
    constants[61] = 1.11404
    constants[62] = 12.0566
    constants[63] = 0.062444
    constants[64] = 9.09233
    constants[65] = 3.40963
    constants[66] = 22.2937
    constants[67] = 5.57343e-06
    constants[68] = 66.2656
    constants[69] = 0.0265011
    constants[70] = 1.58796
    constants[71] = 31.4449
    constants[72] = 23.8827
    constants[73] = 0.319783
    constants[74] = 6.33236
    constants[75] = 4.80948
    constants[76] = 4875.4
    constants[77] = 96542.9
    constants[78] = 73325.1
    constants[79] = 981.805
    constants[80] = 19441.8
    constants[81] = 14766.2
    constants[82] = 2.85254e+08
    constants[83] = 16.9249
    constants[84] = 34379.9
    constants[85] = 313010
    constants[86] = 6.01862e+07
    constants[87] = 929.686
    constants[88] = 0.012842
    constants[89] = 0.0107799
    constants[90] = 0.0126813
    constants[91] = 0.0178289
    constants[92] = 0.482706
    constants[93] = 0.0120458
    constants[94] = 2.99358
    constants[95] = 0.0189254
    constants[96] = 1.63848
    constants[97] = 66.755
    constants[98] = 62.347
    constants[99] = 0.0304897
    constants[100] = 2234.81
    constants[101] = 30.332
    constants[102] = 0.0957866
    constants[103] = 7.05739
    constants[104] = 62.115
    constants[105] = 1.88391
    constants[106] = 0.271481
    constants[107] = 1292.79
    constants[108] = 0.00208939
    constants[109] = 139.3
    constants[110] = 0.710561
    constants[111] = 1.30406
    constants[112] = 1.3624
    constants[113] = 486.59
    constants[114] = 15.0787
    constants[115] = 1.53572e-05
    constants[116] = 0.00616948
    constants[117] = 2
    constants[118] = 2.1404
    constants[119] = -1.1495
    constants[120] = 0.72162
    constants[121] = 4.2933
    constants[122] = -2.1404
    constants[123] = 1.8993
    constants[124] = -0.52288
    constants[125] = 0
    constants[126] = 3
    constants[127] = 3
    constants[128] = -0.55679
    constants[129] = 0.44321
    constants[130] = 1.1
    constants[131] = 2
    constants[132] = 25.84
    constants[133] = 153400
    states[0] = -13039
    states[1] = 3.68876E-07
    states[2] = 2.57
    states[3] = 1e-18
    states[4] = 0.005663912
    states[5] = 481.46
    states[6] = 725.48
    states[7] = 1
    states[8] = 0
    states[9] = 0
    states[10] = 0
    states[11] = 6.84
    states[12] = 4.028E+00
    states[13] = 2.234E-03
    states[14] = 1e-18
    states[15] = 3.382E-02
    states[16] = 1e-18
    states[17] = 1e-18
    constants[134] = 1e-18
    states[18] = 1.999E-03
    states[19] = 1e-18
    states[20] = 0.641
    states[21] = 0.0032
    states[22] = 1e-9
    states[23] = 2.584e-6
    states[24] = 570
    states[25] = 1.3794
    states[26] = 3.8
    states[27] = 1.3798e-05
    states[28] = 1.3798e-05
    states[29] = 1.3798e-05
    states[30] = 1.3798e-05
    states[31] = 1.3798e-05
    states[32] = 1.3798e-05
    states[33] = 1.3798e-05
    states[34] = 1.3798e-05
    states[35] = 1.3798e-05
    states[36] = 1.3798e-05
    states[37] = 1.3798e-05
    states[38] = 1.3798e-05
    states[39] = 4.24554e-07
    states[40] = 4.24554e-07
    states[41] = 4.24554e-07
    states[42] = 4.24554e-07
    states[43] = 4.24554e-07
    states[44] = 4.24554e-07
    states[45] = 4.13941e-05
    states[46] = 4.13941e-05
    states[47] = 4.13941e-05
    states[48] = 4.13941e-05
    states[49] = 2.83036e-08
    states[50] = 2.83036e-08
    states[51] = 2.83036e-08
    states[52] = 2.83036e-08
    states[53] = 2.83036e-08
    states[54] = 2.83036e-08
    states[55] = 2.83036e-08
    states[56] = 2.83036e-08
    states[57] = 2.83036e-08
    states[58] = 2e-6
    constants[135] = 1
    constants[136] = 0.001
    constants[137] = 19e-6
    constants[138] = 38
    constants[139] = 5.182
    constants[140] = 0.0025375
    constants[141] = 8.31
    constants[142] = 310
    constants[143] = 96485
    constants[144] = 1
    constants[145] = -1
    constants[146] = 1
    constants[147] = 2
    constants[148] = 2e-6
    constants[149] = 1e-6
    constants[150] = 0.25
    constants[151] = 0.5
    constants[152] = 25
    constants[153] = 2.23
    constants[154] = 26
    constants[155] = 4
    states[59] = 1e-6
    states[60] = 1e-6
    constants[156] = 1
    constants[157] = 40.5
    states[61] = 0
    constants[158] = 200e3
    constants[159] = 20e3
    constants[160] = 7
    constants[161] = 2.1
    constants[162] = 9.1
    constants[163] = 1
    constants[164] = 2
    constants[165] = 2
    constants[166] = 2
    constants[167] = 2
    constants[168] = 34.0
    constants[169] = (constants[152]*constants[150])/((1.00000-constants[150])*constants[151]+constants[150])
    constants[170] = constants[138]*0.0350000
    constants[171] = (constants[153]*constants[154]*(1.00000-constants[151]))/constants[151]
    constants[172] = (constants[153]*constants[155]*(1.00000-constants[150])*constants[151])/constants[150]
    constants[173] = constants[141]*constants[142]*log(constants[97]*constants[134])
    constants[174] = constants[168]*0.0350000
    constants[175] = constants[169]
    constants[176] = constants[168]+constants[174]
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[2] = custom_piecewise([less(voi , 0.0600000), 1.00000*constants[137] , greater(voi , 0.500000) & less(voi , 1.10000), -0.100000*constants[137] , True, 0.00000*constants[137]])
    algebraic[26] = algebraic[2]
    rates[58] = algebraic[26]
    rootfind_0(voi, constants, rates, states, algebraic)
    rates[61] = algebraic[44]
    algebraic[30] = -constants[169]*algebraic[26]
    algebraic[35] = constants[171]*states[59]
    algebraic[41] = -algebraic[30]-algebraic[35]
    algebraic[51] = algebraic[41]
    rates[59] = algebraic[51]
    algebraic[31] = -constants[175]*algebraic[26]
    algebraic[36] = constants[172]*states[60]
    algebraic[42] = -algebraic[31]-algebraic[36]
    algebraic[52] = algebraic[42]
    rates[60] = algebraic[52]
    algebraic[34] = constants[141]*constants[142]*log(constants[95]*states[15])
    algebraic[40] = constants[141]*constants[142]*log(constants[98]*states[18])
    algebraic[50] = constants[141]*constants[142]*log(constants[99]*states[19])
    algebraic[56] = constants[45]*(exp((algebraic[34]+algebraic[40])/(constants[141]*constants[142]))-exp(algebraic[50]/(constants[141]*constants[142])))
    rates[18] = -algebraic[56]
    rates[19] = algebraic[56]
    algebraic[0] = constants[141]*constants[142]*log(constants[92]*states[12])
    algebraic[25] = constants[141]*constants[142]*log(constants[93]*states[13])
    algebraic[29] = constants[141]*constants[142]*log(constants[94]*states[14])
    algebraic[55] = constants[41]*(exp((algebraic[0]+algebraic[25])/(constants[141]*constants[142]))-exp(algebraic[29]/(constants[141]*constants[142])))
    algebraic[49] = constants[141]*constants[142]*log(constants[97]*states[17])
    algebraic[60] = constants[42]*(exp(algebraic[29]/(constants[141]*constants[142]))-exp((algebraic[49]+algebraic[25])/(constants[141]*constants[142])))
    rates[13] = algebraic[60]-algebraic[55]
    rates[14] = algebraic[55]-algebraic[60]
    rates[15] = algebraic[55]-algebraic[60]
    algebraic[39] = constants[141]*constants[142]*log(constants[96]*states[16])
    algebraic[62] = constants[43]*(exp((algebraic[49]+algebraic[34])/(constants[141]*constants[142]))-exp(algebraic[39]/(constants[141]*constants[142])))
    rates[17] = algebraic[60]-algebraic[62]
    algebraic[58] = constants[141]*constants[142]*log(constants[62]*states[2])
    algebraic[61] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[63] = constants[141]*constants[142]*log(constants[63]*states[3])
    algebraic[66] = constants[1]*(exp((constants[131]*algebraic[61]+algebraic[58])/(constants[141]*constants[142]))-exp(algebraic[63]/(constants[141]*constants[142])))
    rates[2] = -algebraic[66]
    rates[3] = algebraic[66]
    algebraic[65] = constants[44]*(exp(algebraic[39]/(constants[141]*constants[142]))-exp((algebraic[0]+algebraic[34])/(constants[141]*constants[142])))
    rates[12] = algebraic[65]-algebraic[55]
    rates[16] = algebraic[62]-algebraic[65]
    algebraic[64] = constants[141]*constants[142]*log(constants[64]*states[7])
    algebraic[67] = constants[141]*constants[142]*log(constants[65]*states[8])
    algebraic[73] = constants[2]*(exp((algebraic[64]+constants[130]*algebraic[63])/(constants[141]*constants[142]))-exp((algebraic[67]+constants[130]*algebraic[63])/(constants[141]*constants[142])))
    rates[7] = -algebraic[73]
    algebraic[69] = constants[141]*constants[142]*log(constants[66]*states[9])
    algebraic[75] = constants[3]*(exp(algebraic[67]/(constants[141]*constants[142]))-exp(algebraic[69]/(constants[141]*constants[142])))
    algebraic[71] = constants[141]*constants[142]*log(constants[67]*states[10])
    algebraic[77] = constants[4]*(exp(algebraic[69]/(constants[141]*constants[142]))-exp(algebraic[71]/(constants[141]*constants[142])))
    rates[9] = algebraic[75]-algebraic[77]
    algebraic[79] = constants[5]*(exp(algebraic[71]/(constants[141]*constants[142]))-exp(algebraic[67]/(constants[141]*constants[142])))
    rates[8] = (algebraic[73]-algebraic[75])+algebraic[79]
    rates[10] = algebraic[77]-algebraic[79]
    algebraic[80] = constants[141]*constants[142]*log(constants[70]*states[27])
    algebraic[108] = algebraic[80]
    algebraic[78] = constants[141]*constants[142]*log(constants[68]*states[1])
    algebraic[154] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[117]*algebraic[78]
    algebraic[155] = constants[27]*(exp(algebraic[108]/(constants[141]*constants[142]))-exp(algebraic[154]/(constants[141]*constants[142])))
    algebraic[74] = states[0]/constants[133]
    algebraic[90] = constants[141]*constants[142]*log(constants[70]*states[27])+constants[118]*constants[143]*algebraic[74]
    algebraic[118] = constants[141]*constants[142]*log(constants[73]*states[30])+constants[122]*constants[143]*algebraic[74]
    algebraic[119] = constants[9]*(exp(algebraic[90]/(constants[141]*constants[142]))-exp(algebraic[118]/(constants[141]*constants[142])))
    algebraic[96] = constants[141]*constants[142]*log(constants[70]*states[27])+constants[119]*constants[143]*algebraic[74]
    algebraic[130] = constants[141]*constants[142]*log(constants[71]*states[28])+constants[123]*constants[143]*algebraic[74]
    algebraic[131] = constants[15]*(exp(algebraic[96]/(constants[141]*constants[142]))-exp(algebraic[130]/(constants[141]*constants[142])))
    algebraic[100] = constants[141]*constants[142]*log(constants[70]*states[27])+constants[120]*constants[143]*algebraic[74]
    algebraic[138] = constants[141]*constants[142]*log(constants[72]*states[29])+constants[124]*constants[143]*algebraic[74]
    algebraic[139] = constants[19]*(exp(algebraic[100]/(constants[141]*constants[142]))-exp(algebraic[138]/(constants[141]*constants[142])))
    algebraic[157] = ((-algebraic[119]-algebraic[131])-algebraic[139])-algebraic[155]
    rates[27] = algebraic[157]
    algebraic[91] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[118]*constants[143]*algebraic[74]
    algebraic[120] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[122]*constants[143]*algebraic[74]
    algebraic[121] = constants[12]*(exp(algebraic[91]/(constants[141]*constants[142]))-exp(algebraic[120]/(constants[141]*constants[142])))
    algebraic[97] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[119]*constants[143]*algebraic[74]
    algebraic[132] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[123]*constants[143]*algebraic[74]
    algebraic[133] = constants[17]*(exp(algebraic[97]/(constants[141]*constants[142]))-exp(algebraic[132]/(constants[141]*constants[142])))
    algebraic[101] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[120]*constants[143]*algebraic[74]
    algebraic[140] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[124]*constants[143]*algebraic[74]
    algebraic[141] = constants[21]*(exp(algebraic[101]/(constants[141]*constants[142]))-exp(algebraic[140]/(constants[141]*constants[142])))
    algebraic[158] = ((-algebraic[121]-algebraic[133])-algebraic[141])--algebraic[155]
    rates[33] = algebraic[158]
    algebraic[81] = constants[141]*constants[142]*log(constants[71]*states[28])
    algebraic[109] = algebraic[81]
    algebraic[156] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[117]*algebraic[78]
    algebraic[159] = constants[29]*(exp(algebraic[109]/(constants[141]*constants[142]))-exp(algebraic[156]/(constants[141]*constants[142])))
    algebraic[92] = constants[141]*constants[142]*log(constants[71]*states[28])+constants[118]*constants[143]*algebraic[74]
    algebraic[122] = constants[141]*constants[142]*log(constants[74]*states[31])+constants[122]*constants[143]*algebraic[74]
    algebraic[123] = constants[10]*(exp(algebraic[92]/(constants[141]*constants[142]))-exp(algebraic[122]/(constants[141]*constants[142])))
    algebraic[104] = constants[141]*constants[142]*log(constants[71]*states[28])+constants[121]*constants[143]*algebraic[74]
    algebraic[146] = constants[141]*constants[142]*log(constants[72]*states[29])+constants[125]*constants[143]*algebraic[74]
    algebraic[147] = constants[23]*(exp(algebraic[104]/(constants[141]*constants[142]))-exp(algebraic[146]/(constants[141]*constants[142])))
    algebraic[161] = ((-algebraic[123]+algebraic[131])-algebraic[159])-algebraic[147]
    rates[28] = algebraic[161]
    algebraic[93] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[118]*constants[143]*algebraic[74]
    algebraic[124] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[122]*constants[143]*algebraic[74]
    algebraic[125] = constants[13]*(exp(algebraic[93]/(constants[141]*constants[142]))-exp(algebraic[124]/(constants[141]*constants[142])))
    algebraic[105] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[121]*constants[143]*algebraic[74]
    algebraic[148] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[125]*constants[143]*algebraic[74]
    algebraic[149] = constants[25]*(exp(algebraic[105]/(constants[141]*constants[142]))-exp(algebraic[148]/(constants[141]*constants[142])))
    algebraic[162] = ((-algebraic[125]+algebraic[133])--algebraic[159])-algebraic[149]
    rates[34] = algebraic[162]
    algebraic[82] = constants[141]*constants[142]*log(constants[72]*states[29])
    algebraic[110] = algebraic[82]
    algebraic[160] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[117]*algebraic[78]
    algebraic[163] = constants[31]*(exp(algebraic[110]/(constants[141]*constants[142]))-exp(algebraic[160]/(constants[141]*constants[142])))
    algebraic[94] = constants[141]*constants[142]*log(constants[72]*states[29])+constants[118]*constants[143]*algebraic[74]
    algebraic[126] = constants[141]*constants[142]*log(constants[75]*states[32])+constants[122]*constants[143]*algebraic[74]
    algebraic[127] = constants[11]*(exp(algebraic[94]/(constants[141]*constants[142]))-exp(algebraic[126]/(constants[141]*constants[142])))
    algebraic[165] = ((-algebraic[127]+algebraic[139])-algebraic[163])+algebraic[147]
    rates[29] = algebraic[165]
    algebraic[95] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[118]*constants[143]*algebraic[74]
    algebraic[128] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[122]*constants[143]*algebraic[74]
    algebraic[129] = constants[14]*(exp(algebraic[95]/(constants[141]*constants[142]))-exp(algebraic[128]/(constants[141]*constants[142])))
    algebraic[166] = ((-algebraic[129]+algebraic[141])--algebraic[163])+algebraic[149]
    rates[35] = algebraic[166]
    algebraic[83] = constants[141]*constants[142]*log(constants[73]*states[30])
    algebraic[111] = algebraic[83]
    algebraic[164] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[117]*algebraic[78]
    algebraic[167] = constants[28]*(exp(algebraic[111]/(constants[141]*constants[142]))-exp(algebraic[164]/(constants[141]*constants[142])))
    algebraic[98] = constants[141]*constants[142]*log(constants[73]*states[30])+constants[119]*constants[143]*algebraic[74]
    algebraic[134] = constants[141]*constants[142]*log(constants[74]*states[31])+constants[123]*constants[143]*algebraic[74]
    algebraic[135] = constants[16]*(exp(algebraic[98]/(constants[141]*constants[142]))-exp(algebraic[134]/(constants[141]*constants[142])))
    algebraic[102] = constants[141]*constants[142]*log(constants[73]*states[30])+constants[120]*constants[143]*algebraic[74]
    algebraic[142] = constants[141]*constants[142]*log(constants[75]*states[32])+constants[124]*constants[143]*algebraic[74]
    algebraic[143] = constants[20]*(exp(algebraic[102]/(constants[141]*constants[142]))-exp(algebraic[142]/(constants[141]*constants[142])))
    algebraic[169] = ((-algebraic[143]+algebraic[119])-algebraic[135])-algebraic[167]
    rates[30] = algebraic[169]
    algebraic[99] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[119]*constants[143]*algebraic[74]
    algebraic[136] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[123]*constants[143]*algebraic[74]
    algebraic[137] = constants[18]*(exp(algebraic[99]/(constants[141]*constants[142]))-exp(algebraic[136]/(constants[141]*constants[142])))
    algebraic[103] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[120]*constants[143]*algebraic[74]
    algebraic[144] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[124]*constants[143]*algebraic[74]
    algebraic[145] = constants[22]*(exp(algebraic[103]/(constants[141]*constants[142]))-exp(algebraic[144]/(constants[141]*constants[142])))
    algebraic[170] = ((-algebraic[145]+algebraic[121])-algebraic[137])--algebraic[167]
    rates[36] = algebraic[170]
    algebraic[84] = constants[141]*constants[142]*log(constants[74]*states[31])
    algebraic[112] = algebraic[84]
    algebraic[168] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[117]*algebraic[78]
    algebraic[171] = constants[30]*(exp(algebraic[112]/(constants[141]*constants[142]))-exp(algebraic[168]/(constants[141]*constants[142])))
    algebraic[106] = constants[141]*constants[142]*log(constants[74]*states[31])+constants[121]*constants[143]*algebraic[74]
    algebraic[150] = constants[141]*constants[142]*log(constants[75]*states[32])+constants[125]*constants[143]*algebraic[74]
    algebraic[151] = constants[24]*(exp(algebraic[106]/(constants[141]*constants[142]))-exp(algebraic[150]/(constants[141]*constants[142])))
    algebraic[173] = ((algebraic[135]+algebraic[123])-algebraic[171])-algebraic[151]
    rates[31] = algebraic[173]
    algebraic[86] = constants[141]*constants[142]*log(constants[75]*states[32])
    algebraic[113] = algebraic[86]
    algebraic[172] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[117]*algebraic[78]
    algebraic[174] = constants[32]*(exp(algebraic[113]/(constants[141]*constants[142]))-exp(algebraic[172]/(constants[141]*constants[142])))
    algebraic[176] = ((algebraic[143]+algebraic[127])-algebraic[174])+algebraic[151]
    rates[32] = algebraic[176]
    algebraic[85] = constants[141]*constants[142]*log(constants[80]*states[37])
    algebraic[88] = algebraic[78]+constants[147]*constants[143]*algebraic[74]+algebraic[85]
    algebraic[76] = constants[141]*constants[142]*log(constants[69]*states[11])
    algebraic[116] = algebraic[76]+algebraic[85]
    algebraic[114] = constants[147]*constants[143]*algebraic[74]
    algebraic[175] = custom_piecewise([equal(algebraic[114] , 0.00000), constants[7]*(exp(algebraic[88]/(constants[141]*constants[142]))-exp(algebraic[116]/(constants[141]*constants[142]))) , True, (((constants[7]*algebraic[114])/(constants[141]*constants[142]))/(exp(algebraic[114]/(constants[141]*constants[142]))-1.00000))*(exp(algebraic[88]/(constants[141]*constants[142]))-exp(algebraic[116]/(constants[141]*constants[142])))])
    algebraic[107] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[121]*constants[143]*algebraic[74]
    algebraic[152] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[125]*constants[143]*algebraic[74]
    algebraic[153] = constants[26]*(exp(algebraic[107]/(constants[141]*constants[142]))-exp(algebraic[152]/(constants[141]*constants[142])))
    algebraic[178] = ((algebraic[137]+algebraic[125])-((-algebraic[171]+algebraic[175])-algebraic[175]))-algebraic[153]
    rates[37] = algebraic[178]
    algebraic[87] = constants[141]*constants[142]*log(constants[81]*states[38])
    algebraic[89] = algebraic[78]+constants[147]*constants[143]*algebraic[74]+algebraic[87]
    algebraic[117] = algebraic[76]+algebraic[87]
    algebraic[115] = constants[147]*constants[143]*algebraic[74]
    algebraic[177] = custom_piecewise([equal(algebraic[115] , 0.00000), constants[8]*(exp(algebraic[89]/(constants[141]*constants[142]))-exp(algebraic[117]/(constants[141]*constants[142]))) , True, (((constants[8]*algebraic[115])/(constants[141]*constants[142]))/(exp(algebraic[115]/(constants[141]*constants[142]))-1.00000))*(exp(algebraic[89]/(constants[141]*constants[142]))-exp(algebraic[117]/(constants[141]*constants[142])))])
    algebraic[179] = ((algebraic[145]+algebraic[129])-((-algebraic[174]+algebraic[177])-algebraic[177]))+algebraic[153]
    rates[38] = algebraic[179]
    algebraic[188] = constants[141]*constants[142]*log(constants[82]*states[39])
    algebraic[194] = algebraic[188]
    algebraic[187] = constants[141]*constants[142]*log(constants[88]*states[5])
    algebraic[189] = constants[141]*constants[142]*log(constants[83]*states[40])
    algebraic[200] = constants[127]*algebraic[187]+algebraic[189]
    algebraic[201] = constants[33]*(exp(algebraic[194]/(constants[141]*constants[142]))-exp(algebraic[200]/(constants[141]*constants[142])))
    algebraic[203] = constants[127]*algebraic[201]
    rates[5] = algebraic[203]
    algebraic[185] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[195] = algebraic[189]+algebraic[185]
    algebraic[190] = constants[141]*constants[142]*log(constants[84]*states[41])
    algebraic[202] = algebraic[190]
    algebraic[204] = constants[34]*(exp(algebraic[195]/(constants[141]*constants[142]))-exp(algebraic[202]/(constants[141]*constants[142])))
    algebraic[206] = algebraic[201]-algebraic[204]
    rates[40] = algebraic[206]
    algebraic[196] = algebraic[190]
    algebraic[191] = constants[141]*constants[142]*log(constants[85]*states[42])
    algebraic[205] = algebraic[191]
    algebraic[207] = constants[35]*(exp(algebraic[196]/(constants[141]*constants[142]))-exp(algebraic[205]/(constants[141]*constants[142])))
    algebraic[209] = algebraic[204]-algebraic[207]
    rates[41] = algebraic[209]
    algebraic[197] = algebraic[191]
    algebraic[184] = constants[141]*constants[142]*log(constants[69]*states[11])
    algebraic[192] = constants[141]*constants[142]*log(constants[86]*states[43])
    algebraic[208] = algebraic[192]+algebraic[184]
    algebraic[210] = constants[36]*(exp(algebraic[197]/(constants[141]*constants[142]))-exp(algebraic[208]/(constants[141]*constants[142])))
    algebraic[212] = -algebraic[210]+algebraic[207]
    rates[42] = algebraic[212]
    algebraic[186] = constants[141]*constants[142]*log(constants[89]*states[6])
    algebraic[198] = algebraic[192]+constants[126]*algebraic[186]
    algebraic[193] = constants[141]*constants[142]*log(constants[87]*states[44])
    algebraic[211] = algebraic[193]
    algebraic[213] = constants[37]*(exp(algebraic[198]/(constants[141]*constants[142]))-exp(algebraic[211]/(constants[141]*constants[142])))
    algebraic[214] = -constants[126]*algebraic[213]
    rates[6] = algebraic[214]
    algebraic[215] = -algebraic[213]+algebraic[210]
    rates[43] = algebraic[215]
    algebraic[183] = states[0]/constants[133]
    algebraic[199] = constants[141]*constants[142]*log(constants[87]*states[44])+constants[128]*constants[143]*algebraic[183]
    algebraic[216] = constants[141]*constants[142]*log(constants[82]*states[39])+constants[129]*constants[143]*algebraic[183]
    algebraic[217] = constants[38]*(exp(algebraic[199]/(constants[141]*constants[142]))-exp(algebraic[216]/(constants[141]*constants[142])))
    algebraic[218] = algebraic[217]-algebraic[201]
    rates[39] = algebraic[218]
    algebraic[219] = -algebraic[217]+algebraic[213]
    rates[44] = algebraic[219]
    algebraic[181] = algebraic[177]+algebraic[175]
    algebraic[221] = algebraic[210]
    algebraic[224] = constants[141]*constants[142]*log(constants[69]*states[11])
    algebraic[225] = constants[141]*constants[142]*log(constants[90]*states[21])
    algebraic[226] = constants[141]*constants[142]*log(constants[91]*states[22])
    algebraic[228] = constants[40]*(exp(algebraic[226]/(constants[141]*constants[142]))-exp((algebraic[224]+algebraic[225])/(constants[141]*constants[142])))
    rates[11] = algebraic[181]+algebraic[221]+algebraic[228]
    algebraic[223] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[227] = constants[39]*(exp((algebraic[223]+algebraic[225])/(constants[141]*constants[142]))-exp(algebraic[226]/(constants[141]*constants[142])))
    rates[21] = -algebraic[227]+algebraic[228]
    rates[22] = algebraic[227]-algebraic[228]
    algebraic[180] = constants[143]*((((((((((((((((((((((((((((((((((((constants[124]*algebraic[141]-constants[120]*algebraic[141])+constants[125]*algebraic[149])-constants[121]*algebraic[149])+constants[123]*algebraic[137])-constants[119]*algebraic[137])+constants[124]*algebraic[145])-constants[120]*algebraic[145])+constants[125]*algebraic[153])-constants[121]*algebraic[153])+constants[123]*algebraic[133])-constants[119]*algebraic[133])+constants[122]*algebraic[129])-constants[118]*algebraic[129])+constants[122]*algebraic[125])-constants[118]*algebraic[125])+constants[122]*algebraic[121])-constants[118]*algebraic[121])+constants[125]*algebraic[151])-constants[121]*algebraic[151])+constants[124]*algebraic[143])-constants[120]*algebraic[143])+constants[123]*algebraic[135])-constants[119]*algebraic[135])+constants[125]*algebraic[147])-constants[121]*algebraic[147])+constants[124]*algebraic[139])-constants[120]*algebraic[139])+constants[123]*algebraic[131])-constants[119]*algebraic[131])+constants[122]*algebraic[127])-constants[118]*algebraic[127])+constants[122]*algebraic[123])-constants[118]*algebraic[123])+constants[122]*algebraic[119])-constants[118]*algebraic[119])-(constants[147]*algebraic[175]+constants[147]*algebraic[177]))
    algebraic[220] = constants[143]*(-constants[128]*algebraic[217]+constants[129]*algebraic[217])
    algebraic[230] = -constants[147]*constants[143]*algebraic[228]
    algebraic[11] = voi-floor(voi/constants[135])*constants[135]
    algebraic[28] = custom_piecewise([greater_equal(algebraic[11] , 0.300000) & less_equal(algebraic[11] , 0.300000+constants[136]), (0.00000*0.0300000*constants[133])/constants[136] , True, 0.00000])
    algebraic[232] = algebraic[180]+algebraic[220]+algebraic[230]+algebraic[28]
    rates[0] = algebraic[232]
    algebraic[231] = constants[141]*constants[142]*log(constants[68]*states[1])
    algebraic[233] = constants[141]*constants[142]*log(constants[100]*states[45])
    algebraic[236] = constants[141]*constants[142]*log(constants[103]*states[48])
    algebraic[238] = constants[47]*(exp(algebraic[236]/(constants[141]*constants[142]))-exp((algebraic[233]+constants[164]*algebraic[231])/(constants[141]*constants[142])))
    algebraic[234] = constants[141]*constants[142]*log(constants[101]*states[46])
    algebraic[240] = constants[48]*(exp((algebraic[233]+constants[163]*algebraic[231])/(constants[141]*constants[142]))-exp(algebraic[234]/(constants[141]*constants[142])))
    rates[45] = algebraic[238]-algebraic[240]
    algebraic[235] = constants[141]*constants[142]*log(constants[102]*states[47])
    algebraic[242] = constants[49]*(exp((algebraic[234]+constants[164]*algebraic[231])/(constants[141]*constants[142]))-exp(algebraic[235]/(constants[141]*constants[142])))
    rates[46] = algebraic[240]-algebraic[242]
    algebraic[244] = constants[50]*(exp(algebraic[235]/(constants[141]*constants[142]))-exp((algebraic[236]+constants[163]*algebraic[231])/(constants[141]*constants[142])))
    rates[48] = algebraic[244]-algebraic[238]
    rates[47] = algebraic[242]-algebraic[244]
    algebraic[68] = constants[141]*constants[142]*log(constants[68]*states[1])
    algebraic[70] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[72] = constants[6]*(exp(algebraic[68]/(constants[141]*constants[142]))-exp(algebraic[70]/(constants[141]*constants[142])))
    algebraic[182] = (((constants[117])*algebraic[167]+constants[117]*algebraic[171]+constants[117]*algebraic[163]+constants[117]*algebraic[159]+constants[117]*algebraic[155]+constants[117]*algebraic[174])-algebraic[175])-algebraic[177]
    algebraic[229] = constants[141]*constants[142]*log(constants[60]*states[20])
    algebraic[237] = constants[46]*exp(algebraic[236]/(constants[141]*constants[142]))*(exp(algebraic[229]/(constants[141]*constants[142]))-exp(algebraic[231]/(constants[141]*constants[142])))
    algebraic[246] = ((constants[164]*algebraic[238]-constants[163]*algebraic[240])-constants[164]*algebraic[242])+constants[163]*algebraic[244]
    rates[1] = -algebraic[72]+algebraic[182]+algebraic[237]+algebraic[246]
    algebraic[254] = constants[141]*constants[142]*log(constants[112]*states[57])
    algebraic[259] = constants[141]*constants[142]*log(constants[97]*states[17])
    algebraic[260] = algebraic[259]-constants[173]
    algebraic[261] = algebraic[254]+algebraic[260]
    algebraic[249] = constants[141]*constants[142]*log(constants[104]*states[49])
    algebraic[248] = constants[141]*constants[142]*log(constants[116]*states[24])
    algebraic[262] = algebraic[249]+algebraic[248]+algebraic[260]
    algebraic[279] = constants[59]*(exp(algebraic[261]/(constants[141]*constants[142]))-exp(algebraic[262]/(constants[141]*constants[142])))
    algebraic[281] = algebraic[279]
    rates[24] = algebraic[281]
    algebraic[247] = constants[141]*constants[142]*log(constants[114]*states[26])
    algebraic[263] = algebraic[249]+algebraic[247]+algebraic[260]
    algebraic[250] = constants[141]*constants[142]*log(constants[105]*states[50])
    algebraic[264] = algebraic[250]+algebraic[260]
    algebraic[280] = constants[51]*(exp(algebraic[263]/(constants[141]*constants[142]))-exp(algebraic[264]/(constants[141]*constants[142])))
    algebraic[283] = -algebraic[280]
    rates[26] = algebraic[283]
    algebraic[284] = algebraic[279]-algebraic[280]
    rates[49] = algebraic[284]
    algebraic[253] = constants[141]*constants[142]*log(constants[108]*states[53])
    algebraic[265] = algebraic[253]+algebraic[260]
    algebraic[245] = constants[141]*constants[142]*log(constants[115]*states[25])
    algebraic[255] = constants[141]*constants[142]*log(constants[109]*states[54])
    algebraic[266] = algebraic[245]+algebraic[255]+algebraic[260]
    algebraic[282] = constants[55]*(exp(algebraic[265]/(constants[141]*constants[142]))-exp(algebraic[266]/(constants[141]*constants[142])))
    algebraic[286] = algebraic[282]
    rates[25] = algebraic[286]
    algebraic[243] = constants[141]*constants[142]*log(constants[113]*states[23])
    algebraic[267] = algebraic[250]+algebraic[243]+algebraic[260]
    algebraic[251] = constants[141]*constants[142]*log(constants[106]*states[51])
    algebraic[268] = algebraic[251]+algebraic[260]
    algebraic[285] = constants[53]*(exp(algebraic[267]/(constants[141]*constants[142]))-exp(algebraic[268]/(constants[141]*constants[142])))
    algebraic[288] = algebraic[285]
    rates[51] = algebraic[288]
    algebraic[38] = (constants[141]*constants[142])*log(constants[60]*states[20])
    algebraic[48] = (constants[141]*constants[142])*log(constants[61]*states[4])
    algebraic[54] = constants[0]*(exp(algebraic[38]/(constants[141]*constants[142]))-exp(algebraic[48]/(constants[141]*constants[142])))
    algebraic[222] = -algebraic[204]
    algebraic[239] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[269] = algebraic[250]+constants[165]*algebraic[239]+algebraic[260]
    algebraic[252] = constants[141]*constants[142]*log(constants[107]*states[52])
    algebraic[270] = algebraic[252]+algebraic[260]
    algebraic[287] = constants[52]*(exp(algebraic[269]/(constants[141]*constants[142]))-exp(algebraic[270]/(constants[141]*constants[142])))
    algebraic[289] = -constants[165]*algebraic[287]
    algebraic[33] = custom_piecewise([greater_equal(algebraic[11] , 0.300000) & less_equal(algebraic[11] , 0.300000+constants[136]), 0.00000*8000.00 , True, 0.00000])
    rates[4] = ((-algebraic[66]*constants[131]+algebraic[289]+algebraic[54]+algebraic[72]+algebraic[222])-algebraic[227])+algebraic[33]
    algebraic[291] = algebraic[280]-algebraic[287]
    rates[50] = algebraic[291]
    algebraic[271] = algebraic[252]+algebraic[260]
    algebraic[272] = algebraic[253]+constants[167]*algebraic[243]+algebraic[260]
    algebraic[290] = constants[54]*(exp(algebraic[271]/(constants[141]*constants[142]))-exp(algebraic[272]/(constants[141]*constants[142])))
    algebraic[293] = algebraic[287]-algebraic[290]
    rates[52] = algebraic[293]
    algebraic[294] = algebraic[290]-algebraic[282]
    rates[53] = algebraic[294]
    algebraic[273] = algebraic[255]+algebraic[260]
    algebraic[241] = constants[141]*constants[142]*log(constants[60]*states[20])
    algebraic[257] = constants[141]*constants[142]*log(constants[110]*states[55])
    algebraic[274] = algebraic[257]+constants[166]*algebraic[241]+algebraic[260]
    algebraic[292] = constants[56]*(exp(algebraic[273]/(constants[141]*constants[142]))-exp(algebraic[274]/(constants[141]*constants[142])))
    algebraic[295] = constants[166]*algebraic[292]
    rates[20] = (-algebraic[54]-algebraic[237])+algebraic[295]
    algebraic[297] = algebraic[282]-algebraic[292]
    rates[54] = algebraic[297]
    algebraic[275] = algebraic[257]+constants[167]*algebraic[243]+algebraic[260]
    algebraic[258] = constants[141]*constants[142]*log(constants[111]*states[56])
    algebraic[276] = algebraic[258]+algebraic[260]
    algebraic[296] = constants[57]*(exp(algebraic[275]/(constants[141]*constants[142]))-exp(algebraic[276]/(constants[141]*constants[142])))
    algebraic[299] = algebraic[292]-algebraic[296]
    rates[55] = algebraic[299]
    algebraic[277] = algebraic[258]+algebraic[260]
    algebraic[278] = algebraic[243]+algebraic[254]+algebraic[260]
    algebraic[298] = constants[58]*(exp(algebraic[277]/(constants[141]*constants[142]))-exp(algebraic[278]/(constants[141]*constants[142])))
    algebraic[300] = ((constants[167]*algebraic[290]-algebraic[285])-constants[167]*algebraic[296])+algebraic[298]
    rates[23] = algebraic[300]
    algebraic[302] = algebraic[298]-algebraic[279]
    rates[57] = algebraic[302]
    algebraic[301] = algebraic[296]-algebraic[298]
    rates[56] = algebraic[301]
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[2] = custom_piecewise([less(voi , 0.0600000), 1.00000*constants[137] , greater(voi , 0.500000) & less(voi , 1.10000), -0.100000*constants[137] , True, 0.00000*constants[137]])
    algebraic[26] = algebraic[2]
    algebraic[30] = -constants[169]*algebraic[26]
    algebraic[35] = constants[171]*states[59]
    algebraic[41] = -algebraic[30]-algebraic[35]
    algebraic[51] = algebraic[41]
    algebraic[31] = -constants[175]*algebraic[26]
    algebraic[36] = constants[172]*states[60]
    algebraic[42] = -algebraic[31]-algebraic[36]
    algebraic[52] = algebraic[42]
    algebraic[34] = constants[141]*constants[142]*log(constants[95]*states[15])
    algebraic[40] = constants[141]*constants[142]*log(constants[98]*states[18])
    algebraic[50] = constants[141]*constants[142]*log(constants[99]*states[19])
    algebraic[56] = constants[45]*(exp((algebraic[34]+algebraic[40])/(constants[141]*constants[142]))-exp(algebraic[50]/(constants[141]*constants[142])))
    algebraic[0] = constants[141]*constants[142]*log(constants[92]*states[12])
    algebraic[25] = constants[141]*constants[142]*log(constants[93]*states[13])
    algebraic[29] = constants[141]*constants[142]*log(constants[94]*states[14])
    algebraic[55] = constants[41]*(exp((algebraic[0]+algebraic[25])/(constants[141]*constants[142]))-exp(algebraic[29]/(constants[141]*constants[142])))
    algebraic[49] = constants[141]*constants[142]*log(constants[97]*states[17])
    algebraic[60] = constants[42]*(exp(algebraic[29]/(constants[141]*constants[142]))-exp((algebraic[49]+algebraic[25])/(constants[141]*constants[142])))
    algebraic[39] = constants[141]*constants[142]*log(constants[96]*states[16])
    algebraic[62] = constants[43]*(exp((algebraic[49]+algebraic[34])/(constants[141]*constants[142]))-exp(algebraic[39]/(constants[141]*constants[142])))
    algebraic[58] = constants[141]*constants[142]*log(constants[62]*states[2])
    algebraic[61] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[63] = constants[141]*constants[142]*log(constants[63]*states[3])
    algebraic[66] = constants[1]*(exp((constants[131]*algebraic[61]+algebraic[58])/(constants[141]*constants[142]))-exp(algebraic[63]/(constants[141]*constants[142])))
    algebraic[65] = constants[44]*(exp(algebraic[39]/(constants[141]*constants[142]))-exp((algebraic[0]+algebraic[34])/(constants[141]*constants[142])))
    algebraic[64] = constants[141]*constants[142]*log(constants[64]*states[7])
    algebraic[67] = constants[141]*constants[142]*log(constants[65]*states[8])
    algebraic[73] = constants[2]*(exp((algebraic[64]+constants[130]*algebraic[63])/(constants[141]*constants[142]))-exp((algebraic[67]+constants[130]*algebraic[63])/(constants[141]*constants[142])))
    algebraic[69] = constants[141]*constants[142]*log(constants[66]*states[9])
    algebraic[75] = constants[3]*(exp(algebraic[67]/(constants[141]*constants[142]))-exp(algebraic[69]/(constants[141]*constants[142])))
    algebraic[71] = constants[141]*constants[142]*log(constants[67]*states[10])
    algebraic[77] = constants[4]*(exp(algebraic[69]/(constants[141]*constants[142]))-exp(algebraic[71]/(constants[141]*constants[142])))
    algebraic[79] = constants[5]*(exp(algebraic[71]/(constants[141]*constants[142]))-exp(algebraic[67]/(constants[141]*constants[142])))
    algebraic[80] = constants[141]*constants[142]*log(constants[70]*states[27])
    algebraic[108] = algebraic[80]
    algebraic[78] = constants[141]*constants[142]*log(constants[68]*states[1])
    algebraic[154] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[117]*algebraic[78]
    algebraic[155] = constants[27]*(exp(algebraic[108]/(constants[141]*constants[142]))-exp(algebraic[154]/(constants[141]*constants[142])))
    algebraic[74] = states[0]/constants[133]
    algebraic[90] = constants[141]*constants[142]*log(constants[70]*states[27])+constants[118]*constants[143]*algebraic[74]
    algebraic[118] = constants[141]*constants[142]*log(constants[73]*states[30])+constants[122]*constants[143]*algebraic[74]
    algebraic[119] = constants[9]*(exp(algebraic[90]/(constants[141]*constants[142]))-exp(algebraic[118]/(constants[141]*constants[142])))
    algebraic[96] = constants[141]*constants[142]*log(constants[70]*states[27])+constants[119]*constants[143]*algebraic[74]
    algebraic[130] = constants[141]*constants[142]*log(constants[71]*states[28])+constants[123]*constants[143]*algebraic[74]
    algebraic[131] = constants[15]*(exp(algebraic[96]/(constants[141]*constants[142]))-exp(algebraic[130]/(constants[141]*constants[142])))
    algebraic[100] = constants[141]*constants[142]*log(constants[70]*states[27])+constants[120]*constants[143]*algebraic[74]
    algebraic[138] = constants[141]*constants[142]*log(constants[72]*states[29])+constants[124]*constants[143]*algebraic[74]
    algebraic[139] = constants[19]*(exp(algebraic[100]/(constants[141]*constants[142]))-exp(algebraic[138]/(constants[141]*constants[142])))
    algebraic[157] = ((-algebraic[119]-algebraic[131])-algebraic[139])-algebraic[155]
    algebraic[91] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[118]*constants[143]*algebraic[74]
    algebraic[120] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[122]*constants[143]*algebraic[74]
    algebraic[121] = constants[12]*(exp(algebraic[91]/(constants[141]*constants[142]))-exp(algebraic[120]/(constants[141]*constants[142])))
    algebraic[97] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[119]*constants[143]*algebraic[74]
    algebraic[132] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[123]*constants[143]*algebraic[74]
    algebraic[133] = constants[17]*(exp(algebraic[97]/(constants[141]*constants[142]))-exp(algebraic[132]/(constants[141]*constants[142])))
    algebraic[101] = constants[141]*constants[142]*log(constants[76]*states[33])+constants[120]*constants[143]*algebraic[74]
    algebraic[140] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[124]*constants[143]*algebraic[74]
    algebraic[141] = constants[21]*(exp(algebraic[101]/(constants[141]*constants[142]))-exp(algebraic[140]/(constants[141]*constants[142])))
    algebraic[158] = ((-algebraic[121]-algebraic[133])-algebraic[141])--algebraic[155]
    algebraic[81] = constants[141]*constants[142]*log(constants[71]*states[28])
    algebraic[109] = algebraic[81]
    algebraic[156] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[117]*algebraic[78]
    algebraic[159] = constants[29]*(exp(algebraic[109]/(constants[141]*constants[142]))-exp(algebraic[156]/(constants[141]*constants[142])))
    algebraic[92] = constants[141]*constants[142]*log(constants[71]*states[28])+constants[118]*constants[143]*algebraic[74]
    algebraic[122] = constants[141]*constants[142]*log(constants[74]*states[31])+constants[122]*constants[143]*algebraic[74]
    algebraic[123] = constants[10]*(exp(algebraic[92]/(constants[141]*constants[142]))-exp(algebraic[122]/(constants[141]*constants[142])))
    algebraic[104] = constants[141]*constants[142]*log(constants[71]*states[28])+constants[121]*constants[143]*algebraic[74]
    algebraic[146] = constants[141]*constants[142]*log(constants[72]*states[29])+constants[125]*constants[143]*algebraic[74]
    algebraic[147] = constants[23]*(exp(algebraic[104]/(constants[141]*constants[142]))-exp(algebraic[146]/(constants[141]*constants[142])))
    algebraic[161] = ((-algebraic[123]+algebraic[131])-algebraic[159])-algebraic[147]
    algebraic[93] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[118]*constants[143]*algebraic[74]
    algebraic[124] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[122]*constants[143]*algebraic[74]
    algebraic[125] = constants[13]*(exp(algebraic[93]/(constants[141]*constants[142]))-exp(algebraic[124]/(constants[141]*constants[142])))
    algebraic[105] = constants[141]*constants[142]*log(constants[77]*states[34])+constants[121]*constants[143]*algebraic[74]
    algebraic[148] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[125]*constants[143]*algebraic[74]
    algebraic[149] = constants[25]*(exp(algebraic[105]/(constants[141]*constants[142]))-exp(algebraic[148]/(constants[141]*constants[142])))
    algebraic[162] = ((-algebraic[125]+algebraic[133])--algebraic[159])-algebraic[149]
    algebraic[82] = constants[141]*constants[142]*log(constants[72]*states[29])
    algebraic[110] = algebraic[82]
    algebraic[160] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[117]*algebraic[78]
    algebraic[163] = constants[31]*(exp(algebraic[110]/(constants[141]*constants[142]))-exp(algebraic[160]/(constants[141]*constants[142])))
    algebraic[94] = constants[141]*constants[142]*log(constants[72]*states[29])+constants[118]*constants[143]*algebraic[74]
    algebraic[126] = constants[141]*constants[142]*log(constants[75]*states[32])+constants[122]*constants[143]*algebraic[74]
    algebraic[127] = constants[11]*(exp(algebraic[94]/(constants[141]*constants[142]))-exp(algebraic[126]/(constants[141]*constants[142])))
    algebraic[165] = ((-algebraic[127]+algebraic[139])-algebraic[163])+algebraic[147]
    algebraic[95] = constants[141]*constants[142]*log(constants[78]*states[35])+constants[118]*constants[143]*algebraic[74]
    algebraic[128] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[122]*constants[143]*algebraic[74]
    algebraic[129] = constants[14]*(exp(algebraic[95]/(constants[141]*constants[142]))-exp(algebraic[128]/(constants[141]*constants[142])))
    algebraic[166] = ((-algebraic[129]+algebraic[141])--algebraic[163])+algebraic[149]
    algebraic[83] = constants[141]*constants[142]*log(constants[73]*states[30])
    algebraic[111] = algebraic[83]
    algebraic[164] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[117]*algebraic[78]
    algebraic[167] = constants[28]*(exp(algebraic[111]/(constants[141]*constants[142]))-exp(algebraic[164]/(constants[141]*constants[142])))
    algebraic[98] = constants[141]*constants[142]*log(constants[73]*states[30])+constants[119]*constants[143]*algebraic[74]
    algebraic[134] = constants[141]*constants[142]*log(constants[74]*states[31])+constants[123]*constants[143]*algebraic[74]
    algebraic[135] = constants[16]*(exp(algebraic[98]/(constants[141]*constants[142]))-exp(algebraic[134]/(constants[141]*constants[142])))
    algebraic[102] = constants[141]*constants[142]*log(constants[73]*states[30])+constants[120]*constants[143]*algebraic[74]
    algebraic[142] = constants[141]*constants[142]*log(constants[75]*states[32])+constants[124]*constants[143]*algebraic[74]
    algebraic[143] = constants[20]*(exp(algebraic[102]/(constants[141]*constants[142]))-exp(algebraic[142]/(constants[141]*constants[142])))
    algebraic[169] = ((-algebraic[143]+algebraic[119])-algebraic[135])-algebraic[167]
    algebraic[99] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[119]*constants[143]*algebraic[74]
    algebraic[136] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[123]*constants[143]*algebraic[74]
    algebraic[137] = constants[18]*(exp(algebraic[99]/(constants[141]*constants[142]))-exp(algebraic[136]/(constants[141]*constants[142])))
    algebraic[103] = constants[141]*constants[142]*log(constants[79]*states[36])+constants[120]*constants[143]*algebraic[74]
    algebraic[144] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[124]*constants[143]*algebraic[74]
    algebraic[145] = constants[22]*(exp(algebraic[103]/(constants[141]*constants[142]))-exp(algebraic[144]/(constants[141]*constants[142])))
    algebraic[170] = ((-algebraic[145]+algebraic[121])-algebraic[137])--algebraic[167]
    algebraic[84] = constants[141]*constants[142]*log(constants[74]*states[31])
    algebraic[112] = algebraic[84]
    algebraic[168] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[117]*algebraic[78]
    algebraic[171] = constants[30]*(exp(algebraic[112]/(constants[141]*constants[142]))-exp(algebraic[168]/(constants[141]*constants[142])))
    algebraic[106] = constants[141]*constants[142]*log(constants[74]*states[31])+constants[121]*constants[143]*algebraic[74]
    algebraic[150] = constants[141]*constants[142]*log(constants[75]*states[32])+constants[125]*constants[143]*algebraic[74]
    algebraic[151] = constants[24]*(exp(algebraic[106]/(constants[141]*constants[142]))-exp(algebraic[150]/(constants[141]*constants[142])))
    algebraic[173] = ((algebraic[135]+algebraic[123])-algebraic[171])-algebraic[151]
    algebraic[86] = constants[141]*constants[142]*log(constants[75]*states[32])
    algebraic[113] = algebraic[86]
    algebraic[172] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[117]*algebraic[78]
    algebraic[174] = constants[32]*(exp(algebraic[113]/(constants[141]*constants[142]))-exp(algebraic[172]/(constants[141]*constants[142])))
    algebraic[176] = ((algebraic[143]+algebraic[127])-algebraic[174])+algebraic[151]
    algebraic[85] = constants[141]*constants[142]*log(constants[80]*states[37])
    algebraic[88] = algebraic[78]+constants[147]*constants[143]*algebraic[74]+algebraic[85]
    algebraic[76] = constants[141]*constants[142]*log(constants[69]*states[11])
    algebraic[116] = algebraic[76]+algebraic[85]
    algebraic[114] = constants[147]*constants[143]*algebraic[74]
    algebraic[175] = custom_piecewise([equal(algebraic[114] , 0.00000), constants[7]*(exp(algebraic[88]/(constants[141]*constants[142]))-exp(algebraic[116]/(constants[141]*constants[142]))) , True, (((constants[7]*algebraic[114])/(constants[141]*constants[142]))/(exp(algebraic[114]/(constants[141]*constants[142]))-1.00000))*(exp(algebraic[88]/(constants[141]*constants[142]))-exp(algebraic[116]/(constants[141]*constants[142])))])
    algebraic[107] = constants[141]*constants[142]*log(constants[80]*states[37])+constants[121]*constants[143]*algebraic[74]
    algebraic[152] = constants[141]*constants[142]*log(constants[81]*states[38])+constants[125]*constants[143]*algebraic[74]
    algebraic[153] = constants[26]*(exp(algebraic[107]/(constants[141]*constants[142]))-exp(algebraic[152]/(constants[141]*constants[142])))
    algebraic[178] = ((algebraic[137]+algebraic[125])-((-algebraic[171]+algebraic[175])-algebraic[175]))-algebraic[153]
    algebraic[87] = constants[141]*constants[142]*log(constants[81]*states[38])
    algebraic[89] = algebraic[78]+constants[147]*constants[143]*algebraic[74]+algebraic[87]
    algebraic[117] = algebraic[76]+algebraic[87]
    algebraic[115] = constants[147]*constants[143]*algebraic[74]
    algebraic[177] = custom_piecewise([equal(algebraic[115] , 0.00000), constants[8]*(exp(algebraic[89]/(constants[141]*constants[142]))-exp(algebraic[117]/(constants[141]*constants[142]))) , True, (((constants[8]*algebraic[115])/(constants[141]*constants[142]))/(exp(algebraic[115]/(constants[141]*constants[142]))-1.00000))*(exp(algebraic[89]/(constants[141]*constants[142]))-exp(algebraic[117]/(constants[141]*constants[142])))])
    algebraic[179] = ((algebraic[145]+algebraic[129])-((-algebraic[174]+algebraic[177])-algebraic[177]))+algebraic[153]
    algebraic[188] = constants[141]*constants[142]*log(constants[82]*states[39])
    algebraic[194] = algebraic[188]
    algebraic[187] = constants[141]*constants[142]*log(constants[88]*states[5])
    algebraic[189] = constants[141]*constants[142]*log(constants[83]*states[40])
    algebraic[200] = constants[127]*algebraic[187]+algebraic[189]
    algebraic[201] = constants[33]*(exp(algebraic[194]/(constants[141]*constants[142]))-exp(algebraic[200]/(constants[141]*constants[142])))
    algebraic[203] = constants[127]*algebraic[201]
    algebraic[185] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[195] = algebraic[189]+algebraic[185]
    algebraic[190] = constants[141]*constants[142]*log(constants[84]*states[41])
    algebraic[202] = algebraic[190]
    algebraic[204] = constants[34]*(exp(algebraic[195]/(constants[141]*constants[142]))-exp(algebraic[202]/(constants[141]*constants[142])))
    algebraic[206] = algebraic[201]-algebraic[204]
    algebraic[196] = algebraic[190]
    algebraic[191] = constants[141]*constants[142]*log(constants[85]*states[42])
    algebraic[205] = algebraic[191]
    algebraic[207] = constants[35]*(exp(algebraic[196]/(constants[141]*constants[142]))-exp(algebraic[205]/(constants[141]*constants[142])))
    algebraic[209] = algebraic[204]-algebraic[207]
    algebraic[197] = algebraic[191]
    algebraic[184] = constants[141]*constants[142]*log(constants[69]*states[11])
    algebraic[192] = constants[141]*constants[142]*log(constants[86]*states[43])
    algebraic[208] = algebraic[192]+algebraic[184]
    algebraic[210] = constants[36]*(exp(algebraic[197]/(constants[141]*constants[142]))-exp(algebraic[208]/(constants[141]*constants[142])))
    algebraic[212] = -algebraic[210]+algebraic[207]
    algebraic[186] = constants[141]*constants[142]*log(constants[89]*states[6])
    algebraic[198] = algebraic[192]+constants[126]*algebraic[186]
    algebraic[193] = constants[141]*constants[142]*log(constants[87]*states[44])
    algebraic[211] = algebraic[193]
    algebraic[213] = constants[37]*(exp(algebraic[198]/(constants[141]*constants[142]))-exp(algebraic[211]/(constants[141]*constants[142])))
    algebraic[214] = -constants[126]*algebraic[213]
    algebraic[215] = -algebraic[213]+algebraic[210]
    algebraic[183] = states[0]/constants[133]
    algebraic[199] = constants[141]*constants[142]*log(constants[87]*states[44])+constants[128]*constants[143]*algebraic[183]
    algebraic[216] = constants[141]*constants[142]*log(constants[82]*states[39])+constants[129]*constants[143]*algebraic[183]
    algebraic[217] = constants[38]*(exp(algebraic[199]/(constants[141]*constants[142]))-exp(algebraic[216]/(constants[141]*constants[142])))
    algebraic[218] = algebraic[217]-algebraic[201]
    algebraic[219] = -algebraic[217]+algebraic[213]
    algebraic[181] = algebraic[177]+algebraic[175]
    algebraic[221] = algebraic[210]
    algebraic[224] = constants[141]*constants[142]*log(constants[69]*states[11])
    algebraic[225] = constants[141]*constants[142]*log(constants[90]*states[21])
    algebraic[226] = constants[141]*constants[142]*log(constants[91]*states[22])
    algebraic[228] = constants[40]*(exp(algebraic[226]/(constants[141]*constants[142]))-exp((algebraic[224]+algebraic[225])/(constants[141]*constants[142])))
    algebraic[223] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[227] = constants[39]*(exp((algebraic[223]+algebraic[225])/(constants[141]*constants[142]))-exp(algebraic[226]/(constants[141]*constants[142])))
    algebraic[180] = constants[143]*((((((((((((((((((((((((((((((((((((constants[124]*algebraic[141]-constants[120]*algebraic[141])+constants[125]*algebraic[149])-constants[121]*algebraic[149])+constants[123]*algebraic[137])-constants[119]*algebraic[137])+constants[124]*algebraic[145])-constants[120]*algebraic[145])+constants[125]*algebraic[153])-constants[121]*algebraic[153])+constants[123]*algebraic[133])-constants[119]*algebraic[133])+constants[122]*algebraic[129])-constants[118]*algebraic[129])+constants[122]*algebraic[125])-constants[118]*algebraic[125])+constants[122]*algebraic[121])-constants[118]*algebraic[121])+constants[125]*algebraic[151])-constants[121]*algebraic[151])+constants[124]*algebraic[143])-constants[120]*algebraic[143])+constants[123]*algebraic[135])-constants[119]*algebraic[135])+constants[125]*algebraic[147])-constants[121]*algebraic[147])+constants[124]*algebraic[139])-constants[120]*algebraic[139])+constants[123]*algebraic[131])-constants[119]*algebraic[131])+constants[122]*algebraic[127])-constants[118]*algebraic[127])+constants[122]*algebraic[123])-constants[118]*algebraic[123])+constants[122]*algebraic[119])-constants[118]*algebraic[119])-(constants[147]*algebraic[175]+constants[147]*algebraic[177]))
    algebraic[220] = constants[143]*(-constants[128]*algebraic[217]+constants[129]*algebraic[217])
    algebraic[230] = -constants[147]*constants[143]*algebraic[228]
    algebraic[11] = voi-floor(voi/constants[135])*constants[135]
    algebraic[28] = custom_piecewise([greater_equal(algebraic[11] , 0.300000) & less_equal(algebraic[11] , 0.300000+constants[136]), (0.00000*0.0300000*constants[133])/constants[136] , True, 0.00000])
    algebraic[232] = algebraic[180]+algebraic[220]+algebraic[230]+algebraic[28]
    algebraic[231] = constants[141]*constants[142]*log(constants[68]*states[1])
    algebraic[233] = constants[141]*constants[142]*log(constants[100]*states[45])
    algebraic[236] = constants[141]*constants[142]*log(constants[103]*states[48])
    algebraic[238] = constants[47]*(exp(algebraic[236]/(constants[141]*constants[142]))-exp((algebraic[233]+constants[164]*algebraic[231])/(constants[141]*constants[142])))
    algebraic[234] = constants[141]*constants[142]*log(constants[101]*states[46])
    algebraic[240] = constants[48]*(exp((algebraic[233]+constants[163]*algebraic[231])/(constants[141]*constants[142]))-exp(algebraic[234]/(constants[141]*constants[142])))
    algebraic[235] = constants[141]*constants[142]*log(constants[102]*states[47])
    algebraic[242] = constants[49]*(exp((algebraic[234]+constants[164]*algebraic[231])/(constants[141]*constants[142]))-exp(algebraic[235]/(constants[141]*constants[142])))
    algebraic[244] = constants[50]*(exp(algebraic[235]/(constants[141]*constants[142]))-exp((algebraic[236]+constants[163]*algebraic[231])/(constants[141]*constants[142])))
    algebraic[68] = constants[141]*constants[142]*log(constants[68]*states[1])
    algebraic[70] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[72] = constants[6]*(exp(algebraic[68]/(constants[141]*constants[142]))-exp(algebraic[70]/(constants[141]*constants[142])))
    algebraic[182] = (((constants[117])*algebraic[167]+constants[117]*algebraic[171]+constants[117]*algebraic[163]+constants[117]*algebraic[159]+constants[117]*algebraic[155]+constants[117]*algebraic[174])-algebraic[175])-algebraic[177]
    algebraic[229] = constants[141]*constants[142]*log(constants[60]*states[20])
    algebraic[237] = constants[46]*exp(algebraic[236]/(constants[141]*constants[142]))*(exp(algebraic[229]/(constants[141]*constants[142]))-exp(algebraic[231]/(constants[141]*constants[142])))
    algebraic[246] = ((constants[164]*algebraic[238]-constants[163]*algebraic[240])-constants[164]*algebraic[242])+constants[163]*algebraic[244]
    algebraic[254] = constants[141]*constants[142]*log(constants[112]*states[57])
    algebraic[259] = constants[141]*constants[142]*log(constants[97]*states[17])
    algebraic[260] = algebraic[259]-constants[173]
    algebraic[261] = algebraic[254]+algebraic[260]
    algebraic[249] = constants[141]*constants[142]*log(constants[104]*states[49])
    algebraic[248] = constants[141]*constants[142]*log(constants[116]*states[24])
    algebraic[262] = algebraic[249]+algebraic[248]+algebraic[260]
    algebraic[279] = constants[59]*(exp(algebraic[261]/(constants[141]*constants[142]))-exp(algebraic[262]/(constants[141]*constants[142])))
    algebraic[281] = algebraic[279]
    algebraic[247] = constants[141]*constants[142]*log(constants[114]*states[26])
    algebraic[263] = algebraic[249]+algebraic[247]+algebraic[260]
    algebraic[250] = constants[141]*constants[142]*log(constants[105]*states[50])
    algebraic[264] = algebraic[250]+algebraic[260]
    algebraic[280] = constants[51]*(exp(algebraic[263]/(constants[141]*constants[142]))-exp(algebraic[264]/(constants[141]*constants[142])))
    algebraic[283] = -algebraic[280]
    algebraic[284] = algebraic[279]-algebraic[280]
    algebraic[253] = constants[141]*constants[142]*log(constants[108]*states[53])
    algebraic[265] = algebraic[253]+algebraic[260]
    algebraic[245] = constants[141]*constants[142]*log(constants[115]*states[25])
    algebraic[255] = constants[141]*constants[142]*log(constants[109]*states[54])
    algebraic[266] = algebraic[245]+algebraic[255]+algebraic[260]
    algebraic[282] = constants[55]*(exp(algebraic[265]/(constants[141]*constants[142]))-exp(algebraic[266]/(constants[141]*constants[142])))
    algebraic[286] = algebraic[282]
    algebraic[243] = constants[141]*constants[142]*log(constants[113]*states[23])
    algebraic[267] = algebraic[250]+algebraic[243]+algebraic[260]
    algebraic[251] = constants[141]*constants[142]*log(constants[106]*states[51])
    algebraic[268] = algebraic[251]+algebraic[260]
    algebraic[285] = constants[53]*(exp(algebraic[267]/(constants[141]*constants[142]))-exp(algebraic[268]/(constants[141]*constants[142])))
    algebraic[288] = algebraic[285]
    algebraic[38] = (constants[141]*constants[142])*log(constants[60]*states[20])
    algebraic[48] = (constants[141]*constants[142])*log(constants[61]*states[4])
    algebraic[54] = constants[0]*(exp(algebraic[38]/(constants[141]*constants[142]))-exp(algebraic[48]/(constants[141]*constants[142])))
    algebraic[222] = -algebraic[204]
    algebraic[239] = constants[141]*constants[142]*log(constants[61]*states[4])
    algebraic[269] = algebraic[250]+constants[165]*algebraic[239]+algebraic[260]
    algebraic[252] = constants[141]*constants[142]*log(constants[107]*states[52])
    algebraic[270] = algebraic[252]+algebraic[260]
    algebraic[287] = constants[52]*(exp(algebraic[269]/(constants[141]*constants[142]))-exp(algebraic[270]/(constants[141]*constants[142])))
    algebraic[289] = -constants[165]*algebraic[287]
    algebraic[33] = custom_piecewise([greater_equal(algebraic[11] , 0.300000) & less_equal(algebraic[11] , 0.300000+constants[136]), 0.00000*8000.00 , True, 0.00000])
    algebraic[291] = algebraic[280]-algebraic[287]
    algebraic[271] = algebraic[252]+algebraic[260]
    algebraic[272] = algebraic[253]+constants[167]*algebraic[243]+algebraic[260]
    algebraic[290] = constants[54]*(exp(algebraic[271]/(constants[141]*constants[142]))-exp(algebraic[272]/(constants[141]*constants[142])))
    algebraic[293] = algebraic[287]-algebraic[290]
    algebraic[294] = algebraic[290]-algebraic[282]
    algebraic[273] = algebraic[255]+algebraic[260]
    algebraic[241] = constants[141]*constants[142]*log(constants[60]*states[20])
    algebraic[257] = constants[141]*constants[142]*log(constants[110]*states[55])
    algebraic[274] = algebraic[257]+constants[166]*algebraic[241]+algebraic[260]
    algebraic[292] = constants[56]*(exp(algebraic[273]/(constants[141]*constants[142]))-exp(algebraic[274]/(constants[141]*constants[142])))
    algebraic[295] = constants[166]*algebraic[292]
    algebraic[297] = algebraic[282]-algebraic[292]
    algebraic[275] = algebraic[257]+constants[167]*algebraic[243]+algebraic[260]
    algebraic[258] = constants[141]*constants[142]*log(constants[111]*states[56])
    algebraic[276] = algebraic[258]+algebraic[260]
    algebraic[296] = constants[57]*(exp(algebraic[275]/(constants[141]*constants[142]))-exp(algebraic[276]/(constants[141]*constants[142])))
    algebraic[299] = algebraic[292]-algebraic[296]
    algebraic[277] = algebraic[258]+algebraic[260]
    algebraic[278] = algebraic[243]+algebraic[254]+algebraic[260]
    algebraic[298] = constants[58]*(exp(algebraic[277]/(constants[141]*constants[142]))-exp(algebraic[278]/(constants[141]*constants[142])))
    algebraic[300] = ((constants[167]*algebraic[290]-algebraic[285])-constants[167]*algebraic[296])+algebraic[298]
    algebraic[302] = algebraic[298]-algebraic[279]
    algebraic[301] = algebraic[296]-algebraic[298]
    algebraic[1] = states[0]/constants[133]
    algebraic[3] = states[4]/constants[132]
    algebraic[4] = states[11]/constants[139]
    algebraic[5] = states[20]/constants[170]
    algebraic[6] = states[1]/constants[140]
    algebraic[7] = states[5]/constants[132]
    algebraic[8] = -log(states[23]/constants[132], 10)
    algebraic[9] = states[4]+states[11]+states[3]+states[20]+states[1]+states[22]+2.00000*(states[52]+states[53]+states[54])+states[41]+states[42]
    algebraic[10] = (constants[157]/(constants[148]*constants[149]*constants[150]))*states[10]*(states[60]+constants[148])
    algebraic[12] = constants[141]*constants[142]*log(constants[76]*states[33])
    algebraic[13] = constants[141]*constants[142]*log(constants[77]*states[34])
    algebraic[14] = constants[141]*constants[142]*log(constants[78]*states[35])
    algebraic[15] = constants[141]*constants[142]*log(constants[79]*states[36])
    algebraic[16] = states[11]+states[1]+states[33]+states[34]+states[35]+states[36]+states[37]+states[38]
    algebraic[17] = constants[164]*states[48]+constants[163]*states[46]+(constants[163]+constants[164])*states[47]
    algebraic[18] = constants[165]*states[52]+constants[165]*states[53]+constants[166]*states[54]
    algebraic[19] = states[4]/constants[168]
    algebraic[20] = states[20]/constants[174]
    algebraic[21] = states[23]/constants[176]
    algebraic[22] = states[25]/constants[168]
    algebraic[23] = states[26]/constants[168]
    algebraic[24] = states[24]/constants[168]
    algebraic[27] = (constants[157]/(constants[148]*constants[149]*constants[150]))*states[9]*states[59]
    algebraic[32] = algebraic[10]+algebraic[27]
    algebraic[37] = constants[161]*(exp((constants[162]*states[58])/constants[148])-1.00000)
    algebraic[53] = ((constants[161]*algebraic[43])/constants[148])*algebraic[44]
    algebraic[57] = algebraic[37]+algebraic[53]
    algebraic[59] = algebraic[32]+algebraic[57]
    algebraic[256] = constants[59]*(exp(algebraic[254]/(constants[141]*constants[142]))-exp((algebraic[249]+algebraic[248])/(constants[141]*constants[142])))
    return algebraic

initialGuess0 = None
def rootfind_0(voi, constants, rates, states, algebraic):
    """Calculate values of algebraic variables for DAE"""
    from scipy.optimize import fsolve
    global initialGuess0
    if initialGuess0 is None: initialGuess0 = ones(5)*0.1
    if not iterable(voi):
        soln = fsolve(residualSN_0, initialGuess0, args=(algebraic, voi, constants, rates, states), xtol=1E-6)
        initialGuess0 = soln
        algebraic[43] = soln[0]
        algebraic[44] = soln[1]
        algebraic[45] = soln[2]
        algebraic[46] = soln[3]
        algebraic[47] = soln[4]
    else:
        for (i,t) in enumerate(voi):
            soln = fsolve(residualSN_0, initialGuess0, args=(algebraic[:,i], voi[i], constants, rates[:i], states[:,i]), xtol=1E-6)
            initialGuess0 = soln
            algebraic[43][i] = soln[0]
            algebraic[44][i] = soln[1]
            algebraic[45][i] = soln[2]
            algebraic[46][i] = soln[3]
            algebraic[47][i] = soln[4]

def residualSN_0(algebraicCandidate, algebraic, voi, constants, rates, states):
    resid = array([0.0] * 5)
    algebraic[43] = algebraicCandidate[0]
    algebraic[44] = algebraicCandidate[1]
    algebraic[45] = algebraicCandidate[2]
    algebraic[46] = algebraicCandidate[3]
    algebraic[47] = algebraicCandidate[4]
    resid[0] = (algebraic[43]-(custom_piecewise([greater(algebraic[44] , 0.00000), constants[158] , True, constants[159]])))
    resid[1] = (algebraic[44]-algebraic[45])
    resid[2] = (algebraic[46]-(constants[160]/algebraic[43])*states[61])
    resid[3] = (algebraic[47]-(constants[160]/algebraic[43])*(states[58]-constants[148]))
    resid[4] = (algebraic[45]-(-algebraic[46]+algebraic[47]))
    return resid

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)