|
[Sponsors] |
How to write an expression with an if condition statment? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
February 23, 2016, 23:49 |
How to write an expression with an if condition statment?
|
#1 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
February 24, 2016, 03:13 |
|
#2 |
Member
Join Date: Jan 2016
Posts: 34
Rep Power: 10 |
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) |
|
February 24, 2016, 04:23 |
|
#3 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
February 24, 2016, 06:09 |
|
#4 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,872
Rep Power: 144 |
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. |
|
March 14, 2016, 06:24 |
|
#5 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
March 14, 2016, 06:31 |
|
#6 |
Senior Member
Maxim
Join Date: Aug 2015
Location: Germany
Posts: 413
Rep Power: 13 |
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
|
|
March 15, 2016, 07:52 |
|
#7 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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. |
|
March 15, 2016, 12:19 |
|
#8 |
Senior Member
Hydreaulic structures
Join Date: Sep 2012
Posts: 283
Rep Power: 15 |
I think you should use the probe function like below:
if(probe(T)@location<=300[K],7e6,0) hope it helps |
|
March 16, 2016, 03:06 |
|
#9 | |
Senior Member
Maxim
Join Date: Aug 2015
Location: Germany
Posts: 413
Rep Power: 13 |
Quote:
I mean the error message you get is pretty clear... |
||
March 22, 2016, 23:42 |
|
#10 |
Senior Member
AH
Join Date: Apr 2014
Posts: 287
Rep Power: 0 |
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 |
|
March 23, 2016, 17:34 |
|
#11 |
Super Moderator
Glenn Horrocks
Join Date: Mar 2009
Location: Sydney, Australia
Posts: 17,872
Rep Power: 144 |
Have you checked what the temperature is at your point? If the temperature is >350K anyway it would not activate the heater.
|
|
February 10, 2020, 08:23 |
|
#12 | |
Member
Abdullah Arslan
Join Date: Apr 2019
Posts: 94
Rep Power: 7 |
Quote:
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 08:46. Reason: More Queries |
||
February 10, 2020, 09:12 |
|
#13 |
Member
Abdullah Arslan
Join Date: Apr 2019
Posts: 94
Rep Power: 7 |
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 |
|
February 10, 2020, 09:22 |
|
#14 |
Member
Abdullah Arslan
Join Date: Apr 2019
Posts: 94
Rep Power: 7 |
I think it is solved
I used this expression if (0.005[m]<=x&&x<=.015[m], 0.40 ,0) [g m^-2] |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to write Expression for Transient study | AK5 | CFX | 9 | December 2, 2015 15:14 |
How to write an expression in CFD-POST? | siamak1438 | CFX | 2 | August 28, 2015 04:00 |
Time dependant pressure boundary condition | yosuke1984 | OpenFOAM Verification & Validation | 3 | May 6, 2015 07:16 |
write an expression | Cecco | CFX | 3 | June 19, 2012 17:59 |
How to write the boundary condition for round free jet | Jason | Main CFD Forum | 8 | July 26, 1999 17:15 |