Every time we start solving for a solution in a simulation we will automatically generate a plot of the residuals that will show in the GUI. This is set up as default since residuals give important information about how well the calculations are converging towards a solution for our problem statement. In this week’s blog post we will therefore look closer at residuals and how they are calculated and normalized in Simcenter STAR-CCM+.

## What are residuals?

*Residuals are a normalized value of the RMS (root mean squared) absolute error for the variables in each cell, for the equations we are calculating when we are simulating CFD.*

The error (*r* in the equation below) of the variables is calculated as in the equation below. Where we hope for the error to go as low as possible, where the lower value we can get is all the way down to machine precision, since then we know that the simulation has converged to a solution for our problem statement.

The normalization that is used can be manually defined, meaning that the error in each iteration can be normalized (divided) by a specific value. This is to make the error in each iteration comparable to the error in the other iterations.

## Normalization options

There are three types of normalization options in Simcenter STAR-CCM+. The default option is *Auto* and this option uses the maximum value of the previous iterations for normalization – up to a defined number of iterations, where the default value is set to the five first iterations. If another value is wished to be used you can change the number of iterations used in the monitor settings.

If you instead want to manually define which value to divide the error with at the current iteration, then you choose *Manual* as normalization option and then specify which value you wish to use. If the normalization option *Off* is used, then you will get the absolute residuals (without any normalization) visualized.

If you would like to change the normalization option you can always do that even though you are in the middle of a simulation, obtaining the residuals for all previous iterations normalized with the option selected. When changing the normalization option it is convenient to multi-select all monitors for the residuals and edit all at once by right-clicking and selecting Edit. If you include more complex physics then in the picture below you will have more monitors connected to the solver.

## Example of residuals using the different normalization options

In the example the simulation converges at around 80 iterations, the residuals reach a constant value at a low level.

In the picture below auto scaled residuals with default settings are used.

In the picture below manual scaled residuals are used, with scaling value of 100.

In the picture below the normalization option is turned off. Note that this would correspond to a manual scaling with the value of 1, this residual value is 100 times higher in this plot compared to the picture above, and the shape of the graphs are identical.

## Evaluating convergence

Residuals are a strong tool for evaluating the results and to check if the solution is going in the correct direction. Getting a low and constant value of the residuals is a good indication that the simulation has reached the correct results for your physical problem, but *only* looking at the residuals to judge if the simulation has converged is not recommended. The residual plot is something already set up in the simulation, but it is recommended to always monitor some physical properties of the flow as well.

See the picture below containing both the residual plot and pressure drop plot for the example simulation. Here you can see that a constant value of the pressure drop is not reached at the same time as the residuals become flat (some iterations earlier), so there can be a difference. In more complex simulations it is common for the physical property, in this case the pressure drop, to converge later than the residuals seem to have reached their final value – so it is important to monitor the physical properties as well.

## Residuals for transient simulations

The residuals shown above have been for steady state simulations, and in the picture below you can see the residuals for the same problem statement with time dependent solution (transient simulation). The residuals are calculated every iteration and a specified number of iterations are calculated to converge each time step. The number of *Inner iterations* that are used to converge the solution of each time step are set in the Stopping criteria node. To evaluate if there are enough inner iterations to converge the solution in each time step you should see that the residuals start to flat out before they jump up again when the new time step is calculated. Since the transient simulation is changing between each time step you cannot expect the trend of residuals in transient simulations to reach a constant low value as in the steady state simulation. If the residuals instead go more and more upwards you might obtain a diverged simulation, which is true for steady state simulations as well. If obtaining a diverged solution you have some error in the simulation that needs to be solved, by following the tips and tricks from this previous Volupe blog post you will hopefully be able to solve your error https://volupe.com/blog-volupe/en/how-to-locate-high-residaul-cells-in-simcenter-star-ccm/. This previous blog post also includes how to look at the residuals in each cell, as a field function.

We at Volupe hope that this information has been interesting and that you will have a better understanding about how your simulations are developing after this blog post. If you have any questions you are always welcome to reach out to us at support@volupe.com.

## Author

Christoffer Johansson, M.Sc.

support@volupe.com

+46764479945