# NAN result in the half of the simulation at high angle of attack

**URL:** <https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770>\
**Category:** Cases\
**Created:** [9 March 2023 10:46 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770 "2023-03-09T10:46:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yuer](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@Yuer](https://pyfr.discourse.group/u/Yuer)\
**Post date:** [9 March 2023 10:46 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/1 "2023-03-09T10:46:14Z")

</div>

Hi everyone, I simulate the flow over NACA0012 airfoil with Reynold number of 150000, which use the system of ac-navier-stokes. I’ve already got convergent solution at low angle of attack. However, when just increase the angle of attack in the ini file to 10 degree or more, the simulation gets NAN values after a quite long time. When I check the residual, I found that the residual converge to 0.03-0.04 at first. However, it did’t decrease but increase extremely slowly which maintain 0.1-0.2 for a long time before divergence. And finally, it suddenly diverged in a very short time.  
Does anyone encounter the same situation? Any ideas on why this is happening? Is the result calculated before divergence valuable? Looking forward to your help.  
Yuer

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [10 March 2023 09:16 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/2 "2023-03-10T09:16:43Z")

</div>

It sounds like you might need to reduce the tolerences on the pseudo-time stepper. What generally happens when the tolerence isn’t low enough is you get a slow acumulation of error until a point where the pseudo stepper is no longer able to converge the system at all and then the error will rapidly grow until it NaNs.

At higher angles of attack you will probably see separated flow and these are harder to solve with more elements with large gradients, which is why I think you’re only seeing this in the higher angle case.

---

<div class="post-metadata">

**Author:** ![Yuer](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@Yuer](https://pyfr.discourse.group/u/Yuer)\
**Post date:** [10 March 2023 15:58 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/3 "2023-03-10T15:58:17Z")

</div>

Thanks, Will. Do you mean to adjust the parameters of atol or pseudo-resid-tol or both? Is there any tips to choose the appropriate tolerances？

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [10 March 2023 16:09 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/4 "2023-03-10T16:09:20Z")

</div>

I mean you need to tweak `pseudo-resid-tol`.

You can actually set the tollerence of each parameter individually e.g. by using `pseudo-resid-tol-p`. The pressure tolerence is the most critical as it dictates how divergence free the veloicty field is. What value to use is dependent on the zeta and the simulation, but have a look at the output from the residual plugin. When you plot it, if you see the pressure residual creeping up over time, then you need to reduce it.

---

<div class="post-metadata">

**Author:** ![Yuer](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@Yuer](https://pyfr.discourse.group/u/Yuer)\
**Post date:** [11 March 2023 10:54 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/5 "2023-03-11T10:54:46Z")

</div>

Hi,Will. I’ve already reduce the pseudo-resid-tol. And the residual can actually decrease more to approximately 0.01-0.02. However, it still creeps up slowly after that, even though I modify the pseudo-resid-tol to 1e-30 or lower.Are there any other parameters I should also modify to ensure convergence?

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [11 March 2023 12:55 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/6 "2023-03-11T12:55:42Z")

</div>

What have you set the maximum number of pseudo iterations to be? Are you using P-multigrid? Are you using variable local pseudo time stepping

---

<div class="post-metadata">

**Author:** ![Yuer](https://avatars.discourse-cdn.com/v4/letter/y/dc4da7/32.png) [@Yuer](https://pyfr.discourse.group/u/Yuer)\
**Post date:** [11 March 2023 15:26 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/7 "2023-03-11T15:26:49Z")

</div>

Hi,Will. I set the maximum number of pseudo iterations to 15-20. I’m not using P-multigrid, just simple O-grid.There’s no variable local pseudo time stepping. Because I’m new to PyFR. The ini file is very similar to the example of 2D-cylinder-flow. Should I use the variable local pseudo time stepping?

---

<div class="post-metadata">

**Author:** ![WillT](https://avatars.discourse-cdn.com/v4/letter/w/bc79bd/32.png) [@WillT](https://pyfr.discourse.group/u/WillT)\
**Post date:** [13 March 2023 09:08 UTC](https://pyfr.discourse.group/t/nan-result-in-the-half-of-the-simulation-at-high-angle-of-attack/770/8 "2023-03-13T09:08:27Z")

</div>

So if I’m not mistaken, O-grid is a way of generatng a mesh of a domain. P-multigrid is a converngence accleration method when solving systems of equations. Checkout this paper: [https://doi.org/10.1016/j.cpc.2018.06.016](https://doi.org/10.1016/j.cpc.2018.06.016)

If you are just using pseudo-time stepping without P-multigrid or variable local time stepping, then a maximum of 15-20 pseudo iteraions is unlikely to be enough, again you can see this from the residual tolerence. Have a look to see if you are actaully going below the tolerence you set.

You should really enable P-multigrid and variable local time stepping.
