Advection-Diffusion Problems

$$\phi_t + u\phi_x = \Gamma\phi_{xx},$$

Or

$$\frac{\partial\phi}{\partial t} + u\frac{\partial\phi}{\partial x} = \Gamma \frac{\partial^2\phi}{\partial x^2},$$

where $u$ is a velocity, $\phi$ is our scalar variable, and $\Gamma$ is a diffusion coefficient (like $\alpha$).

FTCS method

$$\frac{\partial\phi}{\partial t} + u\frac{\partial\phi}{\partial x} = \Gamma \frac{\partial^2\phi}{\partial x^2},$$$$\phi_i^{n+1} = \phi_i^n - \frac{1}{2}\underbrace{\frac{u\Delta t}{\Delta x}}_{c}(\phi_{i+1}^n - \phi_{i-1}^n) + \underbrace{\frac{\Gamma\Delta t}{\Delta x^2}}_{d}(\phi_{i-1}^n - 2\phi_i^n + \phi_{i+1}^n).$$

BTCS method

Trouble with central differences

$$u\frac{\partial\phi}{\partial x} = \Gamma \frac{\partial^2\phi}{\partial x^2}.$$ $$(u\phi)_e - (u\phi)_w = \Gamma\left(\frac{d\phi}{dx}\right)_e - \Gamma\left(\frac{d\phi}{dx}\right)_w.$$$$\frac{1}{2}u_e(\phi_E + \phi_P) - \frac{1}{2}u_w(\phi_P + \phi_W) = \frac{\Gamma}{\Delta x}(\phi_E - \phi_P) - \frac{\Gamma}{\Delta x}(\phi_P - \phi_W).$$ $$\phi_W\left(-\frac{1}{2}u - \frac{\Gamma}{\Delta x}\right) + \phi_P\left(\frac{\Gamma}{\Delta x}\right) + \phi_E\left(\frac{1}{2}u - \frac{\Gamma}{\Delta x}\right) = 0.$$

Divide through by $\frac{\Gamma}{\Delta x}$:

$$\phi_W\left(-\frac{Pe}{2} -1 \right) + \phi_P(2) + \phi_E\left(\frac{Pe}{2} - 1\right) = 0.$$

Solve the above equation for $\phi_P$ in terms of its neighbors:

$$\phi_P = \frac{1}{2}\left[\phi_W\left(\frac{Pe}{2} + 1\right) - \phi_E\left(\frac{Pe}{2}-1\right)\right].$$
import ipywidgets as wgt
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline


def f(Pe):
    ϕw = 2
    ϕe = 1
    ϕp = 1/2*(ϕw*(Pe/2 + 1) - ϕe*(Pe/2 - 1))
    ϕ = np.array([ϕw,ϕp,ϕe])
    x = np.array([0, 1, 2])
    plt.rc("font", size=14)
    plt.plot(x,ϕ,'o-', markersize=10, lw=3)
    plt.ylim([0,3])
    plt.xlabel('x')
    plt.ylabel('ϕ')
    plt.grid()
    plt.show() 

wgt.interact(f, Pe=(-5,5,0.1));     # try adding string and list arguments...

Following Patankar, we can write our above equation as

$$C_p \phi_P = C_E\phi_E + C_W\phi_W,$$

where $C$’s are coefficients of the $\phi$’s. * Here, $C_P=1$, $C_E = -Pe/4 + 1/2$, and $C_W = Pe/4 + 1/2.$ * All coefficients in this form should have the same sign so that increases in the neighbors result in increases in $\phi_P$, and vice-versa. * If $Pe>2$, then $C_E$ is negitive while the other $C$’s are positive.

Remedy: upwinding

The problem above is that we applied a central difference approximation when evaluating the convective term. * (In the FV approach, we applied a linear interpolation when evaluating the face properties, which is analogous to using a central difference.) * These approaches effectively give equal weighting to the neighbors when computing a property. * But advection is directional. * You can smell much better when something is upwind of you then when it is downwind of you. * In evaluating face properties, don’t weight each neighbor equally. * Insteady, advection blows the upstream value to the face.

$$\phi_e = \phi_P,\phantom{xx}\mbox{if}\phantom{xx} u_e>0,$$

$$\phi_e = \phi_E,\phantom{xx}\mbox{if}\phantom{xx} u_e<0,$$$$\phi_w = \phi_W,\phantom{xx}\mbox{if}\phantom{xx} u_w>0,$$

$$\phi_w = \phi_P,\phantom{xx}\mbox{if}\phantom{xx} u_w<0.$$

There is no change to the diffusion term. Diffusion has no directionality. Use central differences.

$$u\phi_e - u\phi_w = \Gamma\left(\frac{d\phi}{dx}\right)_e - \Gamma\left(\frac{d\phi}{dx}\right)_w.$$$$u\phi_P - u\phi_W = \frac{\Gamma}{\Delta x}(\phi_E - \phi_P) - \frac{\Gamma}{\Delta x}(\phi_P - \phi_W).$$

Solve for $\phi_P$:

$$\phi_P = \phi_E\left[\frac{\frac{\Gamma}{\Delta x}}{u + 2\frac{\Gamma}{\Delta x}}\right] + \phi_W\left[\frac{u+\frac{\Gamma}{\Delta x}}{u + 2\frac{\Gamma}{\Delta x}}\right], $$

Or,

$$\phi_P = \phi_E\left[\frac{1}{Pe+2}\right] + \phi_W\left[\frac{Pe+1}{Pe+2}\right]. $$