CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   judging convergence through residuals (https://www.cfd-online.com/Forums/main/110883-judging-convergence-through-residuals.html)

MachZero December 23, 2012 23:59

judging convergence through residuals
 
I am using Fluent, and as many users do, I often monitor convergence (at least partially) by monitoring the residuals. I think that many CFD users can get confused about exactly what the residuals mean. I am occasionally one of those users.

In theory, residuals are just the change from one iteration to the next. As a solution converges one would expect the residuals to drop such that there is no change from iteration n to n+1. But that can be misleading. For example, as you drop the under-relaxation factors, residuals drop. At first glance one could say "it is converging better!" without that being the case. Taking this to the extreme... If UR factors are dropped to 0.001, the solution simply isnt progressing, almost at all. Therefore the residuals will drop to approx. machine precision.

My ultimate point is that, residuals can mean many things, from "the solution is converged" to "the solution is not progressing". Or, when the residuals are constant at a higher value, that "the solution is changing consistently or oscillating".

So my ultimate question is, are there any good ways to weed out some of these issues? Yes, I like most people set surface monitors and judge those for convergence, but I want this conversation to remain about residuals. Are there any experts out there with some insight into this matter? I would be interested in having some discussion.

cdegroot December 24, 2012 04:31

Residuals actually aren't a measure of change from one iteration to the next, they are a local measure of how well the current solution satisfies the governing equations, typically normalized in some way. For example, you have the equation at a control volume P with neighbors NB:

a_P \phi_P =\sum_{NB}a_{NB}\phi_{NB} +b_P

Then the residual at that control volume is:

R_P = a_P \phi_P -\sum_{NB}a_{NB}\phi_{NB} -b_P

Which is then normalized by some global scale such as the average magnitude of a_P \phi_P in the domain. The residual reported by CFD codes is usually the RMS average of the residuals in the domain or sometimes the maximum. Note that the "a" coefficients and the source "b" depend on the current solution, so after the solution comes from the linear solver the residual will be very small (depending on solver tolerance) but then the coefficients are updated based on that solution which is when the residual is actually checked. So it is a measure of how well your linearized problem is converged to the solution of the nonlinear problem. If your coefficients don't change much between iterations the residual will be small.

To judge convergence the residual is important because it tells you how well your linearized problem is approximated. If the residual is small it is telling you that your coefficients are not changing much between iterations and the nonlinear problem is well approximated. However, you are right, high levels of relaxation will make this number misleading because it causes the solution, and as a result the coefficients, to change less between iterations.

I think the best thing to do is also report all global quantities you are interested in and make sure they are also not changing. If you have to use a lot of relaxation in the beginning for stability reasons, try backing this of later in the calculation to get a better idea of convergence.

FMDenaro December 24, 2012 04:58

Good issue!

Assuming for example a system in the form A.x = q, x is the exact solution, at a generic iteration k you have:

rk = A . xk - q

while you can see that xk+1 - xk = A^-1 . (rk+1 - rk )

Therefore, the conclusion is that one must never use the difference xk+1 - xk ...

MachZero December 24, 2012 09:21

Thank you both so much for your replies! They both help clarify this issue quite a bit for me. I have used CFD for some time, and now I am really trying to get back into understanding the mathematics as I think that will really help my quality of results. Thanks again!

Rami December 25, 2012 04:52

I suggest that in addition the residual monitoring you'll also check global balances (e.g., mass, momentum and energy over the entire domain). This will help you to see if your solution is reasonable and not just frozen due to low relaxation. Another measure is indeed the change between subsequent iterations.

MachZero December 25, 2012 08:35

So that is what I was looking for, additional checks to deterine whether it is converged or not progressing. When you say check global mass balance and energy etc, is there a good way to do that? Is it simple checking mass flow at inlet and outlet? Or is there some sort of volume integral. As well, is there a way to check difference in flow solution between iterations? I know Fluent is doing some normalization, would it be beneficial to stop it from doing this? I have run into slight issues where *I thought* I was not getting a good convergence on residuals, but it was just that I had used an fmg initialization, so my initial condition was very good.

Thanks again for your help, this has been extremely informative.
Merry Christmas!

cdegroot December 25, 2012 09:01

In Fluent you can report the net mass flow through all inlets and outlets, which should sum to something near zero. Look for this under the monitors menu. You can also get it not to normalize residuals under the same menu by opening up the residuals panel. In general the normalization is good, otherwise residual levels are completely problem dependent. When they are normalized they are only somewhat problem dependent.

FMDenaro December 25, 2012 12:18

I am not an expert in Fluent ... but for me the balance between inlet and outlet is of lesser meaning in checking the real convergence ..


All times are GMT -4. The time now is 11:38.