jjgomera/iapws

Region 3 problem

Closed this issue · 4 comments

jH44 commented

There is still a bug in region 3 in the two-phases area (Px and Tx), at least for the specific volume (was trying to plot a P-v diagram for students).
You search rho from P,T without considering the value of x ! (iapws97.py, around line 2877, version 1.2.2)
but rho(x=0) is not equal to rho(x=1) !!
I think you need to search rho on both sides of P(T) and : rho = x_rho1+(1.-x)_rho2

Anyway thanks for your work.

Hi,
P-v isn't implemented as input parameters.
I don't know where the problem you say, obviously liquid rho and vapor rho isn't equal in a two phase state, the procedure use same P and T input but using different equation, Region1 for liquid and Region2 for vapor:

        elif self._thermo == "Px":
            P, x = args
            T = _TSat_P(P)
            if Pt <= P <= Pc and 0 < x < 1:
                propiedades = _Region4(P, x)
            elif P > Ps_623 and x in (0, 1):
                rho = 1./_Backward3_v_PT(P, T)
                propiedades = _Region3(rho, T)
            elif x == 0:
                propiedades = _Region1(T, P)
            elif x == 1:
                propiedades = _Region2(T, P)

I need a sample failed calculation to check the bug

jH44 commented

Hello,
i wanted to plot the "academic" saturated liquid and vapor lines on a P-v diagram
with the code below. The lines are ok except in region 3 ... (region 1 & 2 fines)

from iapws import IAPWS97
import numpy as np
import matplotlib.pyplot as plt

P = np.linspace(0.1,22.064,100)
vvap = [v.v for v in [IAPWS97(P=p, x=1) for p in P]]
vliq = [v.v for v in [IAPWS97(P=p, x=0) for p in P]]
plt.plot(vvap, P, 'r--', linewidth=2.0)
plt.plot(vliq, P, 'b--', linewidth=2.0)
plt.xlim(0.,0.05)

When i use "Px" as input parameters i am in the two-phase region (or on one of the saturated lines). The problem is that, in region 3, you try to find (backward) rho only with P and T, but the answer does depend on x (P and T are tied together by T = _TSat_P(P)).

To have correct saturated lines in my P-v diagram, i replaced

elif P > Ps_623 and x in (0, 1):
                rho = 1./_Backward3_v_PT(P, T)  
                propiedades = _Region3(rho, T)

with this ugly hack :

elif P > Ps_623 and x in (0, 1):
                #rho = 1./_Backward3_v_PT(P, T)
                rho1 = 1./_Backward3_v_PT(P, T+1e-5)
                rho2 = 1./_Backward3_v_PT(P, T-1e-5)
                rho = x*rho1+(1.-x)*rho2
                propiedades = _Region3(rho, T)

And it worked ...

hi, you're right, i've fixed but I don't have internet conection to upload
the commit.

Hello,
i wanted to plot the "academic" saturated liquid and vapor lines on a P-v
diagram
with the code below. The lines are ok except in region 3 ... (region 1 & 2
fines)

from iapws import IAPWS97
import numpy as np
import matplotlib.pyplot as plt

P = np.linspace(0.1,22.064,100)
vvap = [v.v for v in [IAPWS97(P=p, x=1) for p in P]]
vliq = [v.v for v in [IAPWS97(P=p, x=0) for p in P]]
plt.plot(vvap, P, 'r--', linewidth=2.0)
plt.plot(vliq, P, 'b--', linewidth=2.0)
plt.xlim(0.,0.05)

When i use "Px" as input parameters i am in the two-phase region (or on one
of the saturated lines). The problem is that, in region 3, you try to find
(backward) rho only with P and T, but the answer does depend on x (P and T
are tied together by T = _TSat_P(P)).

To have correct saturated lines in my P-v diagram, i replaced

elif P > Ps_623 and x in (0, 1):
rho = 1./_Backward3_v_PT(P, T)
propiedades = _Region3(rho, T)

with this ugly hack :

elif P > Ps_623 and x in (0, 1):
#rho = 1./_Backward3_v_PT(P, T)
rho1 = 1./_Backward3_v_PT(P, T+1e-5)
rho2 = 1./_Backward3_v_PT(P, T-1e-5)
rho = x_rho1+(1.-x)_rho2
propiedades = _Region3(rho, T)

And it worked ...


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#19 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ABoZ08t6adaszgF17E_KXoNqtTCslDCWks5qaTYmgaJpZM4JXOcq
.

Hi, solved, I think, with last commit