import numpy as np
import scipy.integrate as sci
import pylab as pl
k = 0.01
9
y0 = [5, 0]
tspan = np.arange(0., 600., 0.1)
def balances(y, t):
global k
cA, cB = y
dcA = -k * cA
dcB = k * cA
return [dcA, dcB]
y = sci.odeint(balances, y0, tspan)
pl.plot(tspan, y)
pl.xlabel("Time (s)", weight="bold")
pl.ylabel("Concentration (mol/L)", weight="bold")
pl.legend(("cA", "cB"))
pl.title(u"Profile de concentration d'une réaction de type A -> B \ndans un réacteur batch", weight="bold")
pl.savefig('simple_plot')
pl.show()