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 = 223
sizeStates = 43
sizeConstants = 163
from math import *
from numpy import *

def createLegends():
    legend_states = [""] * sizeStates
    legend_rates = [""] * sizeStates
    legend_algebraic = [""] * sizeAlgebraic
    legend_voi = ""
    legend_constants = [""] * sizeConstants
    legend_voi = "time in component environment (millisecond)"
    legend_constants[0] = "celltype in component environment (dimensionless)"
    legend_constants[1] = "nao in component extracellular (millimolar)"
    legend_constants[2] = "cao in component extracellular (millimolar)"
    legend_constants[3] = "ko in component extracellular (millimolar)"
    legend_constants[4] = "clo in component extracellular (millimolar)"
    legend_constants[5] = "R in component physical_constants (joule_per_kilomole_kelvin)"
    legend_constants[6] = "T in component physical_constants (kelvin)"
    legend_constants[7] = "F in component physical_constants (coulomb_per_mole)"
    legend_constants[8] = "zna in component physical_constants (dimensionless)"
    legend_constants[9] = "zca in component physical_constants (dimensionless)"
    legend_constants[10] = "zk in component physical_constants (dimensionless)"
    legend_constants[11] = "zcl in component physical_constants (dimensionless)"
    legend_constants[12] = "L in component cell_geometry (centimeter)"
    legend_constants[13] = "rad in component cell_geometry (centimeter)"
    legend_constants[112] = "vcell in component cell_geometry (microliter)"
    legend_constants[130] = "Ageo in component cell_geometry (centimeter_squared)"
    legend_constants[136] = "Acap in component cell_geometry (centimeter_squared)"
    legend_constants[142] = "vmyo in component cell_geometry (microliter)"
    legend_constants[143] = "vnsr in component cell_geometry (microliter)"
    legend_constants[144] = "vjsr in component cell_geometry (microliter)"
    legend_constants[145] = "vss in component cell_geometry (microliter)"
    legend_states[0] = "v in component membrane (millivolt)"
    legend_algebraic[25] = "vffrt in component membrane (coulomb_per_mole)"
    legend_algebraic[28] = "vfrt in component membrane (dimensionless)"
    legend_algebraic[68] = "INa in component INa (microA_per_microF)"
    legend_algebraic[70] = "INaL in component INaL (microA_per_microF)"
    legend_algebraic[76] = "Ito in component Ito (microA_per_microF)"
    legend_algebraic[112] = "ICaL in component ICaL (microA_per_microF)"
    legend_algebraic[113] = "ICaNa in component ICaL (microA_per_microF)"
    legend_algebraic[114] = "ICaK in component ICaL (microA_per_microF)"
    legend_algebraic[115] = "IKr in component IKr (microA_per_microF)"
    legend_algebraic[117] = "IKs in component IKs (microA_per_microF)"
    legend_algebraic[121] = "IK1 in component IK1 (microA_per_microF)"
    legend_algebraic[153] = "INaCa_i in component INaCa (microA_per_microF)"
    legend_algebraic[183] = "INaCa_ss in component INaCa (microA_per_microF)"
    legend_algebraic[202] = "INaK in component INaK (microA_per_microF)"
    legend_algebraic[205] = "INab in component INab (microA_per_microF)"
    legend_algebraic[204] = "IKb in component IKb (microA_per_microF)"
    legend_algebraic[209] = "IpCa in component IpCa (microA_per_microF)"
    legend_algebraic[207] = "ICab in component ICab (microA_per_microF)"
    legend_algebraic[214] = "IClCa in component ICl (microA_per_microF)"
    legend_algebraic[216] = "IClb in component ICl (microA_per_microF)"
    legend_algebraic[66] = "I_katp in component I_katp (microA_per_microF)"
    legend_algebraic[11] = "Istim in component membrane (microA_per_microF)"
    legend_constants[14] = "i_Stim_Start in component membrane (millisecond)"
    legend_constants[15] = "i_Stim_End in component membrane (millisecond)"
    legend_constants[16] = "i_Stim_Amplitude in component membrane (microA_per_microF)"
    legend_constants[17] = "i_Stim_Period in component membrane (millisecond)"
    legend_constants[18] = "i_Stim_PulseDuration in component membrane (millisecond)"
    legend_constants[19] = "KmCaMK in component CaMK (millimolar)"
    legend_constants[20] = "aCaMK in component CaMK (per_millimolar_per_millisecond)"
    legend_constants[21] = "bCaMK in component CaMK (per_millisecond)"
    legend_constants[22] = "CaMKo in component CaMK (dimensionless)"
    legend_constants[23] = "KmCaM in component CaMK (millimolar)"
    legend_algebraic[43] = "CaMKb in component CaMK (millimolar)"
    legend_algebraic[49] = "CaMKa in component CaMK (millimolar)"
    legend_states[1] = "CaMKt in component CaMK (millimolar)"
    legend_states[2] = "cass in component intracellular_ions (millimolar)"
    legend_constants[24] = "cmdnmax_b in component intracellular_ions (millimolar)"
    legend_constants[113] = "cmdnmax in component intracellular_ions (millimolar)"
    legend_constants[25] = "kmcmdn in component intracellular_ions (millimolar)"
    legend_constants[26] = "trpnmax in component intracellular_ions (millimolar)"
    legend_constants[27] = "kmtrpn in component intracellular_ions (millimolar)"
    legend_constants[28] = "BSRmax in component intracellular_ions (millimolar)"
    legend_constants[29] = "KmBSR in component intracellular_ions (millimolar)"
    legend_constants[30] = "BSLmax in component intracellular_ions (millimolar)"
    legend_constants[31] = "KmBSL in component intracellular_ions (millimolar)"
    legend_constants[32] = "csqnmax in component intracellular_ions (millimolar)"
    legend_constants[33] = "kmcsqn in component intracellular_ions (millimolar)"
    legend_states[3] = "nai in component intracellular_ions (millimolar)"
    legend_states[4] = "nass in component intracellular_ions (millimolar)"
    legend_states[5] = "ki in component intracellular_ions (millimolar)"
    legend_states[6] = "kss in component intracellular_ions (millimolar)"
    legend_states[7] = "cansr in component intracellular_ions (millimolar)"
    legend_states[8] = "cajsr in component intracellular_ions (millimolar)"
    legend_states[9] = "cai in component intracellular_ions (millimolar)"
    legend_constants[34] = "cli in component intracellular_ions (millimolar)"
    legend_algebraic[91] = "ICaL_ss in component ICaL (microA_per_microF)"
    legend_algebraic[92] = "ICaNa_ss in component ICaL (microA_per_microF)"
    legend_algebraic[95] = "ICaK_ss in component ICaL (microA_per_microF)"
    legend_algebraic[109] = "ICaL_i in component ICaL (microA_per_microF)"
    legend_algebraic[110] = "ICaNa_i in component ICaL (microA_per_microF)"
    legend_algebraic[111] = "ICaK_i in component ICaL (microA_per_microF)"
    legend_algebraic[208] = "JdiffNa in component diff (millimolar_per_millisecond)"
    legend_algebraic[211] = "Jdiff in component diff (millimolar_per_millisecond)"
    legend_algebraic[221] = "Jup in component SERCA (millimolar_per_millisecond)"
    legend_algebraic[206] = "JdiffK in component diff (millimolar_per_millisecond)"
    legend_algebraic[215] = "Jrel in component ryr (millimolar_per_millisecond)"
    legend_algebraic[222] = "Jtr in component trans_flux (millimolar_per_millisecond)"
    legend_algebraic[53] = "Bcai in component intracellular_ions (dimensionless)"
    legend_algebraic[59] = "Bcajsr in component intracellular_ions (dimensionless)"
    legend_algebraic[56] = "Bcass in component intracellular_ions (dimensionless)"
    legend_constants[35] = "PKNa in component reversal_potentials (dimensionless)"
    legend_algebraic[63] = "ENa in component reversal_potentials (millivolt)"
    legend_algebraic[64] = "EK in component reversal_potentials (millivolt)"
    legend_algebraic[65] = "EKs in component reversal_potentials (millivolt)"
    legend_constants[114] = "ECl in component reversal_potentials (millivolt)"
    legend_constants[36] = "gkatp in component I_katp (milliS_per_microF)"
    legend_constants[37] = "fkatp in component I_katp (dimensionless)"
    legend_constants[38] = "K_o_n in component I_katp (millimolar)"
    legend_constants[39] = "A_atp in component I_katp (millimolar)"
    legend_constants[40] = "K_atp in component I_katp (millimolar)"
    legend_constants[115] = "akik in component I_katp (dimensionless)"
    legend_constants[116] = "bkik in component I_katp (dimensionless)"
    legend_algebraic[0] = "mss in component INa (dimensionless)"
    legend_algebraic[13] = "tm in component INa (millisecond)"
    legend_states[10] = "m in component INa (dimensionless)"
    legend_algebraic[1] = "hss in component INa (dimensionless)"
    legend_algebraic[14] = "ah in component INa (dimensionless)"
    legend_algebraic[29] = "bh in component INa (dimensionless)"
    legend_algebraic[37] = "th in component INa (millisecond)"
    legend_states[11] = "h in component INa (dimensionless)"
    legend_algebraic[38] = "jss in component INa (dimensionless)"
    legend_algebraic[15] = "aj in component INa (dimensionless)"
    legend_algebraic[30] = "bj in component INa (dimensionless)"
    legend_algebraic[44] = "tj in component INa (millisecond)"
    legend_states[12] = "j in component INa (dimensionless)"
    legend_algebraic[45] = "hssp in component INa (dimensionless)"
    legend_states[13] = "hp in component INa (dimensionless)"
    legend_algebraic[50] = "tjp in component INa (millisecond)"
    legend_states[14] = "jp in component INa (dimensionless)"
    legend_algebraic[67] = "fINap in component INa (dimensionless)"
    legend_constants[41] = "GNa in component INa (milliS_per_microF)"
    legend_algebraic[2] = "mLss in component INaL (dimensionless)"
    legend_algebraic[16] = "tmL in component INaL (millisecond)"
    legend_states[15] = "mL in component INaL (dimensionless)"
    legend_constants[42] = "thL in component INaL (millisecond)"
    legend_algebraic[3] = "hLss in component INaL (dimensionless)"
    legend_states[16] = "hL in component INaL (dimensionless)"
    legend_algebraic[4] = "hLssp in component INaL (dimensionless)"
    legend_constants[117] = "thLp in component INaL (millisecond)"
    legend_states[17] = "hLp in component INaL (dimensionless)"
    legend_constants[43] = "GNaL_b in component INaL (milliS_per_microF)"
    legend_constants[118] = "GNaL in component INaL (milliS_per_microF)"
    legend_algebraic[69] = "fINaLp in component INaL (dimensionless)"
    legend_constants[44] = "Gto_b in component Ito (milliS_per_microF)"
    legend_algebraic[5] = "ass in component Ito (dimensionless)"
    legend_algebraic[17] = "ta in component Ito (millisecond)"
    legend_states[18] = "a in component Ito (dimensionless)"
    legend_constants[45] = "EKshift in component Ito (millivolt)"
    legend_algebraic[6] = "iss in component Ito (dimensionless)"
    legend_algebraic[18] = "delta_epi in component Ito (dimensionless)"
    legend_algebraic[31] = "tiF_b in component Ito (millisecond)"
    legend_algebraic[39] = "tiS_b in component Ito (millisecond)"
    legend_algebraic[46] = "tiF in component Ito (millisecond)"
    legend_algebraic[51] = "tiS in component Ito (millisecond)"
    legend_algebraic[71] = "AiF in component Ito (dimensionless)"
    legend_algebraic[72] = "AiS in component Ito (dimensionless)"
    legend_states[19] = "iF in component Ito (dimensionless)"
    legend_states[20] = "iS in component Ito (dimensionless)"
    legend_algebraic[73] = "i in component Ito (dimensionless)"
    legend_algebraic[32] = "assp in component Ito (dimensionless)"
    legend_states[21] = "ap in component Ito (dimensionless)"
    legend_algebraic[54] = "dti_develop in component Ito (dimensionless)"
    legend_algebraic[57] = "dti_recover in component Ito (dimensionless)"
    legend_algebraic[60] = "tiFp in component Ito (millisecond)"
    legend_algebraic[61] = "tiSp in component Ito (millisecond)"
    legend_states[22] = "iFp in component Ito (dimensionless)"
    legend_states[23] = "iSp in component Ito (dimensionless)"
    legend_algebraic[74] = "ip in component Ito (dimensionless)"
    legend_constants[119] = "Gto in component Ito (milliS_per_microF)"
    legend_algebraic[75] = "fItop in component Ito (dimensionless)"
    legend_constants[46] = "Kmn in component ICaL (millimolar)"
    legend_constants[47] = "k2n in component ICaL (per_millisecond)"
    legend_constants[48] = "PCa_b in component ICaL (dimensionless)"
    legend_algebraic[7] = "dss in component ICaL (dimensionless)"
    legend_states[24] = "d in component ICaL (dimensionless)"
    legend_algebraic[8] = "fss in component ICaL (dimensionless)"
    legend_constants[49] = "Aff in component ICaL (dimensionless)"
    legend_constants[120] = "Afs in component ICaL (dimensionless)"
    legend_states[25] = "ff in component ICaL (dimensionless)"
    legend_states[26] = "fs in component ICaL (dimensionless)"
    legend_algebraic[77] = "f in component ICaL (dimensionless)"
    legend_algebraic[19] = "fcass in component ICaL (dimensionless)"
    legend_algebraic[9] = "jcass in component ICaL (dimensionless)"
    legend_algebraic[78] = "Afcaf in component ICaL (dimensionless)"
    legend_algebraic[79] = "Afcas in component ICaL (dimensionless)"
    legend_states[27] = "fcaf in component ICaL (dimensionless)"
    legend_states[28] = "fcas in component ICaL (dimensionless)"
    legend_algebraic[80] = "fca in component ICaL (dimensionless)"
    legend_states[29] = "jca in component ICaL (dimensionless)"
    legend_states[30] = "ffp in component ICaL (dimensionless)"
    legend_algebraic[81] = "fp in component ICaL (dimensionless)"
    legend_states[31] = "fcafp in component ICaL (dimensionless)"
    legend_algebraic[82] = "fcap in component ICaL (dimensionless)"
    legend_algebraic[10] = "km2n in component ICaL (per_millisecond)"
    legend_algebraic[20] = "anca_ss in component ICaL (dimensionless)"
    legend_states[32] = "nca_ss in component ICaL (dimensionless)"
    legend_algebraic[21] = "anca_i in component ICaL (dimensionless)"
    legend_states[33] = "nca_i in component ICaL (dimensionless)"
    legend_algebraic[87] = "PhiCaL_ss in component ICaL (dimensionless)"
    legend_algebraic[88] = "PhiCaNa_ss in component ICaL (dimensionless)"
    legend_algebraic[89] = "PhiCaK_ss in component ICaL (dimensionless)"
    legend_algebraic[106] = "PhiCaL_i in component ICaL (dimensionless)"
    legend_algebraic[107] = "PhiCaNa_i in component ICaL (dimensionless)"
    legend_algebraic[108] = "PhiCaK_i in component ICaL (dimensionless)"
    legend_constants[121] = "PCa in component ICaL (dimensionless)"
    legend_constants[131] = "PCap in component ICaL (dimensionless)"
    legend_constants[132] = "PCaNa in component ICaL (dimensionless)"
    legend_constants[133] = "PCaK in component ICaL (dimensionless)"
    legend_constants[137] = "PCaNap in component ICaL (dimensionless)"
    legend_constants[138] = "PCaKp in component ICaL (dimensionless)"
    legend_algebraic[90] = "fICaLp in component ICaL (dimensionless)"
    legend_algebraic[22] = "td in component ICaL (millisecond)"
    legend_algebraic[23] = "tff in component ICaL (millisecond)"
    legend_algebraic[24] = "tfs in component ICaL (millisecond)"
    legend_algebraic[33] = "tfcaf in component ICaL (millisecond)"
    legend_algebraic[34] = "tfcas in component ICaL (millisecond)"
    legend_constants[50] = "tjca in component ICaL (millisecond)"
    legend_algebraic[35] = "tffp in component ICaL (millisecond)"
    legend_algebraic[40] = "tfcafp in component ICaL (millisecond)"
    legend_constants[51] = "vShift in component ICaL (millivolt)"
    legend_constants[52] = "offset in component ICaL (millisecond)"
    legend_constants[122] = "Io in component ICaL (dimensionless)"
    legend_algebraic[83] = "Iss in component ICaL (dimensionless)"
    legend_algebraic[98] = "Ii in component ICaL (dimensionless)"
    legend_constants[53] = "dielConstant in component ICaL (per_kelvin)"
    legend_constants[134] = "constA in component ICaL (dimensionless)"
    legend_constants[139] = "gamma_cao in component ICaL (dimensionless)"
    legend_algebraic[84] = "gamma_cass in component ICaL (dimensionless)"
    legend_algebraic[101] = "gamma_cai in component ICaL (dimensionless)"
    legend_constants[140] = "gamma_nao in component ICaL (dimensionless)"
    legend_algebraic[85] = "gamma_nass in component ICaL (dimensionless)"
    legend_algebraic[104] = "gamma_nai in component ICaL (dimensionless)"
    legend_constants[141] = "gamma_ko in component ICaL (dimensionless)"
    legend_algebraic[86] = "gamma_kss in component ICaL (dimensionless)"
    legend_algebraic[105] = "gamma_ki in component ICaL (dimensionless)"
    legend_constants[54] = "ICaL_fractionSS in component ICaL (dimensionless)"
    legend_constants[55] = "GKr_b in component IKr (milliS_per_microF)"
    legend_states[34] = "C1 in component IKr (dimensionless)"
    legend_states[35] = "C2 in component IKr (dimensionless)"
    legend_states[36] = "C3 in component IKr (dimensionless)"
    legend_states[37] = "I in component IKr (dimensionless)"
    legend_states[38] = "O in component IKr (dimensionless)"
    legend_algebraic[41] = "alpha in component IKr (per_millisecond)"
    legend_algebraic[47] = "beta in component IKr (per_millisecond)"
    legend_constants[56] = "alpha_1 in component IKr (per_millisecond)"
    legend_constants[57] = "beta_1 in component IKr (per_millisecond)"
    legend_algebraic[42] = "alpha_2 in component IKr (per_millisecond)"
    legend_algebraic[48] = "beta_2 in component IKr (per_millisecond)"
    legend_algebraic[52] = "alpha_i in component IKr (per_millisecond)"
    legend_algebraic[55] = "beta_i in component IKr (per_millisecond)"
    legend_algebraic[58] = "alpha_C2ToI in component IKr (per_millisecond)"
    legend_algebraic[62] = "beta_ItoC2 in component IKr (per_millisecond)"
    legend_constants[123] = "GKr in component IKr (milliS_per_microF)"
    legend_constants[58] = "GKs_b in component IKs (milliS_per_microF)"
    legend_constants[124] = "GKs in component IKs (milliS_per_microF)"
    legend_algebraic[12] = "xs1ss in component IKs (dimensionless)"
    legend_algebraic[26] = "xs2ss in component IKs (dimensionless)"
    legend_algebraic[27] = "txs1 in component IKs (millisecond)"
    legend_states[39] = "xs1 in component IKs (dimensionless)"
    legend_states[40] = "xs2 in component IKs (dimensionless)"
    legend_algebraic[116] = "KsCa in component IKs (dimensionless)"
    legend_algebraic[36] = "txs2 in component IKs (millisecond)"
    legend_constants[125] = "GK1 in component IK1 (milliS_per_microF)"
    legend_constants[59] = "GK1_b in component IK1 (milliS_per_microF)"
    legend_algebraic[118] = "aK1 in component IK1 (dimensionless)"
    legend_algebraic[119] = "bK1 in component IK1 (dimensionless)"
    legend_algebraic[120] = "K1ss in component IK1 (dimensionless)"
    legend_constants[60] = "INaCa_fractionSS in component INaCa (dimensionless)"
    legend_constants[61] = "kna1 in component INaCa (per_millisecond)"
    legend_constants[62] = "kna2 in component INaCa (per_millisecond)"
    legend_constants[63] = "kna3 in component INaCa (per_millisecond)"
    legend_constants[64] = "kasymm in component INaCa (dimensionless)"
    legend_constants[65] = "wna in component INaCa (dimensionless)"
    legend_constants[66] = "wca in component INaCa (dimensionless)"
    legend_constants[67] = "wnaca in component INaCa (dimensionless)"
    legend_constants[68] = "kcaon in component INaCa (per_millisecond)"
    legend_constants[69] = "kcaoff in component INaCa (per_millisecond)"
    legend_constants[70] = "qna in component INaCa (dimensionless)"
    legend_constants[71] = "qca in component INaCa (dimensionless)"
    legend_algebraic[123] = "hna in component INaCa (dimensionless)"
    legend_algebraic[122] = "hca in component INaCa (dimensionless)"
    legend_constants[72] = "KmCaAct in component INaCa (millimolar)"
    legend_constants[73] = "Gncx_b in component INaCa (milliS_per_microF)"
    legend_constants[152] = "Gncx in component INaCa (milliS_per_microF)"
    legend_algebraic[124] = "h1_i in component INaCa (dimensionless)"
    legend_algebraic[125] = "h2_i in component INaCa (dimensionless)"
    legend_algebraic[126] = "h3_i in component INaCa (dimensionless)"
    legend_algebraic[127] = "h4_i in component INaCa (dimensionless)"
    legend_algebraic[128] = "h5_i in component INaCa (dimensionless)"
    legend_algebraic[129] = "h6_i in component INaCa (dimensionless)"
    legend_algebraic[130] = "h7_i in component INaCa (dimensionless)"
    legend_algebraic[131] = "h8_i in component INaCa (dimensionless)"
    legend_algebraic[132] = "h9_i in component INaCa (dimensionless)"
    legend_constants[146] = "h10_i in component INaCa (dimensionless)"
    legend_constants[147] = "h11_i in component INaCa (dimensionless)"
    legend_constants[148] = "h12_i in component INaCa (dimensionless)"
    legend_constants[149] = "k1_i in component INaCa (dimensionless)"
    legend_constants[150] = "k2_i in component INaCa (dimensionless)"
    legend_algebraic[133] = "k3p_i in component INaCa (dimensionless)"
    legend_algebraic[134] = "k3pp_i in component INaCa (dimensionless)"
    legend_algebraic[135] = "k3_i in component INaCa (dimensionless)"
    legend_algebraic[138] = "k4_i in component INaCa (dimensionless)"
    legend_algebraic[136] = "k4p_i in component INaCa (dimensionless)"
    legend_algebraic[137] = "k4pp_i in component INaCa (dimensionless)"
    legend_constants[151] = "k5_i in component INaCa (dimensionless)"
    legend_algebraic[139] = "k6_i in component INaCa (dimensionless)"
    legend_algebraic[140] = "k7_i in component INaCa (dimensionless)"
    legend_algebraic[141] = "k8_i in component INaCa (dimensionless)"
    legend_algebraic[142] = "x1_i in component INaCa (dimensionless)"
    legend_algebraic[143] = "x2_i in component INaCa (dimensionless)"
    legend_algebraic[144] = "x3_i in component INaCa (dimensionless)"
    legend_algebraic[145] = "x4_i in component INaCa (dimensionless)"
    legend_algebraic[146] = "E1_i in component INaCa (dimensionless)"
    legend_algebraic[147] = "E2_i in component INaCa (dimensionless)"
    legend_algebraic[148] = "E3_i in component INaCa (dimensionless)"
    legend_algebraic[149] = "E4_i in component INaCa (dimensionless)"
    legend_algebraic[150] = "allo_i in component INaCa (dimensionless)"
    legend_algebraic[151] = "JncxNa_i in component INaCa (millimolar_per_millisecond)"
    legend_algebraic[152] = "JncxCa_i in component INaCa (millimolar_per_millisecond)"
    legend_algebraic[154] = "h1_ss in component INaCa (dimensionless)"
    legend_algebraic[155] = "h2_ss in component INaCa (dimensionless)"
    legend_algebraic[156] = "h3_ss in component INaCa (dimensionless)"
    legend_algebraic[157] = "h4_ss in component INaCa (dimensionless)"
    legend_algebraic[158] = "h5_ss in component INaCa (dimensionless)"
    legend_algebraic[159] = "h6_ss in component INaCa (dimensionless)"
    legend_algebraic[160] = "h7_ss in component INaCa (dimensionless)"
    legend_algebraic[161] = "h8_ss in component INaCa (dimensionless)"
    legend_algebraic[162] = "h9_ss in component INaCa (dimensionless)"
    legend_constants[153] = "h10_ss in component INaCa (dimensionless)"
    legend_constants[154] = "h11_ss in component INaCa (dimensionless)"
    legend_constants[155] = "h12_ss in component INaCa (dimensionless)"
    legend_constants[156] = "k1_ss in component INaCa (dimensionless)"
    legend_constants[157] = "k2_ss in component INaCa (dimensionless)"
    legend_algebraic[163] = "k3p_ss in component INaCa (dimensionless)"
    legend_algebraic[164] = "k3pp_ss in component INaCa (dimensionless)"
    legend_algebraic[165] = "k3_ss in component INaCa (dimensionless)"
    legend_algebraic[168] = "k4_ss in component INaCa (dimensionless)"
    legend_algebraic[166] = "k4p_ss in component INaCa (dimensionless)"
    legend_algebraic[167] = "k4pp_ss in component INaCa (dimensionless)"
    legend_constants[158] = "k5_ss in component INaCa (dimensionless)"
    legend_algebraic[169] = "k6_ss in component INaCa (dimensionless)"
    legend_algebraic[170] = "k7_ss in component INaCa (dimensionless)"
    legend_algebraic[171] = "k8_ss in component INaCa (dimensionless)"
    legend_algebraic[172] = "x1_ss in component INaCa (dimensionless)"
    legend_algebraic[173] = "x2_ss in component INaCa (dimensionless)"
    legend_algebraic[174] = "x3_ss in component INaCa (dimensionless)"
    legend_algebraic[175] = "x4_ss in component INaCa (dimensionless)"
    legend_algebraic[176] = "E1_ss in component INaCa (dimensionless)"
    legend_algebraic[177] = "E2_ss in component INaCa (dimensionless)"
    legend_algebraic[178] = "E3_ss in component INaCa (dimensionless)"
    legend_algebraic[179] = "E4_ss in component INaCa (dimensionless)"
    legend_algebraic[180] = "allo_ss in component INaCa (dimensionless)"
    legend_algebraic[181] = "JncxNa_ss in component INaCa (millimolar_per_millisecond)"
    legend_algebraic[182] = "JncxCa_ss in component INaCa (millimolar_per_millisecond)"
    legend_constants[74] = "k1p in component INaK (per_millisecond)"
    legend_constants[75] = "k1m in component INaK (per_millisecond)"
    legend_constants[76] = "k2p in component INaK (per_millisecond)"
    legend_constants[77] = "k2m in component INaK (per_millisecond)"
    legend_constants[78] = "k3p in component INaK (per_millisecond)"
    legend_constants[79] = "k3m in component INaK (per_millisecond)"
    legend_constants[80] = "k4p in component INaK (per_millisecond)"
    legend_constants[81] = "k4m in component INaK (per_millisecond)"
    legend_constants[82] = "Knai0 in component INaK (millimolar)"
    legend_constants[83] = "Knao0 in component INaK (millimolar)"
    legend_constants[84] = "delta in component INaK (millivolt)"
    legend_constants[85] = "Kki in component INaK (per_millisecond)"
    legend_constants[86] = "Kko in component INaK (per_millisecond)"
    legend_constants[87] = "MgADP in component INaK (millimolar)"
    legend_constants[88] = "MgATP in component INaK (millimolar)"
    legend_constants[89] = "Kmgatp in component INaK (millimolar)"
    legend_constants[90] = "H in component INaK (millimolar)"
    legend_constants[91] = "eP in component INaK (dimensionless)"
    legend_constants[92] = "Khp in component INaK (millimolar)"
    legend_constants[93] = "Knap in component INaK (millimolar)"
    legend_constants[94] = "Kxkur in component INaK (millimolar)"
    legend_constants[95] = "Pnak_b in component INaK (milliS_per_microF)"
    legend_constants[162] = "Pnak in component INaK (milliS_per_microF)"
    legend_algebraic[184] = "Knai in component INaK (millimolar)"
    legend_algebraic[185] = "Knao in component INaK (millimolar)"
    legend_algebraic[186] = "P in component INaK (dimensionless)"
    legend_algebraic[187] = "a1 in component INaK (dimensionless)"
    legend_constants[159] = "b1 in component INaK (dimensionless)"
    legend_constants[160] = "a2 in component INaK (dimensionless)"
    legend_algebraic[188] = "b2 in component INaK (dimensionless)"
    legend_algebraic[189] = "a3 in component INaK (dimensionless)"
    legend_algebraic[190] = "b3 in component INaK (dimensionless)"
    legend_constants[161] = "a4 in component INaK (dimensionless)"
    legend_algebraic[191] = "b4 in component INaK (dimensionless)"
    legend_algebraic[192] = "x1 in component INaK (dimensionless)"
    legend_algebraic[193] = "x2 in component INaK (dimensionless)"
    legend_algebraic[194] = "x3 in component INaK (dimensionless)"
    legend_algebraic[195] = "x4 in component INaK (dimensionless)"
    legend_algebraic[196] = "E1 in component INaK (dimensionless)"
    legend_algebraic[197] = "E2 in component INaK (dimensionless)"
    legend_algebraic[198] = "E3 in component INaK (dimensionless)"
    legend_algebraic[199] = "E4 in component INaK (dimensionless)"
    legend_algebraic[200] = "JnakNa in component INaK (millimolar_per_millisecond)"
    legend_algebraic[201] = "JnakK in component INaK (millimolar_per_millisecond)"
    legend_algebraic[203] = "xkb in component IKb (dimensionless)"
    legend_constants[96] = "GKb_b in component IKb (milliS_per_microF)"
    legend_constants[126] = "GKb in component IKb (milliS_per_microF)"
    legend_constants[97] = "PNab in component INab (milliS_per_microF)"
    legend_constants[98] = "PCab in component ICab (milliS_per_microF)"
    legend_constants[99] = "GpCa in component IpCa (milliS_per_microF)"
    legend_constants[100] = "KmCap in component IpCa (millimolar)"
    legend_constants[101] = "GClCa in component ICl (milliS_per_microF)"
    legend_constants[102] = "GClb in component ICl (milliS_per_microF)"
    legend_constants[103] = "KdClCa in component ICl (millimolar)"
    legend_constants[104] = "Fjunc in component ICl (dimensionless)"
    legend_algebraic[210] = "IClCa_junc in component ICl (microA_per_microF)"
    legend_algebraic[212] = "IClCa_sl in component ICl (microA_per_microF)"
    legend_constants[105] = "tauNa in component diff (millisecond)"
    legend_constants[106] = "tauK in component diff (millisecond)"
    legend_constants[107] = "tauCa in component diff (millisecond)"
    legend_constants[108] = "bt in component ryr (millisecond)"
    legend_constants[127] = "a_rel in component ryr (millimolar_per_millisecond)"
    legend_algebraic[93] = "Jrel_inf_b in component ryr (millimolar_per_millisecond)"
    legend_algebraic[96] = "Jrel_inf in component ryr (millimolar_per_millisecond)"
    legend_algebraic[99] = "tau_rel_b in component ryr (millisecond)"
    legend_algebraic[102] = "tau_rel in component ryr (millisecond)"
    legend_states[41] = "Jrel_np in component ryr (millimolar_per_millisecond)"
    legend_constants[128] = "btp in component ryr (millisecond)"
    legend_constants[135] = "a_relp in component ryr (millimolar_per_millisecond)"
    legend_algebraic[94] = "Jrel_infp_b in component ryr (millimolar_per_millisecond)"
    legend_algebraic[97] = "Jrel_infp in component ryr (millimolar_per_millisecond)"
    legend_algebraic[100] = "tau_relp_b in component ryr (millisecond)"
    legend_algebraic[103] = "tau_relp in component ryr (millisecond)"
    legend_states[42] = "Jrel_p in component ryr (millimolar_per_millisecond)"
    legend_constants[109] = "cajsr_half in component ryr (millimolar)"
    legend_algebraic[213] = "fJrelp in component ryr (dimensionless)"
    legend_constants[110] = "Jrel_b in component ryr (dimensionless)"
    legend_constants[129] = "upScale in component SERCA (dimensionless)"
    legend_algebraic[217] = "Jupnp in component SERCA (millimolar_per_millisecond)"
    legend_algebraic[218] = "Jupp in component SERCA (millimolar_per_millisecond)"
    legend_algebraic[219] = "fJupp in component SERCA (dimensionless)"
    legend_algebraic[220] = "Jleak in component SERCA (millimolar_per_millisecond)"
    legend_constants[111] = "Jup_b in component SERCA (dimensionless)"
    legend_rates[0] = "d/dt v in component membrane (millivolt)"
    legend_rates[1] = "d/dt CaMKt in component CaMK (millimolar)"
    legend_rates[3] = "d/dt nai in component intracellular_ions (millimolar)"
    legend_rates[4] = "d/dt nass in component intracellular_ions (millimolar)"
    legend_rates[5] = "d/dt ki in component intracellular_ions (millimolar)"
    legend_rates[6] = "d/dt kss in component intracellular_ions (millimolar)"
    legend_rates[9] = "d/dt cai in component intracellular_ions (millimolar)"
    legend_rates[2] = "d/dt cass in component intracellular_ions (millimolar)"
    legend_rates[7] = "d/dt cansr in component intracellular_ions (millimolar)"
    legend_rates[8] = "d/dt cajsr in component intracellular_ions (millimolar)"
    legend_rates[10] = "d/dt m in component INa (dimensionless)"
    legend_rates[11] = "d/dt h in component INa (dimensionless)"
    legend_rates[12] = "d/dt j in component INa (dimensionless)"
    legend_rates[13] = "d/dt hp in component INa (dimensionless)"
    legend_rates[14] = "d/dt jp in component INa (dimensionless)"
    legend_rates[15] = "d/dt mL in component INaL (dimensionless)"
    legend_rates[16] = "d/dt hL in component INaL (dimensionless)"
    legend_rates[17] = "d/dt hLp in component INaL (dimensionless)"
    legend_rates[18] = "d/dt a in component Ito (dimensionless)"
    legend_rates[19] = "d/dt iF in component Ito (dimensionless)"
    legend_rates[20] = "d/dt iS in component Ito (dimensionless)"
    legend_rates[21] = "d/dt ap in component Ito (dimensionless)"
    legend_rates[22] = "d/dt iFp in component Ito (dimensionless)"
    legend_rates[23] = "d/dt iSp in component Ito (dimensionless)"
    legend_rates[24] = "d/dt d in component ICaL (dimensionless)"
    legend_rates[25] = "d/dt ff in component ICaL (dimensionless)"
    legend_rates[26] = "d/dt fs in component ICaL (dimensionless)"
    legend_rates[27] = "d/dt fcaf in component ICaL (dimensionless)"
    legend_rates[28] = "d/dt fcas in component ICaL (dimensionless)"
    legend_rates[29] = "d/dt jca in component ICaL (dimensionless)"
    legend_rates[30] = "d/dt ffp in component ICaL (dimensionless)"
    legend_rates[31] = "d/dt fcafp in component ICaL (dimensionless)"
    legend_rates[32] = "d/dt nca_ss in component ICaL (dimensionless)"
    legend_rates[33] = "d/dt nca_i in component ICaL (dimensionless)"
    legend_rates[36] = "d/dt C3 in component IKr (dimensionless)"
    legend_rates[35] = "d/dt C2 in component IKr (dimensionless)"
    legend_rates[34] = "d/dt C1 in component IKr (dimensionless)"
    legend_rates[38] = "d/dt O in component IKr (dimensionless)"
    legend_rates[37] = "d/dt I in component IKr (dimensionless)"
    legend_rates[39] = "d/dt xs1 in component IKs (dimensionless)"
    legend_rates[40] = "d/dt xs2 in component IKs (dimensionless)"
    legend_rates[41] = "d/dt Jrel_np in component ryr (millimolar_per_millisecond)"
    legend_rates[42] = "d/dt Jrel_p in component ryr (millimolar_per_millisecond)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 2
    constants[1] = 140.0
    constants[2] = 1.8
    constants[3] = 5.0
    constants[4] = 150.0
    constants[5] = 8314
    constants[6] = 310
    constants[7] = 96485
    constants[8] = 1
    constants[9] = 2
    constants[10] = 1
    constants[11] = -1
    constants[12] = 0.01
    constants[13] = 0.0011
    states[0] = -89.1704
    constants[14] = 0
    constants[15] = 100000000000000000
    constants[16] = -53
    constants[17] = 1000
    constants[18] = 1.0
    constants[19] = 0.15
    constants[20] = 0.05
    constants[21] = 0.00068
    constants[22] = 0.05
    constants[23] = 0.0015
    states[1] = 0.0192
    states[2] = 6.5781e-05
    constants[24] = 0.05
    constants[25] = 0.00238
    constants[26] = 0.07
    constants[27] = 0.0005
    constants[28] = 0.047
    constants[29] = 0.00087
    constants[30] = 1.124
    constants[31] = 0.0087
    constants[32] = 10
    constants[33] = 0.8
    states[3] = 15.0038
    states[4] = 15.0043
    states[5] = 143.0403
    states[6] = 143.0402
    states[7] = 1.9557
    states[8] = 1.9593
    states[9] = 8.166e-05
    constants[34] = 24.0
    constants[35] = 0.01833
    constants[36] = 4.3195
    constants[37] = 0.0
    constants[38] = 5
    constants[39] = 2
    constants[40] = 0.25
    states[10] = 0.00073818
    states[11] = 0.8365
    states[12] = 0.8363
    states[13] = 0.6838
    states[14] = 0.8358
    constants[41] = 11.7802
    states[15] = 0.00015079
    constants[42] = 200
    states[16] = 0.5327
    states[17] = 0.2834
    constants[43] = 0.0279
    constants[44] = 0.16
    states[18] = 0.00092527
    constants[45] = 0
    states[19] = 0.9996
    states[20] = 0.5671
    states[21] = 0.00047143
    states[22] = 0.9996
    states[23] = 0.6261
    constants[46] = 0.002
    constants[47] = 500
    constants[48] = 8.3757e-05
    states[24] = 0
    constants[49] = 0.6
    states[25] = 1.0
    states[26] = 0.92
    states[27] = 1.0
    states[28] = 0.9998
    states[29] = 1.0
    states[30] = 1.0
    states[31] = 1.0
    states[32] = 0.00051399
    states[33] = 0.0012
    constants[50] = 75
    constants[51] = 0
    constants[52] = 0
    constants[53] = 74
    constants[54] = 0.8
    constants[55] = 0.0321
    states[34] = 0.00069560
    states[35] = 0.00082672
    states[36] = 0.9979
    states[37] = 1.8784e-05
    states[38] = 0.00054206
    constants[56] = 0.154375
    constants[57] = 0.1911
    constants[58] = 0.0011
    states[39] = 0.2653
    states[40] = 0.00016921
    constants[59] = 0.6992
    constants[60] = 0.35
    constants[61] = 15
    constants[62] = 5
    constants[63] = 88.12
    constants[64] = 12.5
    constants[65] = 6e4
    constants[66] = 6e4
    constants[67] = 5e3
    constants[68] = 1.5e6
    constants[69] = 5e3
    constants[70] = 0.5224
    constants[71] = 0.167
    constants[72] = 150e-6
    constants[73] = 0.0034
    constants[74] = 949.5
    constants[75] = 182.4
    constants[76] = 687.2
    constants[77] = 39.4
    constants[78] = 1899
    constants[79] = 79300
    constants[80] = 639
    constants[81] = 40
    constants[82] = 9.073
    constants[83] = 27.78
    constants[84] = -0.155
    constants[85] = 0.5
    constants[86] = 0.3582
    constants[87] = 0.05
    constants[88] = 9.8
    constants[89] = 1.698e-7
    constants[90] = 1e-7
    constants[91] = 4.2
    constants[92] = 1.698e-7
    constants[93] = 224
    constants[94] = 292
    constants[95] = 15.4509
    constants[96] = 0.0189
    constants[97] = 1.9239e-09
    constants[98] = 5.9194e-08
    constants[99] = 5e-04
    constants[100] = 0.0005
    constants[101] = 0.2843
    constants[102] = 1.98e-3
    constants[103] = 0.1
    constants[104] = 1
    constants[105] = 2.0
    constants[106] = 2.0
    constants[107] = 0.2
    constants[108] = 4.75
    states[41] = 0
    states[42] = 0
    constants[109] = 1.7
    constants[110] = 1.5378
    constants[111] = 1.0
    constants[112] = 1000.00*3.14000*constants[13]*constants[13]*constants[12]
    constants[113] = custom_piecewise([equal(constants[0] , 1.00000), constants[24]*1.30000 , True, constants[24]])
    constants[114] = ((constants[5]*constants[6])/(constants[11]*constants[7]))*log(constants[4]/constants[34])
    constants[115] = power(constants[3]/constants[38], 0.240000)
    constants[116] = 1.00000/(1.00000+power(constants[39]/constants[40], 2.00000))
    constants[117] = 3.00000*constants[42]
    constants[118] = custom_piecewise([equal(constants[0] , 1.00000), constants[43]*0.600000 , True, constants[43]])
    constants[119] = custom_piecewise([equal(constants[0] , 1.00000), constants[44]*2.00000 , equal(constants[0] , 2.00000), constants[44]*2.00000 , True, constants[44]])
    constants[120] = 1.00000-constants[49]
    constants[121] = custom_piecewise([equal(constants[0] , 1.00000), constants[48]*1.20000 , equal(constants[0] , 2.00000), constants[48]*2.00000 , True, constants[48]])
    constants[122] = (0.500000*(constants[1]+constants[3]+constants[4]+4.00000*constants[2]))/1000.00
    constants[123] = custom_piecewise([equal(constants[0] , 1.00000), constants[55]*1.30000 , equal(constants[0] , 2.00000), constants[55]*0.800000 , True, constants[55]])
    constants[124] = custom_piecewise([equal(constants[0] , 1.00000), constants[58]*1.40000 , True, constants[58]])
    constants[125] = custom_piecewise([equal(constants[0] , 1.00000), constants[59]*1.20000 , equal(constants[0] , 2.00000), constants[59]*1.30000 , True, constants[59]])
    constants[126] = custom_piecewise([equal(constants[0] , 1.00000), constants[96]*0.600000 , True, constants[96]])
    constants[127] = (0.500000*constants[108])/1.00000
    constants[128] = 1.25000*constants[108]
    constants[129] = custom_piecewise([equal(constants[0] , 1.00000), 1.30000 , True, 1.00000])
    constants[130] = 2.00000*3.14000*constants[13]*constants[13]+2.00000*3.14000*constants[13]*constants[12]
    constants[131] = 1.10000*constants[121]
    constants[132] = 0.00125000*constants[121]
    constants[133] = 0.000357400*constants[121]
    constants[134] = 1.82000e+06*(power(constants[53]*constants[6], -1.50000))
    constants[135] = (0.500000*constants[128])/1.00000
    constants[136] = 2.00000*constants[130]
    constants[137] = 0.00125000*constants[131]
    constants[138] = 0.000357400*constants[131]
    constants[139] = exp(-constants[134]*4.00000*((power(constants[122], 1.0/2))/(1.00000+power(constants[122], 1.0/2))-0.300000*constants[122]))
    constants[140] = exp(-constants[134]*1.00000*((power(constants[122], 1.0/2))/(1.00000+power(constants[122], 1.0/2))-0.300000*constants[122]))
    constants[141] = exp(-constants[134]*1.00000*((power(constants[122], 1.0/2))/(1.00000+power(constants[122], 1.0/2))-0.300000*constants[122]))
    constants[142] = 0.680000*constants[112]
    constants[143] = 0.0552000*constants[112]
    constants[144] = 0.00480000*constants[112]
    constants[145] = 0.0200000*constants[112]
    constants[146] = constants[64]+1.00000+(constants[1]/constants[61])*(1.00000+constants[1]/constants[62])
    constants[147] = (constants[1]*constants[1])/(constants[146]*constants[61]*constants[62])
    constants[148] = 1.00000/constants[146]
    constants[149] = constants[148]*constants[2]*constants[68]
    constants[150] = constants[69]
    constants[151] = constants[69]
    constants[152] = custom_piecewise([equal(constants[0] , 1.00000), constants[73]*1.10000 , equal(constants[0] , 2.00000), constants[73]*1.40000 , True, constants[73]])
    constants[153] = constants[64]+1.00000+(constants[1]/constants[61])*(1.00000+constants[1]/constants[62])
    constants[154] = (constants[1]*constants[1])/(constants[153]*constants[61]*constants[62])
    constants[155] = 1.00000/constants[153]
    constants[156] = constants[155]*constants[2]*constants[68]
    constants[157] = constants[69]
    constants[158] = constants[69]
    constants[159] = constants[75]*constants[87]
    constants[160] = constants[76]
    constants[161] = ((constants[80]*constants[88])/constants[89])/(1.00000+constants[88]/constants[89])
    constants[162] = custom_piecewise([equal(constants[0] , 1.00000), constants[95]*0.900000 , equal(constants[0] , 2.00000), constants[95]*0.700000 , True, constants[95]])
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[3] = 1.00000/(1.00000+exp((states[0]+87.6100)/7.48800))
    rates[16] = (algebraic[3]-states[16])/constants[42]
    algebraic[4] = 1.00000/(1.00000+exp((states[0]+93.8100)/7.48800))
    rates[17] = (algebraic[4]-states[17])/constants[117]
    algebraic[9] = 1.00000/(1.00000+exp((states[0]+18.0800)/2.79160))
    rates[29] = (algebraic[9]-states[29])/constants[50]
    algebraic[0] = 1.00000/(power(1.00000+exp(-(states[0]+56.8600)/9.03000), 2.00000))
    algebraic[13] = 0.129200*exp(-(power((states[0]+45.7900)/15.5400, 2.00000)))+0.0648700*exp(-(power((states[0]-4.82300)/51.1200, 2.00000)))
    rates[10] = (algebraic[0]-states[10])/algebraic[13]
    algebraic[2] = 1.00000/(1.00000+exp(-(states[0]+42.8500)/5.26400))
    algebraic[16] = 0.129200*exp(-(power((states[0]+45.7900)/15.5400, 2.00000)))+0.0648700*exp(-(power((states[0]-4.82300)/51.1200, 2.00000)))
    rates[15] = (algebraic[2]-states[15])/algebraic[16]
    algebraic[5] = 1.00000/(1.00000+exp(-((states[0]+constants[45])-14.3400)/14.8200))
    algebraic[17] = 1.05150/(1.00000/(1.20890*(1.00000+exp(-((states[0]+constants[45])-18.4099)/29.3814)))+3.50000/(1.00000+exp((states[0]+constants[45]+100.000)/29.3814)))
    rates[18] = (algebraic[5]-states[18])/algebraic[17]
    algebraic[7] = custom_piecewise([greater_equal(states[0] , 31.4978), 1.00000 , True, 1.07630*exp(-1.00700*exp(-0.0829000*states[0]))])
    algebraic[22] = constants[52]+0.600000+1.00000/(exp(-0.0500000*(states[0]+constants[51]+6.00000))+exp(0.0900000*(states[0]+constants[51]+14.0000)))
    rates[24] = (algebraic[7]-states[24])/algebraic[22]
    algebraic[8] = 1.00000/(1.00000+exp((states[0]+19.5800)/3.69600))
    algebraic[23] = 7.00000+1.00000/(0.00450000*exp(-(states[0]+20.0000)/10.0000)+0.00450000*exp((states[0]+20.0000)/10.0000))
    rates[25] = (algebraic[8]-states[25])/algebraic[23]
    algebraic[24] = 1000.00+1.00000/(3.50000e-05*exp(-(states[0]+5.00000)/4.00000)+3.50000e-05*exp((states[0]+5.00000)/6.00000))
    rates[26] = (algebraic[8]-states[26])/algebraic[24]
    algebraic[10] = states[29]*1.00000
    algebraic[20] = 1.00000/(constants[47]/algebraic[10]+power(1.00000+constants[46]/states[2], 4.00000))
    rates[32] = algebraic[20]*constants[47]-states[32]*algebraic[10]
    algebraic[21] = 1.00000/(constants[47]/algebraic[10]+power(1.00000+constants[46]/states[9], 4.00000))
    rates[33] = algebraic[21]*constants[47]-states[33]*algebraic[10]
    algebraic[12] = 1.00000/(1.00000+exp(-(states[0]+11.6000)/8.93200))
    algebraic[27] = 817.300+1.00000/(0.000232600*exp((states[0]+48.2800)/17.8000)+0.00129200*exp(-(states[0]+210.000)/230.000))
    rates[39] = (algebraic[12]-states[39])/algebraic[27]
    algebraic[32] = 1.00000/(1.00000+exp(-((states[0]+constants[45])-24.3400)/14.8200))
    rates[21] = (algebraic[32]-states[21])/algebraic[17]
    algebraic[19] = algebraic[8]
    algebraic[33] = 7.00000+1.00000/(0.0400000*exp(-(states[0]-4.00000)/7.00000)+0.0400000*exp((states[0]-4.00000)/7.00000))
    rates[27] = (algebraic[19]-states[27])/algebraic[33]
    algebraic[34] = 100.000+1.00000/(0.000120000*exp(-states[0]/3.00000)+0.000120000*exp(states[0]/7.00000))
    rates[28] = (algebraic[19]-states[28])/algebraic[34]
    algebraic[35] = 2.50000*algebraic[23]
    rates[30] = (algebraic[8]-states[30])/algebraic[35]
    algebraic[26] = algebraic[12]
    algebraic[36] = 1.00000/(0.0100000*exp((states[0]-50.0000)/20.0000)+0.0193000*exp(-(states[0]+66.5400)/31.0000))
    rates[40] = (algebraic[26]-states[40])/algebraic[36]
    algebraic[43] = (constants[22]*(1.00000-states[1]))/(1.00000+constants[23]/states[2])
    rates[1] = constants[20]*algebraic[43]*(algebraic[43]+states[1])-constants[21]*states[1]
    algebraic[1] = 1.00000/(power(1.00000+exp((states[0]+71.5500)/7.43000), 2.00000))
    algebraic[14] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, 0.0570000*exp(-(states[0]+80.0000)/6.80000)])
    algebraic[29] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.770000/(0.130000*(1.00000+exp(-(states[0]+10.6600)/11.1000))) , True, 2.70000*exp(0.0790000*states[0])+310000.*exp(0.348500*states[0])])
    algebraic[37] = 1.00000/(algebraic[14]+algebraic[29])
    rates[11] = (algebraic[1]-states[11])/algebraic[37]
    algebraic[40] = 2.50000*algebraic[33]
    rates[31] = (algebraic[19]-states[31])/algebraic[40]
    algebraic[38] = algebraic[1]
    algebraic[15] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, ((-25428.0*exp(0.244400*states[0])-6.94800e-06*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300)))])
    algebraic[30] = custom_piecewise([greater_equal(states[0] , -40.0000), (0.600000*exp(0.0570000*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000))) , True, (0.0242400*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400)))])
    algebraic[44] = 1.00000/(algebraic[15]+algebraic[30])
    rates[12] = (algebraic[38]-states[12])/algebraic[44]
    algebraic[45] = 1.00000/(power(1.00000+exp((states[0]+77.5500)/7.43000), 2.00000))
    rates[13] = (algebraic[45]-states[13])/algebraic[37]
    algebraic[6] = 1.00000/(1.00000+exp((states[0]+constants[45]+43.9400)/5.71100))
    algebraic[18] = custom_piecewise([equal(constants[0] , 1.00000), 1.00000-0.950000/(1.00000+exp((states[0]+constants[45]+70.0000)/5.00000)) , True, 1.00000])
    algebraic[31] = 4.56200+1.00000/(0.393300*exp(-(states[0]+constants[45]+100.000)/100.000)+0.0800400*exp((states[0]+constants[45]+50.0000)/16.5900))
    algebraic[46] = algebraic[31]*algebraic[18]
    rates[19] = (algebraic[6]-states[19])/algebraic[46]
    algebraic[28] = (states[0]*constants[7])/(constants[5]*constants[6])
    algebraic[41] = 0.116100*exp(0.299000*algebraic[28])
    algebraic[47] = 0.244200*exp(-1.60400*algebraic[28])
    rates[36] = algebraic[47]*states[35]-algebraic[41]*states[36]
    rates[35] = (algebraic[41]*states[36]+constants[57]*states[34])-(algebraic[47]+constants[56])*states[35]
    algebraic[50] = 1.46000*algebraic[44]
    rates[14] = (algebraic[38]-states[14])/algebraic[50]
    algebraic[39] = 23.6200+1.00000/(0.00141600*exp(-(states[0]+constants[45]+96.5200)/59.0500)+1.78000e-08*exp((states[0]+constants[45]+114.100)/8.07900))
    algebraic[51] = algebraic[39]*algebraic[18]
    rates[20] = (algebraic[6]-states[20])/algebraic[51]
    algebraic[42] = 0.0578000*exp(0.971000*algebraic[28])
    algebraic[48] = 0.000349000*exp(-1.06200*algebraic[28])
    algebraic[52] = 0.253300*exp(0.595300*algebraic[28])
    algebraic[55] = 0.0652500*exp(-0.820900*algebraic[28])
    rates[38] = (algebraic[42]*states[34]+algebraic[55]*states[37])-(algebraic[48]+algebraic[52])*states[38]
    algebraic[54] = 1.35400+0.000100000/(exp(((states[0]+constants[45])-167.400)/15.8900)+exp(-((states[0]+constants[45])-12.2300)/0.215400))
    algebraic[57] = 1.00000-0.500000/(1.00000+exp((states[0]+constants[45]+70.0000)/20.0000))
    algebraic[60] = algebraic[54]*algebraic[57]*algebraic[46]
    rates[22] = (algebraic[6]-states[22])/algebraic[60]
    algebraic[61] = algebraic[54]*algebraic[57]*algebraic[51]
    rates[23] = (algebraic[6]-states[23])/algebraic[61]
    algebraic[58] = 5.20000e-05*exp(1.52500*algebraic[28])
    algebraic[62] = (algebraic[48]*algebraic[55]*algebraic[58])/(algebraic[42]*algebraic[52])
    rates[34] = (constants[56]*states[35]+algebraic[48]*states[38]+algebraic[62]*states[37])-(constants[57]+algebraic[42]+algebraic[58])*states[34]
    rates[37] = (algebraic[58]*states[34]+algebraic[52]*states[38])-(algebraic[62]+algebraic[55])*states[37]
    algebraic[77] = constants[49]*states[25]+constants[120]*states[26]
    algebraic[78] = 0.300000+0.600000/(1.00000+exp((states[0]-10.0000)/10.0000))
    algebraic[79] = 1.00000-algebraic[78]
    algebraic[80] = algebraic[78]*states[27]+algebraic[79]*states[28]
    algebraic[81] = constants[49]*states[30]+constants[120]*states[26]
    algebraic[82] = algebraic[78]*states[31]+algebraic[79]*states[28]
    algebraic[25] = (states[0]*constants[7]*constants[7])/(constants[5]*constants[6])
    algebraic[83] = (0.500000*(states[4]+states[6]+constants[34]+4.00000*states[2]))/1000.00
    algebraic[84] = exp(-constants[134]*4.00000*((power(algebraic[83], 1.0/2))/(1.00000+power(algebraic[83], 1.0/2))-0.300000*algebraic[83]))
    algebraic[87] = (4.00000*algebraic[25]*(algebraic[84]*states[2]*exp(2.00000*algebraic[28])-constants[139]*constants[2]))/(exp(2.00000*algebraic[28])-1.00000)
    algebraic[49] = algebraic[43]+states[1]
    algebraic[90] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[91] = constants[54]*((1.00000-algebraic[90])*constants[121]*algebraic[87]*states[24]*(algebraic[77]*(1.00000-states[32])+states[29]*algebraic[80]*states[32])+algebraic[90]*constants[131]*algebraic[87]*states[24]*(algebraic[81]*(1.00000-states[32])+states[29]*algebraic[82]*states[32]))
    algebraic[93] = ((-constants[127]*algebraic[91])/1.00000)/(1.00000+power(constants[109]/states[8], 8.00000))
    algebraic[96] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[93]*1.70000 , True, algebraic[93]])
    algebraic[99] = constants[108]/(1.00000+0.0123000/states[8])
    algebraic[102] = custom_piecewise([less(algebraic[99] , 0.00100000), 0.00100000 , True, algebraic[99]])
    rates[41] = (algebraic[96]-states[41])/algebraic[102]
    algebraic[94] = ((-constants[135]*algebraic[91])/1.00000)/(1.00000+power(constants[109]/states[8], 8.00000))
    algebraic[97] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[94]*1.70000 , True, algebraic[94]])
    algebraic[100] = constants[128]/(1.00000+0.0123000/states[8])
    algebraic[103] = custom_piecewise([less(algebraic[100] , 0.00100000), 0.00100000 , True, algebraic[100]])
    rates[42] = (algebraic[97]-states[42])/algebraic[103]
    algebraic[64] = ((constants[5]*constants[6])/(constants[10]*constants[7]))*log(constants[3]/states[5])
    algebraic[71] = 1.00000/(1.00000+exp(((states[0]+constants[45])-213.600)/151.200))
    algebraic[72] = 1.00000-algebraic[71]
    algebraic[73] = algebraic[71]*states[19]+algebraic[72]*states[20]
    algebraic[74] = algebraic[71]*states[22]+algebraic[72]*states[23]
    algebraic[75] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[76] = constants[119]*(states[0]-algebraic[64])*((1.00000-algebraic[75])*states[18]*algebraic[73]+algebraic[75]*states[21]*algebraic[74])
    algebraic[115] = constants[123]*(power(constants[3]/5.00000, 1.0/2))*states[38]*(states[0]-algebraic[64])
    algebraic[65] = ((constants[5]*constants[6])/(constants[10]*constants[7]))*log((constants[3]+constants[35]*constants[1])/(states[5]+constants[35]*states[3]))
    algebraic[116] = 1.00000+0.600000/(1.00000+power(3.80000e-05/states[9], 1.40000))
    algebraic[117] = constants[124]*algebraic[116]*states[39]*states[40]*(states[0]-algebraic[65])
    algebraic[118] = 4.09400/(1.00000+exp(0.121700*((states[0]-algebraic[64])-49.9340)))
    algebraic[119] = (15.7200*exp(0.0674000*((states[0]-algebraic[64])-3.25700))+exp(0.0618000*((states[0]-algebraic[64])-594.310)))/(1.00000+exp(-0.162900*((states[0]-algebraic[64])+14.2070)))
    algebraic[120] = algebraic[118]/(algebraic[118]+algebraic[119])
    algebraic[121] = constants[125]*(power(constants[3]/5.00000, 1.0/2))*algebraic[120]*(states[0]-algebraic[64])
    algebraic[185] = constants[83]*exp(((1.00000-constants[84])*algebraic[28])/3.00000)
    algebraic[189] = (constants[78]*(power(constants[3]/constants[86], 2.00000)))/((power(1.00000+constants[1]/algebraic[185], 3.00000)+power(1.00000+constants[3]/constants[86], 2.00000))-1.00000)
    algebraic[186] = constants[91]/(1.00000+constants[90]/constants[92]+states[3]/constants[93]+states[5]/constants[94])
    algebraic[190] = (constants[79]*algebraic[186]*constants[90])/(1.00000+constants[88]/constants[89])
    algebraic[184] = constants[82]*exp((constants[84]*algebraic[28])/3.00000)
    algebraic[187] = (constants[74]*(power(states[3]/algebraic[184], 3.00000)))/((power(1.00000+states[3]/algebraic[184], 3.00000)+power(1.00000+states[5]/constants[85], 2.00000))-1.00000)
    algebraic[188] = (constants[77]*(power(constants[1]/algebraic[185], 3.00000)))/((power(1.00000+constants[1]/algebraic[185], 3.00000)+power(1.00000+constants[3]/constants[86], 2.00000))-1.00000)
    algebraic[191] = (constants[81]*(power(states[5]/constants[85], 2.00000)))/((power(1.00000+states[3]/algebraic[184], 3.00000)+power(1.00000+states[5]/constants[85], 2.00000))-1.00000)
    algebraic[192] = constants[161]*algebraic[187]*constants[160]+algebraic[188]*algebraic[191]*algebraic[190]+constants[160]*algebraic[191]*algebraic[190]+algebraic[190]*algebraic[187]*constants[160]
    algebraic[193] = algebraic[188]*constants[159]*algebraic[191]+algebraic[187]*constants[160]*algebraic[189]+algebraic[189]*constants[159]*algebraic[191]+constants[160]*algebraic[189]*algebraic[191]
    algebraic[194] = constants[160]*algebraic[189]*constants[161]+algebraic[190]*algebraic[188]*constants[159]+algebraic[188]*constants[159]*constants[161]+algebraic[189]*constants[161]*constants[159]
    algebraic[195] = algebraic[191]*algebraic[190]*algebraic[188]+algebraic[189]*constants[161]*algebraic[187]+algebraic[188]*constants[161]*algebraic[187]+algebraic[190]*algebraic[188]*algebraic[187]
    algebraic[196] = algebraic[192]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[197] = algebraic[193]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[200] = 3.00000*(algebraic[196]*algebraic[189]-algebraic[197]*algebraic[190])
    algebraic[198] = algebraic[194]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[199] = algebraic[195]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[201] = 2.00000*(algebraic[199]*constants[159]-algebraic[198]*algebraic[187])
    algebraic[202] = constants[162]*(constants[8]*algebraic[200]+constants[10]*algebraic[201])
    algebraic[203] = 1.00000/(1.00000+exp(-(states[0]-10.8968)/23.9871))
    algebraic[204] = constants[126]*algebraic[203]*(states[0]-algebraic[64])
    algebraic[66] = constants[37]*constants[36]*constants[115]*constants[116]*(states[0]-algebraic[64])
    algebraic[11] = custom_piecewise([greater_equal(voi , constants[14]) & less_equal(voi , constants[15]) & less_equal((voi-constants[14])-floor((voi-constants[14])/constants[17])*constants[17] , constants[18]), constants[16] , True, 0.00000])
    algebraic[98] = (0.500000*(states[3]+states[5]+constants[34]+4.00000*states[9]))/1000.00
    algebraic[105] = exp(-constants[134]*1.00000*((power(algebraic[98], 1.0/2))/(1.00000+power(algebraic[98], 1.0/2))-0.300000*algebraic[98]))
    algebraic[108] = (1.00000*algebraic[25]*(algebraic[105]*states[5]*exp(1.00000*algebraic[28])-constants[141]*constants[3]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[111] = (1.00000-constants[54])*((1.00000-algebraic[90])*constants[133]*algebraic[108]*states[24]*(algebraic[77]*(1.00000-states[33])+states[29]*algebraic[80]*states[33])+algebraic[90]*constants[138]*algebraic[108]*states[24]*(algebraic[81]*(1.00000-states[33])+states[29]*algebraic[82]*states[33]))
    algebraic[206] = (states[6]-states[5])/constants[106]
    rates[5] = (-(((algebraic[76]+algebraic[115]+algebraic[117]+algebraic[121]+algebraic[204]+algebraic[66]+algebraic[11])-2.00000*algebraic[202])+algebraic[111])*constants[136])/(constants[7]*constants[142])+(algebraic[206]*constants[145])/constants[142]
    algebraic[86] = exp(-constants[134]*1.00000*((power(algebraic[83], 1.0/2))/(1.00000+power(algebraic[83], 1.0/2))-0.300000*algebraic[83]))
    algebraic[89] = (1.00000*algebraic[25]*(algebraic[86]*states[6]*exp(1.00000*algebraic[28])-constants[141]*constants[3]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[95] = constants[54]*((1.00000-algebraic[90])*constants[133]*algebraic[89]*states[24]*(algebraic[77]*(1.00000-states[32])+states[29]*algebraic[80]*states[32])+algebraic[90]*constants[138]*algebraic[89]*states[24]*(algebraic[81]*(1.00000-states[32])+states[29]*algebraic[82]*states[32]))
    rates[6] = (-algebraic[95]*constants[136])/(constants[7]*constants[145])-algebraic[206]
    algebraic[63] = ((constants[5]*constants[6])/(constants[8]*constants[7]))*log(constants[1]/states[3])
    algebraic[67] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[68] = constants[41]*(states[0]-algebraic[63])*(power(states[10], 3.00000))*((1.00000-algebraic[67])*states[11]*states[12]+algebraic[67]*states[13]*states[14])
    algebraic[69] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[70] = constants[118]*(states[0]-algebraic[63])*states[15]*((1.00000-algebraic[69])*states[16]+algebraic[69]*states[17])
    algebraic[150] = 1.00000/(1.00000+power(constants[72]/states[9], 2.00000))
    algebraic[123] = exp(constants[70]*algebraic[28])
    algebraic[130] = 1.00000+(constants[1]/constants[63])*(1.00000+1.00000/algebraic[123])
    algebraic[131] = constants[1]/(constants[63]*algebraic[123]*algebraic[130])
    algebraic[134] = algebraic[131]*constants[67]
    algebraic[124] = 1.00000+(states[3]/constants[63])*(1.00000+algebraic[123])
    algebraic[125] = (states[3]*algebraic[123])/(constants[63]*algebraic[124])
    algebraic[137] = algebraic[125]*constants[67]
    algebraic[127] = 1.00000+(states[3]/constants[61])*(1.00000+states[3]/constants[62])
    algebraic[128] = (states[3]*states[3])/(algebraic[127]*constants[61]*constants[62])
    algebraic[140] = algebraic[128]*algebraic[125]*constants[65]
    algebraic[141] = algebraic[131]*constants[147]*constants[65]
    algebraic[132] = 1.00000/algebraic[130]
    algebraic[133] = algebraic[132]*constants[66]
    algebraic[135] = algebraic[133]+algebraic[134]
    algebraic[122] = exp(constants[71]*algebraic[28])
    algebraic[126] = 1.00000/algebraic[124]
    algebraic[136] = (algebraic[126]*constants[66])/algebraic[122]
    algebraic[138] = algebraic[136]+algebraic[137]
    algebraic[129] = 1.00000/algebraic[127]
    algebraic[139] = algebraic[129]*states[9]*constants[68]
    algebraic[142] = constants[150]*algebraic[138]*(algebraic[140]+algebraic[139])+constants[151]*algebraic[140]*(constants[150]+algebraic[135])
    algebraic[143] = constants[149]*algebraic[140]*(algebraic[138]+constants[151])+algebraic[138]*algebraic[139]*(constants[149]+algebraic[141])
    algebraic[144] = constants[149]*algebraic[135]*(algebraic[140]+algebraic[139])+algebraic[141]*algebraic[139]*(constants[150]+algebraic[135])
    algebraic[145] = constants[150]*algebraic[141]*(algebraic[138]+constants[151])+algebraic[135]*constants[151]*(constants[149]+algebraic[141])
    algebraic[146] = algebraic[142]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[147] = algebraic[143]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[148] = algebraic[144]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[149] = algebraic[145]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[151] = (3.00000*(algebraic[149]*algebraic[140]-algebraic[146]*algebraic[141])+algebraic[148]*algebraic[137])-algebraic[147]*algebraic[134]
    algebraic[152] = algebraic[147]*constants[150]-algebraic[146]*constants[149]
    algebraic[153] = (1.00000-constants[60])*constants[152]*algebraic[150]*(constants[8]*algebraic[151]+constants[9]*algebraic[152])
    algebraic[205] = (constants[97]*algebraic[25]*(states[3]*exp(algebraic[28])-constants[1]))/(exp(algebraic[28])-1.00000)
    algebraic[104] = exp(-constants[134]*1.00000*((power(algebraic[98], 1.0/2))/(1.00000+power(algebraic[98], 1.0/2))-0.300000*algebraic[98]))
    algebraic[107] = (1.00000*algebraic[25]*(algebraic[104]*states[3]*exp(1.00000*algebraic[28])-constants[140]*constants[1]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[110] = (1.00000-constants[54])*((1.00000-algebraic[90])*constants[132]*algebraic[107]*states[24]*(algebraic[77]*(1.00000-states[33])+states[29]*algebraic[80]*states[33])+algebraic[90]*constants[137]*algebraic[107]*states[24]*(algebraic[81]*(1.00000-states[33])+states[29]*algebraic[82]*states[33]))
    algebraic[208] = (states[4]-states[3])/constants[105]
    rates[3] = (-(algebraic[68]+algebraic[70]+3.00000*algebraic[153]+algebraic[110]+3.00000*algebraic[202]+algebraic[205])*constants[136])/(constants[7]*constants[142])+(algebraic[208]*constants[145])/constants[142]
    algebraic[180] = 1.00000/(1.00000+power(constants[72]/states[2], 2.00000))
    algebraic[160] = 1.00000+(constants[1]/constants[63])*(1.00000+1.00000/algebraic[123])
    algebraic[161] = constants[1]/(constants[63]*algebraic[123]*algebraic[160])
    algebraic[164] = algebraic[161]*constants[67]
    algebraic[154] = 1.00000+(states[4]/constants[63])*(1.00000+algebraic[123])
    algebraic[155] = (states[4]*algebraic[123])/(constants[63]*algebraic[154])
    algebraic[167] = algebraic[155]*constants[67]
    algebraic[157] = 1.00000+(states[4]/constants[61])*(1.00000+states[4]/constants[62])
    algebraic[158] = (states[4]*states[4])/(algebraic[157]*constants[61]*constants[62])
    algebraic[170] = algebraic[158]*algebraic[155]*constants[65]
    algebraic[171] = algebraic[161]*constants[154]*constants[65]
    algebraic[162] = 1.00000/algebraic[160]
    algebraic[163] = algebraic[162]*constants[66]
    algebraic[165] = algebraic[163]+algebraic[164]
    algebraic[156] = 1.00000/algebraic[154]
    algebraic[166] = (algebraic[156]*constants[66])/algebraic[122]
    algebraic[168] = algebraic[166]+algebraic[167]
    algebraic[159] = 1.00000/algebraic[157]
    algebraic[169] = algebraic[159]*states[2]*constants[68]
    algebraic[172] = constants[157]*algebraic[168]*(algebraic[170]+algebraic[169])+constants[158]*algebraic[170]*(constants[157]+algebraic[165])
    algebraic[173] = constants[156]*algebraic[170]*(algebraic[168]+constants[158])+algebraic[168]*algebraic[169]*(constants[156]+algebraic[171])
    algebraic[174] = constants[156]*algebraic[165]*(algebraic[170]+algebraic[169])+algebraic[171]*algebraic[169]*(constants[157]+algebraic[165])
    algebraic[175] = constants[157]*algebraic[171]*(algebraic[168]+constants[158])+algebraic[165]*constants[158]*(constants[156]+algebraic[171])
    algebraic[176] = algebraic[172]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[177] = algebraic[173]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[178] = algebraic[174]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[179] = algebraic[175]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[181] = (3.00000*(algebraic[179]*algebraic[170]-algebraic[176]*algebraic[171])+algebraic[178]*algebraic[167])-algebraic[177]*algebraic[164]
    algebraic[182] = algebraic[177]*constants[157]-algebraic[176]*constants[156]
    algebraic[183] = constants[60]*constants[152]*algebraic[180]*(constants[8]*algebraic[181]+constants[9]*algebraic[182])
    algebraic[85] = exp(-constants[134]*1.00000*((power(algebraic[83], 1.0/2))/(1.00000+power(algebraic[83], 1.0/2))-0.300000*algebraic[83]))
    algebraic[88] = (1.00000*algebraic[25]*(algebraic[85]*states[4]*exp(1.00000*algebraic[28])-constants[140]*constants[1]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[92] = constants[54]*((1.00000-algebraic[90])*constants[132]*algebraic[88]*states[24]*(algebraic[77]*(1.00000-states[32])+states[29]*algebraic[80]*states[32])+algebraic[90]*constants[137]*algebraic[88]*states[24]*(algebraic[81]*(1.00000-states[32])+states[29]*algebraic[82]*states[32]))
    rates[4] = (-(algebraic[92]+3.00000*algebraic[183])*constants[136])/(constants[7]*constants[145])-algebraic[208]
    algebraic[211] = (states[2]-states[9])/constants[107]
    algebraic[213] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[215] = constants[110]*((1.00000-algebraic[213])*states[41]+algebraic[213]*states[42])
    algebraic[56] = 1.00000/(1.00000+(constants[28]*constants[29])/(power(constants[29]+states[2], 2.00000))+(constants[30]*constants[31])/(power(constants[31]+states[2], 2.00000)))
    rates[2] = algebraic[56]*(((-(algebraic[91]-2.00000*algebraic[183])*constants[136])/(2.00000*constants[7]*constants[145])+(algebraic[215]*constants[144])/constants[145])-algebraic[211])
    algebraic[101] = exp(-constants[134]*4.00000*((power(algebraic[98], 1.0/2))/(1.00000+power(algebraic[98], 1.0/2))-0.300000*algebraic[98]))
    algebraic[106] = (4.00000*algebraic[25]*(algebraic[101]*states[9]*exp(2.00000*algebraic[28])-constants[139]*constants[2]))/(exp(2.00000*algebraic[28])-1.00000)
    algebraic[109] = (1.00000-constants[54])*((1.00000-algebraic[90])*constants[121]*algebraic[106]*states[24]*(algebraic[77]*(1.00000-states[33])+states[29]*algebraic[80]*states[33])+algebraic[90]*constants[131]*algebraic[106]*states[24]*(algebraic[81]*(1.00000-states[33])+states[29]*algebraic[82]*states[33]))
    algebraic[112] = algebraic[91]+algebraic[109]
    algebraic[113] = algebraic[92]+algebraic[110]
    algebraic[114] = algebraic[95]+algebraic[111]
    algebraic[209] = (constants[99]*states[9])/(constants[100]+states[9])
    algebraic[207] = (constants[98]*4.00000*algebraic[25]*(algebraic[101]*states[9]*exp(2.00000*algebraic[28])-constants[139]*constants[2]))/(exp(2.00000*algebraic[28])-1.00000)
    algebraic[210] = ((constants[104]*constants[101])/(1.00000+constants[103]/states[2]))*(states[0]-constants[114])
    algebraic[212] = (((1.00000-constants[104])*constants[101])/(1.00000+constants[103]/states[9]))*(states[0]-constants[114])
    algebraic[214] = algebraic[210]+algebraic[212]
    algebraic[216] = constants[102]*(states[0]-constants[114])
    rates[0] = -(algebraic[68]+algebraic[70]+algebraic[76]+algebraic[112]+algebraic[113]+algebraic[114]+algebraic[115]+algebraic[117]+algebraic[121]+algebraic[153]+algebraic[183]+algebraic[202]+algebraic[205]+algebraic[204]+algebraic[209]+algebraic[207]+algebraic[214]+algebraic[216]+algebraic[66]+algebraic[11])
    algebraic[217] = (constants[129]*0.00542500*states[9])/(states[9]+0.000920000)
    algebraic[218] = (constants[129]*2.75000*0.00542500*states[9])/((states[9]+0.000920000)-0.000170000)
    algebraic[219] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[220] = (0.00488250*states[7])/15.0000
    algebraic[221] = constants[111]*(((1.00000-algebraic[219])*algebraic[217]+algebraic[219]*algebraic[218])-algebraic[220])
    algebraic[53] = 1.00000/(1.00000+(constants[113]*constants[25])/(power(constants[25]+states[9], 2.00000))+(constants[26]*constants[27])/(power(constants[27]+states[9], 2.00000)))
    rates[9] = algebraic[53]*(((-((algebraic[109]+algebraic[209]+algebraic[207])-2.00000*algebraic[153])*constants[136])/(2.00000*constants[7]*constants[142])-(algebraic[221]*constants[143])/constants[142])+(algebraic[211]*constants[145])/constants[142])
    algebraic[222] = (states[7]-states[8])/60.0000
    rates[7] = algebraic[221]-(algebraic[222]*constants[144])/constants[143]
    algebraic[59] = 1.00000/(1.00000+(constants[32]*constants[33])/(power(constants[33]+states[8], 2.00000)))
    rates[8] = algebraic[59]*(algebraic[222]-algebraic[215])
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[3] = 1.00000/(1.00000+exp((states[0]+87.6100)/7.48800))
    algebraic[4] = 1.00000/(1.00000+exp((states[0]+93.8100)/7.48800))
    algebraic[9] = 1.00000/(1.00000+exp((states[0]+18.0800)/2.79160))
    algebraic[0] = 1.00000/(power(1.00000+exp(-(states[0]+56.8600)/9.03000), 2.00000))
    algebraic[13] = 0.129200*exp(-(power((states[0]+45.7900)/15.5400, 2.00000)))+0.0648700*exp(-(power((states[0]-4.82300)/51.1200, 2.00000)))
    algebraic[2] = 1.00000/(1.00000+exp(-(states[0]+42.8500)/5.26400))
    algebraic[16] = 0.129200*exp(-(power((states[0]+45.7900)/15.5400, 2.00000)))+0.0648700*exp(-(power((states[0]-4.82300)/51.1200, 2.00000)))
    algebraic[5] = 1.00000/(1.00000+exp(-((states[0]+constants[45])-14.3400)/14.8200))
    algebraic[17] = 1.05150/(1.00000/(1.20890*(1.00000+exp(-((states[0]+constants[45])-18.4099)/29.3814)))+3.50000/(1.00000+exp((states[0]+constants[45]+100.000)/29.3814)))
    algebraic[7] = custom_piecewise([greater_equal(states[0] , 31.4978), 1.00000 , True, 1.07630*exp(-1.00700*exp(-0.0829000*states[0]))])
    algebraic[22] = constants[52]+0.600000+1.00000/(exp(-0.0500000*(states[0]+constants[51]+6.00000))+exp(0.0900000*(states[0]+constants[51]+14.0000)))
    algebraic[8] = 1.00000/(1.00000+exp((states[0]+19.5800)/3.69600))
    algebraic[23] = 7.00000+1.00000/(0.00450000*exp(-(states[0]+20.0000)/10.0000)+0.00450000*exp((states[0]+20.0000)/10.0000))
    algebraic[24] = 1000.00+1.00000/(3.50000e-05*exp(-(states[0]+5.00000)/4.00000)+3.50000e-05*exp((states[0]+5.00000)/6.00000))
    algebraic[10] = states[29]*1.00000
    algebraic[20] = 1.00000/(constants[47]/algebraic[10]+power(1.00000+constants[46]/states[2], 4.00000))
    algebraic[21] = 1.00000/(constants[47]/algebraic[10]+power(1.00000+constants[46]/states[9], 4.00000))
    algebraic[12] = 1.00000/(1.00000+exp(-(states[0]+11.6000)/8.93200))
    algebraic[27] = 817.300+1.00000/(0.000232600*exp((states[0]+48.2800)/17.8000)+0.00129200*exp(-(states[0]+210.000)/230.000))
    algebraic[32] = 1.00000/(1.00000+exp(-((states[0]+constants[45])-24.3400)/14.8200))
    algebraic[19] = algebraic[8]
    algebraic[33] = 7.00000+1.00000/(0.0400000*exp(-(states[0]-4.00000)/7.00000)+0.0400000*exp((states[0]-4.00000)/7.00000))
    algebraic[34] = 100.000+1.00000/(0.000120000*exp(-states[0]/3.00000)+0.000120000*exp(states[0]/7.00000))
    algebraic[35] = 2.50000*algebraic[23]
    algebraic[26] = algebraic[12]
    algebraic[36] = 1.00000/(0.0100000*exp((states[0]-50.0000)/20.0000)+0.0193000*exp(-(states[0]+66.5400)/31.0000))
    algebraic[43] = (constants[22]*(1.00000-states[1]))/(1.00000+constants[23]/states[2])
    algebraic[1] = 1.00000/(power(1.00000+exp((states[0]+71.5500)/7.43000), 2.00000))
    algebraic[14] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, 0.0570000*exp(-(states[0]+80.0000)/6.80000)])
    algebraic[29] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.770000/(0.130000*(1.00000+exp(-(states[0]+10.6600)/11.1000))) , True, 2.70000*exp(0.0790000*states[0])+310000.*exp(0.348500*states[0])])
    algebraic[37] = 1.00000/(algebraic[14]+algebraic[29])
    algebraic[40] = 2.50000*algebraic[33]
    algebraic[38] = algebraic[1]
    algebraic[15] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, ((-25428.0*exp(0.244400*states[0])-6.94800e-06*exp(-0.0439100*states[0]))*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300)))])
    algebraic[30] = custom_piecewise([greater_equal(states[0] , -40.0000), (0.600000*exp(0.0570000*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000))) , True, (0.0242400*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400)))])
    algebraic[44] = 1.00000/(algebraic[15]+algebraic[30])
    algebraic[45] = 1.00000/(power(1.00000+exp((states[0]+77.5500)/7.43000), 2.00000))
    algebraic[6] = 1.00000/(1.00000+exp((states[0]+constants[45]+43.9400)/5.71100))
    algebraic[18] = custom_piecewise([equal(constants[0] , 1.00000), 1.00000-0.950000/(1.00000+exp((states[0]+constants[45]+70.0000)/5.00000)) , True, 1.00000])
    algebraic[31] = 4.56200+1.00000/(0.393300*exp(-(states[0]+constants[45]+100.000)/100.000)+0.0800400*exp((states[0]+constants[45]+50.0000)/16.5900))
    algebraic[46] = algebraic[31]*algebraic[18]
    algebraic[28] = (states[0]*constants[7])/(constants[5]*constants[6])
    algebraic[41] = 0.116100*exp(0.299000*algebraic[28])
    algebraic[47] = 0.244200*exp(-1.60400*algebraic[28])
    algebraic[50] = 1.46000*algebraic[44]
    algebraic[39] = 23.6200+1.00000/(0.00141600*exp(-(states[0]+constants[45]+96.5200)/59.0500)+1.78000e-08*exp((states[0]+constants[45]+114.100)/8.07900))
    algebraic[51] = algebraic[39]*algebraic[18]
    algebraic[42] = 0.0578000*exp(0.971000*algebraic[28])
    algebraic[48] = 0.000349000*exp(-1.06200*algebraic[28])
    algebraic[52] = 0.253300*exp(0.595300*algebraic[28])
    algebraic[55] = 0.0652500*exp(-0.820900*algebraic[28])
    algebraic[54] = 1.35400+0.000100000/(exp(((states[0]+constants[45])-167.400)/15.8900)+exp(-((states[0]+constants[45])-12.2300)/0.215400))
    algebraic[57] = 1.00000-0.500000/(1.00000+exp((states[0]+constants[45]+70.0000)/20.0000))
    algebraic[60] = algebraic[54]*algebraic[57]*algebraic[46]
    algebraic[61] = algebraic[54]*algebraic[57]*algebraic[51]
    algebraic[58] = 5.20000e-05*exp(1.52500*algebraic[28])
    algebraic[62] = (algebraic[48]*algebraic[55]*algebraic[58])/(algebraic[42]*algebraic[52])
    algebraic[77] = constants[49]*states[25]+constants[120]*states[26]
    algebraic[78] = 0.300000+0.600000/(1.00000+exp((states[0]-10.0000)/10.0000))
    algebraic[79] = 1.00000-algebraic[78]
    algebraic[80] = algebraic[78]*states[27]+algebraic[79]*states[28]
    algebraic[81] = constants[49]*states[30]+constants[120]*states[26]
    algebraic[82] = algebraic[78]*states[31]+algebraic[79]*states[28]
    algebraic[25] = (states[0]*constants[7]*constants[7])/(constants[5]*constants[6])
    algebraic[83] = (0.500000*(states[4]+states[6]+constants[34]+4.00000*states[2]))/1000.00
    algebraic[84] = exp(-constants[134]*4.00000*((power(algebraic[83], 1.0/2))/(1.00000+power(algebraic[83], 1.0/2))-0.300000*algebraic[83]))
    algebraic[87] = (4.00000*algebraic[25]*(algebraic[84]*states[2]*exp(2.00000*algebraic[28])-constants[139]*constants[2]))/(exp(2.00000*algebraic[28])-1.00000)
    algebraic[49] = algebraic[43]+states[1]
    algebraic[90] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[91] = constants[54]*((1.00000-algebraic[90])*constants[121]*algebraic[87]*states[24]*(algebraic[77]*(1.00000-states[32])+states[29]*algebraic[80]*states[32])+algebraic[90]*constants[131]*algebraic[87]*states[24]*(algebraic[81]*(1.00000-states[32])+states[29]*algebraic[82]*states[32]))
    algebraic[93] = ((-constants[127]*algebraic[91])/1.00000)/(1.00000+power(constants[109]/states[8], 8.00000))
    algebraic[96] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[93]*1.70000 , True, algebraic[93]])
    algebraic[99] = constants[108]/(1.00000+0.0123000/states[8])
    algebraic[102] = custom_piecewise([less(algebraic[99] , 0.00100000), 0.00100000 , True, algebraic[99]])
    algebraic[94] = ((-constants[135]*algebraic[91])/1.00000)/(1.00000+power(constants[109]/states[8], 8.00000))
    algebraic[97] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[94]*1.70000 , True, algebraic[94]])
    algebraic[100] = constants[128]/(1.00000+0.0123000/states[8])
    algebraic[103] = custom_piecewise([less(algebraic[100] , 0.00100000), 0.00100000 , True, algebraic[100]])
    algebraic[64] = ((constants[5]*constants[6])/(constants[10]*constants[7]))*log(constants[3]/states[5])
    algebraic[71] = 1.00000/(1.00000+exp(((states[0]+constants[45])-213.600)/151.200))
    algebraic[72] = 1.00000-algebraic[71]
    algebraic[73] = algebraic[71]*states[19]+algebraic[72]*states[20]
    algebraic[74] = algebraic[71]*states[22]+algebraic[72]*states[23]
    algebraic[75] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[76] = constants[119]*(states[0]-algebraic[64])*((1.00000-algebraic[75])*states[18]*algebraic[73]+algebraic[75]*states[21]*algebraic[74])
    algebraic[115] = constants[123]*(power(constants[3]/5.00000, 1.0/2))*states[38]*(states[0]-algebraic[64])
    algebraic[65] = ((constants[5]*constants[6])/(constants[10]*constants[7]))*log((constants[3]+constants[35]*constants[1])/(states[5]+constants[35]*states[3]))
    algebraic[116] = 1.00000+0.600000/(1.00000+power(3.80000e-05/states[9], 1.40000))
    algebraic[117] = constants[124]*algebraic[116]*states[39]*states[40]*(states[0]-algebraic[65])
    algebraic[118] = 4.09400/(1.00000+exp(0.121700*((states[0]-algebraic[64])-49.9340)))
    algebraic[119] = (15.7200*exp(0.0674000*((states[0]-algebraic[64])-3.25700))+exp(0.0618000*((states[0]-algebraic[64])-594.310)))/(1.00000+exp(-0.162900*((states[0]-algebraic[64])+14.2070)))
    algebraic[120] = algebraic[118]/(algebraic[118]+algebraic[119])
    algebraic[121] = constants[125]*(power(constants[3]/5.00000, 1.0/2))*algebraic[120]*(states[0]-algebraic[64])
    algebraic[185] = constants[83]*exp(((1.00000-constants[84])*algebraic[28])/3.00000)
    algebraic[189] = (constants[78]*(power(constants[3]/constants[86], 2.00000)))/((power(1.00000+constants[1]/algebraic[185], 3.00000)+power(1.00000+constants[3]/constants[86], 2.00000))-1.00000)
    algebraic[186] = constants[91]/(1.00000+constants[90]/constants[92]+states[3]/constants[93]+states[5]/constants[94])
    algebraic[190] = (constants[79]*algebraic[186]*constants[90])/(1.00000+constants[88]/constants[89])
    algebraic[184] = constants[82]*exp((constants[84]*algebraic[28])/3.00000)
    algebraic[187] = (constants[74]*(power(states[3]/algebraic[184], 3.00000)))/((power(1.00000+states[3]/algebraic[184], 3.00000)+power(1.00000+states[5]/constants[85], 2.00000))-1.00000)
    algebraic[188] = (constants[77]*(power(constants[1]/algebraic[185], 3.00000)))/((power(1.00000+constants[1]/algebraic[185], 3.00000)+power(1.00000+constants[3]/constants[86], 2.00000))-1.00000)
    algebraic[191] = (constants[81]*(power(states[5]/constants[85], 2.00000)))/((power(1.00000+states[3]/algebraic[184], 3.00000)+power(1.00000+states[5]/constants[85], 2.00000))-1.00000)
    algebraic[192] = constants[161]*algebraic[187]*constants[160]+algebraic[188]*algebraic[191]*algebraic[190]+constants[160]*algebraic[191]*algebraic[190]+algebraic[190]*algebraic[187]*constants[160]
    algebraic[193] = algebraic[188]*constants[159]*algebraic[191]+algebraic[187]*constants[160]*algebraic[189]+algebraic[189]*constants[159]*algebraic[191]+constants[160]*algebraic[189]*algebraic[191]
    algebraic[194] = constants[160]*algebraic[189]*constants[161]+algebraic[190]*algebraic[188]*constants[159]+algebraic[188]*constants[159]*constants[161]+algebraic[189]*constants[161]*constants[159]
    algebraic[195] = algebraic[191]*algebraic[190]*algebraic[188]+algebraic[189]*constants[161]*algebraic[187]+algebraic[188]*constants[161]*algebraic[187]+algebraic[190]*algebraic[188]*algebraic[187]
    algebraic[196] = algebraic[192]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[197] = algebraic[193]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[200] = 3.00000*(algebraic[196]*algebraic[189]-algebraic[197]*algebraic[190])
    algebraic[198] = algebraic[194]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[199] = algebraic[195]/(algebraic[192]+algebraic[193]+algebraic[194]+algebraic[195])
    algebraic[201] = 2.00000*(algebraic[199]*constants[159]-algebraic[198]*algebraic[187])
    algebraic[202] = constants[162]*(constants[8]*algebraic[200]+constants[10]*algebraic[201])
    algebraic[203] = 1.00000/(1.00000+exp(-(states[0]-10.8968)/23.9871))
    algebraic[204] = constants[126]*algebraic[203]*(states[0]-algebraic[64])
    algebraic[66] = constants[37]*constants[36]*constants[115]*constants[116]*(states[0]-algebraic[64])
    algebraic[11] = custom_piecewise([greater_equal(voi , constants[14]) & less_equal(voi , constants[15]) & less_equal((voi-constants[14])-floor((voi-constants[14])/constants[17])*constants[17] , constants[18]), constants[16] , True, 0.00000])
    algebraic[98] = (0.500000*(states[3]+states[5]+constants[34]+4.00000*states[9]))/1000.00
    algebraic[105] = exp(-constants[134]*1.00000*((power(algebraic[98], 1.0/2))/(1.00000+power(algebraic[98], 1.0/2))-0.300000*algebraic[98]))
    algebraic[108] = (1.00000*algebraic[25]*(algebraic[105]*states[5]*exp(1.00000*algebraic[28])-constants[141]*constants[3]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[111] = (1.00000-constants[54])*((1.00000-algebraic[90])*constants[133]*algebraic[108]*states[24]*(algebraic[77]*(1.00000-states[33])+states[29]*algebraic[80]*states[33])+algebraic[90]*constants[138]*algebraic[108]*states[24]*(algebraic[81]*(1.00000-states[33])+states[29]*algebraic[82]*states[33]))
    algebraic[206] = (states[6]-states[5])/constants[106]
    algebraic[86] = exp(-constants[134]*1.00000*((power(algebraic[83], 1.0/2))/(1.00000+power(algebraic[83], 1.0/2))-0.300000*algebraic[83]))
    algebraic[89] = (1.00000*algebraic[25]*(algebraic[86]*states[6]*exp(1.00000*algebraic[28])-constants[141]*constants[3]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[95] = constants[54]*((1.00000-algebraic[90])*constants[133]*algebraic[89]*states[24]*(algebraic[77]*(1.00000-states[32])+states[29]*algebraic[80]*states[32])+algebraic[90]*constants[138]*algebraic[89]*states[24]*(algebraic[81]*(1.00000-states[32])+states[29]*algebraic[82]*states[32]))
    algebraic[63] = ((constants[5]*constants[6])/(constants[8]*constants[7]))*log(constants[1]/states[3])
    algebraic[67] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[68] = constants[41]*(states[0]-algebraic[63])*(power(states[10], 3.00000))*((1.00000-algebraic[67])*states[11]*states[12]+algebraic[67]*states[13]*states[14])
    algebraic[69] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[70] = constants[118]*(states[0]-algebraic[63])*states[15]*((1.00000-algebraic[69])*states[16]+algebraic[69]*states[17])
    algebraic[150] = 1.00000/(1.00000+power(constants[72]/states[9], 2.00000))
    algebraic[123] = exp(constants[70]*algebraic[28])
    algebraic[130] = 1.00000+(constants[1]/constants[63])*(1.00000+1.00000/algebraic[123])
    algebraic[131] = constants[1]/(constants[63]*algebraic[123]*algebraic[130])
    algebraic[134] = algebraic[131]*constants[67]
    algebraic[124] = 1.00000+(states[3]/constants[63])*(1.00000+algebraic[123])
    algebraic[125] = (states[3]*algebraic[123])/(constants[63]*algebraic[124])
    algebraic[137] = algebraic[125]*constants[67]
    algebraic[127] = 1.00000+(states[3]/constants[61])*(1.00000+states[3]/constants[62])
    algebraic[128] = (states[3]*states[3])/(algebraic[127]*constants[61]*constants[62])
    algebraic[140] = algebraic[128]*algebraic[125]*constants[65]
    algebraic[141] = algebraic[131]*constants[147]*constants[65]
    algebraic[132] = 1.00000/algebraic[130]
    algebraic[133] = algebraic[132]*constants[66]
    algebraic[135] = algebraic[133]+algebraic[134]
    algebraic[122] = exp(constants[71]*algebraic[28])
    algebraic[126] = 1.00000/algebraic[124]
    algebraic[136] = (algebraic[126]*constants[66])/algebraic[122]
    algebraic[138] = algebraic[136]+algebraic[137]
    algebraic[129] = 1.00000/algebraic[127]
    algebraic[139] = algebraic[129]*states[9]*constants[68]
    algebraic[142] = constants[150]*algebraic[138]*(algebraic[140]+algebraic[139])+constants[151]*algebraic[140]*(constants[150]+algebraic[135])
    algebraic[143] = constants[149]*algebraic[140]*(algebraic[138]+constants[151])+algebraic[138]*algebraic[139]*(constants[149]+algebraic[141])
    algebraic[144] = constants[149]*algebraic[135]*(algebraic[140]+algebraic[139])+algebraic[141]*algebraic[139]*(constants[150]+algebraic[135])
    algebraic[145] = constants[150]*algebraic[141]*(algebraic[138]+constants[151])+algebraic[135]*constants[151]*(constants[149]+algebraic[141])
    algebraic[146] = algebraic[142]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[147] = algebraic[143]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[148] = algebraic[144]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[149] = algebraic[145]/(algebraic[142]+algebraic[143]+algebraic[144]+algebraic[145])
    algebraic[151] = (3.00000*(algebraic[149]*algebraic[140]-algebraic[146]*algebraic[141])+algebraic[148]*algebraic[137])-algebraic[147]*algebraic[134]
    algebraic[152] = algebraic[147]*constants[150]-algebraic[146]*constants[149]
    algebraic[153] = (1.00000-constants[60])*constants[152]*algebraic[150]*(constants[8]*algebraic[151]+constants[9]*algebraic[152])
    algebraic[205] = (constants[97]*algebraic[25]*(states[3]*exp(algebraic[28])-constants[1]))/(exp(algebraic[28])-1.00000)
    algebraic[104] = exp(-constants[134]*1.00000*((power(algebraic[98], 1.0/2))/(1.00000+power(algebraic[98], 1.0/2))-0.300000*algebraic[98]))
    algebraic[107] = (1.00000*algebraic[25]*(algebraic[104]*states[3]*exp(1.00000*algebraic[28])-constants[140]*constants[1]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[110] = (1.00000-constants[54])*((1.00000-algebraic[90])*constants[132]*algebraic[107]*states[24]*(algebraic[77]*(1.00000-states[33])+states[29]*algebraic[80]*states[33])+algebraic[90]*constants[137]*algebraic[107]*states[24]*(algebraic[81]*(1.00000-states[33])+states[29]*algebraic[82]*states[33]))
    algebraic[208] = (states[4]-states[3])/constants[105]
    algebraic[180] = 1.00000/(1.00000+power(constants[72]/states[2], 2.00000))
    algebraic[160] = 1.00000+(constants[1]/constants[63])*(1.00000+1.00000/algebraic[123])
    algebraic[161] = constants[1]/(constants[63]*algebraic[123]*algebraic[160])
    algebraic[164] = algebraic[161]*constants[67]
    algebraic[154] = 1.00000+(states[4]/constants[63])*(1.00000+algebraic[123])
    algebraic[155] = (states[4]*algebraic[123])/(constants[63]*algebraic[154])
    algebraic[167] = algebraic[155]*constants[67]
    algebraic[157] = 1.00000+(states[4]/constants[61])*(1.00000+states[4]/constants[62])
    algebraic[158] = (states[4]*states[4])/(algebraic[157]*constants[61]*constants[62])
    algebraic[170] = algebraic[158]*algebraic[155]*constants[65]
    algebraic[171] = algebraic[161]*constants[154]*constants[65]
    algebraic[162] = 1.00000/algebraic[160]
    algebraic[163] = algebraic[162]*constants[66]
    algebraic[165] = algebraic[163]+algebraic[164]
    algebraic[156] = 1.00000/algebraic[154]
    algebraic[166] = (algebraic[156]*constants[66])/algebraic[122]
    algebraic[168] = algebraic[166]+algebraic[167]
    algebraic[159] = 1.00000/algebraic[157]
    algebraic[169] = algebraic[159]*states[2]*constants[68]
    algebraic[172] = constants[157]*algebraic[168]*(algebraic[170]+algebraic[169])+constants[158]*algebraic[170]*(constants[157]+algebraic[165])
    algebraic[173] = constants[156]*algebraic[170]*(algebraic[168]+constants[158])+algebraic[168]*algebraic[169]*(constants[156]+algebraic[171])
    algebraic[174] = constants[156]*algebraic[165]*(algebraic[170]+algebraic[169])+algebraic[171]*algebraic[169]*(constants[157]+algebraic[165])
    algebraic[175] = constants[157]*algebraic[171]*(algebraic[168]+constants[158])+algebraic[165]*constants[158]*(constants[156]+algebraic[171])
    algebraic[176] = algebraic[172]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[177] = algebraic[173]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[178] = algebraic[174]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[179] = algebraic[175]/(algebraic[172]+algebraic[173]+algebraic[174]+algebraic[175])
    algebraic[181] = (3.00000*(algebraic[179]*algebraic[170]-algebraic[176]*algebraic[171])+algebraic[178]*algebraic[167])-algebraic[177]*algebraic[164]
    algebraic[182] = algebraic[177]*constants[157]-algebraic[176]*constants[156]
    algebraic[183] = constants[60]*constants[152]*algebraic[180]*(constants[8]*algebraic[181]+constants[9]*algebraic[182])
    algebraic[85] = exp(-constants[134]*1.00000*((power(algebraic[83], 1.0/2))/(1.00000+power(algebraic[83], 1.0/2))-0.300000*algebraic[83]))
    algebraic[88] = (1.00000*algebraic[25]*(algebraic[85]*states[4]*exp(1.00000*algebraic[28])-constants[140]*constants[1]))/(exp(1.00000*algebraic[28])-1.00000)
    algebraic[92] = constants[54]*((1.00000-algebraic[90])*constants[132]*algebraic[88]*states[24]*(algebraic[77]*(1.00000-states[32])+states[29]*algebraic[80]*states[32])+algebraic[90]*constants[137]*algebraic[88]*states[24]*(algebraic[81]*(1.00000-states[32])+states[29]*algebraic[82]*states[32]))
    algebraic[211] = (states[2]-states[9])/constants[107]
    algebraic[213] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[215] = constants[110]*((1.00000-algebraic[213])*states[41]+algebraic[213]*states[42])
    algebraic[56] = 1.00000/(1.00000+(constants[28]*constants[29])/(power(constants[29]+states[2], 2.00000))+(constants[30]*constants[31])/(power(constants[31]+states[2], 2.00000)))
    algebraic[101] = exp(-constants[134]*4.00000*((power(algebraic[98], 1.0/2))/(1.00000+power(algebraic[98], 1.0/2))-0.300000*algebraic[98]))
    algebraic[106] = (4.00000*algebraic[25]*(algebraic[101]*states[9]*exp(2.00000*algebraic[28])-constants[139]*constants[2]))/(exp(2.00000*algebraic[28])-1.00000)
    algebraic[109] = (1.00000-constants[54])*((1.00000-algebraic[90])*constants[121]*algebraic[106]*states[24]*(algebraic[77]*(1.00000-states[33])+states[29]*algebraic[80]*states[33])+algebraic[90]*constants[131]*algebraic[106]*states[24]*(algebraic[81]*(1.00000-states[33])+states[29]*algebraic[82]*states[33]))
    algebraic[112] = algebraic[91]+algebraic[109]
    algebraic[113] = algebraic[92]+algebraic[110]
    algebraic[114] = algebraic[95]+algebraic[111]
    algebraic[209] = (constants[99]*states[9])/(constants[100]+states[9])
    algebraic[207] = (constants[98]*4.00000*algebraic[25]*(algebraic[101]*states[9]*exp(2.00000*algebraic[28])-constants[139]*constants[2]))/(exp(2.00000*algebraic[28])-1.00000)
    algebraic[210] = ((constants[104]*constants[101])/(1.00000+constants[103]/states[2]))*(states[0]-constants[114])
    algebraic[212] = (((1.00000-constants[104])*constants[101])/(1.00000+constants[103]/states[9]))*(states[0]-constants[114])
    algebraic[214] = algebraic[210]+algebraic[212]
    algebraic[216] = constants[102]*(states[0]-constants[114])
    algebraic[217] = (constants[129]*0.00542500*states[9])/(states[9]+0.000920000)
    algebraic[218] = (constants[129]*2.75000*0.00542500*states[9])/((states[9]+0.000920000)-0.000170000)
    algebraic[219] = 1.00000/(1.00000+constants[19]/algebraic[49])
    algebraic[220] = (0.00488250*states[7])/15.0000
    algebraic[221] = constants[111]*(((1.00000-algebraic[219])*algebraic[217]+algebraic[219]*algebraic[218])-algebraic[220])
    algebraic[53] = 1.00000/(1.00000+(constants[113]*constants[25])/(power(constants[25]+states[9], 2.00000))+(constants[26]*constants[27])/(power(constants[27]+states[9], 2.00000)))
    algebraic[222] = (states[7]-states[8])/60.0000
    algebraic[59] = 1.00000/(1.00000+(constants[32]*constants[33])/(power(constants[33]+states[8], 2.00000)))
    return algebraic

def custom_piecewise(cases):
    """Compute result of a piecewise function"""
    return select(cases[0::2],cases[1::2])

def solve_model():
    """Solve model with ODE solver"""
    from scipy.integrate import ode
    # Initialise constants and state variables
    (init_states, constants) = initConsts()

    # Set timespan to solve over
    voi = linspace(0, 10, 500)

    # Construct ODE object to solve
    r = ode(computeRates)
    r.set_integrator('vode', method='bdf', atol=1e-06, rtol=1e-06, max_step=1)
    r.set_initial_value(init_states, voi[0])
    r.set_f_params(constants)

    # Solve model
    states = array([[0.0] * len(voi)] * sizeStates)
    states[:,0] = init_states
    for (i,t) in enumerate(voi[1:]):
        if r.successful():
            r.integrate(t)
            states[:,i+1] = r.y
        else:
            break

    # Compute algebraic variables
    algebraic = computeAlgebraic(constants, states, voi)
    return (voi, states, algebraic)

def plot_model(voi, states, algebraic):
    """Plot variables against variable of integration"""
    import pylab
    (legend_states, legend_algebraic, legend_voi, legend_constants) = createLegends()
    pylab.figure(1)
    pylab.plot(voi,vstack((states,algebraic)).T)
    pylab.xlabel(legend_voi)
    pylab.legend(legend_states + legend_algebraic, loc='best')
    pylab.show()

if __name__ == "__main__":
    (voi, states, algebraic) = solve_model()
    plot_model(voi, states, algebraic)