CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Convergence in OpenFoam (https://www.cfd-online.com/Forums/openfoam-solving/73365-convergence-openfoam.html)

L3munoz March 5, 2010 14:14

Convergence in OpenFoam
 
Hi everybody!

I'm starting using Openfoam and i'd like to know some stuff about convergence criteria. I saw that the simulation ends once it reases the ending time. however i'd like to run it after a convergence criteria such as maximum value of residuals, just like FLUENT does. is it possible in OpenFoam?

and my last question is about simpleFoam? is it just a version of OpenFoam or what? i don't understand very well the difference between them...

Thanks a lot in advance...any help is welcome!!

Lottar.

alberto March 6, 2010 02:14

Quote:

Originally Posted by L3munoz (Post 248757)
Hi everybody!

I'm starting using Openfoam and i'd like to know some stuff about convergence criteria. I saw that the simulation ends once it reases the ending time. however i'd like to run it after a convergence criteria such as maximum value of residuals, just like FLUENT does. is it possible in OpenFoam?

and my last question is about simpleFoam? is it just a version of OpenFoam or what? i don't understand very well the difference between them...

Thanks a lot in advance...any help is welcome!!

Lottar.

Hi,

I answer at your second question first. OpenFOAM(r) is mainly a library that allows CFD applications and tools to be written with a high level syntax. The OF distribution contains many applications, and among these, a good number of CFD solvers, to deal with different problems. simpleFoam is one of them, and it deals with steady, incompressible flows.
You find the description of each solver in the corresponding main .C file.

About convergence criteria, some solver checks for the maximum residual, and simpleFoam is among them.
You can specify the value of the maximum residual at convergence in the fvSolution dictionary of your case, in the SIMPLE subdictionary. Add "convergence 10^-3" to specify, for example, the convercence criterion is a max residual of 10^-3.

Best,

L3munoz March 8, 2010 04:24

Hi Alberto,

thanks a lot for ur reply, it helped me a lot! ;)

mcarpe April 9, 2010 11:34

Hello, everybody....

I'd like some help from the more experienced in CFD and OpenFOAM, because I'm getting a little bit confused about the convergence issue....

In very basic terms, this is what I've understood about convergence and residuals in steady state simulations: since in this case one is only interested in the steady state converged solution, the residuals at a given time (iteration) step is not really important. The important thing is that, after a number of iteration, the residuals are reduced of several orders of magnitude (say, 10^-4). OK, I know that this is neither sufficient nor necessary condition, and other properties must be checked (like integral values of calculated variables, etc...), but as a first approximation I can claim that my simulation is converged. For example, with simpleFoam, I monitor the residuals (the "initial residuals" in the OpenFoam log output, am I right?) of all the variables and when they are all below my termination criterion, I'll have the converged solution.

My question is: how should I proceed for unsteady simulations? For example when using a transient solver, like pisoFoam.
If I've understood correctly, in this case I cannot expect the "initial residuals" to keep decreasing, because the values of my variables change at every time step. In fact this is what I've observed in my RSM simulations with pisoFoam. I was never able to get the p initial residuals below ~1e-03 (and this arises also another question: should I check p or pFinal, in the case of pisoFoam?). So, how can I be confident that my simulation is converged?

Please help... I know, this may be really a silly question... but I am a CFD newbie..
Thank you in advance

Matteo

alberto April 9, 2010 12:15

Quote:

Originally Posted by mcarpe (Post 253967)
Hello, everybody....

I'd like some help from the more experienced in CFD and OpenFOAM, because I'm getting a little bit confused about the convergence issue....

In very basic terms, this is what I've understood about convergence and residuals in steady state simulations: since in this case one is only interested in the steady state converged solution, the residuals at a given time (iteration) step is not really important. The important thing is that, after a number of iteration, the residuals are reduced of several orders of magnitude (say, 10^-4). OK, I know that this is neither sufficient nor necessary condition, and other properties must be checked (like integral values of calculated variables, etc...), but as a first approximation I can claim that my simulation is converged. For example, with simpleFoam, I monitor the residuals (the "initial residuals" in the OpenFoam log output, am I right?) of all the variables and when they are all below my termination criterion, I'll have the converged solution.

Yes, you have to monitor the initial residual. In steady-state simulations it's easy to just fix a very restrictive requirement and check when the residuals stop changing after for a long number of iterations, after they reduced of several order of magnitude. As you said, it would be better to monitor some physical property too.

Quote:

My question is: how should I proceed for unsteady simulations? For example when using a transient solver, like pisoFoam.
If I've understood correctly, in this case I cannot expect the "initial residuals" to keep decreasing, because the values of my variables change at every time step. In fact this is what I've observed in my RSM simulations with pisoFoam. I was never able to get the p initial residuals below ~1e-03 (and this arises also another question: should I check p or pFinal, in the case of pisoFoam?). So, how can I be confident that my simulation is converged?

Please help... I know, this may be really a silly question... but I am a CFD newbie..
Thank you in advance

Matteo
In general, in unsteady simulations you should check that the initial residual of each variable goes below a certain value too.
In the PISO algorithm you simply assume that one solution step + pressure correctors are enough to obtain convergence. Read it as in "you've to use a time step small enough to have convergence".

Best,

mcarpe April 9, 2010 12:48

1 Attachment(s)
Thanks, Alberto, for the very quick reply.

Quote:

Originally Posted by alberto (Post 253972)
In general, in unsteady simulations you should check that the initial residual of each variable goes below a certain value too.
In the PISO algorithm you simply assume that one solution step + pressure correctors are enough to obtain convergence. Read it as in "you've to use a time step small enough to have convergence".

So, you are saying that, if my convergence criteria is 1e-04, I should check that the initial residuals of all the variables are below that limit, even in the case of transient simulation?

For example: in attachment you'll see the residuals plot for one of my simulations with pisoFoam [RSM turbulence, boundary-layer flow over an array of buildings]. As you can see the p value is still high. I tried every solution I could think of, without success. I can only obtain some improvement by reducing the time step, but in order to make the residual lower than 1e-04 I must decrease the time step A LOT.

...I was thinking that, perhaps, because of the unsteadiness, that result wouldn't be too bad, after all....

Matteo

alberto April 9, 2010 13:34

Quote:

Originally Posted by mcarpe (Post 253978)
Thanks, Alberto, for the very quick reply.

So, you are saying that, if my convergence criteria is 1e-04, I should check that the initial residuals of all the variables are below that limit, even in the case of transient simulation?

Yes, in principle this should be verified at each time-step.

Quote:

For example: in attachment you'll see the residuals plot for one of my simulations with pisoFoam [RSM turbulence, boundary-layer flow over an array of buildings]. As you can see the p value is still high. I tried every solution I could think of, without success. I can only obtain some improvement by reducing the time step, but in order to make the residual lower than 1e-04 I must decrease the time step A LOT.
What is your Courant number?

You could use pimpleFoam instead than pisoFoam to be able to perform sub-iterations (outer corrector steps) to ensure convergence and being able to use an acceptable time-step.

Best,

mcarpe April 9, 2010 14:51

Quote:

Originally Posted by alberto (Post 253986)
Yes, in principle this should be verified at each time-step.


What is your Courant number?

You could use pimpleFoam instead than pisoFoam to be able to perform sub-iterations (outer corrector steps) to ensure convergence and being able to use an acceptable time-step.

Best,

Max Co is usually ~0.6; I tried to reduce the time step until I had MaxCo ~0.1, but p initial residuals were still above the threshold, then I stopped trying.

Thank you for the hint. I'll try pimpleFoam and see what happens.

Cheers
Matteo

alberto April 9, 2010 14:56

Usually in unsteady runs the criterion is fixed to 1e-3 in commercial codes. It doesn't mean much, but it gives you an indication of what to expect.

Best,

alexisespinosa December 23, 2010 01:06

Hello Alberto and Matteo,

Your comments are being very useful for me.

Matteo: Were you able to improve your convergence by using pimpleFoam settings?

Alberto: What settings do you use for pimpleFoam? I'm using using 3 nOuterCorrectors (NonLinearity correctors) and 3 nCorrectors (PISO correctors) and 1 nNonOrthogonalCorrectors for transient simulations of incompressible flow around a cylinder. My simulations are 2D so the increase in the calculation time is still manageble. But I'm planning to go 3D soon and I need to optimize my settings but I do not want to loose too much accuracy. Do you always use the 1e-3 residual criteria?

Thanks a lot,
Alexis

alberto December 23, 2010 01:22

Quote:

Originally Posted by alexisespinosa (Post 288226)
Alberto: What settings do you use for pimpleFoam? I'm using using 3 nOuterCorrectors (NonLinearity correctors) and 3 nCorrectors (PISO correctors) and 1 nNonOrthogonalCorrectors for transient simulations of incompressible flow around a cylinder. My simulations are 2D so the increase in the calculation time is still manageble. But I'm planning to go 3D soon and I need to optimize my settings but I do not want to loose too much accuracy. Do you always use the 1e-3 residual criteria?

To answer I would need to know what level of accuracy you need. Do you need a steady state solution, a time resolved solution? Are you doing LES?

Let me give some guideline. Your case is quite simple: single-phase, I assume in operating conditions that are not particularly challenging, simple geometry (you can mesh it well, so if you have convergence difficulties, re-mesh).

Under there assumptions, use the pisoFoam with a sufficiently small Courant number (if you do well resolved simulations in time, or LES you need this anyway), and save your time. You will notice that the convergence is good, and the efficiency improves quite a bit, without loss of accuracy.

Best,

alexisespinosa December 23, 2010 01:43

Thanks Alberto,

My question was in a general sense, but now I understand that criteria is more specific to the application. I have not started yet the intended simulations (hopefully next week). Trying to be more specific: My cases are low Re so I am planning to solve the the 3D flow with a DNS or a LES for Re up to 700 of the flow around a cylinder.

alberto December 23, 2010 01:53

Quote:

Originally Posted by alexisespinosa (Post 288230)
Thanks Alberto,

My question was in a general sense, but now I understand that criteria is more specific to the application. I have not started yet the intended simulations (hopefully next week). Trying to be more specific: My cases are low Re so I am planning to solve the the 3D flow with a DNS or a LES for Re up to 700 of the flow around a cylinder.

Perfect. You can use pisoFoam without any problem, and since your mesh will be probably very good since you do LES and DNS, you probably won't need orthogonal correctors (Check with 3, and look at the initial residual of p. If it decreases quickly, reduce the correctors or disable them). Since you want high quality results, keep Co a bit smaller than usual. I would say Co < 0.5.

Happy holiday!

alexisespinosa December 23, 2010 01:58

Yes, my case is as simple as you described it. So, I understand from your answer that the basic settings of pisoFoam should be enough if I use sufficiently small Co. OK, I will do that.
Anyway, I would like to still ask you the "general" question about your usual settings for pimpleFoam (if there is possibility of generalization) and about your usual criteria of convergence?

alberto December 23, 2010 02:13

Quote:

Originally Posted by alexisespinosa (Post 288233)
Anyway, I would like to still ask you the "general" question about your usual settings for pimpleFoam (if there is possibility of generalization) and about your usual criteria of convergence?

It depends. I usually have at least 0.001 for U, k, epsilon and other secondary variables, but I want a better convergence of p (0.0001 at least), and I check the mass conservation (which should be at machine precision).

You can easily check these things with pyFoam (i.e: pyFoamPlotRunner pisoFoam).

Best,

mcarpe February 10, 2011 09:55

Hi Alexis,

sorry for the long delay, but I haven't been checking this forum lately.

To answer to your question, I wasn't able to get a converged calculation even with pimpleFoam, and it made really little difference. The only way I was able to get convergence was by reducing (...a lot...) the time step. After that, I stopped trying because it took 2 weeks to have suitable results with a sensible averaging time on my 8-core workstation, and it wasn't a viable option for me. So I reduced my expectations and... used k-epsilon model instead.

Cheers
Matteo

Arnoldinho June 23, 2011 05:54

Hi,

I'm using the interFoam solver and OF 1.6-ext for flow (water) in a 3D channel, with fixed U boundary conditions with log profiles.
Looking at the residuals, I ask myself which p residuals I have to monitor. Below is a snippet from the log file:

Quote:

MULES: Solving for alpha1
Liquid phase volume fraction = 0.6249798 Min(alpha1) = -3.903281e-29 Max(alpha1) = 1.0000077
MULES: Solving for alpha1
Liquid phase volume fraction = 0.6249798 Min(alpha1) = -1.8463853e-27 Max(alpha1) = 1.0000158
GAMG: Solving for pd, Initial residual = 0.0031014169, Final residual = 1.847409e-05, No Iterations 3
GAMG: Solving for pd, Initial residual = 7.7653421e-05, Final residual = 8.0713147e-07, No Iterations 3
GAMGPCG: Solving for pd, Initial residual = 3.3507074e-06, Final residual = 5.1273501e-07, No Iterations 1
time step continuity errors : sum local = 2.217054e-08, global = -5.4684563e-10, cumulative = -1.3187716e-07
ExecutionTime = 312.2 s ClockTime = 314 s

Courant Number mean: 0.011130861 max: 0.42974913 velocity magnitude: 1.3537097
deltaT = 0.015873016
Time = 135.63492
I'm using GAMG solver for pd and PCG with GAMG preconditioner for pcorr and pdFinal. In PISO I use three correctors (nCorrectors 3). My questions:

1. Do the three logged GAMG and GAMGPCG residuals stand for pdFinal?
2. The first initial pd residuals never fall below a value of approx. 0.003. The second and third initial residuals (GAMG and GAMGPCG) are always below 1e-5. Which ones do I have to monitor, in order to know if the solution converges?
3. What could be a good convergence value? You said something about 0.0001 for p, and 1e-3 in commercial codes. But for which of the above mentioned values?

Greetings,

Arne

alberto June 23, 2011 11:38

Quote:

Originally Posted by Arnoldinho (Post 313234)
1. Do the three logged GAMG and GAMGPCG residuals stand for pdFinal?

The "Final" option in linear solvers is used only for the last iteration, but you will see "pd" in the log anyway.

Quote:

2. The first initial pd residuals never fall below a value of approx. 0.003. The second and third initial residuals (GAMG and GAMGPCG) are always below 1e-5. Which ones do I have to monitor, in order to know if the solution converges?
You are using a PISO approach, so the residuals don't tell you a lot on the convergence, since there is no loop over the whole set of equations. If you residual value is stable (not increasing), I'd say it's OK.
To be safe, check also the continuity error instead of the residual. If the continuity error is of the order of machine zero, your continuity constraint is satisfied. Check the literature on incompressible solvers on co-located grids about this.

Best,

Arnoldinho June 25, 2011 10:01

Ok, thanks for the explanation alberto.

I'm not sure what exactly machine zero is, but the time step continuity errors are normally in the order of

Quote:

time step continuity errors : sum local = 2.3154534e-11, global = -6.891574e-14, cumulative = 9.3749989e-05
which I think should be ok.

Arne

alberto June 25, 2011 16:21

Machine zero (or machine epsilon http://en.wikipedia.org/wiki/Machine_epsilon ) depends on the machine. As reference, 1.0 x 10^-12 is what I use as reference. Someone uses smaller numbers.

Best,


All times are GMT -4. The time now is 17:40.