|
[Sponsors] |
![]() |
![]() |
#1 |
Senior Member
|
Hi,
I am writing a simple 1D compressible Euler solver. The time integration I use is RK4. Now I am trying to do time-convergence check. But I am not sure about the exact procedure of doing this. Does anyone can help me out? |
|
![]() |
![]() |
![]() |
![]() |
#2 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73 ![]() ![]() ![]() |
Quote:
Not sure about your question. For "time convergence" are you talking about a steady state? |
||
![]() |
![]() |
![]() |
![]() |
#3 | |
Senior Member
|
Quote:
What I am doing now is transport the wave with 1 period of time, and then compare with the initial solution. But I am guessing this is not a valid way to do this. But I can't find another for doing this. Or maybe I can directly verify the convergence order of my RK4 module? |
||
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73 ![]() ![]() ![]() |
So, you have a linear wave equation? You can compare the exact solution at any time as f(x,t)=f(x-ut,0). However, if you want to see the slope of the error curve ONLY for the time accuracy, you have to use a very refined spatial grid to eliminate the effect of the spatial term in the local truncation error.
|
|
![]() |
![]() |
![]() |
![]() |
#5 | |
Senior Member
|
Quote:
The tricky part is, since I only evaluate the interior grid points for spatial derivatives, when I am doing this "transform" x-ut, it's a little bit tricky to find this t, I have to exclude some points. In this case, my time convergence looks terrible. Maybe I'll just transport the wave within the domain? |
||
![]() |
![]() |
![]() |
![]() |
#6 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73 ![]() ![]() ![]() |
Quote:
Well, i think you have some bugs in the code, there is no problem using periodic BC.s. Just consider the periodicity lenght in (x-ut). |
||
![]() |
![]() |
![]() |
![]() |
#7 | |
Senior Member
|
Quote:
Also, I can't have 4th order convergence for my spatial derivative (I use 4th order scheme). I already set time step size small (~ 1E-5), temporal error should not be a problem. Even so, I get resulting convergence order ~O(1) (man this is a disaster !). So I am completely lost. Is there anything else could affect spatial convergence? |
||
![]() |
![]() |
![]() |
![]() |
#8 |
Super Moderator
|
Here is a suggestion. You will fix some grid size h and there is a time step coming from cfl condition, lets say it is dt.
Compute solution using dt, dt/2, dt/4, dt/8 Lets call these solutions u1, u2, u3, u4 Now we expect |u1 - u2| = C(dt)^p |u2 - u3| = C(dt/2)^p etc. So p = log(|u2-u3|/|u1-u2|)/log(2) All solutions u1, u2, u3, u4, ... will have similar spatial errors since they are on same mesh h. So |u1-u2| will cancel that spatial error and you can then measure the time integration error. Please tell us what you find if you try this. |
|
![]() |
![]() |
![]() |
![]() |
#9 | |
Senior Member
|
Quote:
BTW, is there similar way like this to verify my spatial convergence? |
||
![]() |
![]() |
![]() |
![]() |
#10 |
Super Moderator
|
What was the order of your error norm |u1-u2| when you performed time step convergence test ? If it is already close to machine zero, you will not be able to measure the time step convergence rate, since errors are dominated by round off errors.
When you perform spatial convergence test, you have to reduce time step also due to cfl condition. If you get correct rates in this spatial convergence study, then you can take it that both your spatial and time schemes are fine. |
|
![]() |
![]() |
![]() |
![]() |
#11 | |
Senior Member
|
Quote:
UPDATE: it's still not good, p ~ 1. |
||
![]() |
![]() |
![]() |
![]() |
#12 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73 ![]() ![]() ![]() |
I suggest some hints:
1) start using a smooth solution, that is like sin(x) 2) start checking the one-step error, that is compute the slope of the errors only after 1 time step. It must provide the correct accuracy if you have no bug 3) Start the convergence analysis using constant cfl for all the grids post here the error curve you get |
|
![]() |
![]() |
![]() |
![]() |
#13 | |
Senior Member
|
Quote:
However, I am not sure about your 2nd point: here you are talking about testing spatial convergence (with constant time step size and varying grid spacing), am I right? |
||
![]() |
![]() |
![]() |
![]() |
#14 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73 ![]() ![]() ![]() |
Quote:
No. Let me explain better this issue. The first thing to do is to assess that your discretization is consistent, without bugs. Now that means to assess that the local truncation error (LTE) vanishes as dt,h ->0. Using an exact solution, you actually are measuring a norm of the discretization error (DE), not of the LTE. In a one-time analysis, you have O(DE)=dt*O(LTE), hence your LTE is of the order of DE divided by dt. However, immagine the LTE as a function of dt and h. The consistence of the scheme requires you simultaneously make dt and h tending to zero. This can be obtained if you use the same cfl value on all the grids. That is dt and h must be diminished accordingly. If this test will give you the correct error slope then you can check separately the spatial and temporal accuracy. That is, for the temporal accuracy, you can fix a very small value h (you need to "cancel" any effect of the spatial error) and, taking h fixed, you can vary the dt. This is a test at variable cfl. |
||
![]() |
![]() |
![]() |
![]() |
#15 |
Super Moderator
|
There is another issue that some schemes will have larger errors if you use a very small cfl.
For linear advection equation, most schemes give exact solution with cfl=1. If you keep h fixed and reduce dt, then your cfl -> 0 and your errors can actually go up !!! |
|
![]() |
![]() |
![]() |
![]() |
#16 | |
Senior Member
|
Quote:
Ok, I tried with one fixed extreme small time step size dt = 1E-6, and start with grid size of dx = 1E-6 and 1E-7; my convective velocity is exactly 1 and the function I am transporting is ![]() I follow your advice by transporting it with only one time step, so after one time step, the the left point of the function should hit x = 1E-6. Thus I evaluate the value at x = 1E-6 which should be close to sin(0)=0. But what I get from these two grid sizes are 1E-7 and 1E-8, only first order apparently. (I don't want to go to finer grid, the computation cost is way to high for my crapy laptop) I also tried lowering dx and dt simultaneously by setting CFL=1 (hope this will not cause other problem), and I start with the same grid size as above. The results are pretty much the same. Is it possible the error comes from the dispersion error, cause the spatial scheme I use for hyperbolic part is 4th-order central difference. |
||
![]() |
![]() |
![]() |
![]() |
#17 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73 ![]() ![]() ![]() |
Quote:
I suggested the one-step analysis exactly to avoid the onset of any numerical instability issue.After 1 time step you must measure the correct convergence slope, irrespectly of oscillations. Just to assess that you are computing exactly the error norm, try using the simple FTUS scheme (first order in time and space) and then the Lax-Wendroff scheme (second order time and space). If these schemes provide the correct convergence slope you have a bugs in your 4th order discretization. PS: using the constant cfl you can start the analysis also using larger grid size, you should be able to get at least 5-6 values for the error curve. I suggest using the max norm so you can check the location of the max error |
||
![]() |
![]() |
![]() |
![]() |
#18 | |
Senior Member
|
Quote:
(curiously, why CFL=1 has no significant diffusion? I thought upwind scheme is well-known for its diffusivity.) Should I focus only on those region where the wave lies, and excluding those "zeros" regions, when computing the order? I don't have time for trying Lax-Wendroff now. I'll give it a shot tomorrow and I'll come back and update this reply. |
||
![]() |
![]() |
![]() |
![]() |
#19 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,830
Rep Power: 73 ![]() ![]() ![]() |
Quote:
At cfl=1 the FTUS gives the exact solution! You should check the accuracy at cfl<1, only this way you see the effect of the numerical diffusion. Again, to assess that you have no bugs, for any scheme you test, it is required you obtain several values for the error slope. You cannot say nothing only by a couple of points. |
||
![]() |
![]() |
![]() |
![]() |
#20 | |
Senior Member
|
Quote:
However, lowering dx/dt at the same time (where CFL = 0.9) can give the 1st order convergence in L_inf. upwind.jpg |
||
![]() |
![]() |
![]() |
Tags |
convergence check, runge kutta method, time accurate |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Extrusion with OpenFoam problem No. Iterations 0 | Lord Kelvin | OpenFOAM Running, Solving & CFD | 8 | March 28, 2016 11:08 |
simpleFoam error - "Floating point exception" | mbcx4jc2 | OpenFOAM Running, Solving & CFD | 12 | August 4, 2015 02:20 |
PimpleFoam: check for convergence within time step | Begineer | OpenFOAM Running, Solving & CFD | 3 | April 21, 2014 17:42 |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 15:33 |
critical error during installation of openfoam | Fabio88 | OpenFOAM Installation | 21 | June 2, 2010 03:01 |