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 = 92
sizeStates = 29
sizeConstants = 74
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 (ms)"
    legend_constants[0] = "F in component Environment (C_per_mole)"
    legend_constants[1] = "K_o in component Environment (mM)"
    legend_constants[2] = "Ca_o in component Environment (mM)"
    legend_constants[3] = "Na_o in component Environment (mM)"
    legend_constants[4] = "Cl_o in component Environment (mM)"
    legend_constants[5] = "FonRT in component Environment (per_mV)"
    legend_states[0] = "V in component cell (mV)"
    legend_algebraic[62] = "INa in component INa (uA_per_uF)"
    legend_algebraic[31] = "ICaL in component ICaL (uA_per_uF)"
    legend_algebraic[77] = "IK1 in component IK1 (uA_per_uF)"
    legend_algebraic[83] = "IKp in component IKp (uA_per_uF)"
    legend_algebraic[85] = "IKs in component IKs (uA_per_uF)"
    legend_algebraic[81] = "IKr in component IKr (uA_per_uF)"
    legend_algebraic[49] = "IpCa in component IpCa (uA_per_uF)"
    legend_algebraic[50] = "ICab in component ICab (uA_per_uF)"
    legend_algebraic[48] = "INaCa in component INaCa (uA_per_uF)"
    legend_algebraic[41] = "INaK in component INaK (uA_per_uF)"
    legend_algebraic[82] = "Ito in component Ito (uA_per_uF)"
    legend_algebraic[55] = "Ito2 in component Ito2 (uA_per_uF)"
    legend_algebraic[88] = "IClb in component IClb (uA_per_uF)"
    legend_algebraic[65] = "INal in component INal (uA_per_uF)"
    legend_algebraic[51] = "caiont in component cell (uA_per_uF)"
    legend_algebraic[68] = "naiont in component cell (uA_per_uF)"
    legend_algebraic[86] = "kiont in component cell (uA_per_uF)"
    legend_algebraic[89] = "clont in component cell (uA_per_uF)"
    legend_constants[6] = "l in component cell (cm)"
    legend_constants[7] = "a in component cell (cm)"
    legend_constants[62] = "vcell in component cell (uL)"
    legend_constants[65] = "ageo in component cell (cm2)"
    legend_constants[68] = "Acap in component cell (uF)"
    legend_constants[69] = "vmyo in component cell (uL)"
    legend_constants[66] = "vmito in component cell (uL)"
    legend_constants[67] = "vsr in component cell (uL)"
    legend_constants[70] = "vnsr in component cell (uL)"
    legend_constants[71] = "vjsr in component cell (uL)"
    legend_constants[72] = "vss in component cell (uL)"
    legend_constants[73] = "AF in component cell (uF_mole_per_C)"
    legend_constants[8] = "stim_offset in component cell (ms)"
    legend_constants[9] = "stim_period in component cell (ms)"
    legend_constants[10] = "stim_duration in component cell (ms)"
    legend_constants[11] = "stim_amplitude in component cell (uA_per_uF)"
    legend_algebraic[16] = "i_Stim in component cell (uA_per_uF)"
    legend_algebraic[0] = "past in component cell (ms)"
    legend_algebraic[59] = "ENa in component reversal_potentials (mV)"
    legend_constants[12] = "GNa in component INa (mS_per_uF)"
    legend_algebraic[29] = "gNa in component INa (mS_per_uF)"
    legend_states[1] = "H in component INa (dimensionless)"
    legend_states[2] = "m in component INa (dimensionless)"
    legend_states[3] = "J in component INa (dimensionless)"
    legend_algebraic[1] = "am in component INa (per_ms)"
    legend_algebraic[17] = "bm in component INa (per_ms)"
    legend_algebraic[2] = "ah in component INa (per_ms)"
    legend_algebraic[18] = "bh in component INa (per_ms)"
    legend_algebraic[3] = "aj in component INa (per_ms)"
    legend_algebraic[19] = "bj in component INa (per_ms)"
    legend_states[4] = "Ca_ss in component Ca (mM)"
    legend_states[5] = "d in component ICaL (dimensionless)"
    legend_states[6] = "dp in component ICaL (dimensionless)"
    legend_states[7] = "f in component ICaL (dimensionless)"
    legend_states[8] = "fca in component ICaL (dimensionless)"
    legend_states[9] = "fca2 in component ICaL (dimensionless)"
    legend_states[10] = "f2 in component ICaL (dimensionless)"
    legend_constants[13] = "pca in component ICaL (L_per_F_ms)"
    legend_constants[14] = "gacai in component ICaL (dimensionless)"
    legend_constants[15] = "gacao in component ICaL (dimensionless)"
    legend_algebraic[54] = "CaMKactive in component Irel (dimensionless)"
    legend_algebraic[30] = "ibarca in component ICaL (uA_per_uF)"
    legend_algebraic[4] = "dss in component ICaL (dimensionless)"
    legend_algebraic[20] = "taud in component ICaL (ms)"
    legend_algebraic[5] = "fss in component ICaL (dimensionless)"
    legend_algebraic[6] = "f2ss in component ICaL (dimensionless)"
    legend_algebraic[21] = "tauf in component ICaL (ms)"
    legend_algebraic[22] = "tauf2 in component ICaL (ms)"
    legend_algebraic[7] = "dpss in component ICaL (dimensionless)"
    legend_algebraic[32] = "fcass in component ICaL (dimensionless)"
    legend_algebraic[33] = "fca2ss in component ICaL (dimensionless)"
    legend_algebraic[56] = "taufca in component ICaL (ms)"
    legend_algebraic[35] = "taufca2 in component ICaL (ms)"
    legend_constants[16] = "tau_pow_calcium in component ICaL (ms)"
    legend_algebraic[70] = "EK in component reversal_potentials (mV)"
    legend_constants[17] = "GK1 in component IK1 (mS_per_uF)"
    legend_algebraic[72] = "ak1 in component IK1 (per_ms)"
    legend_algebraic[74] = "bk1 in component IK1 (per_ms)"
    legend_constants[18] = "GKrMax in component IKr (mS_per_uF)"
    legend_constants[63] = "gkr in component IKr (mS_per_uF)"
    legend_algebraic[37] = "r in component IKr (dimensionless)"
    legend_states[11] = "xr in component IKr (dimensionless)"
    legend_algebraic[8] = "xrss in component IKr (dimensionless)"
    legend_algebraic[23] = "tauxr in component IKr (ms)"
    legend_states[12] = "Ca_i in component Ca (mM)"
    legend_algebraic[38] = "gks in component IKs (mS_per_uF)"
    legend_constants[19] = "gks_max in component IKs (mS_per_uF)"
    legend_algebraic[84] = "EKs in component reversal_potentials (mV)"
    legend_algebraic[9] = "xss in component IKs (dimensionless)"
    legend_algebraic[24] = "tauxs in component IKs (ms)"
    legend_states[13] = "xs1 in component IKs (dimensionless)"
    legend_states[14] = "xs2 in component IKs (dimensionless)"
    legend_constants[20] = "gitodv in component Ito (mS_per_uF)"
    legend_algebraic[39] = "rv in component Ito (dimensionless)"
    legend_algebraic[10] = "ay in component Ito (per_ms)"
    legend_algebraic[25] = "by in component Ito (per_ms)"
    legend_algebraic[11] = "ay2 in component Ito (per_ms)"
    legend_algebraic[26] = "by2 in component Ito (per_ms)"
    legend_algebraic[12] = "ay3 in component Ito (per_ms)"
    legend_algebraic[27] = "by3 in component Ito (per_ms)"
    legend_states[15] = "ydv in component Ito (dimensionless)"
    legend_states[16] = "ydv2 in component Ito (dimensionless)"
    legend_states[17] = "zdv in component Ito (dimensionless)"
    legend_constants[21] = "Cto in component Ito (mV)"
    legend_states[18] = "Na_i in component Na (mM)"
    legend_constants[22] = "kmnai in component INaK (mM)"
    legend_constants[23] = "kmko in component INaK (mM)"
    legend_constants[24] = "ibarnak in component INaK (uA_per_uF)"
    legend_constants[64] = "sigma in component INaK (dimensionless)"
    legend_algebraic[40] = "fnak in component INaK (dimensionless)"
    legend_algebraic[42] = "ca_i_NaCa in component INaCa (mM)"
    legend_constants[25] = "KmCa in component INaCa (mM)"
    legend_algebraic[43] = "allo in component INaCa (dimensionless)"
    legend_constants[26] = "NCXmax in component INaCa (uA_per_uF)"
    legend_constants[27] = "ksat in component INaCa (dimensionless)"
    legend_constants[28] = "eta in component INaCa (dimensionless)"
    legend_constants[29] = "KmNai in component INaCa (mM)"
    legend_constants[30] = "KmNao in component INaCa (mM)"
    legend_constants[31] = "KmCai in component INaCa (mM)"
    legend_constants[32] = "KmCao in component INaCa (mM)"
    legend_algebraic[44] = "num in component INaCa (mM4)"
    legend_algebraic[45] = "denom1 in component INaCa (dimensionless)"
    legend_algebraic[46] = "denom2 in component INaCa (mM4)"
    legend_algebraic[47] = "denom3 in component INaCa (mM4)"
    legend_constants[33] = "ibarpca in component IpCa (uA_per_uF)"
    legend_constants[34] = "kmpca in component IpCa (mM)"
    legend_constants[35] = "GCab in component ICab (L_per_F_ms)"
    legend_states[19] = "Cl_i in component Cl (mM)"
    legend_constants[36] = "PCl in component Ito2 (L_per_F_ms)"
    legend_states[20] = "AA in component Ito2 (dimensionless)"
    legend_algebraic[53] = "Ito2_max in component Ito2 (uA_per_uF)"
    legend_algebraic[13] = "AAss in component Ito2 (dimensionless)"
    legend_constants[37] = "Kmto2 in component Ito2 (mM)"
    legend_algebraic[87] = "ECl in component reversal_potentials (mV)"
    legend_constants[38] = "GClb in component IClb (mS_per_uF)"
    legend_constants[39] = "GNaL in component INal (mS_per_uF)"
    legend_states[21] = "mL in component INal (dimensionless)"
    legend_states[22] = "hL in component INal (dimensionless)"
    legend_algebraic[14] = "amL in component INal (per_ms)"
    legend_algebraic[28] = "bmL in component INal (per_ms)"
    legend_algebraic[15] = "hLss in component INal (dimensionless)"
    legend_states[23] = "K_i in component K (mM)"
    legend_constants[40] = "prnak in component reversal_potentials (dimensionless)"
    legend_states[24] = "Ca_jsr in component Ca (mM)"
    legend_algebraic[61] = "Grel in component Irel (per_ms)"
    legend_algebraic[34] = "dro_inf in component Irel (dimensionless)"
    legend_constants[41] = "dtau_rel_max in component Irel (ms)"
    legend_algebraic[60] = "dtau_rel in component Irel (ms)"
    legend_algebraic[36] = "ross in component Irel (dimensionless)"
    legend_algebraic[63] = "riss in component Irel (dimensionless)"
    legend_algebraic[66] = "tauri in component Irel (ms)"
    legend_algebraic[64] = "irelcicr in component Irel (mM_per_ms)"
    legend_constants[42] = "CaMK0 in component Irel (dimensionless)"
    legend_constants[43] = "Km in component Irel (mM)"
    legend_constants[44] = "KmCaMK in component Irel (dimensionless)"
    legend_algebraic[52] = "CaMKbound in component Irel (dimensionless)"
    legend_states[25] = "CaMKtrap in component Irel (dimensionless)"
    legend_states[26] = "ro in component Irel (dimensionless)"
    legend_states[27] = "ri in component Irel (dimensionless)"
    legend_algebraic[58] = "vg in component Irel (dimensionless)"
    legend_algebraic[57] = "cafac in component Irel (dimensionless)"
    legend_constants[45] = "dKmPLBmax in component Iup_Ileak (mM)"
    legend_constants[46] = "dJupmax in component Iup_Ileak (dimensionless)"
    legend_algebraic[67] = "dKmPLB in component Iup_Ileak (mM)"
    legend_algebraic[69] = "dJup in component Iup_Ileak (dimensionless)"
    legend_constants[47] = "iupmax in component Iup_Ileak (mM_per_ms)"
    legend_constants[48] = "Kmup in component Iup_Ileak (mM)"
    legend_constants[49] = "nsrmax in component Iup_Ileak (mM)"
    legend_algebraic[71] = "iup in component Iup_Ileak (mM_per_ms)"
    legend_algebraic[73] = "ileak in component Iup_Ileak (mM_per_ms)"
    legend_states[28] = "Ca_nsr in component Ca (mM)"
    legend_algebraic[76] = "idiff in component Idiff_Itr (mM_per_ms)"
    legend_algebraic[75] = "itr in component Idiff_Itr (mM_per_ms)"
    legend_algebraic[90] = "CTNaCl in component Na (mM_per_ms)"
    legend_constants[50] = "CTNaClmax in component Na (mM_per_ms)"
    legend_algebraic[91] = "CTKCl in component K (mM_per_ms)"
    legend_constants[51] = "CTKClmax in component K (mM_per_ms)"
    legend_constants[52] = "kmt in component Ca (mM)"
    legend_constants[53] = "kmc in component Ca (mM)"
    legend_constants[54] = "tbar in component Ca (mM)"
    legend_constants[55] = "cbar in component Ca (mM)"
    legend_constants[56] = "kmcsqn in component Ca (mM)"
    legend_constants[57] = "csqnbar in component Ca (mM)"
    legend_algebraic[78] = "bcsqn in component Ca (dimensionless)"
    legend_algebraic[79] = "bmyo in component Ca (dimensionless)"
    legend_constants[58] = "BSRmax in component Ca (mM)"
    legend_constants[59] = "KmBSR in component Ca (mM)"
    legend_constants[60] = "BSLmax in component Ca (mM)"
    legend_constants[61] = "KmBSL in component Ca (mM)"
    legend_algebraic[80] = "bss in component Ca (dimensionless)"
    legend_rates[0] = "d/dt V in component cell (mV)"
    legend_rates[1] = "d/dt H in component INa (dimensionless)"
    legend_rates[2] = "d/dt m in component INa (dimensionless)"
    legend_rates[3] = "d/dt J in component INa (dimensionless)"
    legend_rates[5] = "d/dt d in component ICaL (dimensionless)"
    legend_rates[6] = "d/dt dp in component ICaL (dimensionless)"
    legend_rates[7] = "d/dt f in component ICaL (dimensionless)"
    legend_rates[10] = "d/dt f2 in component ICaL (dimensionless)"
    legend_rates[8] = "d/dt fca in component ICaL (dimensionless)"
    legend_rates[9] = "d/dt fca2 in component ICaL (dimensionless)"
    legend_rates[11] = "d/dt xr in component IKr (dimensionless)"
    legend_rates[13] = "d/dt xs1 in component IKs (dimensionless)"
    legend_rates[14] = "d/dt xs2 in component IKs (dimensionless)"
    legend_rates[15] = "d/dt ydv in component Ito (dimensionless)"
    legend_rates[16] = "d/dt ydv2 in component Ito (dimensionless)"
    legend_rates[17] = "d/dt zdv in component Ito (dimensionless)"
    legend_rates[20] = "d/dt AA in component Ito2 (dimensionless)"
    legend_rates[21] = "d/dt mL in component INal (dimensionless)"
    legend_rates[22] = "d/dt hL in component INal (dimensionless)"
    legend_rates[26] = "d/dt ro in component Irel (dimensionless)"
    legend_rates[27] = "d/dt ri in component Irel (dimensionless)"
    legend_rates[25] = "d/dt CaMKtrap in component Irel (dimensionless)"
    legend_rates[18] = "d/dt Na_i in component Na (mM)"
    legend_rates[23] = "d/dt K_i in component K (mM)"
    legend_rates[19] = "d/dt Cl_i in component Cl (mM)"
    legend_rates[12] = "d/dt Ca_i in component Ca (mM)"
    legend_rates[4] = "d/dt Ca_ss in component Ca (mM)"
    legend_rates[28] = "d/dt Ca_nsr in component Ca (mM)"
    legend_rates[24] = "d/dt Ca_jsr in component Ca (mM)"
    return (legend_states, legend_algebraic, legend_voi, legend_constants)

def initConsts():
    constants = [0.0] * sizeConstants; states = [0.0] * sizeStates;
    constants[0] = 96485
    constants[1] = 4
    constants[2] = 1.8
    constants[3] = 150
    constants[4] = 154.6
    constants[5] = 0.0374358835078
    states[0] = -93.2932771154856
    constants[6] = 0.01
    constants[7] = 0.0011
    constants[8] = 0
    constants[9] = 1000
    constants[10] = 1
    constants[11] = -80
    constants[12] = 8.25
    states[1] = 0.99765453819431
    states[2] = 0.000382187369845771
    states[3] = 0.998157020148849
    states[4] = 0.000225131045297696
    states[5] = 5.38067794749339e-7
    states[6] = 8.99805432294836
    states[7] = 0.999986839648304
    states[8] = 0.961568137796573
    states[9] = 0.854261813196152
    states[10] = 0.989081601403786
    constants[13] = 0.000243
    constants[14] = 1
    constants[15] = 0.341
    constants[16] = 10
    constants[17] = 0.5
    constants[18] = 0.0138542
    states[11] = 0.255981702631947
    states[12] = 0.000223768331231758
    constants[19] = 0.00746925
    states[13] = 0.0147449166757808
    states[14] = 0.0147504787196957
    constants[20] = 0.1805
    states[15] = 0.00894974857468432
    states[16] = 0.999992183094244
    states[17] = 0.787996527242362
    constants[21] = 300
    states[18] = 17.9964119779802
    constants[22] = 10
    constants[23] = 1.5
    constants[24] = 0.61875
    constants[25] = 0.000125
    constants[26] = 5.85
    constants[27] = 0.27
    constants[28] = 0.35
    constants[29] = 12.3
    constants[30] = 87.5
    constants[31] = 0.0036
    constants[32] = 1.3
    constants[33] = 0.0575
    constants[34] = 0.0005
    constants[35] = 0.0000007980336
    states[19] = 20.1543792471096
    constants[36] = 4e-7
    states[20] = 0.0014969201082975
    constants[37] = 0.1502
    constants[38] = 0.000225
    constants[39] = 0.011
    states[21] = 0.000382187369845771
    states[22] = 0.488129650338831
    states[23] = 134.555737634453
    constants[40] = 0.01833
    states[24] = 4.1270622547589
    constants[41] = 10
    constants[42] = 0.05
    constants[43] = 0.0015
    constants[44] = 0.15
    states[25] = 0.0971591072782679
    states[26] = -1.07543858779373e-32
    states[27] = 0.716604593002322
    constants[45] = 0.00017
    constants[46] = 0.75
    constants[47] = 0.004375
    constants[48] = 0.00092
    constants[49] = 15
    states[28] = 4.14835141174613
    constants[50] = 9.8443e-6
    constants[51] = 7.0756e-6
    constants[52] = 0.0005
    constants[53] = 0.00238
    constants[54] = 0.07
    constants[55] = 0.05
    constants[56] = 0.8
    constants[57] = 10
    constants[58] = 0.047
    constants[59] = 0.00087
    constants[60] = 1.124
    constants[61] = 0.0087
    constants[62] = 1000.00* pi*constants[7]*constants[7]*constants[6]
    constants[63] = constants[18]*(power(constants[1]/4.00000, 1.0/2))
    constants[64] = (exp(constants[3]/67.3000)-1.00000)/7.00000
    constants[65] = 2.00000* pi*constants[7]*constants[7]+2.00000* pi*constants[7]*constants[6]
    constants[66] = constants[62]*0.260000
    constants[67] = constants[62]*0.0600000
    constants[68] = constants[65]*2.00000
    constants[69] = constants[62]*0.680000
    constants[70] = constants[62]*0.0552000
    constants[71] = constants[62]*0.00480000
    constants[72] = constants[62]*0.0200000
    constants[73] = constants[68]/constants[0]
    return (states, constants)

def computeRates(voi, states, constants):
    rates = [0.0] * sizeStates; algebraic = [0.0] * sizeAlgebraic
    algebraic[7] = 9.00000-8.00000/(1.00000+exp(-(states[0]+65.0000)/3.40000))
    rates[6] = (algebraic[7]-states[6])/constants[16]
    algebraic[13] = 1.00000/(1.00000+constants[37]/states[4])
    rates[20] = (algebraic[13]-states[20])/1.00000
    algebraic[15] = 1.00000/(1.00000+exp((states[0]+91.0000)/6.10000))
    rates[22] = (algebraic[15]-states[22])/600.000
    algebraic[2] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, 0.135000*exp((80.0000+states[0])/-6.80000)])
    algebraic[18] = custom_piecewise([greater_equal(states[0] , -40.0000), 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000))) , True, 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0])])
    rates[1] = algebraic[2]*(1.00000-states[1])-algebraic[18]*states[1]
    algebraic[1] = (0.320000*1.00000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[17] = 0.0800000*exp(-states[0]/11.0000)
    rates[2] = algebraic[1]*(1.00000-states[2])-algebraic[17]*states[2]
    algebraic[3] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, ((-127140.*exp(0.244400*states[0])-3.47400e-05*exp(-0.0439100*states[0]))*1.00000*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300)))])
    algebraic[19] = custom_piecewise([greater_equal(states[0] , -40.0000), (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000))) , True, (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400)))])
    rates[3] = algebraic[3]*(1.00000-states[3])-algebraic[19]*states[3]
    algebraic[4] = 1.00000/(1.00000+exp(-(states[0]-4.00000)/6.74000))
    algebraic[20] = 0.590000+(0.800000*exp(0.0520000*(states[0]+13.0000)))/(1.00000+exp(0.132000*(states[0]+13.0000)))
    rates[5] = (algebraic[4]-states[5])/algebraic[20]
    algebraic[5] = 0.700000/(1.00000+exp((states[0]+17.1200)/7.00000))+0.300000
    algebraic[21] = 1.00000/(0.241100*exp(-(power(0.0450000*(states[0]-9.69140), 2.00000)))+0.0529000)
    rates[7] = (algebraic[5]-states[7])/algebraic[21]
    algebraic[6] = 0.770000/(1.00000+exp((states[0]+17.1200)/7.00000))+0.230000
    algebraic[22] = 1.00000/(0.0423000*exp(-(power(0.0590000*(states[0]-18.5726), 2.00000)))+0.00540000)
    rates[10] = (algebraic[6]-states[10])/algebraic[22]
    algebraic[8] = 1.00000/(1.00000+exp(-2.18200-0.181900*states[0]))
    algebraic[23] = 43.0000+1.00000/(exp(-5.49500+0.169100*states[0])+exp(-7.67700-0.0128000*states[0]))
    rates[11] = (algebraic[8]-states[11])/algebraic[23]
    algebraic[9] = 1.00000/(1.00000+exp(-(states[0]-10.5000)/24.7000))
    algebraic[24] = 1.00000/((7.61000e-05*(states[0]+44.6000))/(1.00000-exp(-9.97000*(states[0]+44.6000)))+(0.000360000*(states[0]-0.550000))/(exp(0.128000*(states[0]-0.550000))-1.00000))
    rates[13] = (algebraic[9]-states[13])/algebraic[24]
    rates[14] = ((algebraic[9]-states[14])/algebraic[24])/2.00000
    algebraic[10] = (25.0000*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000))
    algebraic[25] = (25.0000*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000))
    rates[15] = algebraic[10]*(1.00000-states[15])-algebraic[25]*states[15]
    algebraic[11] = 0.0300000/(1.00000+exp((states[0]+60.0000)/5.00000))
    algebraic[26] = (0.200000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000))
    rates[16] = algebraic[11]*(1.00000-states[16])-algebraic[26]*states[16]
    algebraic[12] = 0.00225000/(1.00000+exp((states[0]+60.0000)/5.00000))
    algebraic[27] = (0.100000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000))
    rates[17] = algebraic[12]*(1.00000-states[17])-algebraic[27]*states[17]
    algebraic[14] = (0.320000*1.00000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[28] = 0.0800000*exp(-states[0]/11.0000)
    rates[21] = algebraic[14]*(1.00000-states[21])-algebraic[28]*states[21]
    algebraic[30] = (constants[13]*4.00000*(states[0]-15.0000)*constants[0]*constants[5]*(constants[14]*states[4]*exp(2.00000*(states[0]-15.0000)*constants[5])-constants[15]*constants[2]))/(exp(2.00000*(states[0]-15.0000)*constants[5])-1.00000)
    algebraic[31] = (power(states[5], states[6]))*states[7]*states[10]*states[8]*states[9]*algebraic[30]
    algebraic[33] = 1.00000/(1.00000-algebraic[31]/0.0100000)
    algebraic[35] = 300.000/(1.00000+exp((-algebraic[31]-0.175000)/0.0400000))+125.000
    rates[9] = (algebraic[33]-states[9])/algebraic[35]
    algebraic[34] = (power(states[24], 1.90000))/(power(states[24], 1.90000)+power((49.2800*states[4])/(states[4]+0.00280000), 1.90000))
    algebraic[36] = algebraic[34]/(power(1.00000/algebraic[31], 2.00000)+1.00000)
    rates[26] = (algebraic[36]-states[26])/3.00000
    algebraic[52] = (constants[42]*(1.00000-states[25]))/(1.00000+constants[43]/states[4])
    algebraic[54] = algebraic[52]+states[25]
    rates[25] = 0.0500000*algebraic[54]*(algebraic[54]-states[25])-0.000680000*states[25]
    algebraic[32] = 0.300000/(1.00000-algebraic[31]/0.0500000)+0.550000/(1.00000+states[4]/0.00300000)+0.150000
    algebraic[56] = (10.0000*algebraic[54])/(0.150000+algebraic[54])+1.00000/(1.00000+states[4]/0.00300000)+0.500000
    rates[8] = (algebraic[32]-states[8])/algebraic[56]
    algebraic[57] = 1.00000/(1.00000+exp((algebraic[31]+0.0500000)/0.0150000))
    algebraic[63] = 1.00000/(1.00000+exp(((states[4]-0.000400000)+0.00200000*algebraic[57])/2.50000e-05))
    algebraic[60] = (constants[41]*algebraic[54])/(constants[44]+algebraic[54])
    algebraic[66] = 3.00000+algebraic[60]+(350.000-algebraic[60])/(1.00000+exp(((states[4]-0.00300000)+0.00300000*algebraic[57])/0.000200000))
    rates[27] = (algebraic[63]-states[27])/algebraic[66]
    algebraic[67] = (constants[45]*algebraic[54])/(constants[44]+algebraic[54])
    algebraic[69] = (constants[46]*algebraic[54])/(constants[44]+algebraic[54])
    algebraic[71] = ((algebraic[69]+1.00000)*constants[47]*states[12])/((states[12]+constants[48])-algebraic[67])
    algebraic[73] = (constants[47]*states[28])/constants[49]
    algebraic[75] = (states[28]-states[24])/120.000
    rates[28] = (algebraic[71]-(algebraic[75]*constants[71])/constants[70])-algebraic[73]
    algebraic[49] = (constants[33]*states[12])/(constants[34]+states[12])
    algebraic[50] = (constants[35]*states[0]*constants[0]*constants[5]*(states[12]*exp(2.00000*states[0]*constants[5])-0.341000*constants[2]))/(exp(2.00000*states[0]*constants[5])-1.00000)
    algebraic[42] = 1.50000*states[12]
    algebraic[43] = 1.00000/(1.00000+power(constants[25]/algebraic[42], 2.00000))
    algebraic[44] = (power(states[18], 3.00000))*constants[2]*exp(constants[28]*states[0]*constants[5])-(power(constants[3], 3.00000))*algebraic[42]*exp((constants[28]-1.00000)*states[0]*constants[5])
    algebraic[45] = 1.00000+constants[27]*exp((constants[28]-1.00000)*states[0]*constants[5])
    algebraic[46] = constants[32]*(power(states[18], 3.00000))+(power(constants[30], 3.00000))*algebraic[42]+(power(constants[29], 3.00000))*constants[2]*(1.00000+algebraic[42]/constants[31])
    algebraic[47] = constants[31]*(power(constants[3], 3.00000))*(1.00000+power(states[18]/constants[29], 3.00000))+(power(states[18], 3.00000))*constants[2]+(power(constants[3], 3.00000))*algebraic[42]
    algebraic[48] = (constants[26]*algebraic[43]*algebraic[44])/(algebraic[45]*(algebraic[46]+algebraic[47]))
    algebraic[76] = (states[4]-states[12])/0.200000
    algebraic[79] = 1.00000/(1.00000+(constants[55]*constants[53])/(power(states[12]+constants[53], 2.00000))+(constants[52]*constants[54])/(power(states[12]+constants[52], 2.00000)))
    rates[12] = algebraic[79]*((-((algebraic[50]+algebraic[49])-2.00000*algebraic[48])*constants[73])/(constants[69]*2.00000)+((algebraic[73]-algebraic[71])*constants[70])/constants[69]+(algebraic[76]*constants[72])/constants[69])
    algebraic[58] = 1.00000/(1.00000+exp((algebraic[30]+13.0000)/5.00000))
    algebraic[61] = 3000.00*algebraic[58]
    algebraic[64] = algebraic[61]*states[26]*states[27]*(states[24]-states[4])
    algebraic[80] = 1.00000/(1.00000+(constants[58]*constants[59])/(power(constants[59]+states[4], 2.00000))+(constants[60]*constants[61])/(power(constants[61]+states[4], 2.00000)))
    rates[4] = algebraic[80]*(((-algebraic[31]*constants[73])/(constants[72]*2.00000)+(algebraic[64]*constants[71])/constants[72])-algebraic[76])
    algebraic[78] = 1.00000/(1.00000+(constants[56]*constants[57])/(power(states[24]+constants[56], 2.00000)))
    rates[24] = algebraic[78]*(algebraic[75]-algebraic[64])
    algebraic[51] = (algebraic[31]+algebraic[50]+algebraic[49])-2.00000*algebraic[48]
    algebraic[59] = log(constants[3]/states[18])/constants[5]
    algebraic[29] = constants[12]*states[2]*states[2]*states[2]*states[1]*states[3]
    algebraic[62] = algebraic[29]*(states[0]-algebraic[59])
    algebraic[40] = 1.00000/(1.00000+0.124500*exp(-0.100000*states[0]*constants[5])+0.0365000*constants[64]*exp(-states[0]*constants[5]))
    algebraic[41] = (((constants[24]*algebraic[40]*1.00000)/(1.00000+power(constants[22]/states[18], 2.00000)))*constants[1])/(constants[1]+constants[23])
    algebraic[65] = constants[39]*(power(states[21], 3.00000))*states[22]*(states[0]-algebraic[59])
    algebraic[68] = algebraic[62]+3.00000*algebraic[48]+3.00000*algebraic[41]+algebraic[65]
    algebraic[70] = log(constants[1]/states[23])/constants[5]
    algebraic[72] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[70])-59.2150)))
    algebraic[74] = (0.491240*exp(0.0803200*((states[0]-algebraic[70])+5.47600))+1.00000*exp(0.0617500*((states[0]-algebraic[70])-594.310)))/(1.00000+exp(-0.514300*((states[0]-algebraic[70])+4.75300)))
    algebraic[77] = ((constants[17]*(power(constants[1]/4.00000, 1.0/2))*algebraic[72])/(algebraic[72]+algebraic[74]))*(states[0]-algebraic[70])
    algebraic[83] = (0.00276000*(states[0]-algebraic[70]))/(1.00000+exp((7.48800-states[0])/5.98000))
    algebraic[38] = constants[19]*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[12], 1.40000)))
    algebraic[84] = log((constants[1]+constants[40]*constants[3])/(states[23]+constants[40]*states[18]))/constants[5]
    algebraic[85] = algebraic[38]*states[13]*states[14]*(states[0]-algebraic[84])
    algebraic[37] = 1.00000/(1.00000+2.50000*exp(0.100000*(states[0]+28.0000)))
    algebraic[81] = constants[63]*states[11]*algebraic[37]*(states[0]-algebraic[70])
    algebraic[39] = custom_piecewise([less_equal(states[0] , 0.00000), exp(states[0]/constants[21]) , True, 1.00000])
    algebraic[82] = constants[20]*(power(states[15], 3.00000))*states[16]*states[17]*algebraic[39]*(states[0]-algebraic[70])
    algebraic[0] = floor(voi/constants[9])*constants[9]
    algebraic[16] = custom_piecewise([greater_equal(voi-algebraic[0] , constants[8]) & less_equal(voi-algebraic[0] , constants[8]+constants[10]), constants[11] , True, 0.00000])
    algebraic[86] = ((algebraic[81]+algebraic[85]+algebraic[77]+algebraic[83])-2.00000*algebraic[41])+algebraic[82]+0.500000*algebraic[16]
    algebraic[53] = (constants[36]*states[0]*constants[0]*constants[5]*(states[19]-constants[4]*exp(states[0]*constants[5])))/(1.00000-exp(states[0]*constants[5]))
    algebraic[55] = algebraic[53]*states[20]
    algebraic[87] = -log(constants[4]/states[19])/constants[5]
    algebraic[88] = constants[38]*(states[0]-algebraic[87])
    algebraic[89] = algebraic[88]+algebraic[55]+0.500000*algebraic[16]
    rates[0] = -(algebraic[68]+algebraic[86]+algebraic[51]+algebraic[89])
    algebraic[90] = (constants[50]*(power(algebraic[59]-algebraic[87], 4.00000)))/(power(algebraic[59]-algebraic[87], 4.00000)+power(87.8251, 4.00000))
    rates[18] = (-algebraic[68]*constants[73])/constants[69]+algebraic[90]
    algebraic[91] = (constants[51]*(algebraic[70]-algebraic[87]))/((algebraic[70]-algebraic[87])+87.8251)
    rates[23] = (-algebraic[86]*constants[73])/constants[69]+algebraic[91]
    rates[19] = (algebraic[89]*constants[73])/constants[69]+algebraic[90]+algebraic[91]
    return(rates)

def computeAlgebraic(constants, states, voi):
    algebraic = array([[0.0] * len(voi)] * sizeAlgebraic)
    states = array(states)
    voi = array(voi)
    algebraic[7] = 9.00000-8.00000/(1.00000+exp(-(states[0]+65.0000)/3.40000))
    algebraic[13] = 1.00000/(1.00000+constants[37]/states[4])
    algebraic[15] = 1.00000/(1.00000+exp((states[0]+91.0000)/6.10000))
    algebraic[2] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, 0.135000*exp((80.0000+states[0])/-6.80000)])
    algebraic[18] = custom_piecewise([greater_equal(states[0] , -40.0000), 1.00000/(0.130000*(1.00000+exp((states[0]+10.6600)/-11.1000))) , True, 3.56000*exp(0.0790000*states[0])+310000.*exp(0.350000*states[0])])
    algebraic[1] = (0.320000*1.00000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[17] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[3] = custom_piecewise([greater_equal(states[0] , -40.0000), 0.00000 , True, ((-127140.*exp(0.244400*states[0])-3.47400e-05*exp(-0.0439100*states[0]))*1.00000*(states[0]+37.7800))/(1.00000+exp(0.311000*(states[0]+79.2300)))])
    algebraic[19] = custom_piecewise([greater_equal(states[0] , -40.0000), (0.300000*exp(-2.53500e-07*states[0]))/(1.00000+exp(-0.100000*(states[0]+32.0000))) , True, (0.121200*exp(-0.0105200*states[0]))/(1.00000+exp(-0.137800*(states[0]+40.1400)))])
    algebraic[4] = 1.00000/(1.00000+exp(-(states[0]-4.00000)/6.74000))
    algebraic[20] = 0.590000+(0.800000*exp(0.0520000*(states[0]+13.0000)))/(1.00000+exp(0.132000*(states[0]+13.0000)))
    algebraic[5] = 0.700000/(1.00000+exp((states[0]+17.1200)/7.00000))+0.300000
    algebraic[21] = 1.00000/(0.241100*exp(-(power(0.0450000*(states[0]-9.69140), 2.00000)))+0.0529000)
    algebraic[6] = 0.770000/(1.00000+exp((states[0]+17.1200)/7.00000))+0.230000
    algebraic[22] = 1.00000/(0.0423000*exp(-(power(0.0590000*(states[0]-18.5726), 2.00000)))+0.00540000)
    algebraic[8] = 1.00000/(1.00000+exp(-2.18200-0.181900*states[0]))
    algebraic[23] = 43.0000+1.00000/(exp(-5.49500+0.169100*states[0])+exp(-7.67700-0.0128000*states[0]))
    algebraic[9] = 1.00000/(1.00000+exp(-(states[0]-10.5000)/24.7000))
    algebraic[24] = 1.00000/((7.61000e-05*(states[0]+44.6000))/(1.00000-exp(-9.97000*(states[0]+44.6000)))+(0.000360000*(states[0]-0.550000))/(exp(0.128000*(states[0]-0.550000))-1.00000))
    algebraic[10] = (25.0000*exp((states[0]-40.0000)/25.0000))/(1.00000+exp((states[0]-40.0000)/25.0000))
    algebraic[25] = (25.0000*exp(-(states[0]+90.0000)/25.0000))/(1.00000+exp(-(states[0]+90.0000)/25.0000))
    algebraic[11] = 0.0300000/(1.00000+exp((states[0]+60.0000)/5.00000))
    algebraic[26] = (0.200000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000))
    algebraic[12] = 0.00225000/(1.00000+exp((states[0]+60.0000)/5.00000))
    algebraic[27] = (0.100000*exp((states[0]+25.0000)/5.00000))/(1.00000+exp((states[0]+25.0000)/5.00000))
    algebraic[14] = (0.320000*1.00000*(states[0]+47.1300))/(1.00000-exp(-0.100000*(states[0]+47.1300)))
    algebraic[28] = 0.0800000*exp(-states[0]/11.0000)
    algebraic[30] = (constants[13]*4.00000*(states[0]-15.0000)*constants[0]*constants[5]*(constants[14]*states[4]*exp(2.00000*(states[0]-15.0000)*constants[5])-constants[15]*constants[2]))/(exp(2.00000*(states[0]-15.0000)*constants[5])-1.00000)
    algebraic[31] = (power(states[5], states[6]))*states[7]*states[10]*states[8]*states[9]*algebraic[30]
    algebraic[33] = 1.00000/(1.00000-algebraic[31]/0.0100000)
    algebraic[35] = 300.000/(1.00000+exp((-algebraic[31]-0.175000)/0.0400000))+125.000
    algebraic[34] = (power(states[24], 1.90000))/(power(states[24], 1.90000)+power((49.2800*states[4])/(states[4]+0.00280000), 1.90000))
    algebraic[36] = algebraic[34]/(power(1.00000/algebraic[31], 2.00000)+1.00000)
    algebraic[52] = (constants[42]*(1.00000-states[25]))/(1.00000+constants[43]/states[4])
    algebraic[54] = algebraic[52]+states[25]
    algebraic[32] = 0.300000/(1.00000-algebraic[31]/0.0500000)+0.550000/(1.00000+states[4]/0.00300000)+0.150000
    algebraic[56] = (10.0000*algebraic[54])/(0.150000+algebraic[54])+1.00000/(1.00000+states[4]/0.00300000)+0.500000
    algebraic[57] = 1.00000/(1.00000+exp((algebraic[31]+0.0500000)/0.0150000))
    algebraic[63] = 1.00000/(1.00000+exp(((states[4]-0.000400000)+0.00200000*algebraic[57])/2.50000e-05))
    algebraic[60] = (constants[41]*algebraic[54])/(constants[44]+algebraic[54])
    algebraic[66] = 3.00000+algebraic[60]+(350.000-algebraic[60])/(1.00000+exp(((states[4]-0.00300000)+0.00300000*algebraic[57])/0.000200000))
    algebraic[67] = (constants[45]*algebraic[54])/(constants[44]+algebraic[54])
    algebraic[69] = (constants[46]*algebraic[54])/(constants[44]+algebraic[54])
    algebraic[71] = ((algebraic[69]+1.00000)*constants[47]*states[12])/((states[12]+constants[48])-algebraic[67])
    algebraic[73] = (constants[47]*states[28])/constants[49]
    algebraic[75] = (states[28]-states[24])/120.000
    algebraic[49] = (constants[33]*states[12])/(constants[34]+states[12])
    algebraic[50] = (constants[35]*states[0]*constants[0]*constants[5]*(states[12]*exp(2.00000*states[0]*constants[5])-0.341000*constants[2]))/(exp(2.00000*states[0]*constants[5])-1.00000)
    algebraic[42] = 1.50000*states[12]
    algebraic[43] = 1.00000/(1.00000+power(constants[25]/algebraic[42], 2.00000))
    algebraic[44] = (power(states[18], 3.00000))*constants[2]*exp(constants[28]*states[0]*constants[5])-(power(constants[3], 3.00000))*algebraic[42]*exp((constants[28]-1.00000)*states[0]*constants[5])
    algebraic[45] = 1.00000+constants[27]*exp((constants[28]-1.00000)*states[0]*constants[5])
    algebraic[46] = constants[32]*(power(states[18], 3.00000))+(power(constants[30], 3.00000))*algebraic[42]+(power(constants[29], 3.00000))*constants[2]*(1.00000+algebraic[42]/constants[31])
    algebraic[47] = constants[31]*(power(constants[3], 3.00000))*(1.00000+power(states[18]/constants[29], 3.00000))+(power(states[18], 3.00000))*constants[2]+(power(constants[3], 3.00000))*algebraic[42]
    algebraic[48] = (constants[26]*algebraic[43]*algebraic[44])/(algebraic[45]*(algebraic[46]+algebraic[47]))
    algebraic[76] = (states[4]-states[12])/0.200000
    algebraic[79] = 1.00000/(1.00000+(constants[55]*constants[53])/(power(states[12]+constants[53], 2.00000))+(constants[52]*constants[54])/(power(states[12]+constants[52], 2.00000)))
    algebraic[58] = 1.00000/(1.00000+exp((algebraic[30]+13.0000)/5.00000))
    algebraic[61] = 3000.00*algebraic[58]
    algebraic[64] = algebraic[61]*states[26]*states[27]*(states[24]-states[4])
    algebraic[80] = 1.00000/(1.00000+(constants[58]*constants[59])/(power(constants[59]+states[4], 2.00000))+(constants[60]*constants[61])/(power(constants[61]+states[4], 2.00000)))
    algebraic[78] = 1.00000/(1.00000+(constants[56]*constants[57])/(power(states[24]+constants[56], 2.00000)))
    algebraic[51] = (algebraic[31]+algebraic[50]+algebraic[49])-2.00000*algebraic[48]
    algebraic[59] = log(constants[3]/states[18])/constants[5]
    algebraic[29] = constants[12]*states[2]*states[2]*states[2]*states[1]*states[3]
    algebraic[62] = algebraic[29]*(states[0]-algebraic[59])
    algebraic[40] = 1.00000/(1.00000+0.124500*exp(-0.100000*states[0]*constants[5])+0.0365000*constants[64]*exp(-states[0]*constants[5]))
    algebraic[41] = (((constants[24]*algebraic[40]*1.00000)/(1.00000+power(constants[22]/states[18], 2.00000)))*constants[1])/(constants[1]+constants[23])
    algebraic[65] = constants[39]*(power(states[21], 3.00000))*states[22]*(states[0]-algebraic[59])
    algebraic[68] = algebraic[62]+3.00000*algebraic[48]+3.00000*algebraic[41]+algebraic[65]
    algebraic[70] = log(constants[1]/states[23])/constants[5]
    algebraic[72] = 1.02000/(1.00000+exp(0.238500*((states[0]-algebraic[70])-59.2150)))
    algebraic[74] = (0.491240*exp(0.0803200*((states[0]-algebraic[70])+5.47600))+1.00000*exp(0.0617500*((states[0]-algebraic[70])-594.310)))/(1.00000+exp(-0.514300*((states[0]-algebraic[70])+4.75300)))
    algebraic[77] = ((constants[17]*(power(constants[1]/4.00000, 1.0/2))*algebraic[72])/(algebraic[72]+algebraic[74]))*(states[0]-algebraic[70])
    algebraic[83] = (0.00276000*(states[0]-algebraic[70]))/(1.00000+exp((7.48800-states[0])/5.98000))
    algebraic[38] = constants[19]*(1.00000+0.600000/(1.00000+power(3.80000e-05/states[12], 1.40000)))
    algebraic[84] = log((constants[1]+constants[40]*constants[3])/(states[23]+constants[40]*states[18]))/constants[5]
    algebraic[85] = algebraic[38]*states[13]*states[14]*(states[0]-algebraic[84])
    algebraic[37] = 1.00000/(1.00000+2.50000*exp(0.100000*(states[0]+28.0000)))
    algebraic[81] = constants[63]*states[11]*algebraic[37]*(states[0]-algebraic[70])
    algebraic[39] = custom_piecewise([less_equal(states[0] , 0.00000), exp(states[0]/constants[21]) , True, 1.00000])
    algebraic[82] = constants[20]*(power(states[15], 3.00000))*states[16]*states[17]*algebraic[39]*(states[0]-algebraic[70])
    algebraic[0] = floor(voi/constants[9])*constants[9]
    algebraic[16] = custom_piecewise([greater_equal(voi-algebraic[0] , constants[8]) & less_equal(voi-algebraic[0] , constants[8]+constants[10]), constants[11] , True, 0.00000])
    algebraic[86] = ((algebraic[81]+algebraic[85]+algebraic[77]+algebraic[83])-2.00000*algebraic[41])+algebraic[82]+0.500000*algebraic[16]
    algebraic[53] = (constants[36]*states[0]*constants[0]*constants[5]*(states[19]-constants[4]*exp(states[0]*constants[5])))/(1.00000-exp(states[0]*constants[5]))
    algebraic[55] = algebraic[53]*states[20]
    algebraic[87] = -log(constants[4]/states[19])/constants[5]
    algebraic[88] = constants[38]*(states[0]-algebraic[87])
    algebraic[89] = algebraic[88]+algebraic[55]+0.500000*algebraic[16]
    algebraic[90] = (constants[50]*(power(algebraic[59]-algebraic[87], 4.00000)))/(power(algebraic[59]-algebraic[87], 4.00000)+power(87.8251, 4.00000))
    algebraic[91] = (constants[51]*(algebraic[70]-algebraic[87]))/((algebraic[70]-algebraic[87])+87.8251)
    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)