def demo_generate_ph_Diagramm(path=None, precision=1.0): '''Generate a p(h) Diagramm showing the Saturation Line''' steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) p_krit = steamTable.criticalPressure( ) - 0.0001 # minus 0.0001 or else hL_V returns NaN h_krit = steamTable.hL_p(p_krit) p = np.arange(0.0, 1000, precision) p2 = np.arange(0.5, p_krit, precision) vaporFrac = np.arange(0.1, 1.0, 0.1) h = np.arange(200.0, 4500.0, 100.0) rho = np.arange(1, 15.0, precision * 2) nph_px = np.frompyfunc(steamTable.h_px, 2, 1) nph_pt = np.frompyfunc(steamTable.h_pt, 2, 1) nphL_p = np.frompyfunc(steamTable.hL_p, 1, 1) nphV_p = np.frompyfunc(steamTable.hV_p, 1, 1) npp_hrho = np.frompyfunc(steamTable.p_hrho, 2, 1) # Siede und Taulinie hL = nphL_p(p) hV = nphV_p(p) # Dampfgehalt for vf in vaporFrac: h_px = nph_px(p2, vf) line, = pyplot.plot(h_px, p2) pyplot.setp(line, linewidth=1, color='g') # Temperatur for temp in range(0, 900, 30): h_pt = nph_pt(p, temp) line, = pyplot.plot(h_pt, p) pyplot.setp(line, linewidth=1, color='r') # Dichte for r in rho: p_hrho = npp_hrho(h, r) line, = pyplot.plot(h, p_hrho) pyplot.setp(line, linewidth=1, color='y') # Kritischer Punkt pyplot.plot([h_krit], [p_krit], marker='s', mfc='k', ms=8) line1, = pyplot.plot(hL, p) line2, = pyplot.plot(hV, p) pyplot.xlabel("h in [kJ/kg]") pyplot.ylabel("p in [bar]") pyplot.setp(line1, linewidth=2, color='b') pyplot.setp(line2, linewidth=2, color='r') pyplot.yscale('log') pyplot.grid() if path == None: pyplot.show() else: pyplot.savefig(path, bbox_inches='tight')
def demo_simpel_Values(): steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) # get saturated liquid enthalpy for a preasure of 220 bar print('hV_p(220.0) =', steamTable.hL_p(220.0)) # get saturated vapour enthalpy for a preasure of 220 bar print('hV_p(220.0) =', steamTable.hV_p(220.0)) print('tcL_p(1.0) =', steamTable.tcL_p(1.0)) print('tcL_t(25.0) =', steamTable.tcL_t(25.0)) print('tcV_p(1.0) =', steamTable.tcV_p(1.0)) print('tcL_t(25.0) =', steamTable.tcV_t(25.0)) print('tc_hs(100.0, 0.34) =', steamTable.tc_hs(100.0, 0.34)) print('tc_ph(1.0, 100.0) =', steamTable.tc_ph(1.0, 100.0)) print('tc_pt(1.0, 25.0) =', steamTable.tc_pt(1.0, 25.0)) print('w_ps(1.0, 1.0) =', steamTable.w_ps(1.0, 1.0))
def demo_simpel_Values(): steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) # get saturated liquid enthalpy for a preasure of 220 bar print('hV_p(220.0) =', steamTable.hL_p(220.0)) # get saturated vapour enthalpy for a preasure of 220 bar print('hV_p(220.0) =', steamTable.hV_p(220.0)) print('tcL_p(1.0) =', steamTable.tcL_p(1.0)) print('tcL_t(25.0) =', steamTable.tcL_t(25.0)) print('tcV_p(1.0) =', steamTable.tcV_p(1.0)) print('tcL_t(25.0) =', steamTable.tcV_t(25.0)) print('tc_hs(100.0, 0.34) =', steamTable.tc_hs(100.0, 0.34)) print('tc_ph(1.0, 100.0) =', steamTable.tc_ph(1.0, 100.0)) print('tc_pt(1.0, 25.0) =', steamTable.tc_pt(1.0, 25.0)) print('w_ps(1.0, 1.0) =', steamTable.w_ps(1.0, 1.0))
def demo_generate_ph_diagramm(path=None, precision=1.0): """Generate a p(h) Diagram showing the Saturation Line""" steam_table = XSteam(XSteam.UNIT_SYSTEM_MKS) p_krit = (steam_table.criticalPressure() - 0.0001 ) # minus 0.0001 or else hL_V returns NaN h_krit = steam_table.hL_p(p_krit) p = np.arange(0.0, 1000, precision) p2 = np.arange(0.5, p_krit, precision) vapor_fraction = np.arange(0.1, 1.0, 0.1) h = np.arange(200.0, 4500.0, 100.0) rho = np.arange(1, 15.0, precision * 2) nph_px = np.frompyfunc(steam_table.h_px, 2, 1) nph_pt = np.frompyfunc(steam_table.h_pt, 2, 1) nphL_p = np.frompyfunc(steam_table.hL_p, 1, 1) nphV_p = np.frompyfunc(steam_table.hV_p, 1, 1) npp_hrho = np.frompyfunc(steam_table.p_hrho, 2, 1) # boiling and dew lines hL = nphL_p(p) hV = nphV_p(p) # vapor fraction for vf in vapor_fraction: h_px = nph_px(p2, vf) pyplot.plot(h_px, p2, linewidth=1, color="g") # temperature for temp in range(0, 900, 30): h_pt = nph_pt(p, temp) pyplot.plot(h_pt, p, linewidth=1, color="r") # density for r in rho: p_hrho = npp_hrho(h, r) pyplot.plot(h, p_hrho, linewidth=1, color="y") # critical point pyplot.plot([h_krit], [p_krit], marker="s", mfc="k", ms=8) (line1, ) = pyplot.plot(hL, p, linewidth=2, color="b") (line2, ) = pyplot.plot(hV, p, linewidth=2, color="r") pyplot.xlabel("h in [kJ/kg]") pyplot.ylabel("p in [bar]") pyplot.yscale("log") pyplot.grid() if path is None: pyplot.show() else: pyplot.savefig(path, bbox_inches="tight")
def demo_simpel_values(): """calculate values and print the results""" steam_table = XSteam(XSteam.UNIT_SYSTEM_MKS) # get saturated liquid enthalpy for a preasure of 220 bar print("hV_p(220.0) =", steam_table.hL_p(220.0)) # get saturated vapour enthalpy for a preasure of 220 bar print("hV_p(220.0) =", steam_table.hV_p(220.0)) print("tcL_p(1.0) =", steam_table.tcL_p(1.0)) print("tcL_t(25.0) =", steam_table.tcL_t(25.0)) print("tcV_p(1.0) =", steam_table.tcV_p(1.0)) print("tcL_t(25.0) =", steam_table.tcV_t(25.0)) print("tc_hs(100.0, 0.34) =", steam_table.tc_hs(100.0, 0.34)) print("tc_ph(1.0, 100.0) =", steam_table.tc_ph(1.0, 100.0)) print("tc_pt(1.0, 25.0) =", steam_table.tc_pt(1.0, 25.0)) print("w_ps(1.0, 1.0) =", steam_table.w_ps(1.0, 1.0))
def demo_generate_ph_Diagramm(path=None, precision=1.0): '''Generate a p(h) Diagramm showing the Saturation Line''' steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) p_krit = steamTable.criticalPressure() - 0.0001 # minus 0.0001 or else hL_V returns NaN h_krit = steamTable.hL_p(p_krit) p = np.arange(0.0, 1000, precision) p2 = np.arange(0.5, p_krit, precision) vaporFrac = np.arange(0.1, 1.0, 0.1) h = np.arange(200.0, 4500.0, 100.0) rho = np.arange(1, 15.0, precision * 2) nph_px = np.frompyfunc(steamTable.h_px, 2, 1) nph_pt = np.frompyfunc(steamTable.h_pt, 2, 1) nphL_p = np.frompyfunc(steamTable.hL_p, 1, 1) nphV_p = np.frompyfunc(steamTable.hV_p, 1, 1) npp_hrho = np.frompyfunc(steamTable.p_hrho, 2, 1) # Siede und Taulinie hL = nphL_p(p) hV = nphV_p(p) # Dampfgehalt for vf in vaporFrac: h_px = nph_px(p2, vf) line, = pyplot.plot(h_px, p2) pyplot.setp(line, linewidth=1, color='g') # Temperatur for temp in range(0, 900, 30): h_pt = nph_pt(p, temp) line, = pyplot.plot(h_pt, p) pyplot.setp(line, linewidth=1, color='r') # Dichte for r in rho: p_hrho = npp_hrho(h, r) line, = pyplot.plot(h, p_hrho) pyplot.setp(line, linewidth=1, color='y') # Kritischer Punkt pyplot.plot([h_krit], [p_krit], marker='s', mfc='k', ms=8) line1, = pyplot.plot(hL, p) line2, = pyplot.plot(hV, p) pyplot.xlabel("h in [kJ/kg]") pyplot.ylabel("p in [bar]") pyplot.setp(line1, linewidth=2, color='b') pyplot.setp(line2, linewidth=2, color='r') pyplot.yscale('log') pyplot.grid() if path is None: pyplot.show() else: pyplot.savefig(path, bbox_inches='tight')
def get_trace_result(input_data): base_data = {} pipe_data = {} for i in input_data[0]: base_data[i['name']] = i['value'] steam_pressure = float(base_data['steam_pressure']) TT = float(base_data['steam_temp']) Tamb = float(base_data['amb_temp']) wv = float(base_data['wind_velocity']) for i in input_data[1]: if i['class'] in pipe_data: pipe_data[i['class']][next(iter(i))] = i[next(iter(i))] else: pipe_data[i['class']] = {next(iter(i)): i[next(iter(i))]} for i, j in pipe_data.items(): TP = float(j['maintain_temp']) NPS = float(j['pipe_dia']) INS = float(j['insulation_thickness']) ins_type = j['insulation_type'] pipe_length = float(j['pipe_length']) trace = get_trace_calc(TP, TT, Tamb, NPS, ins_type, INS, wv)[1] heat_loss = get_trace_calc(TP, TT, Tamb, NPS, ins_type, INS, wv)[0] pipe_data[i]['trace'] = trace pipe_data[i]['heat_loss'] = round(heat_loss, 3) steamTable = XSteam(XSteam.UNIT_SYSTEM_FLS) h = steamTable.hV_p(steam_pressure + 14.696) - steamTable.hL_p(steam_pressure + 14.696) #check pipe_data[i]['steam_require'] = round((pipe_length * heat_loss / h), 3) tracer_length = get_tracer_length(steam_pressure, trace) pipe_data[i]['tracer_length'] = tracer_length return pipe_data
class FLS_FunctionTester(unittest.TestCase): def setUp(self): self.maxError = 1E-6 self.steamTable = XSteam(XSteam.UNIT_SYSTEM_FLS) def tearDown(self): pass def test_tsat_p(self): error = self.steamTable.tsat_p(1.0) - 99.60591861 self.assertLess( error, self.maxError, 'tsat_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_t_ph(self): error = self.steamTable.t_ph(1.0, 100.0) - 23.84481908 self.assertLess( error, self.maxError, 't_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_t_ps(self): error = self.steamTable.t_ps(1.0, 1.0) - 73.70859421 self.assertLess( error, self.maxError, 't_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_t_hs(self): error = self.steamTable.t_hs(100.0, 0.2) - 13.84933511 self.assertLess( error, self.maxError, 't_hs not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_psat_t(self): error = self.steamTable.psat_t(100.0) - 1.014179779 self.assertLess( error, self.maxError, 'psat_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_p_hs(self): error = self.steamTable.p_hs(84.0, 0.296) - 2.295498269 self.assertLess( error, self.maxError, 'p_hs not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_hV_p(self): error = self.steamTable.hV_p(1.0) - 2674.949641 self.assertLess( error, self.maxError, 'hV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_hL_p(self): error = self.steamTable.hL_p(1.0) - 417.4364858 self.assertLess( error, self.maxError, 'hL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_hV_t(self): error = self.steamTable.hV_t(100.0) - 2675.572029 self.assertLess( error, self.maxError, 'hV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_hL_t(self): error = self.steamTable.hL_t(100.0) - 419.099155 self.assertLess( error, self.maxError, 'hL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_h_pt(self): error = self.steamTable.h_pt(1.0, 20.0) - 84.01181117 self.assertLess( error, self.maxError, 'h_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_h_ps(self): error = self.steamTable.h_ps(1.0, 1.0) - 308.6107171 self.assertLess( error, self.maxError, 'h_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_h_px(self): error = self.steamTable.h_px(1.0, 0.5) - 1546.193063 self.assertLess( error, self.maxError, 'h_px not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_h_prho(self): error = self.steamTable.h_prho(1.0, 2.0) - 1082.773391 self.assertLess( error, self.maxError, 'h_prho not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_h_tx(self): error = self.steamTable.h_tx(100.0, 0.5) - 1547.33559211 self.assertLess( error, self.maxError, 'h_tx not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_vV_p(self): error = self.steamTable.vV_p(1.0) - 1.694022523 self.assertLess( error, self.maxError, 'vV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_vL_p(self): error = self.steamTable.vL_p(1.0) - 0.001043148 self.assertLess( error, self.maxError, 'vL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_vV_t(self): error = self.steamTable.vV_t(100.0) - 1.671860601 self.assertLess( error, self.maxError, 'vV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_vL_t(self): error = self.steamTable.vL_t(100.0) - 0.001043455 self.assertLess( error, self.maxError, 'vL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_v_pt(self): error = self.steamTable.v_pt(1.0, 100.0) - 1.695959407 self.assertLess( error, self.maxError, 'v_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_v_ph(self): error = self.steamTable.v_ph(1.0, 1000.0) - 0.437925658 self.assertLess( error, self.maxError, 'v_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_v_ps(self): error = self.steamTable.v_ps(1.0, 5.0) - 1.03463539 self.assertLess( error, self.maxError, 'v_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_rhoV_p(self): error = self.steamTable.rhoV_p(1.0) - 0.590310924 self.assertLess( error, self.maxError, 'rhoV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_rhoL_p(self): error = self.steamTable.rhoL_p(1.0) - 958.6368897 self.assertLess( error, self.maxError, 'rhoL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_rhoV_t(self): error = self.steamTable.rhoV_t(100.0) - 0.598135993 self.assertLess( error, self.maxError, 'rhoV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_rhoL_t(self): error = self.steamTable.rhoL_t(100.0) - 958.3542773 self.assertLess( error, self.maxError, 'rhoL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_rho_pt(self): error = self.steamTable.rho_pt(1.0, 100.0) - 0.589636754 self.assertLess( error, self.maxError, 'rho_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_rho_ph(self): error = self.steamTable.rho_ph(1.0, 1000.0) - 2.283492601 self.assertLess( error, self.maxError, 'rho_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_rho_ps(self): error = self.steamTable.rho_ps(1.0, 1.0) - 975.6236788 self.assertLess( error, self.maxError, 'rho_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_sV_p(self): error = self.steamTable.sV_p(0.006117) - 9.155465556 self.assertLess( error, self.maxError, 'sV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_sL_p(self): error = self.steamTable.sL_p(0.0061171) - 1.8359e-05 self.assertLess( error, self.maxError, 'sL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_sV_t(self): error = self.steamTable.sV_t(0.0001) - 9.155756716 self.assertLess( error, self.maxError, 'sV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_sL_t(self): error = self.steamTable.sL_t(100.0) - 1.307014328 self.assertLess( error, self.maxError, 'sL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_s_pt(self): error = self.steamTable.s_pt(1.0, 20.0) - 0.296482921 self.assertLess( error, self.maxError, 's_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_s_ph(self): error = self.steamTable.s_ph(1.0, 84.01181117) - 0.296813845 self.assertLess( error, self.maxError, 's_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_uV_p(self): error = self.steamTable.uV_p(1.0) - 2505.547389 self.assertLess( error, self.maxError, 'uV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_uL_p(self): error = self.steamTable.uL_p(1.0) - 417.332171 self.assertLess( error, self.maxError, 'uL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_uV_t(self): error = self.steamTable.uV_t(100.0) - 2506.015308 self.assertLess( error, self.maxError, 'uV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_uL_t(self): error = self.steamTable.uL_t(100.0) - 418.9933299 self.assertLess( error, self.maxError, 'uL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_u_pt(self): error = self.steamTable.u_pt(1.0, 100.0) - 2506.171426 self.assertLess( error, self.maxError, 'u_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_u_ph(self): error = self.steamTable.u_ph(1.0, 1000.0) - 956.2074342 self.assertLess( error, self.maxError, 'u_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_u_ps(self): error = self.steamTable.u_ps(1.0, 1.0) - 308.5082185 self.assertLess( error, self.maxError, 'u_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CpV_p(self): error = self.steamTable.cpV_p(1.0) - 2.075938025 self.assertLess( error, self.maxError, 'cpV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CpL_p(self): error = self.steamTable.cpL_p(1.0) - 4.216149431 self.assertLess( error, self.maxError, 'cpL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CpV_t(self): error = self.steamTable.cpV_t(100.0) - 2.077491868 self.assertLess( error, self.maxError, 'cpV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CpL_t(self): error = self.steamTable.cpL_t(100.0) - 4.216645119 self.assertLess( error, self.maxError, 'cpL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_Cp_pt(self): error = self.steamTable.cp_pt(1.0, 100.0) - 2.074108555 self.assertLess( error, self.maxError, 'cp_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_Cp_ph(self): error = self.steamTable.Cp_ph(1.0, 200.0) - 4.17913573169 self.assertLess( error, self.maxError, 'Cp_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_Cp_ps(self): error = self.steamTable.Cp_ps(1.0, 1.0) - 4.190607038 self.assertLess( error, self.maxError, 'Cp_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CvV_p(self): error = self.steamTable.CvV_p(1.0) - 1.552696979 self.assertLess( error, self.maxError, 'CvV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CvL_p(self): error = self.steamTable.CvL_p(1.0) - 3.769699683 self.assertLess( error, self.maxError, 'CvL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CvV_t(self): error = self.steamTable.CvV_t(100.0) - 1.553698696 self.assertLess( error, self.maxError, 'CvV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_CvL_t(self): error = self.steamTable.CvL_t(100.0) - 3.76770022 self.assertLess( error, self.maxError, 'CvL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_Cv_pt(self): error = self.steamTable.Cv_pt(1.0, 100.0) - 1.551397249 self.assertLess( error, self.maxError, 'Cv_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_Cv_ph(self): error = self.steamTable.Cv_ph(1.0, 200.0) - 4.035176364 self.assertLess( error, self.maxError, 'Cv_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_Cv_ps(self): error = self.steamTable.Cv_ps(1.0, 1.0) - 3.902919468 self.assertLess( error, self.maxError, 'Cv_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_wV_p(self): error = self.steamTable.wV_p(1.0) - 472.0541571 self.assertLess( error, self.maxError, 'wV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_wL_p(self): error = self.steamTable.wL_p(1.0) - 1545.451948 self.assertLess( error, self.maxError, 'wL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_wV_t(self): error = self.steamTable.wV_t(100.0) - 472.2559492 self.assertLess( error, self.maxError, 'wV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_wL_t(self): error = self.steamTable.wL_t(100.0) - 1545.092249 self.assertLess( error, self.maxError, 'wL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_w_pt(self): error = self.steamTable.w_pt(1.0, 100.0) - 472.3375235 self.assertLess( error, self.maxError, 'w_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_w_ph(self): error = self.steamTable.w_ph(1.0, 200.0) - 1542.682475 self.assertLess( error, self.maxError, 'w_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_w_ps(self): error = self.steamTable.w_ps(1.0, 1.0) - 1557.8585 self.assertLess( error, self.maxError, 'w_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_my_pt(self): error = self.steamTable.my_pt(1.0, 100.0) - 1.22704e-05 self.assertLess( error, self.maxError, 'my_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_my_ph(self): error = self.steamTable.my_ph(1.0, 100.0) - 0.000914003770302 self.assertLess( error, self.maxError, 'my_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_my_ps(self): error = self.steamTable.my_ps(1.0, 1.0) - 0.000384222 self.assertLess( error, self.maxError, 'my_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_tcL_p(self): error = self.steamTable.tcL_p(1.0) - 0.677593822 self.assertLess( error, self.maxError, 'tcL_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_tcV_p(self): error = self.steamTable.tcV_p(1.0) - 0.024753668 self.assertLess( error, self.maxError, 'tcV_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_tcL_t(self): error = self.steamTable.tcL_t(25.0) - 0.607458162 self.assertLess( error, self.maxError, 'tcL_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_tcV_t(self): error = self.steamTable.tcV_t(25.0) - 0.018326723 self.assertLess( error, self.maxError, 'tcV_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_tc_pt(self): error = self.steamTable.tc_pt(1.0, 25.0) - 0.607509806 self.assertLess( error, self.maxError, 'tc_pt not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_tc_ph(self): error = self.steamTable.tc_ph(1.0, 100.0) - 0.605710062 self.assertLess( error, self.maxError, 'tc_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_tc_hs(self): error = self.steamTable.tc_hs(100.0, 0.34) - 0.606283124 self.assertLess( error, self.maxError, 'tc_hs not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_st_t(self): error = self.steamTable.st_t(100.0) - 0.0589118685877 self.assertLess( error, self.maxError, 'st_t not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_st_p(self): error = self.steamTable.st_p(1.0) - 0.058987784 self.assertLess( error, self.maxError, 'st_p not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_x_ph(self): error = self.steamTable.x_ph(1.0, 1000.0) - 0.258055424 self.assertLess( error, self.maxError, 'x_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_x_ps(self): error = self.steamTable.x_ps(1.0, 4.0) - 0.445397961 self.assertLess( error, self.maxError, 'x_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_vx_ph(self): error = self.steamTable.vx_ph(1.0, 418.0) - 0.288493093 self.assertLess( error, self.maxError, 'vx_ph not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError }) def test_vx_ps(self): error = self.steamTable.vx_ps(1.0, 4.0) - 0.999233827 self.assertLess( error, self.maxError, 'vx_ps not passed Error %(error)e allowed: %(max)e' % { 'error': error, 'max': self.maxError })
P_s = 20.3 #bars z_LC = 0.6 else: print('Erreur ! Experience mal renseigneé') g = 9.81 G = mpoint/(np.pi*0.25*D**2) # Flux massique du mélange z_e = 0. # Position de l'entrée z_s = L_c # Position de la sortie q = P_th / (np.pi * D*L_c) # Titre en sortie pour la BC L_sc = (steamTable.hL_p(P_s)-steamTable.h_pt(P_s,T_e))*mpoint/(np.pi*D*q) x_s = 4*q*(L_c-L_sc)/(G*D*(steamTable.hV_p(P_s)-steamTable.hL_p(P_s))) ##################################################################### ###################### Imports tensorflow ########################### ##################################################################### p_tf = tf.placeholder(dtype=tf.float32,shape=[None,1]) t_tf = tf.placeholder(dtype=tf.float32,shape=[None,1]) z_tf = tf.placeholder(dtype=tf.float32,shape=[None,1]) eps_tf = tf.placeholder(dtype=tf.float32,shape=[None,1]) # #init = tf.compat.v1.global_variables_initializer() # #sess = tf.compat.v1.Session(config=tf.compat.v1.ConfigProto(allow_soft_placement=True, log_device_placement=True))
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 supercritical cycle (double reheat) 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 = 350 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")
def demo_ms_and_ofwh(): """ converted example from Stu Blair, found at https://github.com/stu314159/xsteam/blob/42767648a05c6759ad11aea95256cb24e4fc9499/Examples/Rankine_MS_and_OFWH.m """ print("converted example from Stu Blair / https://github.com/stu314159") print( "Purpose: test XSteam functionality with slightly more complex Rankine. Uses scipy.optimize.fsolve" ) print( """Problem Description: A Pressurized Water Reactor transfers heat to a Rankine cycle with the following properties: * Steam Generator Outlet Pressure: 820 psia, quality = 100% * High Pressure turbine: outlet pressure 164 psia, isentropic efficiency of 94%. * Moisture separator draining to OFWH (Open Feed Water Heater) * Flow extraction downstream of M/S set to make OFWH outlet temperature equal to saturation temp at its pressure * LP Turbine with outlet pressure of 3 psia, isentropic efficiency of 94%. * Condenser outlet quality = 0.0 * Main condensate pump (efficiency = 84%) outlet pressure 164 psia * Main Feed pump (efficiency = 84%) outlet pressure 820 psia""" ) steam_table = XSteam(XSteam.UNIT_SYSTEM_FLS) # % Calculations # %% state point 1 - condenser outlet state_point_1 = dict() state_point_1["P"] = 3.0 # % psia - given state_point_1["x"] = 0.0 # % quality - given state_point_1["T"] = steam_table.hL_p(state_point_1["P"]) state_point_1["h"] = steam_table.tsat_p(state_point_1["P"]) state_point_1["s"] = steam_table.sL_p(state_point_1["P"]) # %% state point 2 # % compression in main condensate pump eta_mcp = 0.84 # % pump isentropic efficiency - given state_point_2 = dict() state_point_2["s_s"] = state_point_1["s"] state_point_2["P"] = 164.0 # % psia - given state_point_2["h_s"] = steam_table.h_ps(state_point_2["P"], state_point_2["s_s"]) state_point_2["h"] = ( state_point_1["h"] - (state_point_1["h"] - state_point_2["h_s"]) / eta_mcp ) # %% state point 3 OFWH exit state_point_3 = dict() state_point_3["P"] = state_point_2["P"] # % constant pressure in OFWH state_point_3["x"] = 0.0 state_point_3["h"] = steam_table.hL_p(state_point_3["P"]) state_point_3["s"] = steam_table.sL_p(state_point_3["P"]) # %% State point 4 MFP exit eta_mfp = 0.84 state_point_4 = dict() state_point_4["P"] = 820.0 # % psia - given state_point_4["s_s"] = state_point_3["s"] state_point_4["h_s"] = steam_table.h_ps(state_point_4["P"], state_point_4["s_s"]) state_point_4["h"] = ( state_point_3["h"] - (state_point_3["h"] - state_point_4["h_s"]) / eta_mfp ) # %% State point 5 S/G Exit state_point_5 = dict() state_point_5["P"] = state_point_4["P"] # % assume isobaric in S/G state_point_5["x"] = 1.0 # % saturated steam; given state_point_5["h"] = steam_table.hV_p(state_point_5["P"]) state_point_5["s"] = steam_table.sV_p(state_point_5["P"]) # %% State point 6 HP Turbine Exhaust eta_hpt = 0.94 # % hp turbine isentropic efficiency; given state_point_6 = dict() state_point_6["P"] = 164.0 # % psia - given state_point_6["s_s"] = state_point_5["s"] state_point_6["h_s"] = steam_table.h_ps(state_point_6["P"], state_point_6["s_s"]) state_point_6["h"] = state_point_5["h"] - eta_hpt * ( state_point_5["h"] - state_point_6["h_s"] ) state_point_6["x"] = steam_table.x_ph(state_point_6["P"], state_point_6["h"]) # %% State point 7 Moisture Separator vapor exit state_point_7 = dict() state_point_7["P"] = state_point_6["P"] # assume isobaric process in M/S state_point_7["x"] = 1.0 # quality - given state_point_7["h"] = steam_table.hV_p(state_point_7["P"]) state_point_7["s"] = steam_table.sV_p(state_point_7["P"]) # %% State point 8 LP Turbine exhaust eta_lpt = 0.94 # % lp turbine isentropic efficiency; given state_point_8 = dict() state_point_8["P"] = state_point_1["P"] state_point_8["s_s"] = state_point_7["s"] state_point_8["h_s"] = steam_table.h_ps(state_point_8["P"], state_point_8["s_s"]) state_point_8["h"] = state_point_7["h"] - eta_lpt * ( state_point_7["h"] - state_point_8["h_s"] ) state_point_8["x"] = steam_table.x_ph(state_point_8["P"], state_point_8["h"]) # %% State point 9 Moisture Separator liquid drain to OFWH state_point_9 = dict() # % same pressure as HP Turbine exhaust state_point_9["P"] = state_point_6["P"] state_point_9["h"] = steam_table.hL_p(state_point_9["P"]) # http://mathesaurus.sourceforge.net/matlab-numpy.html # %% Energy balance on OFWH to find flow fraction f1 at extraction point # OFWH_Ebal = @(f1) x(6)*(1-f1)*h(2)+x(6)*f1*h(7)+(1-x(6))*h(9) - h(3) def OFWH_Ebal(f1): # https://de.mathworks.com/help/matlab/matlab_prog/matlab-operators-and-special-characters.html # x(6)*(1-f1)*h(2)+x(6)*f1*h(7)+(1-x(6))*h(9) - h(3) return ( state_point_6["x"] * (1 - f1) * state_point_2["h"] + state_point_6["x"] * f1 * state_point_7["h"] + (1 - state_point_6["x"]) * state_point_9["h"] - state_point_3["h"] ) f1 = fsolve(OFWH_Ebal, 0.05)[0] # %% Specific Work and Energy Balance w_mcp = (state_point_1["h"] - state_point_2["h"]) * f1 * state_point_6["x"] w_mfp = state_point_3["h"] - state_point_4["h"] w_hpt = state_point_5["h"] - state_point_6["h"] w_lpt = (state_point_7["h"] - state_point_8["h"]) * (1 - f1) * state_point_6["x"] w_net = w_mcp + w_mfp + w_hpt + w_lpt q_cond = (state_point_1["h"] - state_point_8["h"]) * (1 - f1) * state_point_6["x"] q_sg = state_point_5["h"] - state_point_4["h"] q_net = q_cond + q_sg eta_th = w_net / q_sg print(f"Net heat: {q_net:.3f} BTU/lbm Net work: {w_net:.3f} BTU/lbm") print(f"Thermal efficiency: {eta_th*100:.2f} percent")
def demo_reheat_ms_ofwh(): """ converted example from Stu Blair, found at https://github.com/stu314159/xsteam/blob/42767648a05c6759ad11aea95256cb24e4fc9499/Examples/Rankine_Reheat_MS_OFWH.m """ print("converted example from Stu Blair / https://github.com/stu314159") print("Purpose: use fminsearch / scipy.optimize.fmin") print( """Problem Description: (a picture would be better....) """ ) steam_table = XSteam(XSteam.UNIT_SYSTEM_FLS) # %% State point 1 - condenser exit state_point_1 = dict() state_point_1["P"] = 1.5 # % psia state_point_1["h"] = steam_table.hL_p(state_point_1["P"]) state_point_1["s"] = steam_table.sL_p(state_point_1["P"]) # %% State point 1 -> 2, main condensate pump eta_mcp = 0.84 state_point_2 = dict() state_point_2["P"] = 164.0 # % psia state_point_2["s_s"] = state_point_1["s"] state_point_2["h_s"] = steam_table.h_ps(state_point_2["P"], state_point_2["s_s"]) state_point_2["h"] = ( state_point_1["h"] - (state_point_1["h"] - state_point_2["h_s"]) / eta_mcp ) # %% State point 3, OFWH exit, saturated liquid state_point_3 = dict() state_point_3["P"] = state_point_2["P"] state_point_3["h"] = steam_table.hL_p(state_point_3["P"]) state_point_3["s"] = steam_table.sL_p(state_point_3["P"]) # %% State point 3 -> 4, main feed pump eta_mfp = 0.84 state_point_4 = dict() state_point_4["P"] = 820.0 # % psia state_point_4["s_s"] = state_point_3["s"] state_point_4["h_s"] = steam_table.h_ps(state_point_4["P"], state_point_4["s_s"]) state_point_4["h"] = ( state_point_3["h"] - (state_point_3["h"] - state_point_4["h_s"]) / eta_mfp ) # %% State point 5 - Steam generator exit state_point_5 = dict() state_point_5["P"] = state_point_4["P"] state_point_5["h"] = steam_table.hV_p(state_point_5["P"]) state_point_5["s"] = steam_table.sV_p(state_point_5["P"]) # %% State point 6 - HP Turbine Exhaust eta_hpt = 0.94 state_point_6 = dict() state_point_6["P"] = 164.0 # % psia state_point_6["s_s"] = state_point_5["s"] state_point_6["h_s"] = steam_table.h_ps(state_point_6["P"], state_point_6["s_s"]) state_point_6["h"] = state_point_5["h"] - eta_hpt * ( state_point_5["h"] - state_point_6["h_s"] ) state_point_6["x"] = steam_table.x_ph(state_point_6["P"], state_point_6["h"]) # %% State point 7 - Moisture Separator Exit state_point_7 = dict() state_point_7["P"] = state_point_6["P"] state_point_7["h"] = steam_table.hV_p(state_point_7["P"]) state_point_7["s"] = steam_table.sV_p(state_point_7["P"]) # %% State point 8 - Reheater Mid-Pressure Steam exit state_point_8 = dict() state_point_8["P"] = state_point_7["P"] state_point_8["T"] = 490.0 # % degrees F state_point_8["h"] = steam_table.h_pt(state_point_8["P"], state_point_8["T"]) state_point_8["s"] = steam_table.s_pt(state_point_8["P"], state_point_8["T"]) # %% State point 9 - LP Turbine Exhaust state_point_9 = dict() state_point_9["P"] = state_point_1["P"] eta_lpt = 0.94 state_point_9["s_s"] = state_point_8["s"] state_point_9["h_s"] = steam_table.h_ps(state_point_9["P"], state_point_9["s_s"]) state_point_9["h"] = state_point_8["h"] - eta_lpt * ( state_point_8["h"] - state_point_9["h_s"] ) # %% State point 10 - Reheater HP Steam exit state_point_10 = dict() state_point_10["P"] = state_point_5["P"] # % assume steam exits as a saturated liquid. state_point_10["h"] = steam_table.hL_p(state_point_10["P"]) # %% State point 11 - pressure trap exit to OFWH state_point_11 = dict() state_point_11["P"] = state_point_2["P"] # % assume isenthalpic expansion in the trap. state_point_11["h"] = state_point_10["h"] # %% State point 12 - Moisture Separator liquid drain to OFWH state_point_12 = dict() state_point_12["P"] = state_point_6["P"] state_point_12["h"] = steam_table.hL_p(state_point_12["P"]) # %% Heat Balance - find the flow fractions def RH_heatBalance(f): return ( f[0] * state_point_5["h"] + (1 - f[0]) * state_point_6["x"] * (1 - f[1]) * state_point_7["h"] ) - ( f[0] * state_point_10["h"] + (1 - f[0]) * state_point_6["x"] * (1 - f[1]) * state_point_8["h"] ) def OFWH_heatBalance(f): return ( (1 - f[0]) * (1 - f[1]) * state_point_6["x"] * state_point_2["h"] + f[0] * state_point_11["h"] + (1 - f[0]) * state_point_6["x"] * f[1] * state_point_7["h"] + (1 - f[0]) * (1 - state_point_6["x"]) * state_point_12["h"] ) - state_point_3["h"] def totalFunctional(f): return math.fabs(RH_heatBalance(f)) + math.fabs(OFWH_heatBalance(f)) # % the strategy is to minimize the total functional. The minimum value is # % when they are both equal to zero. initialGuess = [0.1, 0.1] f = fmin(func=totalFunctional, x0=initialGuess) # % % calculate heat and energy balances w_mcp = ( (state_point_1["h"] - state_point_2["h"]) * (1 - f[0]) * (1 - f[1]) * state_point_6["x"] ) w_mfp = state_point_3["h"] - state_point_4["h"] w_hpt = (state_point_5["h"] - state_point_6["h"]) * (1 - f[0]) w_lpt = ( (state_point_8["h"] - state_point_9["h"]) * (1 - f[0]) * (1 - f[1]) * state_point_6["x"] ) w_net = w_mcp + w_mfp + w_hpt + w_lpt q_cond = ( (state_point_1["h"] - state_point_9["h"]) * (1 - f[0]) * (1 - f[1]) * state_point_6["x"] ) q_sg = state_point_5["h"] - state_point_4["h"] q_net = q_cond + q_sg eta_th = w_net / q_sg # % % report the results: print(f"Net heat: {q_net:.3f} BTU/lbm Net work: {w_net:.3f} BTU/lbm") print(f"Thermal efficiency: {eta_th*100:.2f} percent")
def demo_simple_cycle(): """ converted example from Stu Blair found at https://github.com/stu314159/xsteam/blob/42767648a05c6759ad11aea95256cb24e4fc9499/Examples/SimpleRankineCycle.m """ print("Purpose: test xsteam functionality for simple Rankine Cycle") print( """Problem Description: Advanced Boiling Water Reactor (ABWR) produces saturated steam at 7.17 MPa (71.7 bar) to a set of turbine generators. The turbines exhaust to condensers maintained at 8 kPa (0.08 bar). Assume the turbines and pumps have isentropic efficiencies of 100% Assume fluid leaving the condenser is saturated liquid.""" ) print( """Goal: Calculate enthalpy, entropy, and temperature for all state points. Calculate net work and thermal efficiency for this cycle""" ) steam_table = XSteam(XSteam.UNIT_SYSTEM_MKS) # state point 1: condenser outlet / feed pump inlet # state point 2: feed pump discharge / Reactor core inlet # state point 3: reactor core outlet / turbine inlet # state point 4: turbine exhaust / condenser inlet # %% State Point 1 # condenser outlet / feed pump inlet state_point_1 = dict() state_point_1["P"] = 0.08 # bar - given state_point_1["x"] = 0.0 # given state_point_1["T"] = steam_table.tsat_p(state_point_1["P"]) state_point_1["h"] = steam_table.hL_p(state_point_1["P"]) state_point_1["s"] = steam_table.sL_p(state_point_1["P"]) # %% State Point 2 # feed pump discharge / Reactor core inlet # process: isentropic compression state_point_2 = dict() state_point_2["s"] = state_point_1["s"] state_point_2["P"] = 71.1 # bar - given state_point_2["h"] = steam_table.t_ps(state_point_2["P"], state_point_2["s"]) state_point_2["T"] = steam_table.t_ph(state_point_2["P"], state_point_2["h"]) # state_point_2["x"] = float("NaN") pump_work = state_point_1["h"] - state_point_2["h"] # %% State Point 3 # reactor core outlet / turbine inlet # % process: isobaric heat addition state_point_3 = dict() state_point_3["P"] = state_point_2["P"] state_point_3["x"] = 1.0 state_point_3["T"] = steam_table.tsat_p(state_point_3["P"]) state_point_3["h"] = steam_table.hV_p(state_point_3["P"]) state_point_3["s"] = steam_table.sV_p(state_point_3["P"]) heat_in = state_point_3["h"] - state_point_2["h"] # %% State Point 4 # turbine exhaust / condenser inlet # % process: isentropic expansion state_point_4 = dict() state_point_4["s"] = state_point_3["s"] state_point_4["P"] = state_point_1["P"] # % for isobaric heat rejection in next step state_point_4["h"] = steam_table.h_ps(state_point_4["P"], state_point_4["s"]) state_point_4["x"] = steam_table.x_ph(state_point_4["P"], state_point_4["h"]) turbine_work = state_point_3["h"] - state_point_4["h"] # % % State Point 1 # % process: isobaric heat rejection heat_out = state_point_1["h"] - state_point_4["h"] # % % Energy Balance net_heat = heat_in + heat_out net_work = turbine_work + pump_work eta_th = net_work / heat_in print(f"Net heat: {net_heat:.3f} Net work: {net_work:.3f}") print(f"Thermal efficiency: {eta_th*100:.2f} percent")
class MKS_FunctionTester(unittest.TestCase): def setUp(self): self.maxError = 1E-6 self.steamTable = XSteam(XSteam.UNIT_SYSTEM_MKS) def tearDown(self): pass def test_tsat_p(self): error = self.steamTable.tsat_p(1.0) - 99.60591861 self.assertLess(error, self.maxError, 'tsat_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_t_ph(self): error = self.steamTable.t_ph(1.0, 100.0) - 23.84481908 self.assertLess(error, self.maxError, 't_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_t_ps(self): error = self.steamTable.t_ps(1.0, 1.0) - 73.70859421 self.assertLess(error, self.maxError, 't_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_t_hs(self): error = self.steamTable.t_hs(100.0, 0.2) - 13.84933511 self.assertLess(error, self.maxError, 't_hs not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_psat_t(self): error = self.steamTable.psat_t(100.0) - 1.014179779 self.assertLess(error, self.maxError, 'psat_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_p_hs(self): error = self.steamTable.p_hs(84.0, 0.296) - 2.295498269 self.assertLess(error, self.maxError, 'p_hs not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_hV_p(self): error = self.steamTable.hV_p(1.0) - 2674.949641 self.assertLess(error, self.maxError, 'hV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_hL_p(self): error = self.steamTable.hL_p(1.0) - 417.4364858 self.assertLess(error, self.maxError, 'hL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_hV_t(self): error = self.steamTable.hV_t(100.0) - 2675.572029 self.assertLess(error, self.maxError, 'hV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_hL_t(self): error = self.steamTable.hL_t(100.0) - 419.099155 self.assertLess(error, self.maxError, 'hL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_h_pt(self): error = self.steamTable.h_pt(1.0, 20.0) - 84.01181117 self.assertLess(error, self.maxError, 'h_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_h_ps(self): error = self.steamTable.h_ps(1.0, 1.0) - 308.6107171 self.assertLess(error, self.maxError, 'h_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_h_px(self): error = self.steamTable.h_px(1.0, 0.5) - 1546.193063 self.assertLess(error, self.maxError, 'h_px not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_h_prho(self): error = self.steamTable.h_prho(1.0, 2.0) - 1082.773391 self.assertLess(error, self.maxError, 'h_prho not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_h_tx(self): error = self.steamTable.h_tx(100.0, 0.5) - 1547.33559211 self.assertLess(error, self.maxError, 'h_tx not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_vV_p(self): error = self.steamTable.vV_p(1.0) - 1.694022523 self.assertLess(error, self.maxError, 'vV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_vL_p(self): error = self.steamTable.vL_p(1.0) - 0.001043148 self.assertLess(error, self.maxError, 'vL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_vV_t(self): error = self.steamTable.vV_t(100.0) - 1.671860601 self.assertLess(error, self.maxError, 'vV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_vL_t(self): error = self.steamTable.vL_t(100.0) - 0.001043455 self.assertLess(error, self.maxError, 'vL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_v_pt(self): error = self.steamTable.v_pt(1.0, 100.0) - 1.695959407 self.assertLess(error, self.maxError, 'v_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_v_ph(self): error = self.steamTable.v_ph(1.0, 1000.0) - 0.437925658 self.assertLess(error, self.maxError, 'v_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_v_ps(self): error = self.steamTable.v_ps(1.0, 5.0) - 1.03463539 self.assertLess(error, self.maxError, 'v_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_rhoV_p(self): error = self.steamTable.rhoV_p(1.0) - 0.590310924 self.assertLess(error, self.maxError, 'rhoV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_rhoL_p(self): error = self.steamTable.rhoL_p(1.0) - 958.6368897 self.assertLess(error, self.maxError, 'rhoL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_rhoV_t(self): error = self.steamTable.rhoV_t(100.0) - 0.598135993 self.assertLess(error, self.maxError, 'rhoV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_rhoL_t(self): error = self.steamTable.rhoL_t(100.0) - 958.3542773 self.assertLess(error, self.maxError, 'rhoL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_rho_pt(self): error = self.steamTable.rho_pt(1.0, 100.0) - 0.589636754 self.assertLess(error, self.maxError, 'rho_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_rho_ph(self): error = self.steamTable.rho_ph(1.0, 1000.0) - 2.283492601 self.assertLess(error, self.maxError, 'rho_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_rho_ps(self): error = self.steamTable.rho_ps(1.0, 1.0) - 975.6236788 self.assertLess(error, self.maxError, 'rho_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_sV_p(self): error = self.steamTable.sV_p(0.006117) - 9.155465556 self.assertLess(error, self.maxError, 'sV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_sL_p(self): error = self.steamTable.sL_p(0.0061171) - 1.8359e-05 self.assertLess(error, self.maxError, 'sL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_sV_t(self): error = self.steamTable.sV_t(0.0001) - 9.155756716 self.assertLess(error, self.maxError, 'sV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_sL_t(self): error = self.steamTable.sL_t(100.0) - 1.307014328 self.assertLess(error, self.maxError, 'sL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_s_pt(self): error = self.steamTable.s_pt(1.0, 20.0) - 0.296482921 self.assertLess(error, self.maxError, 's_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_s_ph(self): error = self.steamTable.s_ph(1.0, 84.01181117) - 0.296813845 self.assertLess(error, self.maxError, 's_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_uV_p(self): error = self.steamTable.uV_p(1.0) - 2505.547389 self.assertLess(error, self.maxError, 'uV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_uL_p(self): error = self.steamTable.uL_p(1.0) - 417.332171 self.assertLess(error, self.maxError, 'uL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_uV_t(self): error = self.steamTable.uV_t(100.0) - 2506.015308 self.assertLess(error, self.maxError, 'uV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_uL_t(self): error = self.steamTable.uL_t(100.0) - 418.9933299 self.assertLess(error, self.maxError, 'uL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_u_pt(self): error = self.steamTable.u_pt(1.0, 100.0) - 2506.171426 self.assertLess(error, self.maxError, 'u_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_u_ph(self): error = self.steamTable.u_ph(1.0, 1000.0) - 956.2074342 self.assertLess(error, self.maxError, 'u_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_u_ps(self): error = self.steamTable.u_ps(1.0, 1.0) - 308.5082185 self.assertLess(error, self.maxError, 'u_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CpV_p(self): error = self.steamTable.CpV_p(1.0) - 2.075938025 self.assertLess(error, self.maxError, 'cpV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CpL_p(self): error = self.steamTable.CpL_p(1.0) - 4.216149431 self.assertLess(error, self.maxError, 'cpL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CpV_t(self): error = self.steamTable.CpV_t(100.0) - 2.077491868 self.assertLess(error, self.maxError, 'cpV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CpL_t(self): error = self.steamTable.CpL_t(100.0) - 4.216645119 self.assertLess(error, self.maxError, 'cpL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_Cp_pt(self): error = self.steamTable.Cp_pt(1.0, 100.0) - 2.074108555 self.assertLess(error, self.maxError, 'cp_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_Cp_ph(self): error = self.steamTable.Cp_ph(1.0, 200.0) - 4.17913573169 self.assertLess(error, self.maxError, 'Cp_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_Cp_ps(self): error = self.steamTable.Cp_ps(1.0, 1.0) - 4.190607038 self.assertLess(error, self.maxError, 'Cp_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CvV_p(self): error = self.steamTable.CvV_p(1.0) - 1.552696979 self.assertLess(error, self.maxError, 'CvV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CvL_p(self): error = self.steamTable.CvL_p(1.0) - 3.769699683 self.assertLess(error, self.maxError, 'CvL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CvV_t(self): error = self.steamTable.CvV_t(100.0) - 1.553698696 self.assertLess(error, self.maxError, 'CvV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_CvL_t(self): error = self.steamTable.CvL_t(100.0) - 3.76770022 self.assertLess(error, self.maxError, 'CvL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_Cv_pt(self): error = self.steamTable.Cv_pt(1.0, 100.0) - 1.551397249 self.assertLess(error, self.maxError, 'Cv_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_Cv_ph(self): error = self.steamTable.Cv_ph(1.0, 200.0) - 4.035176364 self.assertLess(error, self.maxError, 'Cv_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_Cv_ps(self): error = self.steamTable.Cv_ps(1.0, 1.0) - 3.902919468 self.assertLess(error, self.maxError, 'Cv_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_wV_p(self): error = self.steamTable.wV_p(1.0) - 472.0541571 self.assertLess(error, self.maxError, 'wV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_wL_p(self): error = self.steamTable.wL_p(1.0) - 1545.451948 self.assertLess(error, self.maxError, 'wL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_wV_t(self): error = self.steamTable.wV_t(100.0) - 472.2559492 self.assertLess(error, self.maxError, 'wV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_wL_t(self): error = self.steamTable.wL_t(100.0) - 1545.092249 self.assertLess(error, self.maxError, 'wL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_w_pt(self): error = self.steamTable.w_pt(1.0, 100.0) - 472.3375235 self.assertLess(error, self.maxError, 'w_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_w_ph(self): error = self.steamTable.w_ph(1.0, 200.0) - 1542.682475 self.assertLess(error, self.maxError, 'w_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_w_ps(self): # TODO: Check values and calculation error = self.steamTable.w_ps(1.0, 1.0) - 1557.8585 self.assertLess(error, self.maxError, 'w_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_my_pt(self): error = self.steamTable.my_pt(1.0, 100.0) - 1.22704e-05 self.assertLess(error, self.maxError, 'my_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_my_ph(self): error = self.steamTable.my_ph(1.0, 100.0) - 0.000914003770302 self.assertLess(error, self.maxError, 'my_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_my_ps(self): error = self.steamTable.my_ps(1.0, 1.0) - 0.000384222 self.assertLess(error, self.maxError, 'my_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_tcL_p(self): error = self.steamTable.tcL_p(1.0) - 0.677593822 self.assertLess(error, self.maxError, 'tcL_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_tcV_p(self): error = self.steamTable.tcV_p(1.0) - 0.024753668 self.assertLess(error, self.maxError, 'tcV_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_tcL_t(self): error = self.steamTable.tcL_t(25.0) - 0.607458162 self.assertLess(error, self.maxError, 'tcL_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_tcV_t(self): error = self.steamTable.tcV_t(25.0) - 0.018326723 self.assertLess(error, self.maxError, 'tcV_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_tc_pt(self): error = self.steamTable.tc_pt(1.0, 25.0) - 0.607509806 self.assertLess(error, self.maxError, 'tc_pt not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_tc_ph(self): error = self.steamTable.tc_ph(1.0, 100.0) - 0.605710062 self.assertLess(error, self.maxError, 'tc_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_tc_hs(self): error = self.steamTable.tc_hs(100.0, 0.34) - 0.606283124 self.assertLess(error, self.maxError, 'tc_hs not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_st_t(self): error = self.steamTable.st_t(100.0) - 0.0589118685877 self.assertLess(error, self.maxError, 'st_t not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_st_p(self): error = self.steamTable.st_p(1.0) - 0.058987784 self.assertLess(error, self.maxError, 'st_p not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_x_ph(self): error = self.steamTable.x_ph(1.0, 1000.0) - 0.258055424 self.assertLess(error, self.maxError, 'x_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_x_ps(self): error = self.steamTable.x_ps(1.0, 4.0) - 0.445397961 self.assertLess(error, self.maxError, 'x_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_vx_ph(self): error = self.steamTable.vx_ph(1.0, 418.0) - 0.288493093 self.assertLess(error, self.maxError, 'vx_ph not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError}) def test_vx_ps(self): error = self.steamTable.vx_ps(1.0, 4.0) - 0.999233827 self.assertLess(error, self.maxError, 'vx_ps not passed Error %(error)e allowed: %(max)e' % {'error': error, 'max': self.maxError})
# print(steamTable.hV_p(1.01325)) atm = 1.01325 # bar # atm = 3 # nT = 0.9 # turbine efficiency nT = 1 # nP = 0.9 # pump efficiency nP = 1 rho = 997 # kg/m3 # rho = 1000 T = 20 # celsius # max_press = 60 # 60 bar is close to the operating press of real nuke systems max_press = 100 # maybe we can cheat a bit cause mdot is gonna be lower h6 = steamTable.hV_p(max_press) s6 = steamTable.sV_p(max_press) h5 = steamTable.hL_p(max_press) turbine_powers = np.linspace(35, 85, 6) # mw # pressures = np.linspace(2, 10, 9) # bar pressures = np.linspace(20, 60, 100) # bar, holds the low pressure turbine val flow_tab_low = [] flow_tab_med = [] flow_tab_hig = [] flow_tab = [] pump_tab = [] qcore_tab = [] efficiency_tab = [] # mass_flows = [] # going to first calculate with isentropic pump and turbine for power in turbine_powers:
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")
s1 = steamTable.sL_p(p2) print('Carnot cycle analysis') T1 = steamTable.t_ps(p1, s1) print('\nPoint 1') print(f"P1: {round(float(p1),1)} bar") print(f"T1: {round(float(T1),1)} degC") print(f"S1: {round(float(s1),3)} kJ/kg K") s2 = s1 h1 = steamTable.h_ps(p1, s1) print(f"H1: {round(float(h1),1)} kJ/kg") h2 = steamTable.hL_p(p2) s2 = steamTable.sL_p(p2) T2 = steamTable.t_ph(p2, h2) print('\nPoint 2') print(f"P2: {round(float(p2),1)} bar") print(f"T2: {round(float(T2),1)} degC") print(f"H2: {round(float(h2),1)} kJ/kg") print(f"S2: {round(float(s2),3)} kJ/kg K") h3 = steamTable.hV_p(p2) s3 = steamTable.sV_p(p2) T3 = T2 p3 = p2 print('\nPoint 3') print(f"P3: {round(float(p3),1)} bar") print(f"T3: {round(float(T3),1)} degC")