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

Initial residual and Final residual values do not change

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By fumiya
  • 1 Post By Tobi

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 20, 2020, 16:44
Default Initial residual and Final residual values do not change
  #1
New Member
 
Join Date: Sep 2020
Posts: 11
Rep Power: 5
fluid2020 is on a distinguished road
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
fluid2020 is offline   Reply With Quote

Old   September 20, 2020, 22:49
Default Check your linear solver tolerance
  #2
Senior Member
 
fumiya's Avatar
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 266
Blog Entries: 1
Rep Power: 18
fumiya is on a distinguished road
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 likes this.
__________________
[Personal]
fumiya is offline   Reply With Quote

Old   September 21, 2020, 08:09
Default
  #3
New Member
 
Join Date: Sep 2020
Posts: 11
Rep Power: 5
fluid2020 is on a distinguished road
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
fluid2020 is offline   Reply With Quote

Old   September 21, 2020, 08:39
Default
  #4
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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.
fluid2020 likes this.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 21, 2020, 08:41
Default
  #5
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 21, 2020, 12:01
Default
  #6
New Member
 
Join Date: Sep 2020
Posts: 11
Rep Power: 5
fluid2020 is on a distinguished road
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?

Last edited by fluid2020; September 21, 2020 at 12:05. Reason: add information
fluid2020 is offline   Reply With Quote

Old   September 21, 2020, 13:35
Default
  #7
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 21, 2020, 14:02
Default
  #8
New Member
 
Join Date: Sep 2020
Posts: 11
Rep Power: 5
fluid2020 is on a distinguished road
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!
fluid2020 is offline   Reply With Quote

Old   September 21, 2020, 14:10
Default
  #9
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 21, 2020, 14:28
Default
  #10
New Member
 
Join Date: Sep 2020
Posts: 11
Rep Power: 5
fluid2020 is on a distinguished road
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.
fluid2020 is offline   Reply With Quote

Old   September 22, 2020, 03:11
Default
  #11
Super Moderator
 
Tobi's Avatar
 
Tobias Holzmann
Join Date: Oct 2010
Location: Tussenhausen
Posts: 2,708
Blog Entries: 6
Rep Power: 51
Tobi has a spectacular aura aboutTobi has a spectacular aura aboutTobi has a spectacular aura about
Send a message via ICQ to Tobi Send a message via Skype™ to Tobi
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.
__________________
Keep foaming,
Tobias Holzmann
Tobi is offline   Reply With Quote

Old   September 22, 2020, 03:19
Default
  #12
New Member
 
Join Date: Sep 2020
Posts: 11
Rep Power: 5
fluid2020 is on a distinguished road
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.
fluid2020 is offline   Reply With Quote

Reply


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
laplacianFoam with source term Herwig OpenFOAM Running, Solving & CFD 17 November 19, 2019 13:47
Segmentation fault when using reactingFOAM for Fluids Tommy Floessner OpenFOAM Running, Solving & CFD 4 April 22, 2018 12:30
chtMultiRegionSimpleFoam turbulent case Aditya Patil OpenFOAM Running, Solving & CFD 6 April 24, 2017 22:13
simpleFoam error - "Floating point exception" mbcx4jc2 OpenFOAM Running, Solving & CFD 12 August 4, 2015 02:20
calculation stops after few time steps sivakumar OpenFOAM Running, Solving & CFD 7 March 17, 2013 06:37


All times are GMT -4. The time now is 07:56.