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

How to write an expression with an if condition statment?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 2 Post By honcho62
  • 1 Post By Goenitz

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 23, 2016, 22:49
Default How to write an expression with an if condition statment?
  #1
Senior Member
 
AH
Join Date: Apr 2014
Posts: 282
Rep Power: 13
visitor is on a distinguished road
Can anyone help on this please?

Basically a thermostat which reads temperature at a coordinate; 0,0,0.7 this is in meters, and than control a heater. Heater is in the sub-domain at; Sources>Equation Sources>Energy>Source 7e6 W/m3

basically get temp at 0,0,0.7,
if temp <= 300 K then 7e6
else 0

Thanks in advance
visitor is offline   Reply With Quote

Old   February 24, 2016, 02:13
Default
  #2
Member
 
Join Date: Jan 2016
Posts: 34
Rep Power: 10
honcho62 is on a distinguished road
You can find this stuff in the tutorials. You make a new expression and then write:

if(condition, result when true, result when false)

so for yours that'd be something like this, though I'm not sure about the Temperature@Point stuff:

if(Temperature@Point <= 300 [K], 7e6 [W m^-3], 0)
alirezame and danisnug like this.
honcho62 is offline   Reply With Quote

Old   February 24, 2016, 03:23
Default
  #3
Senior Member
 
AH
Join Date: Apr 2014
Posts: 282
Rep Power: 13
visitor is on a distinguished road
Thank you for your reply

Will try this out as soon as i get back in compu lab.

Might enter another expression for Point with a definition of e.g. 0,0,0.7
visitor is offline   Reply With Quote

Old   February 24, 2016, 05:09
Default
  #4
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,691
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
If your simulation is transient then this approach will work. It should cause the heater to turn on and off over time.

If your simulation is steady state this will never converge, so it is not a suitable approach.
ghorrocks is offline   Reply With Quote

Old   March 14, 2016, 05:24
Default
  #5
Senior Member
 
AH
Join Date: Apr 2014
Posts: 282
Rep Power: 13
visitor is on a distinguished road
Didn't get a chance to try this myself, but a friend of mine tried it and got the following errors;

The following unrecognized names were referenced; Temperature, point.


point was defined under a separate expressions with coordinates;
0,0,0.7

Thanks
visitor is offline   Reply With Quote

Old   March 14, 2016, 05:31
Default
  #6
Senior Member
 
Maxim
Join Date: Aug 2015
Location: Germany
Posts: 415
Rep Power: 12
-Maxim- is on a distinguished road
I think you can't use an expression to create that point. I would try to insert a 'Source Point' in Pre with those coordinates and use that as location
-Maxim- is offline   Reply With Quote

Old   March 15, 2016, 06:52
Default
  #7
Senior Member
 
AH
Join Date: Apr 2014
Posts: 282
Rep Power: 13
visitor is on a distinguished road
Well, the Point issue is resolve be assigning the Source Point with a name Point, with coordinates. But, the error message remains with Temperature; CEL error
"The following unrecognized name was referenced: Temperature.
visitor is offline   Reply With Quote

Old   March 15, 2016, 11:19
Default
  #8
Senior Member
 
Hydreaulic structures
Join Date: Sep 2012
Posts: 283
Rep Power: 14
hamidciv is on a distinguished road
I think you should use the probe function like below:

if(probe(T)@location<=300[K],7e6,0)

hope it helps
hamidciv is offline   Reply With Quote

Old   March 16, 2016, 02:06
Default
  #9
Senior Member
 
Maxim
Join Date: Aug 2015
Location: Germany
Posts: 415
Rep Power: 12
-Maxim- is on a distinguished road
Quote:
Originally Posted by visitor View Post
Well, the Point issue is resolve be assigning the Source Point with a name Point, with coordinates. But, the error message remains with Temperature; CEL error
"The following unrecognized name was referenced: Temperature.
How about you post the expression and we help you to find the error?
I mean the error message you get is pretty clear...
-Maxim- is offline   Reply With Quote

Old   March 22, 2016, 22:42
Default
  #10
Senior Member
 
AH
Join Date: Apr 2014
Posts: 282
Rep Power: 13
visitor is on a distinguished road
Hello everyone,

The following were tried, no errors were seen, also nothing happened regarding changes in water temperature.

Following expression was entered to plot temperature at the coordinate Point
(Probe(Temperature)@Point), using Monitor at Solver Output.


This expression is the thermostat, this should switch heater on.
if(Probe(Temperature)@Point <= 350[K],7e6[W m^-3],0[W m^-3])

Point was a Source Point with coordinates, renamed as Point.

Thanks
visitor is offline   Reply With Quote

Old   March 23, 2016, 16:34
Default
  #11
Super Moderator
 
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,691
Rep Power: 143
ghorrocks is just really niceghorrocks is just really niceghorrocks is just really niceghorrocks is just really nice
Have you checked what the temperature is at your point? If the temperature is >350K anyway it would not activate the heater.
ghorrocks is offline   Reply With Quote

Old   February 10, 2020, 07:23
Default
  #12
Member
 
Abdullah Arslan
Join Date: Apr 2019
Posts: 94
Rep Power: 7
Goenitz is on a distinguished road
Quote:
Originally Posted by ghorrocks View Post
Have you checked what the temperature is at your point? If the temperature is >350K anyway it would not activate the heater.
how to apply if statement for an expression to function at certain lengths
for instance Rate1=A* e^(-Eact/R/T) [mol kg^-1 s^-1]
so to active this expression from 5mm-15mm I use this:

Cond if= if(0.005<=x<=.015, Rate=Rate1,0)

P.S: Rate1 has no variable 'x' in its expression and has different units.

Following question is:

I want to use Rate for calculation of fluxes. So defining new expression (Cond if) is good or should I use this:
Rate=if(0.005<=x<=.015, Rate=A* e^(-Eact/R/T),0)
Or
Rate=if(0.005<=x<=.015, A* e^(-Eact/R/T) ,0)

Last edited by Goenitz; February 10, 2020 at 07:46. Reason: More Queries
Goenitz is offline   Reply With Quote

Old   February 10, 2020, 08:12
Default
  #13
Member
 
Abdullah Arslan
Join Date: Apr 2019
Posts: 94
Rep Power: 7
Goenitz is on a distinguished road
To overcome my problem I use this
Actually, The rate expression is like this

Rate=A* e^(-Eact/R/T)*washcoat [mol m^-2 s^-1]

where washcoat is 0.32 [g m^-2]

So I left the Rate as it is but changed the washcoat expression
washcoat=if(0.005[m]<x,0.32,0) [g m^-2]

However it doesn't allow to create expression like this:

washcoat=if(0.005[m]<x<0.015[m],0.32,0) [g m^-2]

which I really want
Goenitz is offline   Reply With Quote

Old   February 10, 2020, 08:22
Default
  #14
Member
 
Abdullah Arslan
Join Date: Apr 2019
Posts: 94
Rep Power: 7
Goenitz is on a distinguished road
I think it is solved
I used this expression
if (0.005[m]<=x&&x<=.015[m], 0.40 ,0) [g m^-2]
onurmutlu94 likes this.
Goenitz is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
How to write Expression for Transient study AK5 CFX 9 December 2, 2015 14:14
How to write an expression in CFD-POST? siamak1438 CFX 2 August 28, 2015 03:00
Time dependant pressure boundary condition yosuke1984 OpenFOAM Verification & Validation 3 May 6, 2015 06:16
write an expression Cecco CFX 3 June 19, 2012 16:59
How to write the boundary condition for round free jet Jason Main CFD Forum 8 July 26, 1999 16:15


All times are GMT -4. The time now is 04:56.