Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168703
Image: ubuntu2004

Simple chemical reaction in an  ideally mixed stirred-stank reactor

import numpy as np import scipy.integrate as sci import pylab as pl k = 0.01 # reaction rate constant (s-1) 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()