cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X

Solving a function: unable to evaluate a conditional expression

S�_10758012
2-Explorer

Solving a function: unable to evaluate a conditional expression

Hello 

I am working on my bachelors project. 

I have made a function that calculate the heat recovery in a heat exchanger with a faze change (condensation). The function calculates the potential heat recovery based on the temperature that comes out of the heat exchangers hot side.

 

The function works fine but i can not get it to solve the function, so i can calculate the temperature based on the heat energy.

 

Does anyone know how to solve this or the reason for the error? 

 image.png

ACCEPTED SOLUTION

Accepted Solutions

The symbolic 'solve' can't deal with functions using conditionals (if/else). Reason is that it first tries to solve the equation symbolically, without specific values but doing so it can't decide which symbolic variable is larger than the other.
It may be possible to rewrite the function using the Heaviside step function instead of the conditional if/else, but thats some work and makes the function sure more unclear for the reader.

But a symbolic solution is not necessary anyway because you are just looking for a numeric value. So I would suggest using one of Primes numeric methods. That's either a solve block with "find" or the usage of the "root" function in one of its two 'flavors'.

It also may be beneficial to plot the function to see where to expect the solution.

Werner_E_0-1728993527624.png

Of course you could also use "root" in its second variant using the guess value 40

Werner_E_1-1728993763854.png

Of course you may also use T.l.4.1 throughout instead of T, I just was lazy 😉

And here for completeness sake the calculation done with a solve block

Werner_E_2-1728993986139.png

 

Prime 10 sheet attached

 

View solution in original post

2 REPLIES 2

The symbolic 'solve' can't deal with functions using conditionals (if/else). Reason is that it first tries to solve the equation symbolically, without specific values but doing so it can't decide which symbolic variable is larger than the other.
It may be possible to rewrite the function using the Heaviside step function instead of the conditional if/else, but thats some work and makes the function sure more unclear for the reader.

But a symbolic solution is not necessary anyway because you are just looking for a numeric value. So I would suggest using one of Primes numeric methods. That's either a solve block with "find" or the usage of the "root" function in one of its two 'flavors'.

It also may be beneficial to plot the function to see where to expect the solution.

Werner_E_0-1728993527624.png

Of course you could also use "root" in its second variant using the guess value 40

Werner_E_1-1728993763854.png

Of course you may also use T.l.4.1 throughout instead of T, I just was lazy 😉

And here for completeness sake the calculation done with a solve block

Werner_E_2-1728993986139.png

 

Prime 10 sheet attached

 

Thank you very much, this solved my issue.

Announcements

Top Tags