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 = 105
sizeStates = 45
sizeConstants = 154
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 (second)"
    legend_algebraic[33] = "JCaM_DYAD_SL in component JCaM_DYAD_SL (flux)"
    legend_constants[0] = "k0B_on in component JCaM_DYAD_SL (second_order_rate_constant)"
    legend_constants[1] = "k0B_off in component JCaM_DYAD_SL (first_order_rate_constant)"
    legend_states[0] = "CaM in component CaM (micromolar)"
    legend_algebraic[30] = "B in component B (micromolar)"
    legend_states[1] = "CaM in component CaM (micromolar)"
    legend_algebraic[34] = "JCa2CaM_DYAD_SL in component JCa2CaM_DYAD_SL (flux)"
    legend_constants[2] = "k2B_on in component JCa2CaM_DYAD_SL (second_order_rate_constant)"
    legend_constants[3] = "k2B_off in component JCa2CaM_DYAD_SL (first_order_rate_constant)"
    legend_states[2] = "Ca2CaM in component Ca2CaM (micromolar)"
    legend_states[3] = "Ca2CaM in component Ca2CaM (micromolar)"
    legend_algebraic[35] = "JCa4CaM_DYAD_SL in component JCa4CaM_DYAD_SL (flux)"
    legend_constants[4] = "k4B_on in component JCa4CaM_DYAD_SL (second_order_rate_constant)"
    legend_constants[5] = "k4B_off in component JCa4CaM_DYAD_SL (first_order_rate_constant)"
    legend_states[4] = "Ca4CaM in component Ca4CaM (micromolar)"
    legend_states[5] = "Ca4CaM in component Ca4CaM (micromolar)"
    legend_algebraic[1] = "JCaM_SL_CYT in component JCaM_SL_CYT (micromole_per_second)"
    legend_constants[6] = "kSLCYT in component model_parameters (litre_per_second)"
    legend_states[6] = "CaM in component CaM (micromolar)"
    legend_algebraic[2] = "JCa2CaM_SL_CYT in component JCa2CaM_SL_CYT (micromole_per_second)"
    legend_states[7] = "Ca2CaM in component Ca2CaM (micromolar)"
    legend_algebraic[3] = "JCa4CaM_SL_CYT in component JCa4CaM_SL_CYT (micromole_per_second)"
    legend_states[8] = "Ca4CaM in component Ca4CaM (micromolar)"
    legend_algebraic[0] = "Reaction_02 in component Reaction_02 (flux)"
    legend_constants[130] = "k02 in component Reaction_02 (third_order_rate_constant)"
    legend_constants[7] = "k20 in component Reaction_02 (first_order_rate_constant)"
    legend_constants[109] = "Kd02 in component Reaction_02 (micromolar2)"
    legend_constants[8] = "K in component model_parameters (micromolar)"
    legend_constants[9] = "Mg in component model_parameters (micromolar)"
    legend_constants[10] = "Ca in component model_parameters (micromolar)"
    legend_algebraic[21] = "Reaction_24 in component Reaction_24 (flux)"
    legend_constants[131] = "k24 in component Reaction_24 (third_order_rate_constant)"
    legend_constants[11] = "k42 in component Reaction_24 (first_order_rate_constant)"
    legend_constants[110] = "Kd24 in component Reaction_24 (micromolar2)"
    legend_algebraic[24] = "Reaction_02B in component Reaction_02B (flux)"
    legend_constants[136] = "k02B in component Reaction_02B (third_order_rate_constant)"
    legend_constants[12] = "k20B in component Reaction_02B (first_order_rate_constant)"
    legend_states[9] = "CaMB in component CaMB (micromolar)"
    legend_states[10] = "Ca2CaMB in component Ca2CaMB (micromolar)"
    legend_algebraic[27] = "Reaction_24B in component Reaction_24B (flux)"
    legend_constants[137] = "k24B in component Reaction_24B (third_order_rate_constant)"
    legend_constants[111] = "k42B in component Reaction_24B (first_order_rate_constant)"
    legend_states[11] = "Ca4CaMB in component Ca4CaMB (micromolar)"
    legend_algebraic[36] = "Reaction_2B in component Reaction_2B (flux)"
    legend_constants[13] = "k2B_on in component Reaction_2B (second_order_rate_constant)"
    legend_constants[14] = "k2B_off in component Reaction_2B (first_order_rate_constant)"
    legend_algebraic[39] = "Reaction_0B in component Reaction_0B (flux)"
    legend_constants[15] = "k0B_on in component Reaction_0B (second_order_rate_constant)"
    legend_constants[16] = "k0B_off in component Reaction_0B (first_order_rate_constant)"
    legend_algebraic[42] = "Reaction_4B in component Reaction_4B (flux)"
    legend_constants[17] = "k4B_on in component Reaction_4B (second_order_rate_constant)"
    legend_constants[18] = "k4B_off in component Reaction_4B (first_order_rate_constant)"
    legend_constants[19] = "Btot in component B (micromolar)"
    legend_algebraic[102] = "Reaction_0CaN in component Reaction_0CaN (flux)"
    legend_constants[20] = "CaMKIItot in component model_parameters (micromolar)"
    legend_algebraic[96] = "Reaction_2CaN in component Reaction_2CaN (flux)"
    legend_algebraic[75] = "Reaction_CKt2a in component Reaction_CKt2a (first_order_rate_constant)"
    legend_algebraic[60] = "Reaction_CKib2 in component Reaction_CKib2 (first_order_rate_constant)"
    legend_algebraic[99] = "Reaction_4CaN in component Reaction_4CaN (flux)"
    legend_algebraic[72] = "Reaction_CKta in component Reaction_CKta (first_order_rate_constant)"
    legend_algebraic[66] = "Reaction_CKib in component Reaction_CKib (first_order_rate_constant)"
    legend_algebraic[49] = "CaMKIIi in component CaMKIIi (micromolar)"
    legend_algebraic[45] = "Pi in component Pi (dimensionless)"
    legend_algebraic[4] = "CaMKIIb2 in component CaMKIIb2 (micromolar)"
    legend_states[12] = "Pb2 in component Pb2 (dimensionless)"
    legend_algebraic[5] = "CaMKIIb in component CaMKIIb (micromolar)"
    legend_states[13] = "Pb in component Pb (dimensionless)"
    legend_algebraic[6] = "CaMKIIt in component CaMKIIt (micromolar)"
    legend_states[14] = "Pt in component Pt (dimensionless)"
    legend_algebraic[7] = "CaMKIIt2 in component CaMKIIt2 (micromolar)"
    legend_states[15] = "Pt2 in component Pt2 (dimensionless)"
    legend_algebraic[8] = "CaMKIIa in component CaMKIIa (micromolar)"
    legend_states[16] = "Pa in component Pa (dimensionless)"
    legend_algebraic[48] = "T in component T (dimensionless)"
    legend_algebraic[57] = "Reaction_CKbt in component Reaction_CKbt (first_order_rate_constant)"
    legend_algebraic[54] = "kbt in component Reaction_CKbt (first_order_rate_constant)"
    legend_constants[21] = "kPP1 in component model_parameters (first_order_rate_constant)"
    legend_constants[22] = "KmPP1 in component model_parameters (micromolar)"
    legend_constants[23] = "PP1tot in component model_parameters (micromolar)"
    legend_constants[24] = "kib2 in component Reaction_CKib2 (second_order_rate_constant)"
    legend_constants[25] = "kb2i in component Reaction_CKib2 (first_order_rate_constant)"
    legend_algebraic[63] = "Reaction_CKb2b in component Reaction_CKb2b (first_order_rate_constant)"
    legend_constants[138] = "kb24 in component Reaction_CKb2b (third_order_rate_constant)"
    legend_constants[112] = "kb42 in component Reaction_CKb2b (first_order_rate_constant)"
    legend_constants[26] = "kib in component Reaction_CKib (second_order_rate_constant)"
    legend_constants[27] = "kbi in component Reaction_CKib (first_order_rate_constant)"
    legend_algebraic[69] = "Reaction_CKtt2 in component Reaction_CKtt2 (first_order_rate_constant)"
    legend_constants[139] = "kt24 in component Reaction_CKtt2 (third_order_rate_constant)"
    legend_constants[113] = "kt42 in component Reaction_CKtt2 (first_order_rate_constant)"
    legend_constants[28] = "kat in component Reaction_CKta (second_order_rate_constant)"
    legend_constants[29] = "kta in component Reaction_CKta (first_order_rate_constant)"
    legend_constants[30] = "kat2 in component Reaction_CKt2a (second_order_rate_constant)"
    legend_constants[31] = "kt2a in component Reaction_CKt2a (first_order_rate_constant)"
    legend_algebraic[79] = "Reaction_CKt2b2 in component Reaction_CKt2b2 (first_order_rate_constant)"
    legend_algebraic[80] = "Reaction_CKai in component Reaction_CKai (first_order_rate_constant)"
    legend_algebraic[78] = "Ca2CaN in component Ca2CaN (micromolar)"
    legend_constants[32] = "CaNtot in component Ca2CaN (micromolar)"
    legend_states[17] = "Ca4CaN in component Ca4CaN (micromolar)"
    legend_states[18] = "CaMCaN in component CaMCaN (micromolar)"
    legend_states[19] = "Ca2CaMCaN in component Ca2CaMCaN (micromolar)"
    legend_states[20] = "Ca4CaMCaN in component Ca4CaMCaN (micromolar)"
    legend_algebraic[87] = "Reaction_Ca4CaN in component Reaction_Ca4CaN (flux)"
    legend_constants[33] = "kCaNCa_on in component Reaction_Ca4CaN (third_order_rate_constant)"
    legend_constants[34] = "kCaNCa_off in component Reaction_Ca4CaN (first_order_rate_constant)"
    legend_algebraic[90] = "Reaction_02CaN in component Reaction_02CaN (flux)"
    legend_constants[140] = "k02CaN in component Reaction_02CaN (third_order_rate_constant)"
    legend_constants[114] = "k20CaN in component Reaction_02CaN (first_order_rate_constant)"
    legend_algebraic[93] = "Reaction_24CaN in component Reaction_24CaN (flux)"
    legend_constants[141] = "k24CaN in component Reaction_24CaN (third_order_rate_constant)"
    legend_constants[115] = "k42CaN in component Reaction_24CaN (first_order_rate_constant)"
    legend_constants[35] = "kCaN2_on in component Reaction_2CaN (second_order_rate_constant)"
    legend_constants[36] = "kCaN2_off in component Reaction_2CaN (first_order_rate_constant)"
    legend_constants[37] = "kCaN4_on in component Reaction_4CaN (second_order_rate_constant)"
    legend_constants[38] = "kCaN4_off in component Reaction_4CaN (first_order_rate_constant)"
    legend_constants[39] = "kCaN0_on in component Reaction_0CaN (second_order_rate_constant)"
    legend_constants[40] = "kCaN0_off in component Reaction_0CaN (first_order_rate_constant)"
    legend_algebraic[9] = "Reaction_02 in component Reaction_02 (flux)"
    legend_constants[132] = "k02 in component Reaction_02 (third_order_rate_constant)"
    legend_constants[41] = "k20 in component Reaction_02 (first_order_rate_constant)"
    legend_constants[116] = "Kd02 in component Reaction_02 (micromolar2)"
    legend_constants[42] = "K in component model_parameters (micromolar)"
    legend_constants[43] = "Mg in component model_parameters (micromolar)"
    legend_constants[44] = "Ca in component model_parameters (micromolar)"
    legend_algebraic[22] = "Reaction_24 in component Reaction_24 (flux)"
    legend_constants[133] = "k24 in component Reaction_24 (third_order_rate_constant)"
    legend_constants[45] = "k42 in component Reaction_24 (first_order_rate_constant)"
    legend_constants[117] = "Kd24 in component Reaction_24 (micromolar2)"
    legend_algebraic[25] = "Reaction_02B in component Reaction_02B (flux)"
    legend_constants[142] = "k02B in component Reaction_02B (third_order_rate_constant)"
    legend_constants[46] = "k20B in component Reaction_02B (first_order_rate_constant)"
    legend_states[21] = "CaMB in component CaMB (micromolar)"
    legend_states[22] = "Ca2CaMB in component Ca2CaMB (micromolar)"
    legend_algebraic[28] = "Reaction_24B in component Reaction_24B (flux)"
    legend_constants[143] = "k24B in component Reaction_24B (third_order_rate_constant)"
    legend_constants[118] = "k42B in component Reaction_24B (first_order_rate_constant)"
    legend_states[23] = "Ca4CaMB in component Ca4CaMB (micromolar)"
    legend_algebraic[37] = "Reaction_2B in component Reaction_2B (flux)"
    legend_constants[47] = "k2B_on in component Reaction_2B (second_order_rate_constant)"
    legend_constants[48] = "k2B_off in component Reaction_2B (first_order_rate_constant)"
    legend_algebraic[31] = "B in component B (micromolar)"
    legend_algebraic[40] = "Reaction_0B in component Reaction_0B (flux)"
    legend_constants[49] = "k0B_on in component Reaction_0B (second_order_rate_constant)"
    legend_constants[50] = "k0B_off in component Reaction_0B (first_order_rate_constant)"
    legend_algebraic[43] = "Reaction_4B in component Reaction_4B (flux)"
    legend_constants[51] = "k4B_on in component Reaction_4B (second_order_rate_constant)"
    legend_constants[52] = "k4B_off in component Reaction_4B (first_order_rate_constant)"
    legend_constants[53] = "Btot in component B (micromolar)"
    legend_algebraic[103] = "Reaction_0CaN in component Reaction_0CaN (flux)"
    legend_constants[54] = "CaMKIItot in component model_parameters (micromolar)"
    legend_algebraic[97] = "Reaction_2CaN in component Reaction_2CaN (flux)"
    legend_algebraic[76] = "Reaction_CKt2a in component Reaction_CKt2a (first_order_rate_constant)"
    legend_algebraic[61] = "Reaction_CKib2 in component Reaction_CKib2 (first_order_rate_constant)"
    legend_algebraic[100] = "Reaction_4CaN in component Reaction_4CaN (flux)"
    legend_algebraic[73] = "Reaction_CKta in component Reaction_CKta (first_order_rate_constant)"
    legend_algebraic[67] = "Reaction_CKib in component Reaction_CKib (first_order_rate_constant)"
    legend_algebraic[51] = "CaMKIIi in component CaMKIIi (micromolar)"
    legend_algebraic[46] = "Pi in component Pi (dimensionless)"
    legend_algebraic[10] = "CaMKIIb2 in component CaMKIIb2 (micromolar)"
    legend_states[24] = "Pb2 in component Pb2 (dimensionless)"
    legend_algebraic[11] = "CaMKIIb in component CaMKIIb (micromolar)"
    legend_states[25] = "Pb in component Pb (dimensionless)"
    legend_algebraic[12] = "CaMKIIt in component CaMKIIt (micromolar)"
    legend_states[26] = "Pt in component Pt (dimensionless)"
    legend_algebraic[13] = "CaMKIIt2 in component CaMKIIt2 (micromolar)"
    legend_states[27] = "Pt2 in component Pt2 (dimensionless)"
    legend_algebraic[14] = "CaMKIIa in component CaMKIIa (micromolar)"
    legend_states[28] = "Pa in component Pa (dimensionless)"
    legend_algebraic[50] = "T in component T (dimensionless)"
    legend_algebraic[58] = "Reaction_CKbt in component Reaction_CKbt (first_order_rate_constant)"
    legend_algebraic[55] = "kbt in component Reaction_CKbt (first_order_rate_constant)"
    legend_constants[55] = "kPP1 in component model_parameters (first_order_rate_constant)"
    legend_constants[56] = "KmPP1 in component model_parameters (micromolar)"
    legend_constants[57] = "PP1tot in component model_parameters (micromolar)"
    legend_constants[58] = "kib2 in component Reaction_CKib2 (second_order_rate_constant)"
    legend_constants[59] = "kb2i in component Reaction_CKib2 (first_order_rate_constant)"
    legend_algebraic[64] = "Reaction_CKb2b in component Reaction_CKb2b (first_order_rate_constant)"
    legend_constants[144] = "kb24 in component Reaction_CKb2b (third_order_rate_constant)"
    legend_constants[119] = "kb42 in component Reaction_CKb2b (first_order_rate_constant)"
    legend_constants[60] = "kib in component Reaction_CKib (second_order_rate_constant)"
    legend_constants[61] = "kbi in component Reaction_CKib (first_order_rate_constant)"
    legend_algebraic[70] = "Reaction_CKtt2 in component Reaction_CKtt2 (first_order_rate_constant)"
    legend_constants[145] = "kt24 in component Reaction_CKtt2 (third_order_rate_constant)"
    legend_constants[120] = "kt42 in component Reaction_CKtt2 (first_order_rate_constant)"
    legend_constants[62] = "kat in component Reaction_CKta (second_order_rate_constant)"
    legend_constants[63] = "kta in component Reaction_CKta (first_order_rate_constant)"
    legend_constants[64] = "kat2 in component Reaction_CKt2a (second_order_rate_constant)"
    legend_constants[65] = "kt2a in component Reaction_CKt2a (first_order_rate_constant)"
    legend_algebraic[82] = "Reaction_CKt2b2 in component Reaction_CKt2b2 (first_order_rate_constant)"
    legend_algebraic[83] = "Reaction_CKai in component Reaction_CKai (first_order_rate_constant)"
    legend_algebraic[81] = "Ca2CaN in component Ca2CaN (micromolar)"
    legend_constants[66] = "CaNtot in component Ca2CaN (micromolar)"
    legend_states[29] = "Ca4CaN in component Ca4CaN (micromolar)"
    legend_states[30] = "CaMCaN in component CaMCaN (micromolar)"
    legend_states[31] = "Ca2CaMCaN in component Ca2CaMCaN (micromolar)"
    legend_states[32] = "Ca4CaMCaN in component Ca4CaMCaN (micromolar)"
    legend_algebraic[88] = "Reaction_Ca4CaN in component Reaction_Ca4CaN (flux)"
    legend_constants[67] = "kCaNCa_on in component Reaction_Ca4CaN (third_order_rate_constant)"
    legend_constants[68] = "kCaNCa_off in component Reaction_Ca4CaN (first_order_rate_constant)"
    legend_algebraic[91] = "Reaction_02CaN in component Reaction_02CaN (flux)"
    legend_constants[146] = "k02CaN in component Reaction_02CaN (third_order_rate_constant)"
    legend_constants[121] = "k20CaN in component Reaction_02CaN (first_order_rate_constant)"
    legend_algebraic[94] = "Reaction_24CaN in component Reaction_24CaN (flux)"
    legend_constants[147] = "k24CaN in component Reaction_24CaN (third_order_rate_constant)"
    legend_constants[122] = "k42CaN in component Reaction_24CaN (first_order_rate_constant)"
    legend_constants[69] = "kCaN2_on in component Reaction_2CaN (second_order_rate_constant)"
    legend_constants[70] = "kCaN2_off in component Reaction_2CaN (first_order_rate_constant)"
    legend_constants[71] = "kCaN4_on in component Reaction_4CaN (second_order_rate_constant)"
    legend_constants[72] = "kCaN4_off in component Reaction_4CaN (first_order_rate_constant)"
    legend_constants[73] = "kCaN0_on in component Reaction_0CaN (second_order_rate_constant)"
    legend_constants[74] = "kCaN0_off in component Reaction_0CaN (first_order_rate_constant)"
    legend_algebraic[15] = "Reaction_02 in component Reaction_02 (flux)"
    legend_constants[134] = "k02 in component Reaction_02 (third_order_rate_constant)"
    legend_constants[75] = "k20 in component Reaction_02 (first_order_rate_constant)"
    legend_constants[123] = "Kd02 in component Reaction_02 (micromolar2)"
    legend_constants[76] = "K in component model_parameters (micromolar)"
    legend_constants[77] = "Mg in component model_parameters (micromolar)"
    legend_constants[78] = "Ca in component model_parameters (micromolar)"
    legend_algebraic[23] = "Reaction_24 in component Reaction_24 (flux)"
    legend_constants[135] = "k24 in component Reaction_24 (third_order_rate_constant)"
    legend_constants[79] = "k42 in component Reaction_24 (first_order_rate_constant)"
    legend_constants[124] = "Kd24 in component Reaction_24 (micromolar2)"
    legend_algebraic[26] = "Reaction_02B in component Reaction_02B (flux)"
    legend_constants[148] = "k02B in component Reaction_02B (third_order_rate_constant)"
    legend_constants[80] = "k20B in component Reaction_02B (first_order_rate_constant)"
    legend_states[33] = "CaMB in component CaMB (micromolar)"
    legend_states[34] = "Ca2CaMB in component Ca2CaMB (micromolar)"
    legend_algebraic[29] = "Reaction_24B in component Reaction_24B (flux)"
    legend_constants[149] = "k24B in component Reaction_24B (third_order_rate_constant)"
    legend_constants[125] = "k42B in component Reaction_24B (first_order_rate_constant)"
    legend_states[35] = "Ca4CaMB in component Ca4CaMB (micromolar)"
    legend_algebraic[38] = "Reaction_2B in component Reaction_2B (flux)"
    legend_constants[81] = "k2B_on in component Reaction_2B (second_order_rate_constant)"
    legend_constants[82] = "k2B_off in component Reaction_2B (first_order_rate_constant)"
    legend_algebraic[32] = "B in component B (micromolar)"
    legend_algebraic[41] = "Reaction_0B in component Reaction_0B (flux)"
    legend_constants[83] = "k0B_on in component Reaction_0B (second_order_rate_constant)"
    legend_constants[84] = "k0B_off in component Reaction_0B (first_order_rate_constant)"
    legend_algebraic[44] = "Reaction_4B in component Reaction_4B (flux)"
    legend_constants[85] = "k4B_on in component Reaction_4B (second_order_rate_constant)"
    legend_constants[86] = "k4B_off in component Reaction_4B (first_order_rate_constant)"
    legend_constants[87] = "Btot in component B (micromolar)"
    legend_algebraic[104] = "Reaction_0CaN in component Reaction_0CaN (flux)"
    legend_constants[88] = "CaMKIItot in component model_parameters (micromolar)"
    legend_algebraic[98] = "Reaction_2CaN in component Reaction_2CaN (flux)"
    legend_algebraic[77] = "Reaction_CKt2a in component Reaction_CKt2a (first_order_rate_constant)"
    legend_algebraic[62] = "Reaction_CKib2 in component Reaction_CKib2 (first_order_rate_constant)"
    legend_algebraic[101] = "Reaction_4CaN in component Reaction_4CaN (flux)"
    legend_algebraic[74] = "Reaction_CKta in component Reaction_CKta (first_order_rate_constant)"
    legend_algebraic[68] = "Reaction_CKib in component Reaction_CKib (first_order_rate_constant)"
    legend_algebraic[53] = "CaMKIIi in component CaMKIIi (micromolar)"
    legend_algebraic[47] = "Pi in component Pi (dimensionless)"
    legend_algebraic[16] = "CaMKIIb2 in component CaMKIIb2 (micromolar)"
    legend_states[36] = "Pb2 in component Pb2 (dimensionless)"
    legend_algebraic[17] = "CaMKIIb in component CaMKIIb (micromolar)"
    legend_states[37] = "Pb in component Pb (dimensionless)"
    legend_algebraic[18] = "CaMKIIt in component CaMKIIt (micromolar)"
    legend_states[38] = "Pt in component Pt (dimensionless)"
    legend_algebraic[19] = "CaMKIIt2 in component CaMKIIt2 (micromolar)"
    legend_states[39] = "Pt2 in component Pt2 (dimensionless)"
    legend_algebraic[20] = "CaMKIIa in component CaMKIIa (micromolar)"
    legend_states[40] = "Pa in component Pa (dimensionless)"
    legend_algebraic[52] = "T in component T (dimensionless)"
    legend_algebraic[59] = "Reaction_CKbt in component Reaction_CKbt (first_order_rate_constant)"
    legend_algebraic[56] = "kbt in component Reaction_CKbt (first_order_rate_constant)"
    legend_constants[89] = "kPP1 in component model_parameters (first_order_rate_constant)"
    legend_constants[90] = "KmPP1 in component model_parameters (micromolar)"
    legend_constants[91] = "PP1tot in component model_parameters (micromolar)"
    legend_constants[92] = "kib2 in component Reaction_CKib2 (second_order_rate_constant)"
    legend_constants[93] = "kb2i in component Reaction_CKib2 (first_order_rate_constant)"
    legend_algebraic[65] = "Reaction_CKb2b in component Reaction_CKb2b (first_order_rate_constant)"
    legend_constants[150] = "kb24 in component Reaction_CKb2b (third_order_rate_constant)"
    legend_constants[126] = "kb42 in component Reaction_CKb2b (first_order_rate_constant)"
    legend_constants[94] = "kib in component Reaction_CKib (second_order_rate_constant)"
    legend_constants[95] = "kbi in component Reaction_CKib (first_order_rate_constant)"
    legend_algebraic[71] = "Reaction_CKtt2 in component Reaction_CKtt2 (first_order_rate_constant)"
    legend_constants[151] = "kt24 in component Reaction_CKtt2 (third_order_rate_constant)"
    legend_constants[127] = "kt42 in component Reaction_CKtt2 (first_order_rate_constant)"
    legend_constants[96] = "kat in component Reaction_CKta (second_order_rate_constant)"
    legend_constants[97] = "kta in component Reaction_CKta (first_order_rate_constant)"
    legend_constants[98] = "kat2 in component Reaction_CKt2a (second_order_rate_constant)"
    legend_constants[99] = "kt2a in component Reaction_CKt2a (first_order_rate_constant)"
    legend_algebraic[85] = "Reaction_CKt2b2 in component Reaction_CKt2b2 (first_order_rate_constant)"
    legend_algebraic[86] = "Reaction_CKai in component Reaction_CKai (first_order_rate_constant)"
    legend_algebraic[84] = "Ca2CaN in component Ca2CaN (micromolar)"
    legend_constants[100] = "CaNtot in component Ca2CaN (micromolar)"
    legend_states[41] = "Ca4CaN in component Ca4CaN (micromolar)"
    legend_states[42] = "CaMCaN in component CaMCaN (micromolar)"
    legend_states[43] = "Ca2CaMCaN in component Ca2CaMCaN (micromolar)"
    legend_states[44] = "Ca4CaMCaN in component Ca4CaMCaN (micromolar)"
    legend_algebraic[89] = "Reaction_Ca4CaN in component Reaction_Ca4CaN (flux)"
    legend_constants[101] = "kCaNCa_on in component Reaction_Ca4CaN (third_order_rate_constant)"
    legend_constants[102] = "kCaNCa_off in component Reaction_Ca4CaN (first_order_rate_constant)"
    legend_algebraic[92] = "Reaction_02CaN in component Reaction_02CaN (flux)"
    legend_constants[152] = "k02CaN in component Reaction_02CaN (third_order_rate_constant)"
    legend_constants[128] = "k20CaN in component Reaction_02CaN (first_order_rate_constant)"
    legend_algebraic[95] = "Reaction_24CaN in component Reaction_24CaN (flux)"
    legend_constants[153] = "k24CaN in component Reaction_24CaN (third_order_rate_constant)"
    legend_constants[129] = "k42CaN in component Reaction_24CaN (first_order_rate_constant)"
    legend_constants[103] = "kCaN2_on in component Reaction_2CaN (second_order_rate_constant)"
    legend_constants[104] = "kCaN2_off in component Reaction_2CaN (first_order_rate_constant)"
    legend_constants[105] = "kCaN4_on in component Reaction_4CaN (second_order_rate_constant)"
    legend_constants[106] = "kCaN4_off in component Reaction_4CaN (first_order_rate_constant)"
    legend_constants[107] = "kCaN0_on in component Reaction_0CaN (second_order_rate_constant)"
    legend_constants[108] = "kCaN0_off in component Reaction_0CaN (first_order_rate_constant)"
    legend_rates[0] = "d/dt CaM in component CaM (micromolar)"
    legend_rates[2] = "d/dt Ca2CaM in component Ca2CaM (micromolar)"
    legend_rates[4] = "d/dt Ca4CaM in component Ca4CaM (micromolar)"
    legend_rates[9] = "d/dt CaMB in component CaMB (micromolar)"
    legend_rates[10] = "d/dt Ca2CaMB in component Ca2CaMB (micromolar)"
    legend_rates[11] = "d/dt Ca4CaMB in component Ca4CaMB (micromolar)"
    legend_rates[12] = "d/dt Pb2 in component Pb2 (dimensionless)"
    legend_rates[13] = "d/dt Pb in component Pb (dimensionless)"
    legend_rates[14] = "d/dt Pt in component Pt (dimensionless)"
    legend_rates[15] = "d/dt Pt2 in component Pt2 (dimensionless)"
    legend_rates[16] = "d/dt Pa in component Pa (dimensionless)"
    legend_rates[17] = "d/dt Ca4CaN in component Ca4CaN (micromolar)"
    legend_rates[18] = "d/dt CaMCaN in component CaMCaN (micromolar)"
    legend_rates[19] = "d/dt Ca2CaMCaN in component Ca2CaMCaN (micromolar)"
    legend_rates[20] = "d/dt Ca4CaMCaN in component Ca4CaMCaN (micromolar)"
    legend_rates[1] = "d/dt CaM in component CaM (micromolar)"
    legend_rates[3] = "d/dt Ca2CaM in component Ca2CaM (micromolar)"
    legend_rates[5] = "d/dt Ca4CaM in component Ca4CaM (micromolar)"
    legend_rates[21] = "d/dt CaMB in component CaMB (micromolar)"
    legend_rates[22] = "d/dt Ca2CaMB in component Ca2CaMB (micromolar)"
    legend_rates[23] = "d/dt Ca4CaMB in component Ca4CaMB (micromolar)"
    legend_rates[24] = "d/dt Pb2 in component Pb2 (dimensionless)"
    legend_rates[25] = "d/dt Pb in component Pb (dimensionless)"
    legend_rates[26] = "d/dt Pt in component Pt (dimensionless)"
    legend_rates[27] = "d/dt Pt2 in component Pt2 (dimensionless)"
    legend_rates[28] = "d/dt Pa in component Pa (dimensionless)"
    legend_rates[29] = "d/dt Ca4CaN in component Ca4CaN (micromolar)"
    legend_rates[30] = "d/dt CaMCaN in component CaMCaN (micromolar)"
    legend_rates[31] = "d/dt Ca2CaMCaN in component Ca2CaMCaN (micromolar)"
    legend_rates[32] = "d/dt Ca4CaMCaN in component Ca4CaMCaN (micromolar)"
    legend_rates[6] = "d/dt CaM in component CaM (micromolar)"
    legend_rates[7] = "d/dt Ca2CaM in component Ca2CaM (micromolar)"
    legend_rates[8] = "d/dt Ca4CaM in component Ca4CaM (micromolar)"
    legend_rates[33] = "d/dt CaMB in component CaMB (micromolar)"
    legend_rates[34] = "d/dt Ca2CaMB in component Ca2CaMB (micromolar)"
    legend_rates[35] = "d/dt Ca4CaMB in component Ca4CaMB (micromolar)"
    legend_rates[36] = "d/dt Pb2 in component Pb2 (dimensionless)"
    legend_rates[37] = "d/dt Pb in component Pb (dimensionless)"
    legend_rates[38] = "d/dt Pt in component Pt (dimensionless)"
    legend_rates[39] = "d/dt Pt2 in component Pt2 (dimensionless)"
    legend_rates[40] = "d/dt Pa in component Pa (dimensionless)"
    legend_rates[41] = "d/dt Ca4CaN in component Ca4CaN (micromolar)"
    legend_rates[42] = "d/dt CaMCaN in component CaMCaN (micromolar)"
    legend_rates[43] = "d/dt Ca2CaMCaN in component Ca2CaMCaN (micromolar)"
    legend_rates[44] = "d/dt Ca4CaMCaN in component Ca4CaMCaN (micromolar)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 0.007
    constants[1] = 0.0014
    states[0] = 0.1
    states[1] = 0.1
    constants[2] = 0.007
    constants[3] = 0.000014
    states[2] = 0.1
    states[3] = 0.1
    constants[4] = 0.007
    constants[5] = 0.000014
    states[4] = 0.1
    states[5] = 0.1
    constants[6] = 8.59E-12
    states[6] = 0.1
    states[7] = 0.1
    states[8] = 0.1
    constants[7] = 10.0
    constants[8] = 135
    constants[9] = 1
    constants[10] = 1
    constants[11] = 500.0
    constants[12] = 0.1
    states[9] = 0.1
    states[10] = 0.1
    states[11] = 0.1
    constants[13] = 0.007
    constants[14] = 0.000014
    constants[15] = 0.007
    constants[16] = 0.0014
    constants[17] = 0.007
    constants[18] = 0.000014
    constants[19] = 1860.0
    constants[20] = 120.0
    states[12] = 0.1
    states[13] = 0.1
    states[14] = 0.1
    states[15] = 0.1
    states[16] = 0.1
    constants[21] = 1.72
    constants[22] = 11.5
    constants[23] = 96.5
    constants[24] = 65.67
    constants[25] = 328.36
    constants[26] = 6.567
    constants[27] = 2.2
    constants[28] = 6.567
    constants[29] = 0.0022
    constants[30] = 6.567
    constants[31] = 32.835
    constants[32] = 3.62
    states[17] = 0.1
    states[18] = 0.1
    states[19] = 0.1
    states[20] = 0.1
    constants[33] = 2.0
    constants[34] = 1.0
    constants[35] = 46.0
    constants[36] = 3.2604
    constants[37] = 46.0
    constants[38] = 1.3E-3
    constants[39] = 46.0
    constants[40] = 537.966
    constants[41] = 10.0
    constants[42] = 135
    constants[43] = 1
    constants[44] = 1
    constants[45] = 500.0
    constants[46] = 0.1
    states[21] = 0.1
    states[22] = 0.1
    states[23] = 0.1
    constants[47] = 0.007
    constants[48] = 0.000014
    constants[49] = 0.007
    constants[50] = 0.0014
    constants[51] = 0.007
    constants[52] = 0.000014
    constants[53] = 24.5
    constants[54] = 0.2
    states[24] = 0.1
    states[25] = 0.1
    states[26] = 0.1
    states[27] = 0.1
    states[28] = 0.1
    constants[55] = 1.72
    constants[56] = 11.5
    constants[57] = 0.57
    constants[58] = 65.67
    constants[59] = 328.36
    constants[60] = 6.567
    constants[61] = 2.2
    constants[62] = 6.567
    constants[63] = 0.0022
    constants[64] = 6.567
    constants[65] = 32.835
    constants[66] = 3E-3
    states[29] = 0.1
    states[30] = 0.1
    states[31] = 0.1
    states[32] = 0.1
    constants[67] = 2.0
    constants[68] = 1.0
    constants[69] = 46.0
    constants[70] = 3.2604
    constants[71] = 46.0
    constants[72] = 1.3E-3
    constants[73] = 46.0
    constants[74] = 537.966
    constants[75] = 10.0
    constants[76] = 135
    constants[77] = 1
    constants[78] = 1
    constants[79] = 500.0
    constants[80] = 0.1
    states[33] = 0.1
    states[34] = 0.1
    states[35] = 0.1
    constants[81] = 0.007
    constants[82] = 0.000014
    constants[83] = 0.007
    constants[84] = 0.0014
    constants[85] = 0.007
    constants[86] = 0.000014
    constants[87] = 24.5
    constants[88] = 0.2
    states[36] = 0.1
    states[37] = 0.1
    states[38] = 0.1
    states[39] = 0.1
    states[40] = 0.1
    constants[89] = 1.72
    constants[90] = 11.5
    constants[91] = 0.57
    constants[92] = 65.67
    constants[93] = 328.36
    constants[94] = 6.567
    constants[95] = 2.2
    constants[96] = 6.567
    constants[97] = 0.0022
    constants[98] = 6.567
    constants[99] = 32.835
    constants[100] = 3E-3
    states[41] = 0.1
    states[42] = 0.1
    states[43] = 0.1
    states[44] = 0.1
    constants[101] = 2.0
    constants[102] = 1.0
    constants[103] = 46.0
    constants[104] = 3.2604
    constants[105] = 46.0
    constants[106] = 1.3E-3
    constants[107] = 46.0
    constants[108] = 537.966
    constants[109] = custom_piecewise([less_equal(constants[9] , 1.00000), 0.00250000*((1.00000+constants[8]/0.940000)-constants[9]/0.0120000)*(1.00000+constants[8]/8.10000+constants[9]/0.0220000) , True, 0.00250000*((1.00000+constants[8]/0.940000+(constants[9]-1.00000)/0.0600000)-1.00000/0.0120000)*(1.00000+constants[8]/8.10000+1.00000/0.0220000+(constants[9]-1.00000)/0.0680000)])
    constants[110] = custom_piecewise([less_equal(constants[9] , 1.00000), 0.128000*(1.00000+constants[8]/0.640000+constants[9]/0.0140000)*((1.00000+constants[8]/13.0000)-constants[9]/0.153000) , True, 0.128000*(1.00000+constants[8]/0.640000+(constants[9]-1.00000)/0.00500000)*(1.00000/0.0120000)*((1.00000+constants[8]/13.0000+(constants[9]-1.00000)/0.150000)-1.00000/0.153000)])
    constants[111] = constants[11]
    constants[112] = constants[11]*(0.0335000/5.00000)
    constants[113] = constants[11]*(3.35000e-05/5.00000)
    constants[114] = constants[7]/160.000
    constants[115] = constants[11]/2508.00
    constants[116] = custom_piecewise([less_equal(constants[43] , 1.00000), 0.00250000*((1.00000+constants[42]/0.940000)-constants[43]/0.0120000)*(1.00000+constants[42]/8.10000+constants[43]/0.0220000) , True, 0.00250000*((1.00000+constants[42]/0.940000+(constants[43]-1.00000)/0.0600000)-1.00000/0.0120000)*(1.00000+constants[42]/8.10000+1.00000/0.0220000+(constants[43]-1.00000)/0.0680000)])
    constants[117] = custom_piecewise([less_equal(constants[43] , 1.00000), 0.128000*(1.00000+constants[42]/0.640000+constants[43]/0.0140000)*((1.00000+constants[42]/13.0000)-constants[43]/0.153000) , True, 0.128000*(1.00000+constants[42]/0.640000+(constants[43]-1.00000)/0.00500000)*(1.00000/0.0120000)*((1.00000+constants[42]/13.0000+(constants[43]-1.00000)/0.150000)-1.00000/0.153000)])
    constants[118] = constants[45]
    constants[119] = constants[45]*(0.0335000/5.00000)
    constants[120] = constants[45]*(3.35000e-05/5.00000)
    constants[121] = constants[41]/160.000
    constants[122] = constants[45]/2508.00
    constants[123] = custom_piecewise([less_equal(constants[77] , 1.00000), 0.00250000*((1.00000+constants[76]/0.940000)-constants[77]/0.0120000)*(1.00000+constants[76]/8.10000+constants[77]/0.0220000) , True, 0.00250000*((1.00000+constants[76]/0.940000+(constants[77]-1.00000)/0.0600000)-1.00000/0.0120000)*(1.00000+constants[76]/8.10000+1.00000/0.0220000+(constants[77]-1.00000)/0.0680000)])
    constants[124] = custom_piecewise([less_equal(constants[77] , 1.00000), 0.128000*(1.00000+constants[76]/0.640000+constants[77]/0.0140000)*((1.00000+constants[76]/13.0000)-constants[77]/0.153000) , True, 0.128000*(1.00000+constants[76]/0.640000+(constants[77]-1.00000)/0.00500000)*(1.00000/0.0120000)*((1.00000+constants[76]/13.0000+(constants[77]-1.00000)/0.150000)-1.00000/0.153000)])
    constants[125] = constants[79]
    constants[126] = constants[79]*(0.0335000/5.00000)
    constants[127] = constants[79]*(3.35000e-05/5.00000)
    constants[128] = constants[75]/160.000
    constants[129] = constants[79]/2508.00
    constants[130] = constants[7]/constants[109]
    constants[131] = constants[11]/constants[110]
    constants[132] = constants[41]/constants[116]
    constants[133] = constants[45]/constants[117]
    constants[134] = constants[75]/constants[123]
    constants[135] = constants[79]/constants[124]
    constants[136] = constants[130]
    constants[137] = constants[131]
    constants[138] = constants[131]
    constants[139] = constants[131]
    constants[140] = constants[130]
    constants[141] = constants[131]
    constants[142] = constants[132]
    constants[143] = constants[133]
    constants[144] = constants[133]
    constants[145] = constants[133]
    constants[146] = constants[132]
    constants[147] = constants[133]
    constants[148] = constants[134]
    constants[149] = constants[135]
    constants[150] = constants[135]
    constants[151] = constants[135]
    constants[152] = constants[134]
    constants[153] = constants[135]
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[24] = constants[136]*(power(constants[10], 2.00000))*states[9]-constants[12]*states[10]
    algebraic[27] = constants[137]*(power(constants[10], 2.00000))*states[10]-constants[111]*states[11]
    algebraic[30] = constants[19]-(states[9]+states[10]+states[11])
    algebraic[36] = constants[13]*states[2]*algebraic[30]-constants[14]*states[10]
    rates[10] = 0.00100000*((algebraic[24]+algebraic[36])-algebraic[27])
    algebraic[25] = constants[142]*(power(constants[44], 2.00000))*states[21]-constants[46]*states[22]
    algebraic[28] = constants[143]*(power(constants[44], 2.00000))*states[22]-constants[118]*states[23]
    algebraic[31] = constants[53]-(states[21]+states[22]+states[23])
    algebraic[37] = constants[47]*states[3]*algebraic[31]-constants[48]*states[22]
    rates[22] = 0.00100000*((algebraic[25]+algebraic[37])-algebraic[28])
    algebraic[26] = constants[148]*(power(constants[78], 2.00000))*states[33]-constants[80]*states[34]
    algebraic[29] = constants[149]*(power(constants[78], 2.00000))*states[34]-constants[125]*states[35]
    algebraic[32] = constants[87]-(states[33]+states[34]+states[35])
    algebraic[38] = constants[81]*states[7]*algebraic[32]-constants[82]*states[34]
    rates[34] = 0.00100000*((algebraic[26]+algebraic[38])-algebraic[29])
    algebraic[39] = constants[15]*states[0]*algebraic[30]-constants[16]*states[9]
    rates[9] = 0.00100000*(algebraic[39]-algebraic[24])
    algebraic[40] = constants[49]*states[1]*algebraic[31]-constants[50]*states[21]
    rates[21] = 0.00100000*(algebraic[40]-algebraic[25])
    algebraic[41] = constants[83]*states[6]*algebraic[32]-constants[84]*states[33]
    rates[33] = 0.00100000*(algebraic[41]-algebraic[26])
    algebraic[42] = constants[17]*states[4]*algebraic[30]-constants[18]*states[11]
    rates[11] = 0.00100000*(algebraic[27]+algebraic[42])
    algebraic[43] = constants[51]*states[5]*algebraic[31]-constants[52]*states[23]
    rates[23] = 0.00100000*(algebraic[28]+algebraic[43])
    algebraic[44] = constants[85]*states[8]*algebraic[32]-constants[86]*states[35]
    rates[35] = 0.00100000*(algebraic[29]+algebraic[44])
    algebraic[45] = 1.00000-(states[13]+states[12]+states[14]+states[15]+states[16])
    algebraic[66] = constants[26]*states[4]*algebraic[45]-constants[27]*states[13]
    algebraic[48] = states[13]+states[14]+states[15]+states[16]
    algebraic[54] = 0.0550000*algebraic[48]+0.00740000*(power(algebraic[48], 2.00000))+0.0150000*(power(algebraic[48], 3.00000))
    algebraic[57] = algebraic[54]*states[13]-(constants[21]*constants[23]*states[14])/(constants[22]+constants[20]*states[14])
    algebraic[63] = constants[138]*(power(constants[10], 2.00000))*states[12]-constants[112]*states[12]
    rates[13] = 0.00100000*((algebraic[66]+algebraic[63])-algebraic[57])
    algebraic[46] = 1.00000-(states[25]+states[24]+states[26]+states[27]+states[28])
    algebraic[67] = constants[60]*states[5]*algebraic[46]-constants[61]*states[25]
    algebraic[50] = states[25]+states[26]+states[27]+states[28]
    algebraic[55] = 0.0550000*algebraic[50]+0.00740000*(power(algebraic[50], 2.00000))+0.0150000*(power(algebraic[50], 3.00000))
    algebraic[58] = algebraic[55]*states[25]-(constants[55]*constants[57]*states[26])/(constants[56]+constants[54]*states[26])
    algebraic[64] = constants[144]*(power(constants[44], 2.00000))*states[24]-constants[119]*states[24]
    rates[25] = 0.00100000*((algebraic[67]+algebraic[64])-algebraic[58])
    algebraic[47] = 1.00000-(states[37]+states[36]+states[38]+states[39]+states[40])
    algebraic[68] = constants[94]*states[8]*algebraic[47]-constants[95]*states[37]
    algebraic[52] = states[37]+states[38]+states[39]+states[40]
    algebraic[56] = 0.0550000*algebraic[52]+0.00740000*(power(algebraic[52], 2.00000))+0.0150000*(power(algebraic[52], 3.00000))
    algebraic[59] = algebraic[56]*states[37]-(constants[89]*constants[91]*states[38])/(constants[90]+constants[88]*states[38])
    algebraic[65] = constants[150]*(power(constants[78], 2.00000))*states[36]-constants[126]*states[36]
    rates[37] = 0.00100000*((algebraic[68]+algebraic[65])-algebraic[59])
    algebraic[72] = constants[29]*states[14]-constants[28]*states[4]*states[16]
    algebraic[69] = constants[113]*states[14]-constants[139]*(power(constants[10], 2.00000))*states[15]
    rates[14] = 0.00100000*-(algebraic[57]+algebraic[72]+algebraic[69])
    algebraic[73] = constants[63]*states[26]-constants[62]*states[5]*states[28]
    algebraic[70] = constants[120]*states[26]-constants[145]*(power(constants[44], 2.00000))*states[27]
    rates[26] = 0.00100000*-(algebraic[58]+algebraic[73]+algebraic[70])
    algebraic[74] = constants[97]*states[38]-constants[96]*states[8]*states[40]
    algebraic[71] = constants[127]*states[38]-constants[151]*(power(constants[78], 2.00000))*states[39]
    rates[38] = 0.00100000*-(algebraic[59]+algebraic[74]+algebraic[71])
    algebraic[60] = constants[24]*states[2]*algebraic[45]-constants[25]*states[12]
    algebraic[79] = (constants[21]*constants[23]*states[15])/(constants[22]+constants[20]*states[15])
    rates[12] = 0.00100000*(algebraic[79]-(algebraic[60]+algebraic[63]))
    algebraic[75] = constants[31]*states[15]-constants[30]*states[2]*states[16]
    rates[15] = 0.00100000*-(algebraic[69]+algebraic[75]+algebraic[79])
    algebraic[80] = (constants[21]*constants[23]*states[16])/(constants[22]+constants[20]*states[16])
    rates[16] = 0.00100000*((algebraic[72]+algebraic[75])-algebraic[80])
    algebraic[61] = constants[58]*states[3]*algebraic[46]-constants[59]*states[24]
    algebraic[82] = (constants[55]*constants[57]*states[27])/(constants[56]+constants[54]*states[27])
    rates[24] = 0.00100000*(algebraic[82]-(algebraic[61]+algebraic[64]))
    algebraic[76] = constants[65]*states[27]-constants[64]*states[3]*states[28]
    rates[27] = 0.00100000*-(algebraic[70]+algebraic[76]+algebraic[82])
    algebraic[83] = (constants[55]*constants[57]*states[28])/(constants[56]+constants[54]*states[28])
    rates[28] = 0.00100000*((algebraic[73]+algebraic[76])-algebraic[83])
    algebraic[62] = constants[92]*states[7]*algebraic[47]-constants[93]*states[36]
    algebraic[85] = (constants[89]*constants[91]*states[39])/(constants[90]+constants[88]*states[39])
    rates[36] = 0.00100000*(algebraic[85]-(algebraic[62]+algebraic[65]))
    algebraic[77] = constants[99]*states[39]-constants[98]*states[7]*states[40]
    rates[39] = 0.00100000*-(algebraic[71]+algebraic[77]+algebraic[85])
    algebraic[86] = (constants[89]*constants[91]*states[40])/(constants[90]+constants[88]*states[40])
    rates[40] = 0.00100000*((algebraic[74]+algebraic[77])-algebraic[86])
    algebraic[0] = constants[130]*(power(constants[10], 2.00000))*states[0]-constants[7]*states[2]
    algebraic[21] = constants[131]*(power(constants[10], 2.00000))*states[2]-constants[11]*states[4]
    algebraic[96] = constants[35]*states[2]*states[17]-constants[36]*states[19]
    rates[2] = 0.00100000*((constants[20]*(algebraic[75]-algebraic[60])+algebraic[0])-(algebraic[21]+algebraic[36]+algebraic[96]))
    algebraic[90] = constants[140]*(power(constants[10], 2.00000))*states[18]-constants[114]*states[19]
    algebraic[93] = constants[141]*(power(constants[10], 2.00000))*states[19]-constants[115]*states[20]
    rates[19] = 0.00100000*((algebraic[96]+algebraic[90])-algebraic[93])
    algebraic[9] = constants[132]*(power(constants[44], 2.00000))*states[1]-constants[41]*states[3]
    algebraic[22] = constants[133]*(power(constants[44], 2.00000))*states[3]-constants[45]*states[5]
    algebraic[97] = constants[69]*states[3]*states[29]-constants[70]*states[31]
    rates[3] = 0.00100000*((constants[54]*(algebraic[76]-algebraic[61])+algebraic[9])-(algebraic[22]+algebraic[37]+algebraic[97]))
    algebraic[91] = constants[146]*(power(constants[44], 2.00000))*states[30]-constants[121]*states[31]
    algebraic[94] = constants[147]*(power(constants[44], 2.00000))*states[31]-constants[122]*states[32]
    rates[31] = 0.00100000*((algebraic[97]+algebraic[91])-algebraic[94])
    algebraic[15] = constants[134]*(power(constants[78], 2.00000))*states[6]-constants[75]*states[7]
    algebraic[23] = constants[135]*(power(constants[78], 2.00000))*states[7]-constants[79]*states[8]
    algebraic[98] = constants[103]*states[7]*states[41]-constants[104]*states[43]
    rates[7] = 0.00100000*((constants[88]*(algebraic[77]-algebraic[62])+algebraic[15])-(algebraic[23]+algebraic[38]+algebraic[98]))
    algebraic[92] = constants[152]*(power(constants[78], 2.00000))*states[42]-constants[128]*states[43]
    algebraic[95] = constants[153]*(power(constants[78], 2.00000))*states[43]-constants[129]*states[44]
    rates[43] = 0.00100000*((algebraic[98]+algebraic[92])-algebraic[95])
    algebraic[99] = constants[37]*states[4]*states[17]-constants[38]*states[20]
    rates[4] = 0.00100000*((constants[20]*(algebraic[72]-algebraic[66])+algebraic[21])-(algebraic[99]+algebraic[42]))
    rates[20] = 0.00100000*(algebraic[99]+algebraic[93])
    algebraic[100] = constants[71]*states[5]*states[29]-constants[72]*states[32]
    rates[5] = 0.00100000*((constants[54]*(algebraic[73]-algebraic[67])+algebraic[22])-(algebraic[100]+algebraic[43]))
    rates[32] = 0.00100000*(algebraic[100]+algebraic[94])
    algebraic[101] = constants[105]*states[8]*states[41]-constants[106]*states[44]
    rates[8] = 0.00100000*((constants[88]*(algebraic[74]-algebraic[68])+algebraic[23])-(algebraic[101]+algebraic[44]))
    rates[44] = 0.00100000*(algebraic[101]+algebraic[95])
    algebraic[102] = constants[39]*states[0]*states[17]-constants[40]*states[18]
    rates[0] = 0.00100000*-(algebraic[0]+algebraic[39]+algebraic[102])
    algebraic[78] = constants[32]-(states[17]+states[18]+states[19]+states[20])
    algebraic[87] = constants[33]*(power(constants[10], 2.00000))*algebraic[78]-constants[34]*states[17]
    rates[17] = 0.00100000*(algebraic[87]-(algebraic[102]+algebraic[96]+algebraic[99]))
    rates[18] = 0.00100000*(algebraic[102]-algebraic[90])
    algebraic[103] = constants[73]*states[1]*states[29]-constants[74]*states[30]
    rates[1] = 0.00100000*-(algebraic[9]+algebraic[40]+algebraic[103])
    algebraic[81] = constants[66]-(states[29]+states[30]+states[31]+states[32])
    algebraic[88] = constants[67]*(power(constants[44], 2.00000))*algebraic[81]-constants[68]*states[29]
    rates[29] = 0.00100000*(algebraic[88]-(algebraic[103]+algebraic[97]+algebraic[100]))
    rates[30] = 0.00100000*(algebraic[103]-algebraic[91])
    algebraic[104] = constants[107]*states[6]*states[41]-constants[108]*states[42]
    rates[6] = 0.00100000*-(algebraic[15]+algebraic[41]+algebraic[104])
    algebraic[84] = constants[100]-(states[41]+states[42]+states[43]+states[44])
    algebraic[89] = constants[101]*(power(constants[78], 2.00000))*algebraic[84]-constants[102]*states[41]
    rates[41] = 0.00100000*(algebraic[89]-(algebraic[104]+algebraic[98]+algebraic[101]))
    rates[42] = 0.00100000*(algebraic[104]-algebraic[92])
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[24] = constants[136]*(power(constants[10], 2.00000))*states[9]-constants[12]*states[10]
    algebraic[27] = constants[137]*(power(constants[10], 2.00000))*states[10]-constants[111]*states[11]
    algebraic[30] = constants[19]-(states[9]+states[10]+states[11])
    algebraic[36] = constants[13]*states[2]*algebraic[30]-constants[14]*states[10]
    algebraic[25] = constants[142]*(power(constants[44], 2.00000))*states[21]-constants[46]*states[22]
    algebraic[28] = constants[143]*(power(constants[44], 2.00000))*states[22]-constants[118]*states[23]
    algebraic[31] = constants[53]-(states[21]+states[22]+states[23])
    algebraic[37] = constants[47]*states[3]*algebraic[31]-constants[48]*states[22]
    algebraic[26] = constants[148]*(power(constants[78], 2.00000))*states[33]-constants[80]*states[34]
    algebraic[29] = constants[149]*(power(constants[78], 2.00000))*states[34]-constants[125]*states[35]
    algebraic[32] = constants[87]-(states[33]+states[34]+states[35])
    algebraic[38] = constants[81]*states[7]*algebraic[32]-constants[82]*states[34]
    algebraic[39] = constants[15]*states[0]*algebraic[30]-constants[16]*states[9]
    algebraic[40] = constants[49]*states[1]*algebraic[31]-constants[50]*states[21]
    algebraic[41] = constants[83]*states[6]*algebraic[32]-constants[84]*states[33]
    algebraic[42] = constants[17]*states[4]*algebraic[30]-constants[18]*states[11]
    algebraic[43] = constants[51]*states[5]*algebraic[31]-constants[52]*states[23]
    algebraic[44] = constants[85]*states[8]*algebraic[32]-constants[86]*states[35]
    algebraic[45] = 1.00000-(states[13]+states[12]+states[14]+states[15]+states[16])
    algebraic[66] = constants[26]*states[4]*algebraic[45]-constants[27]*states[13]
    algebraic[48] = states[13]+states[14]+states[15]+states[16]
    algebraic[54] = 0.0550000*algebraic[48]+0.00740000*(power(algebraic[48], 2.00000))+0.0150000*(power(algebraic[48], 3.00000))
    algebraic[57] = algebraic[54]*states[13]-(constants[21]*constants[23]*states[14])/(constants[22]+constants[20]*states[14])
    algebraic[63] = constants[138]*(power(constants[10], 2.00000))*states[12]-constants[112]*states[12]
    algebraic[46] = 1.00000-(states[25]+states[24]+states[26]+states[27]+states[28])
    algebraic[67] = constants[60]*states[5]*algebraic[46]-constants[61]*states[25]
    algebraic[50] = states[25]+states[26]+states[27]+states[28]
    algebraic[55] = 0.0550000*algebraic[50]+0.00740000*(power(algebraic[50], 2.00000))+0.0150000*(power(algebraic[50], 3.00000))
    algebraic[58] = algebraic[55]*states[25]-(constants[55]*constants[57]*states[26])/(constants[56]+constants[54]*states[26])
    algebraic[64] = constants[144]*(power(constants[44], 2.00000))*states[24]-constants[119]*states[24]
    algebraic[47] = 1.00000-(states[37]+states[36]+states[38]+states[39]+states[40])
    algebraic[68] = constants[94]*states[8]*algebraic[47]-constants[95]*states[37]
    algebraic[52] = states[37]+states[38]+states[39]+states[40]
    algebraic[56] = 0.0550000*algebraic[52]+0.00740000*(power(algebraic[52], 2.00000))+0.0150000*(power(algebraic[52], 3.00000))
    algebraic[59] = algebraic[56]*states[37]-(constants[89]*constants[91]*states[38])/(constants[90]+constants[88]*states[38])
    algebraic[65] = constants[150]*(power(constants[78], 2.00000))*states[36]-constants[126]*states[36]
    algebraic[72] = constants[29]*states[14]-constants[28]*states[4]*states[16]
    algebraic[69] = constants[113]*states[14]-constants[139]*(power(constants[10], 2.00000))*states[15]
    algebraic[73] = constants[63]*states[26]-constants[62]*states[5]*states[28]
    algebraic[70] = constants[120]*states[26]-constants[145]*(power(constants[44], 2.00000))*states[27]
    algebraic[74] = constants[97]*states[38]-constants[96]*states[8]*states[40]
    algebraic[71] = constants[127]*states[38]-constants[151]*(power(constants[78], 2.00000))*states[39]
    algebraic[60] = constants[24]*states[2]*algebraic[45]-constants[25]*states[12]
    algebraic[79] = (constants[21]*constants[23]*states[15])/(constants[22]+constants[20]*states[15])
    algebraic[75] = constants[31]*states[15]-constants[30]*states[2]*states[16]
    algebraic[80] = (constants[21]*constants[23]*states[16])/(constants[22]+constants[20]*states[16])
    algebraic[61] = constants[58]*states[3]*algebraic[46]-constants[59]*states[24]
    algebraic[82] = (constants[55]*constants[57]*states[27])/(constants[56]+constants[54]*states[27])
    algebraic[76] = constants[65]*states[27]-constants[64]*states[3]*states[28]
    algebraic[83] = (constants[55]*constants[57]*states[28])/(constants[56]+constants[54]*states[28])
    algebraic[62] = constants[92]*states[7]*algebraic[47]-constants[93]*states[36]
    algebraic[85] = (constants[89]*constants[91]*states[39])/(constants[90]+constants[88]*states[39])
    algebraic[77] = constants[99]*states[39]-constants[98]*states[7]*states[40]
    algebraic[86] = (constants[89]*constants[91]*states[40])/(constants[90]+constants[88]*states[40])
    algebraic[0] = constants[130]*(power(constants[10], 2.00000))*states[0]-constants[7]*states[2]
    algebraic[21] = constants[131]*(power(constants[10], 2.00000))*states[2]-constants[11]*states[4]
    algebraic[96] = constants[35]*states[2]*states[17]-constants[36]*states[19]
    algebraic[90] = constants[140]*(power(constants[10], 2.00000))*states[18]-constants[114]*states[19]
    algebraic[93] = constants[141]*(power(constants[10], 2.00000))*states[19]-constants[115]*states[20]
    algebraic[9] = constants[132]*(power(constants[44], 2.00000))*states[1]-constants[41]*states[3]
    algebraic[22] = constants[133]*(power(constants[44], 2.00000))*states[3]-constants[45]*states[5]
    algebraic[97] = constants[69]*states[3]*states[29]-constants[70]*states[31]
    algebraic[91] = constants[146]*(power(constants[44], 2.00000))*states[30]-constants[121]*states[31]
    algebraic[94] = constants[147]*(power(constants[44], 2.00000))*states[31]-constants[122]*states[32]
    algebraic[15] = constants[134]*(power(constants[78], 2.00000))*states[6]-constants[75]*states[7]
    algebraic[23] = constants[135]*(power(constants[78], 2.00000))*states[7]-constants[79]*states[8]
    algebraic[98] = constants[103]*states[7]*states[41]-constants[104]*states[43]
    algebraic[92] = constants[152]*(power(constants[78], 2.00000))*states[42]-constants[128]*states[43]
    algebraic[95] = constants[153]*(power(constants[78], 2.00000))*states[43]-constants[129]*states[44]
    algebraic[99] = constants[37]*states[4]*states[17]-constants[38]*states[20]
    algebraic[100] = constants[71]*states[5]*states[29]-constants[72]*states[32]
    algebraic[101] = constants[105]*states[8]*states[41]-constants[106]*states[44]
    algebraic[102] = constants[39]*states[0]*states[17]-constants[40]*states[18]
    algebraic[78] = constants[32]-(states[17]+states[18]+states[19]+states[20])
    algebraic[87] = constants[33]*(power(constants[10], 2.00000))*algebraic[78]-constants[34]*states[17]
    algebraic[103] = constants[73]*states[1]*states[29]-constants[74]*states[30]
    algebraic[81] = constants[66]-(states[29]+states[30]+states[31]+states[32])
    algebraic[88] = constants[67]*(power(constants[44], 2.00000))*algebraic[81]-constants[68]*states[29]
    algebraic[104] = constants[107]*states[6]*states[41]-constants[108]*states[42]
    algebraic[84] = constants[100]-(states[41]+states[42]+states[43]+states[44])
    algebraic[89] = constants[101]*(power(constants[78], 2.00000))*algebraic[84]-constants[102]*states[41]
    algebraic[1] = constants[6]*(states[1]-states[6])
    algebraic[2] = constants[6]*(states[3]-states[7])
    algebraic[3] = constants[6]*(states[5]-states[8])
    algebraic[4] = states[12]*constants[20]
    algebraic[5] = states[13]*constants[20]
    algebraic[6] = states[14]*constants[20]
    algebraic[7] = states[15]*constants[20]
    algebraic[8] = states[16]*constants[20]
    algebraic[10] = states[24]*constants[54]
    algebraic[11] = states[25]*constants[54]
    algebraic[12] = states[26]*constants[54]
    algebraic[13] = states[27]*constants[54]
    algebraic[14] = states[28]*constants[54]
    algebraic[16] = states[36]*constants[88]
    algebraic[17] = states[37]*constants[88]
    algebraic[18] = states[38]*constants[88]
    algebraic[19] = states[39]*constants[88]
    algebraic[20] = states[40]*constants[88]
    algebraic[33] = constants[1]*states[0]-constants[0]*algebraic[30]*states[1]
    algebraic[34] = constants[3]*states[2]-constants[2]*algebraic[30]*states[3]
    algebraic[35] = constants[5]*states[4]-constants[4]*algebraic[30]*states[5]
    algebraic[49] = algebraic[45]*constants[20]
    algebraic[51] = algebraic[46]*constants[54]
    algebraic[53] = algebraic[47]*constants[88]
    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)