PSYCHROMETRICS
Overview
The PSYCHROMETRICS
function provides core psychrometric calculations, including wet bulb temperature, dew point, humidity ratio, and enthalpy. Psychrometrics is the study of the thermodynamic properties of moist air, essential in engineering, HVAC, and meteorological applications. Key calculations include:
-
Wet Bulb Temperature (): The temperature air would have if cooled to saturation by evaporation, with latent heat supplied by the parcel.
-
Dew Point (): The temperature at which air becomes saturated and water vapor condenses. Calculated using the Magnus formula:
where is the actual vapor pressure, , , and are empirical constants.
-
Humidity Ratio (): The mass of water vapor per unit mass of dry air:
where is the total atmospheric pressure.
-
Enthalpy (): The total heat content of moist air per unit mass of dry air:
where is the specific heat of dry air, is the latent heat of vaporization, and is the dry bulb temperature.
For more advanced psychrometric calculations, see the PsychroLib GitHub repository and the official documentation .
This example function is provided as-is without any representation of accuracy.
Usage
To use the function in Excel:
=PSYCHROMETRICS(calc_type, dry_bulb_C, relative_humidity, [pressure_Pa])
calc_type
(string, required): Calculation type. One of “wetbulb”, “dewpoint”, “humidityratio”, or “enthalpy”.dry_bulb_C
(float, required): Dry bulb temperature in Celsius.relative_humidity
(float, required): Relative humidity (0-100).pressure_Pa
(float, optional, default=101325): Atmospheric pressure in Pascals.
The function returns a single value (float): the result of the requested psychrometric calculation, or an error message (string) if the input is invalid or out-of-range.
Examples
Example 1: Calculate Wet Bulb Temperature
In Excel:
=PSYCHROMETRICS("wetbulb", 25, 60, 101325)
Expected output:
Result (°C) |
---|
19.13 |
Example 2: Calculate Dew Point
In Excel:
=PSYCHROMETRICS("dewpoint", 20, 80, 101325)
Expected output:
Result (°C) |
---|
16.41 |
Example 3: Calculate Humidity Ratio
In Excel:
=PSYCHROMETRICS("humidityratio", 25, 40, 101325)
Expected output:
Result (kg/kg) |
---|
0.007 |
Example 4: Calculate Enthalpy
In Excel:
=PSYCHROMETRICS("enthalpy", 18, 90, 101325)
Expected output:
Result (kJ/kg) |
---|
51.13 |
This means, for example, the enthalpy of moist air at 18°C and 90% RH is approximately 51.13 kJ/kg.
Python Code
import math
def psychrometrics(calc_type, dry_bulb_C, relative_humidity, pressure_Pa=101325):
"""
Perform core psychrometric calculations: wet bulb, dew point, humidity ratio, enthalpy.
Args:
calc_type: Calculation type. One of 'wetbulb', 'dewpoint', 'humidityratio', or 'enthalpy'.
dry_bulb_C: Dry bulb temperature in Celsius.
relative_humidity: Relative humidity (0-100).
pressure_Pa: Atmospheric pressure in Pascals (default: 101325).
Returns:
The result of the requested psychrometric calculation (float), or an error message (str) if the input is invalid or out-of-range.
This example function is provided as-is without any representation of accuracy.
"""
try:
Tdb = float(dry_bulb_C)
RH_input = float(relative_humidity)
P = float(pressure_Pa)
except Exception:
return "Invalid input: could not convert arguments to float."
if not (0 <= RH_input <= 100):
return "Invalid input: relative_humidity must be between 0 and 100."
RH = RH_input / 100.0
if not isinstance(calc_type, str):
return "Invalid input: unknown calculation type."
calc_type_lower = calc_type.lower()
# Constants
A = 6.1121 # hPa
m = 17.368
Tn = 238.88 # deg C
Cp = 1.006 # kJ/kg.K (specific heat of dry air)
Cpv = 1.86 # kJ/kg.K (specific heat of water vapor)
Lv = 2501 # kJ/kg (latent heat of vaporization at 0C)
# Helper: saturation vapor pressure (hPa)
def pws(T):
return A * math.exp((m * T) / (T + Tn))
# Helper: actual vapor pressure (hPa)
def pw(T, RH):
return RH * pws(T)
# Helper: humidity ratio (kg/kg)
def humidity_ratio(T, RH, P):
Pw = pw(T, RH) * 100 # Pa
return 0.62198 * Pw / (P - Pw)
# Helper: dew point (C)
def dew_point(T, RH):
Pw = pw(T, RH)
if Pw <= 0:
return "Invalid input: vapor pressure is non-positive."
lnPw = math.log(Pw / A)
return (Tn * lnPw) / (m - lnPw)
# Helper: enthalpy (kJ/kg)
def enthalpy(T, RH, P):
W = humidity_ratio(T, RH, P)
return (Cp * T + W * (Cpv * T + Lv)) # kJ/kg, matches ASHRAE/PsychroLib
# Helper: wet bulb (C) using psychrometric formula (Stull, 2011, or similar)
def wet_bulb(T, RH, P):
Tw = T * math.atan(0.151977 * (RH + 8.313659) ** 0.5) + \
math.atan(T + RH) - math.atan(RH - 1.676331) + \
0.00391838 * RH ** 1.5 * math.atan(0.023101 * RH) - 4.686035
return Tw
if calc_type_lower == "wetbulb":
return round(wet_bulb(Tdb, RH_input, P), 2)
elif calc_type_lower == "dewpoint":
dp = dew_point(Tdb, RH)
if isinstance(dp, str):
return dp
return round(dp, 2)
elif calc_type_lower == "humidityratio":
return round(humidity_ratio(Tdb, RH, P), 6)
elif calc_type_lower == "enthalpy":
return round(enthalpy(Tdb, RH, P), 2)
else:
return "Invalid input: unknown calculation type."
return "Invalid input: unknown error."
Live Notebook
Edit this function in a live notebook .