Most psychrometric snippets you'll find hard-code one number: 14.696 psia, sea-level pressure. That's fine in Miami. In Denver the same function quietly reports air that's 18% drier than it really is.
The interesting part is what happens when you fix it. A latent load calculation has a second sea-level assumption hiding in it, and the two errors almost cancel each other. Correct one and leave the other, and your answer gets worse.
The formula
Humidity ratio is the mass of water vapor per mass of dry air:
W = 0.621945 * p_v / (p - p_v)
p_v is the partial pressure of the water vapor, p is the total air pressure, and 0.621945 is the ratio of the molar masses of water and dry air. Multiply by 7,000 to get grains per pound.
The vapor pressure comes from temperature and RH and doesn't care about altitude. The total pressure does. Lower p, and the same vapor makes up a bigger share of the mix.
The code
from math import exp
P_SEA = 14.696 # psia
def p_sat(t_f):
"""Saturation vapor pressure, psia (Magnus; liquid branch >= 32 F, ice below)."""
t_c = (t_f - 32) / 1.8
if t_f >= 32:
return 0.08855 * exp(17.625 * t_c / (243.04 + t_c))
return 0.08855 * exp(22.587 * t_c / (273.86 + t_c))
def p_atm(alt_ft):
"""Standard atmosphere pressure at altitude, psia (ASHRAE Fundamentals, Ch. 1)."""
return 14.696 * (1 - 6.8754e-6 * alt_ft) ** 5.2559
def humidity_ratio(t_f, rh, p=P_SEA):
"""Grains of water per lb of dry air."""
p_v = rh / 100 * p_sat(t_f)
return 7000 * 0.621945 * p_v / (p - p_v)
print("75 F / 50% RH")
for alt in (0, 2000, 5280, 7000):
p = p_atm(alt)
w_true = humidity_ratio(75, 50, p)
w_sea = humidity_ratio(75, 50)
print(f"{alt:>5} ft {p:6.3f} psia W = {w_true:5.1f} gr/lb"
f" sea-level formula {w_sea:5.1f} ({(w_sea - w_true) / w_true:+.0%})")
Output:
75 F / 50% RH
0 ft 14.696 psia W = 64.5 gr/lb sea-level formula 64.5 (+0%)
2000 ft 13.664 psia W = 69.4 gr/lb sea-level formula 64.5 (-7%)
5280 ft 12.100 psia W = 78.5 gr/lb sea-level formula 64.5 (-18%)
7000 ft 11.340 psia W = 83.9 gr/lb sea-level formula 64.5 (-23%)
At 2,000 ft the error is already 7%. In Denver, the room is holding about 78.5 grains per pound, not 64.5.
The second sea-level constant
Now use those numbers for something real: the latent load on a cooling coil. The usual shortcut is:
Q_latent = 0.68 * CFM * delta_grains # Btu/h
That 0.68 isn't a law of nature. It's 60 min/h × 0.075 lb/ft³ × about 1,060 Btu/lb of latent heat ÷ 7,000 gr/lb. The 0.075 is the density of standard air at sea level. At altitude, a cubic foot of air weighs less, so each CFM carries fewer pounds of air, and fewer pounds of water.
So there are two sea-level assumptions in one line: the humidity ratio and the 0.68. Here are all three combinations for 1,000 CFM through a coil, 80°F/50% in, 55°F/95% out, in Denver (CFM measured at local conditions):
def latent_btuh(cfm, d_gr, p=P_SEA):
return 0.68 * (p / P_SEA) * cfm * d_gr # 0.68 assumes 0.075 lb/ft3
p = p_atm(5280)
d_sea = humidity_ratio(80, 50) - humidity_ratio(55, 95)
d_den = humidity_ratio(80, 50, p) - humidity_ratio(55, 95, p)
print()
print(f"Coil dW: sea-level formula {d_sea:.1f} gr/lb, Denver {d_den:.1f} gr/lb")
print(f"A) both uncorrected: {0.68 * 1000 * d_sea:7,.0f} Btu/h")
print(f"B) W corrected, 0.68 kept: {0.68 * 1000 * d_den:7,.0f} Btu/h")
print(f"C) both corrected: {latent_btuh(1000, d_den, p):7,.0f} Btu/h")
Coil dW: sea-level formula 15.3 gr/lb, Denver 18.7 gr/lb
A) both uncorrected: 10,399 Btu/h
B) W corrected, 0.68 kept: 12,716 Btu/h
C) both corrected: 10,470 Btu/h
Option A, the lazy one, lands within 1% of the correct answer C. Option B, the "I fixed the altitude bug" version, is about 21% high.
Why? The grains go up by roughly the same factor that the air density goes down. Per cubic foot, the actual amount of water barely changes. The two sea-level assumptions are wrong in opposite directions by nearly the same amount.
So which one should you write?
Not A. It's right here by coincidence, and only for this kind of question. The moment you need the humidity ratio itself, for a dew point check, an ERV effectiveness or a comparison with a sensor reading, A is 18% off.
Write C. Pass pressure into everything that depends on it:
- Humidity ratio: use local pressure, not 14.696.
-
Mass flow: convert CFM to lb/h with the local density, or scale the 0.68 and the sensible 1.08 by
p / 14.696(at the same temperature). - Be clear about CFM. Fan curves and airflow measurements are often in actual CFM at local conditions. Some specs are in standard CFM. Mixing them reintroduces the error you just removed.
Quick rule
If a constant contains 0.075 or 14.696, it has an altitude in it. Pass pressure as a parameter, even when the default is sea level, so the assumption is visible in the function signature instead of buried in a number.
Your turn: what's the sneakiest "standard conditions" constant you've found in someone's engineering code? Air density, gravity, water at 60°F? Share it in the comments.
Top comments (0)