CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   Main CFD Forum (https://www.cfd-online.com/Forums/main/)
-   -   Are you writing solvers for single or double precision? (https://www.cfd-online.com/Forums/main/233169-you-writing-solvers-single-double-precision.html)

aerosayan January 16, 2021 07:18

Are you writing solvers for single or double precision?
 
Hello everyone,


I saw that one expert I know, only writes their solvers with double precision.
It seems a little unproductive to me, since I also like to do simulations with single precision, since they're 2X faster, but only half as accurate. In most cases, the results are good enough, and I can explore design changes easily.

So, for my own solver, I'm making sure that both single and double precision can be used.

What do others in the forum do?


PS : Having a single precision solver has other advantages too.
Main one is to be able to run fast simulations during the solver development phase and profile the performance of the code.


Thanks and regards
~sayan

sbaffini January 16, 2021 11:09

I strictly prefer double precision in development, because there are several little subtle issues in a general CFD code that won't come out in single precision or you couldn't be sure about them. Single precision is tested just after that.

In production it's just up to the user but, again, my personal preference is for double for the same reasons above. Probably after a first single precision run

aerosayan January 16, 2021 13:28

Quote:

Originally Posted by sbaffini (Post 793486)
I strictly prefer double precision in development, because there are several little subtle issues in a general CFD code that won't come out in single precision or you couldn't be sure about them. Single precision is tested just after that.

In production it's just up to the user but, again, my personal preference is for double for the same reasons above. Probably after a first single precision run

Could you please share what kind of subtle issues you observed with double precision?
I mainly use single precision because it's extremely fast.

FMDenaro January 16, 2021 13:37

As Paolo addressed, the issue should be explored by experiencing what happens for some iterative methods applied on some particular matrix. Maybe more than a CFD topic, is a numerical analysis topic.

Briefly speaking, single precision can cause an accumulation of the error.

FMDenaro January 16, 2021 13:55

Just a very simple example of the problem
https://www.ibm.com/support/pages/si...point-accuracy

arjun January 16, 2021 14:20

Quote:

Originally Posted by aerosayan (Post 793493)
Could you please share what kind of subtle issues you observed with double precision?
I mainly use single precision because it's extremely fast.




Have come across cases that do not converge in single precision or in mixed precision. One of the them actually wasted 2 weeks before someone run it in double precision where it finally converged without issues.

sbaffini January 16, 2021 14:23

As mentioned by Filippo, the main reason is that, in single precision, you need to be a sort of magician to have everything under control. I simply don't have time to analyze every single math operation when I develop in the beginning, maybe later.

More generally, you want to be sure that things actually work in double precision as well.

Also, some CFD pieces have inherent discontinuities (wall functions, gradient limiters, etc.) that might kick in unexpectedly, and spoil your convergence. When you develop you want to be sure that you catch them

FMDenaro January 16, 2021 14:28

https://web.ma.utexas.edu/users/arbo...disasters.html

FMDenaro January 16, 2021 14:29

https://link.springer.com/article/10...15-2809-5#Sec2

sbaffini January 16, 2021 15:02

Flow statistics are also of concern. In single precision you have to be careful even for simple averages over, say, 100 million cells

andy_ January 18, 2021 06:36

Quote:

Originally Posted by aerosayan (Post 793474)
So, for my own solver, I'm making sure that both single and double precision can be used.

That is a major challenge for a CFD code. To succeed in general rather than for specific problems one would have to normalise and express terms very carefully.


All times are GMT -4. The time now is 13:25.