# Size of variable arrays: sizeAlgebraic = 52 sizeStates = 18 sizeConstants = 52 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_constants[0] = "q_ATP_init in component environment (fmol)" legend_constants[1] = "q_AC_init in component environment (fmol)" legend_constants[2] = "q_cAMP_init in component environment (fmol)" legend_constants[3] = "q_AC_ATP_init in component environment (fmol)" legend_constants[4] = "q_FSK_init in component environment (fmol)" legend_constants[5] = "q_FSK_AC_init in component environment (fmol)" legend_constants[6] = "q_FSK_AC_ATP_init in component environment (fmol)" legend_constants[7] = "q_Gsa_GTP_init in component environment (fmol)" legend_constants[8] = "q_Gsa_GTP_AC_init in component environment (fmol)" legend_constants[9] = "q_Gsa_GTP_AC_ATP_init in component environment (fmol)" legend_constants[10] = "q_PDE_init in component environment (fmol)" legend_constants[11] = "q_PDEinh_init in component environment (fmol)" legend_constants[12] = "q_PDE_cAMP_init in component environment (fmol)" legend_constants[13] = "q_IBMX_init in component environment (fmol)" legend_constants[14] = "q_five_AMP_init in component environment (fmol)" legend_constants[15] = "q_Gia_GTP_init in component environment (fmol)" legend_constants[16] = "q_ACinh_init in component environment (fmol)" legend_constants[17] = "q_PPi_init in component environment (fmol)" legend_algebraic[8] = "ATP_T in component cAMP (fmol)" legend_algebraic[9] = "AC_T in component cAMP (fmol)" legend_algebraic[17] = "Gs_T in component cAMP (fmol)" legend_algebraic[12] = "cAMP_T in component cAMP (fmol)" legend_algebraic[0] = "q_ATP in component environment (fmol)" legend_algebraic[1] = "q_cAMP in component environment (fmol)" legend_algebraic[2] = "q_AC in component environment (fmol)" legend_algebraic[3] = "q_AC_ATP in component environment (fmol)" legend_algebraic[4] = "q_Gsa_GTP_AC in component environment (fmol)" legend_algebraic[5] = "q_Gsa_GTP_AC_ATP in component environment (fmol)" legend_algebraic[6] = "q_FSK_AC in component environment (fmol)" legend_algebraic[7] = "q_FSK_AC_ATP in component environment (fmol)" legend_algebraic[10] = "q_PDE in component environment (fmol)" legend_algebraic[11] = "q_PDE_cAMP in component environment (fmol)" legend_algebraic[13] = "q_five_AMP in component environment (fmol)" legend_algebraic[14] = "q_IBMX in component environment (fmol)" legend_algebraic[15] = "q_PDEinh in component environment (fmol)" legend_algebraic[16] = "q_Gsa_GTP in component environment (fmol)" legend_algebraic[18] = "q_FSK in component environment (fmol)" legend_algebraic[19] = "q_Gia_GTP in component environment (fmol)" legend_algebraic[20] = "q_ACinh in component environment (fmol)" legend_algebraic[21] = "q_PPi in component environment (fmol)" legend_states[0] = "q_ATP in component cAMP (fmol)" legend_states[1] = "q_cAMP in component cAMP (fmol)" legend_states[2] = "q_AC in component cAMP (fmol)" legend_states[3] = "q_AC_ATP in component cAMP (fmol)" legend_states[4] = "q_Gsa_GTP_AC in component cAMP (fmol)" legend_states[5] = "q_Gsa_GTP_AC_ATP in component cAMP (fmol)" legend_states[6] = "q_FSK_AC in component cAMP (fmol)" legend_states[7] = "q_FSK_AC_ATP in component cAMP (fmol)" legend_states[8] = "q_PDE in component cAMP (fmol)" legend_states[9] = "q_PDE_cAMP in component cAMP (fmol)" legend_states[10] = "q_five_AMP in component cAMP (fmol)" legend_states[11] = "q_IBMX in component cAMP (fmol)" legend_states[12] = "q_PDEinh in component cAMP (fmol)" legend_states[13] = "q_Gsa_GTP in component cAMP (fmol)" legend_states[14] = "q_FSK in component cAMP (fmol)" legend_states[15] = "q_Gia_GTP in component cAMP (fmol)" legend_states[16] = "q_ACinh in component cAMP (fmol)" legend_states[17] = "q_PPi in component cAMP (fmol)" legend_constants[18] = "kappa_1a in component cAMP_parameters (fmol_per_sec)" legend_constants[19] = "kappa_1b in component cAMP_parameters (fmol_per_sec)" legend_constants[20] = "kappa_2a in component cAMP_parameters (fmol_per_sec)" legend_constants[21] = "kappa_2b in component cAMP_parameters (fmol_per_sec)" legend_constants[22] = "kappa_3a in component cAMP_parameters (fmol_per_sec)" legend_constants[23] = "kappa_3b in component cAMP_parameters (fmol_per_sec)" legend_constants[24] = "kappa_4a in component cAMP_parameters (fmol_per_sec)" legend_constants[25] = "kappa_4b in component cAMP_parameters (fmol_per_sec)" legend_constants[26] = "kappa_5 in component cAMP_parameters (fmol_per_sec)" legend_constants[27] = "kappa_6 in component cAMP_parameters (fmol_per_sec)" legend_constants[28] = "kappa_7 in component cAMP_parameters (fmol_per_sec)" legend_constants[29] = "kappa_GiAC in component cAMP_parameters (fmol_per_sec)" legend_constants[30] = "K_ATP in component cAMP_parameters (per_fmol)" legend_constants[31] = "K_cAMP in component cAMP_parameters (per_fmol)" legend_constants[32] = "K_AC in component cAMP_parameters (per_fmol)" legend_constants[33] = "K_AC_ATP in component cAMP_parameters (per_fmol)" legend_constants[34] = "K_Gsa_GTP_AC in component cAMP_parameters (per_fmol)" legend_constants[35] = "K_Gsa_GTP_AC_ATP in component cAMP_parameters (per_fmol)" legend_constants[36] = "K_FSK_AC in component cAMP_parameters (per_fmol)" legend_constants[37] = "K_FSK_AC_ATP in component cAMP_parameters (per_fmol)" legend_constants[38] = "K_PDE in component cAMP_parameters (per_fmol)" legend_constants[39] = "K_PDE_cAMP in component cAMP_parameters (per_fmol)" legend_constants[40] = "K_five_AMP in component cAMP_parameters (per_fmol)" legend_constants[41] = "K_IBMX in component cAMP_parameters (per_fmol)" legend_constants[42] = "K_PDEinh in component cAMP_parameters (per_fmol)" legend_constants[43] = "K_Gsa_GTP in component cAMP_parameters (per_fmol)" legend_constants[44] = "K_FSK in component cAMP_parameters (per_fmol)" legend_constants[45] = "K_Gia_GTP in component cAMP_parameters (per_fmol)" legend_constants[46] = "K_ACinh in component cAMP_parameters (per_fmol)" legend_constants[47] = "K_PPi in component cAMP_parameters (per_fmol)" legend_constants[48] = "R in component constants (J_per_K_per_mol)" legend_constants[49] = "T in component constants (kelvin)" legend_algebraic[40] = "v1a in component cAMP (fmol_per_sec)" legend_algebraic[41] = "v1b in component cAMP (fmol_per_sec)" legend_algebraic[42] = "v2a in component cAMP (fmol_per_sec)" legend_algebraic[43] = "v2b in component cAMP (fmol_per_sec)" legend_algebraic[44] = "v3a in component cAMP (fmol_per_sec)" legend_algebraic[45] = "v3b in component cAMP (fmol_per_sec)" legend_algebraic[46] = "v4a in component cAMP (fmol_per_sec)" legend_algebraic[48] = "v4b in component cAMP (fmol_per_sec)" legend_algebraic[50] = "v5 in component cAMP (fmol_per_sec)" legend_algebraic[47] = "v6 in component cAMP (fmol_per_sec)" legend_algebraic[49] = "v7 in component cAMP (fmol_per_sec)" legend_algebraic[51] = "vGiAC in component cAMP (fmol_per_sec)" legend_algebraic[22] = "mu_ATP in component cAMP (J_per_mol)" legend_algebraic[24] = "mu_AC in component cAMP (J_per_mol)" legend_algebraic[23] = "mu_cAMP in component cAMP (J_per_mol)" legend_algebraic[25] = "mu_AC_ATP in component cAMP (J_per_mol)" legend_algebraic[36] = "mu_FSK in component cAMP (J_per_mol)" legend_algebraic[28] = "mu_FSK_AC in component cAMP (J_per_mol)" legend_algebraic[29] = "mu_FSK_AC_ATP in component cAMP (J_per_mol)" legend_algebraic[35] = "mu_Gsa_GTP in component cAMP (J_per_mol)" legend_algebraic[26] = "mu_Gsa_GTP_AC in component cAMP (J_per_mol)" legend_algebraic[27] = "mu_Gsa_GTP_AC_ATP in component cAMP (J_per_mol)" legend_algebraic[30] = "mu_PDE in component cAMP (J_per_mol)" legend_algebraic[34] = "mu_PDEinh in component cAMP (J_per_mol)" legend_algebraic[31] = "mu_PDE_cAMP in component cAMP (J_per_mol)" legend_algebraic[33] = "mu_IBMX in component cAMP (J_per_mol)" legend_algebraic[32] = "mu_five_AMP in component cAMP (J_per_mol)" legend_algebraic[37] = "mu_Gia_GTP in component cAMP (J_per_mol)" legend_algebraic[38] = "mu_ACinh in component cAMP (J_per_mol)" legend_algebraic[39] = "mu_PPi in component cAMP (J_per_mol)" legend_constants[50] = "vol in component cAMP (pL)" legend_constants[51] = "F in component constants (C_per_mol)" legend_rates[0] = "d/dt q_ATP in component cAMP (fmol)" legend_rates[2] = "d/dt q_AC in component cAMP (fmol)" legend_rates[3] = "d/dt q_AC_ATP in component cAMP (fmol)" legend_rates[1] = "d/dt q_cAMP in component cAMP (fmol)" legend_rates[14] = "d/dt q_FSK in component cAMP (fmol)" legend_rates[6] = "d/dt q_FSK_AC in component cAMP (fmol)" legend_rates[7] = "d/dt q_FSK_AC_ATP in component cAMP (fmol)" legend_rates[13] = "d/dt q_Gsa_GTP in component cAMP (fmol)" legend_rates[4] = "d/dt q_Gsa_GTP_AC in component cAMP (fmol)" legend_rates[5] = "d/dt q_Gsa_GTP_AC_ATP in component cAMP (fmol)" legend_rates[9] = "d/dt q_PDE_cAMP in component cAMP (fmol)" legend_rates[8] = "d/dt q_PDE in component cAMP (fmol)" legend_rates[11] = "d/dt q_IBMX in component cAMP (fmol)" legend_rates[12] = "d/dt q_PDEinh in component cAMP (fmol)" legend_rates[10] = "d/dt q_five_AMP in component cAMP (fmol)" legend_rates[15] = "d/dt q_Gia_GTP in component cAMP (fmol)" legend_rates[16] = "d/dt q_ACinh in component cAMP (fmol)" legend_rates[17] = "d/dt q_PPi in component cAMP (fmol)" return (legend_states, legend_algebraic, legend_voi, legend_constants) def initConsts(): constants = [0.0] * sizeConstants; states = [0.0] * sizeStates; constants[0] = 190 constants[1] = 1.889E-03 constants[2] = 3.212E-02 constants[3] = 1e-18 constants[4] = 3.8e-5 constants[5] = 1e-18 constants[6] = 1e-18 constants[7] = 9.519E-04 constants[8] = 1e-18 constants[9] = 1e-18 constants[10] = 1.482E-03 constants[11] = 1e-18 constants[12] = 1e-18 constants[13] = 3.80E-06 constants[14] = 1e-18 constants[15] = 4.81E-04 constants[16] = 1e-18 constants[17] = 1e-18 states[0] = 1e-16 states[1] = 1e-16 states[2] = 1e-16 states[3] = 1e-16 states[4] = 1e-16 states[5] = 1e-16 states[6] = 1e-16 states[7] = 1e-16 states[8] = 1e-16 states[9] = 1e-16 states[10] = 1e-16 states[11] = 1e-16 states[12] = 1e-16 states[13] = 1e-16 states[14] = 1e-16 states[15] = 1e-16 states[16] = 1e-16 states[17] = 1e-16 constants[18] = 9.47329e+06 constants[19] = 0.00197793 constants[20] = 176000 constants[21] = 0.047492 constants[22] = 5.07667e+08 constants[23] = 5.9031e-17 constants[24] = 36084.5 constants[25] = 0.138787 constants[26] = 751.564 constants[27] = 556.617 constants[28] = 160555 constants[29] = 685.521 constants[30] = 9.19362e-06 constants[31] = 0.0102598 constants[32] = 9.02358 constants[33] = 2.93942 constants[34] = 52.2258 constants[35] = 5.20284 constants[36] = 0.181058 constants[37] = 0.0492449 constants[38] = 2.28256 constants[39] = 1.04728 constants[40] = 0.0102598 constants[41] = 0.01642 constants[42] = 38.679 constants[43] = 0.420618 constants[44] = 1.32565e-05 constants[45] = 0.013661 constants[46] = 42.4053 constants[47] = 2.60488e-05 constants[48] = 8.31 constants[49] = 310 constants[50] = 38.0 constants[51] = 96485 return (states, constants) def computeRates(voi, states, constants): rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic algebraic[0] = states[0]+constants[0] algebraic[22] = constants[48]*constants[49]*log(constants[30]*algebraic[0]) algebraic[2] = states[2]+constants[1] algebraic[24] = constants[48]*constants[49]*log(constants[32]*algebraic[2]) algebraic[3] = states[3]+constants[3] algebraic[25] = constants[48]*constants[49]*log(constants[33]*algebraic[3]) algebraic[40] = constants[18]*(exp((algebraic[24]+algebraic[22])/(constants[48]*constants[49]))-exp(algebraic[25]/(constants[48]*constants[49]))) algebraic[1] = states[1]+constants[2] algebraic[23] = constants[48]*constants[49]*log(constants[31]*algebraic[1]) algebraic[21] = states[17]+constants[17] algebraic[39] = constants[48]*constants[49]*log(constants[47]*algebraic[21]) algebraic[41] = constants[19]*(exp(algebraic[25]/(constants[48]*constants[49]))-exp((algebraic[24]+algebraic[23]+algebraic[39])/(constants[48]*constants[49]))) rates[3] = algebraic[40]-algebraic[41] algebraic[4] = states[4]+constants[8] algebraic[26] = constants[48]*constants[49]*log(constants[34]*algebraic[4]) algebraic[5] = states[5]+constants[9] algebraic[27] = constants[48]*constants[49]*log(constants[35]*algebraic[5]) algebraic[42] = constants[20]*(exp((algebraic[26]+algebraic[22])/(constants[48]*constants[49]))-exp(algebraic[27]/(constants[48]*constants[49]))) algebraic[43] = constants[21]*(exp(algebraic[27]/(constants[48]*constants[49]))-exp((algebraic[26]+algebraic[23]+algebraic[39])/(constants[48]*constants[49]))) rates[5] = algebraic[42]-algebraic[43] algebraic[6] = states[6]+constants[5] algebraic[28] = constants[48]*constants[49]*log(constants[36]*algebraic[6]) algebraic[7] = states[7]+constants[6] algebraic[29] = constants[48]*constants[49]*log(constants[37]*algebraic[7]) algebraic[44] = constants[22]*(exp((algebraic[28]+algebraic[22])/(constants[48]*constants[49]))-exp(algebraic[29]/(constants[48]*constants[49]))) rates[0] = (-algebraic[40]-algebraic[44])-algebraic[42] algebraic[45] = constants[23]*(exp(algebraic[29]/(constants[48]*constants[49]))-exp((algebraic[28]+algebraic[23]+algebraic[39])/(constants[48]*constants[49]))) rates[7] = algebraic[44]-algebraic[45] algebraic[10] = states[8]+constants[10] algebraic[30] = constants[48]*constants[49]*log(constants[38]*algebraic[10]) algebraic[11] = states[9]+constants[12] algebraic[31] = constants[48]*constants[49]*log(constants[39]*algebraic[11]) algebraic[46] = constants[24]*(exp((algebraic[30]+algebraic[23])/(constants[48]*constants[49]))-exp(algebraic[31]/(constants[48]*constants[49]))) rates[1] = (algebraic[41]+algebraic[45]+algebraic[43])-algebraic[46] algebraic[16] = states[13]+constants[7] algebraic[35] = constants[48]*constants[49]*log(constants[43]*algebraic[16]) algebraic[47] = constants[27]*(exp((algebraic[24]+algebraic[35])/(constants[48]*constants[49]))-exp(algebraic[26]/(constants[48]*constants[49]))) rates[13] = -algebraic[47] rates[4] = (algebraic[47]-algebraic[42])+algebraic[43] algebraic[18] = states[14]+constants[4] algebraic[36] = constants[48]*constants[49]*log(constants[44]*algebraic[18]) algebraic[49] = constants[28]*(exp((algebraic[36]+algebraic[24])/(constants[48]*constants[49]))-exp(algebraic[28]/(constants[48]*constants[49]))) rates[14] = -algebraic[49] rates[6] = (algebraic[49]+algebraic[45])-algebraic[44] algebraic[13] = states[10]+constants[14] algebraic[32] = constants[48]*constants[49]*log(constants[40]*algebraic[13]) algebraic[48] = constants[25]*(exp(algebraic[31]/(constants[48]*constants[49]))-exp((algebraic[30]+algebraic[32])/(constants[48]*constants[49]))) rates[9] = algebraic[46]-algebraic[48] rates[10] = algebraic[48] algebraic[19] = states[15]+constants[15] algebraic[37] = constants[48]*constants[49]*log(constants[45]*algebraic[19]) algebraic[20] = states[16]+constants[16] algebraic[38] = constants[48]*constants[49]*log(constants[46]*algebraic[20]) algebraic[51] = constants[29]*(exp((algebraic[24]+algebraic[37])/(constants[48]*constants[49]))-exp(algebraic[38]/(constants[48]*constants[49]))) rates[2] = (((algebraic[41]-algebraic[40])-algebraic[47])-algebraic[49])-algebraic[51] algebraic[15] = states[12]+constants[11] algebraic[34] = constants[48]*constants[49]*log(constants[42]*algebraic[15]) algebraic[14] = states[11]+constants[13] algebraic[33] = constants[48]*constants[49]*log(constants[41]*algebraic[14]) algebraic[50] = constants[26]*(exp((algebraic[30]+algebraic[33])/(constants[48]*constants[49]))-exp(algebraic[34]/(constants[48]*constants[49]))) rates[8] = (algebraic[48]-algebraic[46])-algebraic[50] rates[11] = -algebraic[50] rates[12] = algebraic[50] rates[15] = -algebraic[51] rates[16] = algebraic[51] rates[17] = algebraic[51] return(rates) def computeAlgebraic(constants, states, voi): algebraic = array([[0.0] * len(voi)] * sizeAlgebraic) states = array(states) voi = array(voi) algebraic[0] = states[0]+constants[0] algebraic[22] = constants[48]*constants[49]*log(constants[30]*algebraic[0]) algebraic[2] = states[2]+constants[1] algebraic[24] = constants[48]*constants[49]*log(constants[32]*algebraic[2]) algebraic[3] = states[3]+constants[3] algebraic[25] = constants[48]*constants[49]*log(constants[33]*algebraic[3]) algebraic[40] = constants[18]*(exp((algebraic[24]+algebraic[22])/(constants[48]*constants[49]))-exp(algebraic[25]/(constants[48]*constants[49]))) algebraic[1] = states[1]+constants[2] algebraic[23] = constants[48]*constants[49]*log(constants[31]*algebraic[1]) algebraic[21] = states[17]+constants[17] algebraic[39] = constants[48]*constants[49]*log(constants[47]*algebraic[21]) algebraic[41] = constants[19]*(exp(algebraic[25]/(constants[48]*constants[49]))-exp((algebraic[24]+algebraic[23]+algebraic[39])/(constants[48]*constants[49]))) algebraic[4] = states[4]+constants[8] algebraic[26] = constants[48]*constants[49]*log(constants[34]*algebraic[4]) algebraic[5] = states[5]+constants[9] algebraic[27] = constants[48]*constants[49]*log(constants[35]*algebraic[5]) algebraic[42] = constants[20]*(exp((algebraic[26]+algebraic[22])/(constants[48]*constants[49]))-exp(algebraic[27]/(constants[48]*constants[49]))) algebraic[43] = constants[21]*(exp(algebraic[27]/(constants[48]*constants[49]))-exp((algebraic[26]+algebraic[23]+algebraic[39])/(constants[48]*constants[49]))) algebraic[6] = states[6]+constants[5] algebraic[28] = constants[48]*constants[49]*log(constants[36]*algebraic[6]) algebraic[7] = states[7]+constants[6] algebraic[29] = constants[48]*constants[49]*log(constants[37]*algebraic[7]) algebraic[44] = constants[22]*(exp((algebraic[28]+algebraic[22])/(constants[48]*constants[49]))-exp(algebraic[29]/(constants[48]*constants[49]))) algebraic[45] = constants[23]*(exp(algebraic[29]/(constants[48]*constants[49]))-exp((algebraic[28]+algebraic[23]+algebraic[39])/(constants[48]*constants[49]))) algebraic[10] = states[8]+constants[10] algebraic[30] = constants[48]*constants[49]*log(constants[38]*algebraic[10]) algebraic[11] = states[9]+constants[12] algebraic[31] = constants[48]*constants[49]*log(constants[39]*algebraic[11]) algebraic[46] = constants[24]*(exp((algebraic[30]+algebraic[23])/(constants[48]*constants[49]))-exp(algebraic[31]/(constants[48]*constants[49]))) algebraic[16] = states[13]+constants[7] algebraic[35] = constants[48]*constants[49]*log(constants[43]*algebraic[16]) algebraic[47] = constants[27]*(exp((algebraic[24]+algebraic[35])/(constants[48]*constants[49]))-exp(algebraic[26]/(constants[48]*constants[49]))) algebraic[18] = states[14]+constants[4] algebraic[36] = constants[48]*constants[49]*log(constants[44]*algebraic[18]) algebraic[49] = constants[28]*(exp((algebraic[36]+algebraic[24])/(constants[48]*constants[49]))-exp(algebraic[28]/(constants[48]*constants[49]))) algebraic[13] = states[10]+constants[14] algebraic[32] = constants[48]*constants[49]*log(constants[40]*algebraic[13]) algebraic[48] = constants[25]*(exp(algebraic[31]/(constants[48]*constants[49]))-exp((algebraic[30]+algebraic[32])/(constants[48]*constants[49]))) algebraic[19] = states[15]+constants[15] algebraic[37] = constants[48]*constants[49]*log(constants[45]*algebraic[19]) algebraic[20] = states[16]+constants[16] algebraic[38] = constants[48]*constants[49]*log(constants[46]*algebraic[20]) algebraic[51] = constants[29]*(exp((algebraic[24]+algebraic[37])/(constants[48]*constants[49]))-exp(algebraic[38]/(constants[48]*constants[49]))) algebraic[15] = states[12]+constants[11] algebraic[34] = constants[48]*constants[49]*log(constants[42]*algebraic[15]) algebraic[14] = states[11]+constants[13] algebraic[33] = constants[48]*constants[49]*log(constants[41]*algebraic[14]) algebraic[50] = constants[26]*(exp((algebraic[30]+algebraic[33])/(constants[48]*constants[49]))-exp(algebraic[34]/(constants[48]*constants[49]))) algebraic[8] = algebraic[0]+algebraic[3]+algebraic[7]+algebraic[5] algebraic[9] = algebraic[2]+algebraic[3]+algebraic[6]+algebraic[7]+algebraic[4]+algebraic[5] algebraic[12] = algebraic[1]+algebraic[11]+states[10] algebraic[17] = algebraic[16]+algebraic[4]+algebraic[5] 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)