def plot_tsp3d(): fig = plt.figure() ax = Axes3D(fig) pp = np.logspace(-3, 3, 20) ss = np.linspace(0., 10., 40) xdata, ydata = np.meshgrid(pp, ss) zdata = np.zeros(xdata.shape) for i, p in enumerate(pp): for j, s in enumerate(ss): T = None if not freesteam.bounds_ps(p * 1e5, s * 1e3, 0): try: T = freesteam.steam_ps(p * 1e5, s * 1e3).T except: pass zdata[j, i] = T ax.plot_wireframe(xdata, ydata, zdata, rstride=1, cstride=1) ax.set_xlabel('Pressure / [bar]') ax.set_ylabel('Entropy / [kJ/kgK]') ax.set_zlabel('Temperature / [K]') TT0 = np.linspace(273.15, freesteam.TCRIT, 100) psat = [freesteam.psat_T(T) / 1e5 for T in TT0] sf = [freesteam.region4_Tx(T, 0).s / 1e3 for T in TT0] sg = [freesteam.region4_Tx(T, 1).s / 1e3 for T in TT0] ax.plot(psat, sf, TT0, 'k-') ax.plot(psat, sg, TT0, 'r-') plt.show()
def plot_tsp3d(): fig = plt.figure() ax = Axes3D(fig) pp = np.logspace(-3,3,20) ss = np.linspace(0.,10., 40) xdata,ydata = np.meshgrid(pp, ss) zdata = np.zeros(xdata.shape) for i, p in enumerate(pp): for j, s in enumerate(ss): T = None if not freesteam.bounds_ps(p*1e5,s*1e3,0): try: T = freesteam.steam_ps(p*1e5,s*1e3).T except: pass zdata[j, i]= T ax.plot_wireframe(xdata, ydata, zdata, rstride=1, cstride=1) ax.set_xlabel('Pressure / [bar]') ax.set_ylabel('Entropy / [kJ/kgK]') ax.set_zlabel('Temperature / [K]') TT0 = np.linspace(273.15, freesteam.TCRIT, 100) psat = [freesteam.psat_T(T)/1e5 for T in TT0] sf = [freesteam.region4_Tx(T,0).s/1e3 for T in TT0] sg = [freesteam.region4_Tx(T,1).s/1e3 for T in TT0] ax.plot(psat, sf, TT0,'k-') ax.plot(psat, sg, TT0,'r-') plt.show()
S = freesteam.steam_ph(p, h) x += [S.h / 1.e3] y += [S.T] dy = freesteam.freesteam_deriv(S, 'T', 'h', 'p') dx = 0.0005 m = math.sqrt(dx**2 + dy**2) u += [dx / m] v += [dy / m] except: pass plot([0, 4500], [550 + 273.15, 550 + 273.15], 'b--') s = freesteam.steam_pT(12e6, 550 + 273.15).s pp = linspace(3e6, 12e6) hh = [freesteam.steam_ps(p, s).h / 1e3 for p in pp] TT = [freesteam.steam_ps(p, s).T for p in pp] plot(hh, TT, 'g--') if 1: s = freesteam.steam_pT(3e6, 550 + 273.15).s pp = linspace(0.1e5, 3e6) hh = [freesteam.steam_ps(p, s).h / 1e3 for p in pp] TT = [freesteam.steam_ps(p, s).T for p in pp] plot(hh, TT, 'g--') quiver(x, y, u, v, alpha=1) axis([0, 4500, 273.15, 1073.15]) xlabel('h / [kJ/kg]') ylabel('T / [K]')
sg = [freesteam.region4_Tx(T, 1).s / 1e3 for T in TT0] plot(sf, TT0, 'b-') plot(sg, TT0, 'r-') # LINES OF CONSTANT PRESSURE pp = logspace(-3, 3, 50) * 1e5 ss = arange(0., 10., 0.1) * 1e3 for p in pp: TT = [] for s in ss: T = None if not freesteam.bounds_ps(p, s, 0): try: T = freesteam.steam_ps(p, s).T except: pass TT += [T] plot(ss / 1e3, TT, alpha=0.4) #sys.exit(1) # QUIVER SHOWING PARTIAL DERVIATIVE (dT/ds)p ss1 = arange(0., 10., 0.5) * 1e3 x = [] y = [] u = [] v = [] for p in pp:
S = freesteam.steam_ph(p,h) x += [S.h/1.e3] y += [S.T] dy = freesteam.freesteam_deriv(S,'T','h','p') dx = 0.0005 m = math.sqrt(dx**2 + dy**2) u += [dx/m] v += [dy/m] except: pass plot([0,4500],[550+273.15,550+273.15],'b--') s = freesteam.steam_pT(12e6, 550+273.15).s pp = linspace(3e6,12e6) hh = [freesteam.steam_ps(p,s).h/1e3 for p in pp] TT = [freesteam.steam_ps(p,s).T for p in pp] plot(hh,TT,'g--') if 1: s = freesteam.steam_pT(3e6, 550+273.15).s pp = linspace(0.1e5,3e6) hh = [freesteam.steam_ps(p,s).h/1e3 for p in pp] TT = [freesteam.steam_ps(p,s).T for p in pp] plot(hh,TT,'g--') quiver(x,y,u,v,alpha=1) axis([0,4500,273.15,1073.15]) xlabel('h / [kJ/kg]') ylabel('T / [K]') show()
sg = [freesteam.region4_Tx(T,1).s/1e3 for T in TT0] plot(sf,TT0,'b-') plot(sg,TT0,'r-') # LINES OF CONSTANT PRESSURE pp = logspace(-3,3,50)*1e5 ss = arange(0.,10.,0.1)*1e3 for p in pp: TT = [] for s in ss: T = None if not freesteam.bounds_ps(p,s,0): try: T = freesteam.steam_ps(p,s).T except: pass TT += [T] plot(ss/1e3,TT,alpha=0.4) #sys.exit(1) # QUIVER SHOWING PARTIAL DERVIATIVE (dT/ds)p ss1 = arange(0.,10.,0.5)*1e3 x = [] y = [] u = [] v = [] for p in pp:
continue S = freesteam.steam_Ts(T,s) if p < 20e6: freesteam.bounds_ph(S.p, S.h,1) if S.h < 0: raise RuntimeError("failed to solve in bounds T = %f, s = %f" % (T,s)) hh += [S.h/1e3] pp += [S.p/1e6] plot(hh,pp,'g-') # LINES OF CONSTANT ENTROPY ss = linspace(1,11,30) * 1e3 for s in ss: print "s =",s Tmin = freesteam.steam_ps(freesteam.PMAX,s).T Tmax = freesteam.steam_ps(freesteam.PTRIPLE,s).T TT = linspace(Tmin,Tmax,1000) #print "smin =",smin, ", smax =",smax #continue hh = [] pp = [] for T in TT: if freesteam.bounds_Ts(T,s,0): continue S = freesteam.steam_Ts(T,s) hh += [S.h/1e3] pp += [S.p/1e6] plot(hh,pp,'r-') # plot the sat curve on top
S = freesteam.steam_Ts(T, s) if p < 20e6: freesteam.bounds_ph(S.p, S.h, 1) if S.h < 0: raise RuntimeError("failed to solve in bounds T = %f, s = %f" % (T, s)) hh += [S.h / 1e3] pp += [S.p / 1e6] plot(hh, pp, 'g-') # LINES OF CONSTANT ENTROPY ss = linspace(1, 11, 30) * 1e3 for s in ss: print "s =", s Tmin = freesteam.steam_ps(freesteam.PMAX, s).T Tmax = freesteam.steam_ps(freesteam.PTRIPLE, s).T TT = linspace(Tmin, Tmax, 1000) #print "smin =",smin, ", smax =",smax #continue hh = [] pp = [] for T in TT: if freesteam.bounds_Ts(T, s, 0): continue S = freesteam.steam_Ts(T, s) hh += [S.h / 1e3] pp += [S.p / 1e6] plot(hh, pp, 'r-') # plot the sat curve on top
imshow(im,extent=[Tmin,Tmax,pmin/1e6,pmax/1e6],origin='lower',aspect='auto',interpolation='nearest',alpha=0.6) # LINES OF CONSTANT ENTHALPY hh = arange(100,4500,200)*1e3 for h in hh: TT2 = [freesteam.steam_ph(p,h).T for p in pp] plot(TT2,pp/1e6,'g-') plot(TT0,psat,'b-') axis([Tmin,Tmax,pmin/1e6,pmax/1e6]) #quiver(x,y,u,v,alpha=0.6) # LINES OF CONSTANT ENTROPY ss = arange(0,12,1./3)*1e3 for s in ss: TT2 = [freesteam.steam_ps(p,s).T for p in pp] plot(TT2,pp/1e6,'r:') plot(TT0,psat,'b-') axis([Tmin,Tmax,pmin/1e6,pmax/1e6]) #quiver(x,y,u,v,alpha=0.6) xlabel('T / [K]') ylabel('p / [MPa]') show()
if freesteam.bounds_Ts(T,s,0): continue S = freesteam.steam_Ts(T,s) uu += [S.u/1e3] pp += [S.p/1e6] plot(uu,pp,'g-') # LINES OF CONSTANT ENTROPY sgpmin = freesteam.region4_Tx(freesteam.Tsat_p(freesteam.PTRIPLE),1.).s print sgpmin ss = logspace(math.log10(1e3),math.log10(12e3),30) for s in ss: print "s =",s Tmax = freesteam.steam_ps(100e6,s).T if s<sgpmin: Tmin = freesteam.TMIN else: Tmin = freesteam.steam_ps(freesteam.PTRIPLE,s).T print "Tmin = %f, Tmax = %f" %(Tmin,Tmax) TT = linspace(Tmin,Tmax,1000) uu = [] pp = [] for T in TT: #print T if freesteam.bounds_Ts(T,s,0): continue S = freesteam.steam_Ts(T,s) uu += [S.u/1e3] pp += [S.p/1e6]