# How to stop iterating when residuals fall down enough

 Register Blogs Members List Search Today's Posts Mark Forums Read

 December 12, 2014, 14:56 How to stop iterating when residuals fall down enough #1 Member   Richardpluff Join Date: May 2014 Posts: 54 Rep Power: 9 Hi guys, When I used FLUENT, I remember that there exist a tolerance for residuals (I hardly remember it, but I think it was set by default to 1e-3 except for energy, 1e-6). When residuals fall down this values, the simulation stops and the result is considered as converged (I know, it can also be added another physical quantity like flow rate, averaged value or so to make sure the solution is really converged). Now I want to stop my simulation with OpenFOAM when residuals fall below 1e-5 for p and 1e-7 for U and T. I am using my own version of simpleFoam with SIMPLE algorithm. How can I do this? I have been playing with values in residualControls and tolerance of solvers, but the solver always continues iterating, even when I am seeing that residuals have drop down the specified value. Anybody can help? This seems an easy question but I cannot find the solution yet... THANKS!!!

 December 12, 2014, 15:51 #2 Senior Member   Alexey Matveichev Join Date: Aug 2011 Location: Nancy, France Posts: 1,926 Rep Power: 35 Hi, here's a excerpt from tutorials/incompressible/simpleFoam/pitzDaily/system/fvSolution Code: ```SIMPLE { nNonOrthogonalCorrectors 0; residualControl { p 1e-2; U 1e-3; "(k|epsilon|omega)" 1e-3; } }``` Those residuals (under residualControl) are convergence criteria. jherb and CRI_CFD like this.

 December 15, 2014, 06:01 #3 Senior Member   James Join Date: May 2013 Posts: 115 Rep Power: 9 Hey CRI, Did you remeber to include convergence criteria for new variable you have introduced? You said that you have your own simpelFoam based solver and I see you are computing T. So if you want to set a convergence criteria, you have to set it in the source code for all variables. Otherwise the solver will continue iterating until maximun number of iterations specified in controlDict is reached... Hope it helps. Regards, Tensi CRI_CFD likes this.

 December 15, 2014, 06:07 #4 Member   Richardpluff Join Date: May 2014 Posts: 54 Rep Power: 9 Thanks alexeym and Tensian for yur replies. As I expected, the residualControl is the place where I should establish my convergence criteria. I have made several trial and error and nothing works... Tensian, I think you have pointed me in the right direction. I have not implemented any kind of control over residuals in my solver source code, so, how can I expect it stops? This have no sense and I have to review the code and create something that makes T residuals to stop under any condition... Thanks for the tips guys!

 December 15, 2014, 06:11 #5 Member   Richardpluff Join Date: May 2014 Posts: 54 Rep Power: 9 Unfortunately I have no idea about the starting point to add this kind of condition over T residuals. Has anybody implemented something similar? I have to put and "if" statement in somewhere, but I have no idea about classes or methods related to residuals. Any hints? Thanks in advance, Best, CRI