def CalPump(Pump, Nodes, Task): """ "PUMP": {'minID': None, 'moutID': None, 'eta': None, 'wdot': None, "energy": "Win", "fun": CalPump} """ iND = Nodes[Pump['minID']] oND = Nodes[Pump['moutID']] if Task == "State": # 1 oND sout_s = iND['s'] hout_s = ps2h(oND['p'], sout_s) oND['h'] = iND['h'] + (hout_s - iND['h']) / Pump['eta'] oND['t'] = ph2t(oND['p'], oND['h']) oND['s'] = ph2s(oND['p'], oND['h']) oND['x'] = ph2x(oND['p'], oND['h']) if Task == "Balance": # 2 Mass and Energy Balance if iND['fdot'] != None: oND['fdot'] = iND['fdot'] if oND['fdot'] != None: iND['fdot'] = oND['fdot'] Pump['wdot'] = oND['fdot'] * oND['h'] - iND['fdot'] * iND['h']
def CalTurbineEx0(TurbineEx0, Nodes, Task): """ "TURBINE-EX0": {'minID': None, 'moutID': None, 'eta': None, 'wdot': None, "energy": "Wout", "fun": CalTurbineEx0} """ iND = Nodes[TurbineEx0['minID']] oND = Nodes[TurbineEx0['moutID']] if (Task == "State"): # 1 oND if TurbineEx0['eta'] == 1.0: oND['s'] = iND['s'] oND['t'] = ps2t(oND['p'], oND['s']) oND['h'] = ps2h(oND['p'], oND['s']) oND['x'] = ps2x(oND['p'], oND['s']) else: sout_s = iND['s'] hout_s = ps2h(oND['p'], sout_s) oND['h'] = iND['h'] - TurbineEx0['eta'] * (iND['h'] - hout_s) oND['t'] = ph2t(oND['p'], oND['h']) oND['s'] = ph2s(oND['p'], oND['h']) oND['x'] = ph2x(oND['p'], oND['h']) if (Task == "Balance"): # 2 Mass and Energy Balance if iND['fdot'] != None: oND['fdot'] = iND['fdot'] if oND['fdot'] != None: iND['fdot'] = oND['fdot'] TurbineEx0['wdot'] = iND['fdot'] * (iND['h'] - oND['h'])
def CalTurbineEx1(TurbineEx1, Nodes, Task): """ "TURBINE-EX1":{'minID': None, 'moutID': None, 'mexID': None ,'eta': None, 'wdot': None, "energy": "Wout", "fun": CalTurbineEx1}, """ iND = Nodes[TurbineEx1['minID']] oND = Nodes[TurbineEx1['moutID']] eND = Nodes[TurbineEx1['mexID']] if Task == "State": # 1 oND if TurbineEx1['eta'] == 1.0: eND['s'] = iND['s'] eND['t'] = ps2t(eND['p'], eND['s']) eND['h'] = ps2h(eND['p'], eND['s']) eND['x'] = ps2x(eND['p'], eND['s']) oND['s'] = iND['s'] oND['t'] = ps2t(oND['p'], oND['s']) oND['h'] = ps2h(oND['p'], oND['s']) oND['x'] = ps2x(oND['p'], oND['s']) else: isoh = ps2h(eND['p'], iND['s']) eND['h'] = iND['h'] - TurbineEx1['eta'] * (iND['h'] - isoh) eND['t'] = ph2t(eND['p'], eND['h']) eND['s'] = ph2s(eND['p'], eND['h']) eND['x'] = ph2x(eND['p'], eND['h']) isoh = ps2h(oND['p'], eND['s']) oND['h'] = eND['h'] - TurbineEx1['eta'] * (eND['h'] - isoh) oND['t'] = ph2t(oND['p'], oND['h']) oND['s'] = ph2s(oND['p'], oND['h']) oND['x'] = ph2x(oND['p'], oND['h']) if Task == "Balance": # 2 Mass and Energy Balance oND['fdot'] = iND['fdot'] - eND['fdot'] TurbineEx1['wdot'] = eND['fdot'] * (iND['h'] - eND['h']) TurbineEx1['wdot'] += oND['fdot'] * (iND['h'] - oND['h'])
def ph(self): self.t = if97.ph2t(self.p, self.h) self.s = if97.ph2s(self.p, self.h) self.v = if97.ph2v(self.p, self.h) self.x = if97.ph2x(self.p, self.h)
yAxis = "T" title = {"T": "T, C", "s": "s, kJ/kgK"} plt.title("%s-%s Diagram" % (yAxis, xAxis)) plt.xlabel(title[xAxis]) plt.ylabel(title[yAxis]) plt.grid() Pt = 611.657e-6 isoh = np.linspace(200, 3600, 18) isop = np.array([ Pt, 0.001, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0 ]) for h in isoh: T = np.array([ph2t(p, h) for p in isop]) S = np.array([ph2s(p, h) for p in isop]) plt.plot(S, T, 'b', lw=0.5) for p in isop: T = np.array([ph2t(p, h) for h in isoh]) S = np.array([ph2s(p, h) for h in isoh]) plt.plot(S, T, 'b', lw=0.5) tc = 647.096 - 273.15 T = np.linspace(0.11, tc, 100) for x in np.array([0, 1.0]): S = np.array([tx2s(t, x) for t in T]) plt.plot(S, T, 'r', lw=1.0) for x in np.linspace(0.1, 0.9, 11): S = np.array([tx2s(t, x) for t in T])
xAxis = "s" yAxis = "T" title = {"T": "T, °C", "s": "s, kJ/kgK"} plt.title("%s-%s Diagram" % (yAxis, xAxis)) plt.xlabel(title[xAxis]) plt.ylabel(title[yAxis]) plt.grid() Pt = 611.657e-6 isoh = np.linspace(200, 3600, 18) isop = np.array([Pt, 0.001, 0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0]) for h in isoh: T = np.array([ph2t(p, h) for p in isop]) S = np.array([ph2s(p, h) for p in isop]) plt.plot(S, T, 'b', lw=0.5) for p in isop: T = np.array([ph2t(p, h) for h in isoh]) S = np.array([ph2s(p, h) for h in isoh]) plt.plot(S, T, 'b', lw=0.5) tc = 647.096 - 273.15 T = np.linspace(0.11, tc, 100) for x in np.array([0, 1.0]): S = np.array([tx2s(t, x) for t in T]) plt.plot(S, T, 'r', lw=1.0) for x in np.linspace(0.1, 0.9, 11): S = np.array([tx2s(t, x) for t in T])