Skip to content

Compute an exact pressure loss in a vessel #543

Answered by fwitte
rafaelmarqferreira asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @rafaelmarqferreira and thank you for updating.

I think you could also do a simple Newton search instead:

from CoolProp.CoolProp import PropsSI


h_target = 214140.6804
p = 13e5
d = 1e-3

while True:
    residual = h_target - PropsSI("H", "P", p, "Q", 0, "R32")
    derivative = ((-PropsSI("H", "P", p + d, "Q", 0, "R32")) - (-PropsSI("H", "P", p - d, "Q", 0, "R32"))) / (2 * d)
    p -= residual / derivative
    if abs(residual) < 1e-3:
        break

print(p)

1042459.6668

Best!

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fwitte
Comment options

Answer selected by rafaelmarqferreira
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants