# 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 = 93 sizeStates = 38 sizeConstants = 21 from math import * from numpy import * def createLegends(): legend_states = [""] * sizeStates legend_rates = [""] * sizeStates legend_algebraic = [""] * sizeAlgebraic legend_voi = "" legend_constants = [""] * sizeConstants legend_voi = "time in component environment (second)" legend_states[0] = "NatP in component NatP (molecules)" legend_constants[17] = "v1 in component v1 (flux)" legend_algebraic[0] = "v2 in component v2 (flux)" legend_algebraic[1] = "v3 in component v3 (flux)" legend_states[1] = "MisP in component MisP (molecules)" legend_algebraic[3] = "v5 in component v5 (flux)" legend_algebraic[21] = "v23 in component v23 (flux)" legend_algebraic[2] = "v4 in component v4 (flux)" legend_algebraic[37] = "v39 in component v39 (flux)" legend_algebraic[38] = "v40 in component v40 (flux)" legend_algebraic[47] = "v49 in component v49 (flux)" legend_algebraic[48] = "v50 in component v50 (flux)" legend_algebraic[49] = "v51 in component v51 (flux)" legend_algebraic[50] = "v52 in component v52 (flux)" legend_algebraic[51] = "v53 in component v53 (flux)" legend_algebraic[52] = "v54 in component v54 (flux)" legend_algebraic[53] = "v55 in component v55 (flux)" legend_algebraic[54] = "v56 in component v56 (flux)" legend_states[2] = "Ub in component Ub (molecules)" legend_algebraic[14] = "v16 in component v16 (flux)" legend_algebraic[15] = "v17 in component v17 (flux)" legend_algebraic[16] = "v18 in component v18 (flux)" legend_algebraic[17] = "v19 in component v19 (flux)" legend_algebraic[18] = "v20 in component v20 (flux)" legend_algebraic[19] = "v21 in component v21 (flux)" legend_algebraic[20] = "v22 in component v22 (flux)" legend_algebraic[27] = "v29 in component v29 (flux)" legend_algebraic[28] = "v30 in component v30 (flux)" legend_algebraic[29] = "v31 in component v31 (flux)" legend_algebraic[30] = "v32 in component v32 (flux)" legend_algebraic[31] = "v33 in component v33 (flux)" legend_algebraic[32] = "v34 in component v34 (flux)" legend_algebraic[33] = "v35 in component v35 (flux)" legend_algebraic[34] = "v36 in component v36 (flux)" legend_algebraic[35] = "v37 in component v37 (flux)" legend_algebraic[36] = "v38 in component v38 (flux)" legend_algebraic[4] = "v6 in component v6 (flux)" legend_states[3] = "E1 in component E1 (molecules)" legend_algebraic[5] = "v7 in component v7 (flux)" legend_states[4] = "E2 in component E2 (molecules)" legend_algebraic[6] = "v8 in component v8 (flux)" legend_algebraic[7] = "v9 in component v9 (flux)" legend_algebraic[8] = "v10 in component v10 (flux)" legend_algebraic[9] = "v11 in component v11 (flux)" legend_algebraic[10] = "v12 in component v12 (flux)" legend_algebraic[11] = "v13 in component v13 (flux)" legend_algebraic[12] = "v14 in component v14 (flux)" legend_algebraic[13] = "v15 in component v15 (flux)" legend_states[5] = "E3 in component E3 (molecules)" legend_states[6] = "DUB in component DUB (molecules)" legend_states[7] = "Proteasome in component Proteasome (molecules)" legend_algebraic[22] = "v24 in component v24 (flux)" legend_algebraic[23] = "v25 in component v25 (flux)" legend_algebraic[24] = "v26 in component v26 (flux)" legend_algebraic[25] = "v27 in component v27 (flux)" legend_algebraic[26] = "v28 in component v28 (flux)" legend_algebraic[92] = "v94 in component v94 (flux)" legend_states[8] = "ROS in component ROS (molecules)" legend_states[9] = "E1_Ub in component E1_Ub (molecules)" legend_states[10] = "E2_Ub in component E2_Ub (molecules)" legend_states[11] = "E3_MisP in component E3_MisP (molecules)" legend_states[12] = "MisP_Ub in component MisP_Ub (molecules)" legend_algebraic[39] = "v41 in component v41 (flux)" legend_algebraic[55] = "v57 in component v57 (flux)" legend_algebraic[63] = "v65 in component v65 (flux)" legend_algebraic[64] = "v66 in component v66 (flux)" legend_algebraic[65] = "v67 in component v67 (flux)" legend_algebraic[66] = "v68 in component v68 (flux)" legend_algebraic[67] = "v69 in component v69 (flux)" legend_algebraic[68] = "v70 in component v70 (flux)" legend_algebraic[69] = "v71 in component v71 (flux)" legend_states[13] = "MisP_Ub2 in component MisP_Ub2 (molecules)" legend_algebraic[40] = "v42 in component v42 (flux)" legend_algebraic[56] = "v58 in component v58 (flux)" legend_algebraic[70] = "v72 in component v72 (flux)" legend_algebraic[71] = "v73 in component v73 (flux)" legend_algebraic[72] = "v74 in component v74 (flux)" legend_algebraic[73] = "v75 in component v75 (flux)" legend_algebraic[74] = "v76 in component v76 (flux)" legend_algebraic[75] = "v77 in component v77 (flux)" legend_states[14] = "MisP_Ub3 in component MisP_Ub3 (molecules)" legend_algebraic[41] = "v43 in component v43 (flux)" legend_algebraic[57] = "v59 in component v59 (flux)" legend_algebraic[76] = "v78 in component v78 (flux)" legend_algebraic[77] = "v79 in component v79 (flux)" legend_algebraic[78] = "v80 in component v80 (flux)" legend_algebraic[79] = "v81 in component v81 (flux)" legend_algebraic[80] = "v82 in component v82 (flux)" legend_states[15] = "MisP_Ub4 in component MisP_Ub4 (molecules)" legend_algebraic[42] = "v44 in component v44 (flux)" legend_algebraic[58] = "v60 in component v60 (flux)" legend_algebraic[81] = "v83 in component v83 (flux)" legend_algebraic[82] = "v84 in component v84 (flux)" legend_algebraic[83] = "v85 in component v85 (flux)" legend_algebraic[84] = "v86 in component v86 (flux)" legend_states[16] = "MisP_Ub5 in component MisP_Ub5 (molecules)" legend_algebraic[43] = "v45 in component v45 (flux)" legend_algebraic[59] = "v61 in component v61 (flux)" legend_algebraic[85] = "v87 in component v87 (flux)" legend_algebraic[86] = "v88 in component v88 (flux)" legend_algebraic[87] = "v89 in component v89 (flux)" legend_states[17] = "MisP_Ub6 in component MisP_Ub6 (molecules)" legend_algebraic[44] = "v46 in component v46 (flux)" legend_algebraic[60] = "v62 in component v62 (flux)" legend_algebraic[88] = "v90 in component v90 (flux)" legend_algebraic[89] = "v91 in component v91 (flux)" legend_states[18] = "MisP_Ub7 in component MisP_Ub7 (molecules)" legend_algebraic[45] = "v47 in component v47 (flux)" legend_algebraic[61] = "v63 in component v63 (flux)" legend_algebraic[90] = "v92 in component v92 (flux)" legend_states[19] = "MisP_Ub8 in component MisP_Ub8 (molecules)" legend_algebraic[46] = "v48 in component v48 (flux)" legend_algebraic[62] = "v64 in component v64 (flux)" legend_states[20] = "MisP_Ub4_Proteasome in component MisP_Ub4_Proteasome (molecules)" legend_states[21] = "MisP_Ub5_Proteasome in component MisP_Ub5_Proteasome (molecules)" legend_states[22] = "MisP_Ub6_Proteasome in component MisP_Ub6_Proteasome (molecules)" legend_states[23] = "MisP_Ub7_Proteasome in component MisP_Ub7_Proteasome (molecules)" legend_states[24] = "MisP_Ub8_Proteasome in component MisP_Ub8_Proteasome (molecules)" legend_states[25] = "ATP in component ATP (molecules)" legend_states[26] = "ADP in component ADP (molecules)" legend_states[27] = "AMP in component AMP (molecules)" legend_states[28] = "degUb4 in component degUb4 (molecules)" legend_states[29] = "degUb5 in component degUb5 (molecules)" legend_states[30] = "degUb6 in component degUb6 (molecules)" legend_states[31] = "degUb7 in component degUb7 (molecules)" legend_states[32] = "degUb8 in component degUb8 (molecules)" legend_states[33] = "MisP_total in component MisP_total (molecules)" legend_states[34] = "NatP_refolded in component NatP_refolded (molecules)" legend_states[35] = "AggP in component AggP (molecules)" legend_algebraic[91] = "v93 in component v93 (flux)" legend_states[36] = "SeqAggP in component SeqAggP (molecules)" legend_states[37] = "AggP_Proteasome in component AggP_Proteasome (molecules)" legend_constants[0] = "k1 in component kinetic_parameters (flux)" legend_constants[1] = "k2 in component kinetic_parameters (second_order_rate_constant)" legend_constants[2] = "k3 in component kinetic_parameters (first_order_rate_constant)" legend_constants[3] = "k61 in component kinetic_parameters (second_order_rate_constant)" legend_constants[4] = "k61r in component kinetic_parameters (first_order_rate_constant)" legend_constants[5] = "k62 in component kinetic_parameters (second_order_rate_constant)" legend_constants[6] = "k63 in component kinetic_parameters (second_order_rate_constant)" legend_constants[7] = "k64 in component kinetic_parameters (second_order_rate_constant)" legend_constants[8] = "k65 in component kinetic_parameters (second_order_rate_constant)" legend_constants[9] = "k66 in component kinetic_parameters (second_order_rate_constant)" legend_constants[10] = "k67 in component kinetic_parameters (second_order_rate_constant)" legend_constants[11] = "k68 in component kinetic_parameters (second_order_rate_constant)" legend_constants[12] = "k69 in component kinetic_parameters (first_order_rate_constant)" legend_constants[13] = "k71 in component kinetic_parameters (second_order_rate_constant)" legend_constants[14] = "k72 in component kinetic_parameters (second_order_rate_constant)" legend_constants[15] = "k73 in component kinetic_parameters (first_order_rate_constant)" legend_constants[16] = "k74 in component kinetic_parameters (second_order_rate_constant)" legend_rates[0] = "d/dt NatP in component NatP (molecules)" legend_rates[1] = "d/dt MisP in component MisP (molecules)" legend_rates[2] = "d/dt Ub in component Ub (molecules)" legend_rates[3] = "d/dt E1 in component E1 (molecules)" legend_rates[4] = "d/dt E2 in component E2 (molecules)" legend_rates[5] = "d/dt E3 in component E3 (molecules)" legend_rates[6] = "d/dt DUB in component DUB (molecules)" legend_rates[7] = "d/dt Proteasome in component Proteasome (molecules)" legend_rates[8] = "d/dt ROS in component ROS (molecules)" legend_rates[9] = "d/dt E1_Ub in component E1_Ub (molecules)" legend_rates[10] = "d/dt E2_Ub in component E2_Ub (molecules)" legend_rates[11] = "d/dt E3_MisP in component E3_MisP (molecules)" legend_rates[12] = "d/dt MisP_Ub in component MisP_Ub (molecules)" legend_rates[13] = "d/dt MisP_Ub2 in component MisP_Ub2 (molecules)" legend_rates[14] = "d/dt MisP_Ub3 in component MisP_Ub3 (molecules)" legend_rates[15] = "d/dt MisP_Ub4 in component MisP_Ub4 (molecules)" legend_rates[16] = "d/dt MisP_Ub5 in component MisP_Ub5 (molecules)" legend_rates[17] = "d/dt MisP_Ub6 in component MisP_Ub6 (molecules)" legend_rates[18] = "d/dt MisP_Ub7 in component MisP_Ub7 (molecules)" legend_rates[19] = "d/dt MisP_Ub8 in component MisP_Ub8 (molecules)" legend_rates[20] = "d/dt MisP_Ub4_Proteasome in component MisP_Ub4_Proteasome (molecules)" legend_rates[21] = "d/dt MisP_Ub5_Proteasome in component MisP_Ub5_Proteasome (molecules)" legend_rates[22] = "d/dt MisP_Ub6_Proteasome in component MisP_Ub6_Proteasome (molecules)" legend_rates[23] = "d/dt MisP_Ub7_Proteasome in component MisP_Ub7_Proteasome (molecules)" legend_rates[24] = "d/dt MisP_Ub8_Proteasome in component MisP_Ub8_Proteasome (molecules)" legend_rates[25] = "d/dt ATP in component ATP (molecules)" legend_rates[26] = "d/dt ADP in component ADP (molecules)" legend_rates[27] = "d/dt AMP in component AMP (molecules)" legend_rates[28] = "d/dt degUb4 in component degUb4 (molecules)" legend_rates[29] = "d/dt degUb5 in component degUb5 (molecules)" legend_rates[30] = "d/dt degUb6 in component degUb6 (molecules)" legend_rates[31] = "d/dt degUb7 in component degUb7 (molecules)" legend_rates[32] = "d/dt degUb8 in component degUb8 (molecules)" legend_rates[33] = "d/dt MisP_total in component MisP_total (molecules)" legend_rates[34] = "d/dt NatP_refolded in component NatP_refolded (molecules)" legend_rates[35] = "d/dt AggP in component AggP (molecules)" legend_rates[36] = "d/dt SeqAggP in component SeqAggP (molecules)" legend_rates[37] = "d/dt AggP_Proteasome in component AggP_Proteasome (molecules)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; states[0] = 500 states[1] = 0 states[2] = 500 states[3] = 100 states[4] = 100 states[5] = 100 states[6] = 200 states[7] = 100 states[8] = 10 states[9] = 0 states[10] = 0 states[11] = 0 states[12] = 0 states[13] = 0 states[14] = 0 states[15] = 0 states[16] = 0 states[17] = 0 states[18] = 0 states[19] = 0 states[20] = 0 states[21] = 0 states[22] = 0 states[23] = 0 states[24] = 0 states[25] = 10000 states[26] = 1000 states[27] = 1000 states[28] = 0 states[29] = 0 states[30] = 0 states[31] = 0 states[32] = 0 states[33] = 0 states[34] = 0 states[35] = 0 states[36] = 0 states[37] = 0 constants[0] = 0.01 constants[1] = 2e-6 constants[2] = 4e-6 constants[3] = 1.7e-5 constants[4] = 2e-4 constants[5] = 2e-4 constants[6] = 1e-3 constants[7] = 1e-3 constants[8] = 1e-3 constants[9] = 1e-5 constants[10] = 1e-5 constants[11] = 1e-5 constants[12] = 0 constants[13] = 1e-8 constants[14] = 1e-8 constants[15] = 1e-3 constants[16] = 1e-5 constants[17] = constants[0] constants[18] = 0.00000 constants[19] = 0.00000 constants[20] = 0.00000 return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic rates[25] = constants[18] rates[26] = constants[19] rates[27] = constants[20] algebraic[0] = constants[1]*states[0]*states[8] rates[8] = algebraic[0]-algebraic[0] rates[33] = algebraic[0] algebraic[1] = constants[2]*states[1] rates[0] = (constants[17]+algebraic[1])-algebraic[0] rates[34] = algebraic[1] algebraic[4] = (constants[5]*states[3]*states[2]*states[25])/(5000.00+states[25]) algebraic[5] = constants[6]*states[4]*states[9] rates[3] = algebraic[5]-algebraic[4] rates[9] = algebraic[4]-algebraic[5] algebraic[3] = constants[4]*states[11] algebraic[2] = constants[3]*states[5]*states[1] algebraic[6] = constants[7]*states[10]*states[11] rates[5] = (algebraic[3]+algebraic[6])-algebraic[2] rates[11] = (algebraic[2]-algebraic[3])-algebraic[6] algebraic[7] = constants[8]*states[10]*states[12] algebraic[8] = constants[8]*states[10]*states[13] algebraic[9] = constants[8]*states[10]*states[14] algebraic[10] = constants[8]*states[10]*states[15] algebraic[11] = constants[8]*states[10]*states[16] algebraic[12] = constants[8]*states[10]*states[17] algebraic[13] = constants[8]*states[10]*states[18] rates[4] = (algebraic[6]+algebraic[7]+algebraic[8]+algebraic[9]+algebraic[10]+algebraic[11]+algebraic[12]+algebraic[13])-algebraic[5] rates[10] = (((((((algebraic[5]-algebraic[6])-algebraic[7])-algebraic[8])-algebraic[9])-algebraic[10])-algebraic[11])-algebraic[12])-algebraic[13] algebraic[21] = constants[9]*states[6]*states[12] algebraic[14] = constants[9]*states[6]*states[19] algebraic[15] = constants[9]*states[6]*states[18] algebraic[16] = constants[9]*states[6]*states[17] algebraic[17] = constants[9]*states[6]*states[16] algebraic[18] = constants[9]*states[6]*states[15] algebraic[19] = constants[9]*states[6]*states[14] algebraic[20] = constants[9]*states[6]*states[13] algebraic[27] = constants[11]*states[6]*states[20] algebraic[28] = constants[11]*states[6]*states[21] algebraic[29] = constants[11]*states[6]*states[22] algebraic[30] = constants[11]*states[6]*states[23] algebraic[31] = constants[11]*states[6]*states[24] rates[6] = (algebraic[14]+algebraic[15]+algebraic[16]+algebraic[17]+algebraic[18]+algebraic[19]+algebraic[20]+algebraic[21]+algebraic[27]+algebraic[28]+algebraic[29]+algebraic[30]+algebraic[31])-(algebraic[14]+algebraic[15]+algebraic[16]+algebraic[17]+algebraic[18]+algebraic[19]+algebraic[20]+algebraic[21]+algebraic[27]+algebraic[28]+algebraic[29]+algebraic[30]+algebraic[31]) algebraic[32] = (constants[12]*states[20]*states[25])/(5000.00+states[25]) algebraic[22] = constants[10]*states[15]*states[7] rates[20] = (algebraic[22]+algebraic[28])-(algebraic[27]+algebraic[32]) rates[28] = algebraic[32] algebraic[33] = (constants[12]*states[21]*states[25])/(5000.00+states[25]) algebraic[23] = constants[10]*states[16]*states[7] rates[21] = (algebraic[23]+algebraic[29])-(algebraic[28]+algebraic[33]) rates[29] = algebraic[33] algebraic[34] = (constants[12]*states[22]*states[25])/(5000.00+states[25]) algebraic[24] = constants[10]*states[17]*states[7] rates[22] = (algebraic[24]+algebraic[30])-(algebraic[29]+algebraic[34]) rates[30] = algebraic[34] algebraic[35] = (constants[12]*states[23]*states[25])/(5000.00+states[25]) algebraic[25] = constants[10]*states[18]*states[7] rates[23] = (algebraic[25]+algebraic[31])-(algebraic[30]+algebraic[35]) rates[31] = algebraic[35] algebraic[36] = (constants[12]*states[24]*states[25])/(5000.00+states[25]) rates[2] = (algebraic[14]+algebraic[15]+algebraic[16]+algebraic[17]+algebraic[18]+algebraic[19]+algebraic[20]+algebraic[21]+algebraic[27]+algebraic[28]+algebraic[29]+algebraic[30]+algebraic[31]+4.00000*algebraic[32]+5.00000*algebraic[33]+6.00000*algebraic[34]+7.00000*algebraic[35]+8.00000*algebraic[36])-algebraic[4] algebraic[26] = constants[10]*states[19]*states[7] rates[24] = algebraic[26]-(algebraic[31]+algebraic[36]) rates[32] = algebraic[36] algebraic[37] = (constants[13]*states[1]*(states[1]-1.00000))/2.00000 algebraic[38] = constants[13]*states[1]*states[35] algebraic[47] = constants[14]*states[1]*states[12] algebraic[48] = constants[14]*states[1]*states[13] algebraic[49] = constants[14]*states[1]*states[14] algebraic[50] = constants[14]*states[1]*states[15] algebraic[51] = constants[14]*states[1]*states[16] algebraic[52] = constants[14]*states[1]*states[17] algebraic[53] = constants[14]*states[1]*states[18] algebraic[54] = constants[14]*states[1]*states[19] rates[1] = (algebraic[0]+algebraic[3]+algebraic[21])-(algebraic[1]+algebraic[2]+2.00000*algebraic[37]+algebraic[38]+algebraic[47]+algebraic[48]+algebraic[49]+algebraic[50]+algebraic[51]+algebraic[52]+algebraic[53]+algebraic[54]) algebraic[39] = (constants[14]*states[12]*(states[12]-1.00000))/2.00000 algebraic[55] = constants[14]*states[35]*states[12] algebraic[63] = constants[14]*states[12]*states[13] algebraic[64] = constants[14]*states[12]*states[14] algebraic[65] = constants[14]*states[12]*states[15] algebraic[66] = constants[14]*states[12]*states[16] algebraic[67] = constants[14]*states[12]*states[17] algebraic[68] = constants[14]*states[12]*states[18] algebraic[69] = constants[14]*states[12]*states[19] rates[12] = (algebraic[6]+algebraic[20])-(algebraic[7]+algebraic[21]+2.00000*algebraic[39]+algebraic[47]+algebraic[55]+algebraic[63]+algebraic[64]+algebraic[65]+algebraic[66]+algebraic[67]+algebraic[68]+algebraic[69]) algebraic[40] = (constants[14]*states[13]*(states[13]-1.00000))/2.00000 algebraic[56] = constants[14]*states[35]*states[13] algebraic[70] = constants[14]*states[13]*states[14] algebraic[71] = constants[14]*states[13]*states[15] algebraic[72] = constants[14]*states[13]*states[16] algebraic[73] = constants[14]*states[13]*states[17] algebraic[74] = constants[14]*states[13]*states[18] algebraic[75] = constants[14]*states[13]*states[19] rates[13] = (algebraic[7]+algebraic[19])-(algebraic[8]+algebraic[20]+2.00000*algebraic[40]+algebraic[48]+algebraic[56]+algebraic[63]+algebraic[70]+algebraic[71]+algebraic[72]+algebraic[73]+algebraic[74]+algebraic[75]) algebraic[41] = (constants[14]*states[14]*(states[14]-1.00000))/2.00000 algebraic[57] = constants[14]*states[35]*states[14] algebraic[76] = constants[14]*states[14]*states[15] algebraic[77] = constants[14]*states[14]*states[16] algebraic[78] = constants[14]*states[14]*states[17] algebraic[79] = constants[14]*states[14]*states[18] algebraic[80] = constants[14]*states[14]*states[19] rates[14] = (algebraic[8]+algebraic[18]+algebraic[27])-(algebraic[9]+algebraic[19]+2.00000*algebraic[41]+algebraic[49]+algebraic[57]+algebraic[64]+algebraic[70]+algebraic[76]+algebraic[77]+algebraic[78]+algebraic[79]+algebraic[80]) algebraic[42] = (constants[14]*states[15]*(states[15]-1.00000))/2.00000 algebraic[58] = constants[14]*states[35]*states[15] algebraic[81] = constants[14]*states[15]*states[16] algebraic[82] = constants[14]*states[15]*states[17] algebraic[83] = constants[14]*states[15]*states[18] algebraic[84] = constants[14]*states[15]*states[19] rates[15] = (algebraic[9]+algebraic[17])-(algebraic[10]+algebraic[18]+algebraic[22]+2.00000*algebraic[42]+algebraic[50]+algebraic[58]+algebraic[65]+algebraic[71]+algebraic[76]+algebraic[81]+algebraic[82]+algebraic[83]+algebraic[84]) algebraic[43] = (constants[14]*states[16]*(states[16]-1.00000))/2.00000 algebraic[59] = constants[14]*states[35]*states[16] algebraic[85] = constants[14]*states[16]*states[17] algebraic[86] = constants[14]*states[16]*states[18] algebraic[87] = constants[14]*states[16]*states[19] rates[16] = (algebraic[10]+algebraic[16])-(algebraic[11]+algebraic[17]+algebraic[23]+2.00000*algebraic[43]+algebraic[51]+algebraic[59]+algebraic[66]+algebraic[72]+algebraic[77]+algebraic[81]+algebraic[85]+algebraic[86]+algebraic[87]) algebraic[44] = (constants[14]*states[17]*(states[17]-1.00000))/2.00000 algebraic[60] = constants[14]*states[35]*states[17] algebraic[88] = constants[14]*states[17]*states[18] algebraic[89] = constants[14]*states[17]*states[19] rates[17] = (algebraic[11]+algebraic[15])-(algebraic[12]+algebraic[16]+algebraic[24]+2.00000*algebraic[44]+algebraic[52]+algebraic[60]+algebraic[67]+algebraic[73]+algebraic[78]+algebraic[82]+algebraic[85]+algebraic[88]+algebraic[89]) algebraic[45] = (constants[14]*states[18]*(states[18]-1.00000))/2.00000 algebraic[61] = constants[14]*states[35]*states[18] algebraic[90] = constants[14]*states[18]*states[19] rates[18] = (algebraic[12]+algebraic[14])-(algebraic[13]+algebraic[15]+algebraic[25]+2.00000*algebraic[45]+algebraic[53]+algebraic[61]+algebraic[68]+algebraic[74]+algebraic[79]+algebraic[83]+algebraic[86]+algebraic[88]+algebraic[90]) algebraic[46] = (constants[14]*states[19]*(states[19]-1.00000))/2.00000 algebraic[62] = constants[14]*states[35]*states[19] rates[19] = algebraic[13]-(algebraic[14]+algebraic[26]+2.00000*algebraic[46]+algebraic[54]+algebraic[62]+algebraic[69]+algebraic[75]+algebraic[80]+algebraic[84]+algebraic[87]+algebraic[89]+algebraic[90]) algebraic[91] = constants[15]*states[35] rates[36] = algebraic[91] algebraic[92] = constants[16]*states[35]*states[7] rates[7] = (algebraic[27]+algebraic[32]+algebraic[33]+algebraic[34]+algebraic[35]+algebraic[36])-(algebraic[22]+algebraic[23]+algebraic[24]+algebraic[25]+algebraic[26]+algebraic[92]) rates[35] = (algebraic[37]+2.00000*algebraic[38]+algebraic[39]+algebraic[40]+algebraic[41]+algebraic[42]+algebraic[43]+algebraic[44]+algebraic[45]+algebraic[46]+algebraic[47]+algebraic[48]+algebraic[49]+algebraic[50]+algebraic[51]+algebraic[52]+algebraic[53]+algebraic[54]+2.00000*algebraic[55]+2.00000*algebraic[56]+2.00000*algebraic[57]+2.00000*algebraic[58]+2.00000*algebraic[59]+2.00000*algebraic[60]+2.00000*algebraic[61]+2.00000*algebraic[62]+algebraic[63]+algebraic[64]+algebraic[65]+algebraic[66]+algebraic[67]+algebraic[68]+algebraic[69]+algebraic[70]+algebraic[71]+algebraic[72]+algebraic[73]+algebraic[74]+algebraic[75]+algebraic[76]+algebraic[77]+algebraic[78]+algebraic[79]+algebraic[80]+algebraic[81]+algebraic[82]+algebraic[83]+algebraic[84]+algebraic[85]+algebraic[86]+algebraic[87]+algebraic[88]+algebraic[89]+algebraic[90])-(algebraic[38]+algebraic[55]+algebraic[56]+algebraic[57]+algebraic[58]+algebraic[59]+algebraic[60]+algebraic[61]+algebraic[62]+algebraic[91]+algebraic[92]) rates[37] = algebraic[92] return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[0] = constants[1]*states[0]*states[8] algebraic[1] = constants[2]*states[1] algebraic[4] = (constants[5]*states[3]*states[2]*states[25])/(5000.00+states[25]) algebraic[5] = constants[6]*states[4]*states[9] algebraic[3] = constants[4]*states[11] algebraic[2] = constants[3]*states[5]*states[1] algebraic[6] = constants[7]*states[10]*states[11] algebraic[7] = constants[8]*states[10]*states[12] algebraic[8] = constants[8]*states[10]*states[13] algebraic[9] = constants[8]*states[10]*states[14] algebraic[10] = constants[8]*states[10]*states[15] algebraic[11] = constants[8]*states[10]*states[16] algebraic[12] = constants[8]*states[10]*states[17] algebraic[13] = constants[8]*states[10]*states[18] algebraic[21] = constants[9]*states[6]*states[12] algebraic[14] = constants[9]*states[6]*states[19] algebraic[15] = constants[9]*states[6]*states[18] algebraic[16] = constants[9]*states[6]*states[17] algebraic[17] = constants[9]*states[6]*states[16] algebraic[18] = constants[9]*states[6]*states[15] algebraic[19] = constants[9]*states[6]*states[14] algebraic[20] = constants[9]*states[6]*states[13] algebraic[27] = constants[11]*states[6]*states[20] algebraic[28] = constants[11]*states[6]*states[21] algebraic[29] = constants[11]*states[6]*states[22] algebraic[30] = constants[11]*states[6]*states[23] algebraic[31] = constants[11]*states[6]*states[24] algebraic[32] = (constants[12]*states[20]*states[25])/(5000.00+states[25]) algebraic[22] = constants[10]*states[15]*states[7] algebraic[33] = (constants[12]*states[21]*states[25])/(5000.00+states[25]) algebraic[23] = constants[10]*states[16]*states[7] algebraic[34] = (constants[12]*states[22]*states[25])/(5000.00+states[25]) algebraic[24] = constants[10]*states[17]*states[7] algebraic[35] = (constants[12]*states[23]*states[25])/(5000.00+states[25]) algebraic[25] = constants[10]*states[18]*states[7] algebraic[36] = (constants[12]*states[24]*states[25])/(5000.00+states[25]) algebraic[26] = constants[10]*states[19]*states[7] algebraic[37] = (constants[13]*states[1]*(states[1]-1.00000))/2.00000 algebraic[38] = constants[13]*states[1]*states[35] algebraic[47] = constants[14]*states[1]*states[12] algebraic[48] = constants[14]*states[1]*states[13] algebraic[49] = constants[14]*states[1]*states[14] algebraic[50] = constants[14]*states[1]*states[15] algebraic[51] = constants[14]*states[1]*states[16] algebraic[52] = constants[14]*states[1]*states[17] algebraic[53] = constants[14]*states[1]*states[18] algebraic[54] = constants[14]*states[1]*states[19] algebraic[39] = (constants[14]*states[12]*(states[12]-1.00000))/2.00000 algebraic[55] = constants[14]*states[35]*states[12] algebraic[63] = constants[14]*states[12]*states[13] algebraic[64] = constants[14]*states[12]*states[14] algebraic[65] = constants[14]*states[12]*states[15] algebraic[66] = constants[14]*states[12]*states[16] algebraic[67] = constants[14]*states[12]*states[17] algebraic[68] = constants[14]*states[12]*states[18] algebraic[69] = constants[14]*states[12]*states[19] algebraic[40] = (constants[14]*states[13]*(states[13]-1.00000))/2.00000 algebraic[56] = constants[14]*states[35]*states[13] algebraic[70] = constants[14]*states[13]*states[14] algebraic[71] = constants[14]*states[13]*states[15] algebraic[72] = constants[14]*states[13]*states[16] algebraic[73] = constants[14]*states[13]*states[17] algebraic[74] = constants[14]*states[13]*states[18] algebraic[75] = constants[14]*states[13]*states[19] algebraic[41] = (constants[14]*states[14]*(states[14]-1.00000))/2.00000 algebraic[57] = constants[14]*states[35]*states[14] algebraic[76] = constants[14]*states[14]*states[15] algebraic[77] = constants[14]*states[14]*states[16] algebraic[78] = constants[14]*states[14]*states[17] algebraic[79] = constants[14]*states[14]*states[18] algebraic[80] = constants[14]*states[14]*states[19] algebraic[42] = (constants[14]*states[15]*(states[15]-1.00000))/2.00000 algebraic[58] = constants[14]*states[35]*states[15] algebraic[81] = constants[14]*states[15]*states[16] algebraic[82] = constants[14]*states[15]*states[17] algebraic[83] = constants[14]*states[15]*states[18] algebraic[84] = constants[14]*states[15]*states[19] algebraic[43] = (constants[14]*states[16]*(states[16]-1.00000))/2.00000 algebraic[59] = constants[14]*states[35]*states[16] algebraic[85] = constants[14]*states[16]*states[17] algebraic[86] = constants[14]*states[16]*states[18] algebraic[87] = constants[14]*states[16]*states[19] algebraic[44] = (constants[14]*states[17]*(states[17]-1.00000))/2.00000 algebraic[60] = constants[14]*states[35]*states[17] algebraic[88] = constants[14]*states[17]*states[18] algebraic[89] = constants[14]*states[17]*states[19] algebraic[45] = (constants[14]*states[18]*(states[18]-1.00000))/2.00000 algebraic[61] = constants[14]*states[35]*states[18] algebraic[90] = constants[14]*states[18]*states[19] algebraic[46] = (constants[14]*states[19]*(states[19]-1.00000))/2.00000 algebraic[62] = constants[14]*states[35]*states[19] algebraic[91] = constants[15]*states[35] algebraic[92] = constants[16]*states[35]*states[7] return algebraic 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)