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 = 198
sizeStates = 41
sizeConstants = 140
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] = "R in component physical_constants (joule_per_kilomole_kelvin)"
    legend_constants[5] = "T in component physical_constants (kelvin)"
    legend_constants[6] = "F in component physical_constants (coulomb_per_mole)"
    legend_constants[7] = "zna in component physical_constants (dimensionless)"
    legend_constants[8] = "zca in component physical_constants (dimensionless)"
    legend_constants[9] = "zk in component physical_constants (dimensionless)"
    legend_constants[10] = "L in component cell_geometry (centimeter)"
    legend_constants[11] = "rad in component cell_geometry (centimeter)"
    legend_constants[105] = "vcell in component cell_geometry (microliter)"
    legend_constants[114] = "Ageo in component cell_geometry (centimeter_squared)"
    legend_constants[118] = "Acap in component cell_geometry (centimeter_squared)"
    legend_constants[119] = "vmyo in component cell_geometry (microliter)"
    legend_constants[120] = "vnsr in component cell_geometry (microliter)"
    legend_constants[121] = "vjsr in component cell_geometry (microliter)"
    legend_constants[122] = "vss in component cell_geometry (microliter)"
    legend_states[0] = "v in component membrane (millivolt)"
    legend_algebraic[29] = "vffrt in component membrane (coulomb_per_mole)"
    legend_algebraic[39] = "vfrt in component membrane (dimensionless)"
    legend_algebraic[62] = "INa in component INa (microA_per_microF)"
    legend_algebraic[64] = "INaL in component INaL (microA_per_microF)"
    legend_algebraic[70] = "Ito in component Ito (microA_per_microF)"
    legend_algebraic[81] = "ICaL in component ICaL (microA_per_microF)"
    legend_algebraic[82] = "ICaNa in component ICaL (microA_per_microF)"
    legend_algebraic[85] = "ICaK in component ICaL (microA_per_microF)"
    legend_algebraic[96] = "IKr in component IKr (microA_per_microF)"
    legend_algebraic[98] = "IKs in component IKs (microA_per_microF)"
    legend_algebraic[100] = "IK1 in component IK1 (microA_per_microF)"
    legend_algebraic[132] = "INaCa_i in component INaCa_i (microA_per_microF)"
    legend_algebraic[162] = "INaCa_ss in component INaCa_i (microA_per_microF)"
    legend_algebraic[181] = "INaK in component INaK (microA_per_microF)"
    legend_algebraic[184] = "INab in component INab (microA_per_microF)"
    legend_algebraic[183] = "IKb in component IKb (microA_per_microF)"
    legend_algebraic[188] = "IpCa in component IpCa (microA_per_microF)"
    legend_algebraic[186] = "ICab in component ICab (microA_per_microF)"
    legend_algebraic[12] = "Istim in component membrane (microA_per_microF)"
    legend_constants[12] = "amp in component membrane (microA_per_microF)"
    legend_constants[13] = "duration in component membrane (millisecond)"
    legend_constants[14] = "stimStart in component membrane (millisecond)"
    legend_constants[15] = "KmCaMK in component CaMK (millimolar)"
    legend_constants[16] = "aCaMK in component CaMK (per_millimolar_per_millisecond)"
    legend_constants[17] = "bCaMK in component CaMK (per_millisecond)"
    legend_constants[18] = "CaMKo in component CaMK (dimensionless)"
    legend_constants[19] = "KmCaM in component CaMK (millimolar)"
    legend_algebraic[45] = "CaMKb in component CaMK (millimolar)"
    legend_algebraic[47] = "CaMKa in component CaMK (millimolar)"
    legend_states[1] = "CaMKt in component CaMK (millimolar)"
    legend_states[2] = "cass in component intracellular_ions (millimolar)"
    legend_constants[20] = "cmdnmax_b in component intracellular_ions (millimolar)"
    legend_constants[94] = "cmdnmax in component intracellular_ions (millimolar)"
    legend_constants[21] = "kmcmdn in component intracellular_ions (millimolar)"
    legend_constants[22] = "trpnmax in component intracellular_ions (millimolar)"
    legend_constants[23] = "kmtrpn in component intracellular_ions (millimolar)"
    legend_constants[24] = "BSRmax in component intracellular_ions (millimolar)"
    legend_constants[25] = "KmBSR in component intracellular_ions (millimolar)"
    legend_constants[26] = "BSLmax in component intracellular_ions (millimolar)"
    legend_constants[27] = "KmBSL in component intracellular_ions (millimolar)"
    legend_constants[28] = "csqnmax in component intracellular_ions (millimolar)"
    legend_constants[29] = "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_algebraic[187] = "JdiffNa in component diff (millimolar_per_millisecond)"
    legend_algebraic[189] = "Jdiff in component diff (millimolar_per_millisecond)"
    legend_algebraic[196] = "Jup in component SERCA (millimolar_per_millisecond)"
    legend_algebraic[185] = "JdiffK in component diff (millimolar_per_millisecond)"
    legend_algebraic[191] = "Jrel in component ryr (millimolar_per_millisecond)"
    legend_algebraic[197] = "Jtr in component trans_flux (millimolar_per_millisecond)"
    legend_algebraic[49] = "Bcai in component intracellular_ions (dimensionless)"
    legend_algebraic[53] = "Bcajsr in component intracellular_ions (dimensionless)"
    legend_algebraic[51] = "Bcass in component intracellular_ions (dimensionless)"
    legend_constants[30] = "cm in component intracellular_ions (microF_per_centimeter_squared)"
    legend_constants[31] = "PKNa in component reversal_potentials (dimensionless)"
    legend_algebraic[56] = "ENa in component reversal_potentials (millivolt)"
    legend_algebraic[57] = "EK in component reversal_potentials (millivolt)"
    legend_algebraic[58] = "EKs in component reversal_potentials (millivolt)"
    legend_algebraic[0] = "mss in component INa (dimensionless)"
    legend_algebraic[13] = "tm in component INa (millisecond)"
    legend_constants[32] = "mssV1 in component INa (millivolt)"
    legend_constants[33] = "mssV2 in component INa (millivolt)"
    legend_constants[34] = "mtV1 in component INa (millivolt)"
    legend_constants[35] = "mtV2 in component INa (millivolt)"
    legend_constants[36] = "mtD1 in component INa (dimensionless)"
    legend_constants[37] = "mtD2 in component INa (dimensionless)"
    legend_constants[38] = "mtV3 in component INa (millivolt)"
    legend_constants[39] = "mtV4 in component INa (millivolt)"
    legend_states[10] = "m in component INa (dimensionless)"
    legend_algebraic[1] = "hss in component INa (dimensionless)"
    legend_algebraic[14] = "thf in component INa (millisecond)"
    legend_algebraic[15] = "ths in component INa (millisecond)"
    legend_constants[40] = "hssV1 in component INa (millivolt)"
    legend_constants[41] = "hssV2 in component INa (millivolt)"
    legend_constants[95] = "Ahs in component INa (dimensionless)"
    legend_constants[42] = "Ahf in component INa (dimensionless)"
    legend_states[11] = "hf in component INa (dimensionless)"
    legend_states[12] = "hs in component INa (dimensionless)"
    legend_algebraic[59] = "h in component INa (dimensionless)"
    legend_constants[43] = "GNa in component INa (milliS_per_microF)"
    legend_algebraic[16] = "jss in component INa (dimensionless)"
    legend_algebraic[30] = "tj in component INa (millisecond)"
    legend_states[13] = "j in component INa (dimensionless)"
    legend_algebraic[31] = "hssp in component INa (dimensionless)"
    legend_algebraic[40] = "thsp in component INa (millisecond)"
    legend_states[14] = "hsp in component INa (dimensionless)"
    legend_algebraic[60] = "hp in component INa (dimensionless)"
    legend_algebraic[41] = "tjp in component INa (millisecond)"
    legend_states[15] = "jp in component INa (dimensionless)"
    legend_algebraic[61] = "fINap in component INa (dimensionless)"
    legend_algebraic[32] = "mLss in component INaL (dimensionless)"
    legend_algebraic[42] = "tmL in component INaL (millisecond)"
    legend_states[16] = "mL in component INaL (dimensionless)"
    legend_constants[44] = "thL in component INaL (millisecond)"
    legend_algebraic[2] = "hLss in component INaL (dimensionless)"
    legend_states[17] = "hL in component INaL (dimensionless)"
    legend_algebraic[3] = "hLssp in component INaL (dimensionless)"
    legend_constants[96] = "thLp in component INaL (millisecond)"
    legend_states[18] = "hLp in component INaL (dimensionless)"
    legend_constants[45] = "GNaL_b in component INaL (milliS_per_microF)"
    legend_constants[97] = "GNaL in component INaL (milliS_per_microF)"
    legend_algebraic[63] = "fINaLp in component INaL (dimensionless)"
    legend_constants[46] = "Gto_b in component Ito (milliS_per_microF)"
    legend_algebraic[4] = "ass in component Ito (dimensionless)"
    legend_algebraic[17] = "ta in component Ito (millisecond)"
    legend_states[19] = "a in component Ito (dimensionless)"
    legend_algebraic[5] = "iss in component Ito (dimensionless)"
    legend_algebraic[18] = "delta_epi in component Ito (dimensionless)"
    legend_algebraic[33] = "tiF_b in component Ito (millisecond)"
    legend_algebraic[43] = "tiS_b in component Ito (millisecond)"
    legend_algebraic[46] = "tiF in component Ito (millisecond)"
    legend_algebraic[48] = "tiS in component Ito (millisecond)"
    legend_algebraic[65] = "AiF in component Ito (dimensionless)"
    legend_algebraic[66] = "AiS in component Ito (dimensionless)"
    legend_states[20] = "iF in component Ito (dimensionless)"
    legend_states[21] = "iS in component Ito (dimensionless)"
    legend_algebraic[67] = "i in component Ito (dimensionless)"
    legend_algebraic[34] = "assp in component Ito (dimensionless)"
    legend_states[22] = "ap in component Ito (dimensionless)"
    legend_algebraic[50] = "dti_develop in component Ito (dimensionless)"
    legend_algebraic[52] = "dti_recover in component Ito (dimensionless)"
    legend_algebraic[54] = "tiFp in component Ito (millisecond)"
    legend_algebraic[55] = "tiSp in component Ito (millisecond)"
    legend_states[23] = "iFp in component Ito (dimensionless)"
    legend_states[24] = "iSp in component Ito (dimensionless)"
    legend_algebraic[68] = "ip in component Ito (dimensionless)"
    legend_constants[98] = "Gto in component Ito (milliS_per_microF)"
    legend_algebraic[69] = "fItop in component Ito (dimensionless)"
    legend_constants[47] = "Kmn in component ICaL (millimolar)"
    legend_constants[48] = "k2n in component ICaL (per_millisecond)"
    legend_constants[49] = "PCa_b in component ICaL (dimensionless)"
    legend_algebraic[6] = "dss in component ICaL (dimensionless)"
    legend_states[25] = "d in component ICaL (dimensionless)"
    legend_algebraic[7] = "fss in component ICaL (dimensionless)"
    legend_constants[99] = "Aff in component ICaL (dimensionless)"
    legend_constants[110] = "Afs in component ICaL (dimensionless)"
    legend_states[26] = "ff in component ICaL (dimensionless)"
    legend_states[27] = "fs in component ICaL (dimensionless)"
    legend_algebraic[71] = "f in component ICaL (dimensionless)"
    legend_algebraic[19] = "fcass in component ICaL (dimensionless)"
    legend_algebraic[72] = "Afcaf in component ICaL (dimensionless)"
    legend_algebraic[73] = "Afcas in component ICaL (dimensionless)"
    legend_states[28] = "fcaf in component ICaL (dimensionless)"
    legend_states[29] = "fcas in component ICaL (dimensionless)"
    legend_algebraic[74] = "fca in component ICaL (dimensionless)"
    legend_states[30] = "jca in component ICaL (dimensionless)"
    legend_states[31] = "ffp in component ICaL (dimensionless)"
    legend_algebraic[75] = "fp in component ICaL (dimensionless)"
    legend_states[32] = "fcafp in component ICaL (dimensionless)"
    legend_algebraic[76] = "fcap in component ICaL (dimensionless)"
    legend_algebraic[8] = "km2n in component ICaL (per_millisecond)"
    legend_algebraic[20] = "anca in component ICaL (dimensionless)"
    legend_states[33] = "nca in component ICaL (dimensionless)"
    legend_algebraic[77] = "PhiCaL in component ICaL (dimensionless)"
    legend_algebraic[78] = "PhiCaNa in component ICaL (dimensionless)"
    legend_algebraic[79] = "PhiCaK in component ICaL (dimensionless)"
    legend_constants[100] = "PCa in component ICaL (dimensionless)"
    legend_constants[111] = "PCap in component ICaL (dimensionless)"
    legend_constants[112] = "PCaNa in component ICaL (dimensionless)"
    legend_constants[113] = "PCaK in component ICaL (dimensionless)"
    legend_constants[116] = "PCaNap in component ICaL (dimensionless)"
    legend_constants[117] = "PCaKp in component ICaL (dimensionless)"
    legend_algebraic[80] = "fICaLp in component ICaL (dimensionless)"
    legend_algebraic[21] = "td in component ICaL (millisecond)"
    legend_algebraic[22] = "tff in component ICaL (millisecond)"
    legend_algebraic[23] = "tfs in component ICaL (millisecond)"
    legend_algebraic[35] = "tfcaf in component ICaL (millisecond)"
    legend_algebraic[36] = "tfcas in component ICaL (millisecond)"
    legend_constants[101] = "tjca in component ICaL (millisecond)"
    legend_algebraic[37] = "tffp in component ICaL (millisecond)"
    legend_algebraic[44] = "tfcafp in component ICaL (millisecond)"
    legend_constants[50] = "GKr_b in component IKr (milliS_per_microF)"
    legend_constants[102] = "GKr in component IKr (milliS_per_microF)"
    legend_algebraic[9] = "xrss in component IKr (dimensionless)"
    legend_algebraic[24] = "txrf in component IKr (millisecond)"
    legend_algebraic[25] = "txrs in component IKr (millisecond)"
    legend_algebraic[88] = "Axrf in component IKr (dimensionless)"
    legend_algebraic[91] = "Axrs in component IKr (dimensionless)"
    legend_states[34] = "xrf in component IKr (dimensionless)"
    legend_states[35] = "xrs in component IKr (dimensionless)"
    legend_algebraic[94] = "xr in component IKr (dimensionless)"
    legend_algebraic[95] = "rkr in component IKr (dimensionless)"
    legend_constants[51] = "GKs_b in component IKs (milliS_per_microF)"
    legend_constants[103] = "GKs in component IKs (milliS_per_microF)"
    legend_algebraic[10] = "xs1ss in component IKs (dimensionless)"
    legend_algebraic[26] = "xs2ss in component IKs (dimensionless)"
    legend_algebraic[27] = "txs1 in component IKs (millisecond)"
    legend_states[36] = "xs1 in component IKs (dimensionless)"
    legend_states[37] = "xs2 in component IKs (dimensionless)"
    legend_algebraic[97] = "KsCa in component IKs (dimensionless)"
    legend_algebraic[38] = "txs2 in component IKs (millisecond)"
    legend_constants[104] = "GK1 in component IK1 (milliS_per_microF)"
    legend_constants[52] = "GK1_b in component IK1 (milliS_per_microF)"
    legend_algebraic[11] = "xk1ss in component IK1 (dimensionless)"
    legend_algebraic[28] = "txk1 in component IK1 (millisecond)"
    legend_states[38] = "xk1 in component IK1 (dimensionless)"
    legend_algebraic[99] = "rk1 in component IK1 (millisecond)"
    legend_constants[53] = "kna1 in component INaCa_i (per_millisecond)"
    legend_constants[54] = "kna2 in component INaCa_i (per_millisecond)"
    legend_constants[55] = "kna3 in component INaCa_i (per_millisecond)"
    legend_constants[56] = "kasymm in component INaCa_i (dimensionless)"
    legend_constants[57] = "wna in component INaCa_i (dimensionless)"
    legend_constants[58] = "wca in component INaCa_i (dimensionless)"
    legend_constants[59] = "wnaca in component INaCa_i (dimensionless)"
    legend_constants[60] = "kcaon in component INaCa_i (per_millisecond)"
    legend_constants[61] = "kcaoff in component INaCa_i (per_millisecond)"
    legend_constants[62] = "qna in component INaCa_i (dimensionless)"
    legend_constants[63] = "qca in component INaCa_i (dimensionless)"
    legend_algebraic[102] = "hna in component INaCa_i (dimensionless)"
    legend_algebraic[101] = "hca in component INaCa_i (dimensionless)"
    legend_constants[64] = "KmCaAct in component INaCa_i (millimolar)"
    legend_constants[65] = "Gncx_b in component INaCa_i (milliS_per_microF)"
    legend_constants[129] = "Gncx in component INaCa_i (milliS_per_microF)"
    legend_algebraic[103] = "h1_i in component INaCa_i (dimensionless)"
    legend_algebraic[104] = "h2_i in component INaCa_i (dimensionless)"
    legend_algebraic[105] = "h3_i in component INaCa_i (dimensionless)"
    legend_algebraic[106] = "h4_i in component INaCa_i (dimensionless)"
    legend_algebraic[107] = "h5_i in component INaCa_i (dimensionless)"
    legend_algebraic[108] = "h6_i in component INaCa_i (dimensionless)"
    legend_algebraic[109] = "h7_i in component INaCa_i (dimensionless)"
    legend_algebraic[110] = "h8_i in component INaCa_i (dimensionless)"
    legend_algebraic[111] = "h9_i in component INaCa_i (dimensionless)"
    legend_constants[123] = "h10_i in component INaCa_i (dimensionless)"
    legend_constants[124] = "h11_i in component INaCa_i (dimensionless)"
    legend_constants[125] = "h12_i in component INaCa_i (dimensionless)"
    legend_constants[126] = "k1_i in component INaCa_i (dimensionless)"
    legend_constants[127] = "k2_i in component INaCa_i (dimensionless)"
    legend_algebraic[112] = "k3p_i in component INaCa_i (dimensionless)"
    legend_algebraic[113] = "k3pp_i in component INaCa_i (dimensionless)"
    legend_algebraic[114] = "k3_i in component INaCa_i (dimensionless)"
    legend_algebraic[117] = "k4_i in component INaCa_i (dimensionless)"
    legend_algebraic[115] = "k4p_i in component INaCa_i (dimensionless)"
    legend_algebraic[116] = "k4pp_i in component INaCa_i (dimensionless)"
    legend_constants[128] = "k5_i in component INaCa_i (dimensionless)"
    legend_algebraic[118] = "k6_i in component INaCa_i (dimensionless)"
    legend_algebraic[119] = "k7_i in component INaCa_i (dimensionless)"
    legend_algebraic[120] = "k8_i in component INaCa_i (dimensionless)"
    legend_algebraic[121] = "x1_i in component INaCa_i (dimensionless)"
    legend_algebraic[122] = "x2_i in component INaCa_i (dimensionless)"
    legend_algebraic[123] = "x3_i in component INaCa_i (dimensionless)"
    legend_algebraic[124] = "x4_i in component INaCa_i (dimensionless)"
    legend_algebraic[125] = "E1_i in component INaCa_i (dimensionless)"
    legend_algebraic[126] = "E2_i in component INaCa_i (dimensionless)"
    legend_algebraic[127] = "E3_i in component INaCa_i (dimensionless)"
    legend_algebraic[128] = "E4_i in component INaCa_i (dimensionless)"
    legend_algebraic[129] = "allo_i in component INaCa_i (dimensionless)"
    legend_algebraic[130] = "JncxNa_i in component INaCa_i (millimolar_per_millisecond)"
    legend_algebraic[131] = "JncxCa_i in component INaCa_i (millimolar_per_millisecond)"
    legend_algebraic[133] = "h1_ss in component INaCa_i (dimensionless)"
    legend_algebraic[134] = "h2_ss in component INaCa_i (dimensionless)"
    legend_algebraic[135] = "h3_ss in component INaCa_i (dimensionless)"
    legend_algebraic[136] = "h4_ss in component INaCa_i (dimensionless)"
    legend_algebraic[137] = "h5_ss in component INaCa_i (dimensionless)"
    legend_algebraic[138] = "h6_ss in component INaCa_i (dimensionless)"
    legend_algebraic[139] = "h7_ss in component INaCa_i (dimensionless)"
    legend_algebraic[140] = "h8_ss in component INaCa_i (dimensionless)"
    legend_algebraic[141] = "h9_ss in component INaCa_i (dimensionless)"
    legend_constants[130] = "h10_ss in component INaCa_i (dimensionless)"
    legend_constants[131] = "h11_ss in component INaCa_i (dimensionless)"
    legend_constants[132] = "h12_ss in component INaCa_i (dimensionless)"
    legend_constants[133] = "k1_ss in component INaCa_i (dimensionless)"
    legend_constants[134] = "k2_ss in component INaCa_i (dimensionless)"
    legend_algebraic[142] = "k3p_ss in component INaCa_i (dimensionless)"
    legend_algebraic[143] = "k3pp_ss in component INaCa_i (dimensionless)"
    legend_algebraic[144] = "k3_ss in component INaCa_i (dimensionless)"
    legend_algebraic[147] = "k4_ss in component INaCa_i (dimensionless)"
    legend_algebraic[145] = "k4p_ss in component INaCa_i (dimensionless)"
    legend_algebraic[146] = "k4pp_ss in component INaCa_i (dimensionless)"
    legend_constants[135] = "k5_ss in component INaCa_i (dimensionless)"
    legend_algebraic[148] = "k6_ss in component INaCa_i (dimensionless)"
    legend_algebraic[149] = "k7_ss in component INaCa_i (dimensionless)"
    legend_algebraic[150] = "k8_ss in component INaCa_i (dimensionless)"
    legend_algebraic[151] = "x1_ss in component INaCa_i (dimensionless)"
    legend_algebraic[152] = "x2_ss in component INaCa_i (dimensionless)"
    legend_algebraic[153] = "x3_ss in component INaCa_i (dimensionless)"
    legend_algebraic[154] = "x4_ss in component INaCa_i (dimensionless)"
    legend_algebraic[155] = "E1_ss in component INaCa_i (dimensionless)"
    legend_algebraic[156] = "E2_ss in component INaCa_i (dimensionless)"
    legend_algebraic[157] = "E3_ss in component INaCa_i (dimensionless)"
    legend_algebraic[158] = "E4_ss in component INaCa_i (dimensionless)"
    legend_algebraic[159] = "allo_ss in component INaCa_i (dimensionless)"
    legend_algebraic[160] = "JncxNa_ss in component INaCa_i (millimolar_per_millisecond)"
    legend_algebraic[161] = "JncxCa_ss in component INaCa_i (millimolar_per_millisecond)"
    legend_constants[66] = "k1p in component INaK (per_millisecond)"
    legend_constants[67] = "k1m in component INaK (per_millisecond)"
    legend_constants[68] = "k2p in component INaK (per_millisecond)"
    legend_constants[69] = "k2m in component INaK (per_millisecond)"
    legend_constants[70] = "k3p in component INaK (per_millisecond)"
    legend_constants[71] = "k3m in component INaK (per_millisecond)"
    legend_constants[72] = "k4p in component INaK (per_millisecond)"
    legend_constants[73] = "k4m in component INaK (per_millisecond)"
    legend_constants[74] = "Knai0 in component INaK (millimolar)"
    legend_constants[75] = "Knao0 in component INaK (millimolar)"
    legend_constants[76] = "delta in component INaK (millivolt)"
    legend_constants[77] = "Kki in component INaK (per_millisecond)"
    legend_constants[78] = "Kko in component INaK (per_millisecond)"
    legend_constants[79] = "MgADP in component INaK (millimolar)"
    legend_constants[80] = "MgATP in component INaK (millimolar)"
    legend_constants[81] = "Kmgatp in component INaK (millimolar)"
    legend_constants[82] = "H in component INaK (millimolar)"
    legend_constants[83] = "eP in component INaK (dimensionless)"
    legend_constants[84] = "Khp in component INaK (millimolar)"
    legend_constants[85] = "Knap in component INaK (millimolar)"
    legend_constants[86] = "Kxkur in component INaK (millimolar)"
    legend_constants[87] = "Pnak_b in component INaK (milliS_per_microF)"
    legend_constants[139] = "Pnak in component INaK (milliS_per_microF)"
    legend_algebraic[163] = "Knai in component INaK (millimolar)"
    legend_algebraic[164] = "Knao in component INaK (millimolar)"
    legend_algebraic[165] = "P in component INaK (dimensionless)"
    legend_algebraic[166] = "a1 in component INaK (dimensionless)"
    legend_constants[136] = "b1 in component INaK (dimensionless)"
    legend_constants[137] = "a2 in component INaK (dimensionless)"
    legend_algebraic[167] = "b2 in component INaK (dimensionless)"
    legend_algebraic[168] = "a3 in component INaK (dimensionless)"
    legend_algebraic[169] = "b3 in component INaK (dimensionless)"
    legend_constants[138] = "a4 in component INaK (dimensionless)"
    legend_algebraic[170] = "b4 in component INaK (dimensionless)"
    legend_algebraic[171] = "x1 in component INaK (dimensionless)"
    legend_algebraic[172] = "x2 in component INaK (dimensionless)"
    legend_algebraic[173] = "x3 in component INaK (dimensionless)"
    legend_algebraic[174] = "x4 in component INaK (dimensionless)"
    legend_algebraic[175] = "E1 in component INaK (dimensionless)"
    legend_algebraic[176] = "E2 in component INaK (dimensionless)"
    legend_algebraic[177] = "E3 in component INaK (dimensionless)"
    legend_algebraic[178] = "E4 in component INaK (dimensionless)"
    legend_algebraic[179] = "JnakNa in component INaK (millimolar_per_millisecond)"
    legend_algebraic[180] = "JnakK in component INaK (millimolar_per_millisecond)"
    legend_algebraic[182] = "xkb in component IKb (dimensionless)"
    legend_constants[88] = "GKb_b in component IKb (milliS_per_microF)"
    legend_constants[106] = "GKb in component IKb (milliS_per_microF)"
    legend_constants[89] = "PNab in component INab (milliS_per_microF)"
    legend_constants[90] = "PCab in component ICab (milliS_per_microF)"
    legend_constants[91] = "GpCa in component IpCa (milliS_per_microF)"
    legend_constants[92] = "KmCap in component IpCa (millimolar)"
    legend_constants[93] = "bt in component ryr (millisecond)"
    legend_constants[107] = "a_rel in component ryr (millisecond)"
    legend_algebraic[86] = "Jrel_inf in component ryr (dimensionless)"
    legend_algebraic[92] = "tau_rel in component ryr (millisecond)"
    legend_algebraic[87] = "Jrel_infp in component ryr (dimensionless)"
    legend_algebraic[84] = "Jrel_temp in component ryr (dimensionless)"
    legend_algebraic[93] = "tau_relp in component ryr (millisecond)"
    legend_states[39] = "Jrelnp in component ryr (dimensionless)"
    legend_states[40] = "Jrelp in component ryr (dimensionless)"
    legend_constants[108] = "btp in component ryr (millisecond)"
    legend_constants[115] = "a_relp in component ryr (millisecond)"
    legend_algebraic[83] = "Jrel_inf_temp in component ryr (dimensionless)"
    legend_algebraic[190] = "fJrelp in component ryr (dimensionless)"
    legend_algebraic[89] = "tau_rel_temp in component ryr (millisecond)"
    legend_algebraic[90] = "tau_relp_temp in component ryr (millisecond)"
    legend_constants[109] = "upScale in component SERCA (dimensionless)"
    legend_algebraic[192] = "Jupnp in component SERCA (millimolar_per_millisecond)"
    legend_algebraic[193] = "Jupp in component SERCA (millimolar_per_millisecond)"
    legend_algebraic[194] = "fJupp in component SERCA (dimensionless)"
    legend_algebraic[195] = "Jleak in component SERCA (millimolar_per_millisecond)"
    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 hf in component INa (dimensionless)"
    legend_rates[12] = "d/dt hs in component INa (dimensionless)"
    legend_rates[13] = "d/dt j in component INa (dimensionless)"
    legend_rates[14] = "d/dt hsp in component INa (dimensionless)"
    legend_rates[15] = "d/dt jp in component INa (dimensionless)"
    legend_rates[16] = "d/dt mL in component INaL (dimensionless)"
    legend_rates[17] = "d/dt hL in component INaL (dimensionless)"
    legend_rates[18] = "d/dt hLp in component INaL (dimensionless)"
    legend_rates[19] = "d/dt a in component Ito (dimensionless)"
    legend_rates[20] = "d/dt iF in component Ito (dimensionless)"
    legend_rates[21] = "d/dt iS in component Ito (dimensionless)"
    legend_rates[22] = "d/dt ap in component Ito (dimensionless)"
    legend_rates[23] = "d/dt iFp in component Ito (dimensionless)"
    legend_rates[24] = "d/dt iSp in component Ito (dimensionless)"
    legend_rates[25] = "d/dt d in component ICaL (dimensionless)"
    legend_rates[26] = "d/dt ff in component ICaL (dimensionless)"
    legend_rates[27] = "d/dt fs in component ICaL (dimensionless)"
    legend_rates[28] = "d/dt fcaf in component ICaL (dimensionless)"
    legend_rates[29] = "d/dt fcas in component ICaL (dimensionless)"
    legend_rates[30] = "d/dt jca in component ICaL (dimensionless)"
    legend_rates[31] = "d/dt ffp in component ICaL (dimensionless)"
    legend_rates[32] = "d/dt fcafp in component ICaL (dimensionless)"
    legend_rates[33] = "d/dt nca in component ICaL (dimensionless)"
    legend_rates[34] = "d/dt xrf in component IKr (dimensionless)"
    legend_rates[35] = "d/dt xrs in component IKr (dimensionless)"
    legend_rates[36] = "d/dt xs1 in component IKs (dimensionless)"
    legend_rates[37] = "d/dt xs2 in component IKs (dimensionless)"
    legend_rates[38] = "d/dt xk1 in component IK1 (dimensionless)"
    legend_rates[39] = "d/dt Jrelnp in component ryr (dimensionless)"
    legend_rates[40] = "d/dt Jrelp in component ryr (dimensionless)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 0
    constants[1] = 140
    constants[2] = 1.8
    constants[3] = 5.4
    constants[4] = 8314
    constants[5] = 310
    constants[6] = 96485
    constants[7] = 1
    constants[8] = 2
    constants[9] = 1
    constants[10] = 0.01
    constants[11] = 0.0011
    states[0] = -87
    constants[12] = -80
    constants[13] = 0.5
    constants[14] = 50.0
    constants[15] = 0.15
    constants[16] = 0.05
    constants[17] = 0.00068
    constants[18] = 0.05
    constants[19] = 0.0015
    states[1] = 0
    states[2] = 1e-4
    constants[20] = 0.05
    constants[21] = 0.00238
    constants[22] = 0.07
    constants[23] = 0.0005
    constants[24] = 0.047
    constants[25] = 0.00087
    constants[26] = 1.124
    constants[27] = 0.0087
    constants[28] = 10
    constants[29] = 0.8
    states[3] = 7
    states[4] = 7
    states[5] = 145
    states[6] = 145
    states[7] = 1.2
    states[8] = 1.2
    states[9] = 1e-4
    constants[30] = 1
    constants[31] = 0.01833
    constants[32] = 39.57
    constants[33] = 9.871
    constants[34] = 11.64
    constants[35] = 34.77
    constants[36] = 6.765
    constants[37] = 8.552
    constants[38] = 77.42
    constants[39] = 5.955
    states[10] = 0
    constants[40] = 82.9
    constants[41] = 6.086
    constants[42] = 0.99
    states[11] = 1
    states[12] = 1
    constants[43] = 75
    states[13] = 1
    states[14] = 1
    states[15] = 1
    states[16] = 0
    constants[44] = 200
    states[17] = 1
    states[18] = 1
    constants[45] = 0.0075
    constants[46] = 0.02
    states[19] = 0
    states[20] = 1
    states[21] = 1
    states[22] = 0
    states[23] = 1
    states[24] = 1
    constants[47] = 0.002
    constants[48] = 1000
    constants[49] = 0.0001
    states[25] = 0
    states[26] = 1
    states[27] = 1
    states[28] = 1
    states[29] = 1
    states[30] = 1
    states[31] = 1
    states[32] = 1
    states[33] = 0
    constants[50] = 0.046
    states[34] = 0
    states[35] = 0
    constants[51] = 0.0034
    states[36] = 0
    states[37] = 0
    constants[52] = 0.1908
    states[38] = 1
    constants[53] = 15
    constants[54] = 5
    constants[55] = 88.12
    constants[56] = 12.5
    constants[57] = 6e4
    constants[58] = 6e4
    constants[59] = 5e3
    constants[60] = 1.5e6
    constants[61] = 5e3
    constants[62] = 0.5224
    constants[63] = 0.167
    constants[64] = 150e-6
    constants[65] = 0.0008
    constants[66] = 949.5
    constants[67] = 182.4
    constants[68] = 687.2
    constants[69] = 39.4
    constants[70] = 1899
    constants[71] = 79300
    constants[72] = 639
    constants[73] = 40
    constants[74] = 9.073
    constants[75] = 27.78
    constants[76] = -0.155
    constants[77] = 0.5
    constants[78] = 0.3582
    constants[79] = 0.05
    constants[80] = 9.8
    constants[81] = 1.698e-7
    constants[82] = 1e-7
    constants[83] = 4.2
    constants[84] = 1.698e-7
    constants[85] = 224
    constants[86] = 292
    constants[87] = 30
    constants[88] = 0.003
    constants[89] = 3.75e-10
    constants[90] = 2.5e-8
    constants[91] = 0.0005
    constants[92] = 0.0005
    constants[93] = 4.75
    states[39] = 0
    states[40] = 0
    constants[94] = custom_piecewise([equal(constants[0] , 1.00000), constants[20]*1.30000 , True, constants[20]])
    constants[95] = 1.00000-constants[42]
    constants[96] = 3.00000*constants[44]
    constants[97] = custom_piecewise([equal(constants[0] , 1.00000), constants[45]*0.600000 , True, constants[45]])
    constants[98] = custom_piecewise([equal(constants[0] , 1.00000), constants[46]*4.00000 , equal(constants[0] , 2.00000), constants[46]*4.00000 , True, constants[46]])
    constants[99] = 0.600000
    constants[100] = custom_piecewise([equal(constants[0] , 1.00000), constants[49]*1.20000 , equal(constants[0] , 2.00000), constants[49]*2.50000 , True, constants[49]])
    constants[101] = 75.0000
    constants[102] = custom_piecewise([equal(constants[0] , 1.00000), constants[50]*1.30000 , equal(constants[0] , 2.00000), constants[50]*0.800000 , True, constants[50]])
    constants[103] = custom_piecewise([equal(constants[0] , 1.00000), constants[51]*1.40000 , True, constants[51]])
    constants[104] = custom_piecewise([equal(constants[0] , 1.00000), constants[52]*1.20000 , equal(constants[0] , 2.00000), constants[52]*1.30000 , True, constants[52]])
    constants[105] = 1000.00*3.14000*constants[11]*constants[11]*constants[10]
    constants[106] = custom_piecewise([equal(constants[0] , 1.00000), constants[88]*0.600000 , True, constants[88]])
    constants[107] = 0.500000*constants[93]
    constants[108] = 1.25000*constants[93]
    constants[109] = custom_piecewise([equal(constants[0] , 1.00000), 1.30000 , True, 1.00000])
    constants[110] = 1.00000-constants[99]
    constants[111] = 1.10000*constants[100]
    constants[112] = 0.00125000*constants[100]
    constants[113] = 0.000357400*constants[100]
    constants[114] = 2.00000*3.14000*constants[11]*constants[11]+2.00000*3.14000*constants[11]*constants[10]
    constants[115] = 0.500000*constants[108]
    constants[116] = 0.00125000*constants[111]
    constants[117] = 0.000357400*constants[111]
    constants[118] = 2.00000*constants[114]
    constants[119] = 0.680000*constants[105]
    constants[120] = 0.0552000*constants[105]
    constants[121] = 0.00480000*constants[105]
    constants[122] = 0.0200000*constants[105]
    constants[123] = constants[56]+1.00000+(constants[1]/constants[53])*(1.00000+constants[1]/constants[54])
    constants[124] = (constants[1]*constants[1])/(constants[123]*constants[53]*constants[54])
    constants[125] = 1.00000/constants[123]
    constants[126] = constants[125]*constants[2]*constants[60]
    constants[127] = constants[61]
    constants[128] = constants[61]
    constants[129] = custom_piecewise([equal(constants[0] , 1.00000), constants[65]*1.10000 , equal(constants[0] , 2.00000), constants[65]*1.40000 , True, constants[65]])
    constants[130] = constants[56]+1.00000+(constants[1]/constants[53])*(1.00000+constants[1]/constants[54])
    constants[131] = (constants[1]*constants[1])/(constants[130]*constants[53]*constants[54])
    constants[132] = 1.00000/constants[130]
    constants[133] = constants[132]*constants[2]*constants[60]
    constants[134] = constants[61]
    constants[135] = constants[61]
    constants[136] = constants[67]*constants[79]
    constants[137] = constants[68]
    constants[138] = ((constants[72]*constants[80])/constants[81])/(1.00000+constants[80]/constants[81])
    constants[139] = custom_piecewise([equal(constants[0] , 1.00000), constants[87]*0.900000 , equal(constants[0] , 2.00000), constants[87]*0.700000 , True, constants[87]])
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[2] = 1.00000/(1.00000+exp((states[0]+87.6100)/7.48800))
    rates[17] = (algebraic[2]-states[17])/constants[44]
    algebraic[3] = 1.00000/(1.00000+exp((states[0]+93.8100)/7.48800))
    rates[18] = (algebraic[3]-states[18])/constants[96]
    algebraic[0] = 1.00000/(1.00000+exp(-(states[0]+constants[32])/constants[33]))
    algebraic[13] = 1.00000/(constants[36]*exp((states[0]+constants[34])/constants[35])+constants[37]*exp(-(states[0]+constants[38])/constants[39]))
    rates[10] = (algebraic[0]-states[10])/algebraic[13]
    algebraic[1] = 1.00000/(1.00000+exp((states[0]+constants[40])/constants[41]))
    algebraic[14] = 1.00000/(1.43200e-05*exp(-(states[0]+1.19600)/6.28500)+6.14900*exp((states[0]+0.509600)/20.2700))
    rates[11] = (algebraic[1]-states[11])/algebraic[14]
    algebraic[15] = 1.00000/(0.00979400*exp(-(states[0]+17.9500)/28.0500)+0.334300*exp((states[0]+5.73000)/56.6600))
    rates[12] = (algebraic[1]-states[12])/algebraic[15]
    algebraic[4] = 1.00000/(1.00000+exp(-(states[0]-14.3400)/14.8200))
    algebraic[17] = 1.05150/(1.00000/(1.20890*(1.00000+exp(-(states[0]-18.4099)/29.3814)))+3.50000/(1.00000+exp((states[0]+100.000)/29.3814)))
    rates[19] = (algebraic[4]-states[19])/algebraic[17]
    algebraic[6] = 1.00000/(1.00000+exp(-(states[0]+3.94000)/4.23000))
    algebraic[21] = 0.600000+1.00000/(exp(-0.0500000*(states[0]+6.00000))+exp(0.0900000*(states[0]+14.0000)))
    rates[25] = (algebraic[6]-states[25])/algebraic[21]
    algebraic[7] = 1.00000/(1.00000+exp((states[0]+19.5800)/3.69600))
    algebraic[22] = 7.00000+1.00000/(0.00450000*exp(-(states[0]+20.0000)/10.0000)+0.00450000*exp((states[0]+20.0000)/10.0000))
    rates[26] = (algebraic[7]-states[26])/algebraic[22]
    algebraic[23] = 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[27] = (algebraic[7]-states[27])/algebraic[23]
    algebraic[19] = algebraic[7]
    rates[30] = (algebraic[19]-states[30])/constants[101]
    algebraic[8] = states[30]*1.00000
    algebraic[20] = 1.00000/(constants[48]/algebraic[8]+power(1.00000+constants[47]/states[2], 4.00000))
    rates[33] = algebraic[20]*constants[48]-states[33]*algebraic[8]
    algebraic[9] = 1.00000/(1.00000+exp(-(states[0]+8.33700)/6.78900))
    algebraic[24] = 12.9800+1.00000/(0.365200*exp((states[0]-31.6600)/3.86900)+4.12300e-05*exp(-(states[0]-47.7800)/20.3800))
    rates[34] = (algebraic[9]-states[34])/algebraic[24]
    algebraic[25] = 1.86500+1.00000/(0.0662900*exp((states[0]-34.7000)/7.35500)+1.12800e-05*exp(-(states[0]-29.7400)/25.9400))
    rates[35] = (algebraic[9]-states[35])/algebraic[25]
    algebraic[10] = 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[36] = (algebraic[10]-states[36])/algebraic[27]
    algebraic[11] = 1.00000/(1.00000+exp(-(states[0]+2.55380*constants[3]+144.590)/(1.56920*constants[3]+3.81150)))
    algebraic[28] = 122.200/(exp(-(states[0]+127.200)/20.3600)+exp((states[0]+236.800)/69.3300))
    rates[38] = (algebraic[11]-states[38])/algebraic[28]
    algebraic[16] = algebraic[1]
    algebraic[30] = 2.03800+1.00000/(0.0213600*exp(-(states[0]+100.600)/8.28100)+0.305200*exp((states[0]+0.994100)/38.4500))
    rates[13] = (algebraic[16]-states[13])/algebraic[30]
    algebraic[34] = 1.00000/(1.00000+exp(-(states[0]-24.3400)/14.8200))
    rates[22] = (algebraic[34]-states[22])/algebraic[17]
    algebraic[35] = 7.00000+1.00000/(0.0400000*exp(-(states[0]-4.00000)/7.00000)+0.0400000*exp((states[0]-4.00000)/7.00000))
    rates[28] = (algebraic[19]-states[28])/algebraic[35]
    algebraic[36] = 100.000+1.00000/(0.000120000*exp(-states[0]/3.00000)+0.000120000*exp(states[0]/7.00000))
    rates[29] = (algebraic[19]-states[29])/algebraic[36]
    algebraic[37] = 2.50000*algebraic[22]
    rates[31] = (algebraic[7]-states[31])/algebraic[37]
    algebraic[26] = algebraic[10]
    algebraic[38] = 1.00000/(0.0100000*exp((states[0]-50.0000)/20.0000)+0.0193000*exp(-(states[0]+66.5400)/31.0000))
    rates[37] = (algebraic[26]-states[37])/algebraic[38]
    algebraic[45] = (constants[18]*(1.00000-states[1]))/(1.00000+constants[19]/states[2])
    rates[1] = constants[16]*algebraic[45]*(algebraic[45]+states[1])-constants[17]*states[1]
    algebraic[31] = 1.00000/(1.00000+exp((states[0]+89.1000)/6.08600))
    algebraic[40] = 3.00000*algebraic[15]
    rates[14] = (algebraic[31]-states[14])/algebraic[40]
    algebraic[41] = 1.46000*algebraic[30]
    rates[15] = (algebraic[16]-states[15])/algebraic[41]
    algebraic[32] = 1.00000/(1.00000+exp(-(states[0]+42.8500)/5.26400))
    algebraic[42] = algebraic[13]
    rates[16] = (algebraic[32]-states[16])/algebraic[42]
    algebraic[44] = 2.50000*algebraic[35]
    rates[32] = (algebraic[19]-states[32])/algebraic[44]
    algebraic[5] = 1.00000/(1.00000+exp((states[0]+43.9400)/5.71100))
    algebraic[18] = custom_piecewise([equal(constants[0] , 1.00000), 1.00000-0.950000/(1.00000+exp((states[0]+70.0000)/5.00000)) , True, 1.00000])
    algebraic[33] = 4.56200+1.00000/(0.393300*exp(-(states[0]+100.000)/100.000)+0.0800400*exp((states[0]+50.0000)/16.5900))
    algebraic[46] = algebraic[33]*algebraic[18]
    rates[20] = (algebraic[5]-states[20])/algebraic[46]
    algebraic[43] = 23.6200+1.00000/(0.00141600*exp(-(states[0]+96.5200)/59.0500)+1.78000e-08*exp((states[0]+114.100)/8.07900))
    algebraic[48] = algebraic[43]*algebraic[18]
    rates[21] = (algebraic[5]-states[21])/algebraic[48]
    algebraic[50] = 1.35400+0.000100000/(exp((states[0]-167.400)/15.8900)+exp(-(states[0]-12.2300)/0.215400))
    algebraic[52] = 1.00000-0.500000/(1.00000+exp((states[0]+70.0000)/20.0000))
    algebraic[54] = algebraic[50]*algebraic[52]*algebraic[46]
    rates[23] = (algebraic[5]-states[23])/algebraic[54]
    algebraic[55] = algebraic[50]*algebraic[52]*algebraic[48]
    rates[24] = (algebraic[5]-states[24])/algebraic[55]
    algebraic[71] = constants[99]*states[26]+constants[110]*states[27]
    algebraic[72] = 0.300000+0.600000/(1.00000+exp((states[0]-10.0000)/10.0000))
    algebraic[73] = 1.00000-algebraic[72]
    algebraic[74] = algebraic[72]*states[28]+algebraic[73]*states[29]
    algebraic[75] = constants[99]*states[31]+constants[110]*states[27]
    algebraic[76] = algebraic[72]*states[32]+algebraic[73]*states[29]
    algebraic[29] = (states[0]*constants[6]*constants[6])/(constants[4]*constants[5])
    algebraic[39] = (states[0]*constants[6])/(constants[4]*constants[5])
    algebraic[77] = (4.00000*algebraic[29]*(states[2]*exp(2.00000*algebraic[39])-0.341000*constants[2]))/(exp(2.00000*algebraic[39])-1.00000)
    algebraic[47] = algebraic[45]+states[1]
    algebraic[80] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[81] = (1.00000-algebraic[80])*constants[100]*algebraic[77]*states[25]*(algebraic[71]*(1.00000-states[33])+states[30]*algebraic[74]*states[33])+algebraic[80]*constants[111]*algebraic[77]*states[25]*(algebraic[75]*(1.00000-states[33])+states[30]*algebraic[76]*states[33])
    algebraic[83] = (constants[107]*-algebraic[81])/(1.00000+1.00000*(power(1.50000/states[8], 8.00000)))
    algebraic[86] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[83]*1.70000 , True, algebraic[83]])
    algebraic[89] = constants[93]/(1.00000+0.0123000/states[8])
    algebraic[92] = custom_piecewise([less(algebraic[89] , 0.00100000), 0.00100000 , True, algebraic[89]])
    rates[39] = (algebraic[86]-states[39])/algebraic[92]
    algebraic[84] = (constants[115]*-algebraic[81])/(1.00000+power(1.50000/states[8], 8.00000))
    algebraic[87] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[84]*1.70000 , True, algebraic[84]])
    algebraic[90] = constants[108]/(1.00000+0.0123000/states[8])
    algebraic[93] = custom_piecewise([less(algebraic[90] , 0.00100000), 0.00100000 , True, algebraic[90]])
    rates[40] = (algebraic[87]-states[40])/algebraic[93]
    algebraic[57] = ((constants[4]*constants[5])/constants[6])*log(constants[3]/states[5])
    algebraic[65] = 1.00000/(1.00000+exp((states[0]-213.600)/151.200))
    algebraic[66] = 1.00000-algebraic[65]
    algebraic[67] = algebraic[65]*states[20]+algebraic[66]*states[21]
    algebraic[68] = algebraic[65]*states[23]+algebraic[66]*states[24]
    algebraic[69] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[70] = constants[98]*(states[0]-algebraic[57])*((1.00000-algebraic[69])*states[19]*algebraic[67]+algebraic[69]*states[22]*algebraic[68])
    algebraic[88] = 1.00000/(1.00000+exp((states[0]+54.8100)/38.2100))
    algebraic[91] = 1.00000-algebraic[88]
    algebraic[94] = algebraic[88]*states[34]+algebraic[91]*states[35]
    algebraic[95] = ((1.00000/(1.00000+exp((states[0]+55.0000)/75.0000)))*1.00000)/(1.00000+exp((states[0]-10.0000)/30.0000))
    algebraic[96] = constants[102]*(power(constants[3]/5.40000, 1.0/2))*algebraic[94]*algebraic[95]*(states[0]-algebraic[57])
    algebraic[58] = ((constants[4]*constants[5])/constants[6])*log((constants[3]+constants[31]*constants[1])/(states[5]+constants[31]*states[3]))
    algebraic[97] = 1.00000+0.600000/(1.00000+power(3.80000e-05/states[9], 1.40000))
    algebraic[98] = constants[103]*algebraic[97]*states[36]*states[37]*(states[0]-algebraic[58])
    algebraic[99] = 1.00000/(1.00000+exp(((states[0]+105.800)-2.60000*constants[3])/9.49300))
    algebraic[100] = constants[104]*(power(constants[3], 1.0/2))*algebraic[99]*states[38]*(states[0]-algebraic[57])
    algebraic[164] = constants[75]*exp(((1.00000-constants[76])*states[0]*constants[6])/(3.00000*constants[4]*constants[5]))
    algebraic[168] = (constants[70]*(power(constants[3]/constants[78], 2.00000)))/((power(1.00000+constants[1]/algebraic[164], 3.00000)+power(1.00000+constants[3]/constants[78], 2.00000))-1.00000)
    algebraic[165] = constants[83]/(1.00000+constants[82]/constants[84]+states[3]/constants[85]+states[5]/constants[86])
    algebraic[169] = (constants[71]*algebraic[165]*constants[82])/(1.00000+constants[80]/constants[81])
    algebraic[163] = constants[74]*exp((constants[76]*states[0]*constants[6])/(3.00000*constants[4]*constants[5]))
    algebraic[166] = (constants[66]*(power(states[3]/algebraic[163], 3.00000)))/((power(1.00000+states[3]/algebraic[163], 3.00000)+power(1.00000+states[5]/constants[77], 2.00000))-1.00000)
    algebraic[167] = (constants[69]*(power(constants[1]/algebraic[164], 3.00000)))/((power(1.00000+constants[1]/algebraic[164], 3.00000)+power(1.00000+constants[3]/constants[78], 2.00000))-1.00000)
    algebraic[170] = (constants[73]*(power(states[5]/constants[77], 2.00000)))/((power(1.00000+states[3]/algebraic[163], 3.00000)+power(1.00000+states[5]/constants[77], 2.00000))-1.00000)
    algebraic[171] = constants[138]*algebraic[166]*constants[137]+algebraic[167]*algebraic[170]*algebraic[169]+constants[137]*algebraic[170]*algebraic[169]+algebraic[169]*algebraic[166]*constants[137]
    algebraic[172] = algebraic[167]*constants[136]*algebraic[170]+algebraic[166]*constants[137]*algebraic[168]+algebraic[168]*constants[136]*algebraic[170]+constants[137]*algebraic[168]*algebraic[170]
    algebraic[173] = constants[137]*algebraic[168]*constants[138]+algebraic[169]*algebraic[167]*constants[136]+algebraic[167]*constants[136]*constants[138]+algebraic[168]*constants[138]*constants[136]
    algebraic[174] = algebraic[170]*algebraic[169]*algebraic[167]+algebraic[168]*constants[138]*algebraic[166]+algebraic[167]*constants[138]*algebraic[166]+algebraic[169]*algebraic[167]*algebraic[166]
    algebraic[175] = algebraic[171]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[176] = algebraic[172]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[179] = 3.00000*(algebraic[175]*algebraic[168]-algebraic[176]*algebraic[169])
    algebraic[177] = algebraic[173]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[178] = algebraic[174]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[180] = 2.00000*(algebraic[178]*constants[136]-algebraic[177]*algebraic[166])
    algebraic[181] = constants[139]*(constants[7]*algebraic[179]+constants[9]*algebraic[180])
    algebraic[182] = 1.00000/(1.00000+exp(-(states[0]-14.4800)/18.3400))
    algebraic[183] = constants[106]*algebraic[182]*(states[0]-algebraic[57])
    algebraic[12] = custom_piecewise([greater(voi , constants[14]) & less_equal(voi , constants[14]+constants[13]), constants[12] , True, 0.00000])
    algebraic[185] = (states[6]-states[5])/2.00000
    rates[5] = (-((algebraic[70]+algebraic[96]+algebraic[98]+algebraic[100]+algebraic[183]+algebraic[12])-2.00000*algebraic[181])*constants[30]*constants[118])/(constants[6]*constants[119])+(algebraic[185]*constants[122])/constants[119]
    algebraic[79] = (1.00000*algebraic[29]*(0.750000*states[6]*exp(1.00000*algebraic[39])-0.750000*constants[3]))/(exp(1.00000*algebraic[39])-1.00000)
    algebraic[85] = (1.00000-algebraic[80])*constants[113]*algebraic[79]*states[25]*(algebraic[71]*(1.00000-states[33])+states[30]*algebraic[74]*states[33])+algebraic[80]*constants[117]*algebraic[79]*states[25]*(algebraic[75]*(1.00000-states[33])+states[30]*algebraic[76]*states[33])
    rates[6] = (-algebraic[85]*constants[30]*constants[118])/(constants[6]*constants[122])-algebraic[185]
    algebraic[56] = ((constants[4]*constants[5])/constants[6])*log(constants[1]/states[3])
    algebraic[59] = constants[42]*states[11]+constants[95]*states[12]
    algebraic[60] = constants[42]*states[11]+constants[95]*states[14]
    algebraic[61] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[62] = constants[43]*(states[0]-algebraic[56])*(power(states[10], 3.00000))*((1.00000-algebraic[61])*algebraic[59]*states[13]+algebraic[61]*algebraic[60]*states[15])
    algebraic[63] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[64] = constants[97]*(states[0]-algebraic[56])*states[16]*((1.00000-algebraic[63])*states[17]+algebraic[63]*states[18])
    algebraic[129] = 1.00000/(1.00000+power(constants[64]/states[9], 2.00000))
    algebraic[102] = exp((constants[62]*states[0]*constants[6])/(constants[4]*constants[5]))
    algebraic[109] = 1.00000+(constants[1]/constants[55])*(1.00000+1.00000/algebraic[102])
    algebraic[110] = constants[1]/(constants[55]*algebraic[102]*algebraic[109])
    algebraic[113] = algebraic[110]*constants[59]
    algebraic[103] = 1.00000+(states[3]/constants[55])*(1.00000+algebraic[102])
    algebraic[104] = (states[3]*algebraic[102])/(constants[55]*algebraic[103])
    algebraic[116] = algebraic[104]*constants[59]
    algebraic[106] = 1.00000+(states[3]/constants[53])*(1.00000+states[3]/constants[54])
    algebraic[107] = (states[3]*states[3])/(algebraic[106]*constants[53]*constants[54])
    algebraic[119] = algebraic[107]*algebraic[104]*constants[57]
    algebraic[120] = algebraic[110]*constants[124]*constants[57]
    algebraic[111] = 1.00000/algebraic[109]
    algebraic[112] = algebraic[111]*constants[58]
    algebraic[114] = algebraic[112]+algebraic[113]
    algebraic[101] = exp((constants[63]*states[0]*constants[6])/(constants[4]*constants[5]))
    algebraic[105] = 1.00000/algebraic[103]
    algebraic[115] = (algebraic[105]*constants[58])/algebraic[101]
    algebraic[117] = algebraic[115]+algebraic[116]
    algebraic[108] = 1.00000/algebraic[106]
    algebraic[118] = algebraic[108]*states[9]*constants[60]
    algebraic[121] = constants[127]*algebraic[117]*(algebraic[119]+algebraic[118])+constants[128]*algebraic[119]*(constants[127]+algebraic[114])
    algebraic[122] = constants[126]*algebraic[119]*(algebraic[117]+constants[128])+algebraic[117]*algebraic[118]*(constants[126]+algebraic[120])
    algebraic[123] = constants[126]*algebraic[114]*(algebraic[119]+algebraic[118])+algebraic[120]*algebraic[118]*(constants[127]+algebraic[114])
    algebraic[124] = constants[127]*algebraic[120]*(algebraic[117]+constants[128])+algebraic[114]*constants[128]*(constants[126]+algebraic[120])
    algebraic[125] = algebraic[121]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[126] = algebraic[122]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[127] = algebraic[123]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[128] = algebraic[124]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[130] = (3.00000*(algebraic[128]*algebraic[119]-algebraic[125]*algebraic[120])+algebraic[127]*algebraic[116])-algebraic[126]*algebraic[113]
    algebraic[131] = algebraic[126]*constants[127]-algebraic[125]*constants[126]
    algebraic[132] = 0.800000*constants[129]*algebraic[129]*(constants[7]*algebraic[130]+constants[8]*algebraic[131])
    algebraic[184] = (constants[89]*algebraic[29]*(states[3]*exp(algebraic[39])-constants[1]))/(exp(algebraic[39])-1.00000)
    algebraic[187] = (states[4]-states[3])/2.00000
    rates[3] = (-(algebraic[62]+algebraic[64]+3.00000*algebraic[132]+3.00000*algebraic[181]+algebraic[184])*constants[118]*constants[30])/(constants[6]*constants[119])+(algebraic[187]*constants[122])/constants[119]
    algebraic[78] = (1.00000*algebraic[29]*(0.750000*states[4]*exp(1.00000*algebraic[39])-0.750000*constants[1]))/(exp(1.00000*algebraic[39])-1.00000)
    algebraic[82] = (1.00000-algebraic[80])*constants[112]*algebraic[78]*states[25]*(algebraic[71]*(1.00000-states[33])+states[30]*algebraic[74]*states[33])+algebraic[80]*constants[116]*algebraic[78]*states[25]*(algebraic[75]*(1.00000-states[33])+states[30]*algebraic[76]*states[33])
    algebraic[159] = 1.00000/(1.00000+power(constants[64]/states[2], 2.00000))
    algebraic[139] = 1.00000+(constants[1]/constants[55])*(1.00000+1.00000/algebraic[102])
    algebraic[140] = constants[1]/(constants[55]*algebraic[102]*algebraic[139])
    algebraic[143] = algebraic[140]*constants[59]
    algebraic[133] = 1.00000+(states[4]/constants[55])*(1.00000+algebraic[102])
    algebraic[134] = (states[4]*algebraic[102])/(constants[55]*algebraic[133])
    algebraic[146] = algebraic[134]*constants[59]
    algebraic[136] = 1.00000+(states[4]/constants[53])*(1.00000+states[4]/constants[54])
    algebraic[137] = (states[4]*states[4])/(algebraic[136]*constants[53]*constants[54])
    algebraic[149] = algebraic[137]*algebraic[134]*constants[57]
    algebraic[150] = algebraic[140]*constants[131]*constants[57]
    algebraic[141] = 1.00000/algebraic[139]
    algebraic[142] = algebraic[141]*constants[58]
    algebraic[144] = algebraic[142]+algebraic[143]
    algebraic[135] = 1.00000/algebraic[133]
    algebraic[145] = (algebraic[135]*constants[58])/algebraic[101]
    algebraic[147] = algebraic[145]+algebraic[146]
    algebraic[138] = 1.00000/algebraic[136]
    algebraic[148] = algebraic[138]*states[2]*constants[60]
    algebraic[151] = constants[134]*algebraic[147]*(algebraic[149]+algebraic[148])+constants[135]*algebraic[149]*(constants[134]+algebraic[144])
    algebraic[152] = constants[133]*algebraic[149]*(algebraic[147]+constants[135])+algebraic[147]*algebraic[148]*(constants[133]+algebraic[150])
    algebraic[153] = constants[133]*algebraic[144]*(algebraic[149]+algebraic[148])+algebraic[150]*algebraic[148]*(constants[134]+algebraic[144])
    algebraic[154] = constants[134]*algebraic[150]*(algebraic[147]+constants[135])+algebraic[144]*constants[135]*(constants[133]+algebraic[150])
    algebraic[155] = algebraic[151]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[156] = algebraic[152]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[157] = algebraic[153]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[158] = algebraic[154]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[160] = (3.00000*(algebraic[158]*algebraic[149]-algebraic[155]*algebraic[150])+algebraic[157]*algebraic[146])-algebraic[156]*algebraic[143]
    algebraic[161] = algebraic[156]*constants[134]-algebraic[155]*constants[133]
    algebraic[162] = 0.200000*constants[129]*algebraic[159]*(constants[7]*algebraic[160]+constants[8]*algebraic[161])
    rates[4] = (-(algebraic[82]+3.00000*algebraic[162])*constants[30]*constants[118])/(constants[6]*constants[122])-algebraic[187]
    algebraic[188] = (constants[91]*states[9])/(constants[92]+states[9])
    algebraic[186] = (constants[90]*4.00000*algebraic[29]*(states[9]*exp(2.00000*algebraic[39])-0.341000*constants[2]))/(exp(2.00000*algebraic[39])-1.00000)
    rates[0] = -(algebraic[62]+algebraic[64]+algebraic[70]+algebraic[81]+algebraic[82]+algebraic[85]+algebraic[96]+algebraic[98]+algebraic[100]+algebraic[132]+algebraic[162]+algebraic[181]+algebraic[184]+algebraic[183]+algebraic[188]+algebraic[186]+algebraic[12])
    algebraic[189] = (states[2]-states[9])/0.200000
    algebraic[190] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[191] = (1.00000-algebraic[190])*states[39]+algebraic[190]*states[40]
    algebraic[51] = 1.00000/(1.00000+(constants[24]*constants[25])/(power(constants[25]+states[2], 2.00000))+(constants[26]*constants[27])/(power(constants[27]+states[2], 2.00000)))
    rates[2] = algebraic[51]*(((-(algebraic[81]-2.00000*algebraic[162])*constants[30]*constants[118])/(2.00000*constants[6]*constants[122])+(algebraic[191]*constants[121])/constants[122])-algebraic[189])
    algebraic[192] = (constants[109]*0.00437500*states[9])/(states[9]+0.000920000)
    algebraic[193] = (constants[109]*2.75000*0.00437500*states[9])/((states[9]+0.000920000)-0.000170000)
    algebraic[194] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[195] = (0.00393750*states[7])/15.0000
    algebraic[196] = ((1.00000-algebraic[194])*algebraic[192]+algebraic[194]*algebraic[193])-algebraic[195]
    algebraic[49] = 1.00000/(1.00000+(constants[94]*constants[21])/(power(constants[21]+states[9], 2.00000))+(constants[22]*constants[23])/(power(constants[23]+states[9], 2.00000)))
    rates[9] = algebraic[49]*(((-((algebraic[188]+algebraic[186])-2.00000*algebraic[132])*constants[30]*constants[118])/(2.00000*constants[6]*constants[119])-(algebraic[196]*constants[120])/constants[119])+(algebraic[189]*constants[122])/constants[119])
    algebraic[197] = (states[7]-states[8])/100.000
    rates[7] = algebraic[196]-(algebraic[197]*constants[121])/constants[120]
    algebraic[53] = 1.00000/(1.00000+(constants[28]*constants[29])/(power(constants[29]+states[8], 2.00000)))
    rates[8] = algebraic[53]*(algebraic[197]-algebraic[191])
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[2] = 1.00000/(1.00000+exp((states[0]+87.6100)/7.48800))
    algebraic[3] = 1.00000/(1.00000+exp((states[0]+93.8100)/7.48800))
    algebraic[0] = 1.00000/(1.00000+exp(-(states[0]+constants[32])/constants[33]))
    algebraic[13] = 1.00000/(constants[36]*exp((states[0]+constants[34])/constants[35])+constants[37]*exp(-(states[0]+constants[38])/constants[39]))
    algebraic[1] = 1.00000/(1.00000+exp((states[0]+constants[40])/constants[41]))
    algebraic[14] = 1.00000/(1.43200e-05*exp(-(states[0]+1.19600)/6.28500)+6.14900*exp((states[0]+0.509600)/20.2700))
    algebraic[15] = 1.00000/(0.00979400*exp(-(states[0]+17.9500)/28.0500)+0.334300*exp((states[0]+5.73000)/56.6600))
    algebraic[4] = 1.00000/(1.00000+exp(-(states[0]-14.3400)/14.8200))
    algebraic[17] = 1.05150/(1.00000/(1.20890*(1.00000+exp(-(states[0]-18.4099)/29.3814)))+3.50000/(1.00000+exp((states[0]+100.000)/29.3814)))
    algebraic[6] = 1.00000/(1.00000+exp(-(states[0]+3.94000)/4.23000))
    algebraic[21] = 0.600000+1.00000/(exp(-0.0500000*(states[0]+6.00000))+exp(0.0900000*(states[0]+14.0000)))
    algebraic[7] = 1.00000/(1.00000+exp((states[0]+19.5800)/3.69600))
    algebraic[22] = 7.00000+1.00000/(0.00450000*exp(-(states[0]+20.0000)/10.0000)+0.00450000*exp((states[0]+20.0000)/10.0000))
    algebraic[23] = 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[19] = algebraic[7]
    algebraic[8] = states[30]*1.00000
    algebraic[20] = 1.00000/(constants[48]/algebraic[8]+power(1.00000+constants[47]/states[2], 4.00000))
    algebraic[9] = 1.00000/(1.00000+exp(-(states[0]+8.33700)/6.78900))
    algebraic[24] = 12.9800+1.00000/(0.365200*exp((states[0]-31.6600)/3.86900)+4.12300e-05*exp(-(states[0]-47.7800)/20.3800))
    algebraic[25] = 1.86500+1.00000/(0.0662900*exp((states[0]-34.7000)/7.35500)+1.12800e-05*exp(-(states[0]-29.7400)/25.9400))
    algebraic[10] = 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[11] = 1.00000/(1.00000+exp(-(states[0]+2.55380*constants[3]+144.590)/(1.56920*constants[3]+3.81150)))
    algebraic[28] = 122.200/(exp(-(states[0]+127.200)/20.3600)+exp((states[0]+236.800)/69.3300))
    algebraic[16] = algebraic[1]
    algebraic[30] = 2.03800+1.00000/(0.0213600*exp(-(states[0]+100.600)/8.28100)+0.305200*exp((states[0]+0.994100)/38.4500))
    algebraic[34] = 1.00000/(1.00000+exp(-(states[0]-24.3400)/14.8200))
    algebraic[35] = 7.00000+1.00000/(0.0400000*exp(-(states[0]-4.00000)/7.00000)+0.0400000*exp((states[0]-4.00000)/7.00000))
    algebraic[36] = 100.000+1.00000/(0.000120000*exp(-states[0]/3.00000)+0.000120000*exp(states[0]/7.00000))
    algebraic[37] = 2.50000*algebraic[22]
    algebraic[26] = algebraic[10]
    algebraic[38] = 1.00000/(0.0100000*exp((states[0]-50.0000)/20.0000)+0.0193000*exp(-(states[0]+66.5400)/31.0000))
    algebraic[45] = (constants[18]*(1.00000-states[1]))/(1.00000+constants[19]/states[2])
    algebraic[31] = 1.00000/(1.00000+exp((states[0]+89.1000)/6.08600))
    algebraic[40] = 3.00000*algebraic[15]
    algebraic[41] = 1.46000*algebraic[30]
    algebraic[32] = 1.00000/(1.00000+exp(-(states[0]+42.8500)/5.26400))
    algebraic[42] = algebraic[13]
    algebraic[44] = 2.50000*algebraic[35]
    algebraic[5] = 1.00000/(1.00000+exp((states[0]+43.9400)/5.71100))
    algebraic[18] = custom_piecewise([equal(constants[0] , 1.00000), 1.00000-0.950000/(1.00000+exp((states[0]+70.0000)/5.00000)) , True, 1.00000])
    algebraic[33] = 4.56200+1.00000/(0.393300*exp(-(states[0]+100.000)/100.000)+0.0800400*exp((states[0]+50.0000)/16.5900))
    algebraic[46] = algebraic[33]*algebraic[18]
    algebraic[43] = 23.6200+1.00000/(0.00141600*exp(-(states[0]+96.5200)/59.0500)+1.78000e-08*exp((states[0]+114.100)/8.07900))
    algebraic[48] = algebraic[43]*algebraic[18]
    algebraic[50] = 1.35400+0.000100000/(exp((states[0]-167.400)/15.8900)+exp(-(states[0]-12.2300)/0.215400))
    algebraic[52] = 1.00000-0.500000/(1.00000+exp((states[0]+70.0000)/20.0000))
    algebraic[54] = algebraic[50]*algebraic[52]*algebraic[46]
    algebraic[55] = algebraic[50]*algebraic[52]*algebraic[48]
    algebraic[71] = constants[99]*states[26]+constants[110]*states[27]
    algebraic[72] = 0.300000+0.600000/(1.00000+exp((states[0]-10.0000)/10.0000))
    algebraic[73] = 1.00000-algebraic[72]
    algebraic[74] = algebraic[72]*states[28]+algebraic[73]*states[29]
    algebraic[75] = constants[99]*states[31]+constants[110]*states[27]
    algebraic[76] = algebraic[72]*states[32]+algebraic[73]*states[29]
    algebraic[29] = (states[0]*constants[6]*constants[6])/(constants[4]*constants[5])
    algebraic[39] = (states[0]*constants[6])/(constants[4]*constants[5])
    algebraic[77] = (4.00000*algebraic[29]*(states[2]*exp(2.00000*algebraic[39])-0.341000*constants[2]))/(exp(2.00000*algebraic[39])-1.00000)
    algebraic[47] = algebraic[45]+states[1]
    algebraic[80] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[81] = (1.00000-algebraic[80])*constants[100]*algebraic[77]*states[25]*(algebraic[71]*(1.00000-states[33])+states[30]*algebraic[74]*states[33])+algebraic[80]*constants[111]*algebraic[77]*states[25]*(algebraic[75]*(1.00000-states[33])+states[30]*algebraic[76]*states[33])
    algebraic[83] = (constants[107]*-algebraic[81])/(1.00000+1.00000*(power(1.50000/states[8], 8.00000)))
    algebraic[86] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[83]*1.70000 , True, algebraic[83]])
    algebraic[89] = constants[93]/(1.00000+0.0123000/states[8])
    algebraic[92] = custom_piecewise([less(algebraic[89] , 0.00100000), 0.00100000 , True, algebraic[89]])
    algebraic[84] = (constants[115]*-algebraic[81])/(1.00000+power(1.50000/states[8], 8.00000))
    algebraic[87] = custom_piecewise([equal(constants[0] , 2.00000), algebraic[84]*1.70000 , True, algebraic[84]])
    algebraic[90] = constants[108]/(1.00000+0.0123000/states[8])
    algebraic[93] = custom_piecewise([less(algebraic[90] , 0.00100000), 0.00100000 , True, algebraic[90]])
    algebraic[57] = ((constants[4]*constants[5])/constants[6])*log(constants[3]/states[5])
    algebraic[65] = 1.00000/(1.00000+exp((states[0]-213.600)/151.200))
    algebraic[66] = 1.00000-algebraic[65]
    algebraic[67] = algebraic[65]*states[20]+algebraic[66]*states[21]
    algebraic[68] = algebraic[65]*states[23]+algebraic[66]*states[24]
    algebraic[69] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[70] = constants[98]*(states[0]-algebraic[57])*((1.00000-algebraic[69])*states[19]*algebraic[67]+algebraic[69]*states[22]*algebraic[68])
    algebraic[88] = 1.00000/(1.00000+exp((states[0]+54.8100)/38.2100))
    algebraic[91] = 1.00000-algebraic[88]
    algebraic[94] = algebraic[88]*states[34]+algebraic[91]*states[35]
    algebraic[95] = ((1.00000/(1.00000+exp((states[0]+55.0000)/75.0000)))*1.00000)/(1.00000+exp((states[0]-10.0000)/30.0000))
    algebraic[96] = constants[102]*(power(constants[3]/5.40000, 1.0/2))*algebraic[94]*algebraic[95]*(states[0]-algebraic[57])
    algebraic[58] = ((constants[4]*constants[5])/constants[6])*log((constants[3]+constants[31]*constants[1])/(states[5]+constants[31]*states[3]))
    algebraic[97] = 1.00000+0.600000/(1.00000+power(3.80000e-05/states[9], 1.40000))
    algebraic[98] = constants[103]*algebraic[97]*states[36]*states[37]*(states[0]-algebraic[58])
    algebraic[99] = 1.00000/(1.00000+exp(((states[0]+105.800)-2.60000*constants[3])/9.49300))
    algebraic[100] = constants[104]*(power(constants[3], 1.0/2))*algebraic[99]*states[38]*(states[0]-algebraic[57])
    algebraic[164] = constants[75]*exp(((1.00000-constants[76])*states[0]*constants[6])/(3.00000*constants[4]*constants[5]))
    algebraic[168] = (constants[70]*(power(constants[3]/constants[78], 2.00000)))/((power(1.00000+constants[1]/algebraic[164], 3.00000)+power(1.00000+constants[3]/constants[78], 2.00000))-1.00000)
    algebraic[165] = constants[83]/(1.00000+constants[82]/constants[84]+states[3]/constants[85]+states[5]/constants[86])
    algebraic[169] = (constants[71]*algebraic[165]*constants[82])/(1.00000+constants[80]/constants[81])
    algebraic[163] = constants[74]*exp((constants[76]*states[0]*constants[6])/(3.00000*constants[4]*constants[5]))
    algebraic[166] = (constants[66]*(power(states[3]/algebraic[163], 3.00000)))/((power(1.00000+states[3]/algebraic[163], 3.00000)+power(1.00000+states[5]/constants[77], 2.00000))-1.00000)
    algebraic[167] = (constants[69]*(power(constants[1]/algebraic[164], 3.00000)))/((power(1.00000+constants[1]/algebraic[164], 3.00000)+power(1.00000+constants[3]/constants[78], 2.00000))-1.00000)
    algebraic[170] = (constants[73]*(power(states[5]/constants[77], 2.00000)))/((power(1.00000+states[3]/algebraic[163], 3.00000)+power(1.00000+states[5]/constants[77], 2.00000))-1.00000)
    algebraic[171] = constants[138]*algebraic[166]*constants[137]+algebraic[167]*algebraic[170]*algebraic[169]+constants[137]*algebraic[170]*algebraic[169]+algebraic[169]*algebraic[166]*constants[137]
    algebraic[172] = algebraic[167]*constants[136]*algebraic[170]+algebraic[166]*constants[137]*algebraic[168]+algebraic[168]*constants[136]*algebraic[170]+constants[137]*algebraic[168]*algebraic[170]
    algebraic[173] = constants[137]*algebraic[168]*constants[138]+algebraic[169]*algebraic[167]*constants[136]+algebraic[167]*constants[136]*constants[138]+algebraic[168]*constants[138]*constants[136]
    algebraic[174] = algebraic[170]*algebraic[169]*algebraic[167]+algebraic[168]*constants[138]*algebraic[166]+algebraic[167]*constants[138]*algebraic[166]+algebraic[169]*algebraic[167]*algebraic[166]
    algebraic[175] = algebraic[171]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[176] = algebraic[172]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[179] = 3.00000*(algebraic[175]*algebraic[168]-algebraic[176]*algebraic[169])
    algebraic[177] = algebraic[173]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[178] = algebraic[174]/(algebraic[171]+algebraic[172]+algebraic[173]+algebraic[174])
    algebraic[180] = 2.00000*(algebraic[178]*constants[136]-algebraic[177]*algebraic[166])
    algebraic[181] = constants[139]*(constants[7]*algebraic[179]+constants[9]*algebraic[180])
    algebraic[182] = 1.00000/(1.00000+exp(-(states[0]-14.4800)/18.3400))
    algebraic[183] = constants[106]*algebraic[182]*(states[0]-algebraic[57])
    algebraic[12] = custom_piecewise([greater(voi , constants[14]) & less_equal(voi , constants[14]+constants[13]), constants[12] , True, 0.00000])
    algebraic[185] = (states[6]-states[5])/2.00000
    algebraic[79] = (1.00000*algebraic[29]*(0.750000*states[6]*exp(1.00000*algebraic[39])-0.750000*constants[3]))/(exp(1.00000*algebraic[39])-1.00000)
    algebraic[85] = (1.00000-algebraic[80])*constants[113]*algebraic[79]*states[25]*(algebraic[71]*(1.00000-states[33])+states[30]*algebraic[74]*states[33])+algebraic[80]*constants[117]*algebraic[79]*states[25]*(algebraic[75]*(1.00000-states[33])+states[30]*algebraic[76]*states[33])
    algebraic[56] = ((constants[4]*constants[5])/constants[6])*log(constants[1]/states[3])
    algebraic[59] = constants[42]*states[11]+constants[95]*states[12]
    algebraic[60] = constants[42]*states[11]+constants[95]*states[14]
    algebraic[61] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[62] = constants[43]*(states[0]-algebraic[56])*(power(states[10], 3.00000))*((1.00000-algebraic[61])*algebraic[59]*states[13]+algebraic[61]*algebraic[60]*states[15])
    algebraic[63] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[64] = constants[97]*(states[0]-algebraic[56])*states[16]*((1.00000-algebraic[63])*states[17]+algebraic[63]*states[18])
    algebraic[129] = 1.00000/(1.00000+power(constants[64]/states[9], 2.00000))
    algebraic[102] = exp((constants[62]*states[0]*constants[6])/(constants[4]*constants[5]))
    algebraic[109] = 1.00000+(constants[1]/constants[55])*(1.00000+1.00000/algebraic[102])
    algebraic[110] = constants[1]/(constants[55]*algebraic[102]*algebraic[109])
    algebraic[113] = algebraic[110]*constants[59]
    algebraic[103] = 1.00000+(states[3]/constants[55])*(1.00000+algebraic[102])
    algebraic[104] = (states[3]*algebraic[102])/(constants[55]*algebraic[103])
    algebraic[116] = algebraic[104]*constants[59]
    algebraic[106] = 1.00000+(states[3]/constants[53])*(1.00000+states[3]/constants[54])
    algebraic[107] = (states[3]*states[3])/(algebraic[106]*constants[53]*constants[54])
    algebraic[119] = algebraic[107]*algebraic[104]*constants[57]
    algebraic[120] = algebraic[110]*constants[124]*constants[57]
    algebraic[111] = 1.00000/algebraic[109]
    algebraic[112] = algebraic[111]*constants[58]
    algebraic[114] = algebraic[112]+algebraic[113]
    algebraic[101] = exp((constants[63]*states[0]*constants[6])/(constants[4]*constants[5]))
    algebraic[105] = 1.00000/algebraic[103]
    algebraic[115] = (algebraic[105]*constants[58])/algebraic[101]
    algebraic[117] = algebraic[115]+algebraic[116]
    algebraic[108] = 1.00000/algebraic[106]
    algebraic[118] = algebraic[108]*states[9]*constants[60]
    algebraic[121] = constants[127]*algebraic[117]*(algebraic[119]+algebraic[118])+constants[128]*algebraic[119]*(constants[127]+algebraic[114])
    algebraic[122] = constants[126]*algebraic[119]*(algebraic[117]+constants[128])+algebraic[117]*algebraic[118]*(constants[126]+algebraic[120])
    algebraic[123] = constants[126]*algebraic[114]*(algebraic[119]+algebraic[118])+algebraic[120]*algebraic[118]*(constants[127]+algebraic[114])
    algebraic[124] = constants[127]*algebraic[120]*(algebraic[117]+constants[128])+algebraic[114]*constants[128]*(constants[126]+algebraic[120])
    algebraic[125] = algebraic[121]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[126] = algebraic[122]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[127] = algebraic[123]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[128] = algebraic[124]/(algebraic[121]+algebraic[122]+algebraic[123]+algebraic[124])
    algebraic[130] = (3.00000*(algebraic[128]*algebraic[119]-algebraic[125]*algebraic[120])+algebraic[127]*algebraic[116])-algebraic[126]*algebraic[113]
    algebraic[131] = algebraic[126]*constants[127]-algebraic[125]*constants[126]
    algebraic[132] = 0.800000*constants[129]*algebraic[129]*(constants[7]*algebraic[130]+constants[8]*algebraic[131])
    algebraic[184] = (constants[89]*algebraic[29]*(states[3]*exp(algebraic[39])-constants[1]))/(exp(algebraic[39])-1.00000)
    algebraic[187] = (states[4]-states[3])/2.00000
    algebraic[78] = (1.00000*algebraic[29]*(0.750000*states[4]*exp(1.00000*algebraic[39])-0.750000*constants[1]))/(exp(1.00000*algebraic[39])-1.00000)
    algebraic[82] = (1.00000-algebraic[80])*constants[112]*algebraic[78]*states[25]*(algebraic[71]*(1.00000-states[33])+states[30]*algebraic[74]*states[33])+algebraic[80]*constants[116]*algebraic[78]*states[25]*(algebraic[75]*(1.00000-states[33])+states[30]*algebraic[76]*states[33])
    algebraic[159] = 1.00000/(1.00000+power(constants[64]/states[2], 2.00000))
    algebraic[139] = 1.00000+(constants[1]/constants[55])*(1.00000+1.00000/algebraic[102])
    algebraic[140] = constants[1]/(constants[55]*algebraic[102]*algebraic[139])
    algebraic[143] = algebraic[140]*constants[59]
    algebraic[133] = 1.00000+(states[4]/constants[55])*(1.00000+algebraic[102])
    algebraic[134] = (states[4]*algebraic[102])/(constants[55]*algebraic[133])
    algebraic[146] = algebraic[134]*constants[59]
    algebraic[136] = 1.00000+(states[4]/constants[53])*(1.00000+states[4]/constants[54])
    algebraic[137] = (states[4]*states[4])/(algebraic[136]*constants[53]*constants[54])
    algebraic[149] = algebraic[137]*algebraic[134]*constants[57]
    algebraic[150] = algebraic[140]*constants[131]*constants[57]
    algebraic[141] = 1.00000/algebraic[139]
    algebraic[142] = algebraic[141]*constants[58]
    algebraic[144] = algebraic[142]+algebraic[143]
    algebraic[135] = 1.00000/algebraic[133]
    algebraic[145] = (algebraic[135]*constants[58])/algebraic[101]
    algebraic[147] = algebraic[145]+algebraic[146]
    algebraic[138] = 1.00000/algebraic[136]
    algebraic[148] = algebraic[138]*states[2]*constants[60]
    algebraic[151] = constants[134]*algebraic[147]*(algebraic[149]+algebraic[148])+constants[135]*algebraic[149]*(constants[134]+algebraic[144])
    algebraic[152] = constants[133]*algebraic[149]*(algebraic[147]+constants[135])+algebraic[147]*algebraic[148]*(constants[133]+algebraic[150])
    algebraic[153] = constants[133]*algebraic[144]*(algebraic[149]+algebraic[148])+algebraic[150]*algebraic[148]*(constants[134]+algebraic[144])
    algebraic[154] = constants[134]*algebraic[150]*(algebraic[147]+constants[135])+algebraic[144]*constants[135]*(constants[133]+algebraic[150])
    algebraic[155] = algebraic[151]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[156] = algebraic[152]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[157] = algebraic[153]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[158] = algebraic[154]/(algebraic[151]+algebraic[152]+algebraic[153]+algebraic[154])
    algebraic[160] = (3.00000*(algebraic[158]*algebraic[149]-algebraic[155]*algebraic[150])+algebraic[157]*algebraic[146])-algebraic[156]*algebraic[143]
    algebraic[161] = algebraic[156]*constants[134]-algebraic[155]*constants[133]
    algebraic[162] = 0.200000*constants[129]*algebraic[159]*(constants[7]*algebraic[160]+constants[8]*algebraic[161])
    algebraic[188] = (constants[91]*states[9])/(constants[92]+states[9])
    algebraic[186] = (constants[90]*4.00000*algebraic[29]*(states[9]*exp(2.00000*algebraic[39])-0.341000*constants[2]))/(exp(2.00000*algebraic[39])-1.00000)
    algebraic[189] = (states[2]-states[9])/0.200000
    algebraic[190] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[191] = (1.00000-algebraic[190])*states[39]+algebraic[190]*states[40]
    algebraic[51] = 1.00000/(1.00000+(constants[24]*constants[25])/(power(constants[25]+states[2], 2.00000))+(constants[26]*constants[27])/(power(constants[27]+states[2], 2.00000)))
    algebraic[192] = (constants[109]*0.00437500*states[9])/(states[9]+0.000920000)
    algebraic[193] = (constants[109]*2.75000*0.00437500*states[9])/((states[9]+0.000920000)-0.000170000)
    algebraic[194] = 1.00000/(1.00000+constants[15]/algebraic[47])
    algebraic[195] = (0.00393750*states[7])/15.0000
    algebraic[196] = ((1.00000-algebraic[194])*algebraic[192]+algebraic[194]*algebraic[193])-algebraic[195]
    algebraic[49] = 1.00000/(1.00000+(constants[94]*constants[21])/(power(constants[21]+states[9], 2.00000))+(constants[22]*constants[23])/(power(constants[23]+states[9], 2.00000)))
    algebraic[197] = (states[7]-states[8])/100.000
    algebraic[53] = 1.00000/(1.00000+(constants[28]*constants[29])/(power(constants[29]+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)