** Finding equilibrium conversion
:PROPERTIES:
:categories: Nonlinear algebra
:date: 2013/02/27 10:48:49
:updated: 2013/02/27 14:47:24
:END:
A common problem to solve in reaction engineering is finding the equilibrium conversion.[fn:1] A typical problem to solve is the following nonlinear equation:
$1.44 = \frac{X_e^2}{(1-X_e)^2}$
To solve this we create a function:
$f(X_e)=0=1.44 - \frac{X_e^2}{(1-X_e)^2}$
and use a nonlinear solver to find the value of $X_e$ that makes this function equal to zero. We have to provide an initial guess. Chemical intuition suggests that the solution must be between 0 and 1, and mathematical intuition suggests the solution might be near 0.5 (which would give a ratio near 1).
Here is our solution.
#+BEGIN_SRC python
from scipy.optimize import fsolve
def func(Xe):
z = 1.44 - (Xe**2)/(1-Xe)**2
return z
X0 = 0.5
Xe, = fsolve(func, X0)
print('The equilibrium conversion is X = {0:1.2f}'.format(Xe))
#+END_SRC
#+RESULTS:
: The equilibrium conversion is X = 0.55
*** Footnotes
[fn:1] See Fogler, 4th ed. page 1025 for the setup of this equation.