from CoolProp.CoolProp import PropsSI import pylab, numpy as np from ACHP.Correlations import ShahEvaporation_Average x = np.linspace(0, 1, 1000) h = np.zeros_like(x) TsatL, TsatV = 300., 300. p = PropsSI('P', 'T', TsatL, 'Q', 0, 'R134a') for i in range(len(x)): h[i] = ShahEvaporation_Average(x[i], x[i], 'R134a', 300, 0.01, p, 200, TsatL, TsatV) havg = np.trapz(h, x=x) pylab.figure(figsize=(7, 5)) pylab.axhline(havg, ls='--') pylab.text(0.2, havg, r'$\alpha_{avg}$', ha='center', va='bottom') pylab.text( 0.7, 1300, 'R134a\nG=300 kg/m$^2$\nD=0.01 m\nq\"=200 W/m$^2$\np=%0.1f kPa' % (p / 1000)) pylab.gca().set_xlabel('x [-]') pylab.gca().set_ylabel(r'$\alpha$ [W/m$^2$/K]') pylab.plot(x, h) pylab.title('Shah Evaporation HTC as a function of quality') pylab.show()
def updateHeatFlux(): # double tube system (outer is downward/innner is upward) # Local Reynolds number and Prandtl numbers for k in range(0,NZ): Redtube[k] = UDmean * dD / mutube[k] for k in range(NZ,2*NZ): Redtube[k] = UUmean * dU / mutube[k] #print(UDmean, UUmean, dD, dU, mutube[1], np.ndarray.max(Redtube)) # update boundary heat transfer coeffcients for k in range(0,NZ): htctube[k,0] = htc_DB(Redtube[2*NZ-1-k], Prtube[2*NZ-1-k], tktube[2*NZ-1-k], dU) htctube[k,1] = htc_DB(Redtube[k] , Prtube[k] , tktube[k] , dD) htctube[k,2] = htc_DB(Redtube[k] , Prtube[k] , tktube[k] , dD) htctube[k,3] = htc_OUT(Z[k]) # insulation factors tkPipe_inner_insFactor = np.ones(NZ,dtype=float) for k in range(NZ,2*NZ): if Ztube[k] <= 500.0: kk = 2*NZ-1-k tkPipe_inner_insFactor[kk] = 0.1 tkPipe_outer_insFactor = np.ones(NZ,dtype=float) for k in range(0,NZ): if Ztube[k] <= 150.0: tkPipe_outer_insFactor[k] = 0.1 # update input heat flux, W ## outer tube heat budget downward, W for k in range(0,NZ): # CV in-flux if k == 0: hf_in = UDmean * (Dtube[k]*cptube[k]*Tin) * AD else: hf_in = UDmean * (Dtube[k-1]*cptube[k-1]*Ttube[k-1]) * AD # CV radial in-flux Regist = 1./(htctube[k,0]*Ri1)+math.log(Ro1/Ri1)/(tkPipe_inner*tkPipe_inner_insFactor[k]) + 1./(htctube[k,1]*Ro1) hf_ri = 2 * math.pi * DZtube[k] / Regist * (Ttube[2*NZ-1-k] - Ttube[k]) # CV radial out-flux hf_ro = 0.0 Registo = 1./(htctube[k,2]*Ri2)+math.log(Ro2/Ri2)/(tkPipe*tkPipe_outer_insFactor[k])+ 1./(htctube[k,3]*Ro2) sumArea = 0.0 for j in range(NT): iadj = kj2iadj[k,j,0] jadj = kj2iadj[k,j,1] sumArea = sumArea + faceArea[iadj,jadj] for j in range(NT): iadj = kj2iadj[k,j,0] jadj = kj2iadj[k,j,1] areaWeight = faceArea[iadj,jadj]/sumArea fluxExt[iadj,jadj] = 2 * math.pi * DZtube[k] / Registo * (Ttube[k] - t[iadj]) * areaWeight # W hf_ro = hf_ro + fluxExt[iadj,jadj] # CV out-flux hf_out = UDmean * (Dtube[k]*cptube[k]*Ttube[k]) * AD # net flux netHeattube[k] = hf_in - hf_out + hf_ri - hf_ro ## inner tube heat budget upward, W for k in range(NZ,2*NZ): kk = 2*NZ-1-k # CV in-flux if kk == NZ-1: hf_in = UUmean * (Dtube[kk]*cptube[kk]*Ttube[kk]) * AU else: hf_in = UUmean * (Dtube[k-1]*cptube[k-1]*Ttube[k-1]) * AU # CV radial out-flux Registi = 1./(htctube[kk,0]*Ri1)+math.log(Ro1/Ri1)/(tkPipe_inner*tkPipe_inner_insFactor[kk]) + 1./(htctube[kk,1]*Ro1) hf_ro = 2 * math.pi * DZtube[k] / Registi * (Ttube[k] - Ttube[2*NZ-1-k]) # CV out-flux hf_out = UUmean * (Dtube[k]*cptube[k]*Ttube[k]) * AU # net flux netHeattube[k] = hf_in - hf_ro - hf_out # update WF state (temperature (Euler) and pressure, etc.) for k in range(2*NZ): Ttuben[k] = Ttube[k] + netHeattube[k]/(Dtube[k]*cptube[k]*Vtube[k]) * dtime Ptube[k] = Pin + Dtube[k]*cg*Ztube[k] #Ptube[k] = PropsSI('P','T',Ttube[k],'Q',Qtube[k],'Water') Dtube[k] = PropsSI('D','T',Ttube[k],'P',Ptube[k],'Water') htube[k] = PropsSI('H','T',Ttube[k],'P',Ptube[k],'Water') mutube[k] = PropsSI('V','T',Ttube[k],'P',Ptube[k],'Water')/Dtube[k] # m2/s Prtube[k] = PropsSI('PRANDTL','T',Ttube[k],'P',Ptube[k],'Water') tktube[k] = PropsSI('CONDUCTIVITY','T',Ttube[k],'P',Ptube[k],'Water') cptube[k] = PropsSI('C','T',Ttube[k],'P',Ptube[k],'Water') Ttube[:] = Ttuben[:] # calc. thermal budget TotalWatt = 0.0 for k in range(NZ): for j in range(NT): iadj = kj2iadj[k,j,0] jadj = kj2iadj[k,j,1] # minus means outward flux (e.g.,inward ground) "fluxExt" is positive. # note that fluxExt is in [W] TotalWatt = TotalWatt - fluxExt[iadj,jadj] return TotalWatt
def TwoStage(Ref, Q, Te, Tc, DTsh, DTsc, eta_oi, f_p, Tsat_ic, DTsh_ic, Ts_Ph='Ph', prints=False, skipPlot=False, axis=None, **kwargs): """ This function plots a two-stage cycle, on the current axis, or that given by the optional parameter *axis* Required parameters: * Ref : Refrigerant [string] * Q : Cooling capacity [W] * Te : Evap Temperature [K] * Tc : Condensing Temperature [K] * DTsh : Evaporator outlet superheat [K] * DTsc : Condenser outlet subcooling [K] * eta_oi : Adiabatic efficiency of compressor (no units) in range [0,1] * f_p : fraction of compressor power lost as ambient heat transfer in range [0,1] * Tsat_ic : Saturation temperature corresponding to intermediate pressure [K] * DTsh_ic : Superheating at outlet of intermediate stage [K] Optional parameters: * Ts_Ph : 'Ts' for a Temperature-Entropy plot, 'Ph' for a Pressure-Enthalpy * prints : True to print out some values * axis : An axis to use instead of the active axis * skipPlot : If True, won't actually plot anything, just print COP """ warnings.warn( "This function has been deprecated. PLease consider converting it to an object inheriting from \"BaseCycle\".", DeprecationWarning) T = np.zeros((8)) h = np.zeros_like(T) p = np.zeros_like(T) s = np.zeros_like(T) rho = np.zeros_like(T) T[0] = np.NAN s[0] = np.NAN T[1] = Te + DTsh pe = PropsSI('P', 'T', Te, 'Q', 1.0, Ref) pc = PropsSI('P', 'T', Tc, 'Q', 1.0, Ref) pic = PropsSI('P', 'T', Tsat_ic, 'Q', 1.0, Ref) Tbubble_c = PropsSI('T', 'P', pc, 'Q', 0, Ref) Tbubble_e = PropsSI('T', 'P', pe, 'Q', 0, Ref) h[1] = PropsSI('H', 'T', T[1], 'P', pe, Ref) s[1] = PropsSI('S', 'T', T[1], 'P', pe, Ref) rho[1] = PropsSI('D', 'T', T[1], 'P', pe, Ref) T[5] = Tbubble_c - DTsc h[5] = PropsSI('H', 'T', T[5], 'P', pc, Ref) s[5] = PropsSI('S', 'T', T[5], 'P', pc, Ref) rho[5] = PropsSI('D', 'T', T[5], 'P', pc, Ref) mdot = Q / (h[1] - h[5]) rho1 = PropsSI('D', 'T', T[1], 'P', pe, Ref) h2s = PropsSI('H', 'S', s[1], 'P', pic, Ref) Wdot1 = mdot * (h2s - h[1]) / eta_oi h[2] = h[1] + (1 - f_p) * Wdot1 / mdot T[2] = PropsSI('T', 'H', h[2], 'P', pic, Ref) s[2] = PropsSI('S', 'T', T[2], 'P', pic, Ref) rho[2] = PropsSI('D', 'T', T[2], 'P', pic, Ref) T[3] = 288 p[3] = pic h[3] = PropsSI('H', 'T', T[3], 'P', pic, Ref) s[3] = PropsSI('S', 'T', T[3], 'P', pic, Ref) rho[3] = PropsSI('D', 'T', T[3], 'P', pic, Ref) rho3 = PropsSI('D', 'T', T[3], 'P', pic, Ref) h4s = PropsSI('H', 'T', s[3], 'P', pc, Ref) Wdot2 = mdot * (h4s - h[3]) / eta_oi h[4] = h[3] + (1 - f_p) * Wdot2 / mdot T[4] = PropsSI('T', 'H', h[4], 'P', pc, Ref) s[4] = PropsSI('S', 'T', T[4], 'P', pc, Ref) rho[4] = PropsSI('D', 'T', T[4], 'P', pc, Ref) sbubble_e = PropsSI('S', 'T', Tbubble_e, 'Q', 0, Ref) sbubble_c = PropsSI('S', 'T', Tbubble_c, 'Q', 0, Ref) sdew_e = PropsSI('S', 'T', Te, 'Q', 1, Ref) sdew_c = PropsSI('S', 'T', Tc, 'Q', 1, Ref) hsatL = PropsSI('H', 'T', Tbubble_e, 'Q', 0, Ref) hsatV = PropsSI('H', 'T', Te, 'Q', 1, Ref) ssatL = PropsSI('S', 'T', Tbubble_e, 'Q', 0, Ref) ssatV = PropsSI('S', 'T', Te, 'Q', 1, Ref) vsatL = 1 / PropsSI('D', 'T', Tbubble_e, 'Q', 0, Ref) vsatV = 1 / PropsSI('D', 'T', Te, 'Q', 1, Ref) x = (h[5] - hsatL) / (hsatV - hsatL) s[6] = x * ssatV + (1 - x) * ssatL T[6] = x * Te + (1 - x) * Tbubble_e rho[6] = 1.0 / (x * vsatV + (1 - x) * vsatL) h[6] = h[5] h[7] = h[1] s[7] = s[1] T[7] = T[1] p = [np.nan, pe, pic, pic, pc, pc, pe, pe] COP = Q / (Wdot1 + Wdot2) RE = h[1] - h[6] if prints == True: print('x5:', x) print('COP:', COP) print('COPH', (Q + Wdot1 + Wdot2) / (Wdot1 + Wdot2)) print(T[2] - 273.15, T[4] - 273.15, p[2] / p[1], p[4] / p[3]) print(mdot, mdot * (h[4] - h[5]), pic) print('Vdot1', mdot / rho1, 'Vdisp', mdot / rho1 / (3500 / 60.) * 1e6 / 0.7) print('Vdot2', mdot / rho3, 'Vdisp', mdot / rho3 / (3500 / 60.) * 1e6 / 0.7) print(mdot * (h[4] - h[5]), Tc - 273.15) for i in range(1, len(T) - 1): print('%d & %g & %g & %g & %g & %g \\\\' % (i, T[i] - 273.15, p[i], h[i], s[i], rho[i])) else: print(Tsat_ic, COP) if skipPlot == False: if axis == None: ax = matplotlib.pyplot.gca() else: ax = axis if Ts_Ph in ['ph', 'Ph']: ax.plot(h, p) elif Ts_Ph in ['Ts', 'ts']: s_copy = s.copy() T_copy = T.copy() for i in range(1, len(s) - 1): ax.plot(s[i], T[i], 'bo', mfc='b', mec='b') dT = [0, -5, 5, -20, 5, 5, 5] ds = [0, 0.05, 0, 0, 0, 0, 0] ax.text(s[i] + ds[i], T[i] + dT[i], str(i)) s = list(s) T = list(T) s.insert(7, sdew_e) T.insert(7, Te) s.insert(5, sbubble_c) T.insert(5, Tbubble_c) s.insert(5, sdew_c) T.insert(5, Tc) ax.plot(s, T) s = s_copy T = T_copy else: raise TypeError('Type of Ts_Ph invalid') return COP
def sg(self, T: Iterable): return [ PropsSI('S', 'T', t, 'Q', 1, self.eos + "::" + self.name) if (self.Tmin < t < self.Tmax) else None for t in T ]
def create_Hs_diagram(H, S, H1, H01, S1, H2, H02, S2, H2s, S2s, H3, H03, S3, H3s, S3s, H4, H04, S4, P1, P2, P3, P4, dome1h, dome2h, dome1, dome2, criticalisobar): #creating isobars stator_inlet = PropsSI("H", "P", P1, "S", S, 'Toluene') * 1e-3 stator_outlet = PropsSI("H", "P", P2, "S", S, 'Toluene') * 1e-3 rotor_outlet = PropsSI("H", "P", P3, "S", S, 'Toluene') * 1e-3 condenser_inlet = PropsSI("H", "P", P4, "S", S, 'Toluene') * 1e-3 #creating contour dftemp = pd.DataFrame(H, columns=['H']) dfentr = pd.DataFrame(S, columns=['S']) dftemp['key'] = 1 dfentr['key'] = 1 df = dftemp.merge(dfentr, how='outer')[['S', 'H']] df['Z'] = df.apply( lambda x: PropsSI('Z', 'H', x['H'], 'S', x['S'], 'Toluene'), axis=1) df['phase'] = df.apply( lambda x: PropsSI('Phase', 'H', x['H'], 'S', x['S'], 'Toluene'), axis=1) gas = df['phase'] == CP.get_phase_index('phase_gas') supercritical_gas = df['phase'] == CP.get_phase_index( 'phase_supercritical_gas') df_filter = df[gas | supercritical_gas][['H', "S", "Z"]] df_filter['H'] = df_filter['H'] * 1e-3 df_filter['S'] = df_filter['S'] * 1e-3 hdfpivot = df_filter.pivot('H', 'S') X = hdfpivot.columns.levels[1].values Y = hdfpivot.index.values Z = hdfpivot.values Xi, Yi = np.meshgrid(X, Y) fig, ax = plt.subplots(figsize=(10, 7)) # isobars ax.plot(S * 1e-3, H01 * np.ones(np.size(S)) * 1e-3, color='black', linestyle=':') fig.text(0.15, 0.77, "$\displaystyle h_{01}$", fontsize=20) ax.plot(S * 1e-3, H03 * np.ones(np.size(S)) * 1e-3, color='black', linestyle=':') fig.text(0.15, 0.5, "$\displaystyle h_{03}$", fontsize=20) #isobars ax.plot(S * 1e-3, stator_inlet, color='black', linestyle='--') fig.text(0.3, 0.65, "{:4.2f}".format(P1 / 1e5) + ' [Bar]') ax.plot(S * 1e-3, stator_outlet, color='black', linestyle='--') fig.text(0.3, 0.42, "{:4.2f}".format(P2 / 1e5) + ' [Bar]') ax.plot(S * 1e-3, rotor_outlet, color='black', linestyle='--') fig.text(0.3, 0.29, "{:4.2f}".format(P3 / 1e5) + ' [Bar]') ax.plot(S * 1e-3, condenser_inlet, color='black', linestyle='--') fig.text(0.3, 0.33, "{:4.2f}".format(P4 / 1e5) + ' [Bar]') # ax.plot(S, condenser_inlet, color='black', linestyle='--') # dome ax.plot(dome1 * 1e-3, dome1h * 1e-3, color='black') ax.plot(dome2 * 1e-3, dome2h * 1e-3, color='black') # process ax.plot([S1 * 1e-3, S2 * 1e-3, S3 * 1e-3, S4 * 1e-3], [H1 * 1e-3, H2 * 1e-3, H3 * 1e-3, H4 * 1e-3], color='black', marker="X") #isentropic process ax.plot([S1 * 1e-3, S2s * 1e-3], [H1 * 1e-3, H2s * 1e-3], color='black', marker="o") ax.plot([S2 * 1e-3, S3s * 1e-3], [H2 * 1e-3, H3s * 1e-3], color='black', marker="o") # compressibility fig = ax.contourf(Xi, Yi, Z, 25, alpha=0.7, cmap=plt.cm.jet) ax.set_xlim([.850, 1.5]) ax.ticklabel_format(fontsize=20) ax.set_ylim([200, 700]) ax.set_xlabel(r'Entropy [KJ/kgK]', fontsize=15) ax.set_ylabel(r'Enthalpy [KJ/kg]', fontsize=15) cb = plt.colorbar(fig) cb.set_label(r"Compressibility factor [-]", fontsize=15) return fig, ax
def dvg_dP_saturation(self): dP = 0.002 rho1 = PropsSI('D', 'P', self.state.p() + dP / 2, 'Q', 1, self.name) rho0 = PropsSI('D', 'P', self.state.p() - dP / 2, 'Q', 1, self.name) dvg = 1 / rho1 - 1 / rho0 return dvg / dP
def psat(self, T: Iterable): return [ PropsSI('P', 'Q', 0.5, 'T', t, self.eos + "::" + self.name) if (self.Tmin < t < self.Tmax) else None for t in T ]
# -------------- # analysis conditions - fixed # -------------- p_in = 100.0 # [bar] p_out = 1.01325 # [bar] t_in = 298.15 # [K] t_out = 298.15 # [K] RPM = 3600 # [rpm] # -------------- # specific work # -------------- # air properties fluid = 'Air.mix' CP = PropsSI('CPMASS', "T", t_in, "P", p_in, fluid) # J/Kg-K CV = PropsSI('CVMASS', "T", t_in, "P", p_in, fluid) # J/Kg-K k = CP / CV MW = PropsSI('M', fluid) * 1000.0 # kg/kmol R_bar = PropsSI('GAS_CONSTANT', fluid) # kJ/kmol/K R = R_bar / MW # kJ/kg-K # polytropic work n = k # polytropic exponent t2 = t_in * (p_out / p_in) ** ((n - 1.0) / n) # [K] w = 1.0 * R * (t2 - t_in) / (1.0 - n) # [kJ/kg] # -------------- # run sweep # -------------- pwrs = [0.5, 1.0, 5.0, 10.0, 50.0, 100.0, 500.0, 1000.0] # [MW] pistons = [False]
def calc_temperature(self): # Calculate temperature based on saturation curve T = PropsSI("T", "Q", 0, "P", self.storage_pressure, self.coolprop_name) self.storage_temperature = T return T
def Calculate(self): #Update the parameters self.Update() #Average mass flux of refrigerant [kg/m^2-s] self.G_r = self.mdot_r / (pi * self.ID_i**2 / 4.0) #Average mass flux of glycol [kg/m^2-s] self.G_g = self.mdot_g / (pi * (self.ID_o**2 - self.OD_i**2) / 4.0) #Hydraulic diameter self.Dh_g = self.ID_o - self.OD_i #Evaporation hydraulic diameter [m] self.Dh_r = self.ID_i #Thermal conductivity of the intermediate wall pipe self.k = self.Conductivity #Thermal Conduction Resistance of the intermediate wall self.Rw = log(self.OD_i / self.ID_i) / (2 * pi * self.k * self.L) self.Tbubble_r = PropsSI('T', 'P', self.pin_r, 'Q', 0, self.Ref_r) self.Tdew_r = PropsSI('T', 'P', self.pin_r, 'Q', 1, self.Ref_r) self.Tsat_r = (self.Tbubble_r + self.Tdew_r) / 2.0 #Inlet enthalpy hsatL = PropsSI('H', 'T', self.Tbubble_r, 'Q', 0, self.Ref_r) #*1000 hsatV = PropsSI('H', 'T', self.Tdew_r, 'Q', 1, self.Ref_r) #*1000 self.xin_r = (self.hin_r - hsatL) / (hsatV - hsatL) #Change in enthalpy through two-phase region [J/kg] self.h_fg = hsatV - hsatL self.Tin_r = self.xin_r * self.Tdew_r + (1 - self.xin_r) * self.Tbubble_r #Inlet entropy ssatL = PropsSI('S', 'T', self.Tbubble_r, 'Q', 0, self.Ref_r) #*1000 ssatV = PropsSI('S', 'T', self.Tdew_r, 'Q', 1, self.Ref_r) #*1000 self.sin_r = self.xin_r * ssatV + (1 - self.xin_r) * ssatL #Mean values for the glycol side based on average of inlet temperatures Tavg_g = (self.Tsat_r + self.Tin_g) / 2.0 self.f_g, self.h_g, self.Re_g = f_h_1phase_Annulus( self.mdot_g, self.ID_o, self.OD_i, Tavg_g, self.pin_g, self.Ref_g) self.cp_g = PropsSI('C', 'T', Tavg_g, 'P', self.pin_g, self.Ref_g) #*1000 #Glycol pressure drop v_g = 1 / PropsSI('D', 'T', Tavg_g, 'P', self.pin_g, self.Ref_g) dpdz_g = -self.f_g * v_g * self.G_g**2 / (2. * self.Dh_g ) #Pressure gradient self.DP_g = dpdz_g * self.L def OBJECTIVE(w_superheat): """Nested function for driving the Brent's method solver""" #Run the superheated portion self._Superheat_Forward(w_superheat) #Run the two-phase portion and return residual return self._TwoPhase_Forward(1 - w_superheat) def OBJECTIVE_2phase(xout_2phase): """Nested function for finding outlet quality""" #Need to pass in outlet quality but still maintain the full w_2phase return self._TwoPhase_Forward(1.0, xout_2phase) # First see if you have a superheated portion. Try to use the entire HX # for the two-phase portion # --------------------- # Intermediate glycol temp between superheated and 2phase sections [K] self.T_g_x = self.Tin_g #Call two-phase forward method error = self._TwoPhase_Forward(1.0) # If HT greater than required if error > 0: #Too much HT if all is 2phase, there is a superheated section existsSuperheat = True #Solve for the break between 2phase and superheated parts w_superheat = brentq(OBJECTIVE, 0.00001, 0.99999) self.w_2phase = 1 - w_superheat self.w_superheat = w_superheat else: existsSuperheat = False # Solve for outlet quality in 2phase section, lowest possible outlet # quality is the inlet quality self.xout_2phase = brentq(OBJECTIVE_2phase, self.xin_r, 0.99999) #Dummy variables for the superheated section which doesn't exist self.Q_superheat = 0.0 self.Charge_r_superheat = 0.0 self.h_r_superheat = 0.0 self.DP_r_superheat = 0.0 self.w_superheat = 0.0 self.w_2phase = 1.0 self.Charge_r = self.Charge_r_2phase + self.Charge_r_superheat self.Q = self.Q_2phase + self.Q_superheat self.Tout_g = self.Tin_g - self.Q / (self.cp_g * self.mdot_g) self.DP_r = self.DP_r_2phase + self.DP_r_superheat if existsSuperheat == True: self.hout_r = PropsSI('H', 'T', self.Tout_r, 'P', self.pin_r, self.Ref_r) #*1000 self.sout_r = PropsSI('S', 'T', self.Tout_r, 'P', self.pin_r, self.Ref_r) #*1000 else: self.Tout_r = self.xout_2phase * self.Tdew_r + ( 1 - self.xout_2phase) * self.Tbubble_r self.hout_r = PropsSI('H', 'T', self.Tout_r, 'Q', self.xout_2phase, self.Ref_r) #*1000 self.sout_r = PropsSI('S', 'T', self.Tout_r, 'Q', self.xout_2phase, self.Ref_r) #*1000 #Dummy variables for the subcooled section which doesn't exist self.Q_subcool = 0.0 self.DP_r_subcool = 0.0 self.h_r_subcool = 0.0 self.Re_r_subcool = 0.0 self.Charge_r_subcool = 0.0 self.w_subcool = 0.0
RPMs = np.arange(3600, 72000, 1000) # Conditions to Vary PRs = [2.0, 4.0, 6.0, 8.0, 10.0, 12.0, 14.0] # Pressure Ratio RPMs = [3600, 7200, 14400] # RPM #RPMs = [10000.,20000.,40000.,50000.] # RPM #RPMs = [3600,7200,14400] # RPM #=============================== # Prep #=============================== g = 9.81 #m/s^2 g = 9.81 # Gas properties CP = PropsSI('CPMASS', "T", T1, "P", p1, fluid) * 1000.0 # KJ/Kg CV = PropsSI('CVMASS', "T", T1, "P", p1, fluid) * 1000.0 # KJ/Kg kappa = CP / CV MW = PropsSI('M', fluid) * 1000.0 # kg/kmol R_bar = PropsSI('GAS_CONSTANT', fluid) # kJ/kmol/K R = R_bar / MW * 1000.0 # J/kg-K D1 = PropsSI('H', 'T', T1, 'P', p1, fluid) # Density (kg/m3) # Results variables = ['RPM', 'PR', 'D', 'pwr', 'pwr_real', 'm_dot', 'V1', 'T2', 'p2'] df = pd.DataFrame(columns=variables) for RPM in RPMs: for PR in PRs: # Compressor Calculations
self.DP_r_2phase = DP_frict + DP_accel if self.Verbosity > 4: print Q_2phase_eNTU - self.Q_2phase return Q_2phase_eNTU - self.Q_2phase if __name__ == '__main__': TT = [] QQ = [] Q1 = [] for Tdew_evap in np.linspace(270, 290.4): Tdew_cond = 317.73 # Tdew_evap=285.42 pdew_cond = PropsSI('P', 'T', Tdew_cond, 'Q', 1.0, 'R290') h = PropsSI('H', 'T', Tdew_cond - 7, 'P', pdew_cond, 'R290') #*1000 params = { 'ID_i': 0.0278, #inner tube, Internal Diameter (ID) 'OD_i': 0.03415, #inner tube, Outer Diameter (OD) 'ID_o': 0.045, #outer tube (annulus), Internal Diameter (ID) 'L': 50, 'mdot_r': 0.040, 'mdot_g': 0.38, 'hin_r': h, 'pin_r': PropsSI('P', 'T', Tdew_evap, 'Q', 1.0, 'R290'), 'pin_g': 300000, #pin_g in Pa 'Tin_g': 290.52, 'Ref_r': 'R290', 'Ref_g': 'Water', 'Verbosity': 0,
FinsTubes.Air.RH = 0.51 FinsTubes.Air.RHmean = 0.51 FinsTubes.Air.FanPower = 438 #Abstract State Ref = 'R410A' Backend = 'HEOS' #choose between: 'HEOS','TTSE&HEOS','BICUBIC&HEOS','REFPROP','SRK','PR' AS = CP.AbstractState(Backend, Ref) kwargs = { 'AS': AS, 'mdot_r': 0.0708, 'psat_r': PropsSI('P', 'T', T_dews[0], 'Q', 1.0, Ref), 'Fins': FinsTubes, 'FinsType': 'WavyLouveredFins', #Choose fin Type: 'WavyLouveredFins' or 'HerringboneFins'or 'PlainFins' 'hin_r': PropsSI('H', 'P', PropsSI('P', 'T', 282, 'Q', 1.0, Ref), 'Q', 0.15, Ref), 'Verbosity': 0, 'h_a_tuning': 1, 'h_tp_tuning': 1, 'DP_tuning': 1,
T_clr = 150 + 273.15 # K # Tank V = 1E6 # m3 p_min = 2.0 * p_amb p_max = 10.0 * p_amb # Simulation dt = 60.0 # s pwr = 10E6 # W = 1 MW # ---------- # Pre-processing calculations # ---------- # Ambient T1 = T_amb p1 = p_amb h1 = PropsSI('H', 'T', T1, 'P', p1, fluid) s1 = PropsSI('S', 'T', T1, 'P', p1, fluid) # Air Tank T_tnk = T_amb p_tnk = p_min m_tnk = V * PropsSI('D', 'T', T_tnk, 'P', p_tnk, fluid) u_tnk = PropsSI('U', 'T', T_tnk, 'P', p_tnk, fluid) MW = PropsSI('MOLEMASS', fluid) # kg/mol R = PropsSI('GAS_CONSTANT', fluid) # J/mol-K # Track energy and heat stored E_stor = 0.0 Q_stor = 0.0 #------------------------------------- # Charge #-------------------------------------
def getPr(self, P, T): self.Pr = PropsSI('Prandtl', 'T', T, 'P', P, self.name) return self.Pr
def __init__( self, num_samples=100, # Have this many chromos in the sample group num_selected=20, # Have this many chromos in the selected group mutation_factor=2, # Randomly mutate 1/n of the chromosomes num_powers=5, # How many powers in the fit Ref='R407C', value='rhoV', addTr=True, values=None, Tlims=None): self.num_samples = num_samples self.num_selected = num_selected self.mutation_factor = mutation_factor self.num_powers = num_powers self.addTr = addTr self.value = value self.Ref = Ref #Thermodynamics from CoolProp.CoolProp import PropsSI if values is None: self.Tc = PropsSI(Ref, 'Tcrit') self.pc = PropsSI(Ref, 'pcrit') self.rhoc = PropsSI(Ref, 'rhocrit') self.Tmin = PropsSI(Ref, 'Tmin') if Tlims is None: self.T = np.append( np.linspace(self.Tmin + 1e-14, self.Tc - 1, 150), np.logspace(np.log10(self.Tc - 1), np.log10(self.Tc) - 1e-15, 40)) else: self.T = np.linspace(Tlims[0], Tlims[1]) self.pL = np.array( PropsSI('P', 'T', self.T, 'Q', [0] * len(self.T), Ref)) self.pV = np.array( PropsSI('P', 'T', self.T, 'Q', [1] * len(self.T), Ref)) self.rhoL = PropsSI('D', 'T', self.T, 'Q', [0] * len(self.T), Ref) self.rhoV = PropsSI('D', 'T', self.T, 'Q', [1] * len(self.T), Ref) else: self.Tc = values['Tcrit'] self.pc = values['pcrit'] self.rhoc = values['rhocrit'] self.Tmin = values['Tmin'] self.T = values['T'] self.p = values['p'] self.rhoL = values['rhoL'] self.rhoV = values['rhoV'] self.logpLpc = (np.log(self.pL) - np.log(self.pc)) self.logpVpc = (np.log(self.pV) - np.log(self.pc)) self.rhoLrhoc = np.array(self.rhoL) / self.rhoc self.rhoVrhoc = np.array(self.rhoV) / self.rhoc self.logrhoLrhoc = np.log(self.rhoL) - np.log(self.rhoc) self.logrhoVrhoc = np.log(self.rhoV) - np.log(self.rhoc) self.x = 1.0 - self.T / self.Tc MM = PropsSI(Ref, 'molemass') self.T_r = self.Tc if self.value == 'pL': self.LHS = self.logpLpc.copy() self.EOS_value = self.pL.copy() if self.addTr == False: self.description = "p' = pc*exp(sum(n_i*theta^t_i))" else: self.description = "p' = pc*exp(Tc/T*sum(n_i*theta^t_i))" self.reducing_value = self.pc elif self.value == 'pV': self.LHS = self.logpVpc.copy() self.EOS_value = self.pV.copy() if self.addTr == False: self.description = "p'' = pc*exp(sum(n_i*theta^t_i))" else: self.description = "p'' = pc*exp(Tc/T*sum(n_i*theta^t_i))" self.reducing_value = self.pc elif self.value == 'rhoL': self.LHS = self.logrhoLrhoc.copy() self.EOS_value = self.rhoL if self.addTr == False: self.description = "rho' = rhoc*exp(sum(n_i*theta^t_i))" else: self.description = "rho' = rhoc*exp(Tc/T*sum(n_i*theta^t_i))" self.reducing_value = self.rhoc / MM elif self.value == 'rhoV': self.LHS = self.logrhoVrhoc.copy() self.EOS_value = self.rhoV if self.addTr == False: self.description = "rho'' = rhoc*exp(sum(n_i*theta^t_i))" else: self.description = "rho'' = rhoc*exp(Tc/T*sum(n_i*theta^t_i))" self.reducing_value = self.rhoc / MM elif self.value == 'rhoLnoexp': self.LHS = (self.rhoLrhoc - 1).copy() self.EOS_value = self.rhoL self.description = "rho' = rhoc*(1+sum(n_i*theta^t_i))" self.reducing_value = self.rhoc / MM else: raise ValueError if self.value == 'rhoLnoexp' and self.addTr: raise ValueError('Invalid combination') if self.addTr: self.LHS *= self.T / self.Tc
Fins.Air.Vdot_ha = 1.7934 #rated volumetric flowrate Fins.Air.Tdb = 308.15 #Dry Bulb Temperature Fins.Air.p = 101325 #Air pressure in Pa Fins.Air.RH = 0.51 #Relative Humidity Fins.Air.FanPower = 160 Ref = 'R410A' Backend = 'TTSE&HEOS' #choose between: 'HEOS','TTSE&HEOS','BICUBIC&HEOS','REFPROP','SRK','PR' AS = CP.AbstractState(Backend, Ref) params = { 'AS': AS, 'mdot_r': 0.0708, 'Tin_r': 333.15, 'psat_r': PropsSI('P', 'T', 323.15, 'Q', 1.0, Ref), 'Fins': Fins, 'FinsType': 'WavyLouveredFins', #WavyLouveredFins, HerringboneFins, PlainFins 'Verbosity': 0, } Cond = CondenserClass(**params) Cond.Calculate() print('Heat transfer rate in condenser is', Cond.Q, 'W') print('Heat transfer rate in condenser (superheat section) is', Cond.Q_superheat, 'W') print('Heat transfer rate in condenser (twophase section) is', Cond.Q_2phase, 'W') print('Heat transfer rate in condenser (subcooled section) is', Cond.Q_subcool,
@author: TrungNguyen """ import CoolProp.CoolProp as CP from CoolProp.CoolProp import PropsSI from CoolProp.Plots import PropertyPlot from CoolProp.Plots import StateContainer #Evaporator chracteristics HEOS = CP.AbstractState('HEOS', 'Propane&IsoButane') HEOS.set_mole_fractions([0.3, 0.7]) isentropic_eff = 0.7 evaporation_temp = 0 + 273.15 # R290 condensation_temp = 55 + 273.15 # Estimation from Aeronamic superheat = 5 # ambient temperature subcooling = 3.1 # estimation from Aeronamic (how to know or calculate the value) #Compressor characteristics compressor_power = 4300 # massflow = 0.04506 # #Aeronamic calculated values Qdot_condensor_expected = 14.3e3 Expected_COP = 3.17 #after evaporator, not superheated T1 = evaporation_temp P1 = PropsSI('P', 'T', T1, 'Q', 1, 'Propane&IsoButane') h1 = PropsSI('H', 'T', T1, 'Q', 1, 'Propane&IsoButane') s1 = PropsSI('S', 'T', T1, 'Q', 1, 'Propane&IsoButane')
def rhog(self, T: Iterable): return [ PropsSI('D', 'T', t, 'Q', 1, self.eos + "::" + self.name) for t in T ]
def pentanes(): # from doi 10.1021/je0202174 | J. Chem. Eng. Data 2003, 48, 1418-1421 # T (K), rhoL (kg/m^3), rhoV (kg/m^3), eta (mPa-s) data_cyclopentane = """253.15 258.15 263.15 268.15 273.15 278.15 283.15 288.15 293.15 298.15 303.15 308.15 313.15 318.15 323.15 328.15 333.15 338.15 343.15 348.15 353.15 784.64 779.53 774.59 769.77 765.12 760.20 755.32 750.27 745.02 738.63 731.97 725.15 718.32 711.59 705.11 699.08 693.40 688.44 684.25 680.96 678.71 0.0881 0.1127 0.1443 0.1848 0.2368 0.3036 0.3894 0.4999 0.6421 0.8255 1.062 1.368 1.764 2.279 2.950 3.827 4.980 6.509 8.554 11.33 15.20 0.7268 0.6786 0.6347 0.5930 0.5567 0.5224 0.4922 0.4646 0.4382 0.4148 0.3923 0.3714 0.3521 0.3350 0.3190 0.3048 0.2912 0.2793 0.2690 0.2590 0.2502""" # from doi 10.1021/je0202174 | J. Chem. Eng. Data 2003, 48, 1418-1421 # T (K), rhoL (kg/m^3), rhoV (kg/m^3), eta (mPa-s) data_isopentane = """253.15 258.15 263.15 268.15 273.15 278.15 283.15 288.15 293.15 298.15 303.15 308.15 313.15 318.15 323.15 328.15 333.15 338.15 343.15 348.15 353.15 658.32 653.55 648.73 643.87 639.01 634.15 629.35 624.63 620.05 615.69 610.87 605.63 600.05 594.23 588.24 582.18 576.13 570.18 564.41 558.92 553.79 0.4655 0.5889 0.7372 0.9137 1.122 1.366 1.650 1.979 2.356 2.788 3.278 3.833 4.459 5.162 5.949 6.827 7.803 8.886 10.09 11.41 12.87 0.3893 0.3661 0.3439 0.3201 0.3023 0.2859 0.2703 0.2547 0.2399 0.2289 0.2144 0.2023 0.1910 0.1813 0.1724 0.1611 0.1543 0.1480 0.1411 0.1332 0.1287""" fluid = '' def undelimit(args, delim=''): return [ np.array([float(_) for _ in a.strip().split(delim)]) for a in args ] from CoolProp.CoolProp import PropsSI for fluid, e_k, sigma_nm in zip(['CycloPentane', 'Isopentane'], [406.33, 341.06], [0.518, 0.56232]): xx, yy, RHO, ETA, ETACP, ETARP = [], [], [], [], [], [] for _T, _rhoLmass, _rhoVmass, _eta_mPas in zip( *undelimit(data_cyclopentane.split('\n'), delim=' ')): MM = PropsSI('molemass', fluid) rhomolar = _rhoLmass / MM eta = _eta_mPas / 1000 psi = get_psi(fluid, 'Propane', eta, _T, rhomolar, e_k, sigma_nm) xx.append(_T) yy.append(psi) RHO.append(rhomolar) try: ETACP.append( CoolProp.CoolProp.PropsSI('V', 'T', _T, 'Q', 0, fluid)) except: ETACP.append(np.nan) ETA.append(eta) ETARP.append( CoolProp.CoolProp.PropsSI( 'V', 'T', _T, 'Q', 0, 'REFPROP::' + CoolProp.CoolProp.get_fluid_param_string( fluid, 'REFPROP_name'))) xx, yy, ETACP, ETARP, RHO, = arrayize(xx, yy, ETACP, ETARP, RHO) rhored = CoolProp.CoolProp.PropsSI(fluid, 'rhomolar_critical') print('rhored', rhored) rhor = np.array(RHO) / rhored plt.title(fluid) plt.plot(rhor, yy, 'o-', label='from experimental data') p = np.polyfit(rhor, yy, 2) print(p[::-1]) plt.plot(rhor, np.polyval(p, rhor), 'o-', label='from correlation') plt.xlabel(r'$\rho_r$') plt.ylabel('$\psi$') plt.legend(loc='best') plt.show() plt.title(fluid) plt.plot(xx, (ETACP / ETA - 1) * 100, '^', label='CoolProp') plt.plot(xx, (ETARP / ETA - 1) * 100, 'o', label='REFPROP') plt.xlabel('Temperature (K)') plt.ylabel('$100\\times(\eta_{calc}/\eta_{exp}-1)$ (%)') plt.legend(loc='best') plt.savefig(fluid + '_deviation.pdf') plt.show()
def tsat(self, P: Iterable): return [ PropsSI('T', 'P', P, 'Q', 0.5, self.eos + "::" + self.name) if (self.pmin < p < self.pmax) else None for p in P ]
def __init__(self, symbol="N2", T=530.0, P=1000.0, child=1): '''Init generic Fluid''' self.symbol = symbol.upper() # http://www.coolprop.org/_static/doxygen/html/class_cool_prop_1_1_abstract_state.html AS = AbstractState("HEOS", self.symbol) self.AS = AS self.name = AS.name() self.T = T self.P = P self.child = child Tsi = TSI_fromEng(T) Psi = PSI_fromEng(P) AS.update(CP.PT_INPUTS, Psi, Tsi) self.WtMol = AS.molar_mass() * 1000.0 self.Tc = Teng_fromSI(AS.T_critical()) self.Pc = Peng_fromSI(AS.p_critical()) self.Dc = Deng_fromSI(AS.rhomass_critical()) self.Ttriple = Teng_fromSI(AS.Ttriple()) try: self.Tfreeze = Teng_fromSI(AS.T_freeze()) except: self.Tfreeze = self.Ttriple self.Tmin = Teng_fromSI(AS.Tmin()) self.Tmax = Teng_fromSI(AS.Tmax()) #self.Pmin = Peng_fromSI( AS.pmin() ) # missing from AbstractState self.Pmax = Peng_fromSI(AS.pmax()) dcIdeal = self.Pc * self.WtMol / self.Tc / 10.729 self.Zc = dcIdeal / self.Dc try: TnbpSI = PropsSI("T", "P", 101325, "Q", Q_LIQUID, self.symbol) self.good_nbp = True self.Tnbp = Teng_fromSI(TnbpSI) except: #print('WARNING... "%s" failed Normal Boiling Point Calculation.'%self.symbol) Ttriple = PropsSI(self.symbol, 'Ttriple') #print(' Using Triple Point = %g degK as Tref'%Ttriple) self.good_nbp = False self.Tnbp = 'N/A' if self.good_nbp: if self.Tnbp < 536.67: self.Tref = self.Tnbp # if NBP is low, use NBP as ref else: self.Tref = 536.67 # 536.67R = (SATP, Standard Ambient T P) = 77F, 25C else: self.Tref = Teng_fromSI(Ttriple) + 0.1 self.Pref = 14.7 #print( 'About to call setTP #1 with Tref, Pref=',self.Tref,self.Pref ) self.setTP(self.Tref, self.Pref) #print( 'Back from call setTP') self.Href = self.H #print( 'About to call setTP #2') self.setTP(T, P) #print( 'Back from call setTP') if child == 1: self.dup = EC_Fluid(symbol=self.symbol, T=self.T, P=self.P, child=0) self.calcdFreezePt = 0
Tmax = 650 T = np.linspace(Tmin, Tmax, nT) nS = 100 Smin = 850 Smax = 1500 S = np.linspace(Smin, Smax, nS) nH = nT Hmin = 200 * 1e3 #PropsSI("H", "T", Tmin, "S", Smin, 'Toluene') Hmax = 700 * 1e3 #psSI("H", "T", Tmax, "S", Smax, 'Toluene') H = np.linspace(Hmin, Hmax, nH) print(Hmin, Hmax) condenser_inlet = PropsSI("T", "P", P4, "S", S, 'Toluene') # diagram bars criticalisobar = PropsSI("T", "P", CP.PropsSI("Pcrit", "Toluene"), "S", S, 'Toluene') dome1 = PropsSI("S", "T", T, "Q", 1., 'Toluene') dome2 = PropsSI("S", "T", T, "Q", 0., 'Toluene') dome1 = PropsSI("S", "T", T, "Q", 1., 'Toluene') dome2 = PropsSI("S", "T", T, "Q", 0., 'Toluene') dome1h = [] dome2h = [] for index, element in enumerate(dome1): try: dome1h.append(PropsSI("H", "T", T[index], "S", element, 'Toluene'))
def getRho(self, P, T): self.rho = PropsSI('D', 'T', T, 'P', P, self.name) return self.rho
Tg = np.zeros(NZ) for i in range(NZ): if Z[i] < Z2: Tg[i] = 273.2 + 20.0+(100.0/350.0)*Z[i] else: Tg[i] = 273.2 + 120.0 # initilize in tube Qtube[:] = 1.0 Ttube[:] = Tin Ttuben[:] = Tin for i in range(2*NZ): Ptube[i] = Pin + Rhoin * cg * (Ztube[i]) # PropsSI('P','T',Ttube[i],'Q',Qtube[i],'Water') Dtube[i] = PropsSI('D','T',Ttube[i],'P',Ptube[i],'Water') htube[i] = PropsSI('H','T',Ttube[i],'P',Ptube[i],'Water') mutube[i] = PropsSI('V','T',Ttube[i],'P',Ptube[i],'Water')/Dtube[i] # m2/s Prtube[i] = PropsSI('PRANDTL','T',Ttube[i],'P',Ptube[i],'Water') tktube[i] = PropsSI('CONDUCTIVITY','T',Ttube[i],'P',Ptube[i],'Water') cptube[i] = PropsSI('C','T',Ttube[i],'P',Ptube[i],'Water') #----------------- Ground temperature as reference (real data will be required) def Tg1(z): Tsg1 = 20.0+273.2 dtdz = 100.0/350.0 # 100K/350m return Tsg1+dtdz*z def Tg2(z): Tsg2 = 120.0+273.2
def getViscosity(self, P, T): self.viscosity = PropsSI('viscosity', 'T', T, 'P', P, self.name) return self.viscosity
def EconomizedCycle(Ref, Qin, Te, Tc, DTsh, DTsc, eta_oi, f_p, Ti, Ts_Ph='Ts', skipPlot=False, axis=None, **kwargs): """ This function plots an economized cycle, on the current axis, or that given by the optional parameter *axis* Required parameters: * Ref : Refrigerant [string] * Qin : Cooling capacity [W] * Te : Evap Temperature [K] * Tc : Condensing Temperature [K] * DTsh : Evaporator outlet superheat [K] * DTsc : Condenser outlet subcooling [K] * eta_oi : Adiabatic efficiency of compressor (no units) in range [0,1] * f_p : fraction of compressor power lost as ambient heat transfer in range [0,1] * Ti : Saturation temperature corresponding to intermediate pressure [K] Optional parameters: * Ts_Ph : 'Ts' for a Temperature-Entropy plot, 'Ph' for a Pressure-Enthalpy * axis : An axis to use instead of the active axis * skipPlot : If True, won't actually plot anything, just print COP """ warnings.warn( "This function has been deprecated. Please consider converting it to an object inheriting from \"BaseCycle\".", DeprecationWarning) from scipy.optimize import newton m = 1 T = np.zeros((11)) h = np.zeros_like(T) p = np.zeros_like(T) s = np.zeros_like(T) rho = np.zeros_like(T) T[0] = np.NAN s[0] = np.NAN T[1] = Te + DTsh pe = PropsSI('P', 'T', Te, 'Q', 1.0, Ref) pc = PropsSI('P', 'T', Tc, 'Q', 1.0, Ref) pi = PropsSI('P', 'T', Ti, 'Q', 1.0, Ref) p[1] = pe h[1] = PropsSI('H', 'T', T[1], 'P', pe, Ref) s[1] = PropsSI('S', 'T', T[1], 'P', pe, Ref) rho[1] = PropsSI('D', 'T', T[1], 'P', pe, Ref) h2s = PropsSI('H', 'S', s[1], 'P', pi, Ref) wdot1 = (h2s - h[1]) / eta_oi h[2] = h[1] + (1 - f_p[0]) * wdot1 p[2] = pi #T[2]=T_hp(Ref,h[2],pi,T2s) T[2] = PropsSI('T', 'H', h[2], 'P', pi, Ref) s[2] = PropsSI('S', 'T', T[2], 'P', pi, Ref) rho[2] = PropsSI('D', 'T', T[2], 'P', pi, Ref) T[5] = Tc - DTsc h[5] = PropsSI('H', 'T', T[5], 'P', pc, Ref) s[5] = PropsSI('S', 'T', T[5], 'P', pc, Ref) rho[5] = PropsSI('D', 'T', T[5], 'P', pc, Ref) p[5] = pc p[6] = pi h[6] = h[5] p[7] = pi p[8] = pi p[6] = pi T[7] = Ti h[7] = PropsSI('H', 'T', Ti, 'Q', 1, Ref) s[7] = PropsSI('S', 'T', Ti, 'Q', 1, Ref) rho[7] = PropsSI('D', 'T', Ti, 'Q', 1, Ref) T[8] = Ti h[8] = PropsSI('H', 'T', Ti, 'Q', 0, Ref) s[8] = PropsSI('S', 'T', Ti, 'Q', 0, Ref) rho[8] = PropsSI('D', 'T', Ti, 'Q', 0, Ref) x6 = (h[6] - h[8]) / (h[7] - h[8]) #Vapor Quality s[6] = s[7] * x6 + s[8] * (1 - x6) rho[6] = 1.0 / (x6 / rho[7] + (1 - x6) / rho[8]) T[6] = Ti #Injection mass flow rate x = m * (h[6] - h[8]) / (h[7] - h[6]) p[3] = pi h[3] = (m * h[2] + x * h[7]) / (m + x) #T[3]=T_hp(Ref,h[3],pi,T[2]) T[3] = PropsSI('T', 'H', h[3], 'P', pi, Ref) s[3] = PropsSI('S', 'T', T[3], 'P', pi, Ref) rho[3] = PropsSI('D', 'T', T[3], 'P', pi, Ref) T4s = newton(lambda T: PropsSI('S', 'T', T, 'P', pc, Ref) - s[3], T[2] + 30) h4s = PropsSI('H', 'T', T4s, 'P', pc, Ref) p[4] = pc wdot2 = (h4s - h[3]) / eta_oi h[4] = h[3] + (1 - f_p[1]) * wdot2 #T[4]=T_hp(Ref,h[4],pc,T4s) T[4] = PropsSI('T', 'H', h[4], 'P', pc, Ref) s[4] = PropsSI('S', 'T', T[4], 'P', pc, Ref) rho[4] = PropsSI('D', 'T', T[4], 'P', pc, Ref) p[9] = pe h[9] = h[8] T[9] = Te hsatL_e = PropsSI('H', 'T', Te, 'Q', 0, Ref) hsatV_e = PropsSI('H', 'T', Te, 'Q', 1, Ref) ssatL_e = PropsSI('S', 'T', Te, 'Q', 0, Ref) ssatV_e = PropsSI('S', 'T', Te, 'Q', 1, Ref) vsatL_e = 1 / PropsSI('D', 'T', Te, 'Q', 0, Ref) vsatV_e = 1 / PropsSI('D', 'T', Te, 'Q', 1, Ref) x9 = (h[9] - hsatL_e) / (hsatV_e - hsatL_e) #Vapor Quality s[9] = ssatV_e * x9 + ssatL_e * (1 - x9) rho[9] = 1.0 / (x9 * vsatV_e + (1 - x9) * vsatL_e) s[10] = s[1] T[10] = T[1] h[10] = h[1] p[10] = p[1] Tbubble_e = Te Tbubble_c = Tc sbubble_e = PropsSI('S', 'T', Tbubble_e, 'Q', 0, Ref) sbubble_c = PropsSI('S', 'T', Tbubble_c, 'Q', 0, Ref) sdew_e = PropsSI('S', 'T', Te, 'Q', 1, Ref) sdew_c = PropsSI('S', 'T', Tc, 'Q', 1, Ref) Wdot1 = m * wdot1 Wdot2 = (m + x) * wdot2 if skipPlot == False: if axis == None: ax = matplotlib.pyplot.gca() else: ax = axis if Ts_Ph in ['ph', 'Ph']: ax.plot(h, p) ax.set_yscale('log') elif Ts_Ph in ['Ts', 'ts']: ax.plot(np.r_[s[7], s[3]], np.r_[T[7], T[3]], 'b') s_copy = s.copy() T_copy = T.copy() dT = [0, -5, 5, -12, 5, 12, -12, 0, 0, 0] ds = [0, 0.05, 0.05, 0, 0.05, 0, 0.0, 0.05, -0.05, -0.05] for i in range(1, len(s) - 1): ax.plot(s[i], T[i], 'bo', mfc='b', mec='b') ax.text(s[i] + ds[i], T[i] + dT[i], str(i), ha='center', va='center') s = list(s) T = list(T) s.insert(10, sdew_e) T.insert(10, Te) s.insert(5, sbubble_c) T.insert(5, Tbubble_c) s.insert(5, sdew_c) T.insert(5, Tc) ax.plot(s, T, 'b') s = s_copy T = T_copy else: raise TypeError('Type of Ts_Ph invalid') COP = m * (h[1] - h[9]) / (m * (h[2] - h[1]) + (m + x) * (h[4] - h[3])) for i in range(1, len(T) - 1): print('%d & %g & %g & %g & %g & %g \\\\' % (i, T[i] - 273.15, p[i], h[i], s[i], rho[i])) print(x, m * (h[1] - h[9]), (m * (h[2] - h[1]) + (m + x) * (h[4] - h[3])), COP) mdot = Qin / (h[1] - h[9]) mdot_inj = x * mdot print( 'x9', x9, ) print('Qcond', (mdot + mdot_inj) * (h[4] - h[5]), 'T4', T[4] - 273.15) print(mdot, mdot + mdot_inj) f = 3500 / 60. eta_v = 0.7 print('Vdisp1: ', mdot / (rho[1] * f * eta_v) * 1e6, 'cm^3') print('Vdisp2: ', (mdot + mdot_inj) / (rho[1] * f * eta_v) * 1e6, 'cm^3') return COP
def getK(self, P, T): self.k = PropsSI('conductivity', 'T', T, 'P', P, self.name) return self.k
self.FilterDrierCharge = 0 #Charge in MicroMotion [kg] self.MicroMotionCharge = 0 #Total Chnarge [kg] self.Charge = 0 if __name__=='__main__': #Abstract State Ref = 'R410A' Backend = 'HEOS' #choose between: 'HEOS','TTSE&HEOS','BICUBIC&HEOS','REFPROP','SRK','PR' AS = CP.AbstractState(Backend, Ref) kwargs={ 'AS': AS, 'pin': 500000, 'hin': PropsSI('H','P',500000,'T',PropsSI('T','P',500000,'Q',0,Ref)-10,Ref), 'mdot': 0.03, 'ID':in2m(3.0/8.0)-mm2m(2), #pipe diameter 'h':in2m(1.370), #height of sight glass in m 'D':in2m(1.110), #diameter of sight glass in m 'n_sight':2, #number of sight glasses 'V': cubin2cubm(16), #volume of filter drier (website = 13.74in^3 calculated) (manual = 16in^3) 'D_Micro': in2m(0.21), #micromotion tube diameter 'L_Micro': in2m(14.6), #micormotion tube length 'n_Micro': 2, #micormotion number of tubes } SightGlassFilterDrierMicroMotionClass = SightGlassFilterDrierMicroMotionClass(**kwargs) SightGlassFilterDrierMicroMotionClass.Calculate() print (SightGlassFilterDrierMicroMotionClass.OutputList())
def run(self): # ---------- # Pre-processing calculations # ---------- # Ambient T1 = self.T_amb p1 = self.p_amb h1 = PropsSI('H', 'T', T1, 'P', p1, self.fluid) s1 = PropsSI('S', 'T', T1, 'P', p1, self.fluid) # Cavern p_cav = self.p_min m_cav = self.V * PropsSI('D', 'T', self.T_cav, 'P', p_cav, self.fluid) # u_tnk = PropsSI('U', 'T', T_tnk, 'P', p_tnk, self.fluid) MW = PropsSI('MOLEMASS', self.fluid) # kg/mol R = PropsSI('GAS_CONSTANT', self.fluid) # J/mol-K # Track energy and heat stored E_stor = 0.0 Q_stor = 0.0 #------------------------------------- # Charge #------------------------------------- t = 0. while p_cav < self.p_max: t = t + self.dt # Compressor p2 = p_cav h2s = PropsSI('H', 'P', p2, 'S', s1, self.fluid) h2 = h1 + (h2s - h1) / self.cmp_eff T2 = PropsSI('T', 'P', p2, 'H', h2, self.fluid) m_dot = self.pwr / (h2 - h1) # Cooler p3 = p2 T3 = min(self.T_stor, T2) h3 = PropsSI('H', 'T', T3, 'P', p3, self.fluid) Q_clr = m_dot * (h2 - h3) # Storage Tank # Mass balance m_cav = m_cav + m_dot * self.dt n = m_cav / MW # moles # Energy balance # Cv = PropsSI('CVMASS', 'T', self.T_cav, 'P', p_tnk, self.fluid) # Assume small differences in Cv # u_tnk = ((m_tnk-m_dot*self.dt)*u_tnk + m_dot*self.dt*h3)/(m_tnk) # T_tnk = u_tnk / Cv p_tnk = n * R * self.T_cav / self.V # Energy/Heat Storage Q_stor = Q_stor + Q_clr * self.dt E_stor = E_stor + self.pwr * self.dt # Store Data s = pd.Series(index=variablesC) s['t'] = t s['pwr'] = self.pwr s['m_dot'] = m_dot s['p1'] = p1 s['T1'] = T1 s['p2'] = p2 s['T2'] = T2 s['p3'] = p3 s['T3'] = T3 s['p_cav'] = p_cav s['T_cav'] = self.T_cav s['Q_clr'] = Q_clr s['Q_stor'] = Q_stor s['E_stor'] = E_stor s.name = t self.dfC = self.dfC.append(s) #------------------------------------- # Mid-Analysis #------------------------------------- E_in = E_stor Q_in = Q_stor #------------------------------------- # Discharge #------------------------------------- t = 0. while p_cav > self.p_min and E_stor > 0.0: t = t + self.dt # Heater T4 = self.T_cav p4 = p_cav h4 = PropsSI('H', 'T', T4, 'P', p4, self.fluid) p5 = p_cav if Q_stor > 0: T5 = max(self.T_stor, self.T_cav) else: T5 = self.T_cav h5 = PropsSI('H', 'T', T5, 'P', p5, self.fluid) s5 = PropsSI('S', 'T', T5, 'P', p5, self.fluid) # Turbine p6 = self.p_amb h6s = PropsSI('H', 'P', p6, 'S', s5, self.fluid) h6 = h5 + (h6s - h5) * self.trb_eff T6 = PropsSI('T', 'P', p6, 'H', h6, self.fluid) m_dot = self.pwr / (h5 - h6) # Revisit Heater Q_htr = m_dot * (h5 - h4) # Cavern # Mass balance m_cav = m_cav - m_dot * self.dt n = m_cav / MW # moles # Energy balance # Cv = PropsSI('CVMASS', 'T', T_tnk, 'P', p_tnk, self.fluid) # Assume small differences in Cv # u_tnk = ((m_tnk+m_dot*self.dt)*u_tnk - m_dot*self.dt*h4)/(m_tnk) # T_tnk = u_tnk / Cv p_tnk = n * R * self.T_cav / self.V # Energy/Heat Storage Q_stor = Q_stor - Q_htr * self.dt E_stor = E_stor - self.pwr * self.dt # Check outlet temp if self.T_out_min == -1.0: self.T_out_min = T6 else: self.T_out_min = min(self.T_out_min, T6) # Store Data s = pd.Series(index=variablesD) s['t'] = t s['pwr'] = self.pwr s['m_dot'] = m_dot s['p4'] = p4 s['T4'] = T4 s['p5'] = p5 s['T5'] = T5 s['p6'] = p6 s['T6'] = T6 s['p_cav'] = p_cav s['T_cav'] = self.T_cav s['Q_htr'] = Q_htr s['Q_stor'] = Q_stor s['E_stor'] = E_stor s.name = t self.dfD = self.dfD.append(s) #------------------------------------- # Final-Analysis #------------------------------------- Q_out = Q_in - Q_stor E_out = E_in - E_stor self.RTE = E_out / E_in * 100.0 self.Heat_Util = Q_out / Q_in * 100.0 # Store and Convert from Ws to MWh convert = 1.0 / 1E6 / 60. / 60. self.E_in = E_in * convert self.E_out = E_out * convert self.Q_in = Q_in * convert self.Q_out = Q_out * convert # Convert to C self.T_out_min = self.T_out_min - 273.15 results = pd.Series(index=[ 'RTE', 'Heat_Util', 'E_in', 'E_out', 'Q_in', 'Q_out', 'T_out_min', 'Ebal', 'Qbal' ]) results['RTE'] = self.RTE results['Heat_Util'] = self.Heat_Util results['E_in'] = self.E_in results['E_out'] = self.E_out results['Q_in'] = self.Q_in results['Q_out'] = self.Q_out results['T_out_min'] = self.T_out_min results['Ebal'] = self.E_in - self.E_out results['Qbal'] = self.Q_in - self.Q_out return results