|
[Sponsors] |
August 25, 2022, 12:21 |
How does numerical diffusion happen?
|
#1 |
Senior Member
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8 |
I was testing with calculating local dt to satisfy CFL condition for a 1d non-linear convection solver.
I used the formula dt = cfl*dx/un[i] When CFL was 1.0, the wave didn't have have any numerical diffusion, but for CFL 0.9 the numerical diffusion started to occur. Why? For CFL 0.9, the code should be more stable, right? I still don't 100% understand: How does numerical diffusion happen? Julia code: Code:
using Plots; n = 1000; # no. of nodes in the domain c = +1.0; # linear velocity of the wave xstart = +0.0; # start of domain xend = +100.0; # end of domain dt = +99999999; # timestep (*needs* to be computed later to satisfy cfl condition) dx = (xend-xstart)/(n-1.0); # spacestep cfl = 1.0; # courant-freidrichs-lewy condition icstart = 25; # initial condition start index icend = 100; # initial condition end index x = collect(LinRange(xstart,xend,n)); # domain or mesh of n nodes u = collect(LinRange(1.0,1.0,n)); # solution of the linear wave equation u[icstart:icend] .= 2.0; # set initial condition, a hat function u0 = copy(u); # initial solution for t in 1:2^8; # timestep iterations un = copy(u); for i in 2:n dt = cfl*dx/un[i]; u[i] = un[i] - un[i]*dt/dx*(un[i]-un[i-1]); end end display(plot(x,[u0,u])); |
|
August 25, 2022, 12:48 |
|
#2 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,855
Rep Power: 73 |
Sorry but what about your background in CFD?
This is one of the fundamental topics in any CFD course! Just start considering the analysis in the physical space by adopting the modified differential equation technique. Have a look to the evaluated expression that multiplies the second derivative in space. Then you can also see the same issu in the wavenumber space. That has no need of any code to be seen. In your code I see that you compute a different dt value for different location i and that is wrong! I also suggest to use the conservative form, not the quasi-linear form of the Burgers equation. |
|
August 25, 2022, 13:34 |
|
#3 |
Senior Member
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8 |
Thanks for your help! I'm self-taught, with some gaps in knowledge.
|
|
August 25, 2022, 13:41 |
|
#4 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,855
Rep Power: 73 |
Quote:
Be careful, you need to learn carefully the basics... Your code has the first order upwind with backward formula but you have to consider that the Burgers equation can have initial negative data and your code will not work. PS: I strongly suggest to check what happen using a Heaviside initial condition. Compare the velocity of your shock wave with the theoretical value. |
||
August 25, 2022, 15:07 |
|
#5 |
Senior Member
|
For the linear, pure convection case in 1D with uniform grid, first order upwind and first order explicit Euler (I don't know for other cases) it can be shown analytically that CFL = 1 leads to exactly 0 numerical error (diffusion included) because ALL the spurious terms in the MDE become 0.
Of course, if you think about it, it is as much obvious as useless in real cases. Yet, it tells you something important about numerical convection that lagrangian schemes explicitly try to leverage. |
|
August 25, 2022, 16:03 |
|
#6 | |
Senior Member
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8 |
Quote:
Didn't know that. Thanks! |
||
August 25, 2022, 16:54 |
|
#7 |
Senior Member
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34 |
if you can find this book
https://link.springer.com/book/10.10...-94-007-4038-9 There is a detailed discussion about what you have asked. What you asked is not a simple question. A very very short and crude answer to your question is that at cfl of 0.9 the wave moves somewhere in between the cells and now the face values are not well constructed (for any reason, mostly it is limiting that would do this). Thus you end up with all sorts of issues, this diffusion is one of them. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ANSYS Meshing] MultiZone/multiblock near-wall numerical diffusion | mlazim14 | ANSYS Meshing & Geometry | 0 | April 19, 2020 07:48 |
Numerical error at false diffusion case | jpeter3 | OpenFOAM Running, Solving & CFD | 0 | January 28, 2015 07:18 |
Reducing numerical diffusion in compressibleInterFoam | kd55 | OpenFOAM Verification & Validation | 0 | September 12, 2013 20:34 |
numerical diffusion & patch operation | ronen | FLUENT | 4 | April 10, 2011 18:44 |
How to estimate numerical diffusion ? | Mukhopadhyay | Main CFD Forum | 3 | June 19, 2001 10:35 |