CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to choose the right courant number?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree134Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 28, 2009, 14:23
Default How to choose the right courant number?
  #1
New Member
 
Vitor Braga
Join Date: Oct 2009
Posts: 28
Rep Power: 16
vitor is on a distinguished road
How to choose the right Courant number in complexes simulations (3D, with a great number of cells) and what are its implications?


Thanks.
vitor is offline   Reply With Quote

Old   October 29, 2009, 04:50
Default
  #2
Senior Member
 
MadsR's Avatar
 
Mads Reck
Join Date: Aug 2009
Location: Copenhagen, Denmark
Posts: 177
Rep Power: 17
MadsR is on a distinguished road
Hi Vitor.

The Courant/CFL number (wiki here) depends, as you probably know, on velocity, cell-size and time step and is typically calculated for each cell. The Courant number will accordingly change a bit with velocity when you have a static mesh and a constant time step. Now, assuming here that your mesh is static (non-moving/morphing) and that the velocity field is more or less fully developed, changing the time step is a good way of controlling the Courant number.

A physical explanation, for a CFD simulation, of the Courant number could be that it tells you something about how fluid is moving through your computational cells. If the Courant number is <=1 fluid particles move from one cell to another within one time step (at most). If it is >1 a fluid particles moves through two or more cells at each time step and this can affect convergence negatively. Robust systems and fine solvers, as OpenFOAM, easily deals with large Courant numbers way into the houndreds, but it's a good place to look if you have Convergence problems and it also can effect accuracy of a transient simulation. Diffusion dominated problems should typically be run with low Courant numbers, if I remember correctly.

Hope it helps you a bit, I didn't mean to lecture you if you already knew this.

Short answer is: lower time step to lower Courant number, raise time step to increase Courant number.

Cheers
Mads
igo, bioexplore, Paebin and 94 others like this.
__________________
Online free airfoil-mesher for OpenFOAM here
MadsR is offline   Reply With Quote

Old   October 29, 2009, 12:46
Default
  #3
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
For complex simulations with changing velocities it can help to use automatic time step adjustment. See how it's implemented in the interFoam solver (http://www.opencfd.co.uk/openfoam/doc/damBreak.html), or also threads in the forum (e.g. Problems with adjustable timestep control and maxCo Number).
akidess is offline   Reply With Quote

Old   October 30, 2009, 06:23
Default
  #4
New Member
 
Vitor Braga
Join Date: Oct 2009
Posts: 28
Rep Power: 16
vitor is on a distinguished road
Quote:
Originally Posted by akidess View Post
For complex simulations with changing velocities it can help to use automatic time step adjustment. See how it's implemented in the interFoam solver (http://www.opencfd.co.uk/openfoam/doc/damBreak.html), or also threads in the forum (e.g. Problems with adjustable timestep control and maxCo Number).
I've seen it, but do you have any tips for setting the right maxCo?


Thanks;

Vitor
sourav90 likes this.
vitor is offline   Reply With Quote

Old   October 30, 2009, 15:10
Default
  #5
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
Unfortunately I don't think there is a general recipe for that. You will have to play around a little and see what works for you. As Mads already lined out, maxCo will usually have to be smaller than 1, and I think you will rarely have to make it smaller than 0.5.
sourav90 likes this.
akidess is offline   Reply With Quote

Old   April 24, 2010, 21:02
Default
  #6
New Member
 
Vitor Geraldes
Join Date: Dec 2009
Location: Lisbon, Portugal
Posts: 26
Rep Power: 16
vitor.geraldes@ist.utl.pt is on a distinguished road
I think that the best approach is to make different simulations with decreasing values of the time step until the final solution becomes independent of this value. I have already made some simulations where the maximum Courant was of the order of hundreds and, nevertheless, the solution was already converged.
liucheng8602 and sourav90 like this.
vitor.geraldes@ist.utl.pt is offline   Reply With Quote

Old   April 27, 2010, 06:31
Default
  #7
Member
 
Florian Ettner
Join Date: Mar 2009
Location: Munich, Germany
Posts: 41
Rep Power: 17
dohnie is on a distinguished road
Actually, in compressible flow (if you are interested in acoustic waves or shocks) the courant number should not be based on velocity U, but on U+a (sound speed).
Does anybody know if this is implemented in OpenFOAM? Seems to be trickier than I thought at first, because U is a volVectorField and a is a volScalarField (thus it should always be added in the positive U-direction).
dohnie is offline   Reply With Quote

Old   April 28, 2011, 18:48
Default adjustable time step doesn't limit Courant?
  #8
Member
 
Sarah
Join Date: Apr 2011
Location: Eastern US
Posts: 31
Rep Power: 14
SMesser is on a distinguished road
I'm using sonicDyMFoam with a solid object moving through a confined space (a fast gas valve). I'm getting lots of trouble with "max number of iterations exceeded" in the calculation of e and "time step continuity errors". I've tried setting maxCo=0.2 and maxAlphaCo=0.2 in system/controlDict, yet the text output shows the max Courant number is still sometimes 1 or larger... sometimes the mean is >1 as well.

Is this normal? my controlDict is as follows:
Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  1.7.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.com                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     sonicDyMFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.001;

deltaT          1e-7;

writeControl    adjustableRunTime;

writeInterval   1e-6;//2e-5

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression uncompressed;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

adjustTimeStep  yes;

maxCo           0.2;
maxAlphaCo      0.2;

maxDeltaT       1;


// ************************************************************************* //
Thanks

Last edited by SMesser; May 4, 2011 at 14:37.
SMesser is offline   Reply With Quote

Old   April 30, 2011, 09:58
Default
  #9
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
I have this problem too.

I can't use max courant setting for pisoFoam and simpleFoam.

Any suggestion?

Best,
maysmech is offline   Reply With Quote

Old   May 2, 2011, 05:39
Default CFL in steady solvers
  #10
Member
 
Ngoc-Minh Truong
Join Date: Feb 2010
Location: Toulouse, France
Posts: 42
Rep Power: 16
truong_nm is on a distinguished road
Send a message via MSN to truong_nm
Hi maysmech,

There's no CFL Number in such steady solvers. In OF, steady solver means "d/dt=0". Thus, there is no more time step and so no more Courant Number.

I do agree with you: how to control stability in such cases?
The answer is: relaxation factors.

Minh
lil_star, faiazk, vivek05 and 2 others like this.
truong_nm is offline   Reply With Quote

Old   May 2, 2011, 07:23
Default
  #11
Senior Member
 
maysmech's Avatar
 
Join Date: Jan 2010
Posts: 347
Blog Entries: 2
Rep Power: 17
maysmech is on a distinguished road
You right, I meant pisoFoam only. It is an unsteady solver.
maysmech is offline   Reply With Quote

Old   May 4, 2011, 14:35
Default details of crash
  #12
Member
 
Sarah
Join Date: Apr 2011
Location: Eastern US
Posts: 31
Rep Power: 14
SMesser is on a distinguished road
A couple of updates - I tried increasing the spatial and temporal resolution to get y+ to about 63, following the Best-Practices for TurboMachinery page on the CFD Wiki, but the sim crashed _faster_... which seems odd. I'm dealing with a fast-opening gas valve. (40 psi Argon on one side, vacuum on the other; device spatial scales are on the order of 1 cm, and opening time is measured in several tens of microseconds.) I also found a web tutorial with info on revising OpenFoam codes to do adaptive timesteps, but it seemed fairly out-of-date and led to me reinstalling OpenFoam. (I'm missing some library; compilation fails unless I'm in the midst of the install.)

I've learned a couple other things:
1) Strong pressure differences (or maybe just strong gradients?) cause crashiness, but I'm not sure _why_ or if there's a workaround. I changed the "vacuum" to 10 psi to avoid the problem, but the motion of the valve's poppet still generates a near-vacuum for some time. (The mechanical parts move slower than Mach 1, but the gas still has to flow supersonically to fill in the gaps through narrow channels.)

2) non-convergence seems to show up at calculation of either e or T. This makes me think my problem's in the choice of thermodynamic model (currently
Code:
thermoType      ePsiThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>;
), but I'd love feedback from someone with more experience

3) The message from the last timestep is
Code:
Time = 5.68e-06

Courant Number mean: 0.000260452 max: 0.850669
DICPCG:  Solving for cellMotionUx, Initial residual = 1.7015e-07, Final residual = 9.6024e-09, No Iterations 80
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for Ux, Initial residual = 0.641902, Final residual = 4.55875e-06, No Iterations 3
DILUPBiCG:  Solving for Uy, Initial residual = 0.0790439, Final residual = 2.72074e-07, No Iterations 4
DILUPBiCG:  Solving for e, Initial residual = 0.967212, Final residual = 6.18915e-06, No Iterations 2


--> FOAM FATAL ERROR: 
Maximum number of iterations exceeded

    From function specieThermo<thermo>::T(scalar f, scalar T0, scalar (specieThermo<thermo>::*F)(const scalar) const, scalar (specieThermo<thermo>::*dFdT)(const scalar) const) const
    in file /home/opencfd/OpenFOAM/OpenFOAM-1.7.x/src/thermophysicalModels/specie/lnInclude/specieThermoI.H at line 67.

FOAM aborting

#0  Foam::error::printStack(Foam::Ostream&) in "/opt/openfoam171/lib/linuxGccDPOpt/libOpenFOAM.so"
#1  Foam::error::abort() in "/opt/openfoam171/lib/linuxGccDPOpt/libOpenFOAM.so"
#2  Foam::ePsiThermo<Foam::pureMixture<Foam::constTransport<Foam::specieThermo<Foam::hConstThermo<Foam::perfectGas> > > > >::calculate() in "/opt/openfoam171/lib/linuxGccDPOpt/libbasicThermophysicalModels.so"
#3  Foam::ePsiThermo<Foam::pureMixture<Foam::constTransport<Foam::specieThermo<Foam::hConstThermo<Foam::perfectGas> > > > >::correct() in "/opt/openfoam171/lib/linuxGccDPOpt/libbasicThermophysicalModels.so"
#4  
 in "/opt/openfoam171/applications/bin/linuxGccDPOpt/sonicDyMFoam"
#5  __libc_start_main in "/lib/libc.so.6"
#6  
 in "/opt/openfoam171/applications/bin/linuxGccDPOpt/sonicDyMFoam"
I'm not sure how / if I should try to increase the max number of iterations. Would it be better to increase tolerance and/or relTol in fvSchemes? T isn't directly listed there, but most listed items are at tolerance of 10^-5 or 10^-8, with relTol=0. Using relTol seems sketchy since this is a transient sim, not steady-state. Again, it'd be nifty to get feedback from an expert.

Thanks for answering the new-B questions. This isn't my first simulation, but I'm much more used to wiring up hardware than to trying to simulate its operation.
SMesser is offline   Reply With Quote

Old   May 22, 2012, 22:54
Default
  #13
Senior Member
 
Daniel
Join Date: Jul 2009
Location: Montreal, Canada
Posts: 156
Rep Power: 16
dancfd is on a distinguished road
Hello Sarah,

I do not think that adjustTimeStep works for sonicDyMFoam - my experience has shown that regardless of what I set maxCo to, the timestep will revert to what I set in the deltaT field in controlDict. Granted, I am using sonicFoam vice sonicDyMFoam, however they probably have that limitation in common.

I suggest that you may have to try reducing your deltaT until you compute a Co that is where you want it to be. I find ~0.5 to be the maximum that will converge. Please post the results / let me know if you were able to resolve your issue, since I am still struggling with this too.

Regards,

Dan
dancfd is offline   Reply With Quote

Old   January 9, 2013, 15:55
Default
  #14
Senior Member
 
zaynah K.
Join Date: Jun 2012
Location: Mauritius
Posts: 138
Rep Power: 13
zaynah04 is on a distinguished road
dear Mads,

i have very low courant numb 1e-5, and my solution does not acheive convergence.. can you please tell me what may be the problem?
i am using incompresible flow in laminar regime with very low velocity..
thanks
zaynah
zaynah04 is offline   Reply With Quote

Old   January 10, 2013, 04:10
Default
  #15
Senior Member
 
MadsR's Avatar
 
Mads Reck
Join Date: Aug 2009
Location: Copenhagen, Denmark
Posts: 177
Rep Power: 17
MadsR is on a distinguished road
Dear Zaynah,

troubleshooting convergence problems can be easy or very, very hard, especially through a forum
You don't reveal enough information for anyone to help you out I think. I think that a Courant number of 1e-5 is surprisingly low (actually I would bluntly call it: way too low) but it could depend on some strange simulation that you are trying to perform.
Tell us more, but my intuition says that it is not your Courant number which is the problem. It seems that you have tried to lower the time step much to achieve convergence? Is it some explosion simulation or what?

best regards
Mads
zaynah04 and faiazk like this.
__________________
Online free airfoil-mesher for OpenFOAM here
MadsR is offline   Reply With Quote

Old   January 10, 2013, 07:23
Default
  #16
New Member
 
Traib
Join Date: Sep 2012
Posts: 27
Rep Power: 13
Traib is on a distinguished road
Hi Mads,

User zaynah's has found the solution which was I think related to the problem setup as we were discussing in another thread. If you don't mind, I have a question regarding what you said above.

You mentioned relatively lower courant number/time step size required for explosion problems? Or do I understand it differently? I am working on explosions and my simulations sometimes result in very low courant numbers (lower upto 0.01 and time steps upto 1e-15s) when adjustTimeStep is enabled with maxCo typically around 0.2. The problem that I often face is the courant number calculated using the typical velocity, timestep and cell size, which is of order 1e-8s, does not always apply- infact sometimes the time step size required is 10 or higher times than calculated for stable calculations.

I am not sure my explanation is clear enough but any information would be helpful regarding the treatments required in such problems.
rajann_786 likes this.
Traib is offline   Reply With Quote

Old   January 10, 2013, 07:30
Default
  #17
Senior Member
 
zaynah K.
Join Date: Jun 2012
Location: Mauritius
Posts: 138
Rep Power: 13
zaynah04 is on a distinguished road
Hi Mads,
i will come back to you later with this..I am currently stuck somewhere else..

I have successfully iterated around 6 case and achieved convergence...

Suddenly for all the 6 cases i get this same error!!
can anyone tell me what is wrong ?

Quote:
--> FOAM FATAL IO ERROR:
cannot find file

file: /home/zaynah/Desktop/system/controlDict at line 0.

From function regIOobject::readStream()
in file db/regIOobject/regIOobjectRead.C at line 73.

FOAM exiting
zaynah04 is offline   Reply With Quote

Old   January 10, 2013, 11:10
Default
  #18
Senior Member
 
MadsR's Avatar
 
Mads Reck
Join Date: Aug 2009
Location: Copenhagen, Denmark
Posts: 177
Rep Power: 17
MadsR is on a distinguished road
Traib,

I am not sure I understand your question. I don't think explosions, per say, needs low Courant numbers, as it of course also depends on your mesh, but they sure needs low time-steps (relative to more "normal" simulations).
I would expect, being completely ignorant of explosion simulations, however, that you would run at a very low min-Courant number as I would expect that your cells are quite large in certain (most) areas because of the development of an explosion-plume (or what you call it) into the surroundings...I am just guessing here though.

Mads
zaynah04 likes this.
__________________
Online free airfoil-mesher for OpenFOAM here
MadsR is offline   Reply With Quote

Old   January 10, 2013, 11:37
Default
  #19
New Member
 
Traib
Join Date: Sep 2012
Posts: 27
Rep Power: 13
Traib is on a distinguished road
Thanks for your reply Mads. Yes, the cells are of quite varied sizes, larger at regions far from core combustion region. I just realized I was using max time step as the limiting parameter with low courant number calculated using smallest mesh size, instead of using an appropriate courant number to control the time step, which resulted in significantly decreased time step sizes in densely meshed areas where temperature also increase significantly. This strangely enough seems to be the cause of the error and with a limit on courant number time step sizes are adjusted to about the calculated values. I suppose I just had to try this different approach for stable results.
Traib is offline   Reply With Quote

Old   January 10, 2013, 12:35
Default
  #20
Senior Member
 
zaynah K.
Join Date: Jun 2012
Location: Mauritius
Posts: 138
Rep Power: 13
zaynah04 is on a distinguished road
Dear Mads,

lets come back to the low courant number..;-)

My velocity is 0.0001m/s courant is 2.4 e-6.

i am simulating some simple case for comparison with other softwares.. I have to decide which software is best suited for my project.

I have not modify the time step.
Quote:
It seems that you have tried to lower the time step much to achieve convergence?
i will be waiting for your analysis..
Regards
zaynah.

ps: for good convergence what must be display in terminal? i mean for me to know that the solution has converged??

Last edited by zaynah04; January 11, 2013 at 01:53.
zaynah04 is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
[mesh manipulation] Mesh Refinement Luiz Eduardo Bittencourt Sampaio (Sampaio) OpenFOAM Meshing & Mesh Conversion 42 January 8, 2017 13:55
DecomposePar unequal number of shared faces maka OpenFOAM Pre-Processing 6 August 12, 2010 10:01
Unaligned accesses on IA64 andre OpenFOAM 5 June 23, 2008 11:37
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15


All times are GMT -4. The time now is 13:20.