# Size of variable arrays: sizeAlgebraic = 126 sizeStates = 46 sizeConstants = 175 from math import * from numpy import * def createLegends(): legend_states = [""] * sizeStates legend_rates = [""] * sizeStates legend_algebraic = [""] * sizeAlgebraic legend_voi = "" legend_constants = [""] * sizeConstants legend_voi = "t in component main (second)" legend_constants[0] = "rho in component main (Js2_per_m5)" legend_constants[1] = "g in component main (m_per_s2)" legend_constants[2] = "theta_deg in component main (dim)" legend_constants[174] = "theta_rad in component main (radian)" legend_algebraic[0] = "z in component main (dim)" legend_constants[3] = "T in component main (second)" legend_algebraic[2] = "mt in component main (dim)" legend_algebraic[1] = "mta in component main (dim)" legend_constants[4] = "delay in component main (dim)" legend_constants[5] = "To_pk in component main (dim)" legend_states[0] = "q_LV in component main (litre)" legend_constants[6] = "q_LV_us in component main (litre)" legend_algebraic[6] = "u_LV in component main (kPa)" legend_algebraic[4] = "E_LV in component main (kPa_per_L)" legend_constants[7] = "E_LVmax in component main (kPa_per_L)" legend_constants[8] = "E_LVmin in component main (kPa_per_L)" legend_states[1] = "q_RV in component main (litre)" legend_constants[9] = "q_RV_us in component main (litre)" legend_algebraic[10] = "u_RV in component main (kPa)" legend_algebraic[8] = "E_RV in component main (kPa_per_L)" legend_constants[10] = "E_RVmax in component main (kPa_per_L)" legend_constants[11] = "E_RVmin in component main (kPa_per_L)" legend_states[2] = "q_LA in component main (litre)" legend_constants[12] = "q_LA_us in component main (litre)" legend_algebraic[12] = "u_LA in component main (kPa)" legend_constants[13] = "E_LA in component main (kPa_per_L)" legend_states[3] = "q_RA in component main (litre)" legend_constants[14] = "q_RA_us in component main (litre)" legend_algebraic[14] = "u_RA in component main (kPa)" legend_constants[15] = "E_RA in component main (kPa_per_L)" legend_algebraic[24] = "v_AV in component main (L_per_s)" legend_constants[16] = "R_AV in component main (kPa_s_per_L)" legend_algebraic[23] = "v_PV in component main (L_per_s)" legend_constants[17] = "R_PV in component main (kPa_s_per_L)" legend_algebraic[16] = "v_TV in component main (L_per_s)" legend_constants[18] = "R_TV in component main (kPa_s_per_L)" legend_algebraic[18] = "v_MV in component main (L_per_s)" legend_constants[19] = "R_MV in component main (kPa_s_per_L)" legend_states[4] = "q_pulmA in component main (litre)" legend_constants[20] = "q_pulmA_us in component main (litre)" legend_algebraic[20] = "u_pulmA in component main (kPa)" legend_constants[21] = "E_pulmA in component main (kPa_per_L)" legend_algebraic[27] = "v_lungA in component main (L_per_s)" legend_constants[22] = "R_lungA in component main (kPa_s_per_L)" legend_states[5] = "q_lungC in component main (litre)" legend_constants[23] = "q_lungC_us in component main (litre)" legend_algebraic[25] = "u_lungC in component main (kPa)" legend_constants[24] = "E_lungC in component main (kPa_per_L)" legend_algebraic[29] = "v_pulmV in component main (L_per_s)" legend_constants[25] = "R_pulmV in component main (kPa_s_per_L)" legend_states[6] = "q_AA in component main (litre)" legend_constants[26] = "q_AA_us in component main (litre)" legend_algebraic[21] = "u_AA in component main (kPa)" legend_constants[27] = "E_AA in component main (kPa_per_L)" legend_algebraic[28] = "v_brachiocephalicA in component main (L_per_s)" legend_constants[28] = "R_brachiocephalicA in component main (kPa_s_per_L)" legend_states[7] = "q_brachiocephalicA in component main (litre)" legend_constants[29] = "q_brachiocephalicA_us in component main (litre)" legend_algebraic[26] = "u_brachiocephalicA in component main (kPa)" legend_constants[30] = "E_brachiocephalicA in component main (kPa_per_L)" legend_algebraic[31] = "v_rSubclavianA in component main (L_per_s)" legend_constants[31] = "R_rSubclavianA in component main (kPa_s_per_L)" legend_algebraic[35] = "v_rCCA in component main (L_per_s)" legend_constants[32] = "R_rCCA in component main (kPa_s_per_L)" legend_states[8] = "q_rSubclavianA in component main (litre)" legend_constants[33] = "q_rSubclavianA_us in component main (litre)" legend_algebraic[30] = "u_rSubclavianA in component main (kPa)" legend_constants[34] = "E_rSubclavianA in component main (kPa_per_L)" legend_algebraic[44] = "v_rBrachialA in component main (L_per_s)" legend_constants[35] = "R_rBrachialA in component main (kPa_s_per_L)" legend_algebraic[36] = "v_rVertebralA in component main (L_per_s)" legend_constants[36] = "R_rVertebralA in component main (kPa_s_per_L)" legend_algebraic[37] = "v_lCCA in component main (L_per_s)" legend_constants[37] = "R_lCCA in component main (kPa_s_per_L)" legend_algebraic[33] = "v_lSubclavianA in component main (L_per_s)" legend_constants[38] = "R_lSubclavianA in component main (kPa_s_per_L)" legend_states[9] = "q_lSubclavianA in component main (litre)" legend_constants[39] = "q_lSubclavianA_us in component main (litre)" legend_algebraic[32] = "u_lSubclavianA in component main (kPa)" legend_constants[40] = "E_lSubclavianA in component main (kPa_per_L)" legend_algebraic[41] = "v_lBrachialA in component main (L_per_s)" legend_constants[41] = "R_lBrachialA in component main (kPa_s_per_L)" legend_algebraic[38] = "v_lVertebralA in component main (L_per_s)" legend_constants[42] = "R_lVertebralA in component main (kPa_s_per_L)" legend_states[10] = "q_headC in component main (litre)" legend_constants[43] = "q_headC_us in component main (litre)" legend_algebraic[34] = "u_headC in component main (kPa)" legend_constants[44] = "E_headC in component main (kPa_per_L)" legend_algebraic[39] = "v_headV in component main (L_per_s)" legend_constants[45] = "R_headV in component main (kPa_s_per_L)" legend_states[11] = "q_lArmC in component main (litre)" legend_constants[46] = "q_lArmC_us in component main (litre)" legend_algebraic[40] = "u_lArmC in component main (kPa)" legend_constants[47] = "E_lArmC in component main (kPa_per_L)" legend_algebraic[42] = "v_lArmV in component main (L_per_s)" legend_constants[48] = "R_lArmV in component main (kPa_s_per_L)" legend_states[12] = "q_rArmC in component main (litre)" legend_constants[49] = "q_rArmC_us in component main (litre)" legend_algebraic[43] = "u_rArmC in component main (kPa)" legend_constants[50] = "E_rArmC in component main (kPa_per_L)" legend_algebraic[45] = "v_rArmV in component main (L_per_s)" legend_constants[51] = "R_rArmV in component main (kPa_s_per_L)" legend_states[13] = "q_A1 in component main (litre)" legend_constants[52] = "q_A1_us in component main (litre)" legend_states[14] = "q_A2 in component main (litre)" legend_constants[53] = "q_A2_us in component main (litre)" legend_states[15] = "q_A3 in component main (litre)" legend_constants[54] = "q_A3_us in component main (litre)" legend_states[16] = "q_A4 in component main (litre)" legend_constants[55] = "q_A4_us in component main (litre)" legend_states[17] = "q_A5 in component main (litre)" legend_constants[56] = "q_A5_us in component main (litre)" legend_states[18] = "q_A6 in component main (litre)" legend_constants[57] = "q_A6_us in component main (litre)" legend_states[19] = "q_A7 in component main (litre)" legend_constants[58] = "q_A7_us in component main (litre)" legend_states[20] = "q_A8 in component main (litre)" legend_constants[59] = "q_A8_us in component main (litre)" legend_algebraic[54] = "v_A1 in component main (L_per_s)" legend_algebraic[55] = "v_A2 in component main (L_per_s)" legend_algebraic[56] = "v_A3 in component main (L_per_s)" legend_algebraic[57] = "v_A4 in component main (L_per_s)" legend_algebraic[58] = "v_A5 in component main (L_per_s)" legend_algebraic[59] = "v_A6 in component main (L_per_s)" legend_algebraic[60] = "v_A7 in component main (L_per_s)" legend_algebraic[61] = "v_A8 in component main (L_per_s)" legend_algebraic[46] = "u_A1 in component main (kPa)" legend_algebraic[47] = "u_A2 in component main (kPa)" legend_algebraic[48] = "u_A3 in component main (kPa)" legend_algebraic[49] = "u_A4 in component main (kPa)" legend_algebraic[50] = "u_A5 in component main (kPa)" legend_algebraic[51] = "u_A6 in component main (kPa)" legend_algebraic[52] = "u_A7 in component main (kPa)" legend_algebraic[53] = "u_A8 in component main (kPa)" legend_constants[60] = "E_A1 in component main (kPa_per_L)" legend_constants[61] = "E_A2 in component main (kPa_per_L)" legend_constants[62] = "E_A3 in component main (kPa_per_L)" legend_constants[63] = "E_A4 in component main (kPa_per_L)" legend_constants[64] = "E_A5 in component main (kPa_per_L)" legend_constants[65] = "E_A6 in component main (kPa_per_L)" legend_constants[66] = "E_A7 in component main (kPa_per_L)" legend_constants[67] = "E_A8 in component main (kPa_per_L)" legend_constants[68] = "R_A1 in component main (kPa_s_per_L)" legend_constants[69] = "R_A2 in component main (kPa_s_per_L)" legend_constants[70] = "R_A3 in component main (kPa_s_per_L)" legend_constants[71] = "R_A4 in component main (kPa_s_per_L)" legend_constants[72] = "R_A5 in component main (kPa_s_per_L)" legend_constants[73] = "R_A6 in component main (kPa_s_per_L)" legend_constants[74] = "R_A7 in component main (kPa_s_per_L)" legend_constants[75] = "R_A8 in component main (kPa_s_per_L)" legend_algebraic[63] = "v_lInfPhrenicA in component main (L_per_s)" legend_constants[76] = "R_lInfPhrenicA in component main (kPa_s_per_L)" legend_states[21] = "q_lAdrenalGlandC in component main (litre)" legend_constants[77] = "q_lAdrenalGlandC_us in component main (litre)" legend_algebraic[62] = "u_lAdrenalGlandC in component main (kPa)" legend_constants[78] = "E_lAdrenalGlandC in component main (kPa_per_L)" legend_algebraic[65] = "v_lAdrenalV in component main (L_per_s)" legend_constants[79] = "R_lAdrenalV in component main (kPa_s_per_L)" legend_states[22] = "q_lInfPhrenicV in component main (litre)" legend_constants[80] = "q_lInfPhrenicV_us in component main (litre)" legend_algebraic[64] = "u_lInfPhrenicV in component main (kPa)" legend_constants[81] = "E_lInfPhrenicV in component main (kPa_per_L)" legend_algebraic[104] = "v_lInfPhrenicV in component main (L_per_s)" legend_constants[82] = "R_lInfPhrenicV in component main (kPa_s_per_L)" legend_algebraic[67] = "v_rInfPhrenicA in component main (L_per_s)" legend_constants[83] = "R_rInfPhrenicA in component main (kPa_s_per_L)" legend_states[23] = "q_rAdrenalGlandC in component main (litre)" legend_constants[84] = "q_rAdrenalGlandC_us in component main (litre)" legend_algebraic[66] = "u_rAdrenalGlandC in component main (kPa)" legend_constants[85] = "E_rAdrenalGlandC in component main (kPa_per_L)" legend_algebraic[69] = "v_rAdrenalV in component main (L_per_s)" legend_constants[86] = "R_rAdrenalV in component main (kPa_s_per_L)" legend_states[24] = "q_rInfPhrenicV in component main (litre)" legend_constants[87] = "q_rInfPhrenicV_us in component main (litre)" legend_algebraic[68] = "u_rInfPhrenicV in component main (kPa)" legend_constants[88] = "E_rInfPhrenicV in component main (kPa_per_L)" legend_algebraic[106] = "v_rInfPhrenicV in component main (L_per_s)" legend_constants[89] = "R_rInfPhrenicV in component main (kPa_s_per_L)" legend_algebraic[71] = "v_celiacA in component main (L_per_s)" legend_constants[90] = "R_celiacA in component main (kPa_s_per_L)" legend_states[25] = "q_celiacA in component main (litre)" legend_constants[91] = "q_celiacA_us in component main (litre)" legend_algebraic[70] = "u_celiacA in component main (kPa)" legend_constants[92] = "E_celiacA in component main (kPa_per_L)" legend_constants[93] = "z_celiacA in component main (meter)" legend_algebraic[73] = "v_supMesA in component main (L_per_s)" legend_constants[94] = "R_supMesA in component main (kPa_s_per_L)" legend_states[26] = "q_supMesA in component main (litre)" legend_constants[95] = "q_supMesA_us in component main (litre)" legend_algebraic[72] = "u_supMesA in component main (kPa)" legend_constants[96] = "E_supMesA in component main (kPa_per_L)" legend_constants[97] = "z_supMesA in component main (meter)" legend_algebraic[75] = "v_lRenalA in component main (L_per_s)" legend_constants[98] = "R_lRenalA in component main (kPa_s_per_L)" legend_states[27] = "q_lGlomerulusC in component main (litre)" legend_constants[99] = "q_lGlomerulusC_us in component main (litre)" legend_algebraic[74] = "u_lGlomerulusC in component main (kPa)" legend_constants[100] = "E_lGlomerulusC in component main (kPa_per_L)" legend_algebraic[77] = "v_lEffArteriol in component main (L_per_s)" legend_constants[101] = "R_lEffArteriol in component main (kPa_s_per_L)" legend_states[28] = "q_lPeritubularC in component main (litre)" legend_constants[102] = "q_lPeritubularC_us in component main (litre)" legend_algebraic[76] = "u_lPeritubularC in component main (kPa)" legend_constants[103] = "E_lPeritubularC in component main (kPa_per_L)" legend_algebraic[110] = "v_lRenalV in component main (L_per_s)" legend_constants[104] = "R_lRenalV in component main (kPa_s_per_L)" legend_algebraic[79] = "v_rRenalA in component main (L_per_s)" legend_constants[105] = "R_rRenalA in component main (kPa_s_per_L)" legend_states[29] = "q_rGlomerulusC in component main (litre)" legend_constants[106] = "q_rGlomerulusC_us in component main (litre)" legend_algebraic[78] = "u_rGlomerulusC in component main (kPa)" legend_constants[107] = "E_rGlomerulusC in component main (kPa_per_L)" legend_algebraic[81] = "v_rEffArteriol in component main (L_per_s)" legend_constants[108] = "R_rEffArteriol in component main (kPa_s_per_L)" legend_states[30] = "q_rPeritubularC in component main (litre)" legend_constants[109] = "q_rPeritubularC_us in component main (litre)" legend_algebraic[80] = "u_rPeritubularC in component main (kPa)" legend_constants[110] = "E_rPeritubularC in component main (kPa_per_L)" legend_algebraic[112] = "v_rRenalV in component main (L_per_s)" legend_constants[111] = "R_rRenalV in component main (kPa_s_per_L)" legend_algebraic[92] = "v_infMesA in component main (L_per_s)" legend_constants[112] = "R_infMesA in component main (kPa_s_per_L)" legend_algebraic[83] = "v_stomachA in component main (L_per_s)" legend_constants[113] = "R_stomachA in component main (kPa_s_per_L)" legend_states[31] = "q_stomachC in component main (litre)" legend_constants[114] = "q_stomachC_us in component main (litre)" legend_algebraic[82] = "u_stomachC in component main (kPa)" legend_constants[115] = "E_stomachC in component main (kPa_per_L)" legend_constants[116] = "z_stomachC in component main (meter)" legend_algebraic[95] = "v_stomachV in component main (L_per_s)" legend_constants[117] = "R_stomachV in component main (kPa_s_per_L)" legend_algebraic[85] = "v_spleenA in component main (L_per_s)" legend_constants[118] = "R_spleenA in component main (kPa_s_per_L)" legend_states[32] = "q_spleenC in component main (litre)" legend_constants[119] = "q_spleenC_us in component main (litre)" legend_algebraic[84] = "u_spleenC in component main (kPa)" legend_constants[120] = "E_spleenC in component main (kPa_per_L)" legend_constants[121] = "z_spleenC in component main (meter)" legend_algebraic[96] = "v_spleenV in component main (L_per_s)" legend_constants[122] = "R_spleenV in component main (kPa_s_per_L)" legend_algebraic[87] = "v_pancreas1A in component main (L_per_s)" legend_algebraic[88] = "v_pancreas2A in component main (L_per_s)" legend_constants[123] = "R_pancreas1A in component main (kPa_s_per_L)" legend_constants[124] = "R_pancreas2A in component main (kPa_s_per_L)" legend_states[33] = "q_pancreasC in component main (litre)" legend_constants[125] = "q_pancreasC_us in component main (litre)" legend_algebraic[86] = "u_pancreasC in component main (kPa)" legend_constants[126] = "E_pancreasC in component main (kPa_per_L)" legend_constants[127] = "z_pancreasC in component main (meter)" legend_algebraic[97] = "v_pancreasV in component main (L_per_s)" legend_constants[128] = "R_pancreasV in component main (kPa_s_per_L)" legend_algebraic[90] = "v_intestineA in component main (L_per_s)" legend_constants[129] = "R_intestineA in component main (kPa_s_per_L)" legend_states[34] = "q_intestineC in component main (litre)" legend_constants[130] = "q_intestineC_us in component main (litre)" legend_algebraic[89] = "u_intestineC in component main (kPa)" legend_constants[131] = "E_intestineC in component main (kPa_per_L)" legend_constants[132] = "z_ in component main (meter)" legend_algebraic[98] = "v_intestineV in component main (L_per_s)" legend_constants[133] = "R_intestineV in component main (kPa_s_per_L)" legend_algebraic[93] = "v_colonA in component main (L_per_s)" legend_constants[134] = "R_colonA in component main (kPa_s_per_L)" legend_states[35] = "q_colonC in component main (litre)" legend_constants[135] = "q_colonC_us in component main (litre)" legend_algebraic[91] = "u_colonC in component main (kPa)" legend_constants[136] = "E_colonC in component main (kPa_per_L)" legend_constants[137] = "z_colonC in component main (meter)" legend_algebraic[99] = "v_colonV in component main (L_per_s)" legend_constants[138] = "R_colonV in component main (kPa_s_per_L)" legend_states[36] = "q_portalV in component main (litre)" legend_constants[139] = "q_portalV_us in component main (litre)" legend_algebraic[94] = "u_portalV in component main (kPa)" legend_constants[140] = "E_portalV in component main (kPa_per_L)" legend_constants[141] = "z_portalV in component main (meter)" legend_algebraic[101] = "v_portalV in component main (L_per_s)" legend_constants[142] = "R_portalV in component main (kPa_s_per_L)" legend_algebraic[102] = "v_liverA in component main (L_per_s)" legend_constants[143] = "R_liverA in component main (kPa_s_per_L)" legend_states[37] = "q_liverC in component main (litre)" legend_constants[144] = "q_liverC_us in component main (litre)" legend_algebraic[100] = "u_liverC in component main (kPa)" legend_constants[145] = "E_liverC in component main (kPa_per_L)" legend_constants[146] = "z_liverC in component main (meter)" legend_algebraic[108] = "v_liverV in component main (L_per_s)" legend_constants[147] = "R_liverV in component main (kPa_s_per_L)" legend_states[38] = "q_V1 in component main (litre)" legend_constants[148] = "q_V1_us in component main (litre)" legend_states[39] = "q_V2 in component main (litre)" legend_constants[149] = "q_V2_us in component main (litre)" legend_states[40] = "q_V3 in component main (litre)" legend_constants[150] = "q_V3_us in component main (litre)" legend_states[41] = "q_V4 in component main (litre)" legend_constants[151] = "q_V4_us in component main (litre)" legend_states[42] = "q_V5 in component main (litre)" legend_constants[152] = "q_V5_us in component main (litre)" legend_states[43] = "q_V6 in component main (litre)" legend_constants[153] = "q_V6_us in component main (litre)" legend_algebraic[114] = "v_V1 in component main (L_per_s)" legend_algebraic[115] = "v_V2 in component main (L_per_s)" legend_algebraic[116] = "v_V3 in component main (L_per_s)" legend_algebraic[117] = "v_V4 in component main (L_per_s)" legend_algebraic[118] = "v_V5 in component main (L_per_s)" legend_algebraic[119] = "v_V6 in component main (L_per_s)" legend_algebraic[103] = "u_V1 in component main (kPa)" legend_algebraic[105] = "u_V2 in component main (kPa)" legend_algebraic[107] = "u_V3 in component main (kPa)" legend_algebraic[109] = "u_V4 in component main (kPa)" legend_algebraic[111] = "u_V5 in component main (kPa)" legend_algebraic[113] = "u_V6 in component main (kPa)" legend_constants[154] = "E_V1 in component main (kPa_per_L)" legend_constants[155] = "E_V2 in component main (kPa_per_L)" legend_constants[156] = "E_V3 in component main (kPa_per_L)" legend_constants[157] = "E_V4 in component main (kPa_per_L)" legend_constants[158] = "E_V5 in component main (kPa_per_L)" legend_constants[159] = "E_V6 in component main (kPa_per_L)" legend_constants[160] = "R_V1 in component main (kPa_s_per_L)" legend_constants[161] = "R_V2 in component main (kPa_s_per_L)" legend_constants[162] = "R_V3 in component main (kPa_s_per_L)" legend_constants[163] = "R_V4 in component main (kPa_s_per_L)" legend_constants[164] = "R_V5 in component main (kPa_s_per_L)" legend_constants[165] = "R_V6 in component main (kPa_s_per_L)" legend_algebraic[121] = "v_lCommonIliacA in component main (L_per_s)" legend_constants[166] = "R_lCommonIliacA in component main (kPa_s_per_L)" legend_states[44] = "q_lLegC in component main (litre)" legend_constants[167] = "q_lLegC_us in component main (litre)" legend_algebraic[120] = "u_lLegC in component main (kPa)" legend_constants[168] = "E_lLegC in component main (kPa_per_L)" legend_algebraic[122] = "v_lCommonIliacV in component main (L_per_s)" legend_constants[169] = "R_lCommonIliacV in component main (kPa_s_per_L)" legend_algebraic[124] = "v_rCommonIliacA in component main (L_per_s)" legend_constants[170] = "R_rCommonIliacA in component main (kPa_s_per_L)" legend_states[45] = "q_rLegC in component main (litre)" legend_constants[171] = "q_rLegC_us in component main (litre)" legend_algebraic[123] = "u_rLegC in component main (kPa)" legend_constants[172] = "E_rLegC in component main (kPa_per_L)" legend_algebraic[125] = "v_rCommonIliacV in component main (L_per_s)" legend_constants[173] = "R_rCommonIliacV in component main (kPa_s_per_L)" legend_algebraic[3] = "q_TotHeart in component main (litre)" legend_algebraic[5] = "q_TotLung in component main (litre)" legend_algebraic[7] = "q_TotHead in component main (litre)" legend_algebraic[9] = "q_TotThoracic in component main (litre)" legend_algebraic[11] = "q_TotAorta in component main (litre)" legend_algebraic[13] = "q_TotRenal in component main (litre)" legend_algebraic[15] = "q_TotGut in component main (litre)" legend_algebraic[17] = "q_TotVenaCava in component main (litre)" legend_algebraic[19] = "q_TotLimbs in component main (litre)" legend_algebraic[22] = "q_TotBlood in component main (litre)" legend_rates[0] = "d/dt q_LV in component main (litre)" legend_rates[1] = "d/dt q_RV in component main (litre)" legend_rates[2] = "d/dt q_LA in component main (litre)" legend_rates[3] = "d/dt q_RA in component main (litre)" legend_rates[4] = "d/dt q_pulmA in component main (litre)" legend_rates[5] = "d/dt q_lungC in component main (litre)" legend_rates[6] = "d/dt q_AA in component main (litre)" legend_rates[7] = "d/dt q_brachiocephalicA in component main (litre)" legend_rates[8] = "d/dt q_rSubclavianA in component main (litre)" legend_rates[9] = "d/dt q_lSubclavianA in component main (litre)" legend_rates[10] = "d/dt q_headC in component main (litre)" legend_rates[11] = "d/dt q_lArmC in component main (litre)" legend_rates[12] = "d/dt q_rArmC in component main (litre)" legend_rates[13] = "d/dt q_A1 in component main (litre)" legend_rates[14] = "d/dt q_A2 in component main (litre)" legend_rates[15] = "d/dt q_A3 in component main (litre)" legend_rates[16] = "d/dt q_A4 in component main (litre)" legend_rates[17] = "d/dt q_A5 in component main (litre)" legend_rates[18] = "d/dt q_A6 in component main (litre)" legend_rates[19] = "d/dt q_A7 in component main (litre)" legend_rates[20] = "d/dt q_A8 in component main (litre)" legend_rates[21] = "d/dt q_lAdrenalGlandC in component main (litre)" legend_rates[22] = "d/dt q_lInfPhrenicV in component main (litre)" legend_rates[23] = "d/dt q_rAdrenalGlandC in component main (litre)" legend_rates[24] = "d/dt q_rInfPhrenicV in component main (litre)" legend_rates[25] = "d/dt q_celiacA in component main (litre)" legend_rates[26] = "d/dt q_supMesA in component main (litre)" legend_rates[27] = "d/dt q_lGlomerulusC in component main (litre)" legend_rates[28] = "d/dt q_lPeritubularC in component main (litre)" legend_rates[29] = "d/dt q_rGlomerulusC in component main (litre)" legend_rates[30] = "d/dt q_rPeritubularC in component main (litre)" legend_rates[31] = "d/dt q_stomachC in component main (litre)" legend_rates[32] = "d/dt q_spleenC in component main (litre)" legend_rates[33] = "d/dt q_pancreasC in component main (litre)" legend_rates[34] = "d/dt q_intestineC in component main (litre)" legend_rates[35] = "d/dt q_colonC in component main (litre)" legend_rates[36] = "d/dt q_portalV in component main (litre)" legend_rates[37] = "d/dt q_liverC in component main (litre)" legend_rates[38] = "d/dt q_V1 in component main (litre)" legend_rates[39] = "d/dt q_V2 in component main (litre)" legend_rates[40] = "d/dt q_V3 in component main (litre)" legend_rates[41] = "d/dt q_V4 in component main (litre)" legend_rates[42] = "d/dt q_V5 in component main (litre)" legend_rates[43] = "d/dt q_V6 in component main (litre)" legend_rates[44] = "d/dt q_lLegC in component main (litre)" legend_rates[45] = "d/dt q_rLegC in component main (litre)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; constants[0] = 1000 constants[1] = 9.81 constants[2] = 90 constants[3] = 1 constants[4] = 0.1 constants[5] = 0.1 states[0] = 2.24894867772612 constants[6] = 0.005 constants[7] = 320 constants[8] = 6.667 states[1] = 2.24212874273495 constants[9] = 0.01 constants[10] = 70 constants[11] = 2 states[2] = 1.50038322871398 constants[12] = 0.004 constants[13] = 10 states[3] = 0.582873822068968 constants[14] = 0.004 constants[15] = 10 constants[16] = 1 constants[17] = 1 constants[18] = 1 constants[19] = 1 states[4] = 0.274822042097049 constants[20] = 0.2 constants[21] = 200 constants[22] = 1 states[5] = 0.274821056256821 constants[23] = 0.2 constants[24] = 200 constants[25] = 1 states[6] = 1.43716360225001 constants[26] = 0.12 constants[27] = 80 constants[28] = 100 states[7] = 0.658321340279823 constants[29] = 0.2 constants[30] = 200 constants[31] = 100 constants[32] = 100 states[8] = 0.578637981993128 constants[33] = 0.2 constants[34] = 200 constants[35] = 100 constants[36] = 100 constants[37] = 100 constants[38] = 100 states[9] = 0.609560299960373 constants[39] = 0.2 constants[40] = 200 constants[41] = 100 constants[42] = 100 states[10] = 0.575700923676085 constants[43] = 0.2 constants[44] = 200 constants[45] = 100 states[11] = 0.380415025779693 constants[46] = 0.06 constants[47] = 150 constants[48] = 100 states[12] = 0.380415025779692 constants[49] = 0.06 constants[50] = 150 constants[51] = 100 states[13] = 0.0726453866278764 constants[52] = 0.06 states[14] = 0.0722595904606296 constants[53] = 0.06 states[15] = 0.0717727262354559 constants[54] = 0.06 states[16] = 0.0715328891139091 constants[55] = 0.06 states[17] = 0.0714293557557069 constants[56] = 0.06 states[18] = 0.0713497500336812 constants[57] = 0.06 states[19] = 0.0712949341825069 constants[58] = 0.06 states[20] = 0.0712201889071758 constants[59] = 0.06 constants[60] = 400 constants[61] = 400 constants[62] = 400 constants[63] = 400 constants[64] = 400 constants[65] = 400 constants[66] = 400 constants[67] = 400 constants[68] = 10000000 constants[69] = 100 constants[70] = 100 constants[71] = 100 constants[72] = 100 constants[73] = 100 constants[74] = 100 constants[75] = 100 constants[76] = 100 states[21] = 0.226013520134949 constants[77] = 0.2 constants[78] = 200 constants[79] = 100 states[22] = 0.226425525942081 constants[80] = 0.2 constants[81] = 200 constants[82] = 100 constants[83] = 100 states[23] = 0.224729694488936 constants[84] = 0.2 constants[85] = 200 constants[86] = 100 states[24] = 0.224899115493557 constants[87] = 0.2 constants[88] = 200 constants[89] = 100 constants[90] = 100 states[25] = 0.0715428919998289 constants[91] = 0.06 constants[92] = 400 constants[93] = 0.2 constants[94] = 100 states[26] = 0.071414457768405 constants[95] = 0.06 constants[96] = 400 constants[97] = 0.2 constants[98] = 100 states[27] = 0.222843940557744 constants[99] = 0.2 constants[100] = 200 constants[101] = 100 states[28] = 0.222892809988734 constants[102] = 0.2 constants[103] = 200 constants[104] = 100 constants[105] = 100 states[29] = 0.222680450943523 constants[106] = 0.2 constants[107] = 200 constants[108] = 100 states[30] = 0.222721287850087 constants[109] = 0.2 constants[110] = 200 constants[111] = 100 constants[112] = 100 constants[113] = 100 states[31] = 0.105910755847991 constants[114] = 0.06 constants[115] = 100 constants[116] = 0.2 constants[117] = 2400 constants[118] = 100 states[32] = 0.105910034847806 constants[119] = 0.06 constants[120] = 100 constants[121] = 0.2 constants[122] = 3000 constants[123] = 100 constants[124] = 100 states[33] = 0.105787155209054 constants[125] = 0.06 constants[126] = 100 constants[127] = 0.2 constants[128] = 4000 constants[129] = 100 states[34] = 0.105459895332545 constants[130] = 0.06 constants[131] = 100 constants[132] = 0.2 constants[133] = 1200 constants[134] = 100 states[35] = 0.105317375726849 constants[135] = 0.06 constants[136] = 100 constants[137] = 0.2 constants[138] = 2000 states[36] = 0.152013945600315 constants[139] = 0.06 constants[140] = 50 constants[141] = 0.2 constants[142] = 100 constants[143] = 800 states[37] = 0.526188169704937 constants[144] = 0.06 constants[145] = 10 constants[146] = -0.5 constants[147] = 1 states[38] = 0.0732527312969717 constants[148] = 0.06 states[39] = 0.0724355014489091 constants[149] = 0.06 states[40] = 0.0716607456049039 constants[150] = 0.06 states[41] = 0.071501504166401 constants[151] = 0.06 states[42] = 0.0714111536200381 constants[152] = 0.06 states[43] = 0.0713861207574313 constants[153] = 0.06 constants[154] = 400 constants[155] = 400 constants[156] = 400 constants[157] = 400 constants[158] = 400 constants[159] = 400 constants[160] = 100 constants[161] = 100 constants[162] = 100 constants[163] = 100 constants[164] = 100 constants[165] = 100 constants[166] = 100 states[44] = 0.0898390162613648 constants[167] = 0.06 constants[168] = 150 constants[169] = 4000 constants[170] = 100 states[45] = 0.0898390162613648 constants[171] = 0.06 constants[172] = 150 constants[173] = 4000 constants[174] = (constants[2]* pi)/180.000 return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic algebraic[2] = voi/constants[3]-floor(voi/constants[3]) algebraic[4] = custom_piecewise([less(algebraic[2] , 0.400000), (((constants[7]-constants[8])*algebraic[2])/constants[5])*exp(0.500000*(1.00000-power(algebraic[2]/constants[5], 2.00000)))+constants[8] , less(algebraic[2] , 0.600000), (((constants[7]-constants[8])*0.400000)/constants[5])*exp(0.500000*(1.00000-power(0.400000/constants[5], 2.00000)))+constants[8] , True, constants[8]]) algebraic[6] = algebraic[4]*(states[0]-constants[6]) algebraic[21] = constants[27]*(states[6]-constants[26]) algebraic[24] = custom_piecewise([greater(algebraic[6] , algebraic[21]), (algebraic[6]-algebraic[21])/constants[16] , True, 0.00000]) algebraic[12] = constants[13]*(states[2]-constants[12]) algebraic[18] = custom_piecewise([greater(algebraic[12] , algebraic[6]), (algebraic[12]-algebraic[6])/constants[19] , True, 0.00000]) rates[0] = algebraic[18]-algebraic[24] algebraic[8] = custom_piecewise([less(algebraic[2] , 0.400000), (((constants[10]-constants[11])*algebraic[2])/constants[5])*exp(0.500000*(1.00000-power(algebraic[2]/constants[5], 2.00000)))+constants[11] , less(algebraic[2] , 0.600000), (((constants[10]-constants[11])*0.400000)/constants[5])*exp(0.500000*(1.00000-power(0.400000/constants[5], 2.00000)))+constants[11] , True, constants[11]]) algebraic[10] = algebraic[8]*(states[1]-constants[9]) algebraic[20] = constants[21]*(states[4]-constants[20]) algebraic[23] = custom_piecewise([greater(algebraic[10] , algebraic[20]), (algebraic[10]-algebraic[20])/constants[17] , True, 0.00000]) algebraic[14] = constants[15]*(states[3]-constants[14]) algebraic[16] = custom_piecewise([greater(algebraic[14] , algebraic[10]), (algebraic[14]-algebraic[10])/constants[18] , True, 0.00000]) rates[1] = algebraic[16]-algebraic[23] algebraic[25] = constants[24]*(states[5]-constants[23]) algebraic[27] = (algebraic[20]-algebraic[25])/constants[22] rates[4] = algebraic[23]-algebraic[27] algebraic[29] = (algebraic[25]-algebraic[12])/constants[25] rates[2] = algebraic[29]-algebraic[18] rates[5] = algebraic[27]-algebraic[29] algebraic[26] = constants[30]*(states[7]-constants[29]) algebraic[28] = (algebraic[21]-algebraic[26])/constants[28] algebraic[30] = constants[34]*(states[8]-constants[33]) algebraic[31] = (algebraic[26]-algebraic[30])/constants[31] algebraic[34] = constants[44]*(states[10]-constants[43]) algebraic[35] = (algebraic[26]-algebraic[34])/constants[32] rates[7] = (algebraic[28]-algebraic[31])-algebraic[35] algebraic[36] = (algebraic[30]-algebraic[34])/constants[36] algebraic[37] = (algebraic[21]-algebraic[34])/constants[37] algebraic[32] = constants[40]*(states[9]-constants[39]) algebraic[38] = (algebraic[32]-algebraic[34])/constants[42] algebraic[39] = (algebraic[34]-algebraic[14])/constants[45] rates[10] = (algebraic[36]+algebraic[35]+algebraic[37]+algebraic[38])-algebraic[39] algebraic[33] = (algebraic[21]-algebraic[32])/constants[38] algebraic[40] = constants[47]*(states[11]-constants[46]) algebraic[41] = (algebraic[32]-algebraic[40])/constants[41] rates[9] = (algebraic[33]-algebraic[41])-algebraic[38] algebraic[42] = (algebraic[40]-algebraic[14])/constants[48] rates[11] = algebraic[41]-algebraic[42] algebraic[43] = constants[50]*(states[12]-constants[49]) algebraic[44] = (algebraic[30]-algebraic[43])/constants[35] rates[8] = (algebraic[31]-algebraic[44])-algebraic[36] algebraic[45] = (algebraic[43]-algebraic[14])/constants[51] rates[12] = algebraic[44]-algebraic[45] algebraic[46] = constants[60]*(states[13]-constants[52]) algebraic[54] = (algebraic[21]-algebraic[46])/constants[68] rates[6] = (((algebraic[24]-algebraic[54])-algebraic[28])-algebraic[37])-algebraic[33] algebraic[47] = constants[61]*(states[14]-constants[53]) algebraic[55] = (algebraic[46]-algebraic[47])/constants[69] algebraic[62] = constants[78]*(states[21]-constants[77]) algebraic[63] = (algebraic[46]-algebraic[62])/constants[76] rates[13] = (algebraic[54]-algebraic[55])-algebraic[63] algebraic[64] = constants[81]*(states[22]-constants[80]) algebraic[65] = (algebraic[62]-algebraic[64])/constants[79] rates[21] = algebraic[63]-algebraic[65] algebraic[48] = constants[62]*(states[15]-constants[54]) algebraic[56] = (algebraic[47]-algebraic[48])/constants[70] algebraic[66] = constants[85]*(states[23]-constants[84]) algebraic[67] = (algebraic[47]-algebraic[66])/constants[83] rates[14] = (algebraic[55]-algebraic[56])-algebraic[67] algebraic[68] = constants[88]*(states[24]-constants[87]) algebraic[69] = (algebraic[66]-algebraic[68])/constants[86] rates[23] = algebraic[67]-algebraic[69] algebraic[49] = constants[63]*(states[16]-constants[55]) algebraic[57] = (algebraic[48]-algebraic[49])/constants[71] algebraic[70] = constants[92]*(states[25]-constants[91]) algebraic[71] = (algebraic[48]-algebraic[70])/constants[90] rates[15] = (algebraic[56]-algebraic[57])-algebraic[71] algebraic[50] = constants[64]*(states[17]-constants[56]) algebraic[58] = (algebraic[49]-algebraic[50])/constants[72] algebraic[72] = constants[96]*(states[26]-constants[95]) algebraic[73] = (algebraic[49]-algebraic[72])/constants[94] rates[16] = (algebraic[57]-algebraic[58])-algebraic[73] algebraic[51] = constants[65]*(states[18]-constants[57]) algebraic[59] = (algebraic[50]-algebraic[51])/constants[73] algebraic[74] = constants[100]*(states[27]-constants[99]) algebraic[75] = (algebraic[50]-algebraic[74])/constants[98] rates[17] = (algebraic[58]-algebraic[59])-algebraic[75] algebraic[76] = constants[103]*(states[28]-constants[102]) algebraic[77] = (algebraic[74]-algebraic[76])/constants[101] rates[27] = algebraic[75]-algebraic[77] algebraic[52] = constants[66]*(states[19]-constants[58]) algebraic[60] = (algebraic[51]-algebraic[52])/constants[74] algebraic[78] = constants[107]*(states[29]-constants[106]) algebraic[79] = (algebraic[51]-algebraic[78])/constants[105] rates[18] = (algebraic[59]-algebraic[60])-algebraic[79] algebraic[80] = constants[110]*(states[30]-constants[109]) algebraic[81] = (algebraic[78]-algebraic[80])/constants[108] rates[29] = algebraic[79]-algebraic[81] algebraic[53] = constants[67]*(states[20]-constants[59]) algebraic[61] = (algebraic[52]-algebraic[53])/constants[75] algebraic[91] = constants[136]*(states[35]-constants[135]) algebraic[92] = (algebraic[52]-algebraic[91])/constants[112] rates[19] = (algebraic[60]-algebraic[61])-algebraic[92] algebraic[86] = constants[126]*(states[33]-constants[125]) algebraic[88] = (algebraic[72]-algebraic[86])/constants[124] algebraic[89] = constants[131]*(states[34]-constants[130]) algebraic[90] = (algebraic[72]-algebraic[89])/constants[129] algebraic[93] = (algebraic[72]-algebraic[91])/constants[134] rates[26] = ((algebraic[73]-algebraic[88])-algebraic[90])-algebraic[93] algebraic[82] = constants[115]*(states[31]-constants[114]) algebraic[83] = (algebraic[70]-algebraic[82])/constants[113] algebraic[94] = constants[140]*(states[36]-constants[139]) algebraic[95] = (algebraic[82]-algebraic[94])/constants[117] rates[31] = algebraic[83]-algebraic[95] algebraic[84] = constants[120]*(states[32]-constants[119]) algebraic[85] = (algebraic[70]-algebraic[84])/constants[118] algebraic[96] = (algebraic[84]-algebraic[94])/constants[122] rates[32] = algebraic[85]-algebraic[96] algebraic[87] = (algebraic[70]-algebraic[86])/constants[123] algebraic[97] = (algebraic[86]-algebraic[94])/constants[128] rates[33] = (algebraic[87]+algebraic[88])-algebraic[97] algebraic[98] = (algebraic[89]-algebraic[94])/constants[133] rates[34] = algebraic[90]-algebraic[98] algebraic[99] = (algebraic[91]-algebraic[94])/constants[138] rates[35] = (algebraic[93]+algebraic[92])-algebraic[99] algebraic[100] = constants[145]*(states[37]-constants[144]) algebraic[101] = (algebraic[94]-algebraic[100])/constants[142] rates[36] = (algebraic[95]+algebraic[96]+algebraic[97]+algebraic[98]+algebraic[99])-algebraic[101] algebraic[102] = (algebraic[70]-algebraic[100])/constants[143] rates[25] = (((algebraic[71]-algebraic[102])-algebraic[83])-algebraic[85])-algebraic[87] algebraic[103] = constants[154]*(states[38]-constants[148]) algebraic[104] = (algebraic[64]-algebraic[103])/constants[82] rates[22] = algebraic[65]-algebraic[104] algebraic[105] = constants[155]*(states[39]-constants[149]) algebraic[106] = (algebraic[68]-algebraic[105])/constants[89] rates[24] = algebraic[69]-algebraic[106] algebraic[107] = constants[156]*(states[40]-constants[150]) algebraic[108] = (algebraic[100]-algebraic[107])/constants[147] rates[37] = (algebraic[102]+algebraic[101])-algebraic[108] algebraic[109] = constants[157]*(states[41]-constants[151]) algebraic[110] = (algebraic[76]-algebraic[109])/constants[104] rates[28] = algebraic[77]-algebraic[110] algebraic[111] = constants[158]*(states[42]-constants[152]) algebraic[112] = (algebraic[80]-algebraic[111])/constants[111] rates[30] = algebraic[81]-algebraic[112] algebraic[114] = (algebraic[103]-algebraic[14])/constants[160] rates[3] = (algebraic[39]+algebraic[42]+algebraic[45]+algebraic[114])-algebraic[16] algebraic[115] = (algebraic[105]-algebraic[103])/constants[161] rates[38] = (algebraic[115]+algebraic[104])-algebraic[114] algebraic[116] = (algebraic[107]-algebraic[105])/constants[162] rates[39] = (algebraic[116]+algebraic[106])-algebraic[115] algebraic[117] = (algebraic[109]-algebraic[107])/constants[163] rates[40] = (algebraic[117]+algebraic[108])-algebraic[116] algebraic[118] = (algebraic[111]-algebraic[109])/constants[164] rates[41] = (algebraic[118]+algebraic[110])-algebraic[117] algebraic[113] = constants[159]*(states[43]-constants[153]) algebraic[119] = (algebraic[113]-algebraic[111])/constants[165] rates[42] = (algebraic[119]+algebraic[112])-algebraic[118] algebraic[120] = constants[168]*(states[44]-constants[167]) algebraic[121] = (algebraic[53]-algebraic[120])/constants[166] algebraic[122] = (algebraic[120]-algebraic[113])/constants[169] rates[44] = algebraic[121]-algebraic[122] algebraic[123] = constants[172]*(states[45]-constants[171]) algebraic[124] = (algebraic[53]-algebraic[123])/constants[170] rates[20] = (algebraic[61]-algebraic[121])-algebraic[124] algebraic[125] = (algebraic[123]-algebraic[113])/constants[173] rates[43] = (algebraic[122]+algebraic[125])-algebraic[119] rates[45] = algebraic[124]-algebraic[125] return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[2] = voi/constants[3]-floor(voi/constants[3]) algebraic[4] = custom_piecewise([less(algebraic[2] , 0.400000), (((constants[7]-constants[8])*algebraic[2])/constants[5])*exp(0.500000*(1.00000-power(algebraic[2]/constants[5], 2.00000)))+constants[8] , less(algebraic[2] , 0.600000), (((constants[7]-constants[8])*0.400000)/constants[5])*exp(0.500000*(1.00000-power(0.400000/constants[5], 2.00000)))+constants[8] , True, constants[8]]) algebraic[6] = algebraic[4]*(states[0]-constants[6]) algebraic[21] = constants[27]*(states[6]-constants[26]) algebraic[24] = custom_piecewise([greater(algebraic[6] , algebraic[21]), (algebraic[6]-algebraic[21])/constants[16] , True, 0.00000]) algebraic[12] = constants[13]*(states[2]-constants[12]) algebraic[18] = custom_piecewise([greater(algebraic[12] , algebraic[6]), (algebraic[12]-algebraic[6])/constants[19] , True, 0.00000]) algebraic[8] = custom_piecewise([less(algebraic[2] , 0.400000), (((constants[10]-constants[11])*algebraic[2])/constants[5])*exp(0.500000*(1.00000-power(algebraic[2]/constants[5], 2.00000)))+constants[11] , less(algebraic[2] , 0.600000), (((constants[10]-constants[11])*0.400000)/constants[5])*exp(0.500000*(1.00000-power(0.400000/constants[5], 2.00000)))+constants[11] , True, constants[11]]) algebraic[10] = algebraic[8]*(states[1]-constants[9]) algebraic[20] = constants[21]*(states[4]-constants[20]) algebraic[23] = custom_piecewise([greater(algebraic[10] , algebraic[20]), (algebraic[10]-algebraic[20])/constants[17] , True, 0.00000]) algebraic[14] = constants[15]*(states[3]-constants[14]) algebraic[16] = custom_piecewise([greater(algebraic[14] , algebraic[10]), (algebraic[14]-algebraic[10])/constants[18] , True, 0.00000]) algebraic[25] = constants[24]*(states[5]-constants[23]) algebraic[27] = (algebraic[20]-algebraic[25])/constants[22] algebraic[29] = (algebraic[25]-algebraic[12])/constants[25] algebraic[26] = constants[30]*(states[7]-constants[29]) algebraic[28] = (algebraic[21]-algebraic[26])/constants[28] algebraic[30] = constants[34]*(states[8]-constants[33]) algebraic[31] = (algebraic[26]-algebraic[30])/constants[31] algebraic[34] = constants[44]*(states[10]-constants[43]) algebraic[35] = (algebraic[26]-algebraic[34])/constants[32] algebraic[36] = (algebraic[30]-algebraic[34])/constants[36] algebraic[37] = (algebraic[21]-algebraic[34])/constants[37] algebraic[32] = constants[40]*(states[9]-constants[39]) algebraic[38] = (algebraic[32]-algebraic[34])/constants[42] algebraic[39] = (algebraic[34]-algebraic[14])/constants[45] algebraic[33] = (algebraic[21]-algebraic[32])/constants[38] algebraic[40] = constants[47]*(states[11]-constants[46]) algebraic[41] = (algebraic[32]-algebraic[40])/constants[41] algebraic[42] = (algebraic[40]-algebraic[14])/constants[48] algebraic[43] = constants[50]*(states[12]-constants[49]) algebraic[44] = (algebraic[30]-algebraic[43])/constants[35] algebraic[45] = (algebraic[43]-algebraic[14])/constants[51] algebraic[46] = constants[60]*(states[13]-constants[52]) algebraic[54] = (algebraic[21]-algebraic[46])/constants[68] algebraic[47] = constants[61]*(states[14]-constants[53]) algebraic[55] = (algebraic[46]-algebraic[47])/constants[69] algebraic[62] = constants[78]*(states[21]-constants[77]) algebraic[63] = (algebraic[46]-algebraic[62])/constants[76] algebraic[64] = constants[81]*(states[22]-constants[80]) algebraic[65] = (algebraic[62]-algebraic[64])/constants[79] algebraic[48] = constants[62]*(states[15]-constants[54]) algebraic[56] = (algebraic[47]-algebraic[48])/constants[70] algebraic[66] = constants[85]*(states[23]-constants[84]) algebraic[67] = (algebraic[47]-algebraic[66])/constants[83] algebraic[68] = constants[88]*(states[24]-constants[87]) algebraic[69] = (algebraic[66]-algebraic[68])/constants[86] algebraic[49] = constants[63]*(states[16]-constants[55]) algebraic[57] = (algebraic[48]-algebraic[49])/constants[71] algebraic[70] = constants[92]*(states[25]-constants[91]) algebraic[71] = (algebraic[48]-algebraic[70])/constants[90] algebraic[50] = constants[64]*(states[17]-constants[56]) algebraic[58] = (algebraic[49]-algebraic[50])/constants[72] algebraic[72] = constants[96]*(states[26]-constants[95]) algebraic[73] = (algebraic[49]-algebraic[72])/constants[94] algebraic[51] = constants[65]*(states[18]-constants[57]) algebraic[59] = (algebraic[50]-algebraic[51])/constants[73] algebraic[74] = constants[100]*(states[27]-constants[99]) algebraic[75] = (algebraic[50]-algebraic[74])/constants[98] algebraic[76] = constants[103]*(states[28]-constants[102]) algebraic[77] = (algebraic[74]-algebraic[76])/constants[101] algebraic[52] = constants[66]*(states[19]-constants[58]) algebraic[60] = (algebraic[51]-algebraic[52])/constants[74] algebraic[78] = constants[107]*(states[29]-constants[106]) algebraic[79] = (algebraic[51]-algebraic[78])/constants[105] algebraic[80] = constants[110]*(states[30]-constants[109]) algebraic[81] = (algebraic[78]-algebraic[80])/constants[108] algebraic[53] = constants[67]*(states[20]-constants[59]) algebraic[61] = (algebraic[52]-algebraic[53])/constants[75] algebraic[91] = constants[136]*(states[35]-constants[135]) algebraic[92] = (algebraic[52]-algebraic[91])/constants[112] algebraic[86] = constants[126]*(states[33]-constants[125]) algebraic[88] = (algebraic[72]-algebraic[86])/constants[124] algebraic[89] = constants[131]*(states[34]-constants[130]) algebraic[90] = (algebraic[72]-algebraic[89])/constants[129] algebraic[93] = (algebraic[72]-algebraic[91])/constants[134] algebraic[82] = constants[115]*(states[31]-constants[114]) algebraic[83] = (algebraic[70]-algebraic[82])/constants[113] algebraic[94] = constants[140]*(states[36]-constants[139]) algebraic[95] = (algebraic[82]-algebraic[94])/constants[117] algebraic[84] = constants[120]*(states[32]-constants[119]) algebraic[85] = (algebraic[70]-algebraic[84])/constants[118] algebraic[96] = (algebraic[84]-algebraic[94])/constants[122] algebraic[87] = (algebraic[70]-algebraic[86])/constants[123] algebraic[97] = (algebraic[86]-algebraic[94])/constants[128] algebraic[98] = (algebraic[89]-algebraic[94])/constants[133] algebraic[99] = (algebraic[91]-algebraic[94])/constants[138] algebraic[100] = constants[145]*(states[37]-constants[144]) algebraic[101] = (algebraic[94]-algebraic[100])/constants[142] algebraic[102] = (algebraic[70]-algebraic[100])/constants[143] algebraic[103] = constants[154]*(states[38]-constants[148]) algebraic[104] = (algebraic[64]-algebraic[103])/constants[82] algebraic[105] = constants[155]*(states[39]-constants[149]) algebraic[106] = (algebraic[68]-algebraic[105])/constants[89] algebraic[107] = constants[156]*(states[40]-constants[150]) algebraic[108] = (algebraic[100]-algebraic[107])/constants[147] algebraic[109] = constants[157]*(states[41]-constants[151]) algebraic[110] = (algebraic[76]-algebraic[109])/constants[104] algebraic[111] = constants[158]*(states[42]-constants[152]) algebraic[112] = (algebraic[80]-algebraic[111])/constants[111] algebraic[114] = (algebraic[103]-algebraic[14])/constants[160] algebraic[115] = (algebraic[105]-algebraic[103])/constants[161] algebraic[116] = (algebraic[107]-algebraic[105])/constants[162] algebraic[117] = (algebraic[109]-algebraic[107])/constants[163] algebraic[118] = (algebraic[111]-algebraic[109])/constants[164] algebraic[113] = constants[159]*(states[43]-constants[153]) algebraic[119] = (algebraic[113]-algebraic[111])/constants[165] algebraic[120] = constants[168]*(states[44]-constants[167]) algebraic[121] = (algebraic[53]-algebraic[120])/constants[166] algebraic[122] = (algebraic[120]-algebraic[113])/constants[169] algebraic[123] = constants[172]*(states[45]-constants[171]) algebraic[124] = (algebraic[53]-algebraic[123])/constants[170] algebraic[125] = (algebraic[123]-algebraic[113])/constants[173] algebraic[0] = custom_piecewise([greater(voi , 100.000) & less(voi , 101.000), 1.00000 , True, 0.00000]) algebraic[1] = (voi/constants[3]-constants[4])-floor((voi-constants[4]*constants[3])/constants[3]) algebraic[3] = states[3]+states[1]+states[2]+states[0] algebraic[5] = states[5]+states[4] algebraic[7] = states[7]+states[8]+states[9]+states[10] algebraic[9] = states[21]+states[22]+states[23]+states[24] algebraic[11] = states[6]+states[13]+states[14]+states[15]+states[16]+states[17]+states[18]+states[19]+states[20] algebraic[13] = states[27]+states[28]+states[29]+states[30] algebraic[15] = states[25]+states[26]+states[31]+states[32]+states[33]+states[34]+states[35]+states[36]+states[37] algebraic[17] = states[38]+states[39]+states[40]+states[41]+states[42]+states[43] algebraic[19] = states[11]+states[12]+states[44]+states[45] algebraic[22] = algebraic[3]+algebraic[5]+(algebraic[7])+algebraic[9]+algebraic[11]+algebraic[13]+algebraic[15]+algebraic[17]+algebraic[19] 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)