|
[Sponsors] |
how to check when the residual is smaller than the prescribed tolerance while solving |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 9, 2017, 04:04 |
how to check when the residual is smaller than the prescribed tolerance while solving
|
#1 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Dear,
I have set the tolerance for U and p separately, and how can I realize automatically that the simulation will stop once the residuals for both U and p are smaller than the corresponding predefined tolerance? Thank you for any help. Best Regards, Bill Last edited by 6863523; January 22, 2017 at 11:18. Reason: delete sth unrelated |
|
January 9, 2017, 18:47 |
|
#2 |
Senior Member
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12 |
Bill,
I don't know which solver your are using, but consider the SIMPLE for example. Look at the source code of Foam::simpleControl::criteriaSatisfied(). I understand from it that the convergence is achieved just when the residuals of all fields are less then the values that were set for each one. That is, it is doing already what you wanted it to do. Best regards, Thomas |
|
January 11, 2017, 02:23 |
steady flow
|
#3 | |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Quote:
Thanks for the answer. I compiled a new solver, a similar one to icoFoam. I agree with you that the solution is converged if the residuals are less than the prescribed tolerances. I am confused while I am reading one paper, " From steady to unsteady laminar flow in model porous structures: an investigation of the first Hopf bifurcation", the part talking about the residual and the tolerance is attached. Because it seems that the author used the relation between them to judge whether the flow is steady or not at a certain Re. I am confused whether the criteria for the convergence could be used to determine the flow is steady or not. Thank you. Best Regards, Bill |
||
January 12, 2017, 03:43 |
tolerance and convergence in fvSolution
|
#4 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Hi,
I have set the tolerance for p and U separately in fvSolution file, as shown below. Code:
solvers { p { solver PCG; preconditioner DIC; tolerance 1e-07; relTol 0; } U { solver PBiCG; preconditioner DILU; tolerance 1e-10; relTol 0; } } PISO { nCorrectors 2; nNonOrthogonalCorrectors 0; pRefCell 0; pRefValue 0; } The related part about the convergence in the post is also screenshotted and attached. I want to set the convergence separately for p and U. How can I realize this in the fvSolution file? I just add the convergence in the PISO content? If so, how can I add different values for p and U? Thank you in advance. Best Regards, Bill |
|
January 12, 2017, 05:15 |
|
#5 |
Member
jey
Join Date: Nov 2016
Location: Greece
Posts: 30
Rep Power: 9 |
Dear Bill
Please correct me If I haven't understood correctly but what you are trying to do is setting residuals controls separately for pressure and velocity. You can do this by simply including the following code in the fvSolution file Code:
PISO { nCorrectors 2; nNonOrthogonalCorrectors 0; pRefCell 0; pRefValue 0; residualControl { p 1e-5; U 1e-3; } } Kind regards! |
|
January 12, 2017, 10:20 |
|
#6 | |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Quote:
Thank you for your reply. Yes! This is the first step I want to do. (To stop the simulation as long as the residuals are smaller than the tolerance.) Code:
PISO { nCorrectors 2; nNonOrthogonalCorrectors 0; pRefCell 0; pRefValue 0; convergence { p 1e-5; U 1e-3; } } I am wondering about the second step if it is possible to check the flow is steady according to the convergence criteria. Thank you. Best Regards, Bill |
||
January 12, 2017, 15:43 |
|
#7 |
Member
jey
Join Date: Nov 2016
Location: Greece
Posts: 30
Rep Power: 9 |
Dear Bill
I've been using residualControls with SIMPLE algorithm which is for steady-state simulations. Probably there must be a problem with this function when turning to transient solvers like PISO. Maybe a more experienced user can tell us why this happens. Could you please post the error message that was produced when you tried it, just to gain further insight in OF functionality ? Which OF version are you using? Regarding your second question, the author states that since the user prescribes the tolerances, is up to the user to set the threshold of the, lets say, "steadiness" of the flow. So in our case, we state that when pressure residual reaches below 1e-5 and velocity residual reaches below 1e-3, the simulation has converged. The tolerances here are the 1e-5 and the 1e-3. However, I think that wether a flow is steady or unsteady has nothing to do with that. I found this article explaining steady and unsteady flow. I hope I helped Please correct me if I am wrong! Kind regards |
|
January 13, 2017, 02:04 |
error while using the residualControl
|
#8 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Dear jeytsav,
The error while I am using the residualControl is like bellow. Code:
/*---------------------------------------------------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 3.0.1 | | \\ / A nd | Web: [IMG]file:///C:\Users\wyb\AppData\Local\Temp\%W@GJ$ACOF(TYDYECOKVDYB.png[/IMG]www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ Build : 3.0.1-d8a290b55d28 Exec : myIcoFoam Date : Jan 13 2017 Time : 07:57:05 Host : "srv-calmipo01" PID : 93231 Case : /home/LEPT/ywang/OpenFOAM/ywang-3.0.1/run/UCUCUC/Re17500 nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Allowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time Create mesh for time = 0 --> FOAM FATAL ERROR: Residual data for p must be specified as a dictionary From function bool Foam::solutionControl::read() in file cfdTools/general/solutionControl/solutionControl/solutionControl.C at line 84. FOAM exiting Thank you for the article. It is very kind of you to help me. I have read through the website, but did not find a clue on how to determine at which Re the flow will lose stability while using the transient solver. The unsteadiness is related to the vortex shedding / oscillating streamlines, it is easy to observe these phenomena in a simple situation, like flow past a cylinder, at the same time, the lift coefficient or the component of velocity may be monitored to check the oscillating values with time, as attached, and also a related spectral analysis may be done. Q2: But can these indications be just used to determine if the flow is steady or used only as auxiliaries? I am confused and need help on this. Thank you. Best Regards, Bill Last edited by 6863523; January 13, 2017 at 02:41. Reason: not enough |
|
January 15, 2017, 04:37 |
simulations will not stop using convergence
|
#9 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Dear jeytsav,
I added the lines in fvSolution, using Code:
convergence {p 1e-7; U 1e-10; } Code:
Time = 20000.0000000443724 Courant Number mean: 0.125065 max: 0.342207 DILUPBiCG: Solving for Ux, Initial residual = 2.61563e-13, Final residual = 2.61563e-13, No Iterations 0 DILUPBiCG: Solving for Uy, Initial residual = 1.16709e-11, Final residual = 1.16709e-11, No Iterations 0 DICPCG: Solving for p, Initial residual = 6.32159e-08, Final residual = 6.32159e-08, No Iterations 0 time step continuity errors : sum local = 7.58537e-14, global = -2.38405e-20, cumulative = -1.58064e-15 DICPCG: Solving for p, Initial residual = 7.26257e-08, Final residual = 7.26257e-08, No Iterations 0 time step continuity errors : sum local = 8.71431e-14, global = -3.72906e-20, cumulative = -1.58068e-15 ExecutionTime = 170121 s ClockTime = 170322 s End Thank you. Best Regards, Bill Last edited by 6863523; January 15, 2017 at 08:22. |
|
January 15, 2017, 05:31 |
|
#10 |
Member
jey
Join Date: Nov 2016
Location: Greece
Posts: 30
Rep Power: 9 |
Dear Bill
Regarding the residual control I have found this thread that might solve the problem. Check the last post (post #7). My approach to the problem would be to first solve as a steady-state case and then check whether the results agree (i.e. no oscillations) and if not, switch to a transient solver to have a better capture. I think that the oscillation of force coefficients is a clear indication of unsteady flow as the field changes around the body with time. Actually I am not sure whether is correct to use the word "time" when talking about steady-state because it is time-independent. Maybe the word "pseudotime" is better. Also note, that a flow might be unsteady in the beginning (so you will have oscillations) but then oscillations could be damped indicating a steady flow. Kind regards |
|
January 15, 2017, 08:50 |
results checked
|
#11 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Dear jeytsav,
Thank you very much for your quick help. I have checked the results of the transient simulations. There is no oscillating streamlines, the same as for the steady solution. In addition, I have monitored the component of velocity, and there is no peridic oscillation. Also, I have transformed the velocity component using FFT, and found there is only a signal at f=0. Based on the above analysis, I assumed that the flow is still at steady for the Re range I have tested. BTW: I have modified the fvSolution file according to the thread you recommended. I am testing and will post the results here. It is really very kidn of you to help me so much. Thank you. Best Wishes, Bill |
|
January 18, 2017, 12:57 |
|
#12 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Regarding your problem with the residual control: Which solver are you using? A solver based on PISO or on PIMPLE? If your solver is based on PIMPLE (e. g. pimpleFoam) you have to add something like the following to the PIMPLE section within system/fvSolution
Code:
PIMPLE { // here are your other settings like nOuterCorrectors etc. residualControl { "(U.*)" // should also work for 2D problems { relTol 0; tolerance 1e-4; } p { relTol 0; tolerance 1e-4; } } } |
|
January 18, 2017, 13:11 |
|
#13 | |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Quote:
Thanks for your reply and the detailed information. I am using icoFoam, based on PISO. But I would like to modify the fvSolution file according to your suggestions. Code:
PISO { nCorrectors 2; nNonOrthogonalCorrectors 0; pRefCell 0; pRefValue 0; residualControl { p { relTol 0; tolerance 1e-07; } U { relTol 0; tolerance 1e-10; } } } I have posted the problem here and wonder if you have experience in running parallel. How to use parallel running to the most? Thank you in advance. Best Regards, Bill |
||
January 19, 2017, 05:38 |
|
#14 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Are you sure, that you need such tight tolerance levels? Normal values seems to be in the range of 1e-4.
|
|
January 19, 2017, 10:22 |
|
#15 | |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Quote:
And these values are the same ones for the solver as in post #4. Thanks. Regards, Bill |
||
January 20, 2017, 03:03 |
residualControl not work
|
#16 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Dear,
To update, I have run the case with the residualControl mentioned above, but it seems that it does not work al all. The simulation only ends according to the endTime in the controlDict file. Thank you in advance for any suggestions. Best Regards, Bill |
|
January 20, 2017, 18:57 |
|
#17 |
Senior Member
Joachim Herb
Join Date: Sep 2010
Posts: 650
Rep Power: 21 |
Your solver solves for the fields Ux and Uy, so these names must appear in the PISO section of fvSolution. Otherwise these two fields are not checked, if they have converged. Please use the code from my first comment: how to check when the residual is smaller than the prescribed tolerance while solving
|
|
January 21, 2017, 14:53 |
residualControl still not work
|
#18 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Dear jeytsav,
I have modified the fvSolution file according to your suggestions. But it still does not work. The simulation only ends at the endTime, the residualControl function still does not work. The fvSolution file is like this: Code:
FoamFile { version 2.0; format ascii; class dictionary; location "system"; object fvSolution; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // solvers { p { solver PCG; preconditioner DIC; tolerance 1e-07; relTol 0; } U { solver PBiCG; preconditioner DILU; tolerance 1e-10; relTol 0; } } PISO { nCorrectors 2; nNonOrthogonalCorrectors 0; pRefCell 0; pRefValue 0; residualControl { p { relTol 0; tolerance 1e-07; } "(U.*)" { relTol 0; tolerance 1e-10; } } } I have no clue to do what for the next step... Yours sincerely, Bill |
|
January 22, 2017, 11:03 |
residualControl for pimpleFoam
|
#19 |
Senior Member
Bill Wang
Join Date: Aug 2014
Posts: 109
Rep Power: 11 |
Dear,
I have found an example, which uses the residualControl for pimple: https://openfoamwiki.net/index.php/O...hm_in_OpenFOAM And below is what I got from the openFoam support: icoFoam is a simple demonstration solvers and does not and need not support residual control, fvOptions etc. If you are developing an transient incompressible laminar or turbulent flow cases choose either pisoFoam or pimpleFoam if you need residual control, fvOptions etc. Does this mean that the residualControl does not work for PISO algorithm? Thank you. I am simulating the transient, laminar, incompressible flow. Regards, Bill Last edited by 6863523; January 22, 2017 at 11:56. Reason: information added |
|
January 23, 2017, 02:03 |
|
#20 |
Senior Member
|
Hi,
For residualControl to work nOuterCorrectors should be greater than 1. Since pisoFoam does not have outer correct loop (or in other words nOuterCorrectors is always 1), it does not check for convergence in term of initial residuals; pimpleFoam does. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
a problem with convergence in buoyantSimpleFoam | skuznet | OpenFOAM Running, Solving & CFD | 6 | November 15, 2017 12:12 |
Wrong fluctuation of pressure in transient simulation | caitao | OpenFOAM Running, Solving & CFD | 2 | March 5, 2015 21:33 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 06:20 |
SLTS+rhoPisoFoam: what is rDeltaT??? | nileshjrane | OpenFOAM Running, Solving & CFD | 4 | February 25, 2013 04:13 |
Orifice Plate with a fully developed flow - Problems with convergence | jonmec | OpenFOAM Running, Solving & CFD | 3 | July 28, 2011 05:24 |