Finding a Temperature with Root, Solve or FindRoot Using CoolProp

Finding a Temperature with Root, Solve or FindRoot Using CoolProp - Mathcad Solve Block - Messages

#1 Posted: 3/30/2022 10:20:10 AM
Erick Valentino

Erick Valentino

7 likes in 28 posts.

Group: User

Hi, it's me again XD

I try to find the value of a temperature that when replacing it in an equation the result is 0 KJ/Kg. I have already done things like this, where I propose a temperature or pressure and with the "Root" or "Solve" command I get the result, however this time I am using CoolProp instead of equations of state and polynomials, I don't know if that affects, you know by the units and things like that... does anyone know how to do it?
I already tried with a mathcad solve block although I think I'm not using it well, approximately the temperature is around 294.2 K, it would be great if this can be done with a "Root", "Solve", or "FindRoot" so as not to have to do it with a Newton Raphson

thank you very much for reading me


Cooling Towers with SMath Studio E1.sm (65 KiB) downloaded 44 time(s).

[albumimg]1666[/albumimg]
#2 Posted: 3/30/2022 2:12:50 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: User

Hola Valentino. The nonlinear plugin solvers don't work because they can't get the derivative of the function. SMath's diff function does not work on functions defined in plugins, in this case coolprop. You can see that in this post: https://en.smath.com/forum/yaf_postst12504_Uneval.aspx

To get the root you need to implement your own pure numerical solver or use al_nleqsolve.

img.jpg

Cooling Towers with SMath Studio E1.sm (69 KiB) downloaded 39 time(s).

Best regards.
Alvaro.

PD: It's a bit awkward having to define f(T) as a 1x1 matrix, while accepting guess as a scalar. I think that an interesting improvement in al_nleqsolve could be to accept scalar functions for the case of a single variable, and also return the result as a scalar, and not a 1x1 vector.

Of course, preserving the possibility that
You really want to solve a 1x1 system, recognizing it as such because f is a matrix.
#3 Posted: 3/30/2022 2:32:32 PM
Вячеслав Мезенцев

Вячеслав Мезенцев

1402 likes in 1708 posts.

Group: Moderator

First, the frame must completely cover the expressions. This needs to be checked. Secondly, it is desirable to make sure that the solver works without a block.

2022-03-30 Block.png

Here is a possible bug in the program.

File not found. File not found.

Wrote

PD: It's a bit awkward having to define f(T) as a 1x1 matrix, while accepting guess as a scalar. I think that an interesting improvement in al_nleqsolve could be to accept scalar functions for the case of a single variable, and also return the result as a scalar, and not a 1x1 vector.


Someday it will also work with block.
Russia ☭ forever, Viacheslav N. Mezentsev
1 users liked this post
Alvaro Diaz Falconi 3/30/2022 2:42:00 PM
#4 Posted: 3/31/2022 8:47:04 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

I try to find the value of a temperature that when replacing it in an equation ...


If you can tabulate that curve on the image,
it might be possible to approximate with a function.
If so from possible approximation, solution will be
more general and immediate from maple/solve
thus no more need for solver bloc.
Cheers ... Jean

#5 Posted: 3/31/2022 1:54:37 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Here is a support example ...
The dual solver from undocumented root is exceptional
Per say: from measured Ω evaluate °C
from user ranged [min °C ... max °C] calibrated Ω XTR

Inst_IAPWS region 1 Solve Entropy Saturation.sm (37 KiB) downloaded 35 time(s).
  • New Posts New Posts
  • No New Posts No New Posts