[go: up one dir, main page]

Menu

[81dbcb]: / dev / Tickets / 870.py  Maximize  Restore  History

Download this file

74 lines (63 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import numpy as np
import CoolProp
import matplotlib.pyplot as plt
AS = CoolProp.AbstractState('HEOS','Water')
steps = 100
# Saturated liquid
AS.update(CoolProp.PQ_INPUTS, 101325, 0)
Ts = AS.T()
h_fg = AS.saturated_vapor_keyed_output(CoolProp.iHmass) - AS.saturated_liquid_keyed_output(CoolProp.iHmass)
cl = AS.cpmass()
# Subcooled liquid
x, y = [], []
for T in np.linspace(Ts - 30, Ts - 0.1, steps):
AS.update(CoolProp.PT_INPUTS, 101325, T)
x.append(-cl*(Ts-T)/h_fg)
y.append(AS.first_partial_deriv(CoolProp.iDmass, CoolProp.iHmass, CoolProp.iP))
plt.plot(x, y, label = 'Subcooled', color = 'gray')
# Two-phase derivatives (splined)
x, y1 = [], []
for Q in np.linspace(0, 0.3, steps):
AS.update(CoolProp.PQ_INPUTS, 101325, Q)
x.append(AS.Q())
y1.append(AS.first_two_phase_deriv_splined(CoolProp.iDmass, CoolProp.iHmass, CoolProp.iP, 0.3))
plt.plot(x, y1, label = 'Two-phase (splined)')
# Two-phase derivatives (normal)
x, y1 = [], []
for Q in np.linspace(0.0, 0.6, steps):
AS.update(CoolProp.PQ_INPUTS, 101325, Q)
x.append(AS.Q())
y1.append(AS.first_two_phase_deriv(CoolProp.iDmass, CoolProp.iHmass, CoolProp.iP))
plt.plot(x, y1, label = 'Two-phase (normal)')
AS = CoolProp.AbstractState('TTSE&HEOS','Water')
# Two-phase derivatives (splined, tabular)
x, y1 = [], []
for Q in np.linspace(0, 0.3, steps):
AS.update(CoolProp.PQ_INPUTS, 101325, Q)
x.append(AS.Q())
try:
y1.append(AS.first_two_phase_deriv_splined(CoolProp.iDmass, CoolProp.iHmass, CoolProp.iP, 0.3))
except Exception as e:
print(e)
y1.append(np.NAN)
break
plt.plot(x, y1, label = 'Two-phase (splined, tabular)', ls = '--', lw = 3)
# Two-phase derivatives (normal, tabular)
x, y1 = [], []
for Q in np.linspace(0.0, 0.6, steps):
AS.update(CoolProp.PQ_INPUTS, 101325, Q)
x.append(AS.Q())
try:
y1.append(AS.first_two_phase_deriv(CoolProp.iDmass, CoolProp.iHmass, CoolProp.iP))
except Exception as e:
print(e)
y1.append(np.NAN)
break
plt.plot(x, y1, label = 'Two-phase (normal, tabular)', ls = '--', lw = 3)
plt.title(r'$d\rho/dh|p$')
plt.xlabel('vapor quality (-)')
plt.ylabel(r'$d\rho/dh|p$')
plt.ylim(-0.005, 0.005)
plt.legend(loc='best')
plt.savefig('870_test_two_phase_tabular.png')
plt.show()