CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   CFX (http://www.cfd-online.com/Forums/cfx/)
-   -   If Statement (http://www.cfd-online.com/Forums/cfx/77243-if-statement.html)

 Zaktatir June 17, 2010 10:03

If Statement

hello,
i want to know why my If statement doesn't work if write:
if(Water.Volume Fraction==0.5,Velocity1,Velocity2) although, Water.Volume Fraction can be 0.5 in my domain (my interphase)...
I want to write a special expression estimating the wave length on an interphase
(for >0.5 it works)

 ghorrocks June 17, 2010 19:54

Forget C. Try if(Water.Volume Fraction=0.5,Velocity1,Velocity2)

 Zaktatir June 18, 2010 02:26

what shall i forget, and = is not a logical operator

 ghorrocks June 18, 2010 06:04

== is a logical operator in C. That's why I said forget C as CFX does not use C for expressions. = is a logical operator in CEL.

 Zaktatir June 18, 2010 09:43

WARNING
Syntax error detected in the expression assigned to 'mfrac'.
if(Water.Volume Fraction
then error detected at:
=0.5,1,2)
Details - Unexpected character.

ERROR
Syntax error detected in the expression assigned to 'mfrac'.
if(Water.Volume Fraction
then error detected at:
=0.5,1,2)
Details - Unexpected character.

----------------------- i i should use "==" and this statement delivers wrong results ( as if Water.Volume Fraction never takes the value 0.5)

 ghorrocks June 19, 2010 06:09

I see - in that case you may well be right about the ==. And as you say, VF is never exactly 0.5 so it will never be true anywhere. You will have to specify a range - and I don't think CEL supports AND/OR statements. You may have to construct this logic the hard way with step() functions eg step(VF-0.4)*step(0.6-VF) to find nodes where VF is between 0.4 and 0.6.

 All times are GMT -4. The time now is 22:00.