CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   CFX (https://www.cfd-online.com/Forums/cfx/)
-   -   Expression in cfx (https://www.cfd-online.com/Forums/cfx/174005-expression-cfx.html)

dfernandez July 1, 2016 10:53

Expression in cfx
 
Hi

I will like to insert a cel expression with the following information

Visupper = 271.8171 [kg m^-1 s^-1]
Vislower = 7689.3521 [kg m^-1 s^-1]
Tupper = 338.7055 [K]
Tlower = 310.9278 [K]
IF (T>Tupper)
VisT = 271.8171 [kg m^-1 s^-1]
END IF
IF (T<Tlower)
VisT = 7689.3521 [kg m^-1 s^-1]
IF (T=Tupper)
VisT = 271.8171 [kg m^-1 s^-1]
END IF
IF (T=Tlower)
VisT = 7689.3521 [kg m^-1 s^-1]
END IF
IF (T<Tupper.AND.T>Tlower)
VisT = Vislower+ (Visupper-Vislower)*(T-Tlower)/(Tupper-Tlower)

I wrote it in FORTRAN language but i got this error for example

ERROR
CCL parser failed with message:
parseCCLLineH: syntax error near "IF (T>Tupper)"

If use IF (T.GT.Tupper), I got the same error.


Can any one guide me to write it well? . Or is there another easy way to introduce that calculation?

Thanks in advance.

ghorrocks July 2, 2016 06:56

CEL uses the if(<true/false>,<action if true>,<action if false>) format which is a little different to fortran. But still pretty simple so I will let you transcribe it. Note that CEL does not execute line by line like fortran - so you will have to put the entire logic in a single line (or break it up with intermediate variables).

But your function is complex enough that it will require several nested if statements. Thus I recommend you use a 1D interpolation function as it is much simpler and you can put in as many bends and wiggles as you like and the function stays simple.

dfernandez July 2, 2016 13:18

Thanks for your response.

i figured out and i did this.

I did an aproximation for the curve i had ( can't attached the curve) to two linear equations.

y = -270.99x + 92062
y = -13.083x + 4707.2

then i created 3 expressions

Vis1= -270.99x + 92062
Vis2 = -13.083x + 4707.2
VisT= if ( T<=338.7055333[K],Vis1,Vis2)

I hope not to get the ENFORCED BOUNDS error.

Thanks for your advice Glenn


All times are GMT -4. The time now is 08:30.