CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

very small values get set to 0

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By HPE
  • 1 Post By superkelle

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 28, 2020, 10:32
Question very small values get set to 0
  #1
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7
superkelle is on a distinguished road
Hi my problem is that in my simulations some numeric values are very small, in regions of 1E-40 for example a approximation for a rate coefficient field :

Code:
k4.field() = 1.5E-40*pow(TGas.field()/300, -2.5);
all values are simply set to zero. Is there a setting to prevent this? Or is it simply to small in terms of machine epsilon?
superkelle is offline   Reply With Quote

Old   April 28, 2020, 12:23
Default
  #2
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
Have a look at the machine epsilon table below, and compare it with your hardware:
Machine epsilon
superkelle likes this.
HPE is offline   Reply With Quote

Old   May 1, 2020, 14:30
Default
  #3
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7
superkelle is on a distinguished road
from python I got:

Code:
import sys
sys.float_info.epsilon

Out[2]: 2.220446049250313e-16
So does that really mean that if I am making calculations in OF, I will not get right (adequate) results in any equation, when I have any value involved that is in this region or lower? I found out that it was maybe a limit of paraview in the first place to display small values, since when I multiplied this value with some big values in the region of 1E40 the results were not zero.
superkelle is offline   Reply With Quote

Old   May 3, 2020, 18:11
Default
  #4
HPE
Senior Member
 
HPE's Avatar
 
Herpes Free Engineer
Join Date: Sep 2019
Location: The Home Under The Ground with the Lost Boys
Posts: 931
Rep Power: 13
HPE is on a distinguished road
yes, those numbers lower than the machepsilon ks mumbo jumbo most of the time to avoid fp exceptions.
HPE is offline   Reply With Quote

Old   May 4, 2020, 06:28
Default
  #5
Member
 
alexander thierfelder
Join Date: Dec 2019
Posts: 71
Rep Power: 7
superkelle is on a distinguished road
Hi for everyone who sees this post, here is a complete discussion about the topic.

is double precision default of OF?

in short:

Quote:
Quote:
Originally Posted by immortality View Post
thanks but I wonder then whats its relation to zero of machine thats about 1e-17 that must reached by continuity residuals?Is it a limit while DP can work with numbers very smaller than 1e-17?
Be aware that you can work with numbers much smaller than eps, as the maximum and minimum exponents (with 10-base) is -308 and 308 respectively (double prec.). That means that it is possible to represent a number down to to 2.2250738585072014e-308 (equal to 2^-1022) in double precision. It is also perfectly possible to do arithmetics with small numbers, for example 1e-30 + 1e-30 equals (correctly) 2e-30. The trouble arise when the numbers differ greatly in magnitude. If you for example try to calculate the sum 1+10^-16, the result is still 1 (exactly).

See this page for more information: http://en.wikipedia.org/wiki/Double-...g-point_format
HPE likes this.
superkelle is offline   Reply With Quote

Reply

Tags
numerical, small, values


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
[ICEM] ICEM Scripting Issues tylerplowright ANSYS Meshing & Geometry 33 September 27, 2021 17:35
Set values of a volVectorField to zero GustavGans OpenFOAM Programming & Development 12 April 9, 2019 01:12
set a volScalarField values anishtain4 OpenFOAM 1 July 5, 2012 10:28
Numerical errors in nested domain with pre-calculated boundary values Arnoldinho OpenFOAM Running, Solving & CFD 3 April 4, 2012 11:31
Reference values set up Plz help! pah FLUENT 0 June 14, 2005 07:39


All times are GMT -4. The time now is 16:24.