def dichotomy(maxValue, minValue, press, sumheat, dQ, initVolume): error1 = -1 error2 = 1 k = minValue count = 0 while (abs(error1 - error2) > 0.00001): if (error1 * error2 < 0): maxValue = maxValue minValue = k k = (maxValue + minValue) / 2 h2 = seuif97.pt2h(press, k) rho2 = 1 / seuif97.pt2v(press, k) h2up = seuif97.pt2h(press, maxValue) rho2up = 1 / seuif97.pt2v(press, maxValue) error1 = (sumheat - dQ * 1) - (initVolume * rho2 * h2) error2 = (sumheat - dQ * 1) - (initVolume * rho2up * h2up) count = count + 1 else: maxValue = k minValue = minValue k = (maxValue + minValue) / 2 h2 = seuif97.pt2h(press, k) rho2 = seuif97.pt2v(press, k) h2down = seuif97.pt2h(press, minValue) rho2down = 1 / seuif97.pt2v(press, minValue) error1 = (sumheat - dQ * 1) - (initVolume * h2 * rho2) error2 = (sumheat - dQ * 1) - (initVolume * h2down * rho2down) count = count + 1 return k
def CylinderEff(cylinder): """simple function for cylinde using 'dict' """ cylinder['inlet']['h'] = pt2h(cylinder['inlet']['p'], cylinder['inlet']['t']) cylinder['inlet']['s'] = pt2s(cylinder['inlet']['p'], cylinder['inlet']['t']) cylinder['outlet']['h'] = pt2h(cylinder['outlet']['p'], cylinder['outlet']['t']) cylinder['outlet']['s'] = pt2s(cylinder['outlet']['p'], cylinder['outlet']['t']) # h2s is the specific enthalpy at state 2 for the isentropic turbine h2s = ps2h(cylinder['outlet']['p'], cylinder['inlet']['s']) cylinder['h2s'] = h2s hds = cylinder['inlet']['h'] - h2s # isentropic specific enthalpy drop hd = cylinder['inlet']['h'] - cylinder['outlet'][ 'h'] # specific enthalpy drop cylinder['ef'] = 100 * hd / hds return cylinder
def calcOverHeatSteam(tempe, maxValue, minValue, press, seconds, innerDiameter, outerDiameter, oneInsulaDiameter, twoInsulaDiameter, pipeLength, insulaType, sumheat): # 计算这一段管段产生的饱和水量 # 就当是这条管道是稳态的已经饱和的蒸汽 #dQ = calcheatLossPermeter(tempe,seconds) heatLossPerSquare = CalcOverHeadPipeThermalFlux(tempe, innerDiameter, outerDiameter, oneInsulaDiameter, twoInsulaDiameter, insulaType) dQ = heatLossPerSquare * math.pi * twoInsulaDiameter * 1e-3 * 3.6 * seconds / 3600 # 计算每米的热损,kJ initVolume = math.pi * pow( (twoInsulaDiameter / 2), 2) * 1e-6 # 单位:m^3 ,单位体积 h1 = seuif97.pt2h(press, tempe) # 输入的焓值,kJ/kg rho = 1 / seuif97.pt2v(press, tempe) # kg/m^3 #sumheat = h1 * rho * initVolume # 单位:kJ,管道中预留的总热量 mass = rho * initVolume * 1e-3 # 单位:t,管道中总的蒸汽质量 # 计算压降 #dropPress = calculateDropPressure(innerDiameter, pipeLength, mass, press, tempe) # Mpa # 二分法计算 outTempe = dichotomy(maxValue, minValue, press, sumheat, dQ, initVolume) # 出口的温度 sumheat = sumheat - dQ #press = press - dropPress # 出口的压强 return outTempe, press, heatLossPerSquare, dQ, rho, h1, sumheat
def CylinderEff(cylinder): """simple function for cylinde using 'dict' """ cylinder['inlet']['h'] = pt2h(cylinder['inlet']['p'], cylinder['inlet']['t']) cylinder['inlet']['s'] = pt2s(cylinder['inlet']['p'], cylinder['inlet']['t']) cylinder['outlet']['h'] = pt2h(cylinder['outlet']['p'], cylinder['outlet']['t']) cylinder['outlet']['s'] = pt2s(cylinder['outlet']['p'], cylinder['outlet']['t']) # h2s is the specific enthalpy at state 2 for the isentropic turbine h2s = ps2h(cylinder['outlet']['p'], cylinder['inlet']['s']) cylinder['h2s'] = h2s hds = cylinder['inlet']['h'] - h2s # isentropic specific enthalpy drop hd = cylinder['inlet']['h'] - cylinder['outlet']['h'] # specific enthalpy drop cylinder['ef'] = 100 * hd / hds return cylinder
def CalNodeProperties(nodes): """ get node properties using seuif97 """ for node in nodes: if node['p'] != None and node['t'] != None: node['h'] = pt2h(node['p'], node['t']) node['s'] = pt2s(node['p'], node['t']) node['x'] = pt2x(node['p'], node['t']) elif node['p'] != None and node['x'] != None: node['t'] = px2t(node['p'], node['x']) node['h'] = px2h(node['p'], node['x']) node['s'] = px2s(node['p'], node['x']) elif node['t'] != None and node['x'] != None: node['p'] = tx2p(node['t'], node['x']) node['h'] = tx2h(node['t'], node['x']) node['s'] = tx2s(node['t'], node['x'])
def __init__(self, s): self.taglist = s.GetTagDefFromExcel() self.tagcount = s.tagcount self.tagdict = s.desc_valueMatch() self.power = self.tagdict['发电机有功功率'] self.MainSteamFlow = self.tagdict['主蒸汽流量'] self.MainSteamP = self.tagdict['主蒸汽压力'] self.MainSteamT = self.tagdict['主蒸汽温度'] self.RHSteamP = self.tagdict['再热汽压'] self.RHSteamT = self.tagdict['再热汽温'] self.FeedwaterFlow = self.tagdict['给水流量'] self.FeedwaterP = self.tagdict['给水压力'] self.FeedwaterT = self.tagdict['给水温度'] self.firstinP = self.tagdict['汽机调速级压力'] self.firstoutP = self.tagdict['一级抽汽压力'] self.firstoutT = self.tagdict['一级抽汽温度'] self.HPoutP = self.tagdict['高压缸排汽压力'] # ~ 二级抽汽压力 self.HPoutT = self.tagdict['高压缸排汽温度'] self.SHcoolwaterFlow = self.tagdict['过热器减温水总管流量'] self.SHcoolwaterP = self.tagdict['过热器减温水总管压力'] self.SHcoolwaterT = self.tagdict['除氧器水温度'] # ~ 过热器减温水温度 self.RHcoolwaterFlow = self.tagdict['再热器减温水总管流量'] self.RHcoolwaterP = self.tagdict['再热器减温水总管压力'] self.RHcoolwaterT = self.tagdict['再热器减温水温度'] self.hm = pt2h(self.MainSteamP, self.MainSteamT) # 主蒸汽焓 self.hr = pt2h(self.RHSteamP, self.RHSteamT) # 再热焓 self.hfw = pt2h(self.FeedwaterP, self.FeedwaterT) # 给水焓 self.hcr = pt2h(self.HPoutP, self.firstoutT) # 冷再热蒸汽焓 self.hshr = pt2h(self.SHcoolwaterP, self.SHcoolwaterT) # 过热器减温水焓 self.hrhs = pt2h(self.RHcoolwaterP, self.RHcoolwaterT) # 再热器减温水焓 self.HR = 0 self.LeakFlow = 1.3707 * self.power / 300 # 轴封漏汽、阀杆漏汽流量参考设计值 self.ExtractFlow = 0.1476 * self.MainSteamFlow # 工况变化前后,调节级后通流部分面积不变,抽汽流量与主蒸汽流量为线性关系
# -*- coding: utf-8 -*- import seuif97 import timeit import cProfile, pstats import io p=16.10 t=535.10 #t = timeit.Timer("seuif97.pt2h(p,t)","from __main__ import seuif97,p,t") #if97time=t.timeit(1) #print('Time(s)=',if97time) #print(h) pr = cProfile.Profile() pr.enable() h=seuif97.pt2h(p,t) pr.disable() s = io.StringIO() sortby = 'cumulative' ps = pstats.Stats(pr, stream=s).sort_stats(sortby) ps.print_stats() print (s.getvalue()) print(h)
def pt(self): self.h = if97.pt2h(self.p, self.t) self.s = if97.pt2s(self.p, self.t) self.v = if97.pt2v(self.p, self.t) self.x = None
yAxis = "h" title = {"h": "h, kJ/kg", "s": "s, kJ/kgK"} plt.title("%s-%s Diagram" % (yAxis, xAxis)) plt.xlabel(title[xAxis]) plt.ylabel(title[yAxis]) plt.xlim(0, 12.5) plt.ylim(0, 4300) plt.grid() Pt = 611.657e-6 # Isotherm lines to plot, values in ºC isot = np.array([0, 50, 100, 200, 300, 400, 500, 600, 700, 800]) isop = np.array([Pt, 0.001, 0.01, 0.1, 1, 10, 20, 50, 100]) for t in isot: h = np.array([pt2h(p, t) for p in isop]) s = np.array([pt2s(p, t) for p in isop]) plt.plot(s, h, 'g', lw=0.5) # Isobar lines to plot for p in isop: h = np.array([pt2h(p, t) for t in isot]) s = np.array([pt2s(p, t) for t in isot]) plt.plot(s, h, 'b', lw=0.5) tc = 647.096 - 273.15 T = np.linspace(0.1, tc, 100) # Calculate saturation line for x in np.array([0, 1.0]): h = np.array([tx2h(t, x) for t in T]) s = np.array([tx2s(t, x) for t in T])
# -*- coding: utf-8 -*- import seuif97 import timeit import cProfile, pstats import io p = 16 t = 350 #t = timeit.Timer("seuif97.pt2h(p,t)","from __main__ import seuif97,p,t") #if97time=t.timeit(1) #print('Time(s)=',if97time) #print(h) pr = cProfile.Profile() pr.enable() h = seuif97.pt2h(p, t) pr.disable() s = io.StringIO() sortby = 'cumulative' ps = pstats.Stats(pr, stream=s).sort_stats(sortby) ps.print_stats() print(s.getvalue()) print(h)
twoInsulaThick = 50 pipeLength = 87 oneInsulaDiameter = outerDiameter + 2 * oneInsulaThick twoInsulaDiameter = oneInsulaDiameter + 2 * twoInsulaThick insulaType = ['GSL','GLASS'] #原管道中的蒸汽质量 initVolume = math.pi * pow((twoInsulaDiameter / 2), 2) * 1e-6 # 单位:m^3 ,单位体积 rho1 = 1 / seuif97.pt2v(press, tempe) # kg/m^3 massSteam = rho1 * initVolume # 单位:kg,管道中总的蒸汽质量 sumtime,heatLossPerSquareList,heatLossPerMeterList, rhoList, hList, sumHeatList = [],[],[],[],[],[] # 初始的温度和压强下每米管道的蒸汽总热量 initVolume = math.pi * pow((twoInsulaDiameter / 2), 2) * 1e-6 # 单位:m^3 ,单位体积 h1 = seuif97.pt2h(press, tempe) # 输入的焓值,kJ/kg rho = 1 / seuif97.pt2v(press, tempe) # kg/m^3 sumheat = h1 * rho * initVolume # 单位:kJ,管道中预留的总热量 # 过热蒸汽到饱和蒸汽的过渡计算 while abs(tempe - satT) > 0.5: maxValue = tempe minValue = tempe - 1 seconds = 1 #计算出口的温度和压强 tempe, press,heatLossPerSquare,dQ,rho,h1,sumheat = calcOverHeatSteam(tempe, maxValue, minValue, press,seconds,innerDiameter, outerDiameter,oneInsulaDiameter,twoInsulaDiameter,pipeLength,insulaType,sumheat) count = count + 1 rho = 1 / seuif97.pt2v(press, tempe) h1 = seuif97.pt2h(press, tempe) # 输入的焓值,kJ/kg
# -*- coding: utf-8 -*- import seuif97 p = 0.00353658941 t = 300 - 273.15 s1 = seuif97.px2s(p, 0) s2 = seuif97.px2s(p, 1) h1 = seuif97.px2h(p, 0) h2 = seuif97.px2h(p, 1) x = 0.20 s = s1 + x * (s2 - s1) h = h1 + x * (h2 - h1) v = seuif97.hs2t(h, s) print(v) p = 3 t = 300 - 273.15 s = seuif97.ph2s(p, t) print(s) t = 310 - 273.15 s = seuif97.ph2s(p, t) print(s) s = seuif97.pt2s(0.000611212677444, 273.15) print(s) h = seuif97.pt2h(0.000611212677444, 273.15) print(h)
# -*- coding: utf-8 -*- import seuif97 p = 0.00353658941 t = 300 - 273.15 s1 = seuif97.px2s(p, 0) s2 = seuif97.px2s(p, 1) h1 = seuif97.px2h(p, 0) h2 = seuif97.px2h(p, 1) x = 0.20 s = s1 + x * (s2 - s1) h = h1 + x * (h2 - h1) v = seuif97.hs2t(h, s) print(v) p = 3 t = 300 - 273.15 s = seuif97.ph2s(p, t) print(s) t = 310 - 273.15 s = seuif97.ph2s(p, t) print(s) s = seuif97.pt2s(0.000611212677444, 273.15) print(s) h = seuif97.pt2h(0.000611212677444, 273.15) print(h)
def pt(self): self.h = if97.pt2h(self.p, self.t) self.s = if97.pt2s(self.p, self.t) self.v = if97.pt2v(self.p, self.t) self.x = None