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

Newbie: CFL criterion--can I violate it to make my code run faster?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 27, 2012, 12:14
Default Newbie: CFL criterion--can I violate it to make my code run faster?
  #1
New Member
 
Join Date: Jan 2010
Posts: 28
Rep Power: 16
bzz77 is on a distinguished road
Hi everyone:

I'm a chemist, using a code for modeling advection-diffusion processes. This may be a silly question, so advance apologies!

The code uses explicit time stepping. My problem is that when the time steps obey the CFL criterion, the code takes a very, very long time to run.

I can choose larger time steps. But then I can end up with negative concentrations of chemical components in each cell (I'm using a finite element scheme). If I obey the CFL criterion, I don't end up with negative concentrations.

Here's my question...

I can change the code. So for any timestep, I can restrict myself to transporting only the amount of a chemical component that is in a cell (i.e., I would not allow transport out of a cell of more mass than what exists in a cell). If I do this though, I would be violating the CFL condition.

Would this be OK? Or would my solution be wrong. In other words, does the CFL condition only guard against negative results or does it also ensure that solutions/results are correct?

Thanks a lot for any guidance.
bzz77 is offline   Reply With Quote

Old   January 27, 2012, 13:21
Default
  #2
Senior Member
 
Martin Hegedus
Join Date: Feb 2011
Posts: 500
Rep Power: 19
Martin Hegedus is on a distinguished road
In general, an overall CFL number is used for steady state answers. (CFL can be used for a Newtonian outer loop for implicit methods, but maybe beyond the requirement of this discussion) In this case, if your answer converges the CFL number is good, regardless of what you pick. How you get to the converged answer does not matter. If it does not converge, then the CFL needs to be lowered until the solution converges. However, the choice of CFL will affect your rate of convergence. The lower it is, the lower your rate. But, if you increase it enough to get close to your stability bound, then the rate will also slow down. There is an optimum which lies between zero and your stability bound. When an overall CFL number exists, then each cell will have a different time step.

On the other hand, time accurate is a different story. For time accurate there is a physical time step and that time step applies to all the cells. Then each cell has a different CFL number. In the case of unsteady results, the time step size (or the size of the local CFL number) does affect the accuracy. The larger the time step, the less accurate. As the inaccuracies build, the solution eventually becomes unstable.

So your answer depends on if you are calculating a steady state or time accurate result.
Martin Hegedus is offline   Reply With Quote

Old   January 27, 2012, 13:28
Default
  #3
New Member
 
Join Date: Jan 2010
Posts: 28
Rep Power: 16
bzz77 is on a distinguished road
Thanks Martin for taking time to explain. I am calculating a time-dependent solution. So if I understand you correctly, my solution would become less accurate if I violated the CFL criterion by increasing my time step.
bzz77 is offline   Reply With Quote

Old   January 27, 2012, 13:59
Default
  #4
Senior Member
 
Martin Hegedus
Join Date: Feb 2011
Posts: 500
Rep Power: 19
Martin Hegedus is on a distinguished road
Sorry, the story may be more depressing then that. There are two aspects to the problem, accuracy and stability. Stability is black and white. The code either blows up or it doesn't. The CFL criteria applies to that. However, you may still be inaccurate and stable. What you need to do is get a solution at one time step and then compare that solution to another solution obtained with a lower time step. For example 1/2 the original.

The reason a code goes unstable is that the error has built up enough to cause the code to go unstable. So even if you are stable, you need to determine if the error that does exist is important to you or not.

The fact that you are ending up with negative chemical concentrations means that you are probably not time accurate at that time step value.
Martin Hegedus is offline   Reply With Quote

Old   January 27, 2012, 14:29
Default
  #5
New Member
 
Join Date: Jan 2010
Posts: 28
Rep Power: 16
bzz77 is on a distinguished road
Aha! Thank you very much for that explanation. Much appreciated.

I will definitely do the time-step comparison test you mentioned. But I suspect I will end up having to adhere to the CFL criterion time step. Because even if a solution is OK for one chemical system, it may not be OK for another.

From what you've said, I think I'm going to have to learn to parallelize this code! Sticking to the CFL criterion = very slow calculations!
bzz77 is offline   Reply With Quote

Old   January 27, 2012, 15:48
Default
  #6
Senior Member
 
cfdnewbie
Join Date: Mar 2010
Posts: 557
Rep Power: 20
cfdnewbie is on a distinguished road
Quote:
Originally Posted by bzz77 View Post
Aha! Thank you very much for that explanation. Much appreciated.

I will definitely do the time-step comparison test you mentioned. But I suspect I will end up having to adhere to the CFL criterion time step. Because even if a solution is OK for one chemical system, it may not be OK for another.

From what you've said, I think I'm going to have to learn to parallelize this code! Sticking to the CFL criterion = very slow calculations!

What kind of scheme are you using? FV?
Yes, the physics can really bog down your CFL number, so if the physical time scale is much larger than your numerical one, think about using implicit integration...
the explicit CFL condition is just there to make sure you are not violating the physics, so there's no real playing around with it without violating the important stuff...
cfdnewbie is offline   Reply With Quote

Old   January 27, 2012, 16:16
Default
  #7
Senior Member
 
Martin Hegedus
Join Date: Feb 2011
Posts: 500
Rep Power: 19
Martin Hegedus is on a distinguished road
That will help! (Edit: That=parallelize code)

There is one other trick you can play. Unfortunately I don't exactly know the title for it. It's usually referred to as an implicit solver with sub iterations. Technically it is true, but I never really thought that was a good name for it. To those not familiar with it, the name can be misleading. Also I don't know the ins and outs of this since, in general, I don't do time accurate solutions. Others can maybe help out.

An example of it is equation 1.3 in this document. http://people.nas.nasa.gov/~pulliam/Overflow/Chapter%201.pdf

The idea is that there is a right hand side (RHS) and left hand side (LHS). The right hand side is implicit, i.e. q(n+1) - q(n) + spatial differences at (n+1). The RHS has a physical time step. The LHS just gets you there. You can use explicit (i.e. not matrix), implicit (i.e. matrix), local time stepping and/or multigrid. The LHS does not need to be time accurate since the RHS is. It is exactly like getting a steady state solution, except, instead of the physical dt=infinity, dt is equal to some value. The thing to keep in mind is that there are two time steps. The physical time step on the RHS and a numerical time step on the LHS. As far as I understand, the two are independent. However, if your physical time step is too large, you might not be able to get there, in the same sense that you might not get to a steady state solution.

So in your case you could use an explicit local time stepping approach to get to a time accurate implicit solution. How efficient this is compared to your current approach, I do not know.
Martin Hegedus is offline   Reply With Quote

Old   January 28, 2012, 04:08
Default Hi
  #8
Member
 
Ramesh K
Join Date: Dec 2009
Location: Bangalore
Posts: 73
Rep Power: 16
RameshK is on a distinguished road
Send a message via Yahoo to RameshK
It depends on your scheme stability condition. If the scheme is stable you can to higher CFL without altering your steady state physics. I am not aware of time accurate solutions.

Please correct me if I am wrong

Thank you
RameshK is offline   Reply With Quote

Reply

Tags
cfl condition, cfl number, explicit, finite element method


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
How to make code run in parallel? cwang5 OpenFOAM Programming & Development 1 May 30, 2011 05:47
OpenFOAM 1.7.1 installation problem on OpenSUSE 11.3 flakid OpenFOAM Installation 16 December 28, 2010 09:48
OpenFOAM with IBM AIX matthias OpenFOAM Installation 20 March 25, 2008 03:36
CFL criterion in transient run prabhu CFX 2 July 5, 2007 18:30
Design Integration with CFD? John C. Chien Main CFD Forum 19 May 17, 2001 16:56


All times are GMT -4. The time now is 02:19.