Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Convection of one species using different schemes

The unsteady convection equation for a concentration cc that is convected with velocity vv is:

ct=v cx\frac{\partial c}{\partial t} = - v\ \frac{\partial c}{\partial x}

For unsteady problems we will use the method of lines. After performing a spatial discretization the resulting set of ODE’s has the form:

dcdt=f(t,c)\frac{d\mathbf{c}}{dt} = \mathbf{f}\left( t,\mathbf{c} \right)

where c\mathbf{c} is the column vector that contains the concentrations, cic_{i}, where ii is the label of the grid cell.

You are asked to implement the one-component convection equation using the method-of-lines described above, using different spatial discretization methods, namely, upwind, central differencing and a total variance diminishing (TVD) scheme. For the time integration use a standard IVP solver.

Suggested approach:

  • Use NumPy arrays to store the concentrations, cic_{i}, and right hand side, fif_{i}, at different axial positions ii.

  • Prefer using NumPy array indexing notation over for loops for element-wise operations. This approach leverages NumPy’s optimized performance and often results in more readable and efficient code.

  • For each method, plot axial concentration profiles for several times.

  • Compare your results with an analytical solution of the problem to verify your code.

  • Play with the number of grid points NN used in the spatial discretization.

Questions:

  1. Implement upwind discretization, where

fi={v(c0cinΔx), for i=0v(cici1Δx), for i>0f_{i} = \left\{ \begin{matrix} - v\left( \frac{c_{0} - c_{in}}{\Delta x} \right),\ \text{for}\ i = 0 \\ - v\left( \frac{c_{i} - c_{i - 1}}{\Delta x} \right),\ \text{for}\ i > 0 \end{matrix} \right.
  1. Implement central differencing, where

fi={v(c1cinΔx), for i=0v(ci+1ci12 Δx), for i>0v(cici1Δx), for i=N1f_{i} = \left\{ \begin{array}{l} - v\left( \frac{c_{1} - c_{in}}{\Delta x} \right),\ \text{for}\ i = 0 \\ - v\left( \frac{c_{i + 1} - c_{i - 1}}{2\ \Delta x} \right),\ \text{for}\ i > 0 \\ - v\left( \frac{c_{i} - c_{i - 1}}{\Delta x} \right),\ \text{for}\ i = N - 1 \end{array} \right.
  1. Implement a TVD scheme, e.g. Min-Mod, for the convection. See lecture notes for the scheme.