def humidity_ratio(t, t_d, p): # CoolProp try: mmr = hap.HAPropsSI('W', 'T', t, 'D', t_d, 'P', p) except: mmr = 0.9415 return mmr
def compute_hp_param_estimation(params, m_s, m_l, T_s, T_l, q_load, q_source, humidity, hp_specification): refrigerant = hp_specification[2] T_min_ref = CP.PropsSI('TMIN', refrigerant) T_max_ref = CP.PropsSI('TCRIT', refrigerant) p_min_ref = CP.PropsSI('PMIN', refrigerant) p_max_ref = CP.PropsSI('PCRIT', refrigerant) source_composition = hp_specification[3] load_composition = hp_specification[4] # constants cp_l = CP.PropsSI('CP0MASS', 'T', T_l, 'P', hp_specification[6], load_composition) if hp_specification[0] == 'a-a' or hp_specification[0] == 'a-w': # humid air properties cp_s = HA.HAPropsSI('cp_ha', 'T', T_s, 'P', hp_specification[5], 'R', humidity) epsilon_s = thermal_eff(params[1], m_s, cp_s) else: cp_s = CP.PropsSI('C', 'T', T_s, 'P', hp_specification[5], source_composition) epsilon_s = thermal_eff(params[1], m_s, cp_s) epsilon_l = thermal_eff(params[0], m_l, cp_l) [m_ref, q_source, q_heating, comp_p] = heat_pump_cycle(params, T_s, T_l, q_load, q_source, m_s, m_l, hp_specification, [cp_l, cp_s], [epsilon_l, epsilon_s], [T_min_ref, T_max_ref, p_min_ref, p_max_ref]) return [q_heating, comp_p, q_source]
def humidity_ratio(t, t_d, p=14.696): p_pa = p * 6894.76 t_k = (t - 32) * 5 / 9 + 273.15 td_k = (t_d - 32) * 5 / 9 + 273.15 # CoolProp mmr = hap.HAPropsSI('W', 'T', t_k, 'D', td_k, 'P', p_pa) return mmr
def relative_humidity(t, t_d, p=14.696): p_pa = p * 6894.76 t_k = (t - 32) * 5 / 9 + 273.15 td_k = (t_d - 32) * 5 / 9 + 273.15 # CoolProp rh = hap.HAPropsSI('R', 'T', t_k, 'D', td_k, 'P', p_pa) return rh
def dew_point(mmr=1e-3, p=14.696): # Vapor pressure p_w = vapor_pressure(mmr, p) # # ASHRAE method # t_d = 90.12 + 26.412 * np.log(p_w) + 0.8927 * np.log(p_w)**2 # CoolProp method t_d = hap.HAPropsSI('D', 'W', mmr, 'P', p * 6894.76, 'T', 300) t_d = (t_d - 273.15) * 1.8 + 32 return t_d
def relative_humidity2(t, t_d, p): # CoolProp try: rh = hap.HAPropsSI('R', 'T', t, 'D', t_d, 'P', p) except: if t < t_d: # HAPropsSI doesn't work with supersaturated air; set to 1.0 rh = 1.0 elif t <= 0.0 or t_d <= 0.0: # low humidity; return 0.0 rh = 0.0 else: # unknown error; return error value rh = -1.0 return rh
def dew_point(mmr, p_psi): # Vapor pressure p_w_psi = vapor_pressure(mmr, p_psi) # Convert to SI units p_w = p_w_psi / (KPA2PSI / 1000) p = p_psi / (KPA2PSI / 1000) # # ASHRAE method # t_d = 90.12 + 26.412 * np.log(p_w) + 0.8927 * np.log(p_w)**2 # CoolProp method try: t_d = hap.HAPropsSI('D', 'W', mmr, 'P', p, 'T', 300) except: t_d = 0.0 return (t_d - 273.15) * 9 / 5 + 32 # converted to degreesF
def relative_humidity1(t_f, mmr, p_psi): # Convert to SI units t = (t_f - 32) * 5 / 9 + 273.15 # Kelvin p = p_psi / (KPA2PSI / 1000) # Pascals # Calculate dew point (K) t_d = (dew_point(mmr, p_psi) - 32) * 5 / 9 + 273.15 # CoolProp try: rh = hap.HAPropsSI('R', 'T', t, 'D', t_d, 'P', p) except: if t < t_d: # HAPropsSI doesn't work with supersaturated air; set to 1.0 rh = 1.0 elif t <= 0.0 or t_d <= 0.0: # low humidity; return 0.0 rh = 0.0 else: # unknown error; return error value rh = -1.0 return rh
def compute_hp_performance(params, T_s, T_l, q_load, m_s, m_l, humidity, hp_specification): # constants iter = 0 maxiter = 1000 tol = 5 * 10**(-2) q_load_calc = 0 refrigerant = hp_specification[2] source_composition = hp_specification[3] load_composition = hp_specification[4] T_min_ref = CP.PropsSI('TMIN', refrigerant) T_max_ref = CP.PropsSI('TCRIT', refrigerant) p_min_ref = CP.PropsSI('PMIN', refrigerant) p_max_ref = CP.PropsSI('PCRIT', refrigerant) cp_l = CP.PropsSI('CP0MASS', 'T', T_l, 'P', hp_specification[6], load_composition) epsilon_l = thermal_eff(params[0], m_l, cp_l) if hp_specification[0] == 'a-a' or hp_specification[0] == 'a-w': # humid air properties cp_s = HA.HAPropsSI('cp_ha', 'T', T_s, 'P', hp_specification[5], 'R', humidity) epsilon_s = thermal_eff(params[1], m_s, cp_s) else: cp_s = CP.PropsSI('C', 'T', T_s, 'P', hp_specification[5], source_composition) epsilon_s = thermal_eff(params[1], m_s, cp_s) # initial guess for q_source q_source = q_load * 0.8 while abs((q_load - q_load_calc) / q_load) > tol and iter < maxiter: [m_ref, q_source, q_load_calc, comp_p ] = heat_pump_cycle(params, T_s, T_l, q_load, q_source, m_s, m_l, hp_specification, [cp_l, cp_s], [epsilon_l, epsilon_s], [T_min_ref, T_max_ref, p_min_ref, p_max_ref]) iter = iter + 1 return [m_ref, q_source, comp_p, q_load_calc, iter]
# 3 - source composition/ relative humidity , 4 - load composition hp_specification = hp.loc[0, "HP-Type":"pressure load"].to_numpy() # convert sample values samples.T_s = samples.T_s + 273.15 samples.T_l = samples.T_l + 273.15 samples.q_load = samples.q_load * 10**3 samples.q_source = samples.q_source * 10**3 samples.w_el = samples.w_el * 10**3 # convert source volume flow rate to mass flow rate if hp_array[10] == 'l/s': if hp_specification[0] == 'a-a' or hp_specification[0] == 'a-w': for k, row_samples in samples.iterrows(): rho = 1 / HA.HAPropsSI('Vha', 'T', samples.T_s[k], 'P', hp_specification[5], 'R', samples.comment[k]) m_s = samples.m_s[k] * rho * 10**(-3) samples.at[k, 'm_s'] = m_s hp.at[0, 'flow type source'] = 'kg/s' else: for k, row_samples in samples.iterrows(): rho = CP.PropsSI('D', 'P', hp_specification[5], 'T', samples.T_s[k], hp_specification[3]) m_s = samples.m_s[k] * rho * 10**(-3) samples.at[k, 'm_s'] = m_s hp.at[0, 'flow type source'] = 'kg/s' elif hp_array[10] == 'm^3/h': if hp_specification[0] == 'a-a' or hp_specification[0] == 'a-w': for k, row_samples in samples.iterrows(): rho = 1 / HA.HAPropsSI('Vha', 'T', samples.T_s[k], 'P',
def parallel_evaporation( temperature_interface = 300, temperature_far_in = 290, relhum_far_in = 0.2, dryair_mass_flow_in = 0.1, water_flow_in = 0.07, a_cell = 2., pressure = 1e5, cells = 20, supersaturated_method=None): """For supersaturated method, consider 'hack'.""" nodal_temperature = [] nodal_relhum = [] nodal_humrat = [] nodal_water_flow = [] nodal_water_temperature = [] nodal_interface_humrat = [] relhum_interface = 1 nodal_temperature.append(temperature_far_in) nodal_relhum.append(relhum_far_in) humrat_far_in = HAP.HAPropsSI('HumRat','P',pressure,'T',temperature_far_in,'RH',relhum_far_in) nodal_humrat.append(humrat_far_in) nodal_water_flow.append(water_flow_in) nodal_water_temperature.append(temperature_interface) nodal_interface_humrat.append(HAP.HAPropsSI( 'HumRat','P',pressure,'T',temperature_interface,'RH',relhum_interface)) for i in range(cells): temperature_far = temperature_far_in relhum_far = relhum_far_in # Convert to dimensions we wish to average enthalpy_interface = HAP.HAPropsSI('Hha','P',pressure,'T',temperature_interface,'RH',relhum_interface) humrat_interface = HAP.HAPropsSI('HumRat','P',pressure,'T',temperature_interface,'RH',relhum_interface) mole_fraction_interface = HAP.HAPropsSI('Y','P',pressure,'T',temperature_interface,'RH',relhum_interface) mixture_density_interface = 1 / HAP.HAPropsSI('Vha','P',pressure,'T',temperature_interface,'RH',relhum_interface) vapor_density_interface = mole_fraction_interface * mixture_density_interface enthalpy_far = HAP.HAPropsSI('Hha','P',pressure,'T',temperature_far,'RH',relhum_far) humrat_far = HAP.HAPropsSI('HumRat','P',pressure,'T',temperature_far,'RH',relhum_far) mole_fraction_far = HAP.HAPropsSI('Y','P',pressure,'T',temperature_far,'RH',relhum_far) mixture_density_far = 1 / HAP.HAPropsSI('Vha','P',pressure,'T',temperature_far,'RH',relhum_far) vapor_density_far = mole_fraction_far * mixture_density_far enthalpy_vapor_interface = CP.PropsSI('H','T',temperature_interface,'Q',1,'water') \ - h_ref_water # Now determine the film state and transport properties enthalpy_film = 0.5 * (enthalpy_interface + enthalpy_far) humrat_film = 0.5 * (humrat_interface + humrat_far) temperature_film = HAP.HAPropsSI('T','P',pressure,'Hha',enthalpy_film,'HumRat',humrat_film) relhum_film = HAP.HAPropsSI('RH','P',pressure,'Hha',enthalpy_film,'HumRat',humrat_film) volume = HAP.HAPropsSI('Vha','P',pressure,'Hha',enthalpy_film,'HumRat',humrat_film) density = 1 / volume c_p = HAP.HAPropsSI('Cha','P',pressure,'Hha',enthalpy_film,'HumRat',humrat_film) k = HAP.HAPropsSI('K','P',pressure,'Hha',enthalpy_film,'HumRat',humrat_film) mu = HAP.HAPropsSI('mu','P',pressure,'Hha',enthalpy_film,'HumRat',humrat_film) nu = mu * volume prandtl = c_p * mu / k #print(prandtl) #print(vapor_density_far, vapor_density_interface, mixture_density_far) length_scale = 0.01 velocity = 1 nusselt = 1 h_heat = nusselt * k / length_scale stanton_heat = h_heat / (density * velocity * c_p) #print(stanton_heat) # Mass diffusivity [m2/s] # TODO: add a lookup-table with temperature diffusivity_mass = 2.5e-5 schmidt = nu / diffusivity_mass lewis = schmidt / prandtl #print(lewis) stanton_ratio = pow(lewis, 2/3) #print(stanton_ratio) stanton_mass = stanton_heat / stanton_ratio h_mass = stanton_mass * velocity #print(h_mass) flow_per_area_mass = h_mass * (vapor_density_interface - vapor_density_far) flow_per_area_heat = h_heat * (temperature_interface - temperature_far) flow_per_area_mass, flow_per_area_heat mass_flow_cell = a_cell * flow_per_area_mass heat_flow_cell = a_cell * flow_per_area_heat # If the state is near saturation and getting closer, # then we need to dial down the water vapor influx. # Water vapor outflux is okay, as it tends to drive away from saturation. if supersaturated_method is 'hack': if relhum_film > 1 and mass_flow_cell > 0: mass_flow_cell = 0 water_flow_out = water_flow_in - mass_flow_cell humrat_in = humrat_far humair_mass_flow_in = dryair_mass_flow_in * (1+humrat_in) humair_mass_flow_out = humair_mass_flow_in + mass_flow_cell humrat_out = humair_mass_flow_out / dryair_mass_flow_in - 1 enthalpy_ave_in = enthalpy_far total_enthalpy_in = humair_mass_flow_in * enthalpy_ave_in total_enthalpy_out = total_enthalpy_in + heat_flow_cell \ + mass_flow_cell * enthalpy_vapor_interface enthalpy_ave_out = total_enthalpy_out / humair_mass_flow_out water_total_enthalpy_in = water_flow_in * CP.PropsSI('H','T',temperature_interface,'Q',0,'water') water_total_enthalpy_out = water_total_enthalpy_in - heat_flow_cell \ - mass_flow_cell * enthalpy_vapor_interface water_enthalpy_out = water_total_enthalpy_out / water_flow_out water_temperature_out = CP.PropsSI('T','H',water_enthalpy_out,'P',pressure,'water') #print(water_temperature_out) interface_humrat_out = HAP.HAPropsSI('HumRat','P',pressure,'T',water_temperature_out,'RH',relhum_interface) t_out = HAP.HAPropsSI('T','P',pressure,'Hha',enthalpy_ave_out,'HumRat',humrat_out) rh_out = HAP.HAPropsSI('RH','P',pressure,'Hha',enthalpy_ave_out,'HumRat',humrat_out) temperature_far_in = t_out relhum_far_in = rh_out water_flow_in = water_flow_out temperature_interface = water_temperature_out nodal_temperature.append(t_out) nodal_relhum.append(rh_out) nodal_humrat.append(humrat_out) nodal_water_flow.append(water_flow_out) nodal_water_temperature.append(water_temperature_out) nodal_interface_humrat.append(interface_humrat_out) result = pandas.DataFrame.from_dict(dict( T_air=nodal_temperature, RelHum=nodal_relhum, HumRat_air=nodal_humrat, WaterFlow=nodal_water_flow, T_water=nodal_water_temperature, HumRat_interface=nodal_interface_humrat )) return result