def _pT_x(p,T): """ given pressure and Temperature, return quality """ if (np.isnan(p) or np.isnan(T)) : return np.nan fs_T,fs_p=self._get_SI_TempPress(T,p,self.units.type) fs_val = freesteam.steam_pT(fs_p, fs_T).x val=fs_val return val
def _pT_rho(p,T): """ given pressure and Temperature, return density """ fs_T,fs_p=self._get_SI_TempPress(T,p,self.units.type) fs_val = freesteam.steam_pT(fs_p, fs_T).rho val=fs_val if self.units.type == "US": val=fs_val * 0.06242796 return val
def _pT_u(p,T): """ given pressure and Temperature, return specific energy """ fs_T,fs_p=self._get_SI_TempPress(T,p,self.units.type) fs_val = freesteam.steam_pT(fs_p, fs_T).u val=fs_val if self.units.type=="altSI": val=fs_val/1000. elif self.units.type=="US": val=fs_val * 0.000429922614 return val
for h in hh: try: 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]')
for h in hh: try: 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]')
def setup(num_output_times=10, tfinal=3, nx=200, kernel_language='Python', use_petsc=False, solver_type='classic', weno_order=5, time_integrator='SSP104', outdir='./_output'): if use_petsc: import clawpack.petclaw as pyclaw else: from clawpack import pyclaw if kernel_language == 'Fortran': riemann_solver = riemann.advection_1D elif kernel_language == 'Python': riemann_solver = riemann.advection_1D_py.advection_1D if solver_type == 'classic': solver = pyclaw.ClawSolver1D(riemann_solver) solver.step_source = step_Euler_radial solver.dt_variable = True solver.cfl_desired = 0.9 solver.max_steps = 50000 elif solver_type == 'sharpclaw': solver = pyclaw.SharpClawSolver1D(riemann_solver) solver.dq_src = dq_Euler_radial solver.weno_order = weno_order solver.dt_variable = True solver.cfl_desired = 0.9 solver.time_integrator = time_integrator solver.max_steps = 50000 if time_integrator == 'SSPLMMk3': solver.lmm_steps = 5 solver.check_lmm_cond = True else: raise Exception('Unrecognized value of solver_type.') solver.kernel_language = kernel_language verbosity = 1 total_steps = 30 solver.bc_lower[0] = pyclaw.BC.extrap #periodic solver.bc_upper[0] = pyclaw.BC.extrap #periodic # x = pyclaw.Dimension(0.0,xl,nx,name='x') L = 1.577944e-01 print("L=", L) x0 = -1.5 * L x1 = 4 * L x = pyclaw.Dimension(x0, x1, nx, name='x') domain = pyclaw.Domain(x) state = pyclaw.State(domain, solver.num_eqn) Tin = 15 rho = st.steam_pT(10 * 1e+5, Tin + 273).rho cp = st.steam_pT(10 * 1e+5, Tin + 273).cp print("rho=", rho) print("cp=", cp) print("rhocp=", rho * cp) Flow = 140.e-3 Section = 262.292e-6 \ + 139.392e-6 \ + 176.149e-6 \ + 217.995e-6 \ + 264.365e-6 \ + 315.259e-6 \ + 373.504e-6 \ + 439.1e-6 \ + 511.483e-6 \ + 590.085e-6 \ + 674.908e-6 \ + 765.952e-6 \ + 863.215e-6 \ + 961.045e-6 \ + 292.364e-6 print("Section=", Section) Power1 = 12.5e+6 print("Power=", Power1) Qth = Power1 / (Section * (2 * L)) print("delta T = Pe/(rho Cp Debit)=", Power1 / (rho * cp * Flow)) print("Qth = Power / ( Section * (2*L) )=", Qth, "Qth/(rhocp)=", Qth / (rho * cp), "Q=", Qth / 100.) u = Flow / Section print("u = Flow / Section=", u, "u/rhocp=", u / (rho * cp)) state.problem_data['rhocp'] = rho * cp # Specific Heat state.problem_data['u'] = u # Advection velocity state.problem_data['L'] = L # Advection velocity state.problem_data['Power1'] = Power1 # Advection velocity state.problem_data['Q'] = Qth / (rho * cp) # Advection velocity # Initial data xc = state.grid.x.centers state.q[0, :] = Tin claw = pyclaw.Controller() claw.keep_copy = True claw.solution = pyclaw.Solution(state, domain) claw.solver = solver if outdir is not None: claw.outdir = outdir else: claw.output_format = None claw.tfinal = tfinal claw.setplot = setplot claw.num_output_times = num_output_times return claw
# encoding: utf-8 import freesteam import matplotlib matplotlib.use('gtkcairo') from pylab import * import math, sys # Plot a curve of density with temperature for different pressures. We're # especially interested here in the supercritical curves. pp = [ 1e4, 5e4, 1e5, 5e5, 1e6, 5e6, 10e6, 20e6, 22e6, 23e6, 25e6, 30e6, 50e6, 100e6 ] figure() hold(1) for p in pp: TT = arange(0, 800, 2) + 273.15 rrho = [freesteam.steam_pT(p, T).rho for T in TT] plot(TT - 273.15, rrho, label='%f MPa' % (p / 1e6)) xlabel(u"Temperature / [°C]") ylabel(u"Density / [kg/m³]") legend() show()
def rho(bar, celsius): pascal = bar * 1e+5 kelvin = celsius + 273. rho = st.steam_pT(pascal, kelvin).rho return rho
def cp(bar, celsius): pascal = bar * 1e+5 kelvin = celsius + 273. cp = st.steam_pT(pascal, kelvin).cp return cp
# encoding: utf-8 import freesteam import matplotlib matplotlib.use("gtkcairo") from pylab import * import math, sys # Plot a curve of density with temperature for different pressures. We're # especially interested here in the supercritical curves. pp = [1e4, 5e4, 1e5, 5e5, 1e6, 5e6, 10e6, 20e6, 22e6, 23e6, 25e6, 30e6, 50e6, 100e6] figure() hold(1) for p in pp: TT = arange(0, 800, 2) + 273.15 rrho = [freesteam.steam_pT(p, T).rho for T in TT] plot(TT - 273.15, rrho, label="%f MPa" % (p / 1e6)) xlabel(u"Temperature / [°C]") ylabel(u"Density / [kg/m³]") legend() show()
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 for T in TT: S = freesteam.steam_pT(p,T) #print "p = %f, T = %f" % (p,T) r = S.region #print "p = %f MPa, T = %f K, region[%d,%d] = %d" % (p/1e6,T,x,y,r) im[x,y] = float(r) / 4. y += 1 x += 1 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-')
def cp(bar, celsius): """compute cp""" pascal = bar * 1e+5 kelvin = celsius + 273. return st.steam_pT(pascal, kelvin).cp
def rho(bar, celsius): """compute rho""" pascal = bar * 1e+5 kelvin = celsius + 273. return st.steam_pT(pascal, kelvin).rho
# Add some more columns # Helix Magnet if not 'U1' in keys: # print("Create extra columns [ie: U1,U2,...]") df['U1'] = 0 for i in range(15): ukey = "Ucoil%d" % i if ukey in keys: df['U1'] += df[ukey] df['Pe1'] = df.apply(lambda row: row.U1 * row.Icoil1 / 1.e+6, axis=1) df['DP1'] = df['HP1'] - df['BP'] # Get Water property df['rho1'] = df.apply( lambda row: st.steam_pT(row.BP * 1e+5, row.Tin1 + 273.).rho / 1., axis=1) df['cp1'] = df.apply( lambda row: st.steam_pT(row.BP * 1e+5, row.Tin1 + 273.).cp / 1., axis=1) for i in range(1, 6): df['DT1'] = df.apply(lambda row: row.Pe1 * 1.e+6 / (row.rho1 * row.cp1 * row.Flow1 * 1.e-3) if (row.Flow1 != 0) else row.Tin1, axis=1) # Water Property at BP bar, Tin+DT1 df['rho1'] = df.apply(lambda row: st.steam_pT( (row.BP + row.DP1 / 2.) * 1e+5, (row.Tin1 + row.DT1 / 2.) + 273.).rho / 1.,