CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

Are you writing solvers for single or double precision?

Register Blogs Community New Posts Updated Threads Search

Like Tree20Likes
  • 1 Post By aerosayan
  • 2 Post By sbaffini
  • 3 Post By FMDenaro
  • 3 Post By FMDenaro
  • 2 Post By arjun
  • 3 Post By sbaffini
  • 2 Post By FMDenaro
  • 2 Post By FMDenaro
  • 1 Post By sbaffini
  • 1 Post By andy_

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   January 16, 2021, 08:18
Default Are you writing solvers for single or double precision?
  #1
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
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
aero_head likes this.

Last edited by aerosayan; January 16, 2021 at 10:24.
aerosayan is offline   Reply With Quote

Old   January 16, 2021, 12:09
Default
  #2
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,190
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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 and aero_head like this.
sbaffini is offline   Reply With Quote

Old   January 16, 2021, 14:28
Default
  #3
Senior Member
 
Sayan Bhattacharjee
Join Date: Mar 2020
Posts: 495
Rep Power: 8
aerosayan is on a distinguished road
Quote:
Originally Posted by sbaffini View Post
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.
aerosayan is offline   Reply With Quote

Old   January 16, 2021, 14:37
Default
  #4
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
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.
sbaffini, aerosayan and aero_head like this.
FMDenaro is offline   Reply With Quote

Old   January 16, 2021, 14:55
Default
  #5
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
Just a very simple example of the problem
https://www.ibm.com/support/pages/si...point-accuracy
sbaffini, aerosayan and aero_head like this.
FMDenaro is offline   Reply With Quote

Old   January 16, 2021, 15:20
Default
  #6
Senior Member
 
Arjun
Join Date: Mar 2009
Location: Nurenberg, Germany
Posts: 1,285
Rep Power: 34
arjun will become famous soon enougharjun will become famous soon enough
Quote:
Originally Posted by aerosayan View Post
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 and aerosayan like this.
arjun is offline   Reply With Quote

Old   January 16, 2021, 15:23
Default
  #7
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,190
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
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, aerosayan and aero_head like this.
sbaffini is offline   Reply With Quote

Old   January 16, 2021, 15:28
Default
  #8
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
https://web.ma.utexas.edu/users/arbo...disasters.html
sbaffini and aerosayan like this.
FMDenaro is offline   Reply With Quote

Old   January 16, 2021, 15:29
Default
  #9
Senior Member
 
Filippo Maria Denaro
Join Date: Jul 2010
Posts: 6,849
Rep Power: 73
FMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura aboutFMDenaro has a spectacular aura about
https://link.springer.com/article/10...15-2809-5#Sec2
sbaffini and aerosayan like this.
FMDenaro is offline   Reply With Quote

Old   January 16, 2021, 16:02
Default
  #10
Senior Member
 
sbaffini's Avatar
 
Paolo Lampitella
Join Date: Mar 2009
Location: Italy
Posts: 2,190
Blog Entries: 29
Rep Power: 39
sbaffini will become famous soon enoughsbaffini will become famous soon enough
Send a message via Skype™ to sbaffini
Flow statistics are also of concern. In single precision you have to be careful even for simple averages over, say, 100 million cells
aerosayan likes this.
sbaffini is offline   Reply With Quote

Old   January 18, 2021, 07:36
Default
  #11
Senior Member
 
andy
Join Date: May 2009
Posts: 301
Rep Power: 18
andy_ is on a distinguished road
Quote:
Originally Posted by aerosayan View Post
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.
aerosayan likes this.
andy_ is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Switching between single and double precision in Fortran aerosayan Main CFD Forum 12 November 20, 2020 08:24
How to Mix AIR and WATER Elvis1991 FLUENT 12 December 1, 2016 13:28
Continuing User Defined Real Gas Model issues aeroman FLUENT 6 April 8, 2016 04:34
REAL GAS UDF brian FLUENT 6 September 11, 2006 09:23
Double precision CFX Vanessa CFX 8 August 13, 2006 05:34


All times are GMT -4. The time now is 14:12.