Finite difference method for the diffusion-advection equation

LogarithmLuke
Messages
82
Reaction score
3
Homework Statement
Consider the diffusion-advection equation given by ## \mu \Delta u + \mathbf{v} \cdot \nabla u = f \ \text{in} \ \Omega ## with some appropiate boundary conditions. Here the velocity field ##\mathbf{v} : \Omega \rightarrow \mathbb{R}^2## and the source function ## f: \Omega \rightarrow \mathbb{R} ## may depend on the position. Here ##\Delta## is the Laplace operator, and ##\nabla## is the gradient.

Solve the problem on a unit square with Dirichlet boundary conditions. Set up a finite difference scheme using central differences for both the first and second derivatives of ##u##. Implement the scheme. Write your program so it can solve the problem for different choices of ##\mathbf{v}##
Relevant Equations
-
So for my scheme I obtained ##\frac{\mu}{h^2} U_{p}+(\frac{v_{1}}{2 h}-\frac{\mu}{h^2})U_{E}+(\frac{v_{2}}{2 h} - \frac{\mu}{h^2})U_{N} - (\frac{v_{1}}{2 h}+\frac{\mu}{h^2})U_{W} - (\frac{v_{2}}{2 h} + \frac{\mu}{h^2})U_{N} + \tau = f## however I am not sure this is correct. I am quite new to the finite difference method, and honestly find it quite difficult. I am also not sure how to go about setting up the A matrix and progressing onward to solve the rest of the problem. Any help would be greatly appreciated.
 
Physics news on Phys.org
You have N, W, and E. What happened to S?

I assume that this is a 2D problem, correct? You should be using subscript indexes of I and J on U, not N, S, E, and W.
 
Yes this is a 2D problem. The last ##U_N## should have been a ##U_S##. Ok so using subscript indicies i and j instead I obtain the following scheme:

##4\frac{\mu}{h^2} U_{i,j}+(\frac{v_{1}}{2 h}-\frac{\mu}{h^2})U_{i+1,j}+(\frac{v_{2}}{2 h} -\frac{\mu}{h^2})U_{i,j+1} - (\frac{v_{1}}{2 h}+\frac{\mu}{h^2})U_{i-1,j} - (\frac{v_{2}}{2 h} + \frac{\mu}{h^2})U_{i,j-1} + \tau = f## where ##\tau## is an error term.

Does this seem correct? I realized I had forgotten a factor 4 when I recalculated it.
 
Last edited:
I think you have the signs wrong on the diffusion terms. I haven't checked the advection terms yet. Are you assume that the two velocity components are independent of x and y? The f term should be subscripted i,j unless f is constant.
 
Im not familiar with what the diffusion terms and advection terms of the equation are. I did not think about whether the velocity components were independent of x and y, I simply dotted the components with the nabla vector for u, where I replaced the partial derivatives with central differences.
 
The signs of the terms involving ##\mu## are wrong.
 
So this is the correct scheme? ##-4\frac{\mu}{h^2} U_{i,j}+(\frac{v_{1}}{2 h}+\frac{\mu}{h^2})U_{i+1,j}+(\frac{v_{2}}{2 h} +\frac{\mu}{h^2})U_{i,j+1} - (\frac{v_{1}}{2 h}-\frac{\mu}{h^2})U_{i-1,j} - (\frac{v_{2}}{2 h} - \frac{\mu}{h^2})U_{i,j-1} + \tau = f_{ij}## How would I transition further to set up the pentadiagonal(?) matrix A to solve the problem?
 
LogarithmLuke said:
So this is the correct scheme? ##-4\frac{\mu}{h^2} U_{i,j}+(\frac{v_{1}}{2 h}+\frac{\mu}{h^2})U_{i+1,j}+(\frac{v_{2}}{2 h} +\frac{\mu}{h^2})U_{i,j+1} - (\frac{v_{1}}{2 h}-\frac{\mu}{h^2})U_{i-1,j} - (\frac{v_{2}}{2 h} - \frac{\mu}{h^2})U_{i,j-1} + \tau = f_{ij}##
. Looks OK.
How would I transition further to set up the pentadiagonal(?) matrix A to solve the problem?
You define a solution vector ##y_k##, and then associate the U values with this vector in order, row-by-row or column-by-column.
 
Back
Top