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()
def _psat_T(T): """ given Temperature, return saturation pressure """ fs_T=np.float(T) if self.units.type == "altSI": fs_T=fs_T+273.15 elif self.units.type == "US": fs_T = ((fs_T-32.)/1.8) + 273.15 fs_val = freesteam.psat_T(fs_T) val=fs_val if self.units.type=="altSI": val=fs_val/1E5 elif self.units.type == "US": val=val / 1e5 * 14.5037738007 return val
from pylab import * import math figure() n = 400 TT = [273.15 + (freesteam.TCRIT - 273.15) * x / n for x in range(n + 1)] hf = [freesteam.region4_Tx(T, 0).h / 1e3 for T in TT] hg = [freesteam.region4_Tx(T, 1).h / 1e3 for T in TT] plot(hf, TT, 'b-') plot(hg, TT, 'r-') pp = logspace(-3, 3) * 1e5 # these are the pressures we're interested in here pp = [freesteam.psat_T(50 + 273.15), 3e6, 12e6, 165e5, 300e5] print("low p =", pp[0]) hh = arange(50., 4500., 100) * 1e3 hh1 = arange(50., 4500., 20) * 1e3 x = [] y = [] u = [] v = [] for p in pp: plot(hh1 / 1e3, [freesteam.steam_ph(p, h).T for h in hh1], alpha=0.8) if 0: for h in hh:
imshow(im, extent=[smin / 1e3, smax / 1e3, Tmin, Tmax], origin='lower', aspect='auto', interpolation='nearest', alpha=0.6) # SATURATION CURVES Tmin = 273.15 Tmax = freesteam.TCRIT n = 1000 DT = (Tmax - Tmin) / n TT0 = 273.15 + DT * array(range(n + 1)) psat = array([freesteam.psat_T(T) / 1e6 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] 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):
import math figure() hold(1) n = 400 TT = [273.15 + (freesteam.TCRIT - 273.15)*x/n for x in range(n+1)] hf = [freesteam.region4_Tx(T,0).h/1e3 for T in TT] hg = [freesteam.region4_Tx(T,1).h/1e3 for T in TT] plot(hf,TT,'b-') plot(hg,TT,'r-') pp = logspace(-3,3)*1e5 # these are the pressures we're interested in here pp = [freesteam.psat_T(50+273.15), 3e6, 12e6, 165e5, 300e5] print "low p =",pp[0] hh = arange(50.,4500.,100)*1e3 hh1 = arange(50.,4500.,20)*1e3 x = [] y = [] u = [] v = [] for p in pp: plot(hh1/1e3,[freesteam.steam_ph(p,h).T for h in hh1],alpha=0.8) if 0:
r = freesteam.region_Ts(T,s) #print "T = %f K, s = %f kg/kgK, region[%d,%d] = %d" % (T,s/1e3,x,y,r) im[x,y] = float(r) / 4. y += 1 x += 1 imshow(im,extent=[smin/1e3,smax/1e3,Tmin,Tmax],origin='lower',aspect='auto',interpolation='nearest',alpha=0.6) # SATURATION CURVES Tmin = 273.15 Tmax = freesteam.TCRIT n = 1000 DT = (Tmax - Tmin)/n TT0 = 273.15 + DT*array(range(n+1)) psat = array([freesteam.psat_T(T)/1e6 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] 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):
import freesteam import matplotlib matplotlib.use('gtkcairo') from pylab import * import math figure() hold(1) # SATURATION CURVE n = 400 TT0 = [273.15 + (freesteam.TCRIT - 273.15)*x/n for x in range(n+1)] psat = [freesteam.psat_T(T)/1e6 for T in TT0] # REGION MAP Tmin = 273.15 Tmax = 1073.15 DT = Tmax - Tmin pmin = 1e-3*1e5 pmax = 1e3*1e5 DP = pmax - pmin pp = arange(pmin,pmax,DP/400) #pp = logspace(-3,3)*1.e5 TT = arange(Tmin,Tmax,DT/500) im = zeros((len(pp),len(TT))) x = 0 for p in pp: #print "p = %f MPa" % (p/1e6) y = 0