CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   simpleFoam convergance problem (http://www.cfd-online.com/Forums/openfoam-solving/124778-simplefoam-convergance-problem.html)

 Daniel_Khazaei October 12, 2013 17:37

simpleFoam convergance problem

Hello foamers

I am trying to simulate a simple problem which includes a single straight pipe.
The flow is laminar and incompressible (steady state). As for the boundary condition, I am using:

inlet: pressureInlet 1333.2 Pa
outlet: pressureOutlet 0 Pa

I can easily get convergence on fluent in a minute. (residual order 1e-6)

Now when I try the same case in OpenFOAM (same mesh), it gives me a hard time to converge, as I think its going to take even a day to reach convergence tolerance.(simpleFoam solver) here is my case setup in OpenFOAM ( the case is attached):

Boundary condition:

Code:

```/*--------------------------------*- C++ -*----------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          | |  \\    /  O peration    | Version:  1.5-dev                              | |  \\  /    A nd          | Revision: 1736                                  | |    \\/    M anipulation  | Web:      http://www.OpenFOAM.org              | \*---------------------------------------------------------------------------*/ FoamFile {     version    2.0;     format      ascii;     class      volScalarField;     location    "0";     object      p; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions      [0 2 -2 0 0 0 0]; internalField  uniform 0; boundaryField {     FSI     {         type            zeroGradient;     }     OUTLET     {         type            fixedValue;         value          uniform 0;     }     INLET     {         type            fixedValue;         value          uniform 1333.2;     } } // ************************************************************************* //```
Code:

```/*--------------------------------*- C++ -*----------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          | |  \\    /  O peration    | Version:  1.5-dev                              | |  \\  /    A nd          | Revision: 1736                                  | |    \\/    M anipulation  | Web:      http://www.OpenFOAM.org              | \*---------------------------------------------------------------------------*/ FoamFile {     version    2.0;     format      ascii;     class      volVectorField;     location    "0";     object      U; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions      [0 1 -1 0 0 0 0]; internalField  uniform (0 0 0); boundaryField {     FSI     {         type            fixedValue;         value          uniform (0 0 0);     }     OUTLET     {         type            zeroGradient;     }     INLET     {         type            zeroGradient;     } } // ************************************************************************* //```
Schemes:

Code:

```/*---------------------------------------------------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          | |  \\    /  O peration    | Version:  1.3                                  | |  \\  /    A nd          | Web:      http://www.openfoam.org              | |    \\/    M anipulation  |                                                | \*---------------------------------------------------------------------------*/ FoamFile {     version        2.0;     format          ascii;     root            "";     case            "";     instance        "";     local          "";     class          dictionary;     object          fvSchemes; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // ddtSchemes {     default steadyState; } gradSchemes {     default        cellMDLimited Gauss linear 0.5;     grad(p)        cellMDLimited Gauss linear 0.5; } divSchemes {     default        none;     div(phi,U)      Gauss linearUpwindV cellMDLimited Gauss linear 0.5;     div((nuEff*dev(grad(U).T()))) Gauss linear corrected; } laplacianSchemes {     default        Gauss linear limited 0.5; } interpolationSchemes {     default        linear;     interpolate(U)  linear; } snGradSchemes {     default        limited 0.5; } fluxRequired {     default        no;     p; } // ************************************************************************* //```

Am I missing something obvious in OpenFOAM setup?

regards

 Daniel_Khazaei October 13, 2013 13:52

2 Attachment(s)
Residual plots have been attached.

 ARTem October 14, 2013 07:52

Hello, Daniel.
I haven't calculated the right value of friction and corresponding velocity.
But I calculate max velocity restricted by laminar conditions (Re ~2000). So, velocity is about 0.6 m/s. I set this velocity as INLET boundary condition,with p=0 being set up at OUTLET, and I get average pressure at INLET about 0.1324 Pa. Looks similar to your value * 10^-4. May be there is some mistake in physical settings used?

 Daniel_Khazaei October 14, 2013 14:49

Quote:
 Originally Posted by ARTem (Post 456816) Hello, Daniel. I haven't calculated the right value of friction and corresponding velocity. But I calculate max velocity restricted by laminar conditions (Re ~2000). So, velocity is about 0.6 m/s. I set this velocity as INLET boundary condition,with p=0 being set up at OUTLET, and I get average pressure at INLET about 0.1324 Pa. Looks similar to your value * 10^-4. May be there is some mistake in physical settings used?
yes, actually there was a mistake in pressure input. I have used to work with compressible flow solvers where the dimension of p is [1 -1 -2 0 0 0 0].

but in incompressible solvers, its actually p/rho, so I should have used the value of 1.3332 instead of 1333.2

--------------

Now the only problem is that p does not go lower than a specific value (order of 10^-3), while the residual of U is acceptable (10^-8).

However, the result is the same as fluent.

 RodriguezFatz October 15, 2013 04:42

Can you show us the fvSolution-file?

 Daniel_Khazaei October 15, 2013 05:57

Quote:
 Originally Posted by RodriguezFatz (Post 456994) Can you show us the fvSolution-file?
yes, here you are:

Code:

```/*--------------------------------*- C++ -*----------------------------------*\ | =========                |                                                | | \\      /  F ield        | OpenFOAM Extend Project: Open Source CFD        | |  \\    /  O peration    | Version:  1.6-ext                              | |  \\  /    A nd          | Web:      www.extend-project.de                | |    \\/    M anipulation  |                                                | \*---------------------------------------------------------------------------*/ FoamFile {     version    2.0;     format      ascii;     class      dictionary;     object      fvSolution; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // solvers {     p     {         solver          PCG;         preconditioner  DIC;         tolerance        1e-06;         relTol          0.01;     };     U     {         solver          PBiCG;         preconditioner  DILU;         tolerance        1e-05;         relTol          0.1;     }; } SIMPLE {     nNonOrthogonalCorrectors 2; } relaxationFactors {     p              0.3;     U              0.7; } // ************************************************************************* //```
-----------

By the way, is there anyway to use a step function (function of time) as a boundary condition?

 RodriguezFatz October 15, 2013 06:14

Some ideas:
1) In gnuplot use "plot ... using ... every 3 ..." to get an accurate residual plot of your pressure. If you use 2 orthogonal correctors, you have 3 pressure values each iteration. You just want the first one to be plotted. Then, you can also plot all variables (u,p) in the same windows.
2) Are you sure this is the correct syntax for the relaxation factors? I always use:
Code:

```relaxationFactors {     fields     {         "p.*"          0.3;         "nuSgs.*"      0.5;     }     equations     {         "U.*"          0.8;         "k.*"          0.8;         "omega.*"      0.8;     } }```
Having "p" in the "fields" subsection. For simpleFoam the "U.*" syntax isn't needed but for pimpleFoam. Also, this works for simpleFoam, too. So using this syntax it is easier to switch from simple to pimple.

2) Did you try to use a lower "relTol" for the pressure? Maybe you should use GAMG solver for "p" to save some time.

3) What numerical settings (discretization) did you use in Fluent? When I was comparing Fluent and OpenFoam it was always the case, that Fluent converges easily while OpenFoam had problems. Using limiters and bounding schemes at every possible location solved the problems. This lead me to the assumption that Fluent does the same...

 Daniel_Khazaei October 15, 2013 11:55

Quote:
 Originally Posted by RodriguezFatz (Post 457031) Some ideas: 1) In gnuplot use "plot ... using ... every 3 ..." to get an accurate residual plot of your pressure. If you use 2 orthogonal correctors, you have 3 pressure values each iteration. You just want the first one to be plotted. Then, you can also plot all variables (u,p) in the same windows. 2) Are you sure this is the correct syntax for the relaxation factors? I always use: Code: ```relaxationFactors {     fields     {         "p.*"          0.3;         "nuSgs.*"      0.5;     }     equations     {         "U.*"          0.8;         "k.*"          0.8;         "omega.*"      0.8;     } }``` Having "p" in the "fields" subsection. For simpleFoam the "U.*" syntax isn't needed but for pimpleFoam. Also, this works for simpleFoam, too. So using this syntax it is easier to switch from simple to pimple. 2) Did you try to use a lower "relTol" for the pressure? Maybe you should use GAMG solver for "p" to save some time. 3) What numerical settings (discretization) did you use in Fluent? When I was comparing Fluent and OpenFoam it was always the case, that Fluent converges easily while OpenFoam had problems. Using limiters and bounding schemes at every possible location solved the problems. This lead me to the assumption that Fluent does the same...

1) Thanks for the tip man;) now the life is easier:)

2) I think the difference we are seeing here is because of different versions of OpenFOAM ( I am using 1.6-ext)

3) Well GAMG is just faster in my case and does not help the convergence, not yet I will try to apply your suggestion.

3) in fluent: second order for pressure and second order upwind for momentum.

I have already tested cellMDLimited and cellLimited schemes, is there any other schemes that you have tried?

 Daniel_Khazaei October 15, 2013 15:19

1 Attachment(s)
well I have tested several options, but as you can see in the log file, pressure initial residual does change any more, could something be wrong with my mesh?

Code:

```Time = 0.0199 DILUPBiCG:  Solving for Ux, Initial residual = 0.00024647, Final residual = 1.10217e-07, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 0.000111814, Final residual = 1.58072e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 0.000111592, Final residual = 1.57813e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0106645, Final residual = 7.35506e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.010268, Final residual = 7.64759e-05, No Iterations 4 time step continuity errors : sum local = 1.40317e-07, global = 1.63051e-08, cumulative = 0.00461193 ExecutionTime = 39.56 s  ClockTime = 40 s Time = 0.02 DILUPBiCG:  Solving for Ux, Initial residual = 0.000231742, Final residual = 1.03637e-07, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 0.000105065, Final residual = 1.4862e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 0.000104864, Final residual = 1.48377e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0106366, Final residual = 7.3698e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102653, Final residual = 7.64477e-05, No Iterations 4 time step continuity errors : sum local = 1.40306e-07, global = 1.63289e-08, cumulative = 0.00461194 ExecutionTime = 40.2 s  ClockTime = 41 s Time = 0.0201 DILUPBiCG:  Solving for Ux, Initial residual = 0.000217894, Final residual = 9.74417e-08, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 9.87491e-05, Final residual = 1.39652e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 9.85661e-05, Final residual = 1.39436e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0106104, Final residual = 7.38322e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102628, Final residual = 7.64237e-05, No Iterations 4 time step continuity errors : sum local = 1.403e-07, global = 1.63521e-08, cumulative = 0.00461196 ExecutionTime = 40.38 s  ClockTime = 41 s Time = 0.0202 DILUPBiCG:  Solving for Ux, Initial residual = 0.000204872, Final residual = 9.1616e-08, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 9.28788e-05, Final residual = 1.31221e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 9.27076e-05, Final residual = 1.31033e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0105859, Final residual = 7.39572e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102604, Final residual = 7.64029e-05, No Iterations 4 time step continuity errors : sum local = 1.40297e-07, global = 1.63755e-08, cumulative = 0.00461198 ExecutionTime = 40.57 s  ClockTime = 41 s Time = 0.0203 DILUPBiCG:  Solving for Ux, Initial residual = 0.000192629, Final residual = 8.61439e-08, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 8.74158e-05, Final residual = 1.23364e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 8.72505e-05, Final residual = 1.232e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0105629, Final residual = 7.40766e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102582, Final residual = 7.63834e-05, No Iterations 4 time step continuity errors : sum local = 1.40295e-07, global = 1.63987e-08, cumulative = 0.00461199 ExecutionTime = 40.76 s  ClockTime = 41 s Time = 0.0204 DILUPBiCG:  Solving for Ux, Initial residual = 0.000181116, Final residual = 8.10066e-08, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 8.22841e-05, Final residual = 1.16056e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 8.21225e-05, Final residual = 1.15904e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0105413, Final residual = 7.41916e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102561, Final residual = 7.63641e-05, No Iterations 4 time step continuity errors : sum local = 1.40292e-07, global = 1.64205e-08, cumulative = 0.00461201 ExecutionTime = 40.95 s  ClockTime = 41 s Time = 0.0205 DILUPBiCG:  Solving for Ux, Initial residual = 0.00017029, Final residual = 7.61809e-08, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 7.74076e-05, Final residual = 1.09227e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 7.72516e-05, Final residual = 1.09076e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0105211, Final residual = 7.43008e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102542, Final residual = 7.63447e-05, No Iterations 4 time step continuity errors : sum local = 1.40286e-07, global = 1.644e-08, cumulative = 0.00461203 ExecutionTime = 41.14 s  ClockTime = 42 s Time = 0.0206 DILUPBiCG:  Solving for Ux, Initial residual = 0.000160109, Final residual = 7.16425e-08, No Iterations 2 DILUPBiCG:  Solving for Uy, Initial residual = 7.27476e-05, Final residual = 1.02781e-06, No Iterations 1 DILUPBiCG:  Solving for Uz, Initial residual = 7.26005e-05, Final residual = 1.02631e-06, No Iterations 1 GAMG:  Solving for p, Initial residual = 0.0105021, Final residual = 7.44023e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102523, Final residual = 7.63259e-05, No Iterations 4 time step continuity errors : sum local = 1.40279e-07, global = 1.64572e-08, cumulative = 0.00461204 ExecutionTime = 41.33 s  ClockTime = 42 s . . . . . Time = 0.0838 DILUPBiCG:  Solving for Ux, Initial residual = 4.71877e-10, Final residual = 4.71877e-10, No Iterations 0 DILUPBiCG:  Solving for Uy, Initial residual = 1.72695e-10, Final residual = 1.72695e-10, No Iterations 0 DILUPBiCG:  Solving for Uz, Initial residual = 1.72301e-10, Final residual = 1.72301e-10, No Iterations 0 GAMG:  Solving for p, Initial residual = 0.0102061, Final residual = 7.59525e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102235, Final residual = 7.60813e-05, No Iterations 4 time step continuity errors : sum local = 1.40268e-07, global = 1.67351e-08, cumulative = 0.00462262 ExecutionTime = 151.43 s  ClockTime = 153 s Time = 0.0839 DILUPBiCG:  Solving for Ux, Initial residual = 4.64124e-10, Final residual = 4.64124e-10, No Iterations 0 DILUPBiCG:  Solving for Uy, Initial residual = 1.69857e-10, Final residual = 1.69857e-10, No Iterations 0 DILUPBiCG:  Solving for Uz, Initial residual = 1.69469e-10, Final residual = 1.69469e-10, No Iterations 0 GAMG:  Solving for p, Initial residual = 0.0102061, Final residual = 7.59525e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102235, Final residual = 7.60813e-05, No Iterations 4 time step continuity errors : sum local = 1.40268e-07, global = 1.67351e-08, cumulative = 0.00462263 ExecutionTime = 151.61 s  ClockTime = 154 s Time = 0.084 DILUPBiCG:  Solving for Ux, Initial residual = 4.56497e-10, Final residual = 4.56497e-10, No Iterations 0 DILUPBiCG:  Solving for Uy, Initial residual = 1.67066e-10, Final residual = 1.67066e-10, No Iterations 0 DILUPBiCG:  Solving for Uz, Initial residual = 1.66685e-10, Final residual = 1.66685e-10, No Iterations 0 GAMG:  Solving for p, Initial residual = 0.0102061, Final residual = 7.59525e-05, No Iterations 4 GAMG:  Solving for p, Initial residual = 0.0102235, Final residual = 7.60813e-05, No Iterations 4 time step continuity errors : sum local = 1.40268e-07, global = 1.67351e-08, cumulative = 0.00462265 ExecutionTime = 151.77 s  ClockTime = 154 s```

 RodriguezFatz October 16, 2013 04:26

Hey,

The mesh looks really coarse. Can you tell us the diameter of the pipe and the inlet velocity? I read, that for such systems it is better to have a velocity inlet and a pressure outlet - not two pressure b.c. like you have. But this is so simple, it should run as well with two pressure b.c...

Are you sure this is laminar?

 Daniel_Khazaei October 16, 2013 05:08

Quote:
 Originally Posted by RodriguezFatz (Post 457205) Hey, The mesh looks really coarse. Can you tell us the diameter of the pipe and the inlet velocity? I read, that for such systems it is better to have a velocity inlet and a pressure outlet - not two pressure b.c. like you have. But this is so simple, it should run as well with two pressure b.c... Are you sure this is laminar?
Well, here are the details:

1) the diameter of the pipe is 10 mm

2) the length of the tube is 50 mm

3) The pressure at the inlet of the tube is 1333.2 Pa ( I am using p/rho=1.3332 as a inlet pressure )

Now I am using the totalPressure boundary condition for inlet, like fluent.

4) I have 0 Pa pressure at the outlet.

That was the initial mesh, so first I have tried to test it on fluent and when there was no problem, I have decided to test it on OpenFOAM.

I am using these value according to the paper I have.

 RodriguezFatz October 16, 2013 05:12

1) Can you upload the .msh file somewhere?
2) Are you 100% sure you use the same b.c. and viscosity as fluent?

 Daniel_Khazaei October 16, 2013 05:30

Quote:
 Originally Posted by RodriguezFatz (Post 457217) 1) Can you upload the .msh file somewhere? 2) Are you 100% sure you use the same b.c. and viscosity as fluent?

1) here you are: http://www.rodfile.com/w4dsnlx58l1o

2) I am pretty sure, because values of both simulations are almost the same with a little difference in pressure!

fluent: dynamic viscosity = 0.003 and density = 1000

pressure inlet= total Gage pressure = 1333.2 Pa

OpenFOAM: kinematic viscosity = 3e-6

pressure inlet= total pressure = 1.3332 [m^2/s^2] (p/rho)

 RodriguezFatz October 16, 2013 07:44

1 Attachment(s)
Hi,

I use
Code:

```ddtSchemes {     default steadyState; } gradSchemes {     grad(U)        cellMDLimited Gauss linear 1.0;     grad(p)        cellLimited Gauss linear 1.0; } divSchemes {     default        none;     div(phi,U)      bounded Gauss linearUpwind grad(U);     div((nuEff*dev(T(grad(U))))) Gauss linear; } laplacianSchemes {     default        Gauss linear corrected; } interpolationSchemes {     default        linear; } snGradSchemes {     default        none; } fluxRequired {     default        no;     p; }```
It seems to converge pretty slow, but it does.
Attachment 26109

 Daniel_Khazaei October 16, 2013 08:22

It seems that, I can not use "bounded Gauss linearUpwind grad(U)" scheme in 1.6-ext, I get the following error:

Code:

```unknown convection scheme bounded Valid convection schemes are : 3 ( explicit Gauss off )```

 RodriguezFatz October 16, 2013 08:23

Ok, try without it?

 Daniel_Khazaei October 16, 2013 08:40

Quote:
 Originally Posted by RodriguezFatz (Post 457267) Ok, try without it? Why don't you install the most recent version?
yes, I have tried without that scheme:

Gauss linearUpwindV cellMDLimited Gauss linear 1.0;

But As I can see in your residual plot, the pressure residual drops much faster than others, but I am still on the order of 10^-3 after 2000 iteration.

can you upload the case you have used?

regards

---------

I am trying to simulate a Fluid-solid interaction and that solver is available in OpenFOAM-1.6-ext.
At first I am trying to make sure that everything is OK with Fluid solver.

 RodriguezFatz October 16, 2013 08:59

1 Attachment(s)
Here it is
Attachment 26112

 Daniel_Khazaei October 16, 2013 09:06

Quote:
 Originally Posted by RodriguezFatz (Post 457275) Here it is Attachment 26112
Meanwhile I have setup my case on 22x version and the solution has converged in less than 200 iterations. :confused:
I have also changed U solver to smoothSolver.

results are similar to fluent.