CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Solution diverging on using double precision (https://www.cfd-online.com/Forums/main/112098-solution-diverging-using-double-precision.html)

qrie January 22, 2013 03:11

Solution diverging on using double precision
 
Hi,

I have an incompressible Navier Stokes code that was working fine as long as I was using single precision. When I converted to double precision, the residues are very high. Why is this happening?

Thanks!
Qrie

Martin Hegedus January 22, 2013 11:29

A bug in your code?

Sometimes issues like the following may occur

if (xx == 0.0) {
then do something
}

Under single precision this might work but double does not if xx is very small but not equal to 0.0, for example xx=1.0e-12. Single precision would round value to zero. Error tolerances should be used.

if (abs(xx) < 1.0e-8) {
then do something
}

qrie January 22, 2013 23:11

That helps! Thank you! :)


All times are GMT -4. The time now is 01:04.