Question about finite differences

  • Thread starter Thread starter Telemachus
  • Start date Start date
  • Tags Tags
    Finite
Click For Summary
The discussion centers on the use of finite differences to solve a PDE, specifically the 2D time-dependent advection equation with Dirichlet boundary conditions. The author compares two finite difference derivatives derived from different formulations, noting that one yields better accuracy than the other despite both being third order. They suspect that the matrix representation's diagonal dominance may influence the performance of the derivatives. Stability issues arise when using a forward Euler method, particularly with higher-order schemes, leading to difficulties in achieving a stable solution. The conversation highlights the complexities of finite difference methods and the challenges of maintaining accuracy and stability near boundaries.
Telemachus
Messages
820
Reaction score
30
Hi. I have written a code which solves a pde using finite differences. I won't post the code, because it's too long, and I want to discuss something specific on finite difference regarding theory.

It can be proven that the forward finite difference first derivative can be obtained from the following expansion:

##\left. \frac{dy}{dx}^+\right|_i=\frac{1}{\Delta x}\left[ \Delta-\frac{1}{2}\Delta^2+\frac{1}{3}\Delta^3+...\right] y_i##

Where ##y_i=y(x_i)=y(i\Delta x)##, and where ##\Delta## represents the finite difference operator: ##\Delta y_i=y_{i+1}-y_i##.

When one approximates the differential operator on the left by cutting the series expansion on the right, a finite difference approximation of order ##\mathcal{O}(\Delta x^n)## is obtained, where n is related to the first term ignored in the series.

However, other representations in finite differences of the differential operator might be obtained by evaluating the right hand side of the equation at other grid points.

It can be proven that ##\frac{d}{dx}^+=\frac{1}{\Delta x}\log(1+\Delta)##, so:

##\frac{d}{dx}^+y_i=\frac{1}{\Delta x}\log(1+\Delta)y_i##, the series representation given above is the corresponding for the operator on the right hand side of the last equation. However, this can also be written as: ##\frac{d}{dx}^+y_i=\frac{1}{\Delta x}\log(1+\Delta)(1+\Delta)^k y_{i-k}##

So other series representation for the differential operator in terms of finite difference operator might be obtained by expanding this alternative operator, which allows to obtain the finite difference derivative at point i, with points evaluated from (i-k) in the mesh.

Now here is my doubt. I have worked with this two finite difference derivatives, the one obtained from ##\frac{d}{dx}^+y_i=\frac{1}{\Delta x}\log(1+\Delta)y_i## and the one obtained from ##\frac{d}{dx}^+y_i=\frac{1}{\Delta x}\log(1+\Delta)(1+\Delta) y_{i-1}##.

The thing is that I expected to obtain the same accuracy for both derivatives. Up to the third order, those derivatives are:
##\frac{d}{dx}^+y_i=\frac{1}{\Delta x}\left [ 2y_{i+3}-9y_{i+2}+18y_{i+1}-11y_i\right ]##.

Using the alternative form of the expansion for the forward derivative, which computes the derivative using one previous step, this is obtained:
##\frac{d}{dx}^+y_i=\frac{1}{\Delta x}\left [ -y_{i+2}+6y_{i+1}-3y_i- 2y_{i-1}\right ]##.
The last form of the derivative used in my code gives better results than the first one, and I don't know why. It would look like if the last representation would suffer less dispersive error than the first one. I have checked the code several times, and I have also redone all the algebra to derive the finite difference formulas, and I think they are correct, but I don't know why one is better than the other.

Thanks in advance.

PS: I've been thinking, and what I've noted is that in one way the matrix representation of the finite difference operator for the derivative is more diagonally dominant than in the other. I wonder if this could be affecting some how.
 
Last edited:
  • Like
Likes Delta2
Technology news on Phys.org
What pde and bc’s are you trying to solve?
 
  • Like
Likes Telemachus
I am solving the 2D time dependent advection equation on a square with Dirichlet boundary conditions. I am using forward Euler in time. I am trying to avoid looking for the eigenvalues of the finite difference matrix to see the stability issue, but I have today worked with a 6 points formula (##\Delta x^5## accuracy), and it looked like I should take excessively small time steps to get stability.
 
  • Like
Likes Delta2
Telemachus said:
I am solving the 2D time dependent advection equation on a square with Dirichlet boundary conditions. I am using forward Euler in time. I am trying to avoid looking for the eigenvalues of the finite difference matrix to see the stability issue, but I have today worked with a 6 points formula (##\Delta x^5## accuracy), and it looked like I should take excessively small time steps to get stability.
Only advection, but no diffusion?
 
  • Like
Likes Telemachus
Chestermiller said:
Only advection, but no diffusion?

Yes, advection only.

##\frac{\partial u}{\partial t} + \frac{\partial u}{\partial x}+\frac{\partial u}{\partial y}=q(\mathbf{r},t)##,
with ##u(x=0,y,t)=u(x,y=0,t)=u(x,y,t=0)=0##
 
Telemachus said:
Yes, advection only.

##\frac{\partial u}{\partial t} + \frac{\partial u}{\partial x}+\frac{\partial u}{\partial y}=q(\mathbf{r},t)##,
with ##u(x=0,y,t)=u(x,y=0,t)=u(x,y,t=0)=0##
Because the velocity is constant, this can be solved by the method of characteristics. Are you not allowed to use that?
 
No, I want to solve the pde as it stands using finite differences because it is part of a bigger solver. The signs of the spatial derivatives should be negative in my previous post, I'm not allowed to edit anymore. And anyway, I would like to know what is happening with the different finite difference schemes, why two schemes, both being third order, one works better than the other? and why I haven't been able to obtain a stable scheme for finite differences of bigger order? I am working now with the six point derivative, I have tried with a lot of points in the time derivative, being the time steps four orders of magnitude smaller than the spatial step, and it still being unstable.
 
You can still solve the equation using finite differences, based on the method of characteristics. As far as the difference scheme you are presently using is concerned, I would exercise caution, particularly since you are using a forward Euler in time, which tends to result in stability issues.
 
  • Like
Likes Telemachus
There is something I haven't mentioned. At the points close to the boundary, I am using a different treatment for the derivatives. At those points, I have to use only one sided derivatives, so the scheme I am using in the interior of the domain, and in points close to the boundaries are different, in a way that I can use 5th order finite differences everywhere. However, I am not able to make it work.
 
  • #10
Telemachus said:
There is something I haven't mentioned. At the points close to the boundary, I am using a different treatment for the derivatives. At those points, I have to use only one sided derivatives, so the scheme I am using in the interior of the domain, and in points close to the boundaries are different, in a way that I can use 5th order finite differences everywhere. However, I am not able to make it work.
I'm not surprised. This is a very nasty problem mathematically. How accurate does this thing have to be? If not very accurate, just use upwind differencing.
 
  • Like
Likes Telemachus
  • #11
Ok, I'll see what can I do.
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 7 ·
Replies
7
Views
772
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
8
Views
2K
Replies
1
Views
3K
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K