CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

How to do time convergence check?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 26, 2018, 15:01
Default
  #21
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by TurbJet View Post
I didn't get to test Lax-Wendroff. But for the upwind scheme, the convergence order for L_inf is almost zero (with fixed dt); The reason I think is due to the dispersion at these non-smooth regions (highlighted by red circle).

However, lowering dx/dt at the same time (where CFL = 0.9) can give the 1st order convergence in L_inf.

Attachment 65764



You are using a wrong periodic condition! if you see the profile it does not repeat periodically
FMDenaro is offline   Reply With Quote

Old   September 26, 2018, 17:47
Default
  #22
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
You are using a wrong periodic condition! if you see the profile it does not repeat periodically
You are saying using the entire sine wave on the interval, instead of single period of it?
TurbJet is offline   Reply With Quote

Old   September 26, 2018, 17:52
Default
  #23
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by TurbJet View Post
You are saying using the entire sine wave on the interval, instead of single period of it?



If you use periodic BC, the initial signal must be periodic, the function and all derivatives must be the same.
Therefore, given L the lenght of periodicity you can choose a wavenumber k=1,2... and setting the sine at 2*pi*k/L.
FMDenaro is offline   Reply With Quote

Old   September 26, 2018, 18:24
Default
  #24
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
If you use periodic BC, the initial signal must be periodic, the function and all derivatives must be the same.
Therefore, given L the lenght of periodicity you can choose a wavenumber k=1,2... and setting the sine at 2*pi*k/L.
Ok, I fixed the problem. Now it gives 1st order convergence. But how does it relate to my original 4th-order scheme?
TurbJet is offline   Reply With Quote

Old   September 26, 2018, 18:38
Default
  #25
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by TurbJet View Post
Ok, I fixed the problem. Now it gives 1st order convergence. But how does it relate to my original 4th-order scheme?

You create a discontinuity in the derivatives therefore the local truncation error cannot be defined and the accuracy order cannot be estimated.
FMDenaro is offline   Reply With Quote

Old   September 26, 2018, 18:41
Default
  #26
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
You create a discontinuity in the derivatives therefore the local truncation error cannot be defined and the accuracy order cannot be estimated.
Ok, I'll try this sine wave for my original scheme and see if it can give me 4th order convergence. And I'll get back to you.
TurbJet is offline   Reply With Quote

Old   September 27, 2018, 02:34
Default
  #27
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
You are using a wrong periodic condition! if you see the profile it does not repeat periodically
I tried with the new sine wave. It gives me 1st order convergence. I looked into the solution in detail and it makes me feel that my periodic BC has some issues. I attach the schematic for my mesh below (sorry for the poor image quality).

As in the figure below (I use collocated mesh), I have N+1 interior points and the boundary points, 6 ghost points in total (3 on each sides).
As can see, point 4 and N+1 are boundary points, points 1~3 and N+5~N+7 are ghost points. I only evaluate the derivative on the interior points 5 ~ N+3.

As for the periodic BC, I do (assuming f is the original function I am solving)
Code:
f(N+4 : N+7) = f(5 : 8);
f(1 : 4)     = f(N : N+3);
Would you please take a look where it goes wrong? I just can't see it. Thanks a lot!

Screen Shot 2018-09-26 at 10.28.01 PM.jpg
TurbJet is offline   Reply With Quote

Old   September 27, 2018, 03:35
Default
  #28
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Assume that the periodicity lenght L goes from node i=1 at x=0 and i=N at x=L. Ath the boundaries, then you solve the equation only at the node i=1 (or i=N) and set the peridocity prescribing the same value at i=N. Of course you get


f(0)=f(N-1)
f(-1)=f(N-2)
....
f(N+1)=f(2)
f((N+2)=f(3)


the periodicity must work this way. Otherwise the bug is in your 4th order discretization.
FMDenaro is offline   Reply With Quote

Old   September 27, 2018, 03:42
Default
  #29
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
Assume that the periodicity lenght L goes from node i=1 at x=0 and i=N at x=L. Ath the boundaries, then you solve the equation only at the node i=1 (or i=N) and set the peridocity prescribing the same value at i=N. Of course you get


f(0)=f(N-1)
f(-1)=f(N-2)
....
f(N+1)=f(2)
f((N+2)=f(3)


the periodicity must work this way. Otherwise the bug is in your 4th order discretization.
What do you mean by
Quote:
solve the equation only at the node i=1 (or i=N)
My understanding is that I have to determine which way the wave goes: if the wave goes to the right, need to evaluate the derivatives on the right boundary point i=N, then I do
Code:
f(1) = f(N)
if the wave goes to the left, then I need to do
Code:
f(N) = f(1)
Am I correct?
TurbJet is offline   Reply With Quote

Old   September 27, 2018, 04:20
Default
  #30
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by TurbJet View Post
What do you mean by


My understanding is that I have to determine which way the wave goes: if the wave goes to the right, need to evaluate the derivatives on the right boundary point i=N, then I do
Code:
f(1) = f(N)
if the wave goes to the left, then I need to do
Code:
f(N) = f(1)
Am I correct?



No. You need to solve the wave equation into the domain using the upwinding and that depends on the sign of the velocity in deciding the stencil for the derivative.
That has nothing to do with the setting of periodic BC.s that is totally independent from the scheme that is adopted and does not depend on the velocity.


Setting the correct periodicity means that if you solve the equation at i=1 and the velocity is, for example, positive, the derivative is (f(1)-f(0))/dx and the correct setting of the periodiciy make this exactly equal to (f(1)-f(N-1))/dx. Once computed the updated at i=1, just set the update at i=N without solving the equations.
FMDenaro is offline   Reply With Quote

Old   September 27, 2018, 04:34
Thumbs up
  #31
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
No. You need to solve the wave equation into the domain using the upwinding and that depends on the sign of the velocity in deciding the stencil for the derivative.
That has nothing to do with the setting of periodic BC.s that is totally independent from the scheme that is adopted and does not depend on the velocity.


Setting the correct periodicity means that if you solve the equation at i=1 and the velocity is, for example, positive, the derivative is (f(1)-f(0))/dx and the correct setting of the periodiciy make this exactly equal to (f(1)-f(N-1))/dx. Once computed the updated at i=1, just set the update at i=N without solving the equations.
mmm, I see your point. I'll fix it and get back to you. Thanks a lot!
TurbJet is offline   Reply With Quote

Old   September 27, 2018, 18:01
Default
  #32
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
No. You need to solve the wave equation into the domain using the upwinding and that depends on the sign of the velocity in deciding the stencil for the derivative.
That has nothing to do with the setting of periodic BC.s that is totally independent from the scheme that is adopted and does not depend on the velocity.


Setting the correct periodicity means that if you solve the equation at i=1 and the velocity is, for example, positive, the derivative is (f(1)-f(0))/dx and the correct setting of the periodiciy make this exactly equal to (f(1)-f(N-1))/dx. Once computed the updated at i=1, just set the update at i=N without solving the equations.
Finally! I figured out where I went wrong! I forgot to apply BCs after each sub-time step of the RK scheme. Now I have 4th order convergence (with dx and dt lowering at the same time, CFL=1).
And I can get 4th order in space with fixed small time step.

But for the temporal convergence, at the beginning, the error is already somewhere 1E-8 (with fixed small grid size). And getting smaller gives the same magnitude of error, i.e., the order is O(0). How can I fix this?
FMDenaro likes this.
TurbJet is offline   Reply With Quote

Old   September 28, 2018, 01:29
Default
  #33
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
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.
Even though I have a 4th order convergence in space, it still tricky to get the temporal convergence.

I set grid size to a small value to avoid the error swamp the temporal error. However, since dt is bounded by CFL and dx. If set dx small, even with CFL=1, the error is already push to 1E-12. Lowering dt doesn't give a much better result.

If I am getting 4th order convergence with lowering dt dx at the same time, is it safe to assume that my time integral is 4th order as well? Since it's not compromising the total order.
TurbJet is offline   Reply With Quote

Old   September 28, 2018, 03:35
Default
  #34
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by TurbJet View Post
Even though I have a 4th order convergence in space, it still tricky to get the temporal convergence.

I set grid size to a small value to avoid the error swamp the temporal error. However, since dt is bounded by CFL and dx. If set dx small, even with CFL=1, the error is already push to 1E-12. Lowering dt doesn't give a much better result.

If I am getting 4th order convergence with lowering dt dx at the same time, is it safe to assume that my time integral is 4th order as well? Since it's not compromising the total order.



Consistence requires that the LTE vanishes as the time and space steps go to zero therefore you are assessing that there is no bug in the scheme.
Start again the time accuracy check using the one-step error, this way you can use any CFL since there is no stability problem. You should be able to see the error slope.
FMDenaro is offline   Reply With Quote

Old   September 29, 2018, 18:12
Default
  #35
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
Consistence requires that the LTE vanishes as the time and space steps go to zero therefore you are assessing that there is no bug in the scheme.
Start again the time accuracy check using the one-step error, this way you can use any CFL since there is no stability problem. You should be able to see the error slope.
I set (with convective velocity = 1)

CFL = 1000, error_max ~ 1E-4;
CFL = 100, error_max ~ 1E-8;
CFL = 10, error_max ~ 1E-12.

It does has 4th order in time now.

It just feel wired that CFL went to 1000....
TurbJet is offline   Reply With Quote

Old   September 29, 2018, 18:17
Default
  #36
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by TurbJet View Post
I set (with convective velocity = 1)

CFL = 1000, error_max ~ 1E-4;
CFL = 100, error_max ~ 1E-8;
CFL = 10, error_max ~ 1E-12.

It does has 4th order in time now.

It just feel wired that CFL went to 1000....



How about the error going up to CFL=1 ?
FMDenaro is offline   Reply With Quote

Old   September 29, 2018, 18:19
Default
  #37
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
How about the error going up to CFL=1 ?
When CFL = 1, error_max ~1E-16

Is it safe to say that my time integral does have 4th order and it's all good now??
TurbJet is offline   Reply With Quote

Old   September 30, 2018, 03:07
Default
  #38
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
How about the error going up to CFL=1 ?
Another issue, I can't really get 1E-16 for small grid size. The error hanging around 1E-12 ~ 1E-13. Maybe the machine precision already taken over?
TurbJet is offline   Reply With Quote

Old   September 30, 2018, 03:29
Default
  #39
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,896
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Quote:
Originally Posted by TurbJet View Post
Another issue, I can't really get 1E-16 for small grid size. The error hanging around 1E-12 ~ 1E-13. Maybe the machine precision already taken over?



yes, you are at the limit of double precision... It seems ok now the accuracy
FMDenaro is offline   Reply With Quote

Old   September 30, 2018, 03:30
Default
  #40
Senior Member
 
Join Date: Oct 2017
Location: United States
Posts: 233
Blog Entries: 1
Rep Power: 10
TurbJet is on a distinguished road
Quote:
Originally Posted by FMDenaro View Post
yes, you are at the limit of double precision... It seems ok now the accuracy
Great! And thanks very much for all your help. Really appreciate it!
TurbJet is offline   Reply With Quote

Reply

Tags
convergence check, runge kutta method, time accurate


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Extrusion with OpenFoam problem No. Iterations 0 Lord Kelvin OpenFOAM Running, Solving & CFD 8 March 28, 2016 12:08
simpleFoam error - "Floating point exception" mbcx4jc2 OpenFOAM Running, Solving & CFD 12 August 4, 2015 03:20
PimpleFoam: check for convergence within time step Begineer OpenFOAM Running, Solving & CFD 3 April 21, 2014 18:42
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 16:33
critical error during installation of openfoam Fabio88 OpenFOAM Installation 21 June 2, 2010 04:01


All times are GMT -4. The time now is 18:59.