CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   SimpleFoam convergence criterion? (http://www.cfd-online.com/Forums/openfoam-solving/91514-simplefoam-convergence-criterion.html)

phsieh2005 August 13, 2011 09:57

SimpleFoam convergence criterion?
 
Hi,

I am running a simpleFoam case. The print out messages said that, there is no convergence criterion. The case will run for 1000 steps. What is the reason behind it?

Thanks!

Pei

alberto August 14, 2011 23:46

This happens because the convergence criterion is not specified in fvSolution.

If you use OpenFOAM 1.7.x, you need to specify it in the SIMPLE sub-dictionary:

Code:

SIMPLE
{
  nNonOrthogonalCorrectors 0;

  // Residual here (all residuals must go below this)
  convergenceCriterion 1.0e-6;
}

If you use OpenFOAM 2.0.x, the syntax is:

Code:

SIMPLE
{
    nNonOrthogonalCorrectors 0;

    // Residuals here (one per variable)
    // If one variable is not specified, zero is assumed as
    // desired residual (iterations will not stop)
    residualControl
    {
        p              1e-2;
        U              1e-3;
        "(k|epsilon|omega)" 1e-3;
    }
}

I hope this helps.

bigbang August 16, 2011 09:12

Thanks Alberto, this has helped me.

When I run simpleFoam, I now get this:

Code:

Create time

Create mesh for time = 0

Reading field p

Reading field U

Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting RAS turbulence model realizableKE
realizableKECoeffs
{
    Cmu            0.09;
    A0              4;
    C2              1.9;
    sigmak          1;
    sigmaEps        1.2;
}


SIMPLE: convergence criteria
    field p        tolerance 1e-06
    field U        tolerance 1e-06
    field k        tolerance 1e-06
    field epsilon        tolerance 1e-06


Starting time loop

Time = 1


rgarcia September 19, 2011 09:01

Hi all,

I would like to know what exactly happens if you introduce

SIMPLE
{
nNonOrthogonalCorrectors 0;

// Residual here (all residuals must go below this)
convergenceCriterion 1.0e-6;
}

Does the simulation stop when all the variables has a residual lower than 1.0e-6?


Do you know if it's possible to stop the simulation when the residuals are lower of 1.0e-4 for 50 consecutive iterations instead of loooking just one iteration?

Thanks in advance!

Roger

cfddwarf June 20, 2012 16:36

In my Log file it also says:

SIMPLE: no convergence criteria found. Calculations will run for 2000 steps.

In the fvSolution file entry looks as follows:

SIMPLE
{
nNonOrthogonalCorrectors 0;
}

so my question is, whether the solver is now trying to reach zero as the desired residual? Are my simulations still correct??

Thanks for any answer...

alberto June 20, 2012 16:39

Your results will simply have the residuals the solution gives after 2000 iterations. If such a number of iterations is sufficient for your case, the solution will be correct.

You can store the output of the solver in a text file and then examine them using foamLog.

Alternatively, you can specify residuals (see tutorials).

cfddwarf June 20, 2012 16:46

At approximately timestep 500 the no of iterations change to zero.

Time = 572

DILUPBiCG: Solving for Ux, Initial residual = 8.02058e-06, Final residual = 8.02058e-06, No Iterations 0
DILUPBiCG: Solving for Uy, Initial residual = 9.42366e-06, Final residual = 9.42366e-06, No Iterations 0
DILUPBiCG: Solving for Uz, Initial residual = 8.13976e-06, Final residual = 8.13976e-06, No Iterations 0
DICPCG: Solving for p, Initial residual = 1.09339e-05, Final residual = 9.86413e-07, No Iterations 70
time step continuity errors : sum local = 0.000183096, global = -8.98498e-07, cumulative = 0.00553493
ExecutionTime = 5461.38 s ClockTime = 5489 s

Does this mean it converged? How come the other entries in the fvSolution file dont play a role for the convergence criterion? I mean the entries "tolerance" and "reltol"??

p
{
solver PCG;
preconditioner DIC;
tolerance 1e-06;
relTol 0.01;
}

U
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-05;
relTol 0.1;
}

alberto June 20, 2012 16:55

They actually played a role. If you want convergence with a specified residual specify your criteria in fvSolution / SIMPLE

Code:

SIMPLE
{
    nNonOrthogonalCorrectors 0;
    pRefCell        0;
    pRefValue      0;

    residualControl
    {
        p              1e-5;
        U              1e-5;
        // Add other variables here
    }
}


despaired student July 20, 2012 08:26

a recommandable convergence criterium?
 
4 Attachment(s)
Hi,

how do you specify your convergence criteria? I mean how do you know that the residual must be below e.g. 10^-5 to definitely reach convergence? I first was looking at my residuals to not fluctuate any more (ideal case would be a horizontal line but I've never reached that) but the chief-engineer told me that I must reach a convergence criteria of 10^-5 at least. He said that it is a normally used criteria... but why...???
Can you help me with this question???:confused:

Attached are some pictures of my residuals. I would like to read your opinion - does these pictures proof convergence or not?

This is kind of important for my graduating thesis...


Thank you

alberto July 20, 2012 16:48

Hi Soren,

your plot show the solution behaviour is correct, and the solution is converging. However, for a steady-state solution, residuals are usually required to be very small (ideally close to machine precision) to declare the solution is converged.

Also, note that at convergence, residual curves should be flat. In your case their slope is not negligible, indicating that the solution convergence can be further improved.

I usually set convergence criteria to a very small number (1.0e-12), let the simulation run for a good number (depends on the case) of iterations, and then check the residual curves. If residuals reach 1.0e-12 or if they decreased many orders of magnitude and they stopped changing for a certain number of iterations, then I consider the solution converged.

Best,

Naresh yathuru March 3, 2015 06:56

Simple Foam stops before reaching the end iteration
 
Hi can some one help me out.
1. the simple foam stops in the middle with out any error.
tolerance= 1 e^-09
reltol= 1 e^-o9

There is a huge difference between my initial and final residuals. is it ok?
(approx) initial residuals= 2.4 e--4
final residuals= 6.2 e-10

so still the initial residuals are higher than the tolerance but why does the simulation stops? By stop i mean it gets stuck at a itereation and its not proceeding any further. i waited for almost an hour.

can some one help me.

Thank you

Regards,
Naresh

Andrew_Sm March 3, 2015 07:29

Quote:

Originally Posted by Naresh yathuru (Post 534139)
Hi can some one help me out.
1. the simple foam stops in the middle with out any error.
tolerance= 1 e^-09
reltol= 1 e^-o9

There is a huge difference between my initial and final residuals. is it ok?
(approx) initial residuals= 2.4 e--4
final residuals= 6.2 e-10

so still the initial residuals are higher than the tolerance but why does the simulation stops? By stop i mean it gets stuck at a itereation and its not proceeding any further. i waited for almost an hour.

can some one help me.

Thank you

Regards,
Naresh

Running OpenFoam successfully is not everyone's cup of tea

You gave very less information so I suggest you to first refer the "User guide of OF" and try some basic tutorials before jumping on to anything

Advice:
For tutorials refer the following post:

http://www.cfd-online.com/Forums/ope...-chalmers.html

Naresh yathuru March 3, 2015 08:44

Thank Andrew or your quick reply.

I m trying to simulate a room with inlet and outlet and a box inside in simple foam.

This is my FVscheme
ddtSchemes
{
default steadyState;
}

gradSchemes
{
default leastSquares;//Gauss linear
}

divSchemes
{
default none;
div(phi,U) bounded Gauss linearUpwind grad(U); // was bounded Gauss upwind which is first order but linearupwind is second order
div(phi,k) bounded Gauss upwind;
div(phi,epsilon) bounded Gauss upwind;
div(phi,omega) bounded Gauss upwind;
div(phi,R) bounded Gauss upwind;
div(R) Gauss linear;
div(phi,nuTilda) bounded Gauss upwind;
div((nuEff*dev(T(grad(U))))) Gauss linear;
}

laplacianSchemes
{
default Gauss linear corrected;
}

interpolationSchemes
{
default linear;
}

snGradSchemes
{
default corrected;
}

fluxRequired
{
default no;
p ;
}



And this is my FVsolution

solvers
{
p
{
solver GAMG;
tolerance 1e-12;
relTol 1e-12;
smoother GaussSeidel;
nPreSweeps 0;
nPostSweeps 2;
cacheAgglomeration on;
agglomerator faceAreaPair;
nCellsInCoarsestLevel 10;
mergeLevels 1;
}

"(U|k|epsilon|omega|R|nuTilda)"
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-12;
relTol 1e-12;
}
}

SIMPLE
{
nNonOrthogonalCorrectors 0;

/* residualControl
{
p 1e-2;
U 1e-3;
"(k|epsilon|omega)" 1e-3;
}*/ //as of we do not need
}

relaxationFactors
{
fields
{
p 0.7; // Before 0.3 :it means that 30 percentage of the ew value and 70 % of old value weighted to gether foe the next iteration.
} // It helps in stability but takes longer for convergence.
equations
{
U 0.3;
k 0.7;
epsilon 0.7;
omega 0.7;
R 0.7;
nuTilda 0.7;
}
}

1. i ran the simulation for 5000 iterations but with no sucess for convergence.
then i changed the relaxation factor for p and u.
before :
p= 0.3
u=0.7
now:
p= 0.7
u= 0.3

The simulation runs for some 50 iterations and the iteration get stuck at some point and its not going further.

Interesting is that the Initial residuals are lesser than the specified tolerance.
Time = 5517

smoothSolver: Solving for Ux, Initial residual = 0.00026747233, Final residual = 4.3957841e-14, No Iterations 7
smoothSolver: Solving for Uy, Initial residual = 0.00035219196, Final residual = 5.6268315e-14, No Iterations 7
smoothSolver: Solving for Uz, Initial residual = 0.000529688, Final residual = 8.2691583e-14, No Iterations 7
GAMG: Solving for p, Initial residual = 0.0062565687, Final residual = 9.9888366e-13, No Iterations 143
time step continuity errors : sum local = 2.4610067e-14, global = 5.1314876e-17, cumulative = 1.6021426e-16
smoothSolver: Solving for omega, Initial residual = 0.00023592505, Final residual = 7.3934347e-13, No Iterations 17
smoothSolver: Solving for k, Initial residual = 0.0003149381, Final residual = 9.8133224e-13, No Iterations 18
ExecutionTime = 943.83 s ClockTime = 951 s

Time = 5518

smoothSolver: Solving for Ux, Initial residual = 0.00026770097, Final residual = 4.3982852e-14, No Iterations 7
smoothSolver: Solving for Uy, Initial residual = 0.00035250148, Final residual = 5.6302256e-14, No Iterations 7
smoothSolver: Solving for Uz, Initial residual = 0.00053021843, Final residual = 8.2741381e-14, No Iterations 7
GAMG: Solving for p, Initial residual = 0.0062455933, Final residual = 9.9992215e-13, No Iterations 150
time step continuity errors : sum local = 2.4576868e-14, global = 5.0798341e-17, cumulative = 2.110126e-16
smoothSolver: Solving for omega, Initial residual = 0.00023601326, Final residual = 7.3802878e-13, No Iterations 17
smoothSolver: Solving for k, Initial residual = 0.00031391878, Final residual = 9.7660363e-13, No Iterations 18

where would i have possibly gone wrong. Thank you for your help in advance .

Regards,
Naresh


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