|
[Sponsors] |
January 20, 2016, 11:10 |
Order of numerical scheme
|
#1 |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Hey,
I am running a gravity driven flow between two plates in order to test the order of the numerical scheme. Does it matter what initial condition I start with? I guess my question is about how many iterations/time-steps that are needed in order to judge the convergence behavior of a method. If the initial condition is the true solution then it converges to machine precision within one time-step and never changes (the time derivatives are zero for all times, which seems correct). If I use an initial condition far from the true solution then it takes a relatively long time. Right now I set a condition close to the true solution and let it run for approximately 20000 time-steps on both the coarse and fine grid. Is this OK? Second question is about local and global order. Which type is more common to report? Regards |
|
January 20, 2016, 12:20 |
|
#2 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
Quote:
The time required for reaching the steady state depends both on the initial condition and on the physics of the problem (The Re number is an estimation of the order of magnitute of the steady time). I suggest using the measure of the error in a Linf norm. |
||
January 20, 2016, 12:58 |
|
#3 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
If I set the exact value as initial condition then the average L1-norm becomes exactly zero, which seems a bit odd considering machine round-off errors. Anyways, in this case the solution does not change at all with time, so I guess this would constitute a true numerical steady-state. |
||
January 20, 2016, 13:07 |
|
#4 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
Quote:
Starting with the exact solution as initial condition is a sort of "consistence" test and is a good fact you get an unchanged solution with zero time-derivative. However, I think that the Linf norm is better suited because it is also local, can give you indication of where possible errors are greater. |
||
January 21, 2016, 02:53 |
|
#5 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
I use Fortran (with latest gfortran compiler) and have all reals at double precision. |
||
January 21, 2016, 04:28 |
|
#6 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
Quote:
usually, analytical solutions are best suited to check the convergence order... 5-6 grids should be sufficient to reache a monotonic slope in the error curve |
||
January 21, 2016, 05:34 |
|
#7 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
Example (analytical value is 0.03): 17x17 - 0.029999999999997 33x33 - 0.029999999999989 65x65 - 0.029999999999955 If I use the following expression to calculate the order, p=log_2(abs((u_c-u_a)/(u_f-u_a))) where u_c and u_f is the coarse and fine solutions respectively and u_a is the analytical solution, then I get negative orders at around -2... So the solution is getting worse at a second order rate as I refine the grid? |
||
January 21, 2016, 05:39 |
|
#8 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
I strongly suggest:
1) use the time step of the finest grid for all the other grids 2) be careful in using the correct convergence criteria for the iterative solvers 3) for each grid compute the Linf error and then plot the errors versus the grid size in a double logarithmic scale |
|
January 21, 2016, 09:06 |
|
#9 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
1) This was a good suggestion. Now I have the following results 17x17 - 0.029999999999942 33x33 - 0.029999999999944 65x65 - 0.029999999999945 2) Seems OK. Tried lowering the criteria for the iterative solver by 3 orders of magnitude and the result does not change at all. |
||
January 21, 2016, 09:19 |
|
#10 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
Quote:
you have crearly a problem in the code ...check where the max error is located |
||
January 21, 2016, 09:52 |
|
#11 |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Here is a plot of the error, abs(u-u_a). It is only one line of 17 but I think it gives a good indication where errors are largest in the domain. Could you elaborate why there is clearly a problem in the code?
|
|
January 21, 2016, 10:43 |
|
#12 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
what you should plot is the max(err) vs. the size h obtained on each grid
|
|
January 21, 2016, 10:53 |
|
#13 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
Is it common to compare errors that are so close to machine precision? |
||
January 21, 2016, 11:12 |
|
#14 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
Quote:
No, you can see that your error does not scale at all... this is why I wrote you have something wrong in the test you are performing. |
||
January 21, 2016, 14:19 |
|
#15 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
1) Do you think the test case here is viable to find out the order of the method? 2) If not, what method do you suggest? Thanks. |
||
January 22, 2016, 08:50 |
|
#16 |
Senior Member
Michael Prinkey
Join Date: Mar 2009
Location: Pittsburgh PA
Posts: 363
Rep Power: 25 |
The solution to the continuous problem is parabolic in space, right? If your spatial discretization algorithm can perfectly capture quadratic behavior, the "error scaling" is independent of the number of samples. That may be what you are seeing. Consider the "error" associated with linear interpolation across a LINEAR data set. It doesn't matter what two data points you chose, they are all collinear and give the same interpolation results (within round-off) independent of deltaX. Or another way to look at it, what is the Taylor series expansion of F(x) = x^2? Above 2nd order, they are all zero. There are no higher-order terms.
If you want to do error scaling tests, you need to have underlying solution behaviors that will produce H.O.T.s in discretization scheme so that you can measure them. You may just not have that in such a simple case. It would show that your scheme is consistent UP TO quadratic interpolation, but nothing about higher orders. |
|
January 22, 2016, 11:20 |
|
#17 |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
I agree, if the exact solution is just a linear stable temperature profile, then the test is not suitable to be adopted to check the order of accuracy of the scheme. What about the velocity field, is it vanishing or has a constant streamwise value??
|
|
January 22, 2016, 17:16 |
|
#18 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Thank you for your input!
Quote:
I do not solve for temperature at all. I'm not sure I understand the question. I solve for the parabolic velocity profile between two plates (2d incompressible NS). It is constant in the streamwise direction, i.e. the parabolic profile is the same over the length of the domain. |
||
January 22, 2016, 17:45 |
|
#19 | |
Senior Member
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73 |
Quote:
then what do you mean for gravity driven? I was thinking about a buoyancy flow.... hovewer, if you are running the simple Poiseuille test case, then the second derivative of u along the height is not zero and you should be able to check for the convergence of the error curve... are you using Re=1? |
||
January 23, 2016, 04:56 |
|
#20 | |
Senior Member
Join Date: May 2012
Posts: 551
Rep Power: 16 |
Quote:
Re=20 in the above simulations. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to understand high resolution scheme and high order scheme | iilw1314 | Main CFD Forum | 7 | April 12, 2022 13:29 |
Numerical Scheme for a CFD problem | Saturn_V | Main CFD Forum | 8 | September 25, 2013 03:54 |
Solution scheme: 1st, 2nd order, etc in momentum eqs | nottern | Main CFD Forum | 1 | May 11, 2012 01:30 |
Numerical viscosity due to the MUSCL and HLL coulpled scheme | sonsiest | Main CFD Forum | 0 | May 23, 2011 16:37 |
numerical scheme | ado | Main CFD Forum | 3 | October 12, 2000 09:20 |