CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Smaller time step results in less accuracy!! (https://www.cfd-online.com/Forums/main/116864-smaller-time-step-results-less-accuracy.html)

farshadn12 April 26, 2013 12:02

Smaller time step results in less accuracy!!
 
Hi guys,

I'm writing a code in Fortran that solves a 2D Taylor-Green vortex problem. I'm implementing RK3 with central differences discretization in space and periodic boundary conditions everywhere. I plot the results and they look good. I also compare the results against the analytical solution and they seem close enough. But there are two issues:

1- The order of accuracy in space is 2.4!!!! (Theoretically it is be 2, so in reality it should be less.)

2-Smaller time steps result in less accuracy.

To check my code, I ran a Lid-driven cavity problem and all looks fine. I'm comparing streamlines against those in published journal articles.

Does anyone have any idea what might be wrong? My first thoughts went to boundary and initial conditions but I've checked them both and they seem to be fine.

FMDenaro April 26, 2013 12:26

Quote:

Originally Posted by farshadn12 (Post 423381)
Hi guys,

I'm writing a code in Fortran that solves a 2D Taylor-Green vortex problem. I'm implementing RK3 with central differences discretization in space and periodic boundary conditions everywhere. I plot the results and they look good. I also compare the results against the analytical solution and they seem close enough. But there are two issues:

1- The order of accuracy in space is 2.4!!!! (Theoretically it is be 2, so in reality it should be less.)

2-Smaller time steps result in less accuracy.

To check my code, I ran a Lid-driven cavity problem and all looks fine. I'm comparing streamlines against those in published journal articles.

Does anyone have any idea what might be wrong? My first thoughts went to boundary and initial conditions but I've checked them both and they seem to be fine.

Hi,
first, could you give these details?

1) what about the formulation you use, is it a projection method?
2) how do you perform the accuracy analysis, do you take dt/h constant (and in the stability region) and check for the error in some norm? what about the chosen norm?
3) Are you performing the the test on the analytical Taylor solution as in http://www.sciencedirect.com/science...21999185901482 ?
4) when you say that for smaller dt the solution is less accurate, do you see a deviation in the slope of the error convergence? Did you take h fixed?

farshadn12 April 26, 2013 14:21

Yes I use a projection method, Runge Kutta 3rd order. Fully explicit.

Domain size is: 0 < x,y < 2*pi

Uniform grid 32x32

dt is constant. I run the case for dt = 0.001 and 0.0001 sec

Flow time is 2sec.

As for the error analysis, I subtract the analytical and numerical values od say x-velocity and consider the largest error. I don't normalize. The analytical solutions are provided by the professor whose homework assignment this is, so I'm fairly sure they are correct:

u = -e^(-2*t) * cos(x) * sin (y)

v = e^(-2*t) * sin(x) * cos(y)

FMDenaro April 26, 2013 14:35

Quote:

Originally Posted by farshadn12 (Post 423395)
Yes I use a projection method, Runge Kutta 3rd order. Fully explicit.

Domain size is: 0 < x,y < 2*pi

Uniform grid 32x32

dt is constant. I run the case for dt = 0.001 and 0.0001 sec

Flow time is 2sec.

As for the error analysis, I subtract the analytical and numerical values od say x-velocity and consider the largest error. I don't normalize. The analytical solutions are provided by the professor whose homework assignment this is, so I'm fairly sure they are correct:

u = -e^(-2*t) * cos(x) * sin (y)

v = e^(-2*t) * sin(x) * cos(y)


Ok, follow these steps:

1) fix a uniform 128 x 128 grid
2) compute the maximum error for dt=0.1, 0.05, 0.01, 0.05, 0.001
3) plot the error versus the dt in a double logarithmic scale.
4) repeat the same procedure but now fixing a uniform 628 x 628 grid, you should see that the error slope is more extended than before. That depends on the local truncation error fixed by the spatial mesh measure.
5) Finally, perform the error analysis on a 32, 64, 128, 256, 628 mesh but by taking constant dt/h

RodriguezFatz April 29, 2013 07:42

If I may add something: it would be really nice, to post all these pictures here in the forum!

FMDenaro April 30, 2013 03:27

Quote:

Originally Posted by RodriguezFatz (Post 423839)
If I may add something: it would be really nice, to post all these pictures here in the forum!

I analyzed these problems in some papers published some years ago on IJNMF. You can find many figures about the accuracy analysis ;)

RodriguezFatz April 30, 2013 04:02

Thank you for the direction!
I found this:
http://onlinelibrary.wiley.com/doi/1...d.520/abstract
Any more?

FMDenaro April 30, 2013 04:16

Quote:

Originally Posted by RodriguezFatz (Post 424091)
Thank you for the direction!
I found this:
http://onlinelibrary.wiley.com/doi/1...d.520/abstract
Any more?

yes, this one can be complementary

http://onlinelibrary.wiley.com/doi/1...d.598/abstract

farshadn12 May 3, 2013 09:54

So I was able to fix the problem and now the spatial accuracy is second order. the temporal accuracy however is practically constant. It's zero order.

cfdnewbie May 3, 2013 14:46

How do you determine the temporal order? The usual way to do it is to choose the spatial discretization so fine that the spatial error is essentially zero, and then check the time order.

farshadn12 May 3, 2013 15:09

Quote:

Originally Posted by cfdnewbie (Post 425069)
How do you determine the temporal order? The usual way to do it is to choose the spatial discretization so fine that the spatial error is essentially zero, and then check the time order.

That's exactly what I wasn't doing. Everything is fine now. Thanks for your response.


All times are GMT -4. The time now is 14:07.