CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > ANSYS > CFX

Unexpected results using CEL function mod

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 12, 2015, 02:55
Default Unexpected results using CEL function mod
  #1
Senior Member
 
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22
Lance is on a distinguished road
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
Lance is offline   Reply With Quote

Old   August 12, 2015, 05:52
Default
  #2
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,703
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Sounds like a bug. Have you reported it to ANSYS?
ghorrocks is offline   Reply With Quote

Old   August 13, 2015, 01:33
Default
  #3
Senior Member
 
Lance
Join Date: Mar 2009
Posts: 669
Rep Power: 22
Lance is on a distinguished road
Yes, and a developer have now confirmed that it is a defect.
Lance is offline   Reply With Quote

Reply


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
[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


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