def funco(framenum): t = time.clock() x = 25 + 10 * np.sin(t) y = HAProps('W', 'T', x + 273.15, 'P', p, 'R', r1) z = HAProps('W', 'T', x + 273.15, 'P', p, 'R', r2) a0.set_data(x, y) a1.set_data(x, z)
def plot(self, ax): for H in self.H_values: #Line goes from saturation to zero humidity ratio for this enthalpy T1 = HAProps('T', 'H', H, 'P', p, 'R', 1.0) - 273.15 T0 = HAProps('T', 'H', H, 'P', p, 'R', 0.0) - 273.15 w1 = HAProps('W', 'H', H, 'P', p, 'R', 1.0) w0 = HAProps('W', 'H', H, 'P', p, 'R', 0.0) ax.plot(numpy.r_[T1, T0], numpy.r_[w1, w0], 'r', lw=1)
def plot(self,ax): xv = Tdb #[K] for RH in self.RH_values: yv = [HAProps('W','T',T,'P',p,'R',RH) for T in Tdb] y = HAProps('W','P',p,'H',self.h,'R',RH) T_K,w,rot = InlineLabel(xv, yv, y=y, axis = ax) string = r'$\phi$='+str(RH*100)+'%' #Make a temporary label to get its bounding box bbox_opts = dict(boxstyle='square,pad=0.0',fc='white',ec='None',alpha = 0.5) ax.text(T_K-273.15,w,string,rotation = rot,ha ='center',va='center',bbox=bbox_opts)
def _lib(self): args = self.args() P = self._P() if "Tdb" in self._mode: tdb = self.kwargs["Tdb"] else: tdb = HAProps("Tdb", *args) tdp = HAProps("Tdp", *args) twb = HAProps("Twb", *args) w = HAProps("W", *args) HR = HAProps("RH", *args)*100 Pvs = HAProps_Aux("p_ws", tdb, self._P_kPa, w)[0]*1000 Pv = Pvs*HR/100 ws = HAProps("W", "P", self._P_kPa, "Tdb", tdb, "RH", 1) v = HAProps("V", *args) h = HAProps("H", *args) return tdp, tdb, twb, P, Pvs, Pv, ws, w, HR, v, h
def funco(framenum,ser,fil): global t,a,b,x,y,tt,xx,yy print framenum, t = time.clock() try: (datime, status, relhum, temp) = serialLoop(ser,fil) #x = 25 + 10 * np.sin(t) #y = HAProps('W','T',x+273.15,'P',p,'R',r1) #z = HAProps('W','T',x+273.15,'P',p,'R',r2) tt.append(t) for j in range(5): x = temp[j] y = HAProps('W','T',x+273.15,'P',p,'R',relhum[j]*0.01) xx[j].append(x) yy[j].append(y) a[j].set_data(x,y) except KeyboardInterrupt: print('exciting!') except TypeError: pass
def check_HAProps(*args): val = HAProps(*args)
def check_HAProps(*args): HAProps(*args)
# Setup for plotting # ###################### p = 101.325 Tdb = numpy.linspace(-10,40,100)+273.15 #Make the figure and the axes fig=matplotlib.pyplot.figure(figsize=(10,8)) ax=fig.add_axes((0.1,0.1,0.85,0.85)) fig2=matplotlib.pyplot.figure(figsize=(10,8)) ax2=fig2.add_axes((0.1,0.1,0.85,0.85)) ax2.set_xlim((-1,10)) ax2.set_ylim((0,50)) # Saturation line w = [HAProps('W','T',T,'P',p,'R',1.0) for T in Tdb] ax.plot(Tdb-273.15,w,lw=2) # Humidity lines RHValues = [0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] for RH in RHValues: w = [HAProps('W','T',T,'P',p,'R',RH) for T in Tdb] ax.plot(Tdb-273.15,w,'b--',lw=1) # Enthalpy lines for H in [-20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90]: #Line goes from saturation to zero humidity ratio for this enthalpy T1 = HAProps('T','H',H,'P',p,'R',1.0)-273.15 T0 = HAProps('T','H',H,'P',p,'R',0.0)-273.15 w1 = HAProps('W','H',H,'P',p,'R',1.0) w0 = HAProps('W','H',H,'P',p,'R',0.0)
def getSaturatedProperties(self, name, h): # if (name == "T"): return (HAProps('T', 'P', 101325, 'H', h, 'R', 1.0) - 273.15) else: raise ValueError("name:%s not found" % name)
def getEnthalpy(self, temp, humidityRatio): return HAProps("H", "T", temp + 273.15, "P", 101325, "R", humidityRatio) # J/kg dry air
def HerringboneFins(Inputs): #Source: #Empirical correlations for heat transfer and flow friction characteristics of herringbone wavy fin-and-tube heat exchangers #Chi-Chuan Wang, Young-Ming Hwang, Yur-Tsai Lin #International Journal of Refrigeration, 25, 2002, 637-680 #Properties: p = Inputs.Air.p #air pressure W = HAProps('W', 'T', Inputs.Air.Tdb, 'P', p, 'R', Inputs.Air.RH) #Transport properties of humid air from CoolProp mu_ha = HAProps('M', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) k_ha = HAProps('K', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) * 10**3 #Evaluate the mass flow rate based on inlet conditions Vdot_ha = Inputs.Air.Vdot_ha # To convert a parameter from per kg_{humid air} to per kg_{dry air}, divide by (1+W) W = HAProps('W', 'T', Inputs.Air.Tdb, 'P', p, 'R', Inputs.Air.RH) v_da = HAProps('V', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) h_da = HAProps('H', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) * 1000 rho_ha = 1 / v_da * (1 + W) #[m^3/kg_ha] rho_da = 1 / v_da #[m^3/kg_da] mdot_ha = Vdot_ha * rho_ha #[kg_ha/s] mdot_da = Vdot_ha * rho_da #[kg_da/s] #Use a forward difference to calculate cp from cp=dh/dT dT = 0.0001 #[K] cp_da = (HAProps('H', 'T', Inputs.Air.Tdb + dT, 'P', p, 'W', W) * 1000 - h_da) / dT #[J/kg_da/K] cp_ha = cp_da / (1 + W) #[J/kg_ha/K] # Check that cs_cp is defined, if so, set it to the value passed in if (hasattr(Inputs, 'cs_cp') and Inputs.cs_cp > 0) or (hasattr(Inputs, 'WetDry') and Inputs.WetDry == 'Wet'): isWet = True cs_cp = Inputs.Air.cs_cp else: isWet = False cs_cp = 1.0 #Dimensions and values used for both Reynolds number ranges: delta_f = Inputs.Fins.t #fin thickness(m) FPI = Inputs.Fins.FPI #fins per inch FPM = FPI / 0.0254 #Fins per meter [1/m] pf = 1 / FPM #Fin pitch (distance between centerlines of fins) F_s = 1 / FPM - delta_f #Fin spacing(m) P_t = Inputs.Tubes.Pt #transverse tube pitch (m) P_L = Inputs.Tubes.Pl #longitudinal tube pitch (m) D_o = Inputs.Tubes.OD #Outer diameter of tube (m) D_c = D_o + 2 * delta_f #fin collar outside diameter (m) (tube + 2*fin thickness) Ltube = Inputs.Tubes.Ltube #length of a single tube [m] Nfin = Ltube * FPM #Number of fins in the tube sheet [-] Ntubes_bank = Inputs.Tubes.NTubes_per_bank #tubes per bank Height = P_t * ( Ntubes_bank + 1 ) #Height of heat exchanger [m] # assuming that fin extends 1/2 pt above/below last tube in bundle A_duct = Height * Ltube #A_duct is the face area [m^2] - equivalent to the duct cross-section #neglecting the additional height of the fins above/below the last tubes in the bundle Ac = A_duct - delta_f * Nfin * ( Height - D_c * Ntubes_bank ) - Ntubes_bank * D_c * Ltube #Minimum duct cross-sectional area that is not fin or tube(-collar) [m^2] u_max = mdot_ha / (rho_ha * Ac) #maximum airside velocity [m/s] Re_Dc = rho_ha * u_max * D_c / mu_ha #from reference #4 of Wang et all. Slightly different notation used in [4] P_d = Inputs.Fins.Pd #wave height X_f = Inputs.Fins.xf #projected fin length (m) tanTheta = P_d / X_f #tangens of corrugation angle secTheta = sqrt( X_f * X_f + P_d * P_d ) / X_f ###!!used wavy louvered fins definition - there seems to be a bug in the paper !! beta = (pi * D_c**2) / (4.0 * P_t * P_L) oneMbeta = 1.0 - beta #save one operation D_h = 2.0 * F_s * oneMbeta / (oneMbeta * secTheta + 2 * F_s * beta / D_c ) # hydraulic diameter (m) N = Inputs.Tubes.Nbank #number of lomgitudunal tube rows (#Number of banks in ACHP-notation) if Re_Dc < 1000.0: #Heat transfer J1 = 0.0045 - 0.491 * pow(Re_Dc, -0.0316 - 0.0171 * log( N * tanTheta)) * pow(P_L / P_t, -0.109 * log(N * tanTheta)) * pow( D_c / D_h, 0.542 + 0.0471 * N) * pow(F_s / D_c, 0.984) * pow( F_s / P_t, -0.349) J2 = -2.72 + 6.84 * tanTheta J3 = 2.66 * tanTheta j = 0.882 * pow(Re_Dc, J1) * pow(D_c / D_h, J2) * pow( F_s / P_t, J3) * pow(F_s / D_c, -1.58) * pow(tanTheta, -0.2) #Friction F1 = -0.574 - 0.137 * pow(log(Re_Dc) - 5.26, 0.245) * pow( P_t / D_c, -0.765) * pow(D_c / D_h, -0.243) * pow( F_s / D_h, -0.474) * pow(tanTheta, -0.217) * pow(N, 0.035) F2 = -3.05 * tanTheta F3 = -0.192 * N F4 = -0.646 * tanTheta f = 4.37 * pow(Re_Dc, F1) * pow(F_s / D_h, F2) * pow( P_L / P_t, F3) * pow(D_c / D_h, 0.2054) * pow(N, F4) else: #Heat transfer j1 = -0.0545 - 0.0538 * tanTheta - 0.302 * pow(N, -0.24) * pow( F_s / P_L, -1.3) * pow(P_L / P_t, 0.379) * pow( P_L / D_h, -1.35) * pow(tanTheta, -0.256) j2 = -1.29 * pow(P_L / P_t, 1.77 - 9.43 * tanTheta) * pow( D_c / D_h, 0.229 - 1.43 * tanTheta) * pow(N, -0.166 - 1.08 * tanTheta) * pow( F_s / P_t, -0.174 * log(0.5 * N)) j = 0.0646 * pow(Re_Dc, j1) * pow(D_c / D_h, j2) * pow( F_s / P_t, -1.03) * pow(P_L / D_c, 0.432) * pow( tanTheta, -0.692) * pow(N, -0.737) #Friction f1 = -0.141 * pow(F_s / P_L, 0.0512) * pow(tanTheta, -0.472) * pow( P_L / P_t, 0.35) * pow(P_t / D_h, 0.449 * tanTheta) * pow( N, -0.049 + 0.237 * tanTheta) f2 = -0.562 * pow(log(Re_Dc), -0.0923) * pow(N, 0.013) f3 = 0.302 * pow(Re_Dc, 0.03) * pow(P_t / D_c, 0.026) f4 = -0.306 + 3.63 * tanTheta f = 0.228 * pow(Re_Dc, f1) * pow(tanTheta, f2) * pow( F_s / P_L, f3) * pow(P_L / D_c, f4) * pow(D_c / D_h, 0.383) * pow( P_L / P_t, -0.247) Pr = cp_ha * mu_ha / k_ha h_a = j * rho_ha * u_max * cp_ha / pow( Pr, 2.0 / 3.0) #air side mean heat transfer coefficient using colborn j-factor #calcs needed for specific fin types #additional parameters needed k_fin = Inputs.Fins.k_fin Nbank = Inputs.Tubes.Nbank #Number of banks secTheta = sqrt(X_f * X_f + P_d * P_d) / X_f #secTheta #Wetted Area of a single fin [m^2] A_1fin = 2.0 * ( Height * P_L * (Nbank + 1) * secTheta - Ntubes_bank * Nbank * pi * D_o * D_o / 4 ) #assuming that fin extends 1/2 pt in front/after last tube in bundle # Total wetted area of the fins [m^2] Af = Nfin * A_1fin #Total area including tube and fins [m^2] A = Af + Ntubes_bank * Nbank * pi * D_o * (Ltube - Nfin * delta_f) r = D_o / 2 X_D = sqrt(P_L * P_L + P_t * P_t / 4) / 2 X_T = P_t / 2 rf_r = 1.27 * X_T / r * sqrt(X_D / X_T - 0.3) m = sqrt( 2 * h_a * cs_cp / (k_fin * delta_f)) #cs_cp is the correction for heat/mass transfer #Using the circular fin correlation of Schmidt phi = (rf_r - 1) * (1 + 0.35 * log(rf_r)) eta_f = tanh(m * r * phi) / (m * r * phi) # Fin efficiency based on analysis in # "FIN EFFICIENCY CALCULATION IN ENHANCED FIN-AND-TUBE HEAT EXCHANGERS IN DRY CONDITIONS" # by Thomas PERROTIN, Denis CLODIC, International Congress of Refrigeration 2006 # In the paper, there is no 0.1 in the cosine term, but if the cosine term is used without # the correction, the results are garbage for wet analysis # Using the offset fins correlation phi = (rf_r - 1) * (1 + (0.3 + pow(m * (rf_r * r - r) / 2.5, 1.5 - rf_r / 12.0) * (0.26 * pow(rf_r, 0.3) - 0.3)) * log(rf_r)) #finned surface efficiency eta_f = tanh(m * r * phi) / (m * r * phi) * cos(0.1 * m * r * phi) #overall surface efficiency eta_o = 1 - Af / A * (1 - eta_f) G_c = mdot_ha / Ac #air mass flux Atube = Ntubes_bank * Nbank * pi * D_o * Ltube # Total outer area of the tubes [m^2] DeltaP_air = A / Atube / rho_ha * G_c**2 / 2.0 * f #airside pressure drop #write necessary values back into the given structure Inputs.A_a = A Inputs.cp_da = cp_da Inputs.cp_ha = cp_ha if isWet == True: Inputs.eta_a_wet = eta_o else: Inputs.eta_a = eta_o Inputs.h_a = h_a Inputs.mdot_ha = mdot_ha Inputs.mdot_da = mdot_da Inputs.f_a = f Inputs.dP_a = DeltaP_air Inputs.Re = Re_Dc
def DryWetSegment(DWS): """ Generic solver function for dry-wet mixed surface conditions for a given element. Can handle superheated, subcooled and two-phase regions. Does not handle the pressure drops, only HT required to get the dry/wet interface """ #List of required parameters RequiredParameters=['Tin_a','h_a','cp_da','eta_a','A_a','pin_a','RHin_a','Tin_r','pin_r','h_r','cp_r','A_r','mdot_r','Fins'] #Check that all the parameters are included, raise exception otherwise for param in RequiredParameters: if not hasattr(DWS,param): raise AttributeError("Parameter "+param+" is required for DWS class in DryWetSegment") #Retrieve values from structures defined above Tin_a=DWS.Tin_a h_a=DWS.h_a cp_da=DWS.cp_da eta_a=DWS.eta_a #from fin correlations, overall airside surface effectiveness A_a=DWS.A_a pin_a=DWS.pin_a RHin_a=DWS.RHin_a mdot_da=DWS.mdot_da Tin_r=DWS.Tin_r pin_r=DWS.pin_r h_r=DWS.h_r cp_r=DWS.cp_r A_r=DWS.A_r mdot_r=DWS.mdot_r #Calculate the dewpoint (amongst others) omega_in=HAProps('W','T',Tin_a,'P',pin_a,'R',RHin_a) Tdp=HAProps('D','T',Tin_a,'P',pin_a,'W',omega_in) hin_a=HAProps('H','T',Tin_a,'P',pin_a,'W',omega_in)*1000 #[J/kg_da] # Internal UA between fluid flow and outside surface (neglecting tube conduction) UA_i=h_r*A_r #[W/K], from Shah or f_h_1phase_Tube-fct -> Correlations.py # External UA between wall and free stream UA_o=eta_a*h_a*A_a #[W/K], from fin correlations # Internal Ntu Ntu_i=UA_i/(mdot_r*cp_r) #[-] # External Ntu (multiplied by eta_a since surface is finned and has lower effectiveness) Ntu_o=eta_a*h_a*A_a/(mdot_da*cp_da) #[-] if DWS.IsTwoPhase: #(Two-Phase analysis) UA=1/(1/(h_a*A_a*eta_a)+1/(h_r*A_r)); #overall heat transfer coefficient Ntu_dry=UA/(mdot_da*cp_da); #Number of transfer units epsilon_dry=1-exp(-Ntu_dry); #since Cr=0, e.g. see Incropera - Fundamentals of Heat and Mass Transfer, 2007, p. 690 Q_dry=epsilon_dry*mdot_da*cp_da*(Tin_a-Tin_r); Tout_a=Tin_a-Q_dry/(mdot_da*cp_da); #outlet temperature, dry fin T_so_a=(UA_o*Tin_a+UA_i*Tin_r)/(UA_o+UA_i); #inlet surface temperature T_so_b=(UA_o*Tout_a+UA_i*Tin_r)/(UA_o+UA_i); #outlet surface temperature if T_so_b>Tdp: #All dry, since surface at outlet dry f_dry=1.0 Q=Q_dry #[W] Q_sensible=Q #[W] hout_a=hin_a-Q/mdot_da #[J/kg_da] # Air outlet humidity ratio DWS.omega_out = omega_in #[kg/kg] else: if T_so_a<Tdp: #All wet, since surface at inlet wet f_dry=0.0 Q_dry=0.0 T_ac=Tin_a #temp at onset of wetted wall h_ac=hin_a #enthalpy at onset of wetted surface else: # Partially wet and dry # Air temperature at the interface between wet and dry surface # Based on equating heat fluxes at the wall which is at dew point UA_i*(Tw-Ti)=UA_o*(To-Tw) T_ac = Tdp + UA_i/UA_o*(Tdp - Tin_r) # Dry effectiveness (minimum capacitance on the air side by definition) epsilon_dry=(Tin_a-T_ac)/(Tin_a-Tin_r) # Dry fraction found by solving epsilon=1-exp(-f_dry*Ntu) for known epsilon from above equation f_dry=-1.0/Ntu_dry*log(1.0-epsilon_dry) # Enthalpy, using air humidity at the interface between wet and dry surfaces, which is same humidity ratio as inlet h_ac=HAProps('H','T',T_ac,'P',pin_a,'W',omega_in)*1000 #[J/kg_da] # Dry heat transfer Q_dry=mdot_da*cp_da*(Tin_a-T_ac) # Saturation specific heat at mean water temp c_s=cair_sat(Tin_r)*1000 #[J/kg-K] # Find new, effective fin efficiency since cs/cp is changed from wetting # Ratio of specific heats [-] DWS.Fins.Air.cs_cp=c_s/cp_da DWS.Fins.WetDry='Wet' WavyLouveredFins(DWS.Fins) eta_a_wet=DWS.Fins.eta_a_wet UA_o=eta_a_wet*h_a*A_a Ntu_o=eta_a_wet*h_a*A_a/(mdot_da*cp_da) # Wet analysis overall Ntu for two-phase refrigerant # Minimum capacitance rate is by definition on the air side # Ntu_wet is the NTU if the entire two-phase region were to be wetted UA_wet=1/(c_s/UA_i+cp_da/UA_o) Ntu_wet=UA_wet/(mdot_da) # Wet effectiveness [-] epsilon_wet=1-exp(-(1-f_dry)*Ntu_wet) # Air saturated at refrigerant saturation temp [J/kg] h_s_s_o=HAProps('H','T',Tin_r, 'P',pin_a, 'R', 1.0)*1000 #[kJ/kg_da] # Wet heat transfer [W] Q_wet=epsilon_wet*mdot_da*(h_ac-h_s_s_o) # Total heat transfer [W] Q=Q_wet+Q_dry # Air exit enthalpy [J/kg] hout_a=h_ac-Q_wet/mdot_da # Saturated air temp at effective surface temp [J/kg_da] h_s_s_e=h_ac-(h_ac-hout_a)/(1-exp(-(1-f_dry)*Ntu_o)) # Effective surface temperature [K] T_s_e = HAProps('T','H',h_s_s_e/1000.0,'P',pin_a,'R',1.0) # Outlet dry-bulb temp [K] Tout_a = T_s_e+(T_ac-T_s_e)*exp(-(1-f_dry)*Ntu_o) #Sensible heat transfer rate [kW] Q_sensible=mdot_da*cp_da*(Tin_a-Tout_a) #Outlet is saturated vapor Tout_r=DWS.Tdew_r else: #(Single-Phase analysis) #Overall UA UA = 1 / (1 / (UA_i) + 1 / (UA_o)); # Min and max capacitance rates [W/K] Cmin = min([cp_r * mdot_r, cp_da * mdot_da]) Cmax = max([cp_r * mdot_r, cp_da * mdot_da]) # Capacitance rate ratio [-] C_star = Cmin / Cmax # Ntu overall [-] Ntu_dry = UA / Cmin # Counterflow effectiveness [-] epsilon_dry = ((1 - exp(-Ntu_dry * (1 - C_star))) / (1 - C_star * exp(-Ntu_dry * (1 - C_star)))) # Dry heat transfer [W] Q_dry = epsilon_dry*Cmin*(Tin_a-Tin_r) # Dry-analysis air outlet temp [K] Tout_a_dry=Tin_a-Q_dry/(mdot_da*cp_da) # Dry-analysis outlet temp [K] Tout_r=Tin_r+Q_dry/(mdot_r*cp_r) # Dry-analysis air outlet enthalpy from energy balance [J/kg] hout_a=hin_a-Q_dry/mdot_da # Dry-analysis surface outlet temp [K] Tout_s=(UA_o*Tout_a_dry+UA_i*Tin_r)/(UA_o+UA_i) # Dry-analysis surface inlet temp [K] Tin_s=(UA_o*Tin_a+UA_i*Tout_r)/(UA_o+UA_i) # Dry-analysis outlet refrigerant temp [K] Tout_r_dry=Tout_r # Dry fraction [-] f_dry=1.0 # Air outlet humidity ratio [-] DWS.omega_out = omega_in # If inlet surface temp below dewpoint, whole surface is wetted if Tin_s<Tdp: isFullyWet=True else: isFullyWet=False if Tout_s<Tdp or isFullyWet: # There is some wetting, either the coil is fully wetted or partially wetted # Loop to get the correct c_s # Start with the inlet temp as the outlet temp x1=Tin_r+1 #Lowest possible outlet temperature x2=Tin_a-1 #Highest possible outlet temperature eps=1e-8 iter=1 change=999 while ((iter<=3 or change>eps) and iter<100): if (iter==1): Tout_r=x1; if (iter>1): Tout_r=x2; Tout_r_start=Tout_r; # Saturated air enthalpy at the inlet water temperature [J/kg] h_s_w_i=HAProps('H','T',Tin_r,'P', pin_a, 'R', 1.0)*1000 #[J/kg_da] # Saturation specific heat at mean water temp [J/kg] c_s=cair_sat((Tin_r+Tout_r)/2.0)*1000 # Ratio of specific heats [-] DWS.Fins.Air.cs_cp=c_s/cp_da # Find new, effective fin efficiency since cs/cp is changed from wetting WavyLouveredFins(DWS.Fins) # Effective humid air mass flow ratio m_star=mdot_da/(mdot_r*(cp_r/c_s)) #compute the new Ntu_owet Ntu_owet = eta_a*h_a*A_a/(mdot_da*cp_da) m_star = min([cp_r * mdot_r/c_s, mdot_da])/max([cp_r * mdot_r/c_s, mdot_da]) mdot_min = min([cp_r * mdot_r/c_s, mdot_da]) # Wet-analysis overall Ntu [-] Ntu_wet=Ntu_o/(1+m_star*(Ntu_owet/Ntu_i)) if(cp_r * mdot_r> c_s * mdot_da): Ntu_wet=Ntu_o/(1+m_star*(Ntu_owet/Ntu_i)) else: Ntu_wet=Ntu_i/(1+m_star*(Ntu_i/Ntu_owet)) # Counterflow effectiveness for wet analysis epsilon_wet = ((1 - exp(-Ntu_wet * (1 - m_star))) / (1 - m_star * exp(-Ntu_wet * (1 - m_star)))) # Wet-analysis heat transfer rate Q_wet = epsilon_wet*mdot_min*(hin_a-h_s_w_i) # Air outlet enthalpy [J/kg_da] hout_a=hin_a-Q_wet/mdot_da # Water outlet temp [K] Tout_r = Tin_r+mdot_da/(mdot_r*cp_r)*(hin_a-hout_a) # Water outlet saturated surface enthalpy [J/kg_da] h_s_w_o=HAProps('H','T',Tout_r, 'P',pin_a, 'R', 1.0)*1000 #[J/kg_da] #Local UA* and c_s UA_star = 1/(cp_da/eta_a/h_a/A_a+cair_sat((Tin_a+Tout_r)/2.0)*1000/h_r/A_r) # Wet-analysis surface temperature [K] Tin_s = Tout_r + UA_star/h_r/A_r*(hin_a-h_s_w_o) # Wet-analysis saturation enthalpy [J/kg_da] h_s_s_e=hin_a+(hout_a-hin_a)/(1-exp(-Ntu_owet)) # Surface effective temperature [K] T_s_e=HAProps('T','H',h_s_s_e/1000.0,'P',pin_a,'R',1.0) # Air outlet temp based on effective temp [K] Tout_a=T_s_e + (Tin_a-T_s_e)*exp(-Ntu_o) #Sensible heat transfer rate [W] Q_sensible = mdot_da*cp_da*(Tin_a-Tout_a) # Error between guess and recalculated value [K] errorToutr=Tout_r-Tout_r_start; if(iter>500): print "Superheated region wet analysis T_outr convergence failed" DWS.Q=Q_dry; return if iter==1: y1=errorToutr if iter>1: y2=errorToutr x3=x2-y2/(y2-y1)*(x2-x1) change=abs(y2/(y2-y1)*(x2-x1)) y1=y2; x1=x2; x2=x3 if hasattr(DWS,'Verbosity') and DWS.Verbosity>7: print "Fullwet iter %d Toutr %0.5f dT %g" %(iter,Tout_r,errorToutr) #Update loop counter iter+=1 # Fully wetted outlet temperature [K] Tout_r_wet=Tout_r # Dry fraction f_dry=0.0 if (Tin_s>Tdp and not isFullyWet): #Partially wet and partially dry with single-phase on refrigerant side """ ----------------------------------------------------------- | * Tout_a <---- * T_a,x <---- * Tin_a | ____________Wet____________| Dry ----------------------------o T_dp ------------------------ | * Tin_r ----> * T_w,x ----> * Tout_r | ----------------------------------------------------------- """ iter = 1 # Now do an iterative solver to find the fraction of the coil that is wetted x1=0.0001 x2=0.9999 eps=1e-8 while ((iter<=3 or error>eps) and iter<100): if iter==1: f_dry=x1 if iter>1: f_dry=x2 K=Ntu_dry*(1.0-C_star) expk = exp(-K*f_dry) if cp_da*mdot_da < cp_r*mdot_r: Tout_r_guess = (Tdp + C_star*(Tin_a - Tdp)-expk*(1-K/Ntu_o)*Tin_a)/(1-expk*(1-K/Ntu_o)) else: Tout_r_guess = (expk*(Tin_a+(C_star-1)*Tdp)-C_star*(1+K/Ntu_o)*Tin_a)/(expk*C_star-C_star*(1+K/Ntu_o)) # Wet and dry effective effectivenesses epsilon_dry = ((1 - exp(-f_dry*Ntu_dry * (1 - C_star))) / (1 - C_star * exp(-f_dry*Ntu_dry * (1 - C_star)))) epsilon_wet = ((1 - exp(-(1-f_dry)*Ntu_wet * (1 - m_star))) / (1 - m_star * exp(-(1-f_dry)*Ntu_wet * (1 - m_star)))) # Temperature of "water" where condensation begins T_w_x=(Tin_r+(mdot_min)/(cp_r * mdot_r)*epsilon_wet*(hin_a-h_s_w_i-epsilon_dry*Cmin/mdot_da*Tin_a))/(1-(Cmin*mdot_min)/(cp_r * mdot_r * mdot_da)*epsilon_wet*epsilon_dry) # Temperature of air where condensation begins [K] # Obtained from energy balance on air side T_a_x = Tin_a - epsilon_dry*Cmin*(Tin_a - T_w_x)/(mdot_da*cp_da) # Enthalpy of air where condensation begins h_a_x = hin_a - cp_da*(Tin_a - T_a_x) # New "water" temperature (stored temporarily to be able to build change Tout_r=(Cmin)/(cp_r * mdot_r)*epsilon_dry*Tin_a+(1-(Cmin)/(cp_r * mdot_r)*epsilon_dry)*T_w_x # Difference between initial guess and outlet error=Tout_r-Tout_r_guess if(iter>500): print "Superheated region wet analysis f_dry convergence failed" DWS.Q=Q_dry return if iter==1: y1=error if iter>1: y2=error x3=x2-y2/(y2-y1)*(x2-x1) change=abs(y2/(y2-y1)*(x2-x1)) y1=y2; x1=x2; x2=x3; if hasattr(DWS,'Verbosity') and DWS.Verbosity>7: print "Partwet iter %d Toutr_guess %0.5f diff %g f_dry: %g"%(iter,Tout_r_guess,error,f_dry) #Update loop counter iter+=1 # Wet-analysis saturation enthalpy [J/kg] h_s_s_e=h_a_x+(hout_a-h_a_x)/(1-exp(-(1-f_dry)*Ntu_owet)) # Surface effective temperature [K] T_s_e=HAProps('T','H',h_s_s_e/1000.0,'P',pin_a,'R',1.0) # Air outlet temp based on effective surface temp [K] Tout_a=T_s_e + (T_a_x-T_s_e)*exp(-(1-f_dry)*Ntu_o) # Heat transferred [W] Q=mdot_r*cp_r*(Tout_r-Tin_r) # Dry-analysis air outlet enthalpy from energy balance [J/kg] hout_a=hin_a-Q/mdot_da #Sensible heat transfer rate [kW] Q_sensible = mdot_da*cp_da*(Tin_a-Tout_a) else: Q=Q_wet else: # Coil is fully dry Tout_a=Tout_a_dry Q=Q_dry Q_sensible=Q_dry DWS.f_dry=f_dry DWS.omega_out=HAProps('W','T',Tout_a,'P',101.325,'H',hout_a/1000.0) DWS.RHout_a=HAProps('R','T',Tout_a,'P',101.325,'W',DWS.omega_out) DWS.Tout_a=Tout_a DWS.Q=Q DWS.Q_sensible=Q_sensible DWS.hout_a=hout_a DWS.hin_a=hin_a DWS.Tout_r=Tout_r
def OBJECTIVE(x): Tevap = x[0] Tcond = x[1] Tin_CC = x[2] if Cycle.Mode == 'AC': #Condenser heat transfer rate Qcond = epsilon * Cycle.Condenser.Fins.Air.Vdot_ha / rho_air * ( Cycle.Condenser.Fins.Air.Tdb - Tcond) * 1000 #Compressor power pevap = Props('P', 'T', Tevap, 'Q', 1.0, Cycle.Ref) pcond = Props('P', 'T', Tcond, 'Q', 1.0, Cycle.Ref) Cycle.Compressor.pin_r = pevap Cycle.Compressor.pout_r = pcond Cycle.Compressor.Tin_r = Tevap + Cycle.Compressor.DT_sh Cycle.Compressor.Ref = Cycle.Ref Cycle.Compressor.Calculate() W = Cycle.Compressor.W Qcoolingcoil_dry = epsilon * Cycle.CoolingCoil.Fins.Air.Vdot_ha / rho_air * ( Cycle.CoolingCoil.Fins.Air.Tdb - Tin_CC) * 1000 # Air-side heat transfer UA CC = Cycle.CoolingCoil CC.Initialize() UA_a = CC.Fins.h_a * CC.Fins.A_a * CC.Fins.eta_a #Air outlet temp from dry analysis Tout_a = CC.Tin_a - Qcoolingcoil_dry / (CC.Fins.mdot_a * CC.Fins.cp_a) # Refrigerant side UA f, h, Re = Correlations.f_h_1phase_Tube( Cycle.Pump.mdot_g / CC.Ncircuits, CC.ID, Tin_CC, CC.pin_g, CC.Ref_g) UA_r = CC.A_g_wetted * h #Refrigerant outlet temp cp_g = Props('C', 'T', Tin_CC, 'P', Cycle.Pump.pin_g, Cycle.Pump.Ref_g) * 1000 Tout_CC = Tin_CC + Qcoolingcoil_dry / (Cycle.Pump.mdot_g * cp_g) #Get wall temperatures at inlet and outlet from energy balance T_so_a = (UA_a * CC.Tin_a + UA_r * Tout_CC) / (UA_a + UA_r) T_so_b = (UA_a * Tout_a + UA_r * Tin_CC) / (UA_a + UA_r) Tdewpoint = HAProps( 'D', 'T', CC.Fins.Air.Tdb, 'P', 101.325, 'R', CC.Fins.Air.RH ) #HumAir_Single(CC.Fins.Air.Tdb, 101.325, 'RH',CC.Fins.Air.RH,'DewPoint') #Now calculate the fully-wet analysis #Evaporator is bounded by saturated air at the refrigerant temperature. h_ai = HAProps( 'H', 'T', CC.Fins.Air.Tdb, 'P', 101.325, 'R', CC.Fins.Air.RH ) #HumAir_Single(CC.Fins.Air.Tdb, 101.325, 'RH', CC.Fins.Air.RH,'Enthalpy') h_s_w_o = HAProps( 'H', 'T', Tin_CC, 'P', 101.325, 'R', 1) #HumAir_Single(Tin_CC, 101.325, 'RH', 1.0,'Enthalpy') Qcoolingcoil_wet = epsilon * CC.Fins.Air.Vdot_ha / rho_air * ( h_ai - h_s_w_o) * 1000 #Coil is either fully-wet, fully-dry or partially wet, partially dry if T_so_a > Tdewpoint and T_so_b > Tdewpoint: #Fully dry, use dry Q f_dry = 1.0 elif T_so_a < Tdewpoint and T_so_b < Tdewpoint: #Fully wet, use wet Q f_dry = 0.0 else: f_dry = 1 - (Tdewpoint - T_so_a) / (T_so_b - T_so_a) Qcoolingcoil = f_dry * Qcoolingcoil_dry + ( 1 - f_dry) * Qcoolingcoil_wet Tin_IHX = Tin_CC + Qcoolingcoil / (Cycle.Pump.mdot_g * cp_g) QIHX = epsilon * Cycle.Pump.mdot_g * cp_g * (Tin_IHX - Tevap) Qcond_enthalpy = Cycle.Compressor.mdot_r * ( Cycle.Compressor.hout_r - Props('H', 'T', Tcond - Cycle.DT_sc_target, 'P', pcond, Cycle.Ref) * 1000) resids = [ QIHX + W + Qcond, Qcond + Qcond_enthalpy, Qcoolingcoil - QIHX ] return resids elif Cycle.Mode == 'HP': #Evaporator heat transfer rate Qevap = epsilon * Cycle.Evaporator.Fins.Air.Vdot_ha / rho_air * ( Cycle.Evaporator.Fins.Air.Tdb - Tevap) * 1000 #Compressor power pevap = Props('P', 'T', Tevap, 'Q', 1.0, Cycle.Ref) pcond = Props('P', 'T', Tcond, 'Q', 1.0, Cycle.Ref) Cycle.Compressor.pin_r = pevap Cycle.Compressor.pout_r = pcond Cycle.Compressor.Tin_r = Tevap + Cycle.Evaporator.DT_sh Cycle.Compressor.Ref = Cycle.Ref Cycle.Compressor.Calculate() W = Cycle.Compressor.W #Evaporator will be dry Qcoolingcoil = epsilon * Cycle.CoolingCoil.Fins.Air.Vdot_ha / rho_air * ( Tin_CC - Cycle.CoolingCoil.Fins.Air.Tdb) * 1000 cp_g = Props('C', 'T', Tin_CC, 'P', Cycle.Pump.pin_g, Cycle.Pump.Ref_g) * 1000 Tin_IHX = Tin_CC - Qcoolingcoil / (Cycle.Pump.mdot_g * cp_g) QIHX = epsilon * Cycle.Pump.mdot_g * cp_g * (Tin_IHX - Tcond) QIHX_enthalpy = Cycle.Compressor.mdot_r * ( Cycle.Compressor.hout_r - Props('H', 'T', Tcond - Cycle.DT_sc_target, 'P', pcond, Cycle.Ref) * 1000) resids = [ QIHX + W + Qevap, QIHX + QIHX_enthalpy, Qcoolingcoil + QIHX ] return resids
def plot(self, ax): w = [HAProps('W', 'T', T, 'P', p, 'R', 1.0) for T in Tdb] ax.plot(Tdb - 273.15, w, lw=2)
def plot(self, ax): for RH in self.RH_values: w = [HAProps('W', 'T', T, 'P', p, 'R', RH) for T in Tdb] ax.plot(Tdb - 273.15, w, 'r', lw=1)
import numpy as np import matplotlib.pyplot as plt from CoolProp.HumidAirProp import HAProps Tdb = np.linspace(-10, 55, 100) + 273.15 #Make the figure and the axes fig = plt.figure(figsize=(10, 8)) ax = fig.add_axes((0.15, 0.15, 0.8, 0.8)) ax.set_xlim(Tdb[0] - 273.15, Tdb[-1] - 273.15) ax.set_ylim(0, 0.03) ax.set_xlabel(r"Dry bulb temperature [$^{\circ}$C]") ax.set_ylabel(r"Humidity ratio ($m_{water}/m_{dry\ air}$) [-]") # Saturation line w = [HAProps('W', 'T', T, 'P', 101.325, 'R', 1.0) for T in Tdb] ax.plot(Tdb - 273.15, w, lw=2) # Humidity lines RHValues = [0.05, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9] for RH in RHValues: w = [HAProps('W', 'T', T, 'P', 101.325, 'R', RH) for T in Tdb] ax.plot(Tdb - 273.15, w, 'r', lw=1) # Humidity lines for H in [-20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90]: #Line goes from saturation to zero humidity ratio for this enthalpy T1 = HAProps('T', 'H', H, 'P', 101.325, 'R', 1.0) - 273.15 T0 = HAProps('T', 'H', H, 'P', 101.325, 'R', 0.0) - 273.15 w1 = HAProps('W', 'H', H, 'P', 101.325, 'R', 1.0) w0 = HAProps('W', 'H', H, 'P', 101.325, 'R', 0.0)
def getSaturatedProperties(self, name, h): # if name == "T": return HAProps("T", "P", 101325, "H", h, "R", 1.0) - 273.15 else: raise ValueError("name:%s not found" % name)
def check_type(Tvals, wvals): HAProps('H','T',Tvals,'P',101.325,'W', wvals)
def calculatePlot(cls, parent): """Funtion to calculate point in chart""" Preferences = ConfigParser() Preferences.read(conf_dir+"pychemqtrc") parent.setProgressValue(0) data = {} P = parent.inputs.P.value P_kPa = P/1000 t = cls.LineList("isotdb", Preferences) # Saturation line Hs = [] for tdb in t: Hs.append(HAProps("W", "P", P_kPa, "Tdb", tdb, "RH", 1)) parent.setProgressValue(5*len(Hs)/len(t)) data["t"] = t data["Hs"] = Hs # left limit of isow lines H = cls.LineList("isow", Preferences) th = [] for w in H: if w: tdp = HAProps("Tdp", "P", 101.325, "W", w, "RH", 1) th.append(Temperature(tdp).config()) else: tmin = Preferences.getfloat("Psychr", "isotdbStart") th.append(Temperature(tmin).config()) data["H"] = H data["th"] = th # Humidity ratio lines hr = cls.LineList("isohr", Preferences) Hr = {} cont = 0 for i in hr: Hr[i] = [] for tdb in t: Hr[i].append(HAProps("W", "P", P_kPa, "Tdb", tdb, "RH", i/100)) cont += 1 parent.progressBar.setValue(5+10*cont/len(hr)/len(Hs)) data["Hr"] = Hr # Twb lines = cls.LineList("isotwb", Preferences) Twb = {} cont = 0 for T in lines: ws = HAProps("W", "P", P_kPa, "RH", 1, "Tdb", T) H = [ws, 0] _td = HAProps("Tdb", "P", P_kPa, "Twb", T, "RH", 0) Tw = [Temperature(T).config(), Temperature(_td).config()] cont += 1 parent.progressBar.setValue(15+75*cont/len(lines)) Twb[T] = (H, Tw) data["Twb"] = Twb # v lines = cls.LineList("isochor", Preferences) V = {} # rh = arange(1, -0.05, -0.05) rh = arange(0.00, 1.05, 0.05) for cont, v in enumerate(lines): w = [] Td = [] for r in rh: try: w.append(HAProps("W", "P", P_kPa, "RH", r, "V", v)) _td = HAProps("Tdb", "P", P_kPa, "RH", r, "V", v) Td.append(Temperature(_td).config()) except ValueError: pass parent.progressBar.setValue(90+10*cont/len(lines)) V[v] = (Td, w) data["v"] = V return data
print("Validation against H.F. Nelson and H.J. Sauer,\"Formulation for High-Temperature Properties for Moist Air\", HVAC&R Research v.8 #3, 2002") print("Note: More accurate formulation employed than in Nelson. Just for sanity checking") print("Yields a negative relative humidity for Tdb=5C,Twb=-3C, point omitted") tdb = [5,5,5,25,25,25,25,50,50,50,50,50,50,50] twb = [5,2,-1,25,20,15,10,50,40,30,25,22,20,19] print(" ") print("Table 6: Adiabatic Saturation") print("P=101325 Pa, Altitude = 0 m") print("========================================================================") print("{Tdb:10s}{Twb:10s}{Tdp:10s}{R:10s}{W:10s}{h:10s}{v:10s}".format(W='W',Twb='Twb',Tdp='Tdp',Tdb='Tdb',v='v',h='h',s='s',R='RH')) print("{Tdb:10s}{Twb:10s}{Tdp:10s}{R:10s}{W:10s}{h:10s}{v:10s}".format(W='-',Twb='C',Tdp='C',Tdb='C',v='m^3/kg_da',h='kJ/kg_da',s='kJ/kg_da/K',R='%')) print("------------------------------------------------------------------------") for (tdb_,twb_) in zip(tdb,twb): h=HAProps('H','T',tdb_+273.13,'Twb',twb_+273.15,'P',101.325) tdp=HAProps('Tdp','T',tdb_+273.13,'Twb',twb_+273.15,'P',101.325)-273.15 W=HAProps('W','T',tdb_+273.13,'Twb',twb_+273.15,'P',101.325) R=HAProps('R','T',tdb_+273.13,'Twb',twb_+273.15,'P',101.325)*100 v=HAProps('V','T',tdb_+273.13,'Twb',twb_+273.15,'P',101.325) s=0 print("{Tdb:10.2f}{Twb:10.2f}{Tdp:10.2f}{R:10.1f}{W:10.5f}{h:10.2f}{v:10.3f}".format(W=W,Twb=twb_,Tdp=tdp,Tdb=tdb_,v=v,h=h,s=s,R=R)) print("------------------------------------------------------------------------") print(" ") print("Table 7: Adiabatic Saturation") print("P=84,556 Pa, Altitude = 1500 m") print("========================================================================") print("{Tdb:10s}{Twb:10s}{Tdp:10s}{R:10s}{W:10s}{h:10s}{v:10s}".format(W='W',Twb='Twb',Tdp='Tdp',Tdb='Tdb',v='v',h='h',s='s',R='RH')) print("{Tdb:10s}{Twb:10s}{Tdp:10s}{R:10s}{W:10s}{h:10s}{v:10s}".format(W='-',Twb='C',Tdp='C',Tdb='C',v='m^3/kg_da',h='kJ/kg_da',s='kJ/kg_da/K',R='%')) print("------------------------------------------------------------------------") for (tdb_,twb_) in zip(tdb,twb):
def HotAir(num): from CoolProp.HumidAirProp import HAProps if num == '8': Temp = str(200) T = 200 + 273.15 elif num == '9': Temp = str(320) T = 320 + 273.15 print 'A.' + num + '.1 Psychrometric Properties of Moist Air at 101.325 kPa ' print 'Dry Bulb temperature of ' + Temp + 'C' s5 = ' ' * 5 print '================================================================' print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format(W=s5 + ' W', Twb=s5 + 'Twb', v=s5 + ' v', h=s5 + 'h', s=s5 + ' s', R=s5 + 'RH') print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format( W=' kgw/kg_da', Twb=' C', v=' m3/kgda', h=' kJ/kgda', s=' kJ/kgda/K', R=' %') print '----------------------------------------------------------------' for W in [ 0.0, 0.05, 0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.0 ]: h = HAProps('H', 'T', T, 'W', W, 'P', 101.325) Twb = HAProps('Twb', 'T', T, 'W', W, 'P', 101.325) - 273.15 R = HAProps('R', 'T', T, 'W', W, 'P', 101.325) * 100 v = HAProps('V', 'T', T, 'W', W, 'P', 101.325) s = HAProps('S', 'T', T, 'W', W, 'P', 101.325) print "{W:10.2f}{Twb:10.2f}{v:10.3f}{h:10.2f}{s:10.4f}{R:10.4f}".format( W=W, Twb=Twb, v=v, h=h, s=s, R=R) print '================================================================' print ' ' print 'A.' + num + '.2 Psychrometric Properties of Moist Air at 1000 kPa ' print 'Dry Bulb temperature of ' + Temp + 'C' print '================================================================' print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format(W=s5 + ' W', Twb=s5 + 'Twb', v=s5 + ' v', h=s5 + 'h', s=s5 + ' s', R=s5 + 'RH') print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format( W=' kgw/kg_da', Twb=' C', v=' m3/kgda', h=' kJ/kgda', s=' kJ/kgda/K', R=' %') print '----------------------------------------------------------------' for W in [ 0.0, 0.05, 0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.0 ]: h = HAProps('H', 'T', T, 'W', W, 'P', 1000) Twb = HAProps('Twb', 'T', T, 'W', W, 'P', 1000) - 273.15 R = HAProps('R', 'T', T, 'W', W, 'P', 1000) * 100 v = HAProps('V', 'T', T, 'W', W, 'P', 1000) s = HAProps('S', 'T', T, 'W', W, 'P', 1000) print "{W:10.2f}{Twb:10.2f}{v:10.3f}{h:10.2f}{s:10.4f}{R:10.4f}".format( W=W, Twb=Twb, v=v, h=h, s=s, R=R) print '================================================================' print ' ' s5 = ' ' * 5 print 'A.' + num + '.3 Psychrometric Properties of Moist Air at 2000 kPa ' print 'Dry Bulb temperature of ' + Temp + 'C' print '================================================================' print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format(W=s5 + ' W', Twb=s5 + 'Twb', v=s5 + ' v', h=s5 + 'h', s=s5 + ' s', R=s5 + 'RH') print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format( W=' kgw/kg_da', Twb=' C', v=' m3/kgda', h=' kJ/kgda', s=' kJ/kgda/K', R=' %') print '----------------------------------------------------------------' for W in [ 0.0, 0.05, 0.1, 0.20, 0.30, 0.40, 0.50, 0.60, 0.70, 0.80, 0.90, 1.0 ]: h = HAProps('H', 'T', T, 'W', W, 'P', 2000) Twb = HAProps('Twb', 'T', T, 'W', W, 'P', 2000) - 273.15 R = HAProps('R', 'T', T, 'W', W, 'P', 2000) * 100 v = HAProps('V', 'T', T, 'W', W, 'P', 2000) s = HAProps('S', 'T', T, 'W', W, 'P', 2000) print "{W:10.2f}{Twb:10.2f}{v:10.3f}{h:10.2f}{s:10.4f}{R:10.4f}".format( W=W, Twb=Twb, v=v, h=h, s=s, R=R) print '================================================================' print ' ' s5 = ' ' * 5 print 'A.' + num + '.4 Psychrometric Properties of Moist Air at 5000 kPa ' print 'Dry Bulb temperature of ' + Temp + 'C' print '================================================================' print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format(W=s5 + ' W', Twb=s5 + 'Twb', v=s5 + ' v', h=s5 + 'h', s=s5 + ' s', R=s5 + 'RH') print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format( W=' kgw/kg_da', Twb=' C', v=' m3/kgda', h=' kJ/kgda', s=' kJ/kgda/K', R=' %') print '----------------------------------------------------------------' if Temp == '200': Wrange = [0.0, 0.05, 0.1, 0.15, 0.20, 0.25, 0.30] else: Wrange = [ 0.0, 0.05, 0.1, 0.15, 0.20, 0.25, 0.30, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ] for W in Wrange: h = HAProps('H', 'T', T, 'W', W, 'P', 5000) Twb = HAProps('Twb', 'T', T, 'W', W, 'P', 5000) - 273.15 R = HAProps('R', 'T', T, 'W', W, 'P', 5000) * 100 v = HAProps('V', 'T', T, 'W', W, 'P', 5000) s = HAProps('S', 'T', T, 'W', W, 'P', 5000) print "{W:10.2f}{Twb:10.2f}{v:10.3f}{h:10.2f}{s:10.4f}{R:10.4f}".format( W=W, Twb=Twb, v=v, h=h, s=s, R=R) print '================================================================' print ' ' s5 = ' ' * 5 print 'A.' + num + '.5 Psychrometric Properties of Moist Air at 10,000 kPa ' print 'Dry Bulb temperature of ' + Temp + 'C' print '================================================================' print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format(W=s5 + ' W', Twb=s5 + 'Twb', v=s5 + ' v', h=s5 + 'h', s=s5 + ' s', R=s5 + 'RH') print "{W:10s}{Twb:10s}{v:10s}{h:10s}{s:10s}{R:10s}".format( W=' kgw/kg_da', Twb=' C', v=' m3/kgda', h=' kJ/kgda', s=' kJ/kgda/K', R=' %') print '----------------------------------------------------------------' if Temp == '200': Wrange = [0.0, 0.05, 0.1] else: Wrange = [ 0.0, 0.05, 0.1, 0.15, 0.20, 0.25, 0.30, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0 ] for W in Wrange: h = HAProps('H', 'T', T, 'W', W, 'P', 10000) Twb = HAProps('Twb', 'T', T, 'W', W, 'P', 10000) - 273.15 R = HAProps('R', 'T', T, 'W', W, 'P', 10000) * 100 v = HAProps('V', 'T', T, 'W', W, 'P', 10000) s = HAProps('S', 'T', T, 'W', W, 'P', 10000) print "{W:10.2f}{Twb:10.2f}{v:10.3f}{h:10.2f}{s:10.4f}{R:10.4f}".format( W=W, Twb=Twb, v=v, h=h, s=s, R=R) print '================================================================'
def getEnthalpy(self, temp, humidityRatio): return HAProps('H', 'T', temp + 273.15, 'P', 101325, 'R', humidityRatio) #J/kg dry air
def OBJECTIVE(x): Tevap = x[0] Tcond = x[1] #Condensing heat transfer rate from enthalpies rho_air = 1.1 #Use fixed effectiveness to get a guess for the condenser capacity Qcond = epsilon * Cycle.Condenser.Fins.Air.Vdot_ha / rho_air * ( Cycle.Condenser.Fins.Air.Tdb - Tcond) * 1000 pevap = Props('P', 'T', Tevap, 'Q', 1.0, Cycle.Ref) pcond = Props('P', 'T', Tcond, 'Q', 1.0, Cycle.Ref) Cycle.Compressor.pin_r = pevap Cycle.Compressor.pout_r = pcond Cycle.Compressor.Tin_r = Tevap + Cycle.Evaporator.DT_sh Cycle.Compressor.Ref = Cycle.Ref Cycle.Compressor.Calculate() W = Cycle.Compressor.W # Evaporator fully-dry analysis Qevap_dry = epsilon * Cycle.Evaporator.Fins.Air.Vdot_ha / rho_air * ( Cycle.Evaporator.Fins.Air.Tdb - Tevap) * 1000 #Air-side heat transfer UA Evap = Cycle.Evaporator Evap.mdot_r = Cycle.Compressor.mdot_r Evap.psat_r = pevap Evap.Ref = Cycle.Ref Evap.Initialize() UA_a = Evap.Fins.h_a * Evap.Fins.A_a * Evap.Fins.eta_a Tin_a = Evap.Fins.Air.Tdb Tout_a = Tin_a + Qevap_dry / (Evap.Fins.mdot_da * Evap.Fins.cp_da) #Refrigerant-side heat transfer UA UA_r = Evap.A_r_wetted * Correlations.ShahEvaporation_Average( 0.5, 0.5, Cycle.Ref, Evap.G_r, Evap.ID, Evap.psat_r, Qevap_dry / Evap.A_r_wetted, Evap.Tbubble_r, Evap.Tdew_r) #Get wall temperatures at inlet and outlet from energy balance T_so_a = (UA_a * Evap.Tin_a + UA_r * Tevap) / (UA_a + UA_r) T_so_b = (UA_a * Tout_a + UA_r * Tevap) / (UA_a + UA_r) Tdewpoint = HAProps('D', 'T', Cycle.Evaporator.Fins.Air.Tdb, 'P', 101.325, 'R', Evap.Fins.Air.RH) #Now calculate the fully-wet analysis #Evaporator is bounded by saturated air at the refrigerant temperature. h_ai = HAProps('H', 'T', Cycle.Evaporator.Fins.Air.Tdb, 'P', 101.325, 'R', Cycle.Evaporator.Fins.Air.RH) * 1000 #[J/kg_da] h_s_w_o = HAProps('H', 'T', Tevap, 'P', 101.325, 'R', 1.0) * 1000 #[J/kg_da] Qevap_wet = epsilon * Cycle.Evaporator.Fins.Air.Vdot_ha / rho_air * ( h_ai - h_s_w_o) #Coil is either fully-wet, fully-dry or partially wet, partially dry if T_so_a > Tdewpoint and T_so_b > Tdewpoint: #Fully dry, use dry Q f_dry = 1.0 elif T_so_a < Tdewpoint and T_so_b < Tdewpoint: #Fully wet, use wet Q f_dry = 0.0 else: f_dry = 1 - (Tdewpoint - T_so_a) / (T_so_b - T_so_a) Qevap = f_dry * Qevap_dry + (1 - f_dry) * Qevap_wet Qcond_enthalpy = Cycle.Compressor.mdot_r * ( Cycle.Compressor.hout_r - Props('H', 'T', Tcond - Cycle.DT_sc_target, 'P', pcond, Cycle.Ref) * 1000) resids = [Qevap + W + Qcond, Qcond + Qcond_enthalpy] #,Qevap,f_dry] return resids
def PlainFins(Inputs): #Source: #Heat transfer and friction characteristics of plain fin-and-tube heat exchangers, part II: Correlation #Chi-Chuan Wang, Kuan-Yu Chi, Chun-Jung Chang #Properties: p = Inputs.Air.p #air pressure W = HAProps('W', 'T', Inputs.Air.Tdb, 'P', p, 'R', Inputs.Air.RH) #Transport properties of humid air from CoolProp mu_ha = HAProps('M', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) k_ha = HAProps('K', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) * 10**3 #Evaluate the mass flow rate based on inlet conditions Vdot_ha = Inputs.Air.Vdot_ha # To convert a parameter from per kg_{humid air} to per kg_{dry air}, divide by (1+W) W = HAProps('W', 'T', Inputs.Air.Tdb, 'P', p, 'R', Inputs.Air.RH) v_da = HAProps('V', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) h_da = HAProps('H', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) * 1000 rho_ha = 1 / v_da * (1 + W) #[m^3/kg_ha] rho_da = 1 / v_da #[m^3/kg_da] mdot_ha = Vdot_ha * rho_ha #[kg_ha/s] mdot_da = Vdot_ha * rho_da #[kg_da/s] #Use a forward difference to calculate cp from cp=dh/dT dT = 0.0001 #[K] cp_da = (HAProps('H', 'T', Inputs.Air.Tdb + dT, 'P', p, 'W', W) * 1000 - h_da) / dT #[J/kg_da/K] cp_ha = cp_da / (1 + W) #[J/kg_ha/K] # Check that cs_cp is defined, if so, set it to the value passed in if (hasattr(Inputs, 'cs_cp') and Inputs.cs_cp > 0) or (hasattr(Inputs, 'WetDry') and Inputs.WetDry == 'Wet'): isWet = True cs_cp = Inputs.Air.cs_cp else: isWet = False cs_cp = 1.0 #Dimensions and values used for both Reynolds number ranges: delta_f = Inputs.Fins.t #fin thickness(m) FPI = Inputs.Fins.FPI #fins per inch FPM = FPI / 0.0254 #Fins per meter [1/m] F_p = 1 / FPM #Fin pitch (distance between centerlines of fins) F_s = 1 / FPM - delta_f #Fin spacing(m) P_t = Inputs.Tubes.Pt #transverse tube pitch (m) P_L = Inputs.Tubes.Pl #longitudinal tube pitch (m) D_o = Inputs.Tubes.OD #Outer diameter of tube (m) D_c = D_o + 2 * delta_f #fin collar outside diameter (m) (tube + 2*fin thickness) Ltube = Inputs.Tubes.Ltube #length of a single tube [m] Nfin = Ltube * FPM #Number of fins in the tube sheet [-] Ntubes_bank = Inputs.Tubes.NTubes_per_bank #tubes per bank Height = P_t * ( Ntubes_bank + 1 ) #Height of heat exchanger [m] # assuming that fin extends 1/2 pt above/below last tube in bundle A_duct = Height * Ltube #A_duct is the face area [m^2] - equivalent to the duct cross-section #neglecting the additional height of the fins above/below the last tubes in the bundle A_c = A_duct - delta_f * Nfin * ( Height - D_c * Ntubes_bank ) - Ntubes_bank * D_c * Ltube #Minimum duct cross-sectional area that is not fin or tube(-collar) [m^2] u_max = mdot_ha / (rho_ha * A_c) #maximum airside velocity [m/s] Re_Dc = rho_ha * u_max * D_c / mu_ha #from reference #4 of Wang et all. Slightly different notation used in [4] N = Inputs.Tubes.Nbank #number of lomgitudunal tube rows (#Number of banks in ACHP-notation) L = ( N + 1 ) * P_L #depth of heat exchanger in airflow direction, assuming fins extends 1/2 bank oer the first and last tube Nbank = N #to be able to reuse equations #Wetted Area of a single fin [m^2] A_1fin = 2.0 * ( Height * P_L * (Nbank + 1) - Ntubes_bank * Nbank * pi * D_c * D_c / 4 ) #assuming that fin extends 1/2 pt in front/after last tube in bundle # Total wetted area of the fins [m^2] Af = Nfin * A_1fin #Total area including tube and fins [m^2] A_o = Af + Ntubes_bank * Nbank * pi * D_c * (Ltube - Nfin * delta_f) D_h = 4 * A_c * L / A_o #Hydraulic diameter #heat transfer if N == 1: P1 = 1.9 - 0.23 * log(Re_Dc) P2 = -0.236 + 0.126 * log(Re_Dc) j = 0.108 * pow(Re_Dc, -0.29) * pow(P_t / P_L, P1) * pow( F_p / D_h, -1.084) * pow(F_p / D_h, -0.786) * pow(F_p / P_t, P2) if N >= 2: P3 = -0.361 - 0.042 * N / log(Re_Dc) + 0.158 * log(N * (F_p / D_c)**0.41) P4 = -1.224 - 0.076 * pow(P_L / D_h, 1.42) / log(Re_Dc) P5 = -0.083 + 0.058 * N / log(Re_Dc) P6 = -5.735 + 1.21 * log(Re_Dc / N) j = 0.086 * pow(Re_Dc, P3) * pow(N, P4) * pow(F_p / D_c, P5) * pow( F_p / D_h, P6) * pow(F_p / P_t, -0.93) #pressure drop F1 = -0.764 + 0.739 * P_t / P_L + 0.177 * F_p / D_c - 0.00758 / N F2 = -15.689 + 64.021 / log(Re_Dc) F3 = 1.696 - 15.695 * log(Re_Dc) f = 0.0267 * pow(Re_Dc, F1) * pow(P_t / P_L, F2) * pow(F_p / D_c, F3) Pr = cp_ha * mu_ha / k_ha h_a = j * rho_ha * u_max * cp_ha / pow( Pr, 2.0 / 3.0) #air side mean heat transfer coefficient using colborn j-factor #calcs needed for specific fin types #additional parameters needed k_fin = Inputs.Fins.k_fin #Total area including tube and fins [m^2] A = A_o r = D_o / 2 X_D = sqrt(P_L * P_L + P_t * P_t / 4) / 2 X_T = P_t / 2 rf_r = 1.27 * X_T / r * sqrt(X_D / X_T - 0.3) m = sqrt( 2 * h_a * cs_cp / (k_fin * delta_f)) #cs_cp is the correction for heat/mass transfer #Using the circular fin correlation of Schmidt phi = (rf_r - 1) * (1 + 0.35 * log(rf_r)) eta_f = tanh(m * r * phi) / (m * r * phi) # Fin efficiency based on analysis in # "FIN EFFICIENCY CALCULATION IN ENHANCED FIN-AND-TUBE HEAT EXCHANGERS IN DRY CONDITIONS" # by Thomas PERROTIN, Denis CLODIC, International Congress of Refrigeration 2006 # In the paper, there is no 0.1 in the cosine term, but if the cosine term is used without # the correction, the results are garbage for wet analysis # Using the offset fins correlation phi = (rf_r - 1) * (1 + (0.3 + pow(m * (rf_r * r - r) / 2.5, 1.5 - rf_r / 12.0) * (0.26 * pow(rf_r, 0.3) - 0.3)) * log(rf_r)) #finned surface efficiency eta_f = tanh(m * r * phi) / (m * r * phi) * cos(0.1 * m * r * phi) #overall surface efficiency eta_o = 1 - Af / A * (1 - eta_f) G_c = mdot_ha / A_c #air mass flux Atube = Ntubes_bank * Nbank * pi * D_o * Ltube # Total outer area of the tubes [m^2] DeltaP_air = A / Atube / rho_ha * G_c**2 / 2.0 * f #airside pressure drop #write necessary values back into the given structure Inputs.A_a = A Inputs.cp_da = cp_da Inputs.cp_ha = cp_ha if isWet == True: Inputs.eta_a_wet = eta_o else: Inputs.eta_a = eta_o Inputs.h_a = h_a Inputs.mdot_ha = mdot_ha Inputs.mdot_da = mdot_da Inputs.f_a = f Inputs.dP_a = DeltaP_air Inputs.Re = Re_Dc print "Warning! The PlainFins seem to be buggy, better use HerringboneFins with small waveiness"
# -*- coding: utf-8 -*- """ Created on Tue Jun 10 12:05:27 2014 @author: nfette """ #import the things you need from CoolProp.HumidAirProp import HAProps, HAProps_Aux #Enthalpy (kJ per kg dry air) as a function of temperature, pressure, # and relative humidity at dry bulb temperature T of 25C, pressure # P of one atmosphere, relative humidity R of 50% h = HAProps('H', 'T', 298.15, 'P', 101.325, 'R', 0.5) print h # 50.4249283433 #Temperature of saturated air at the previous enthalpy T = HAProps('T', 'P', 101.325, 'H', h, 'R', 1.0) print T # 290.962168888 #Temperature of saturated air - order of inputs doesn't matter T = HAProps('T', 'H', h, 'R', 1.0, 'P', 101.325) print T # 290.962168888
print 'Saturated air at 101.325 kPa' s5 = ' ' * 5 print '====================================================' print "{T:8s}{W:10s}{v:10s}{h:10s}{s:10s}".format(W=s5 + ' Ws', v=s5 + ' v', h=s5 + 'h', s=s5 + ' s', T=' T') print "{T:8s}{W:10s}{v:10s}{h:10s}{s:10s}".format(W=' kgw/kg_da', v=' m3/kgda', h=' kJ/kgda', s=' kJ/kgda/K', T=' C') print '----------------------------------------------------' for T in np.linspace(-60, 0, 13) + 273.15: h = HAProps('H', 'T', T, 'R', 1.0, 'P', 101.325) Twb = HAProps('Twb', 'T', T, 'R', 1.0, 'P', 101.325) - 273.15 W = HAProps('W', 'T', T, 'R', 1.0, 'P', 101.325) v = HAProps('V', 'T', T, 'R', 1.0, 'P', 101.325) s = HAProps('S', 'T', T, 'R', 1.0, 'P', 101.325) print "{T:8.0f}{W:10.7f}{v:10.4f}{h:10.3f}{s:10.4f}".format(W=W, T=T - 273.15, v=v, h=h, s=s) print '====================================================' print ' ' print 'A.6.2 Psychrometric Properties of Moist Air at 0C and Above' print 'Saturated air at 101.325 kPa' s5 = ' ' * 5 print '===================================================='
def WavyLouveredFins(Inputs): """ # Correlations from: # Chi-Chuan Wang and Yu-Min Tsai and Ding-Chong Lu, 1998, "Comprehensive # Study of Convex-Louver and Wavy Fin-and-Tube Heat Exchangers", Journal # of Thermophysics and Heat Transfer || - xf -> ^ == == | == | == == Pd == | == == | == | == == = == s == | | | == == == == == == == == == == == == == t: thickness of fin plate Pf: fin pitch (centerline-to-centerline distance between fins) Pd: indentation for waviness (not including fin thickness) s: fin spacing (free space between fins) = Pf-t |-- Pl -| ___ | / \ | = | | | | \ ___ / | | | | ___ | / \ | Pt | | D | \ ___ / | | | ___ | / \ = | | \ ___ / """ Ntubes_bank = Inputs.Tubes.NTubes_per_bank #tubes per bank Nbank = Inputs.Tubes.Nbank #Number of banks Ltube = Inputs.Tubes.Ltube #length of a single tube D = Inputs.Tubes.OD #Outer diameter of tube Pl = Inputs.Tubes.Pl #Horizontal spacing between banks (center to center) Pt = Inputs.Tubes.Pt #Vertical spacing between tubes in a bank (center to center) FPI = Inputs.Fins.FPI pd = Inputs.Fins.Pd xf = Inputs.Fins.xf t = Inputs.Fins.t k_fin = Inputs.Fins.k_fin Vdot_ha = Inputs.Air.Vdot_ha p = Inputs.Air.p if hasattr(Inputs, 'Tmean'): Temp = Inputs.Air.Tmean else: Temp = Inputs.Air.Tdb if hasattr(Inputs, 'RHmean'): RHin = Inputs.Air.RHmean else: RHin = Inputs.Air.RH # Check that cs_cp is defined, if so, set it to the value passed in if (hasattr(Inputs, 'cs_cp') and Inputs.cs_cp > 0) or (hasattr(Inputs, 'WetDry') and Inputs.WetDry == 'Wet'): isWet = True cs_cp = Inputs.Air.cs_cp else: isWet = False cs_cp = 1.0 #Film temperature [K] Tfilm = Temp #Fins per meter [1/m] FPM = FPI / 0.0254 #Fin pitch (distance between centerlines of fins) pf = 1 / FPM #Spacing between fins s = 1 / FPM - t #Height of heat exchanger [m] Height = Pt * ( Ntubes_bank + 1 ) #assuming that fin extends 1/2 pt above/below last tube in bundle #A_duct is the face area [m^2] equivalent to the duct cross-section A_duct = Height * Ltube #neglecting the additional height of the fins above/below the last tubes in the bundle #Number of fins in the tube sheet [-] Nfin = Ltube * FPM #Secant of theta is the area enhancement factor [-] # It captures the increase in area due to the waviness of the fins sec_theta = sqrt(xf * xf + pd * pd) / xf # Duct cross-sectional area that is not fin or tube [m^2] Ac = A_duct - t * Nfin * (Height - D * Ntubes_bank) - Ntubes_bank * D * Ltube # Total outer area of the tubes [m^2] Atube = Ntubes_bank * Nbank * pi * D * Ltube #Wetted Area of a single fin [m^2] A_1fin = 2.0 * ( Height * Pl * (Nbank + 1) * sec_theta - Ntubes_bank * Nbank * pi * D * D / 4 ) #assuming that fin extends 1/2 pt in front/after last tube in bundle # Total wetted area of the fins [m^2] Af = Nfin * A_1fin #Total area including tube and fins [m^2] A = Af + Ntubes_bank * Nbank * pi * D * (Ltube - Nfin * t) #Evaluate the mass flow rate based on inlet conditions # To convert a parameter from per kg_{humid air} to per kg_{dry air}, divide by (1+W) W = HAProps('W', 'T', Inputs.Air.Tdb, 'P', p, 'R', Inputs.Air.RH) v_da = HAProps('V', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) h_da = HAProps('H', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) * 1000 rho_ha = 1 / v_da * (1 + W) #[m^3/kg_ha] rho_da = 1 / v_da #[m^3/kg_da] mdot_ha = Vdot_ha * rho_ha #[kg_ha/s] mdot_da = Vdot_ha * rho_da #[kg_da/s] umax = mdot_ha / (rho_ha * Ac) #[m/s] #Use a forward difference to calculate cp from cp=dh/dT dT = 0.0001 #[K] cp_da = (HAProps('H', 'T', Inputs.Air.Tdb + dT, 'P', p, 'W', W) * 1000 - h_da) / dT #[J/kg_da/K] cp_ha = cp_da / (1 + W) #[J/kg_ha/K] #Transport properties of humid air from CoolProp mu_ha = HAProps('M', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) k_ha = HAProps('K', 'T', Inputs.Air.Tdb, 'P', p, 'W', W) * 10**3 #Dimensionless Groups Pr = cp_ha * mu_ha / k_ha Re_D = rho_ha * umax * D / mu_ha #Heat transfer j = 16.06 * pow(Re_D, -1.02 * (pf / D) - 0.256) * pow(A / Atube, -0.601) * pow( Nbank, -0.069) * pow(pf / D, 0.84) #Colburn j-Factor h_a = j * rho_ha * umax * cp_ha / pow( Pr, 2.0 / 3.0) #air side mean heat transfer coefficient #air side pressure drop correlations if (Re_D < 1e3): fa_total = 0.264 * (0.105 + 0.708 * exp(-Re_D / 225.0)) * pow( Re_D, -0.637) * pow(A / Atube, 0.263) * pow(pf / D, -0.317) else: fa_total = 0.768 * (0.0494 + 0.142 * exp(-Re_D / 1180.0)) * pow( A / Atube, 0.0195) * pow(pf / D, -0.121) #calcs needed for specific fin types r = D / 2 X_D = sqrt(Pl * Pl + Pt * Pt / 4) / 2 X_T = Pt / 2 rf_r = 1.27 * X_T / r * sqrt(X_D / X_T - 0.3) m = sqrt(2 * h_a * cs_cp / (k_fin * t)) #cs_cp is the correction for heat/mass transfer #Using the circular fin correlation of Schmidt phi = (rf_r - 1) * (1 + 0.35 * log(rf_r)) eta_f = tanh(m * r * phi) / (m * r * phi) # Fin efficiency based on analysis in # "FIN EFFICIENCY CALCULATION IN ENHANCED FIN-AND-TUBE HEAT EXCHANGERS IN DRY CONDITIONS" # by Thomas PERROTIN, Denis CLODIC, International Congress of Refrigeration 2006 # In the paper, there is no 0.1 in the cosine term, but if the cosine term is used without # the correction, the results are garbage for wet analysis # Using the offset fins correlation phi = (rf_r - 1) * (1 + (0.3 + pow(m * (rf_r * r - r) / 2.5, 1.5 - rf_r / 12.0) * (0.26 * pow(rf_r, 0.3) - 0.3)) * log(rf_r)) #finned surface efficiency eta_f = tanh(m * r * phi) / (m * r * phi) * cos(0.1 * m * r * phi) #overall surface efficiency eta_o = 1 - Af / A * (1 - eta_f) G_c = mdot_ha / Ac #air mass flux DeltaP_air = A / Atube / rho_ha * G_c**2 / 2.0 * fa_total #airside pressure drop #write necessary values back into the given structure Inputs.A_a = A Inputs.cp_da = cp_da Inputs.cp_ha = cp_ha if isWet == True: Inputs.eta_a_wet = eta_o else: Inputs.eta_a = eta_o Inputs.h_a = h_a Inputs.mdot_ha = mdot_ha Inputs.mdot_da = mdot_da Inputs.f_a = fa_total Inputs.dP_a = DeltaP_air Inputs.Re = Re_D
def Calculate(self): #calculate evaporator without consideration of pressure drop for HT self.Initialize() # Input and output thermodynamic properties ssatL=Props('S','T',self.Tbubble_r,'Q',0,self.Ref)*1000 ssatV=Props('S','T',self.Tdew_r,'Q',1,self.Ref)*1000 hsatL=Props('H','T',self.Tbubble_r,'Q',0,self.Ref)*1000 hsatV=Props('H','T',self.Tdew_r,'Q',1,self.Ref)*1000 #Must give enthalpy and pressure as inputs #print "in evaporator-enthalpies","hin_r,hsatL,hsatV",self.hin_r,hsatL,hsatV,"self.Tbubble_r,self.psat_r",self.Tbubble_r,self.psat_r #print "self.__dict__ in Evaporator.py",self.__dict__ #print "hin_r in Evaporator.py",self.hin_r self.xin_r=(self.hin_r-hsatL)/(hsatV-hsatL) self.sin_r=self.xin_r*ssatV+(1-self.xin_r)*ssatL self.hin_r=self.xin_r*hsatV+(1-self.xin_r)*hsatL self.Tin_r=self.xin_r*self.Tdew_r+(1-self.xin_r)*self.Tbubble_r #Begin by assuming that you go all the way to saturated vapor at least self.xout_2phase=1.0 if self.Tin_a<(self.Tin_r+0.3): #too close to saturation temperature - set capacity to 0 print "!!!!!!!!!!!!!!!!!!!!!warning - setting capacity to 0 and neglecting pressure drop in evaporator!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" if self.xin_r<1.0: #since no capacity, everything just goes out as it came in self.w_2phase=1.0 self.w_superheat=0.0 existsSuperheat=False else: self.w_2phase=0.0 self.w_superheat=1.0 existsSuperheat=True self.Q_2phase=0 self.Charge_2phase=0 self.Q_sensible_2phase=0 self.h_r_2phase=0.0 self.DP_r_2phase=0.0 self.xout_2phase=99 #EES-style self.Tout_a_2phase=self.Tin_a #since we have no two-phase capacity self.omega_out_2phase=0.0 self.Q_superheat=0.0 self.h_r_superheat=0.0 self.Re_r_superheat=0.0 self.Charge_superheat=0.0 self.Q_sensible_superheat=0.0 self.Tout_a_superheat=0.0 self.DP_r_superheat=0.0 self.fdry_superheat=0.0 self.omega_out_superheat=0.0 elif self.xin_r<1.0 and self._TwoPhase_Forward(1.0)<0: #print "assuming two-phase",self.xin_r # Evaporator outlet is in two-phase region, use all the area and find the outlet quality existsSuperheat=False self.w_2phase=1.0 def OBJECTIVE(xout): self.xout_2phase=xout Q_target=self.mdot_r*(xout-self.xin_r)*(hsatV-hsatL) self._TwoPhase_Forward(self.w_2phase) #print "in Evaporator xout_objective",self.xin_r,xout,self.Q_2phase,Q_target return self.Q_2phase-Q_target #Use a solver to find outlet quality brentq(OBJECTIVE,self.xin_r,1.0) self.w_superheat=0.0 self.Q_superheat=0.0 self.h_r_superheat=0.0 self.Re_r_superheat=0.0 self.Charge_superheat=0.0 self.Q_sensible_superheat=0.0 self.Tout_a_superheat=0.0 self.DP_r_superheat=0.0 self.fdry_superheat=0.0 self.omega_out_superheat=0.0 else: #have superheated inlet conditions existsSuperheat=True # Evaporator outlet is in superheated region, everything is ok if self.xin_r<1.0: #need to find outlet quality self.w_2phase=brentq(self._TwoPhase_Forward,0.00000000001,0.9999999999) if hasattr(self, 'plotit'): if self.plotit==True: #plot how self._TwoPhase_Forward behaves import pylab as plt w_guesses=np.linspace(0.00000000001,0.9999999999,20) w_resids=np.zeros(len(w_guesses)) for i in range(len(w_guesses)): w_resids[i]=self._TwoPhase_Forward(w_guesses[i]) print "w_resids",w_resids fig = plt.figure() ax = fig.add_subplot(111) ax.plot(w_guesses, w_resids) ax.set_title("residual for 2-phase fraction") plt.show() T_inlet_r=self.Tdew_r #saturated inlet to sensible section else: #have superheated conditions, two phase section doesn't exist self.w_2phase=0.0 self.Q_2phase=0 self.Charge_2phase=0 self.Q_sensible_2phase=0 self.h_r_2phase=0.0 self.DP_r_2phase=0.0 self.xout_2phase=99 #EES-style self.Tout_a_2phase=self.Tin_a #since we have no two-phase capacity self.omega_out_2phase=0.0 T_inlet_r=Props('T','H',self.hin_r/1000.0, 'P', self.psat_r, self.Ref) #calculated inlet temperature based on enthalpy if self.Tin_a<T_inlet_r: print "Evap: inlet air temperature smaller than refrigerant temperature, two phase doesn't exist",self.Tin_a,"<",T_inlet_r,"self.hin_r/1000.0",self.hin_r/1000.0,"self.psat_r",self.psat_r raise ValueError if self.cp_r_iter: #solve for proper cp print "using iteration to find better estimate for cp_r" try: def objective_cp(x0): self.cp_r=1000.0*(Props('C','T',self.Tdew_r+x0*0.3333, 'P', self.psat_r, self.Ref)+Props('C','T',self.Tdew_r+x0, 'P', self.psat_r, self.Ref)+Props('C','T',self.Tdew_r+1.66667*x0, 'P', self.psat_r, self.Ref))/3.0 #average value self._Superheat_Forward(1-self.w_2phase) return self.Tdew_r-2*x0-self.Tout_r brentq_result=brentq(objective_cp,0,50) print "accuracy of cp-iteration loop of evaporator -objective_cp(brentq_result)",objective_cp(brentq_result),brentq_result, -(self.Tdew_r-self.Tout_r)/2.0,self.cp_r except: #if above approach does not work, do not iterate. self.cp_r=1000.0*Props('C','T',self.Tdew_r+3, 'P', self.psat_r, self.Ref) print "warning-cp_r iter in Evaporator did not work. using non-iteratively solved value for superheat instead", self.cp_r,self.w_2phase self._Superheat_Forward(1-self.w_2phase,T_inlet_r) else: #use fixed point cp assuming 6K superheat self.cp_r=1000.0*Props('C','T',self.Tdew_r+3, 'P', self.psat_r, self.Ref) self._Superheat_Forward(1-self.w_2phase,T_inlet_r) self.Q=self.Q_superheat+self.Q_2phase self.Charge=self.Charge_superheat+self.Charge_2phase if self.Verbosity>4: print self.Q,"Evaporator.Q" self.Capacity=self.Q-self.Fins.Air.FanPower #Sensible heat ratio [-] if self.Q>0.0: self.SHR=(self.Q_sensible_2phase+self.Q_sensible_superheat)/self.Q else: self.SHR=1.0 # #Average air outlet values (area fraction weighted average, neglecting influence of different air mass flowrate due to viscosity/density changes with change of omega or temperature) self.Tout_a=self.w_superheat*self.Tout_a_superheat+self.w_2phase*self.Tout_a_2phase self.omega_out=self.w_superheat*self.omega_out_superheat+self.w_2phase*self.omega_out_2phase self.Fins.Air.RH_out=HAProps('R','T',self.Tout_a,'P',101.325,'W',self.omega_out) #neglect pressure drop across evaporator self.DP_r=self.DP_r_superheat+self.DP_r_2phase self.pout_r=self.psat_r+self.DP_r/1000.0 #pressure drop negative and in Pa #limit minimum outlset pressure if self.pout_r<10: print "warning - outlet pressure in evaporator too low - limiting to allow for solver to find correct value" self.pout_r=30#kPa #Outlet enthalpy obtained from energy balance self.hout_r=self.hin_r+self.Q/self.mdot_r #print "debug Evaporator - self.hin_r,",self.hin_r/1000.0,self.hout_r/1000.0," self.Tin_a", self.Fins.Air.Tdb,"self.Fins.mdot_ha",self.Fins.mdot_ha #Outlet superheat an temperature (in case of two phase) if existsSuperheat: try: self.Tout_r=newton(lambda T: Props('H','T',T,'P',self.pout_r,self.Ref)-self.hout_r/1000.0,Props('T','P',self.pout_r,'Q',1.0,self.Ref)) except: print "problem iwith calculating Tout_r in evaporator.py" print "self.hout_r/1000.0",self.hout_r/1000.0,"self.hin_r/1000.0",self.hin_r/1000.0,"Props('H','Q',1.0,'P',self.pout_r,self.Ref)",Props('H','Q',1.0,'P',self.pout_r,self.Ref),"self.pout_r",self.pout_r,"self.psat_r",self.psat_r,"self.mdot_r",self.mdot_r,"self.xin_r",self.xin_r print "Props('H','Q',0.0,'P',self.pout_r,self.Ref)",Props('H','Q',0.0,'P',self.pout_r,self.Ref),"self.Tin_a,self.Tsat_r",self.Tin_a,self.Tsat_r,"self.DP_r/1000.0",self.DP_r/1000.0,self.Q,self.Q_superheat,self.Q_2phase,existsSuperheat,self.w_2phase print self.Fins.cp_da print "neglecting pressure drop in sh-section for normal evaproator (no issue for Calcuilate_PD, since result will be overwritten)" if self.w_2phase<1e-11: print "neglecting capacity of two phase section, since likely not converged properly due to small fraction of two-phase area (self.w_2phase=",self.w_2phase self.Q_2phase=0.0 self.Q=self.Q_superheat+self.Q_2phase #recalculate Outlet enthalpy obtained from energy balance self.hout_r=self.hin_r+self.Q/self.mdot_r print "self.hout_r",self.hout_r self.Tout_r=newton(lambda T: Props('H','T',T,'P',self.psat_r,self.Ref)-self.hout_r/1000.0,Props('T','P',self.psat_r,'Q',1.0,self.Ref)) self.sout_r=Props('S','T',self.Tout_r,'P',self.pin_r,self.Ref)*1000.0 self.DT_sh_calc=self.Tout_r-self.Tdew_r else: xout_r=(self.hout_r-hsatL)/(hsatV-hsatL) self.sout_r=ssatV*xout_r+(1-xout_r)*ssatL self.DT_sh_calc=(self.hout_r-hsatV)/(Props('C','T',self.Tdew_r,'Q',1,self.Ref)*1000.0) #continuous superheat self.Tout_r=Props('T','P',self.pout_r,'Q',xout_r,self.Ref) #saturated temperature at outlet quality self.hmean_r=self.w_2phase*self.h_r_2phase+self.w_superheat*self.h_r_superheat self.UA_r=self.hmean_r*self.A_r_wetted self.UA_a=self.Fins.h_a*self.Fins.A_a*self.Fins.eta_a #Build a vector of temperatures at each point where there is a phase transition along the averaged circuit if existsSuperheat: #Insert the shoulder point Tv=[self.Tin_r,self.Tdew_r,self.Tout_r] x=[0,max(self.w_2phase,0.9999999),1] else: Tv=[self.Tin_r,xout_r*self.Tdew_r+(1-xout_r)*self.Tbubble_r] x=[0,1] #Determine each bend temperature by interpolation #------------------------------------------------ #Number of bends (including inlet and outlet of coil) Nbends=1+self.Lcircuit/self.Ltube #x-position of each point xv=np.linspace(0,1,Nbends) self.Tbends=interp1d(x,Tv)(xv) self.existsSuperheat=existsSuperheat #needed for Calculate_PD()
def calculatePlot(cls, parent): """Funtion to calculate points in chart""" data = {} P = Preferences.getfloat("General", "P") P_kPa = P/1000 t = cls.LineList("isotdb", Preferences) # Saturation line Hs = [] for tdb in t: Hs.append(HAProps("W", "P", P_kPa, "Tdb", tdb, "RH", 1)) parent.progressBar.setValue(5*len(Hs)/len(t)) data["t"] = t data["Hs"] = Hs # left limit of isow lines H = cls.LineList("isow", Preferences) th = [] for w in H: if w: tdp = HAProps("Tdp", "P", 101.325, "W", w, "RH", 1) th.append(tdp-273.15) else: tmin = Preferences.getfloat("Psychr", "isotdbStart") th.append(tmin-273.15) data["H"] = H data["th"] = th # Humidity ratio lines hr = cls.LineList("isohr", Preferences) Hr = {} cont = 0 for i in hr: Hr[i] = [] for tdb in t: Hr[i].append(HAProps("W", "P", P_kPa, "Tdb", tdb, "RH", i/100.)) cont += 1 parent.progressBar.setValue(5+10*cont/len(hr)/len(Hs)) data["Hr"] = Hr # Twb lines = cls.LineList("isotwb", Preferences) Twb = {} cont = 0 for T in lines: ws = HAProps("W", "P", P_kPa, "RH", 1, "Tdb", T) H = [ws, 0] Tw = [T-273.15, HAProps("Tdb", "P", P_kPa, "Twb", T, "RH", 0)-273.15] cont += 1 parent.progressBar.setValue(15+75*cont/len(lines)) Twb[T] = (H, Tw) data["Twb"] = Twb # v lines = cls.LineList("isochor", Preferences) V = {} rh = np.arange(1, -0.05, -0.05) for cont, v in enumerate(lines): w = [] Td = [] for r in rh: w.append(HAProps("W", "P", P_kPa, "RH", r, "V", v)) Td.append(HAProps("Tdb", "P", P_kPa, "RH", r, "V", v)-273.15) parent.progressBar.setValue(90+10*cont/len(lines)) V[v] = (Td, w) data["v"] = V return data