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/)
-   -   Initial residual and Final residual values do not change (https://www.cfd-online.com/Forums/openfoam-solving/230368-initial-residual-final-residual-values-do-not-change.html)

fluid2020 September 20, 2020 16:44

Initial residual and Final residual values do not change
 
Dear Foamers,


Now I encountered a problem that the Initial residual and Final residual are the same at a single step, but do have a small change at the next time step. The solved fields do not move with the fluid (they stay the same although the velocity do change).


The first step for a variable HE,
Quote:

DILUPBiCG: Solving for HE, Initial residual = 5.795970458e-09, Final residual = 5.795970458e-09, No Iterations 0
The second second:
Quote:

DILUPBiCG: Solving for He, Initial residual = 5.797731883e-09, Final residual = 5.797731883e-09, No Iterations 0

I tried different solvers in fvSolution. It does not help. The fvSolution I used can be found in the attached file.


Does anyone know the issue with this?



Any comment is appreciated.


Thank you!

Wang

fumiya September 20, 2020 22:49

Check your linear solver tolerance
 
As you can see, No Iterations are 0 in your simulation.
This means the initial residual satisfies the (absolute) tolerance you specified in the solvers dictionary(initial residual < tolerance)
and the HE equation is not solved.

If you decrease the tolerance or add the minIter entry to the solvers dictionary,
the HE equation will be solved.
You can find some tutorials where minIter is used.

Hope this helps,
Fumiya

fluid2020 September 21, 2020 08:09

Dear Fumiya,


Thank you very much for your kind reply. I forgot to attach my fvSolution in the last post. Here it is.
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    "(rho|G)"
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance      1e-05;
        relTol          0.1;
    }

  "(rho|G)Final"
    {
        $rho;
        tolerance      1e-05;
        relTol          0;
    }

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

    pFinal
    {
        $p;
        tolerance      1e-06;
        relTol          0;
    }

    U
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance      1e-05;
        relTol          0.1;
    }

    UFinal
    {
        $U;
        tolerance      1e-05;
        relTol          0;
    }

    HE
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance      1e-6;
        relTol          0;
    }

    HEFinal
    {
        $Z;
        tolerance      1e-06;
        relTol          0;
    }
}

PIMPLE
{
    transonic      no;
    momentumPredictor yes;
    nOuterCorrectors  1;
    nCorrectors    2;
    nNonOrthogonalCorrectors 0;
}

//relaxationFactors
//{
//    fields
//    {
//        ".*Final"      1;
//    }
//    equations
//    {
//        ".*Final"      1;
//    }
//}

The changed fvSolution is as follows,
Code:

/*--------------------------------*- C++ -*----------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  2.3.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.org                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version    2.0;
    format      ascii;
    class      dictionary;
    location    "system";
    object      fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

solvers
{
    "(rho|G)"
    {
        solver          PCG;
        preconditioner  DIC;
        tolerance      1e-05;
        relTol          0.1;
    }

  "(rho|G)Final"
    {
        $rho;
        tolerance      1e-05;
        relTol          0;
    }

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

    pFinal
    {
        $p;
        tolerance      1e-06;
        relTol          0;
    }


    U
    {
        solver          smoothSolver;
        smoother        symGaussSeidel;
        tolerance      1e-06;
        relTol          0.1;
    }

    UFinal
    {
        $U;
        tolerance      1e-06;
        relTol          0;
    }
    HE
    {
        solver          PBiCG;
        preconditioner  DILU;
        tolerance      1e-7;
        relTol          0;
        minIter        1;

        //solver          smoothSolver;
        //smoother        symGaussSeidel;
        //tolerance      1e-07;
        //relTol          0.1;
        //minIter        1;
    }

    HEFinal
    {
        $HE;
      tolerance      1e-07;
        relTol          0;
        minIter        1;
    }
}
PIMPLE
{
    transonic      no;
    momentumPredictor yes;
    nOuterCorrectors  1;
    nCorrectors    2;
    nNonOrthogonalCorrectors 0;
}

relaxationFactors
{
    fields
    {
        ".*Final"      1;
    }
    equations
    {
        ".*Final"      1;
    }

}

Now the Final residual is different from the initial one, and the governing equations are actually solved.


Quote:

smoothSolver: Solving for Zvol, Initial residual = 1.474558024e-07, Final residual = 9.989741562e-12, No Iterations 1

I still have two confusions:
  1. Why need I set this value? The simulation just starts, and the solution is converged. It is strange. That means for safety, we need always impose the minInter entry in the fvSolution?
  2. The simulation is unstable (it is a swirled-flow). I decreased the Co number, but the help is little. I also included the relaxationFactors in the fvSolution. I am not sure if the relaxationFactors are correctly set. Could you give some comments here?
Thank you very much. Your blog is also very educative. Thank you!


Best regards,
Wang

Tobi September 21, 2020 08:39

Hi,

actually, you donīt have to set the minIter keyword for your linear solver. If you donīt set it, as Fumiya pointed out, your linear solver does not have to do anything as your initial residual is smaller than the specified tolerance (in your case it is set to 1e-7). Hence, you solve the system Ax = b until the remaining error is smaller than 1e-7. If you reach this limit, your linear solver does not need to make more progress because - again - the set-up tells the solver to stop at 1e-7.

There are two options you can do to let your solver still iterate over your linear system either by setting the already mentioned minIter keyword or reducing your tolerance to a limit of e.g., 1e-12.


To your querstions:
  • There is no need to set the minIter keyword
  • You donīt use relaxation factors as you think you use it

I already had a few posts in which I explain the relaxation factors. The field relaxation you set (a value of 1) will not influence anything. So for the pressure field you should set e.g., 0.8 or a value smaller 1. The equation relaxtion of 1 will make your matrix you are investigating at least diagonal-dominant. So now you should know what it means. To keep it simple, it will increase the diagonal dominance of your matrix to support your linear solvers (they converge better). However, doing so, you make your matrix system more explicit. However, commonly you use values < 1 here too. Only if you know that you just need diagonal-dominance or in other words, if you know that you have non-diagonal dominant entries in your matrix, you can set it to 1. To stabilize you could use the PIMPLE algorithm instead of using PISO. This allows you to use relaxation factors < 1 because running in PISO with *Final < 1 is not consistent with respect to time. Just have a look in the forum. I posted this topic several times. The PIMPLE algorithm is explained in my book and different tutorials can be found on my website.

PS: Are you using OpenFOAM-2.3? I hope you are aware that we are at version 8.

Tobi September 21, 2020 08:41

Quote:

Now the Final residual is different from the initial one, and the governing equations are actually solved.
By the way, as already mention within the last post, your linear system is solved in any case but after you reach the tolerance you specify, the solving process is not done anymore.

fluid2020 September 21, 2020 12:01

Hi Tobi,


Thank you very much for your detailed reply. That really helped me a lot.

For the relationFactor setup, the following could work for a stable simulation, right?


Quote:

relaxationFactors
{
fields
{
".*Final" 1; // Set to e.g., 0.8?
}
equations
{
".*Final" 1;
}
}


Quote:

PIMPLE
{
transonic no;
momentumPredictor yes;
nOuterCorrectors 1;
nCorrectors 2;
nNonOrthogonalCorrectors 0;
}


In my setup, I already used the PIMPLE algorithm, right?



I will check your website soon.


Thank you again for your kind help.


Yes, I am using the old version of OpenFOAM 2.3.1. You are using the new version of OpenFOAM 8.0?

Tobi September 21, 2020 13:35

Hi,


yes I am always using the latest versions of FOAM (ESI + Foundation + extend). I guess I do have around 10 foam versions on my system. However, back to your topic.
  • No you are not using the PIMPLE algorithm (nOuterCorrectors >> 1)
  • For PIMPLE you should use residualControl parameters to leave the PIMPLE loop
  • Relaxation for field will just influence your pressure field. I am not sure which solver you use but commonly there only exist field relaxation for the pressure (in some cases there is also field relaxation implemented but one needs to check the code to be sure that it is implemented)



If you set a field relaxation for p to 0.8, you cannot say that it will be a stable situation. Commonly people under-relax, U, p, k, epsilon, and the energy equation. As already pointed out, for U, k, epsilon, omega, ... h, e we manipulate the matrix rather than the field.

fluid2020 September 21, 2020 14:02

Hello Tobi,


Thank you very much for your guidance. After reading your post at the openfoam wiki page, I set the reactionFactors as follows,
Quote:

fields
{
p 0.3;
pFinal 1;
}
equations
{
"U|Z|C|HE" 0.3;
"(U|Z|C|HE)Final" 1;
}

Unfortunately, the simulation is still very unstable. The velocity can go up to extremely high value,
Quote:

fieldMinMax fieldMinMax1 output:
min(mag(U)) = 0 at position (-0.0005113114186 -0.04687200306 0.1435) on processor 95
max(mag(U)) = 2213.074189 at position (-0.01624506635 0.003771284642 0.03809166376) on processor 71 //- The inlet velocity is just around 20 m/s. The condition is swirled flame in complicated geometry.

I have limited the velocity after the U equation is solved in the flow solver. However, it seems this does not help. The velocity still goes up high, and the resulting time-step is extremely small, which makes it difficult to output the results. The simulation cannot go like this way. Do you have some suggestions on this?


Thank you again for your kind assistance!

Tobi September 21, 2020 14:10

You simply can use fvOption and take the limitVelocity function to limit the maximum value of the velocity. Doing so, you will not just cut the values, it is a smarter way (numerically better).

If you are not using the PIMPLE algorithm, you will not use the smaller relaxation factors for the equations (always requesting the *.Final one). If you don't care about time-consistency, you can simply set all relaxation factors (including final) to 0.5 for example. Some people stated, that they need even less relaxation factors.

fluid2020 September 21, 2020 14:28

Yes, I researched this function (limitVelocity), but it does not exist in the old version of OF. I moved the code from the new version to the old version I am using. But it seems it does not actually make effects.


Thank you very much for your suggestion. I will look at this further.

Tobi September 22, 2020 03:11

I am not sure in which release the fvOptions capabilities was introduced but it was not included in 2.3.1. Hence, you are not able to use it even if you are copy pasting some code ... you need to update the equations but the implementation of fvOPtions is not just copy & pasting some simple stuff. My suggestion is that you move to a newer version.

fluid2020 September 22, 2020 03:19

I am currently testing if the PIMPLE algorithm can help the stability. If the PIMPLE works, I will not artificially limit the velocity. After all, the latter is the last choice for fluid simulation. :(


All times are GMT -4. The time now is 02:12.