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 = 56
sizeStates = 4
sizeConstants = 578
from math import *
from numpy import *

def createLegends():
    legend_states = [""] * sizeStates
    legend_rates = [""] * sizeStates
    legend_algebraic = [""] * sizeAlgebraic
    legend_voi = ""
    legend_constants = [""] * sizeConstants
    legend_constants[0] = "PA in component input_values (mmHg)"
    legend_constants[1] = "AUM in component input_values (dimensionless)"
    legend_constants[2] = "ANM in component input_values (dimensionless)"
    legend_constants[3] = "MYOGRS in component input_values (dimensionless)"
    legend_constants[4] = "PAMKRN in component input_values (dimensionless)"
    legend_constants[5] = "HM1 in component input_values (dimensionless)"
    legend_constants[6] = "PPC in component input_values (mmHg)"
    legend_constants[7] = "VTW in component input_values (litre)"
    legend_constants[8] = "CNA in component input_values (monovalent_mEq_per_litre)"
    legend_constants[9] = "ADHMK in component input_values (dimensionless)"
    legend_constants[10] = "AMNA in component input_values (dimensionless)"
    legend_constants[11] = "CKE in component input_values (monovalent_mEq_per_litre)"
    legend_constants[12] = "AMK in component input_values (dimensionless)"
    legend_constants[13] = "ANPX in component input_values (dimensionless)"
    legend_constants[14] = "A1K in component parameter_values (minute)"
    legend_constants[15] = "A2K in component parameter_values (minute)"
    legend_constants[16] = "A3K in component parameter_values (minute)"
    legend_constants[17] = "A4K in component parameter_values (minute)"
    legend_constants[18] = "A4K2 in component parameter_values (minute)"
    legend_constants[19] = "AARK in component parameter_values (mmHg_minute_per_L)"
    legend_constants[20] = "AARLL in component parameter_values (mmHg_minute_per_L)"
    legend_constants[21] = "ADHINF in component parameter_values (dimensionless)"
    legend_constants[22] = "ADHKLL in component parameter_values (dimensionless)"
    legend_constants[23] = "ADHKUL in component parameter_values (dimensionless)"
    legend_constants[24] = "ADHPAM in component parameter_values (per_mmHg2)"
    legend_constants[25] = "ADHPUL in component parameter_values (mmHg)"
    legend_constants[26] = "ADHTC in component parameter_values (minute)"
    legend_constants[27] = "ADHVLL in component parameter_values (dimensionless)"
    legend_constants[28] = "ADHVUL in component parameter_values (dimensionless)"
    legend_constants[29] = "AH10 in component parameter_values (dimensionless)"
    legend_constants[30] = "AH11 in component parameter_values (minute)"
    legend_constants[31] = "AH9 in component parameter_values (per_mmHg)"
    legend_constants[32] = "AHMNAR in component parameter_values (dimensionless)"
    legend_constants[33] = "AHTHM in component parameter_values (dimensionless)"
    legend_constants[34] = "ALCLK in component parameter_values (dimensionless)"
    legend_constants[35] = "ALDINF in component parameter_values (dimensionless)"
    legend_constants[36] = "ALDKNS in component parameter_values (dimensionless)"
    legend_constants[37] = "ALDMM in component parameter_values (dimensionless)"
    legend_constants[38] = "AM1LL in component parameter_values (dimensionless)"
    legend_constants[39] = "AM1UL in component parameter_values (dimensionless)"
    legend_constants[40] = "AMCSNS in component parameter_values (dimensionless)"
    legend_constants[41] = "AMKM in component parameter_values (dimensionless)"
    legend_constants[42] = "AMKMUL in component parameter_values (dimensionless)"
    legend_constants[43] = "AMM1LM in component parameter_values (dimensionless)"
    legend_constants[44] = "AMM4 in component parameter_values (dimensionless)"
    legend_constants[45] = "AMNALL in component parameter_values (dimensionless)"
    legend_constants[46] = "AMNAM in component parameter_values (dimensionless)"
    legend_constants[47] = "AMNAUL in component parameter_values (dimensionless)"
    legend_constants[48] = "AMT in component parameter_values (minute)"
    legend_constants[49] = "ANCSNS in component parameter_values (dimensionless)"
    legend_constants[50] = "ANGINF in component parameter_values (dimensionless)"
    legend_constants[51] = "ANGKNS in component parameter_values (dimensionless)"
    legend_constants[52] = "ANMALD in component parameter_values (dimensionless)"
    legend_constants[53] = "ANMAM in component parameter_values (dimensionless)"
    legend_constants[54] = "ANMARL in component parameter_values (dimensionless)"
    legend_constants[55] = "ANMEM in component parameter_values (dimensionless)"
    legend_constants[56] = "ANMKEL in component parameter_values (dimensionless)"
    legend_constants[57] = "ANMKEM in component parameter_values (dimensionless)"
    legend_constants[58] = "ANMLL in component parameter_values (dimensionless)"
    legend_constants[59] = "ANMNAM in component parameter_values (dimensionless)"
    legend_constants[60] = "ANMSLT in component parameter_values (dimensionless)"
    legend_constants[61] = "ANMTM in component parameter_values (dimensionless)"
    legend_constants[62] = "ANMUL in component parameter_values (dimensionless)"
    legend_constants[63] = "ANPTC in component parameter_values (minute)"
    legend_constants[64] = "ANPXAF in component parameter_values (mmHg_minute_per_L)"
    legend_constants[65] = "ANPXUL in component parameter_values (dimensionless)"
    legend_constants[66] = "ANT in component parameter_values (minute)"
    legend_constants[67] = "ANULL in component parameter_values (dimensionless)"
    legend_constants[68] = "ANUM in component parameter_values (dimensionless)"
    legend_constants[69] = "ANUVM in component parameter_values (dimensionless)"
    legend_constants[70] = "ANV in component parameter_values (minute)"
    legend_constants[71] = "ANXM in component parameter_values (dimensionless)"
    legend_constants[72] = "ANY in component parameter_values (litre)"
    legend_constants[73] = "AR1LM in component parameter_values (dimensionless)"
    legend_constants[74] = "AR2LM in component parameter_values (dimensionless)"
    legend_constants[75] = "ARF in component parameter_values (dimensionless)"
    legend_constants[76] = "AUC1 in component parameter_values (dimensionless)"
    legend_constants[77] = "AUDMP in component parameter_values (minute)"
    legend_constants[78] = "AUK in component parameter_values (per_minute)"
    legend_constants[79] = "AUL in component parameter_values (litre)"
    legend_constants[80] = "AULPM in component parameter_values (dimensionless)"
    legend_constants[81] = "AUM1 in component parameter_values (dimensionless)"
    legend_constants[82] = "AUM2 in component parameter_values (dimensionless)"
    legend_constants[83] = "AUMAX in component parameter_values (dimensionless)"
    legend_constants[84] = "AUMIN in component parameter_values (dimensionless)"
    legend_constants[85] = "AUMK1 in component parameter_values (dimensionless)"
    legend_constants[86] = "AUN1 in component parameter_values (dimensionless)"
    legend_constants[87] = "AURG in component parameter_values (dimensionless)"
    legend_constants[88] = "AUS in component parameter_values (dimensionless)"
    legend_constants[89] = "AUSLP in component parameter_values (dimensionless)"
    legend_constants[90] = "AUTO in component parameter_values (dimensionless)"
    legend_constants[91] = "AUTOGN in component parameter_values (dimensionless)"
    legend_constants[92] = "AUTOSN in component parameter_values (dimensionless)"
    legend_constants[93] = "AUX in component parameter_values (dimensionless)"
    legend_constants[94] = "BAROTC in component parameter_values (minute)"
    legend_constants[95] = "CFC in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[96] = "CKEEX in component parameter_values (dimensionless)"
    legend_constants[97] = "CMPTSS in component parameter_values (dimensionless)"
    legend_constants[98] = "CN2 in component parameter_values (per_mmHg)"
    legend_constants[99] = "CN7 in component parameter_values (dimensionless)"
    legend_constants[100] = "CNR in component parameter_values (monovalent_mEq_per_litre)"
    legend_constants[101] = "CPF in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[102] = "CPK in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[103] = "CPR in component parameter_values (gram_per_L)"
    legend_constants[104] = "CV in component parameter_values (L_per_mmHg)"
    legend_constants[105] = "CRRFLX in component parameter_values (mmHg)"
    legend_constants[106] = "DIURET in component parameter_values (dimensionless)"
    legend_constants[107] = "DHDTR in component parameter_values (per_mmHg_per_minute)"
    legend_constants[108] = "DTNAR in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[109] = "DTNARL in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[110] = "EARK in component parameter_values (mmHg_minute_per_L)"
    legend_constants[111] = "EARLL in component parameter_values (mmHg_minute_per_L)"
    legend_constants[112] = "EFAFR in component parameter_values (dimensionless)"
    legend_constants[113] = "EXC in component parameter_values (dimensionless)"
    legend_constants[114] = "EXCML in component parameter_values (dimensionless)"
    legend_constants[115] = "EXCXP in component parameter_values (dimensionless)"
    legend_constants[116] = "EXCXP2 in component parameter_values (dimensionless)"
    legend_constants[117] = "EXE in component parameter_values (mmHg)"
    legend_constants[118] = "GCOPF in component parameter_values (per_mmHg)"
    legend_constants[119] = "GFLC in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[120] = "GFNDMP in component parameter_values (dimensionless)"
    legend_constants[121] = "GFNLL in component parameter_values (L_per_minute)"
    legend_constants[122] = "GPPD in component parameter_values (dimensionless)"
    legend_constants[123] = "HM6 in component parameter_values (mmHg)"
    legend_constants[124] = "HM8 in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[125] = "HTAUML in component parameter_values (dimensionless)"
    legend_constants[126] = "KORGN in component parameter_values (dimensionless)"
    legend_constants[127] = "KORNER in component parameter_values (dimensionless)"
    legend_constants[128] = "KORREN in component parameter_values (dimensionless)"
    legend_constants[129] = "KORTC in component parameter_values (minute)"
    legend_constants[130] = "LPDE in component parameter_values (dimensionless)"
    legend_constants[131] = "LPK in component parameter_values (L_per_minute)"
    legend_constants[132] = "LPPR in component parameter_values (gram_per_minute)"
    legend_constants[133] = "MDFL1 in component parameter_values (dimensionless)"
    legend_constants[134] = "MDFLKM in component parameter_values (monovalent_mEq_per_litre)"
    legend_constants[135] = "MDFLW2 in component parameter_values (dimensionless)"
    legend_constants[136] = "MDFLWX in component parameter_values (dimensionless)"
    legend_constants[137] = "MDMP in component parameter_values (dimensionless)"
    legend_constants[138] = "O2A in component parameter_values (dimensionless)"
    legend_constants[139] = "O2CHMO in component parameter_values (per_mmHg)"
    legend_constants[140] = "OMM in component parameter_values (mL_per_minute)"
    legend_constants[141] = "PA4 in component parameter_values (dimensionless)"
    legend_constants[142] = "PAEX in component parameter_values (dimensionless)"
    legend_constants[143] = "PCE in component parameter_values (dimensionless)"
    legend_constants[144] = "PCR in component parameter_values (mmHg)"
    legend_constants[145] = "PR1LL in component parameter_values (mmHg)"
    legend_constants[146] = "PGHF in component parameter_values (L_mmHg_per_gram)"
    legend_constants[147] = "PK2 in component parameter_values (mmHg_per_mL)"
    legend_constants[148] = "PL2 in component parameter_values (L_mL_per_minute_per_mmHg)"
    legend_constants[149] = "PLDF in component parameter_values (mmHg)"
    legend_constants[150] = "PM5 in component parameter_values (per_mmHg)"
    legend_constants[151] = "PO2ADV in component parameter_values (dimensionless)"
    legend_constants[152] = "POK in component parameter_values (dimensionless)"
    legend_constants[153] = "POM in component parameter_values (dimensionless)"
    legend_constants[154] = "POM2 in component parameter_values (dimensionless)"
    legend_constants[155] = "PON in component parameter_values (dimensionless)"
    legend_constants[156] = "POR in component parameter_values (mmHg)"
    legend_constants[157] = "POZ in component parameter_values (dimensionless)"
    legend_constants[158] = "PXTP in component parameter_values (mmHg)"
    legend_constants[159] = "QAOLM in component parameter_values (dimensionless)"
    legend_constants[160] = "QRF in component parameter_values (L_per_minute)"
    legend_constants[161] = "RABSC in component parameter_values (per_mmHg)"
    legend_constants[162] = "RAM in component parameter_values (mmHg_minute_per_L)"
    legend_constants[163] = "RAPRSP in component parameter_values (mmHg)"
    legend_constants[164] = "RAR in component parameter_values (mmHg_minute_per_L)"
    legend_constants[165] = "RCDFDP in component parameter_values (minute)"
    legend_constants[166] = "RCDFPC in component parameter_values (dimensionless)"
    legend_constants[167] = "REK in component parameter_values (dimensionless)"
    legend_constants[168] = "RFABKM in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[169] = "RFABDM in component parameter_values (dimensionless)"
    legend_constants[170] = "RFABDP in component parameter_values (dimensionless)"
    legend_constants[171] = "RFCDFT in component parameter_values (dimensionless)"
    legend_constants[172] = "RKC in component parameter_values (per_minute)"
    legend_constants[173] = "RNAGTC in component parameter_values (minute)"
    legend_constants[174] = "RNAUAD in component parameter_values (per_minute)"
    legend_constants[175] = "RPS in component parameter_values (dimensionless)"
    legend_constants[176] = "RTPPR in component parameter_values (dimensionless)"
    legend_constants[177] = "RTPPRS in component parameter_values (mmHg)"
    legend_constants[178] = "RTSPRS in component parameter_values (mmHg)"
    legend_constants[179] = "RVRS in component parameter_values (mmHg_minute_per_L)"
    legend_constants[180] = "RVSM in component parameter_values (mmHg_minute_per_L)"
    legend_constants[181] = "SR in component parameter_values (dimensionless)"
    legend_constants[182] = "SR2 in component parameter_values (dimensionless)"
    legend_constants[183] = "SRK in component parameter_values (minute)"
    legend_constants[184] = "SRK2 in component parameter_values (minute)"
    legend_constants[185] = "STA in component parameter_values (dimensionless)"
    legend_constants[186] = "TENSGN in component parameter_values (dimensionless)"
    legend_constants[187] = "TENSTC in component parameter_values (minute)"
    legend_constants[188] = "TIMETR in component parameter_values (minute)"
    legend_constants[189] = "TRNSFS in component parameter_values (dimensionless)"
    legend_constants[190] = "TRPL in component parameter_values (L_per_minute)"
    legend_constants[191] = "TSSLML in component parameter_values (dimensionless)"
    legend_constants[192] = "TSSLTC in component parameter_values (per_minute)"
    legend_constants[193] = "TVDDL in component parameter_values (minute)"
    legend_constants[194] = "U in component parameter_values (dimensionless)"
    legend_constants[195] = "VID1 in component parameter_values (L_per_minute)"
    legend_constants[196] = "VIDML in component parameter_values (litre2_per_monovalent_mEq_per_minute)"
    legend_constants[197] = "VNTSTM in component parameter_values (dimensionless)"
    legend_constants[198] = "VP1 in component parameter_values (dimensionless)"
    legend_constants[199] = "VPTISS in component parameter_values (litre)"
    legend_constants[200] = "VTSF in component parameter_values (litre)"
    legend_constants[201] = "VV9 in component parameter_values (litre)"
    legend_constants[202] = "X in component parameter_values (dimensionless)"
    legend_constants[203] = "Z in component parameter_values (dimensionless)"
    legend_constants[204] = "Z4 in component parameter_values (dimensionless)"
    legend_constants[205] = "Z5 in component parameter_values (dimensionless)"
    legend_constants[206] = "Z6 in component parameter_values (dimensionless)"
    legend_constants[207] = "Z7 in component parameter_values (dimensionless)"
    legend_constants[208] = "Z10 in component parameter_values (mmHg)"
    legend_constants[209] = "Z11 in component parameter_values (per_mmHg2)"
    legend_constants[210] = "Z12 in component parameter_values (dimensionless)"
    legend_constants[211] = "Z13 in component parameter_values (dimensionless)"
    legend_constants[212] = "Z14 in component parameter_values (dimensionless)"
    legend_constants[213] = "Z16 in component parameter_values (dimensionless)"
    legend_constants[214] = "Z18 in component parameter_values (dimensionless)"
    legend_constants[215] = "Z19 in component parameter_values (dimensionless)"
    legend_constants[216] = "KID in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[217] = "URFORM in component parameter_values (mOsm_per_minute)"
    legend_constants[218] = "AUV in component parameter_values (dimensionless)"
    legend_constants[219] = "AUY in component parameter_values (dimensionless)"
    legend_constants[220] = "O2M in component parameter_values (mL_per_minute)"
    legend_constants[221] = "NID in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[222] = "ATRFBM in component parameter_values (dimensionless)"
    legend_constants[223] = "GBL in component parameter_values (mmHg)"
    legend_constants[224] = "RNAUGN in component parameter_values (minute_per_L)"
    legend_constants[225] = "RNAULL in component parameter_values (dimensionless)"
    legend_constants[226] = "RNAUUL in component parameter_values (dimensionless)"
    legend_constants[227] = "HSR in component parameter_values (dimensionless)"
    legend_constants[228] = "HSL in component parameter_values (dimensionless)"
    legend_constants[229] = "HMK in component parameter_values (dimensionless)"
    legend_constants[230] = "PO2AMB in component parameter_values (mmHg)"
    legend_constants[231] = "HKM in component parameter_values (dimensionless)"
    legend_constants[232] = "DR in component parameter_values (L_per_minute)"
    legend_constants[233] = "ANPKNS in component parameter_values (dimensionless)"
    legend_constants[234] = "RMULT1 in component parameter_values (dimensionless)"
    legend_constants[235] = "GLPCA in component parameter_values (mmHg)"
    legend_constants[236] = "RFN in component parameter_values (L_per_minute)"
    legend_constants[237] = "RFABX in component parameter_values (dimensionless)"
    legend_constants[238] = "ANPINF in component parameter_values (dimensionless)"
    legend_constants[239] = "FIS in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[240] = "CPPD in component parameter_values (gram_per_L)"
    legend_constants[241] = "TRRBC in component parameter_values (L_per_minute)"
    legend_constants[242] = "HYL in component parameter_values (gram)"
    legend_constants[243] = "ATRVM in component parameter_values (litre)"
    legend_constants[244] = "ADHC_init in component state_variables (dimensionless)"
    legend_constants[245] = "AHY_init in component state_variables (dimensionless)"
    legend_constants[246] = "AMC_init in component state_variables (dimensionless)"
    legend_constants[247] = "AMM1T_init in component state_variables (dimensionless)"
    legend_constants[248] = "AMM2_init in component state_variables (dimensionless)"
    legend_constants[249] = "ANC_init in component state_variables (dimensionless)"
    legend_constants[250] = "ANPC_init in component state_variables (dimensionless)"
    legend_constants[251] = "ANX1_init in component state_variables (dimensionless)"
    legend_constants[252] = "AR1T_init in component state_variables (dimensionless)"
    legend_constants[253] = "AR2T_init in component state_variables (dimensionless)"
    legend_constants[254] = "AR3T_init in component state_variables (dimensionless)"
    legend_constants[255] = "AU1_init in component state_variables (dimensionless)"
    legend_constants[256] = "AU4_init in component state_variables (dimensionless)"
    legend_constants[257] = "AU6_init in component state_variables (dimensionless)"
    legend_constants[258] = "DTKA_init in component state_variables (monovalent_mEq_per_minute)"
    legend_constants[259] = "HMD1_init in component state_variables (dimensionless)"
    legend_constants[260] = "HPL_init in component state_variables (dimensionless)"
    legend_constants[261] = "HPR_init in component state_variables (dimensionless)"
    legend_constants[262] = "KTOT_init in component state_variables (monovalent_mEq)"
    legend_constants[263] = "NAE_init in component state_variables (monovalent_mEq)"
    legend_constants[264] = "O2VAD1_init in component state_variables (dimensionless)"
    legend_constants[265] = "OSV_init in component state_variables (dimensionless)"
    legend_constants[266] = "OVA_init in component state_variables (mL_per_L)"
    legend_constants[267] = "OVS_init in component state_variables (dimensionless)"
    legend_constants[268] = "PAR1_init in component state_variables (mmHg)"
    legend_constants[269] = "PC_init in component state_variables (mmHg)"
    legend_constants[270] = "PLUR_init in component state_variables (mOsm)"
    legend_constants[271] = "PPR1_init in component state_variables (gram)"
    legend_constants[272] = "PRP_init in component state_variables (gram)"
    legend_constants[273] = "QO2T_init in component state_variables (mL)"
    legend_constants[274] = "QOM1_init in component state_variables (mL)"
    legend_constants[275] = "RNAUG3_init in component state_variables (dimensionless)"
    legend_constants[276] = "TSP_init in component state_variables (gram)"
    legend_constants[277] = "TVD_init in component state_variables (L_per_minute)"
    legend_constants[278] = "VAS1_init in component state_variables (litre)"
    legend_constants[279] = "VIC_init in component state_variables (litre)"
    legend_constants[280] = "VLA1_init in component state_variables (litre)"
    legend_constants[281] = "VPA1_init in component state_variables (litre)"
    legend_constants[282] = "VPF1_init in component state_variables (litre)"
    legend_constants[283] = "VP_init in component state_variables (litre)"
    legend_constants[284] = "VRA1_init in component state_variables (litre)"
    legend_constants[285] = "VRC_init in component state_variables (litre)"
    legend_constants[286] = "VTS2_init in component state_variables (litre)"
    legend_constants[287] = "VTW_init in component state_variables (litre)"
    legend_constants[288] = "VV6_init in component state_variables (litre)"
    legend_constants[289] = "VV7_init in component state_variables (litre)"
    legend_constants[290] = "VVS1_init in component state_variables (litre)"
    legend_voi = "time in component environment (minute)"
    legend_algebraic[24] = "RBF in component actual_renal_blood_flow (L_per_minute)"
    legend_algebraic[2] = "MDFLW in component proximal_tubular_and_macula_densa_flow (L_per_minute)"
    legend_algebraic[44] = "NOD in component actual_Na_excretion_rate (monovalent_mEq_per_minute)"
    legend_algebraic[47] = "KOD in component actual_K_excretion_rate (monovalent_mEq_per_minute)"
    legend_algebraic[55] = "VUD in component actual_urine_volume (L_per_minute)"
    legend_constants[291] = "A1K in component parameter_values (minute)"
    legend_constants[292] = "A2K in component parameter_values (minute)"
    legend_constants[293] = "A3K in component parameter_values (minute)"
    legend_constants[294] = "A4K in component parameter_values (minute)"
    legend_constants[295] = "A4K2 in component parameter_values (minute)"
    legend_constants[296] = "AARK in component parameter_values (mmHg_minute_per_L)"
    legend_constants[297] = "AARLL in component parameter_values (mmHg_minute_per_L)"
    legend_constants[298] = "ADHINF in component parameter_values (dimensionless)"
    legend_constants[299] = "ADHKLL in component parameter_values (dimensionless)"
    legend_constants[300] = "ADHKUL in component parameter_values (dimensionless)"
    legend_constants[301] = "ADHPAM in component parameter_values (per_mmHg2)"
    legend_constants[302] = "ADHPUL in component parameter_values (mmHg)"
    legend_constants[303] = "ADHTC in component parameter_values (minute)"
    legend_constants[304] = "ADHVLL in component parameter_values (dimensionless)"
    legend_constants[305] = "ADHVUL in component parameter_values (dimensionless)"
    legend_constants[306] = "AH10 in component parameter_values (dimensionless)"
    legend_constants[307] = "AH11 in component parameter_values (minute)"
    legend_constants[308] = "AH9 in component parameter_values (per_mmHg)"
    legend_constants[309] = "AHMNAR in component parameter_values (dimensionless)"
    legend_constants[310] = "AHTHM in component parameter_values (dimensionless)"
    legend_constants[311] = "ALCLK in component parameter_values (dimensionless)"
    legend_constants[312] = "ALDINF in component parameter_values (dimensionless)"
    legend_constants[313] = "ALDKNS in component parameter_values (dimensionless)"
    legend_constants[314] = "ALDMM in component parameter_values (dimensionless)"
    legend_constants[315] = "AM1LL in component parameter_values (dimensionless)"
    legend_constants[316] = "AM1UL in component parameter_values (dimensionless)"
    legend_constants[317] = "AMCSNS in component parameter_values (dimensionless)"
    legend_constants[318] = "AMKM in component parameter_values (dimensionless)"
    legend_constants[319] = "AMKMUL in component parameter_values (dimensionless)"
    legend_constants[320] = "AMM1LM in component parameter_values (dimensionless)"
    legend_constants[321] = "AMM4 in component parameter_values (dimensionless)"
    legend_constants[322] = "AMNALL in component parameter_values (dimensionless)"
    legend_constants[323] = "AMNAM in component parameter_values (dimensionless)"
    legend_constants[324] = "AMNAUL in component parameter_values (dimensionless)"
    legend_constants[325] = "AMT in component parameter_values (minute)"
    legend_constants[326] = "ANCSNS in component parameter_values (dimensionless)"
    legend_constants[327] = "ANGINF in component parameter_values (dimensionless)"
    legend_constants[328] = "ANGKNS in component parameter_values (dimensionless)"
    legend_constants[329] = "ANMALD in component parameter_values (dimensionless)"
    legend_constants[330] = "ANMAM in component parameter_values (dimensionless)"
    legend_constants[331] = "ANMARL in component parameter_values (dimensionless)"
    legend_constants[332] = "ANMEM in component parameter_values (dimensionless)"
    legend_constants[333] = "ANMKEL in component parameter_values (dimensionless)"
    legend_constants[334] = "ANMKEM in component parameter_values (dimensionless)"
    legend_constants[335] = "ANMLL in component parameter_values (dimensionless)"
    legend_constants[336] = "ANMNAM in component parameter_values (dimensionless)"
    legend_constants[337] = "ANMSLT in component parameter_values (dimensionless)"
    legend_constants[338] = "ANMTM in component parameter_values (dimensionless)"
    legend_constants[339] = "ANMUL in component parameter_values (dimensionless)"
    legend_constants[340] = "ANPTC in component parameter_values (minute)"
    legend_constants[341] = "ANPXAF in component parameter_values (mmHg_minute_per_L)"
    legend_constants[342] = "ANPXUL in component parameter_values (dimensionless)"
    legend_constants[343] = "ANT in component parameter_values (minute)"
    legend_constants[344] = "ANULL in component parameter_values (dimensionless)"
    legend_constants[345] = "ANUM in component parameter_values (dimensionless)"
    legend_constants[346] = "ANUVM in component parameter_values (dimensionless)"
    legend_constants[347] = "ANV in component parameter_values (minute)"
    legend_constants[348] = "ANXM in component parameter_values (dimensionless)"
    legend_constants[349] = "ANY in component parameter_values (litre)"
    legend_constants[350] = "AR1LM in component parameter_values (dimensionless)"
    legend_constants[351] = "AR2LM in component parameter_values (dimensionless)"
    legend_constants[352] = "ARF in component parameter_values (dimensionless)"
    legend_constants[353] = "AUC1 in component parameter_values (dimensionless)"
    legend_constants[354] = "AUDMP in component parameter_values (minute)"
    legend_constants[355] = "AUK in component parameter_values (per_minute)"
    legend_constants[356] = "AUL in component parameter_values (litre)"
    legend_constants[357] = "AULPM in component parameter_values (dimensionless)"
    legend_constants[358] = "AUM1 in component parameter_values (dimensionless)"
    legend_constants[359] = "AUM2 in component parameter_values (dimensionless)"
    legend_constants[360] = "AUMAX in component parameter_values (dimensionless)"
    legend_constants[361] = "AUMIN in component parameter_values (dimensionless)"
    legend_constants[362] = "AUMK1 in component parameter_values (dimensionless)"
    legend_constants[363] = "AUN1 in component parameter_values (dimensionless)"
    legend_constants[364] = "AURG in component parameter_values (dimensionless)"
    legend_constants[365] = "AUS in component parameter_values (dimensionless)"
    legend_constants[366] = "AUSLP in component parameter_values (dimensionless)"
    legend_constants[367] = "AUTO in component parameter_values (dimensionless)"
    legend_constants[368] = "AUTOGN in component parameter_values (dimensionless)"
    legend_constants[369] = "AUTOSN in component parameter_values (dimensionless)"
    legend_constants[370] = "AUX in component parameter_values (dimensionless)"
    legend_constants[371] = "BAROTC in component parameter_values (minute)"
    legend_constants[372] = "CFC in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[373] = "CKEEX in component parameter_values (dimensionless)"
    legend_constants[374] = "CMPTSS in component parameter_values (dimensionless)"
    legend_constants[375] = "CN2 in component parameter_values (per_mmHg)"
    legend_constants[376] = "CN7 in component parameter_values (dimensionless)"
    legend_constants[377] = "CNR in component parameter_values (monovalent_mEq_per_litre)"
    legend_constants[378] = "CPF in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[379] = "CPK in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[380] = "CPR in component parameter_values (gram_per_L)"
    legend_constants[381] = "CV in component parameter_values (L_per_mmHg)"
    legend_constants[382] = "CRRFLX in component parameter_values (mmHg)"
    legend_constants[383] = "DIURET in component parameter_values (dimensionless)"
    legend_constants[384] = "DHDTR in component parameter_values (per_mmHg_per_minute)"
    legend_constants[385] = "DTNAR in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[386] = "DTNARL in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[387] = "EARK in component parameter_values (mmHg_minute_per_L)"
    legend_constants[388] = "EARLL in component parameter_values (mmHg_minute_per_L)"
    legend_constants[389] = "EFAFR in component parameter_values (dimensionless)"
    legend_constants[390] = "EXC in component parameter_values (dimensionless)"
    legend_constants[391] = "EXCML in component parameter_values (dimensionless)"
    legend_constants[392] = "EXCXP in component parameter_values (dimensionless)"
    legend_constants[393] = "EXCXP2 in component parameter_values (dimensionless)"
    legend_constants[394] = "EXE in component parameter_values (mmHg)"
    legend_constants[395] = "GCOPF in component parameter_values (per_mmHg)"
    legend_constants[396] = "GFLC in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[397] = "GFNDMP in component parameter_values (dimensionless)"
    legend_constants[398] = "GFNLL in component parameter_values (L_per_minute)"
    legend_constants[399] = "GPPD in component parameter_values (dimensionless)"
    legend_constants[400] = "HM6 in component parameter_values (mmHg)"
    legend_constants[401] = "HM8 in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[402] = "HTAUML in component parameter_values (dimensionless)"
    legend_constants[403] = "KORGN in component parameter_values (dimensionless)"
    legend_constants[404] = "KORNER in component parameter_values (dimensionless)"
    legend_constants[405] = "KORREN in component parameter_values (dimensionless)"
    legend_constants[406] = "KORTC in component parameter_values (minute)"
    legend_constants[407] = "LPDE in component parameter_values (dimensionless)"
    legend_constants[408] = "LPK in component parameter_values (L_per_minute)"
    legend_constants[409] = "LPPR in component parameter_values (gram_per_minute)"
    legend_constants[410] = "MDFL1 in component parameter_values (dimensionless)"
    legend_constants[411] = "MDFLKM in component parameter_values (monovalent_mEq_per_litre)"
    legend_constants[412] = "MDFLW2 in component parameter_values (dimensionless)"
    legend_constants[413] = "MDFLWX in component parameter_values (dimensionless)"
    legend_constants[414] = "MDMP in component parameter_values (dimensionless)"
    legend_constants[415] = "O2A in component parameter_values (dimensionless)"
    legend_constants[416] = "O2CHMO in component parameter_values (per_mmHg)"
    legend_constants[417] = "OMM in component parameter_values (mL_per_minute)"
    legend_constants[418] = "PA4 in component parameter_values (dimensionless)"
    legend_constants[419] = "PAEX in component parameter_values (dimensionless)"
    legend_constants[420] = "PCE in component parameter_values (dimensionless)"
    legend_constants[421] = "PCR in component parameter_values (mmHg)"
    legend_constants[422] = "PR1LL in component parameter_values (mmHg)"
    legend_constants[423] = "PGHF in component parameter_values (L_mmHg_per_gram)"
    legend_constants[424] = "PK2 in component parameter_values (mmHg_per_mL)"
    legend_constants[425] = "PL2 in component parameter_values (L_mL_per_minute_per_mmHg)"
    legend_constants[426] = "PLDF in component parameter_values (mmHg)"
    legend_constants[427] = "PM5 in component parameter_values (per_mmHg)"
    legend_constants[428] = "PO2ADV in component parameter_values (dimensionless)"
    legend_constants[429] = "POK in component parameter_values (dimensionless)"
    legend_constants[430] = "POM in component parameter_values (dimensionless)"
    legend_constants[431] = "POM2 in component parameter_values (dimensionless)"
    legend_constants[432] = "PON in component parameter_values (dimensionless)"
    legend_constants[433] = "POR in component parameter_values (mmHg)"
    legend_constants[434] = "POZ in component parameter_values (dimensionless)"
    legend_constants[435] = "PXTP in component parameter_values (mmHg)"
    legend_constants[436] = "QAOLM in component parameter_values (dimensionless)"
    legend_constants[437] = "QRF in component parameter_values (L_per_minute)"
    legend_constants[438] = "RABSC in component parameter_values (per_mmHg)"
    legend_constants[439] = "RAM in component parameter_values (mmHg_minute_per_L)"
    legend_constants[440] = "RAPRSP in component parameter_values (mmHg)"
    legend_constants[441] = "RAR in component parameter_values (mmHg_minute_per_L)"
    legend_constants[442] = "RCDFDP in component parameter_values (minute)"
    legend_constants[443] = "RCDFPC in component parameter_values (dimensionless)"
    legend_constants[444] = "REK in component parameter_values (dimensionless)"
    legend_constants[445] = "RFABKM in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[446] = "RFABDM in component parameter_values (dimensionless)"
    legend_constants[447] = "RFABDP in component parameter_values (dimensionless)"
    legend_constants[448] = "RFCDFT in component parameter_values (dimensionless)"
    legend_constants[449] = "RKC in component parameter_values (per_minute)"
    legend_constants[450] = "RNAGTC in component parameter_values (minute)"
    legend_constants[451] = "RNAUAD in component parameter_values (per_minute)"
    legend_constants[452] = "RPS in component parameter_values (dimensionless)"
    legend_constants[453] = "RTPPR in component parameter_values (dimensionless)"
    legend_constants[454] = "RTPPRS in component parameter_values (mmHg)"
    legend_constants[455] = "RTSPRS in component parameter_values (mmHg)"
    legend_constants[456] = "RVRS in component parameter_values (mmHg_minute_per_L)"
    legend_constants[457] = "RVSM in component parameter_values (mmHg_minute_per_L)"
    legend_constants[458] = "SR in component parameter_values (dimensionless)"
    legend_constants[459] = "SR2 in component parameter_values (dimensionless)"
    legend_constants[460] = "SRK in component parameter_values (minute)"
    legend_constants[461] = "SRK2 in component parameter_values (minute)"
    legend_constants[462] = "STA in component parameter_values (dimensionless)"
    legend_constants[463] = "TENSGN in component parameter_values (dimensionless)"
    legend_constants[464] = "TENSTC in component parameter_values (minute)"
    legend_constants[465] = "TIMETR in component parameter_values (minute)"
    legend_constants[466] = "TRNSFS in component parameter_values (dimensionless)"
    legend_constants[467] = "TRPL in component parameter_values (L_per_minute)"
    legend_constants[468] = "TSSLML in component parameter_values (dimensionless)"
    legend_constants[469] = "TSSLTC in component parameter_values (per_minute)"
    legend_constants[470] = "TVDDL in component parameter_values (minute)"
    legend_constants[471] = "U in component parameter_values (dimensionless)"
    legend_constants[472] = "VID1 in component parameter_values (L_per_minute)"
    legend_constants[473] = "VIDML in component parameter_values (litre2_per_monovalent_mEq_per_minute)"
    legend_constants[474] = "VNTSTM in component parameter_values (dimensionless)"
    legend_constants[475] = "VP1 in component parameter_values (dimensionless)"
    legend_constants[476] = "VPTISS in component parameter_values (litre)"
    legend_constants[477] = "VTSF in component parameter_values (litre)"
    legend_constants[478] = "VV9 in component parameter_values (litre)"
    legend_constants[479] = "X in component parameter_values (dimensionless)"
    legend_constants[480] = "Z in component parameter_values (dimensionless)"
    legend_constants[481] = "Z4 in component parameter_values (dimensionless)"
    legend_constants[482] = "Z5 in component parameter_values (dimensionless)"
    legend_constants[483] = "Z6 in component parameter_values (dimensionless)"
    legend_constants[484] = "Z7 in component parameter_values (dimensionless)"
    legend_constants[485] = "Z10 in component parameter_values (mmHg)"
    legend_constants[486] = "Z11 in component parameter_values (per_mmHg2)"
    legend_constants[487] = "Z12 in component parameter_values (dimensionless)"
    legend_constants[488] = "Z13 in component parameter_values (dimensionless)"
    legend_constants[489] = "Z14 in component parameter_values (dimensionless)"
    legend_constants[490] = "Z16 in component parameter_values (dimensionless)"
    legend_constants[491] = "Z18 in component parameter_values (dimensionless)"
    legend_constants[492] = "Z19 in component parameter_values (dimensionless)"
    legend_constants[493] = "KID in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[494] = "URFORM in component parameter_values (mOsm_per_minute)"
    legend_constants[495] = "AUV in component parameter_values (dimensionless)"
    legend_constants[496] = "AUY in component parameter_values (dimensionless)"
    legend_constants[497] = "O2M in component parameter_values (mL_per_minute)"
    legend_constants[498] = "NID in component parameter_values (monovalent_mEq_per_minute)"
    legend_constants[499] = "ATRFBM in component parameter_values (dimensionless)"
    legend_constants[500] = "GBL in component parameter_values (mmHg)"
    legend_constants[501] = "RNAUGN in component parameter_values (minute_per_L)"
    legend_constants[502] = "RNAULL in component parameter_values (dimensionless)"
    legend_constants[503] = "RNAUUL in component parameter_values (dimensionless)"
    legend_constants[504] = "HSR in component parameter_values (dimensionless)"
    legend_constants[505] = "HSL in component parameter_values (dimensionless)"
    legend_constants[506] = "HMK in component parameter_values (dimensionless)"
    legend_constants[507] = "PO2AMB in component parameter_values (mmHg)"
    legend_constants[508] = "HKM in component parameter_values (dimensionless)"
    legend_constants[509] = "DR in component parameter_values (L_per_minute)"
    legend_constants[510] = "ANPKNS in component parameter_values (dimensionless)"
    legend_constants[511] = "RMULT1 in component parameter_values (dimensionless)"
    legend_constants[512] = "GLPCA in component parameter_values (mmHg)"
    legend_constants[513] = "RFN in component parameter_values (L_per_minute)"
    legend_constants[514] = "RFABX in component parameter_values (dimensionless)"
    legend_constants[515] = "ANPINF in component parameter_values (dimensionless)"
    legend_constants[516] = "FIS in component parameter_values (L_per_minute_per_mmHg)"
    legend_constants[517] = "CPPD in component parameter_values (gram_per_L)"
    legend_constants[518] = "TRRBC in component parameter_values (L_per_minute)"
    legend_constants[519] = "HYL in component parameter_values (gram)"
    legend_constants[520] = "ATRVM in component parameter_values (litre)"
    legend_constants[521] = "ADHC_init in component state_variables (dimensionless)"
    legend_constants[522] = "AHY_init in component state_variables (dimensionless)"
    legend_constants[523] = "AMC_init in component state_variables (dimensionless)"
    legend_constants[524] = "AMM1T_init in component state_variables (dimensionless)"
    legend_constants[525] = "AMM2_init in component state_variables (dimensionless)"
    legend_constants[526] = "ANC_init in component state_variables (dimensionless)"
    legend_constants[527] = "ANPC_init in component state_variables (dimensionless)"
    legend_constants[528] = "ANX1_init in component state_variables (dimensionless)"
    legend_constants[529] = "AR1T_init in component state_variables (dimensionless)"
    legend_constants[530] = "AR2T_init in component state_variables (dimensionless)"
    legend_constants[531] = "AR3T_init in component state_variables (dimensionless)"
    legend_constants[532] = "AU1_init in component state_variables (dimensionless)"
    legend_constants[533] = "AU4_init in component state_variables (dimensionless)"
    legend_constants[534] = "AU6_init in component state_variables (dimensionless)"
    legend_constants[535] = "DTKA_init in component state_variables (monovalent_mEq_per_minute)"
    legend_constants[536] = "HMD1_init in component state_variables (dimensionless)"
    legend_constants[537] = "HPL_init in component state_variables (dimensionless)"
    legend_constants[538] = "HPR_init in component state_variables (dimensionless)"
    legend_constants[539] = "KTOT_init in component state_variables (monovalent_mEq)"
    legend_constants[540] = "NAE_init in component state_variables (monovalent_mEq)"
    legend_constants[541] = "O2VAD1_init in component state_variables (dimensionless)"
    legend_constants[542] = "OSV_init in component state_variables (dimensionless)"
    legend_constants[543] = "OVA_init in component state_variables (mL_per_L)"
    legend_constants[544] = "OVS_init in component state_variables (dimensionless)"
    legend_constants[545] = "PAR1_init in component state_variables (mmHg)"
    legend_constants[546] = "PC_init in component state_variables (mmHg)"
    legend_constants[547] = "PLUR_init in component state_variables (mOsm)"
    legend_constants[548] = "PPR1_init in component state_variables (gram)"
    legend_constants[549] = "PRP_init in component state_variables (gram)"
    legend_constants[550] = "QO2T_init in component state_variables (mL)"
    legend_constants[551] = "QOM1_init in component state_variables (mL)"
    legend_constants[552] = "RNAUG3_init in component state_variables (dimensionless)"
    legend_constants[553] = "TSP_init in component state_variables (gram)"
    legend_constants[554] = "TVD_init in component state_variables (L_per_minute)"
    legend_constants[555] = "VAS1_init in component state_variables (litre)"
    legend_constants[556] = "VIC_init in component state_variables (litre)"
    legend_constants[557] = "VLA1_init in component state_variables (litre)"
    legend_constants[558] = "VPA1_init in component state_variables (litre)"
    legend_constants[559] = "VPF1_init in component state_variables (litre)"
    legend_constants[560] = "VP_init in component state_variables (litre)"
    legend_constants[561] = "VRA1_init in component state_variables (litre)"
    legend_constants[562] = "VRC_init in component state_variables (litre)"
    legend_constants[563] = "VTS2_init in component state_variables (litre)"
    legend_constants[564] = "VTW_init in component state_variables (litre)"
    legend_constants[565] = "VV6_init in component state_variables (litre)"
    legend_constants[566] = "VV7_init in component state_variables (litre)"
    legend_constants[567] = "VVS1_init in component state_variables (litre)"
    legend_algebraic[0] = "PAR in component perfusion_pressure (mmHg)"
    legend_states[0] = "PAR1 in component perfusion_pressure (mmHg)"
    legend_algebraic[3] = "RNAUG2 in component renal_autoregulatory_feedback_factor (dimensionless)"
    legend_algebraic[4] = "RNAUG1 in component renal_autoregulatory_feedback_factor (dimensionless)"
    legend_algebraic[5] = "RNAUG1T in component renal_autoregulatory_feedback_factor (dimensionless)"
    legend_states[1] = "RNAUG3 in component renal_autoregulatory_feedback_factor (dimensionless)"
    legend_constants[569] = "AUMK in component autonomic_effect_on_AAR (dimensionless)"
    legend_constants[568] = "AUMKT in component autonomic_effect_on_AAR (dimensionless)"
    legend_constants[571] = "ANMAR in component angiotensin_effect_on_AAR (dimensionless)"
    legend_constants[570] = "ANMAR1 in component angiotensin_effect_on_AAR (dimensionless)"
    legend_algebraic[6] = "AAR1 in component AAR_calculation (mmHg_minute_per_L)"
    legend_algebraic[7] = "AAR in component atrial_natriuretic_peptide_effect_on_AAR (mmHg_minute_per_L)"
    legend_algebraic[8] = "AART in component atrial_natriuretic_peptide_effect_on_AAR (mmHg_minute_per_L)"
    legend_constants[572] = "AUMK2 in component autonomic_effect_on_EAR (dimensionless)"
    legend_constants[573] = "ANMER in component angiotensin_effect_on_EAR (dimensionless)"
    legend_algebraic[9] = "RNAUG4 in component effect_of_renal_autoregulatory_feedback_on_EAR (dimensionless)"
    legend_algebraic[10] = "EAR in component EAR_calculation (mmHg_minute_per_L)"
    legend_algebraic[11] = "EAR1 in component EAR_calculation (mmHg_minute_per_L)"
    legend_algebraic[12] = "RR in component total_renal_resistance (mmHg_minute_per_L)"
    legend_algebraic[13] = "RFN in component normal_renal_blood_flow (L_per_minute)"
    legend_algebraic[14] = "GFN in component glomerular_filtration_rate (L_per_minute)"
    legend_algebraic[15] = "GLPC in component glomerular_colloid_osmotic_pressure (mmHg)"
    legend_algebraic[16] = "EFAFPR in component glomerular_colloid_osmotic_pressure (dimensionless)"
    legend_algebraic[17] = "EFAFPR1 in component glomerular_colloid_osmotic_pressure (dimensionless)"
    legend_algebraic[18] = "GLP in component glomerular_pressure (mmHg)"
    legend_algebraic[19] = "APD in component glomerular_pressure (mmHg)"
    legend_algebraic[25] = "GFR in component glomerular_filtration_rate (L_per_minute)"
    legend_algebraic[20] = "PFL in component glomerular_filtration_rate (mmHg)"
    legend_algebraic[21] = "GFN1 in component glomerular_filtration_rate (L_per_minute)"
    legend_algebraic[49] = "UROD in component actual_urea_excretion_rate (mOsm_per_minute)"
    legend_states[2] = "PLUR in component glomerular_urea_concentration (mOsm)"
    legend_algebraic[22] = "PTFL in component proximal_tubular_and_macula_densa_flow (L_per_minute)"
    legend_algebraic[23] = "MDFLWT in component proximal_tubular_and_macula_densa_flow (L_per_minute)"
    legend_algebraic[27] = "RTSPPC in component renal_tissue_osmotic_pressure (mmHg)"
    legend_algebraic[26] = "RTSPPC1 in component renal_tissue_osmotic_pressure (mmHg)"
    legend_algebraic[1] = "PLURC in component plasma_urea_concentration (mOsm_per_litre)"
    legend_algebraic[28] = "RCPRS in component peritubular_capillary_pressure (mmHg)"
    legend_algebraic[33] = "RFABD in component peritubular_capillary_reabsorption_factor (dimensionless)"
    legend_algebraic[29] = "RABSPR in component peritubular_capillary_reabsorption_factor (mmHg)"
    legend_algebraic[30] = "RFAB1 in component peritubular_capillary_reabsorption_factor (dimensionless)"
    legend_algebraic[31] = "RFAB in component peritubular_capillary_reabsorption_factor (dimensionless)"
    legend_algebraic[32] = "RFABD1 in component peritubular_capillary_reabsorption_factor (dimensionless)"
    legend_algebraic[34] = "DTNAI in component distal_tubular_Na_delivery (monovalent_mEq_per_minute)"
    legend_algebraic[36] = "DTNARA in component Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)"
    legend_algebraic[35] = "DTNARA1 in component Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)"
    legend_constants[575] = "DTNANG in component angiotensin_induced_Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)"
    legend_constants[574] = "DTNANG1 in component angiotensin_induced_Na_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)"
    legend_algebraic[37] = "DTKI in component distal_tubular_K_delivery (monovalent_mEq_per_minute)"
    legend_algebraic[38] = "RFABK in component effect_of_physical_forces_on_distal_K_reabsorption (monovalent_mEq_per_minute)"
    legend_algebraic[40] = "MDFLK in component effect_of_fluid_flow_on_distal_K_reabsorption (monovalent_mEq_per_minute)"
    legend_algebraic[39] = "MDFLK1 in component effect_of_fluid_flow_on_distal_K_reabsorption (monovalent_mEq_per_minute)"
    legend_algebraic[46] = "KODN in component normal_K_excretion (monovalent_mEq_per_minute)"
    legend_algebraic[54] = "VUDN in component normal_urine_volume (L_per_minute)"
    legend_states[3] = "DTKA in component K_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)"
    legend_algebraic[41] = "DTKSC in component K_secretion_from_distal_tubules (monovalent_mEq_per_minute)"
    legend_constants[576] = "ANMKE1 in component K_secretion_from_distal_tubules (dimensionless)"
    legend_constants[577] = "ANMKE in component K_secretion_from_distal_tubules (dimensionless)"
    legend_algebraic[43] = "NODN in component normal_Na_excretion (monovalent_mEq_per_minute)"
    legend_algebraic[42] = "NODN1 in component normal_Na_excretion (monovalent_mEq_per_minute)"
    legend_algebraic[45] = "KODN1 in component normal_K_excretion (monovalent_mEq_per_minute)"
    legend_algebraic[48] = "DTURI in component normal_urea_excretion (mOsm_per_minute)"
    legend_algebraic[50] = "OSMOPN1 in component normal_osmolar_and_water_excretion (mOsm_per_minute)"
    legend_algebraic[51] = "OSMOPN in component normal_osmolar_and_water_excretion (mOsm_per_minute)"
    legend_algebraic[52] = "OSMOP1T in component normal_urine_volume (mOsm_per_minute)"
    legend_algebraic[53] = "OSMOP1 in component normal_urine_volume (mOsm_per_minute)"
    legend_rates[0] = "d/dt PAR1 in component perfusion_pressure (mmHg)"
    legend_rates[1] = "d/dt RNAUG3 in component renal_autoregulatory_feedback_factor (dimensionless)"
    legend_rates[2] = "d/dt PLUR in component glomerular_urea_concentration (mOsm)"
    legend_rates[3] = "d/dt DTKA in component K_reabsorption_into_distal_tubules (monovalent_mEq_per_minute)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 103.525
    constants[1] = 1.00066
    constants[2] = 0.987545
    constants[3] = 1.0
    constants[4] = 1.0
    constants[5] = 0.39984739
    constants[6] = 29.9941
    constants[7] = 39.8952
    constants[8] = 142.035
    constants[9] = 1.0
    constants[10] = 1.0
    constants[11] = 4.44092
    constants[12] = 1.037
    constants[13] = 1.0
    constants[14] = 0.5
    constants[15] = 60
    constants[16] = 40000
    constants[17] = 0.1
    constants[18] = 40000
    constants[19] = 1
    constants[20] = 4
    constants[21] = 0
    constants[22] = 0.2
    constants[23] = 5
    constants[24] = 0.3
    constants[25] = 85
    constants[26] = 15
    constants[27] = 0.93617
    constants[28] = 2.5
    constants[29] = 0.333
    constants[30] = 1000
    constants[31] = 1
    constants[32] = 0.3
    constants[33] = 2
    constants[34] = 0.3
    constants[35] = 0
    constants[36] = 0
    constants[37] = 2.5
    constants[38] = 0
    constants[39] = 5
    constants[40] = 0.65
    constants[41] = 0.5
    constants[42] = 12
    constants[43] = 0.005
    constants[44] = 0.005
    constants[45] = 0.04
    constants[46] = 0.8
    constants[47] = 15
    constants[48] = 60
    constants[49] = 0.4
    constants[50] = 0
    constants[51] = 0
    constants[52] = 2.5
    constants[53] = 1.4
    constants[54] = 0.86
    constants[55] = 1.6
    constants[56] = 0.3
    constants[57] = 2
    constants[58] = 0.7
    constants[59] = 1
    constants[60] = 2
    constants[61] = 1.5
    constants[62] = 1.8
    constants[63] = 4
    constants[64] = 1.5
    constants[65] = 10
    constants[66] = 12
    constants[67] = 0.8
    constants[68] = 6
    constants[69] = 0
    constants[70] = 5000
    constants[71] = 0
    constants[72] = -0.2
    constants[73] = 0.005
    constants[74] = 0.005
    constants[75] = 0.5
    constants[76] = 0.3
    constants[77] = 0.3
    constants[78] = 0.004
    constants[79] = 1.5
    constants[80] = 0
    constants[81] = 3
    constants[82] = 1
    constants[83] = 5.0
    constants[84] = 0.4
    constants[85] = 0.3
    constants[86] = 0.5
    constants[87] = 1.0
    constants[88] = 1
    constants[89] = 1.5
    constants[90] = 0
    constants[91] = 7
    constants[92] = 0.9
    constants[93] = 1
    constants[94] = 0.16
    constants[95] = 0.01167
    constants[96] = 4
    constants[97] = 2
    constants[98] = 0.0212
    constants[99] = 0.2
    constants[100] = 139
    constants[101] = 0.0003
    constants[102] = 0.000253
    constants[103] = 40
    constants[104] = 0.1
    constants[105] = 0
    constants[106] = 1
    constants[107] = 0.05
    constants[108] = 0.675
    constants[109] = 1e-06
    constants[110] = 1
    constants[111] = 24
    constants[112] = 0
    constants[113] = 1
    constants[114] = 0.01
    constants[115] = 1.0
    constants[116] = 0.17
    constants[117] = 0
    constants[118] = 0.8092
    constants[119] = 0.0208333
    constants[120] = 3
    constants[121] = 0.001
    constants[122] = 1.0
    constants[123] = 1850
    constants[124] = 4.714e-08
    constants[125] = 0.4
    constants[126] = 1
    constants[127] = 0
    constants[128] = 0
    constants[129] = 10000
    constants[130] = 8
    constants[131] = 2.728e-14
    constants[132] = 0.03
    constants[133] = 10
    constants[134] = 0.667
    constants[135] = 0.005
    constants[136] = 0.01
    constants[137] = 0
    constants[138] = 0.1
    constants[139] = 0.01
    constants[140] = 57.1
    constants[141] = 1
    constants[142] = 2
    constants[143] = 1
    constants[144] = 15
    constants[145] = 0
    constants[146] = -2
    constants[147] = 0.79167
    constants[148] = 1.8
    constants[149] = 4.2
    constants[150] = 30
    constants[151] = 0.001
    constants[152] = 0.1
    constants[153] = 0.04
    constants[154] = 2
    constants[155] = 0.1
    constants[156] = 35
    constants[157] = 2
    constants[158] = 8
    constants[159] = 0.2
    constants[160] = 0.15
    constants[161] = 0.5
    constants[162] = 96.3
    constants[163] = 0
    constants[164] = 30.52
    constants[165] = 2000
    constants[166] = 0
    constants[167] = 1
    constants[168] = 0.03
    constants[169] = 0.3
    constants[170] = 1
    constants[171] = 0
    constants[172] = 5.8e-06
    constants[173] = 15
    constants[174] = 0
    constants[175] = 0
    constants[176] = 0.9
    constants[177] = 15.2
    constants[178] = 6
    constants[179] = 19.167
    constants[180] = 1
    constants[181] = 1
    constants[182] = 1
    constants[183] = 5
    constants[184] = 10000
    constants[185] = 0
    constants[186] = 0
    constants[187] = 0.05
    constants[188] = 0
    constants[189] = 0
    constants[190] = 0
    constants[191] = 0.15
    constants[192] = 0.005
    constants[193] = 30
    constants[194] = 4
    constants[195] = 0.01
    constants[196] = 0.01
    constants[197] = 1
    constants[198] = 0.01
    constants[199] = 0.0175
    constants[200] = 6
    constants[201] = 2.51
    constants[202] = 4
    constants[203] = 1
    constants[204] = 0.5
    constants[205] = 0.3
    constants[206] = 20
    constants[207] = 5
    constants[208] = 45
    constants[209] = 0.01
    constants[210] = 5
    constants[211] = 0.625
    constants[212] = 5
    constants[213] = 5
    constants[214] = 5
    constants[215] = 5
    constants[216] = 0.08
    constants[217] = 0.24
    constants[218] = 0.55
    constants[219] = 0
    constants[220] = 164
    constants[221] = 0.1
    constants[222] = 0
    constants[223] = 0
    constants[224] = 0.6
    constants[225] = 0.3
    constants[226] = 10
    constants[227] = 1
    constants[228] = 1
    constants[229] = 90
    constants[230] = 150
    constants[231] = 0.53333
    constants[232] = 0
    constants[233] = 0
    constants[234] = 1
    constants[235] = 1.0
    constants[236] = 1.22057
    constants[237] = 0.8
    constants[238] = 0
    constants[239] = 0
    constants[240] = 31.9719
    constants[241] = 0
    constants[242] = 60
    constants[243] = 0
    constants[244] = 1.0
    constants[245] = 0.301963
    constants[246] = 1.0
    constants[247] = 1.00269
    constants[248] = 1.09071
    constants[249] = 0.859476
    constants[250] = 1.0
    constants[251] = 0
    constants[252] = 1.02127
    constants[253] = 1.01179
    constants[254] = 1.1448
    constants[255] = 1.00007
    constants[256] = -0.060024
    constants[257] = 1.00132
    constants[258] = 0.0367573
    constants[259] = 1
    constants[260] = 1.00163
    constants[261] = 1.00237
    constants[262] = 3622.54
    constants[263] = 2109.91
    constants[264] = 2.368e-07
    constants[265] = 0.694163
    constants[266] = 204.497
    constants[267] = 0.699673
    constants[268] = 103.525
    constants[269] = 16.9144
    constants[270] = 159.549
    constants[271] = 0.419998
    constants[272] = 216.243
    constants[273] = 72.2362
    constants[274] = 48.0839
    constants[275] = 0
    constants[276] = 279.945
    constants[277] = 0.000980838
    constants[278] = 0.862514
    constants[279] = 25.0404
    constants[280] = 0.379883
    constants[281] = 0.38131
    constants[282] = 0.0123238
    constants[283] = 3.00449
    constants[284] = 0.100043
    constants[285] = 2.00439
    constants[286] = 0
    constants[287] = 39.8952
    constants[288] = 0.0101913
    constants[289] = 0.00366525
    constants[290] = 3.28246
    constants[291] = 0.5
    constants[292] = 60
    constants[293] = 40000
    constants[294] = 0.1
    constants[295] = 40000
    constants[296] = 1
    constants[297] = 4
    constants[298] = 0
    constants[299] = 0.2
    constants[300] = 5
    constants[301] = 0.3
    constants[302] = 85
    constants[303] = 15
    constants[304] = 0.93617
    constants[305] = 2.5
    constants[306] = 0.333
    constants[307] = 1000
    constants[308] = 1
    constants[309] = 0.3
    constants[310] = 2
    constants[311] = 0.3
    constants[312] = 0
    constants[313] = 0
    constants[314] = 2.5
    constants[315] = 0
    constants[316] = 5
    constants[317] = 0.65
    constants[318] = 0.5
    constants[319] = 12
    constants[320] = 0.005
    constants[321] = 0.005
    constants[322] = 0.04
    constants[323] = 0.8
    constants[324] = 15
    constants[325] = 60
    constants[326] = 0.4
    constants[327] = 0
    constants[328] = 0
    constants[329] = 2.5
    constants[330] = 1.4
    constants[331] = 0.86
    constants[332] = 1.6
    constants[333] = 0.3
    constants[334] = 2
    constants[335] = 0.7
    constants[336] = 1
    constants[337] = 2
    constants[338] = 1.5
    constants[339] = 1.8
    constants[340] = 4
    constants[341] = 1.5
    constants[342] = 10
    constants[343] = 12
    constants[344] = 0.8
    constants[345] = 6
    constants[346] = 0
    constants[347] = 5000
    constants[348] = 0
    constants[349] = -0.2
    constants[350] = 0.005
    constants[351] = 0.005
    constants[352] = 0.5
    constants[353] = 0.3
    constants[354] = 0.3
    constants[355] = 0.004
    constants[356] = 1.5
    constants[357] = 0
    constants[358] = 3
    constants[359] = 1
    constants[360] = 5.0
    constants[361] = 0.4
    constants[362] = 0.3
    constants[363] = 0.5
    constants[364] = 1.0
    constants[365] = 1
    constants[366] = 1.5
    constants[367] = 0
    constants[368] = 7
    constants[369] = 0.9
    constants[370] = 1
    constants[371] = 0.16
    constants[372] = 0.01167
    constants[373] = 4
    constants[374] = 2
    constants[375] = 0.0212
    constants[376] = 0.2
    constants[377] = 139
    constants[378] = 0.0003
    constants[379] = 0.000253
    constants[380] = 40
    constants[381] = 0.1
    constants[382] = 0
    constants[383] = 1
    constants[384] = 0.05
    constants[385] = 0.675
    constants[386] = 1e-06
    constants[387] = 1
    constants[388] = 24
    constants[389] = 0
    constants[390] = 1
    constants[391] = 0.01
    constants[392] = 1.0
    constants[393] = 0.17
    constants[394] = 0
    constants[395] = 0.8092
    constants[396] = 0.0208333
    constants[397] = 3
    constants[398] = 0.001
    constants[399] = 1.0
    constants[400] = 1850
    constants[401] = 4.714e-08
    constants[402] = 0.4
    constants[403] = 1
    constants[404] = 0
    constants[405] = 0
    constants[406] = 10000
    constants[407] = 8
    constants[408] = 2.728e-14
    constants[409] = 0.03
    constants[410] = 10
    constants[411] = 0.667
    constants[412] = 0.005
    constants[413] = 0.01
    constants[414] = 0
    constants[415] = 0.1
    constants[416] = 0.01
    constants[417] = 57.1
    constants[418] = 1
    constants[419] = 2
    constants[420] = 1
    constants[421] = 15
    constants[422] = 0
    constants[423] = -2
    constants[424] = 0.79167
    constants[425] = 1.8
    constants[426] = 4.2
    constants[427] = 30
    constants[428] = 0.001
    constants[429] = 0.1
    constants[430] = 0.04
    constants[431] = 2
    constants[432] = 0.1
    constants[433] = 35
    constants[434] = 2
    constants[435] = 8
    constants[436] = 0.2
    constants[437] = 0.15
    constants[438] = 0.5
    constants[439] = 96.3
    constants[440] = 0
    constants[441] = 30.52
    constants[442] = 2000
    constants[443] = 0
    constants[444] = 1
    constants[445] = 0.03
    constants[446] = 0.3
    constants[447] = 1
    constants[448] = 0
    constants[449] = 5.8e-06
    constants[450] = 15
    constants[451] = 0
    constants[452] = 0
    constants[453] = 0.9
    constants[454] = 15.2
    constants[455] = 6
    constants[456] = 19.167
    constants[457] = 1
    constants[458] = 1
    constants[459] = 1
    constants[460] = 5
    constants[461] = 10000
    constants[462] = 0
    constants[463] = 0
    constants[464] = 0.05
    constants[465] = 0
    constants[466] = 0
    constants[467] = 0
    constants[468] = 0.15
    constants[469] = 0.005
    constants[470] = 30
    constants[471] = 4
    constants[472] = 0.01
    constants[473] = 0.01
    constants[474] = 1
    constants[475] = 0.01
    constants[476] = 0.0175
    constants[477] = 6
    constants[478] = 2.51
    constants[479] = 4
    constants[480] = 1
    constants[481] = 0.5
    constants[482] = 0.3
    constants[483] = 20
    constants[484] = 5
    constants[485] = 45
    constants[486] = 0.01
    constants[487] = 5
    constants[488] = 0.625
    constants[489] = 5
    constants[490] = 5
    constants[491] = 5
    constants[492] = 5
    constants[493] = 0.08
    constants[494] = 0.24
    constants[495] = 0.55
    constants[496] = 0
    constants[497] = 164
    constants[498] = 0.1
    constants[499] = 0
    constants[500] = 0
    constants[501] = 0.6
    constants[502] = 0.3
    constants[503] = 10
    constants[504] = 1
    constants[505] = 1
    constants[506] = 90
    constants[507] = 150
    constants[508] = 0.53333
    constants[509] = 0
    constants[510] = 0
    constants[511] = 1
    constants[512] = 1.0
    constants[513] = 1.22057
    constants[514] = 0.8
    constants[515] = 0
    constants[516] = 0
    constants[517] = 31.9719
    constants[518] = 0
    constants[519] = 60
    constants[520] = 0
    constants[521] = 1.0
    constants[522] = 0.301963
    constants[523] = 1.0
    constants[524] = 1.00269
    constants[525] = 1.09071
    constants[526] = 0.859476
    constants[527] = 1.0
    constants[528] = 0
    constants[529] = 1.02127
    constants[530] = 1.01179
    constants[531] = 1.1448
    constants[532] = 1.00007
    constants[533] = -0.060024
    constants[534] = 1.00132
    constants[535] = 0.0367573
    constants[536] = 1
    constants[537] = 1.00163
    constants[538] = 1.00237
    constants[539] = 3622.54
    constants[540] = 2109.91
    constants[541] = 2.368e-07
    constants[542] = 0.694163
    constants[543] = 204.497
    constants[544] = 0.699673
    constants[545] = 103.525
    constants[546] = 16.9144
    constants[547] = 159.549
    constants[548] = 0.419998
    constants[549] = 216.243
    constants[550] = 72.2362
    constants[551] = 48.0839
    constants[552] = 0
    constants[553] = 279.945
    constants[554] = 0.000980838
    constants[555] = 0.862514
    constants[556] = 25.0404
    constants[557] = 0.379883
    constants[558] = 0.38131
    constants[559] = 0.0123238
    constants[560] = 3.00449
    constants[561] = 0.100043
    constants[562] = 2.00439
    constants[563] = 0
    constants[564] = 39.8952
    constants[565] = 0.0101913
    constants[566] = 0.00366525
    constants[567] = 3.28246
    constants[568] = (constants[1]-1.00000)*constants[352]+1.00000
    constants[569] = custom_piecewise([less(constants[568] , 0.800000), 0.800000 , True, constants[568]])
    constants[570] = (constants[2]-1.00000)*constants[330]+1.00000
    constants[571] = custom_piecewise([less(constants[570] , constants[331]), constants[331] , True, constants[570]])
    constants[572] = (constants[569]-1.00000)*constants[362]+1.00000
    constants[573] = (constants[2]-1.00000)*constants[332]+1.00000
    constants[574] = ((constants[2]-1.00000)*constants[336]+1.00000)*0.100000
    constants[575] = custom_piecewise([less(constants[574] , 0.00000), 0.00000 , True, constants[574]])
    constants[576] = (constants[2]-1.00000)*constants[334]+1.00000
    constants[577] = custom_piecewise([less(constants[576] , constants[333]), constants[333] , True, constants[576]])
    states[0] = constants[545]
    states[1] = constants[552]
    states[2] = constants[547]
    states[3] = constants[535]
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    rates[0] = ((100.000+(constants[0]-100.000)*constants[443])-states[0])/constants[442]
    algebraic[0] = custom_piecewise([greater(constants[440] , 0.00000) & less_equal(constants[448] , 0.00000), constants[440] , greater(constants[448] , 0.00000), states[0] , True, constants[0]-constants[500]])
    rootfind_0(voi, constants, rates, states, algebraic)
    rates[1] = (algebraic[3]-1.00000)*constants[451]
    algebraic[1] = states[2]/constants[7]
    algebraic[48] = (power(algebraic[14], 2.00000))*algebraic[1]*3.84000
    algebraic[49] = algebraic[48]*constants[444]
    rates[2] = constants[494]-algebraic[49]
    algebraic[34] = algebraic[2]*constants[8]*0.00616190
    algebraic[37] = (algebraic[34]*constants[11])/constants[8]
    algebraic[26] = algebraic[15]*constants[453]-constants[454]
    algebraic[27] = custom_piecewise([less(algebraic[26] , 1.00000), 1.00000 , True, algebraic[26]])
    algebraic[28] = ((algebraic[13]-1.20000)*constants[514]+1.20000)*constants[456]
    algebraic[29] = ((algebraic[15]+constants[455])-algebraic[28])-algebraic[27]
    algebraic[30] = algebraic[29]*constants[438]
    algebraic[31] = algebraic[30]
    algebraic[32] = (algebraic[31]-1.00000)*constants[446]+1.00000
    algebraic[33] = custom_piecewise([less(algebraic[32] , 0.000100000), 0.000100000 , True, algebraic[32]])
    algebraic[38] = (algebraic[33]-1.00000)*constants[445]
    algebraic[39] = (algebraic[2]-1.00000)*constants[411]+1.00000
    algebraic[40] = custom_piecewise([less(algebraic[39] , 0.100000), 0.100000 , True, algebraic[39]])
    algebraic[41] = ((power(constants[11]/4.40000, constants[373]))*constants[12]*0.0800000*algebraic[40])/constants[577]
    algebraic[45] = ((algebraic[37]+algebraic[41])-states[3])-algebraic[38]
    algebraic[46] = custom_piecewise([less(algebraic[45] , 0.00000), 0.00000 , True, algebraic[45]])
    algebraic[35] = ((constants[10]*algebraic[33]*constants[385])/constants[383])*((constants[9]-1.00000)*constants[309]+1.00000)
    algebraic[36] = custom_piecewise([less(algebraic[35] , constants[386]), constants[386] , True, algebraic[35]])
    algebraic[42] = (algebraic[34]-algebraic[36])-constants[575]
    algebraic[43] = custom_piecewise([less(algebraic[42] , 1.00000e-08), 1.00000e-08 , True, algebraic[42]])
    algebraic[50] = algebraic[48]+2.00000*(algebraic[43]+algebraic[46])
    algebraic[51] = custom_piecewise([greater(algebraic[50] , 0.600000), 0.600000 , True, algebraic[50]])
    algebraic[52] = algebraic[50]-0.600000
    algebraic[53] = custom_piecewise([less(algebraic[52] , 0.00000), 0.00000 , True, algebraic[52]])
    algebraic[54] = algebraic[51]/(600.000*constants[9])+algebraic[53]/360.000
    rates[3] = ((algebraic[46]/algebraic[54])*0.000451800-states[3])*1.00000
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[0] = custom_piecewise([greater(constants[440] , 0.00000) & less_equal(constants[448] , 0.00000), constants[440] , greater(constants[448] , 0.00000), states[0] , True, constants[0]-constants[500]])
    algebraic[1] = states[2]/constants[7]
    algebraic[48] = (power(algebraic[14], 2.00000))*algebraic[1]*3.84000
    algebraic[49] = algebraic[48]*constants[444]
    algebraic[34] = algebraic[2]*constants[8]*0.00616190
    algebraic[37] = (algebraic[34]*constants[11])/constants[8]
    algebraic[26] = algebraic[15]*constants[453]-constants[454]
    algebraic[27] = custom_piecewise([less(algebraic[26] , 1.00000), 1.00000 , True, algebraic[26]])
    algebraic[28] = ((algebraic[13]-1.20000)*constants[514]+1.20000)*constants[456]
    algebraic[29] = ((algebraic[15]+constants[455])-algebraic[28])-algebraic[27]
    algebraic[30] = algebraic[29]*constants[438]
    algebraic[31] = algebraic[30]
    algebraic[32] = (algebraic[31]-1.00000)*constants[446]+1.00000
    algebraic[33] = custom_piecewise([less(algebraic[32] , 0.000100000), 0.000100000 , True, algebraic[32]])
    algebraic[38] = (algebraic[33]-1.00000)*constants[445]
    algebraic[39] = (algebraic[2]-1.00000)*constants[411]+1.00000
    algebraic[40] = custom_piecewise([less(algebraic[39] , 0.100000), 0.100000 , True, algebraic[39]])
    algebraic[41] = ((power(constants[11]/4.40000, constants[373]))*constants[12]*0.0800000*algebraic[40])/constants[577]
    algebraic[45] = ((algebraic[37]+algebraic[41])-states[3])-algebraic[38]
    algebraic[46] = custom_piecewise([less(algebraic[45] , 0.00000), 0.00000 , True, algebraic[45]])
    algebraic[35] = ((constants[10]*algebraic[33]*constants[385])/constants[383])*((constants[9]-1.00000)*constants[309]+1.00000)
    algebraic[36] = custom_piecewise([less(algebraic[35] , constants[386]), constants[386] , True, algebraic[35]])
    algebraic[42] = (algebraic[34]-algebraic[36])-constants[575]
    algebraic[43] = custom_piecewise([less(algebraic[42] , 1.00000e-08), 1.00000e-08 , True, algebraic[42]])
    algebraic[50] = algebraic[48]+2.00000*(algebraic[43]+algebraic[46])
    algebraic[51] = custom_piecewise([greater(algebraic[50] , 0.600000), 0.600000 , True, algebraic[50]])
    algebraic[52] = algebraic[50]-0.600000
    algebraic[53] = custom_piecewise([less(algebraic[52] , 0.00000), 0.00000 , True, algebraic[52]])
    algebraic[54] = algebraic[51]/(600.000*constants[9])+algebraic[53]/360.000
    algebraic[24] = constants[444]*algebraic[13]
    algebraic[25] = algebraic[14]*constants[444]
    algebraic[44] = algebraic[43]*constants[444]
    algebraic[47] = algebraic[46]*constants[444]
    algebraic[55] = algebraic[54]*constants[444]
    return algebraic

initialGuess0 = None
def rootfind_0(voi, constants, rates, states, algebraic):
    """Calculate values of algebraic variables for DAE"""
    from scipy.optimize import fsolve
    global initialGuess0
    if initialGuess0 is None: initialGuess0 = ones(22)*0.1
    if not iterable(voi):
        soln = fsolve(residualSN_0, initialGuess0, args=(algebraic, voi, constants, rates, states), xtol=1E-6)
        initialGuess0 = soln
        algebraic[2] = soln[0]
        algebraic[3] = soln[1]
        algebraic[4] = soln[2]
        algebraic[5] = soln[3]
        algebraic[6] = soln[4]
        algebraic[7] = soln[5]
        algebraic[8] = soln[6]
        algebraic[9] = soln[7]
        algebraic[10] = soln[8]
        algebraic[11] = soln[9]
        algebraic[12] = soln[10]
        algebraic[13] = soln[11]
        algebraic[14] = soln[12]
        algebraic[15] = soln[13]
        algebraic[16] = soln[14]
        algebraic[17] = soln[15]
        algebraic[18] = soln[16]
        algebraic[19] = soln[17]
        algebraic[20] = soln[18]
        algebraic[21] = soln[19]
        algebraic[22] = soln[20]
        algebraic[23] = soln[21]
    else:
        for (i,t) in enumerate(voi):
            soln = fsolve(residualSN_0, initialGuess0, args=(algebraic[:,i], voi[i], constants, rates[:i], states[:,i]), xtol=1E-6)
            initialGuess0 = soln
            algebraic[2][i] = soln[0]
            algebraic[3][i] = soln[1]
            algebraic[4][i] = soln[2]
            algebraic[5][i] = soln[3]
            algebraic[6][i] = soln[4]
            algebraic[7][i] = soln[5]
            algebraic[8][i] = soln[6]
            algebraic[9][i] = soln[7]
            algebraic[10][i] = soln[8]
            algebraic[11][i] = soln[9]
            algebraic[12][i] = soln[10]
            algebraic[13][i] = soln[11]
            algebraic[14][i] = soln[12]
            algebraic[15][i] = soln[13]
            algebraic[16][i] = soln[14]
            algebraic[17][i] = soln[15]
            algebraic[18][i] = soln[16]
            algebraic[19][i] = soln[17]
            algebraic[20][i] = soln[18]
            algebraic[21][i] = soln[19]
            algebraic[22][i] = soln[20]
            algebraic[23][i] = soln[21]

def residualSN_0(algebraicCandidate, algebraic, voi, constants, rates, states):
    resid = array([0.0] * 22)
    algebraic[2] = algebraicCandidate[0]
    algebraic[3] = algebraicCandidate[1]
    algebraic[4] = algebraicCandidate[2]
    algebraic[5] = algebraicCandidate[3]
    algebraic[6] = algebraicCandidate[4]
    algebraic[7] = algebraicCandidate[5]
    algebraic[8] = algebraicCandidate[6]
    algebraic[9] = algebraicCandidate[7]
    algebraic[10] = algebraicCandidate[8]
    algebraic[11] = algebraicCandidate[9]
    algebraic[12] = algebraicCandidate[10]
    algebraic[13] = algebraicCandidate[11]
    algebraic[14] = algebraicCandidate[12]
    algebraic[15] = algebraicCandidate[13]
    algebraic[16] = algebraicCandidate[14]
    algebraic[17] = algebraicCandidate[15]
    algebraic[18] = algebraicCandidate[16]
    algebraic[19] = algebraicCandidate[17]
    algebraic[20] = algebraicCandidate[18]
    algebraic[21] = algebraicCandidate[19]
    algebraic[22] = algebraicCandidate[20]
    algebraic[23] = algebraicCandidate[21]
    resid[0] = (algebraic[5]-((algebraic[2]-1.00000)*constants[501]+1.00000))
    resid[1] = (algebraic[4]-(custom_piecewise([less(algebraic[5] , constants[502]), constants[502] , greater(algebraic[5] , constants[503]), constants[503] , True, algebraic[5]])))
    resid[2] = (algebraic[3]-(algebraic[4]-states[1]))
    resid[3] = (algebraic[6]-constants[296]*constants[4]*constants[569]*algebraic[3]*constants[571]*40.0000*constants[3])
    resid[4] = (algebraic[8]-((algebraic[6]-constants[13]*constants[341])+constants[341]))
    resid[5] = (algebraic[7]-(custom_piecewise([less(algebraic[8] , constants[297]), constants[297] , True, algebraic[8]])))
    resid[6] = (algebraic[9]-((algebraic[3]-1.00000)*constants[389]+1.00000))
    resid[7] = (algebraic[11]-43.3330*constants[387]*constants[573]*algebraic[9]*constants[3]*constants[572])
    resid[8] = (algebraic[10]-(custom_piecewise([less(algebraic[11] , constants[388]), constants[388] , True, algebraic[11]])))
    resid[9] = (algebraic[12]-(algebraic[7]+algebraic[10]))
    resid[10] = (algebraic[13]-algebraic[0]/algebraic[12])
    resid[11] = (algebraic[17]-(algebraic[13]*(1.00000-constants[5]))/(algebraic[13]*(1.00000-constants[5])-algebraic[14]))
    resid[12] = (algebraic[16]-(custom_piecewise([less(algebraic[17] , 1.00000), 1.00000 , True, algebraic[17]])))
    resid[13] = (algebraic[15]-(custom_piecewise([greater(constants[512] , 0.00000), (power(algebraic[16], 1.35000))*constants[6]*0.980000 , True, constants[6]+4.00000])))
    resid[14] = (algebraic[19]-algebraic[7]*algebraic[13])
    resid[15] = (algebraic[18]-(algebraic[0]-algebraic[19]))
    resid[16] = (algebraic[20]-((algebraic[18]-algebraic[15])-constants[435]))
    resid[17] = (algebraic[21]-algebraic[20]*constants[396])
    resid[18] = (algebraic[14]-(custom_piecewise([less(algebraic[21] , constants[398]), constants[398] , True, algebraic[21]])))
    resid[19] = (algebraic[22]-algebraic[14]*8.00000)
    resid[20] = (algebraic[23]-((algebraic[22]-1.00000)*constants[410]+1.00000))
    resid[21] = (algebraic[2]-(custom_piecewise([less(algebraic[23] , 0.00000), 0.00000 , True, algebraic[23]])))
    return resid

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

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

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

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

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

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

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

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