How to write an expression with an if condition statment?
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 |
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) |
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 |
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. |
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 |
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
|
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. |
I think you should use the probe function like below:
if(probe(T)@location<=300[K],7e6,0) hope it helps |
Quote:
I mean the error message you get is pretty clear... |
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 |
Have you checked what the temperature is at your point? If the temperature is >350K anyway it would not activate the heater.
|
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) |
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 |
I think it is solved
I used this expression if (0.005[m]<=x&&x<=.015[m], 0.40 ,0) [g m^-2] |
All times are GMT -4. The time now is 17:21. |