Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
If Condition evaluation?
Posted 2017年7月13日 GMT-4 04:13 1 Reply
Please login with a confirmed email address before reporting spam
Hey there,
I am struggling with the evaluation of if conditions within COMSOL.
I have an equation that shall be evaluated if x is between 0 and 1. Say:
y = f(x) * (0<x<1)
Assuming x is between 0 and 1, the expression (0<x<1) should be evaluated as 1, shouldn´t it? But it is not. COMSOL evaluates the if condition as 0. Hence, COMSOL returns y=0, which is not correct.
I also tried it this way:
y = f(x) * (0<x) * (x<1)
Here both if conditions are evaluated as 1, resulting in the correct solution y = f(x).
I monitored the values of the if expressions with Point Probe Expressions during the calculation procedure.
Why is there a difference in the evaluation of the same if conditions?
Thanks for your effort!
I am struggling with the evaluation of if conditions within COMSOL.
I have an equation that shall be evaluated if x is between 0 and 1. Say:
y = f(x) * (0<x<1)
Assuming x is between 0 and 1, the expression (0<x<1) should be evaluated as 1, shouldn´t it? But it is not. COMSOL evaluates the if condition as 0. Hence, COMSOL returns y=0, which is not correct.
I also tried it this way:
y = f(x) * (0<x) * (x<1)
Here both if conditions are evaluated as 1, resulting in the correct solution y = f(x).
I monitored the values of the if expressions with Point Probe Expressions during the calculation procedure.
Why is there a difference in the evaluation of the same if conditions?
Thanks for your effort!
1 Reply Last Post 2017年7月13日 GMT-4 05:24