floating point error
hi all,
can anyone please tell me whats the source and the way to rectfy this errorthis is killing me. thanks for the help. 
Re: floating point error
(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.

Re: floating point error
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 1e10 usually works well. Greg 
Re: floating point error
(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.

Re: floating point error
A quick and dirty trick is to add to the denominator a very small number. This could be something like 1.e12 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 
Re: floating point error(to Mr. jhon c. chien)
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

Re: floating point error(to Mr. jhon c. chien)
(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.

Re: floating point error
Hi Greg
This seam pretty nice. But how does it work if you implement this into a parallel code. What about pipeline stalling, pipelinefillup ... The same question for cache oriented code implementation. I think "IFstatements" are far expensive tnen FLOPoperation? If ich check each denominator for this relation  the calculation time increases drastically. ( I know: Better as slow code than a garbagecode ... ) Are there better posibilities. 
Re: floating point error(to Mr. jhon c. chien)
Check your k and e values. It could be that they are zero when you try to initialize.

Re: floating point error
(1). So, commercial codes are slow and buggy. (2). Slow because they are doing some checking, buggy because they did not cover every possibility.

Re: floating point error(to Mr. jhon c. chien)
(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 nonzero 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.

Re: floating point error(to Mr. jhon c. chien)
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'.

Re: floating point error(to Mr. jhon c. chien)
(1). In that case, it must be the leftover 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.

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