
[Sponsors] 
October 16, 2012, 07:16 
"if" command in CFX13 is not really an "if" command!!!!

#1 
Senior Member
mohammad
Join Date: Dec 2010
Location: Seoul, South korea
Posts: 210
Rep Power: 7 
Dear All,
I am trying to make a conditional expression with "if" command in CFX13. Amazingly, the if command is not true... for example, create this expression and see the results!!! if (a>5,10,loge(5a)) if we see the results for any a>5 (e.g. "a=6") the results must be 10 However, the CFXpost tried to calculate the value of "loge(5a)" which will be an mathematical error. Seemningly, before applying the if command, the CFXPOST calculated the consequences ..... Any Idea or Alternative solution!!!??? Regards, 

October 16, 2012, 09:45 

#2 
Senior Member
Chris DeGroot
Join Date: Nov 2011
Location: Canada
Posts: 387
Rep Power: 6 
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. Last edited by cdegroot; October 16, 2012 at 09:47. Reason: Mistake 

September 25, 2013, 08:32 
alternative here?

#3  
New Member
Lingyun Lei
Join Date: Jun 2013
Posts: 4
Rep Power: 4 
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:


September 25, 2013, 18:39 

#4 
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 11,063
Rep Power: 86 
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.


September 26, 2013, 07:10 

#5  
New Member
Lingyun Lei
Join Date: Jun 2013
Posts: 4
Rep Power: 4 
Quote:


Thread Tools  
Display Modes  


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 23: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 05:07 