|
[Sponsors] |
August 12, 2015, 02:55 |
Unexpected results using CEL function mod
|
#1 |
Senior Member
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22 |
Hi, I just want to highlight some unexpected results I got from the CEL function mod(a,b). For example mod(0.3,0.05) does not return 0 as it should, but instead 0.05. Integers like mod(15,5) give the correct result. I also tested mod(0.15,0.05) in excel, which also gave 0.05. After doubting my math skills I tested it in Matlab, where the result was indeed 0.
So, what’s going on? It probably has to do with how CFX store decimal numbers, and that they cannot be not represented exactly. Solution? Do not use mod with decimal numbers. In my case it resulted in totally unexpected results which were difficult to debug. Maybe this is commonly known, but it was news to me. Also, see the following link for a discussion on mod and excel. http://answers.microsoft.com/en-us/o...d-087475cb7208 |
|
August 12, 2015, 05:52 |
|
#2 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143 |
Sounds like a bug. Have you reported it to ANSYS?
|
|
August 13, 2015, 01:33 |
|
#3 |
Senior Member
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22 |
Yes, and a developer have now confirmed that it is a defect.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[blockMesh] Errors during blockMesh meshing | Madeleine P. Vincent | OpenFOAM Meshing & Mesh Conversion | 51 | May 30, 2016 10:51 |
using METIS functions in fortran | dokeun | Main CFD Forum | 7 | January 29, 2013 04:06 |
Passing Values in Multiple points by 1 CEL Function | Araz | CFX | 0 | May 5, 2011 16:06 |
latest OpenFOAM-1.6.x from git failed to compile | phsieh2005 | OpenFOAM Bugs | 25 | February 9, 2010 04:37 |
Problem with rhoSimpleFoam | matteo_gautero | OpenFOAM Running, Solving & CFD | 0 | February 28, 2008 06:51 |