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

"if" command in CFX-13 is not really an "if" command!!!!

Register Blogs Community New Posts Updated Threads Search

Like Tree6Likes
  • 1 Post By mohammad
  • 4 Post By cdegroot
  • 1 Post By ghorrocks

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 16, 2012, 07:16
Question "if" command in CFX-13 is not really an "if" command!!!!
  #1
Senior Member
 
mohammad
Join Date: Dec 2010
Location: UK
Posts: 245
Rep Power: 16
mohammad is on a distinguished road
Dear All,
I am trying to make a conditional expression with "if" command in CFX-13.

Amazingly, the if command is not true...

for example, create this expression and see the results!!!

-if (a>5,10,loge(5-a))
if we see the results for any a>5 (e.g. "a=6") the results must be 10
However, the CFX-post tried to calculate the value of "loge(5-a)" which will be an mathematical error.
Seemningly, before applying the if command, the CFX-POST calculated the consequences .....

Any Idea or Alternative solution!!!???

Regards,
Lemanes likes this.
mohammad is offline   Reply With Quote

Old   October 16, 2012, 09:45
Default
  #2
Senior Member
 
cdegroot's Avatar
 
Chris DeGroot
Join Date: Nov 2011
Location: Canada
Posts: 414
Rep Power: 17
cdegroot is on a distinguished road
This is answered in the CFX Reference Guide, section 13.2.2.

CEL supports the conditional if statement using the following syntax:
if( cond_expr, true_expr, false_expr )
where:
cond_expr: is the logical expression used as the conditional test
true_expr: is the mathematical expression used to determine the result if the conditional test is true.
false_expr : is the mathematical expression used to determine the result if the conditional test is false.

Note:**The expressions true_expr and false_expr are always evaluated independent of whether the evaluation of cond_expr is true or false. As a consequence, a conditional statement cannot be used to avoid division by zero as in if( x>0, 1/x, 1.0). In this case, when x=0.0, a division by zero will still occur because the expression 1/x is evaluated independent of whether x>0 is satisfied or not.
mvoss, Luis Lei, mrkmrk and 1 others like this.

Last edited by cdegroot; October 16, 2012 at 09:47. Reason: Mistake
cdegroot is offline   Reply With Quote

Old   September 25, 2013, 08:32
Default alternative here?
  #3
New Member
 
Lingyun Lei
Join Date: Jun 2013
Posts: 4
Rep Power: 12
Luis Lei is on a distinguished road
thank you very much for your infos, which is quite helpful to me. But, what can I do, if i do need the ,,real'' conditional statement? Is there a alternative maybe?

best wishes
Quote:
Originally Posted by cdegroot View Post
This is answered in the CFX Reference Guide, section 13.2.2.

CEL supports the conditional if statement using the following syntax:
if( cond_expr, true_expr, false_expr )
where:
cond_expr: is the logical expression used as the conditional test
true_expr: is the mathematical expression used to determine the result if the conditional test is true.
false_expr : is the mathematical expression used to determine the result if the conditional test is false.

Note:**The expressions true_expr and false_expr are always evaluated independent of whether the evaluation of cond_expr is true or false. As a consequence, a conditional statement cannot be used to avoid division by zero as in if( x>0, 1/x, 1.0). In this case, when x=0.0, a division by zero will still occur because the expression 1/x is evaluated independent of whether x>0 is satisfied or not.
Luis Lei is offline   Reply With Quote

Old   September 25, 2013, 18:39
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,700
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
If you are asking how to get around the caveat Chris mentions (that both true and false expression must evaluate or you get an error) - then the best way around this is to use a fortran user routine where you can use if/then/else statements. This is reasonably easy to do, use a user CEL expression linked to the fortran routine. See the documentation for details, it has examples of how to do it.
Luis Lei likes this.
ghorrocks is offline   Reply With Quote

Old   September 26, 2013, 07:10
Default
  #5
New Member
 
Lingyun Lei
Join Date: Jun 2013
Posts: 4
Rep Power: 12
Luis Lei is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
If you are asking how to get around the caveat Chris mentions (that both true and false expression must evaluate or you get an error) - then the best way around this is to use a fortran user routine where you can use if/then/else statements. This is reasonably easy to do, use a user CEL expression linked to the fortran routine. See the documentation for details, it has examples of how to do it.
Yep, thanks very much, i've found the documents needed and i'll do it.
Luis Lei 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
Different result in CFX and fluent for mass trans.? is segregated better? ftab CFX 7 September 27, 2012 07:57
CFX - Solidworks Flow, Impeller comparison aerospace_guy_ CFX 8 March 20, 2012 22:06
Pros and Cons for CFX, CFdesign, COMSOL Val Main CFD Forum 3 June 10, 2011 02:20
ATTENTION! Reliability problems in CFX 5.7 Joseph CFX 14 April 20, 2010 15:45
CFX 4.4 installation problem Pandu Sattvika CFX 1 December 1, 2001 04:07


All times are GMT -4. The time now is 17:59.