Python Using backward vs central finite difference approximation

Click For Summary
The discussion focuses on solving the 2nd-order wave equation numerically using finite difference approximations. Central difference approximations yield stable solutions, while higher-order backward difference methods often lead to divergence due to their lower stability and potential grid inadequacies. A large Courant number, particularly with high wave speeds, complicates the numerical solution, necessitating modifications like staggered grids or implicit schemes to enhance stability. Spectral methods are also mentioned as a potential solution but may require more complex implementation. The choice of method ultimately depends on the specific parameters and accuracy requirements of the problem.
TheCanadian
Messages
361
Reaction score
13
I am solving the simple 2nd-order wave equation:

$$ \frac {\partial ^2 E}{\partial t^2} = c^2 \frac {\partial ^2 E}{\partial z^2} $$

Over a domain of (in SI units):

## z = [0,L=10]##m, ##t = [0,t_{max} = 10]##s

and boundary/initial conditions:

$$ E(z=0) = E(z=L) = 0 $$

$$ E(t=0) = -E(t=t_{max}) = sin(\frac{\pi z}{L}) $$

I know the analytic solution, but am trying to solve it numerically. (The numerical and analytic solutions are compared to test accuracy.) I just had a couple questions:

1) When I solve the wave equation by applying a central difference approximation of order 2 on the second derivative of time, the code works perfectly fine. Although when I apply http://(https://en.wikipedia.org/wiki/Finite_difference_coefficient#Forward_and_backward_finite_difference) of higher orders for the second derivative in time, my solution diverges. Is there any particular reason why using a backward difference approximation would be worse than a central difference approximation of the same order? I was under the impression using a higher order backward difference method would give me higher accuracy, but it appears to not work at all. I can supply the code if needed, although it's a fairly basic implementation.

2) I am able to solve the equation above when using a central difference approximation and setting ## c = 1## m/s, but if I use ##c = 3 \times 10^8## m/s, the solution diverges. This makes sense as the Courant number (##C_o = c \frac {\Delta t}{\Delta x}##) is much greater than one. But I am curious: are there any possible finite difference schemes that can be applied to numerically solve the equation if ##C_o >> 1##? I have read a bit about BDF methods to help solve stiff equations, but in this case, the only problem is that a more precise grid is needed, correct? I had also heard about spectral methods, but am still trying to learn how to implement them and if they would be applicable/accurate enough if other (nonlinear) terms were included in the wave equation.
 
Last edited by a moderator:
Technology news on Phys.org


1) There are a few reasons why using a backward difference approximation may not work as well as a central difference approximation. First, backward difference approximations are known to be less stable than central difference approximations, meaning that small errors in the initial conditions or boundary conditions can lead to large errors in the solution. This could be one reason why your solution is diverging. Additionally, higher order backward difference approximations may require more points to be accurate, so if your grid is not fine enough, the solution may not be accurate. Another possibility is that there may be an error in your implementation of the backward difference scheme.

2) It is possible to use finite difference methods to solve the wave equation with a large Courant number, but it may require some modifications to the standard scheme. One approach is to use a staggered grid, where the spatial and temporal grid points are offset from each other. This can help improve stability and accuracy for large Courant numbers. Another approach is to use an implicit scheme, where the time derivative is discretized using a backward difference approximation. This can be more stable for large Courant numbers, but it may also require solving a system of equations at each time step. Spectral methods can also be used for the wave equation, but they may require more points and can be more complex to implement. Ultimately, the best approach will depend on the specific problem and the desired level of accuracy.
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
Replies
2
Views
1K
  • · Replies 4 ·
Replies
4
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K