# floating point error

 Register Blogs Members List Search Today's Posts Mark Forums Read

 August 29, 2001, 00:42 floating point error #1 sivakuamr 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, 01:14 Re: floating point error #2 John C. Chien 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, 03:12 Re: floating point error #3 Greg Perkins 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, 03:45 Re: floating point error #4 John C. Chien 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, 04:32 Re: floating point error #5 I. Dotsikas 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, 12:21 Re: floating point error(to Mr. jhon c. chien) #6 sivakuamr 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, 12:36 Re: floating point error(to Mr. jhon c. chien) #7 John C. Chien 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, 06:27 Re: floating point error #8 Matthias 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, 08:36 Re: floating point error(to Mr. jhon c. chien) #9 Dave 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, 12:33 Re: floating point error #10 John C. Chien 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, 14:23 Re: floating point error(to Mr. jhon c. chien) #11 John C. Chien 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, 01:25 Re: floating point error(to Mr. jhon c. chien) #12 Dave 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, 01:37 Re: floating point error(to Mr. jhon c. chien) #13 John C. Chien 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.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post vaina74 OpenFOAM Installation 13 February 3, 2012 18:43 Wantami FLUENT 0 July 18, 2011 05:11 johndeas OpenFOAM 1 September 13, 2010 20:23 gschaider OpenFOAM Installation 120 December 2, 2009 11:23 ivanyao OpenFOAM Running, Solving & CFD 6 September 5, 2008 20:50

All times are GMT -4. The time now is 23:30.