|
[Sponsors] |
August 29, 2001, 01:42 |
floating point error
|
#1 |
Guest
Posts: n/a
|
hi all,
can anyone please tell me whats the source and the way to rectfy this error-this is killing me. thanks for the help. |
|
August 29, 2001, 02:14 |
Re: floating point error
|
#2 |
Guest
Posts: n/a
|
(1). Mostly likely you have divide by zero or multiply by a very large number problem. When this happens, the resulting variable will exceed the range. (too big)(2). Before you do a divide operation, first check the denominator (the downstair variable) to make sure that it is not zero. (3).Use double precision to increase the range of the float point variable.
|
|
August 29, 2001, 04:12 |
Re: floating point error
|
#3 |
Guest
Posts: n/a
|
As John says its probably divide by zero. On some machines checking for zero doesn't always catch all such errors, I usually check that its a small number. For computing x = y/d the C code might look like:
if (fabs(d) < MIN_REAL_NUMBER) then /* --- do something special */ else x = y/d; where MIN_REAL_NUMBER is a small number close to zero. Something like 1e-10 usually works well. Greg |
|
August 29, 2001, 04:45 |
Re: floating point error
|
#4 |
Guest
Posts: n/a
|
(1). Yes, normally you don't check the variable directly to see whether it is equal to zero or not. (because of the round off error) (2)." if(a==0.0) {...;} " is not the best way to avoid divide by zero.
|
|
August 29, 2001, 05:32 |
Re: floating point error
|
#5 |
Guest
Posts: n/a
|
A quick and dirty trick is to add to the denominator a very small number. This could be something like 1.e-12 or a number near the accuracy limit of your computer. (check it before). This small number does not affect your results (devision with a big number like 1.e+3) but is bigger than zero so that not any NaN results occur. Addition (or substraction) of very big and very small numbers is always dangerous (what I used here). Multiplication is not sensitiv and provides you with correct results.
Anyway the best way is to check your code and try to find the mistake. I. Dotsikas |
|
August 29, 2001, 13:21 |
Re: floating point error(to Mr. jhon c. chien)
|
#6 |
Guest
Posts: n/a
|
hi jhon thanks, but this happens when i try to initialize the solution in Fluent5.4. moreover i do not perform any division or multiplication(other rhan the ones involved in general solution procedure). so how do i track down my source of error. thanks for the help. sivakumar
|
|
August 29, 2001, 13:36 |
Re: floating point error(to Mr. jhon c. chien)
|
#7 |
Guest
Posts: n/a
|
(1). Follow a tutorial sample first, to see if you are having the same problem. (2). If you still have the problem, contact the vendor's engineer. When using a commercial cfd code, you must follow only the working sample cases. If the sample cases don't work, stop using the code.
|
|
August 30, 2001, 07:27 |
Re: floating point error
|
#8 |
Guest
Posts: n/a
|
Hi Greg
This seam pretty nice. But how does it work if you implement this into a parallel code. What about pipeline stalling, pipeline-fillup ... The same question for cache oriented code implementation. I think "IF-statements" are far expensive tnen FLOP-operation? If ich check each denominator for this relation - the calculation time increases drastically. ( I know: Better as slow code than a garbage-code ... ) Are there better posibilities. |
|
August 30, 2001, 09:36 |
Re: floating point error(to Mr. jhon c. chien)
|
#9 |
Guest
Posts: n/a
|
Check your k and e values. It could be that they are zero when you try to initialize.
|
|
August 30, 2001, 13:33 |
Re: floating point error
|
#10 |
Guest
Posts: n/a
|
(1). So, commercial codes are slow and buggy. (2). Slow because they are doing some checking, buggy because they did not cover every possibility.
|
|
August 30, 2001, 15:23 |
Re: floating point error(to Mr. jhon c. chien)
|
#11 |
Guest
Posts: n/a
|
(1). What you are saying is when the initial value for k (turbulence kinetic energy) is zero (no turbulence and epsilon will be zero also), the computation will fail. (2). Then the code should set a non-zero initial value for k, and also check the k value constantly during the calculation (or iteration). I think, if the code is having problem with zero initial k value, then it also could run into troubles during the iterations.
|
|
August 31, 2001, 02:25 |
Re: floating point error(to Mr. jhon c. chien)
|
#12 |
Guest
Posts: n/a
|
The default values of k and e are zero and you have to obtain appropriate values from your inlet conditions etc. When you are new to the code you just 'click' the button 'initialize' not knowing what values to use. Sometimes this results into a 'floating point error'.
|
|
August 31, 2001, 02:37 |
Re: floating point error(to Mr. jhon c. chien)
|
#13 |
Guest
Posts: n/a
|
(1). In that case, it must be the left-over garbage in that particular memory location which is causing the problem, when the inlet condition for k and epsilon are not explicitly specified by the user. (2). It shouldn't be that difficult to include the checking of the user's operation at this point, to force the user to properly specify the conditions.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
c++ libraries and solver compiling | vaina74 | OpenFOAM Installation | 13 | February 3, 2012 18:43 |
Problem with UDF compiling for kTkLW model | Wantami | FLUENT | 0 | July 18, 2011 06:11 |
Accessing phi from a fvPatchField at same patch | johndeas | OpenFOAM | 1 | September 13, 2010 21:23 |
Version 15 on Mac OS X | gschaider | OpenFOAM Installation | 113 | December 2, 2009 11:23 |
Problem with compile the setParabolicInlet | ivanyao | OpenFOAM Running, Solving & CFD | 6 | September 5, 2008 21:50 |