-
Notifications
You must be signed in to change notification settings - Fork 1
/
02_rankine_cycle.py
124 lines (97 loc) · 3.79 KB
/
02_rankine_cycle.py
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@date: 14 December 2020 (update)
This source code is provided by Richard J Smith 'as is' and 'with all faults'. The provider makes no
representations or warranties of any kind concerning the safety, suitability, inaccuracies,
typographical errors, or other harmful components of this software.
"""
import matplotlib.pyplot as plt
import numpy as np
from pyXSteam.XSteam import XSteam
steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS)
print('Rankine cycle analysis')
p1 = 0.1
s1 = steamTable.sL_p(p1)
T1 = steamTable.t_ps(p1, s1)
h1 = steamTable.hL_p(p1)
print('\nPoint 1')
print(f"p1: {round(float(p1),1)} bar")
print(f"T1: {round(float(T1),1)} degC")
print(f"H1: {round(float(h1),1)} kJ/kg")
print(f"S1: {round(float(s1),3)} kJ/kg K")
p2 = 150
s2 = s1
v = 1/steamTable.rhoL_p(p1)
w_p = v*(p2-p1)
print('\nPoint 2')
h2 = h1+w_p
print(f"H2: {round(float(h2),1)} kJ/kg")
T2 = steamTable.t_ph(p2, h2)
print(f"T2: {round(float(T2),1)} degC")
h2dash = steamTable.hL_p(p2)
s2dash = steamTable.sL_p(p2)
T2dash = steamTable.t_ph(p2, h2dash)
print('\nPoint 2dash')
print(f"H2dash: {round(float(h2dash),1)} kJ/kg")
print(f"S2dash: {round(float(s2dash),3)} kJ/kg K")
print(f"T2dash: {round(float(T2dash),1)} degC")
p3 = p2
h3 = steamTable.hV_p(p2)
s3 = steamTable.sV_p(p2)
T3 = T2dash
print('\nPoint 3')
print(f"P3: {round(float(p3),1)} bar")
print(f"T3: {round(float(T3),1)} degC")
print(f"H3: {round(float(h3),1)} kJ/kg")
print(f"S3: {round(float(s3),3)} kJ/kg K")
p4 = p1
s4 = s3
T4 = steamTable.t_ps(p4, s4)
x4 = steamTable.x_ps(p4, s4)
h4 = steamTable.h_px(p4, x4)
print('\nPoint 4')
print(f"P4: {round(float(p4),1)} bar")
print(f"T4: {round(float(T4),1)} degC")
print(f"H4: {round(float(h4),1)} kJ/kg")
print(f"S4: {round(float(s4),3)} kJ/kg K")
print(f"x4: {round(float(x4),2)} ")
print('\nSummary')
print(f"Work required by pump: {round(float(w_p),1)} kJ/kg")
w_HPt = h3-h4
print(f"Work generated by turbine: {round(float(w_HPt),1)} kJ/kg")
q_H = (h3-h2)
print(f"Heat input by boiler: {round(float(q_H),1)} kJ/kg")
q_L = h4-h1
print(f"Heat rejected by the condenser: {round(float(q_L),1)} kJ/kg")
eta_th = (w_HPt-w_p)/q_H*100
print(f"Thermal efficiency is: {round(float(eta_th),1)}%")
HRcycle = 3600*100/eta_th
print(f"HR rankine cycle: {round(float(HRcycle),1)} kJ/kWh")
font = {'family' : 'Times New Roman',
'size' : 22}
plt.figure(figsize=(15,10))
plt.title('T-s Diagram - Rankine Cycle (Ideal)')
plt.rc('font', **font)
plt.ylabel('Temperature (C)')
plt.xlabel('Entropy (s)')
plt.xlim(-2,10)
plt.ylim(0,600)
T = np.linspace(0, 373.945, 400) # range of temperatures
# saturated vapor and liquid entropy lines
svap = [s for s in [steamTable.sL_t(t) for t in T]]
sliq = [s for s in [steamTable.sV_t(t) for t in T]]
plt.plot(svap, T, 'b-', linewidth=2.0)
plt.plot(sliq, T, 'r-', linewidth=2.0)
plt.plot([s1, s2, s2dash, s3, s4, s1],[T1, T2, T2dash, T3, T4, T1], 'black', linewidth=2.0)
plt.text(s1-.1,T1,f'(1)\nT = {round(float(T1),2)} C\nP = {round(float(p1),1)} bar \nh = {round(float(h1),1)} kJ/kg\n s = {round(float(s1),3)} kJ/kgK',
ha='right',backgroundcolor='white')
plt.text(1.6,60,f'(2)\nT = {round(float(T2),2)} C\nP = {round(float(p2),1)} bar \nh = {round(float(h2),1)} kJ/kg',
ha='left',backgroundcolor='white')
plt.text(s2dash-.15,T2dash,f"(2')\nT = {round(float(T2dash),2)} C\nP = {round(float(p2),1)} bar\nh = {round(float(h2dash),1)} kJ/kg \ns = {round(float(s2dash),3)} kJ/kgK",
ha='right',backgroundcolor='white')
plt.text(s3+.1,T3,f"(3)\nh = {round(float(h3),1)} kJ/kg \ns = {round(float(s3),3)} kJ/kgK",
ha='left',backgroundcolor='white')
plt.text(s4+.1,T4,f'(4)\nT = {round(float(T4),2)} C\nh = {round(float(h4),1)} kJ/kg \ns = {round(float(s4),3)} kJ/kgK \nx = {round(float(x4),3)}',
ha='left',backgroundcolor='white')
plt.savefig('02-rankine-cycle-TSdiagram.png')