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 = 51
sizeStates = 22
sizeConstants = 87
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 (hour)"
legend_constants[0] = "k16 in component v1 (per_hour)"
legend_states[0] = "ERG in component ERGcomp (dimensionless)"
legend_algebraic[8] = "v_1 in component v1 (per_hour)"
legend_constants[1] = "k18 in component v2 (per_hour)"
legend_states[1] = "DRG in component DRGcomp (dimensionless)"
legend_algebraic[10] = "v_2 in component v2 (per_hour)"
legend_constants[2] = "K10 in component v3 (per_hour)"
legend_states[2] = "CD in component CDcomp (dimensionless)"
legend_algebraic[0] = "v_3 in component v3 (per_hour)"
legend_states[3] = "CYCD in component CYCDcomp (dimensionless)"
legend_algebraic[12] = "v_4 in component v4 (per_hour)"
legend_constants[3] = "K25 in component v5 (per_hour)"
legend_states[4] = "p27 in component p27cmp (dimensionless)"
legend_states[5] = "CYCE in component CYCEcomp (dimensionless)"
legend_algebraic[21] = "v_5 in component v5 (per_hour)"
legend_states[6] = "CYCA in component CYCAcomp (dimensionless)"
legend_algebraic[25] = "v_6 in component v6 (per_hour)"
legend_constants[4] = "k24 in component v7 (per_hour)"
legend_algebraic[27] = "v_7 in component v7 (per_hour)"
legend_constants[5] = "k24r in component v8 (per_hour)"
legend_algebraic[29] = "v_8 in component v8 (per_hour)"
legend_constants[6] = "K30 in component v9 (per_hour)"
legend_constants[7] = "Cdc20 in component v9 (dimensionless)"
legend_algebraic[31] = "v_9 in component v9 (per_hour)"
legend_constants[8] = "CA in component v10 (dimensionless)"
legend_constants[81] = "v_10 in component v10 (per_hour)"
legend_constants[9] = "K25R in component v11 (per_hour)"
legend_states[7] = "CE in component CEcomp (dimensionless)"
legend_algebraic[33] = "v_11 in component v11 (per_hour)"
legend_constants[85] = "v_12 in component v12 (per_hour)"
legend_algebraic[48] = "V_8 in component V8 (per_hour)"
legend_algebraic[49] = "v_13 in component v13 (per_hour)"
legend_algebraic[50] = "v_14 in component v14 (per_hour)"
legend_algebraic[43] = "V_6 in component V6 (per_hour)"
legend_algebraic[44] = "v_15 in component v15 (per_hour)"
legend_algebraic[47] = "v_16 in component v16 (per_hour)"
legend_algebraic[45] = "v_17 in component v17 (per_hour)"
legend_algebraic[46] = "v_18 in component v18 (per_hour)"
legend_algebraic[13] = "V_2 in component V2 (per_hour)"
legend_states[8] = "CYCB in component CYCBcomp (dimensionless)"
legend_algebraic[22] = "v_19 in component v19 (per_hour)"
legend_constants[10] = "K3a in component v20 (per_hour)"
legend_constants[11] = "K3 in component v20 (per_hour)"
legend_states[9] = "Cdh1 in component Cdh1cmp (dimensionless)"
legend_constants[12] = "J3 in component v20 (dimensionless)"
legend_algebraic[2] = "v_20 in component v20 (per_hour)"
legend_algebraic[14] = "V_4 in component V4 (per_hour)"
legend_constants[13] = "J4 in component v21 (dimensionless)"
legend_algebraic[23] = "v_21 in component v21 (per_hour)"
legend_constants[14] = "K34 in component v22 (per_hour)"
legend_states[10] = "PPX in component PPXcomp (dimensionless)"
legend_algebraic[3] = "v_22 in component v22 (per_hour)"
legend_constants[15] = "K31 in component v23 (per_hour)"
legend_states[11] = "IEP in component IEPcomp (dimensionless)"
legend_constants[16] = "J31 in component v23 (dimensionless)"
legend_algebraic[4] = "v_23 in component v23 (per_hour)"
legend_constants[17] = "K32 in component v24 (per_hour)"
legend_constants[18] = "J32 in component v24 (dimensionless)"
legend_algebraic[15] = "v_24 in component v24 (per_hour)"
legend_constants[19] = "K12 in component v25 (per_hour)"
legend_states[12] = "Cdc20T in component Cdc20Tcomp (dimensionless)"
legend_algebraic[9] = "v_25 in component v25 (per_hour)"
legend_constants[20] = "K13 in component v26 (per_hour)"
legend_constants[21] = "J13 in component v26 (dimensionless)"
legend_algebraic[5] = "v_26 in component v26 (per_hour)"
legend_constants[22] = "K14 in component v27 (per_hour)"
legend_constants[23] = "J14 in component v27 (dimensionless)"
legend_constants[82] = "v_27 in component v27 (per_hour)"
legend_constants[83] = "v_28 in component v28 (per_hour)"
legend_states[13] = "E2FRb in component E2FRbcomp (dimensionless)"
legend_constants[24] = "K20 in component v29 (per_hour)"
legend_constants[25] = "CYCDT in component v29 (dimensionless)"
legend_constants[26] = "LD in component v29 (dimensionless)"
legend_constants[27] = "LA in component v29 (dimensionless)"
legend_constants[28] = "LB in component v29 (dimensionless)"
legend_constants[29] = "LE in component v29 (dimensionless)"
legend_algebraic[11] = "v_29 in component v29 (per_hour)"
legend_states[14] = "PE2FRb in component PE2FRbcomp (dimensionless)"
legend_algebraic[20] = "v_30 in component v30 (per_hour)"
legend_constants[30] = "K27 in component v31 (per_hour)"
legend_states[15] = "MASS in component MASScomp (dimensionless)"
legend_constants[31] = "r31switch in component v31 (dimensionless)"
legend_algebraic[6] = "v_31 in component v31 (per_hour)"
legend_constants[32] = "K28 in component v32 (per_hour)"
legend_states[16] = "GM in component GMcomp (dimensionless)"
legend_algebraic[16] = "v_32 in component v32 (per_hour)"
legend_constants[33] = "eps in component v33 (dimensionless)"
legend_constants[34] = "MU in component v33 (per_hour)"
legend_algebraic[7] = "v_33 in component v33 (per_hour)"
legend_constants[35] = "k15 in component v34 (per_hour)"
legend_constants[36] = "J15 in component v34 (dimensionless)"
legend_algebraic[17] = "v_34 in component v34 (per_hour)"
legend_constants[37] = "K11a in component v35 (per_hour)"
legend_constants[38] = "K11 in component v35 (per_hour)"
legend_algebraic[18] = "v_35 in component v35 (per_hour)"
legend_constants[39] = "K29 in component v36 (per_hour)"
legend_states[17] = "E2F in component E2Fcomp (dimensionless)"
legend_algebraic[35] = "v_36 in component v36 (per_hour)"
legend_constants[40] = "K33 in component v37 (per_hour)"
legend_constants[84] = "v_37 in component v37 (per_hour)"
legend_constants[41] = "K7a in component v38 (per_hour)"
legend_constants[42] = "K7 in component v38 (per_hour)"
legend_algebraic[37] = "v_38 in component v38 (per_hour)"
legend_constants[43] = "K9 in component v39 (per_hour)"
legend_algebraic[40] = "v_39 in component v39 (per_hour)"
legend_constants[44] = "K5 in component v40 (per_hour)"
legend_constants[86] = "v_40 in component v40 (per_hour)"
legend_constants[45] = "k17 in component v41 (per_hour)"
legend_constants[46] = "J17 in component v41 (dimensionless)"
legend_constants[47] = "k17a in component v41 (per_hour)"
legend_algebraic[19] = "v_41 in component v41 (per_hour)"
legend_constants[48] = "K1 in component v42 (per_hour)"
legend_constants[49] = "J1 in component v42 (dimensionless)"
legend_constants[50] = "K1a in component v42 (per_hour)"
legend_algebraic[1] = "v_42 in component v42 (per_hour)"
legend_states[18] = "Rb in component Rbcomp (dimensionless)"
legend_algebraic[24] = "v_43 in component v43 (per_hour)"
legend_states[19] = "PPRb in component PPRbcomp (dimensionless)"
legend_constants[51] = "K19 in component v44 (per_hour)"
legend_constants[52] = "K19a in component v44 (per_hour)"
legend_constants[53] = "PP1T in component v44 (dimensionless)"
legend_algebraic[38] = "PP1A in component PP1Acomp (dimensionless)"
legend_algebraic[41] = "v_44 in component v44 (per_hour)"
legend_constants[54] = "K26R in component v45 (per_hour)"
legend_algebraic[26] = "v_45 in component v45 (per_hour)"
legend_constants[55] = "K23a in component v46 (per_hour)"
legend_constants[56] = "K23 in component v46 (per_hour)"
legend_algebraic[28] = "v_46 in component v46 (per_hour)"
legend_states[20] = "PE2F in component PE2Fcomp (dimensionless)"
legend_constants[57] = "K22 in component v47 (per_hour)"
legend_algebraic[30] = "v_47 in component v47 (per_hour)"
legend_constants[58] = "K26 in component v48 (per_hour)"
legend_algebraic[32] = "v_48 in component v48 (per_hour)"
legend_algebraic[34] = "v_49 in component v49 (per_hour)"
legend_algebraic[36] = "v_50 in component v50 (per_hour)"
legend_algebraic[39] = "v_51 in component v51 (per_hour)"
legend_algebraic[42] = "v_52 in component v52 (per_hour)"
legend_constants[59] = "PP1T in component PP1Acomp (dimensionless)"
legend_constants[60] = "K21 in component PP1Acomp (dimensionless)"
legend_constants[61] = "FE in component PP1Acomp (dimensionless)"
legend_constants[62] = "FB in component PP1Acomp (dimensionless)"
legend_constants[63] = "K2aa in component V2 (per_hour)"
legend_constants[64] = "K2a in component V2 (per_hour)"
legend_constants[65] = "K2 in component V2 (per_hour)"
legend_constants[66] = "K4 in component V4 (per_hour)"
legend_constants[67] = "GA in component V4 (dimensionless)"
legend_constants[68] = "GB in component V4 (dimensionless)"
legend_constants[69] = "GE in component V4 (dimensionless)"
legend_constants[70] = "K6a in component V6 (per_hour)"
legend_constants[71] = "K6 in component V6 (per_hour)"
legend_constants[72] = "HA in component V6 (dimensionless)"
legend_constants[73] = "HB in component V6 (dimensionless)"
legend_constants[74] = "HE in component V6 (dimensionless)"
legend_constants[75] = "K8a in component V8 (per_hour)"
legend_constants[76] = "K8 in component V8 (per_hour)"
legend_constants[77] = "J8 in component V8 (dimensionless)"
legend_constants[78] = "YE in component V8 (dimensionless)"
legend_constants[79] = "YB in component V8 (dimensionless)"
legend_constants[80] = "CYCET in component V8 (dimensionless)"
legend_states[21] = "CA in component CAcomp (dimensionless)"
legend_rates[21] = "d/dt CA in component CAcomp (dimensionless)"
legend_rates[2] = "d/dt CD in component CDcomp (dimensionless)"
legend_rates[12] = "d/dt Cdc20T in component Cdc20Tcomp (dimensionless)"
legend_rates[9] = "d/dt Cdh1 in component Cdh1cmp (dimensionless)"
legend_rates[7] = "d/dt CE in component CEcomp (dimensionless)"
legend_rates[6] = "d/dt CYCA in component CYCAcomp (dimensionless)"
legend_rates[8] = "d/dt CYCB in component CYCBcomp (dimensionless)"
legend_rates[3] = "d/dt CYCD in component CYCDcomp (dimensionless)"
legend_rates[5] = "d/dt CYCE in component CYCEcomp (dimensionless)"
legend_rates[1] = "d/dt DRG in component DRGcomp (dimensionless)"
legend_rates[0] = "d/dt ERG in component ERGcomp (dimensionless)"
legend_rates[16] = "d/dt GM in component GMcomp (dimensionless)"
legend_rates[11] = "d/dt IEP in component IEPcomp (dimensionless)"
legend_rates[15] = "d/dt MASS in component MASScomp (dimensionless)"
legend_rates[4] = "d/dt p27 in component p27cmp (dimensionless)"
legend_rates[10] = "d/dt PPX in component PPXcomp (dimensionless)"
legend_rates[19] = "d/dt PPRb in component PPRbcomp (dimensionless)"
legend_rates[17] = "d/dt E2F in component E2Fcomp (dimensionless)"
legend_rates[20] = "d/dt PE2F in component PE2Fcomp (dimensionless)"
legend_rates[18] = "d/dt Rb in component Rbcomp (dimensionless)"
legend_rates[13] = "d/dt E2FRb in component E2FRbcomp (dimensionless)"
legend_rates[14] = "d/dt PE2FRb in component PE2FRbcomp (dimensionless)"
return (legend_states, legend_algebraic, legend_voi, legend_constants)
def initConsts():
constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
constants[0] = 0.25
states[0] = 0.0121809
constants[1] = 10
states[1] = 0.900533
constants[2] = 5
states[2] = 0.010976
states[3] = 0.43929
constants[3] = 1000
states[4] = 0.00922806
states[5] = 0.0229112
states[6] = 1.4094
constants[4] = 1000
constants[5] = 10
constants[6] = 20
constants[7] = 0.00220177
constants[8] = 0.0356927
constants[9] = 10
states[7] = 0.000542587
states[8] = 2.72898
constants[10] = 7.5
constants[11] = 140
states[9] = 0.000653278
constants[12] = 0.01
constants[13] = 0.04
constants[14] = 0.05
states[10] = 1
constants[15] = 0.7
states[11] = 0.154655
constants[16] = 0.01
constants[17] = 1.8
constants[18] = 0.01
constants[19] = 1.5
states[12] = 2.36733
constants[20] = 5
constants[21] = 0.005
constants[22] = 2.5
constants[23] = 0.005
states[13] = 0.00478911
constants[24] = 10
constants[25] = 0.010976
constants[26] = 3.3
constants[27] = 3
constants[28] = 5
constants[29] = 5
states[14] = 0.0192822
constants[30] = 0.2
states[15] = 1.68776
constants[31] = 1
constants[32] = 0.2
states[16] = 1.35565
constants[33] = 1
constants[34] = 0.061
constants[35] = 0.25
constants[36] = 0.1
constants[37] = 0
constants[38] = 1.5
constants[39] = 0.05
states[17] = 0.989986
constants[40] = 0.05
constants[41] = 0
constants[42] = 0.6
constants[43] = 2.5
constants[44] = 20
constants[45] = 10
constants[46] = 0.3
constants[47] = 0.35
constants[48] = 0.6
constants[49] = 0.1
constants[50] = 0.1
states[18] = 0.000190871
states[19] = 9.97574
constants[51] = 20
constants[52] = 0
constants[53] = 1
constants[54] = 200
constants[55] = 0.005
constants[56] = 1
states[20] = 3.98594
constants[57] = 1
constants[58] = 10000
constants[59] = 1
constants[60] = 1
constants[61] = 25
constants[62] = 2
constants[63] = 1
constants[64] = 0.05
constants[65] = 20
constants[66] = 40
constants[67] = 0.3
constants[68] = 1
constants[69] = 0
constants[70] = 10
constants[71] = 100
constants[72] = 0.5
constants[73] = 1
constants[74] = 0.5
constants[75] = 0.1
constants[76] = 2
constants[77] = 0.1
constants[78] = 1
constants[79] = 0.05
constants[80] = 0.000542587
states[21] = 0.0356927
constants[81] = constants[6]*constants[7]*constants[8]
constants[82] = (constants[22]*constants[7])/(constants[23]+constants[7])
constants[83] = constants[19]*constants[7]
constants[84] = constants[33]*constants[40]
constants[85] = constants[9]*constants[8]
constants[86] = constants[33]*constants[44]
return (states, constants)
def computeRates(voi, states, constants):
rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
algebraic[7] = constants[33]*constants[34]*states[16]
rates[15] = algebraic[7]
algebraic[3] = constants[14]*states[10]
rates[10] = constants[84]-algebraic[3]
algebraic[9] = constants[19]*states[12]
algebraic[18] = constants[33]*constants[37]+constants[38]*states[8]
rates[12] = algebraic[18]-algebraic[9]
algebraic[10] = constants[1]*states[1]
algebraic[19] = constants[33]*((constants[45]*(power(states[1]/constants[46], 2.00000)))/(power(states[1]/constants[46], 2.00000)+1.00000)+constants[47]*states[0])
rates[1] = algebraic[19]-algebraic[10]
algebraic[8] = constants[0]*states[0]
algebraic[17] = (constants[33]*constants[35])/(power(states[1]/constants[36], 2.00000)+1.00000)
rates[0] = algebraic[17]-algebraic[8]
algebraic[6] = constants[30]*states[15]*constants[31]
algebraic[16] = constants[32]*states[16]
rates[16] = algebraic[6]-algebraic[16]
algebraic[4] = (constants[15]*states[8]*(1.00000-states[11]))/((constants[16]-states[11])+1.00000)
algebraic[15] = (constants[17]*states[10]*states[11])/(constants[18]+states[11])
rates[11] = algebraic[4]-algebraic[15]
algebraic[2] = ((constants[10]+constants[11]*constants[7])*(1.00000-states[9]))/((constants[12]-states[9])+1.00000)
algebraic[14] = constants[66]*(constants[67]*states[6]+constants[68]*states[8]+constants[69]*states[5])
algebraic[23] = (algebraic[14]*states[9])/(constants[13]+states[9])
rates[9] = algebraic[2]-algebraic[23]
algebraic[13] = constants[63]*constants[7]+constants[64]*(1.00000-states[9])+constants[65]*states[9]
algebraic[22] = algebraic[13]*states[8]
algebraic[1] = constants[33]*((constants[48]*(power(states[8]/constants[49], 2.00000)))/(power(states[8]/constants[49], 2.00000)+1.00000)+constants[50])
rates[8] = algebraic[1]-algebraic[22]
algebraic[11] = states[13]*constants[24]*(constants[25]*constants[26]+constants[27]*states[6]+constants[28]*states[8]+constants[29]*states[5])
algebraic[26] = states[13]*constants[54]
algebraic[28] = states[17]*(constants[55]+constants[56]*(states[6]+states[8]))
algebraic[30] = states[20]*constants[57]
algebraic[32] = states[17]*states[18]*constants[58]
rates[17] = ((algebraic[11]+algebraic[26]+algebraic[30])-algebraic[28])-algebraic[32]
algebraic[20] = states[14]*constants[24]*(constants[25]*constants[26]+constants[27]*states[6]+constants[28]*states[8]+constants[29]*states[5])
algebraic[34] = states[14]*constants[54]
algebraic[36] = states[18]*states[20]*constants[58]
rates[20] = ((algebraic[20]+algebraic[34]+algebraic[28])-algebraic[30])-algebraic[36]
algebraic[24] = states[18]*constants[24]*(constants[25]*constants[26]+constants[27]*states[6]+constants[28]*states[8]+constants[29]*states[5])
algebraic[38] = constants[59]/(constants[60]*constants[61]*(states[6]+states[5]+constants[62]*states[8])+1.00000)
algebraic[41] = states[19]*(constants[52]*(constants[53]-algebraic[38])+constants[51]*algebraic[38])
rates[19] = (algebraic[11]+algebraic[20]+algebraic[24])-algebraic[41]
rates[18] = (((algebraic[41]+algebraic[26]+algebraic[34])-algebraic[32])-algebraic[36])-algebraic[24]
algebraic[39] = states[14]*constants[57]
algebraic[42] = states[13]*(constants[55]+constants[56]*(states[6]+states[8]))
rates[13] = (((algebraic[39]+algebraic[32])-algebraic[42])-algebraic[11])-algebraic[26]
rates[14] = (((algebraic[42]+algebraic[36])-algebraic[39])-algebraic[20])-algebraic[34]
algebraic[25] = constants[3]*states[4]*states[6]
algebraic[43] = constants[70]+constants[71]*(constants[72]*states[6]+constants[73]*states[8]+constants[74]*states[5])
algebraic[46] = algebraic[43]*constants[8]
rates[21] = ((algebraic[25]-constants[85])-algebraic[46])-constants[81]
algebraic[0] = constants[2]*states[2]
algebraic[27] = constants[4]*states[4]*states[3]
algebraic[29] = constants[5]*states[2]
algebraic[45] = algebraic[43]*states[2]
rates[2] = ((algebraic[27]-algebraic[29])-algebraic[45])-algebraic[0]
algebraic[31] = constants[6]*constants[7]*states[6]
algebraic[35] = constants[33]*constants[39]*states[17]*states[15]
rates[6] = ((algebraic[35]-algebraic[31])-algebraic[25])+constants[85]+algebraic[46]
algebraic[12] = constants[2]*states[3]
algebraic[40] = constants[33]*constants[43]*states[1]
rates[3] = ((algebraic[40]+algebraic[45]+algebraic[29])-algebraic[27])-algebraic[12]
algebraic[21] = constants[3]*states[4]*states[5]
algebraic[33] = constants[9]*states[7]
algebraic[48] = (constants[76]*(constants[78]*(states[6]+states[5])+constants[79]*states[8]))/(constants[80]+constants[77])+constants[75]
algebraic[49] = algebraic[48]*states[7]
algebraic[47] = algebraic[43]*states[7]
rates[7] = ((algebraic[21]-algebraic[33])-algebraic[49])-algebraic[47]
algebraic[50] = algebraic[48]*states[5]
algebraic[37] = constants[33]*(constants[41]+constants[42]*states[17])
rates[5] = ((algebraic[37]-algebraic[50])-algebraic[21])+algebraic[33]+algebraic[47]
algebraic[44] = algebraic[43]*states[4]
rates[4] = (((((constants[86]+algebraic[0]+algebraic[29])-algebraic[44])-algebraic[21])-algebraic[25])-algebraic[27])+algebraic[33]+constants[85]+algebraic[49]+constants[81]
return(rates)
def computeAlgebraic(constants, states, voi):
algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
states = array(states)
voi = array(voi)
algebraic[7] = constants[33]*constants[34]*states[16]
algebraic[3] = constants[14]*states[10]
algebraic[9] = constants[19]*states[12]
algebraic[18] = constants[33]*constants[37]+constants[38]*states[8]
algebraic[10] = constants[1]*states[1]
algebraic[19] = constants[33]*((constants[45]*(power(states[1]/constants[46], 2.00000)))/(power(states[1]/constants[46], 2.00000)+1.00000)+constants[47]*states[0])
algebraic[8] = constants[0]*states[0]
algebraic[17] = (constants[33]*constants[35])/(power(states[1]/constants[36], 2.00000)+1.00000)
algebraic[6] = constants[30]*states[15]*constants[31]
algebraic[16] = constants[32]*states[16]
algebraic[4] = (constants[15]*states[8]*(1.00000-states[11]))/((constants[16]-states[11])+1.00000)
algebraic[15] = (constants[17]*states[10]*states[11])/(constants[18]+states[11])
algebraic[2] = ((constants[10]+constants[11]*constants[7])*(1.00000-states[9]))/((constants[12]-states[9])+1.00000)
algebraic[14] = constants[66]*(constants[67]*states[6]+constants[68]*states[8]+constants[69]*states[5])
algebraic[23] = (algebraic[14]*states[9])/(constants[13]+states[9])
algebraic[13] = constants[63]*constants[7]+constants[64]*(1.00000-states[9])+constants[65]*states[9]
algebraic[22] = algebraic[13]*states[8]
algebraic[1] = constants[33]*((constants[48]*(power(states[8]/constants[49], 2.00000)))/(power(states[8]/constants[49], 2.00000)+1.00000)+constants[50])
algebraic[11] = states[13]*constants[24]*(constants[25]*constants[26]+constants[27]*states[6]+constants[28]*states[8]+constants[29]*states[5])
algebraic[26] = states[13]*constants[54]
algebraic[28] = states[17]*(constants[55]+constants[56]*(states[6]+states[8]))
algebraic[30] = states[20]*constants[57]
algebraic[32] = states[17]*states[18]*constants[58]
algebraic[20] = states[14]*constants[24]*(constants[25]*constants[26]+constants[27]*states[6]+constants[28]*states[8]+constants[29]*states[5])
algebraic[34] = states[14]*constants[54]
algebraic[36] = states[18]*states[20]*constants[58]
algebraic[24] = states[18]*constants[24]*(constants[25]*constants[26]+constants[27]*states[6]+constants[28]*states[8]+constants[29]*states[5])
algebraic[38] = constants[59]/(constants[60]*constants[61]*(states[6]+states[5]+constants[62]*states[8])+1.00000)
algebraic[41] = states[19]*(constants[52]*(constants[53]-algebraic[38])+constants[51]*algebraic[38])
algebraic[39] = states[14]*constants[57]
algebraic[42] = states[13]*(constants[55]+constants[56]*(states[6]+states[8]))
algebraic[25] = constants[3]*states[4]*states[6]
algebraic[43] = constants[70]+constants[71]*(constants[72]*states[6]+constants[73]*states[8]+constants[74]*states[5])
algebraic[46] = algebraic[43]*constants[8]
algebraic[0] = constants[2]*states[2]
algebraic[27] = constants[4]*states[4]*states[3]
algebraic[29] = constants[5]*states[2]
algebraic[45] = algebraic[43]*states[2]
algebraic[31] = constants[6]*constants[7]*states[6]
algebraic[35] = constants[33]*constants[39]*states[17]*states[15]
algebraic[12] = constants[2]*states[3]
algebraic[40] = constants[33]*constants[43]*states[1]
algebraic[21] = constants[3]*states[4]*states[5]
algebraic[33] = constants[9]*states[7]
algebraic[48] = (constants[76]*(constants[78]*(states[6]+states[5])+constants[79]*states[8]))/(constants[80]+constants[77])+constants[75]
algebraic[49] = algebraic[48]*states[7]
algebraic[47] = algebraic[43]*states[7]
algebraic[50] = algebraic[48]*states[5]
algebraic[37] = constants[33]*(constants[41]+constants[42]*states[17])
algebraic[44] = algebraic[43]*states[4]
algebraic[5] = (constants[20]*states[11]*(states[12]-constants[7]))/((constants[21]-constants[7])+states[12])
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)
