Newbie: CFL criterioncan I violate it to make my code run faster?
Hi everyone:
I'm a chemist, using a code for modeling advectiondiffusion 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. 
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. 
Thanks Martin for taking time to explain. I am calculating a timedependent solution. So if I understand you correctly, my solution would become less accurate if I violated the CFL criterion by increasing my time step.

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. 
Aha! Thank you very much for that explanation. Much appreciated.
I will definitely do the timestep 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! 
Quote:
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... 
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. 
Hi
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 
All times are GMT 4. The time now is 11:33. 