Application of linear ODEs to ChE examples
Contents
Application of linear ODEs to ChE examples#
Alternate Method (Last class continued)#
Treat as Linear ODE#
Take \(p(t) = \frac{1}{V}(F+kV)\) and \(r(t) = \frac{F}{V}C_{in}\). Then,
And
If \(C(t=0) = C_0\) then \(C_0 = \frac{FC_{in}}{F+kV} + \alpha \implies \alpha = C_0 - \frac{FC_{in}}{F+kV}\) and
Since we were able to solve both as separable and linear, why would we deal with linear?
Solutions with time varying (but known) feed concentrations)#
There will be some cases where we must:
\(\implies\) What if the feed concentration varies with time for the same example?
Take \(p(t) = \left(\frac{F+kV}{V} \right)\) and \(r(t) = \frac{F}{V}C_F(t)\)
\(\rightarrow\) Solve as a linear \(1^\circ\) ODE:
then,
\(\rightarrow\) need to know \(C_F(t)\) to solve. Let’s consider several cases:
No feed (\(C_F(t) = 0\))#
\(\underline{\text{Case 1:}}\) \(C_F(t) = 0 \rightarrow\) no feed
Think first: tank is filled with initial reactant at \(C_0\) and that’s all there will be. Solution for \(C(t)\) should decay from \(C_0\) to 0.
then, \(C(t=0)=C_0=Ne^{-\alpha 0} \implies N=C_0\) and
Constant feed (\(C_F(t) = C_F\))#
\(\underline{\text{Case 2:}}\) \(C_F(t) = C_F \rightarrow\) constant feed
Think first: initial conc. in tank is \(C_0\) and will assyptotically approach a lower or highr value depending on if \(C_F<C_0\) or \(C_F>C_0\)
then, \(C(t=0) = C_0 = \frac{FC_F}{V\alpha} + N e^{-\alpha 0} \implies N = C_0 - \frac{FC_F}{V\alpha}\) and
At steady state:
Exponentially decaying feed (\(C_F(t) = C_F \exp(-\beta t)\))#
\(\underline{\text{Case 3}}\) : \(C_F(t) = C_F \exp(-\beta t)\) (decaying function)
\(\beta\) controls the speed of the approach to steady state
then \(C(t=0) = C_0 = \frac{FC_F}{V(\alpha - \beta)}e^0 + Ne^0 \implies N = C_0 - \frac{FC_F}{V(\alpha - \beta)}\) and
At steady state,
Makes sense, right? No new reactant entering the reactor at steady state Rate of decay depends on parameters \(\alpha, \beta, V, C_f\) and \(F\)
Oscillating Feed (\(C_F(t) = C_f[1+\sin(\omega t)]\)(#
\(\underline{\text{Case 4}}\): \(C_F(t) = C_f[1+\sin(\omega t)]\) (oscillating feed)
then
and:
At steady state right side term drops out; we’r still oscillating at steady state.
Numerical evaluation of the solutions to an oscillatory CSTR feed#
Simplest way using constants for the parameters
import numpy as np
import matplotlib.pyplot as plt
F = 1
V = 1
k = 1
omega = 1
Cf = 2
C0 = 4
alpha = (F+k*V)/V
t = np.linspace(0,30,500)
C = F/V*Cf*(1/alpha + \
(alpha*np.sin(omega*t)-omega*np.cos(omega*t))/(alpha**2+omega**2)) + \
(C0-F/V*Cf*(1/alpha-omega/(alpha**2+omega**2)))*np.exp(-alpha*t)
plt.plot(t,C)
plt.xlabel('Time')
plt.ylabel('Concentration C [mol/L]')
plt.xlim([0,30])
plt.ylim([0,4])
(0.0, 4.0)
alpha
2.0
omega
1
More readable/helpful way using a function to do the solution; this way we know exactly what the parameters are that can be varied, and we can set defaults for parameters. This makes plotting for different parameters really clean!
import numpy as np
import matplotlib.pyplot as plt
def solve_C(t,
V = 1,
F = 1,
k = 1,
omega = 1,
Cf = 2,
C0 = 4):
# This function evaluates the solution for a CSTR with a time-varying
# sinusoidal feed concentration
alpha = (F+k*V)/V
C = F/V*Cf*(1/alpha + \
(alpha*np.sin(omega*t)-omega*np.cos(omega*t))/(alpha**2+omega**2)) + \
(C0-F/V*Cf*(1/alpha-omega/(alpha**2+omega**2)))*np.exp(-alpha*t)
return C
t = np.linspace(0,10,500)
plt.plot(t,solve_C(t=t, C0=1), label='$C_0=1$')
plt.plot(t,solve_C(t=t, C0=2), label='$C_0=2$')
plt.plot(t,solve_C(t=t, C0=4), label='$C_0=4$')
plt.xlabel('Time')
plt.ylabel('Concentration C [mol/L]')
plt.xlim([0,10])
plt.ylim([0,4])
plt.legend()
<matplotlib.legend.Legend at 0x7f5f18432770>
t = np.linspace(0,10,500)
plt.plot(t,solve_C(t=t, omega=0.5), label='$\omega=0.5$')
plt.plot(t,solve_C(t=t, omega=1), label='$\omega=1$')
plt.plot(t,solve_C(t=t, omega=2), label='$\omega=2$')
plt.plot(t,solve_C(t=t, omega=100), label='$\omega=2$')
plt.xlabel('Time')
plt.ylabel('Concentration C [mol/L]')
plt.xlim([0,10])
plt.ylim([0,4])
plt.legend()
<matplotlib.legend.Legend at 0x7f5f3b5f3580>
t = np.linspace(0,10,500)
plt.plot(t,solve_C(t=t, Cf=0.5), label='$C_F=0.5$')
plt.plot(t,solve_C(t=t, Cf=1), label='$C_F=1$')
plt.plot(t,solve_C(t=t, Cf=2), label='$C_F=2$')
plt.xlabel('Time')
plt.ylabel('Concentration C [mol/L]')
plt.xlim([0,10])
plt.ylim([0,4])
plt.legend()
<matplotlib.legend.Legend at 0x7f5f1826d1b0>