Grains per pound in JavaScript: humidity math for drying logs, with an altitude correction
Water damage crews track drying in grains per pound (GPP), not in relative humidity. Relative humidity moves every time the temperature moves. GPP is the absolute amount of water in the air: grains of water per pound of dry air, with 7,000 grains to the pound. If the GPP in a wet room falls day after day, the structure is giving up its water.
Most psychrometric charts and phone apps compute GPP for sea-level pressure. Our crews log these numbers on jobs for water damage restoration in Denver, at about 1,609 m, where the air pressure is roughly 18% lower than the sea-level value. The same temperature and relative humidity then mean more grains per pound. This post builds the calculation in plain JavaScript, with the pressure as a parameter, and checks it against chart values.

Saturation vapor pressure
Everything starts from the saturation vapor pressure: the most water vapor the air can hold at a given temperature. The Buck equation (1996) gives it in hectopascals for temperatures over water:
const fToC = (f) => ((f - 32) * 5) / 9;
// Saturation vapor pressure over water, hPa (Buck, 1996)
function saturationVaporPressure(tempC) {
return 6.1121 * Math.exp((18.678 - tempC / 234.5) * (tempC / (257.14 + tempC)));
}
Moisture meters and thermo-hygrometers in the US read in °F, so the conversion sits next to it.
Grains per pound, with the pressure term
Relative humidity times the saturation pressure gives the actual vapor pressure e. The humidity ratio W is then 0.621945 × e / (P − e), where P is the total air pressure and 0.621945 is the ratio of the molar masses of water and dry air. W comes out in pounds of water per pound of dry air, so multiplying by 7,000 gives grains.
// Standard-atmosphere pressure at an altitude, hPa
function pressureAtAltitude(meters) {
return 1013.25 * Math.pow(1 - 2.25577e-5 * meters, 5.25588);
}
// Grains of water per pound of dry air
function grainsPerPound(tempF, rh, pressureHpa = 1013.25) {
const e = (rh / 100) * saturationVaporPressure(fToC(tempF));
const w = (0.621945 * e) / (pressureHpa - e); // lb water per lb dry air
return w * 7000;
}
P sits in the denominator. Lower pressure means the same vapor pressure is spread over less dry air, so W goes up. That is the whole altitude effect, and it is why a sea-level chart reads low at altitude.
Dew point
Dew point is the second number on a drying log. A wall or a window colder than the room's dew point will collect condensation. The Magnus formula is accurate enough for this range:
// Dew point, °F (Magnus formula, b = 17.62, c = 243.12 °C)
function dewPointF(tempF, rh) {
const t = fToC(tempF);
const g = Math.log(rh / 100) + (17.62 * t) / (243.12 + t);
const tdC = (243.12 * g) / (17.62 - g);
return (tdC * 9) / 5 + 32;
}
Dew point depends only on how much water is in the air, so pressure does not appear in it.
Checking the numbers
A psychrometric chart gives about 54.7 gr/lb and a dew point of about 50.5 °F for 70 °F at 50% relative humidity at sea level. The assertions below run on Node 24:
import assert from "node:assert/strict";
const DENVER_M = 1609;
const pDenver = pressureAtAltitude(DENVER_M);
console.log(pDenver.toFixed(1)); // 834.3
console.log(grainsPerPound(70, 50).toFixed(1)); // 54.5
console.log(grainsPerPound(70, 50, pDenver).toFixed(1)); // 66.3
console.log(dewPointF(70, 50).toFixed(1)); // 50.5
assert.ok(Math.abs(pDenver - 835) < 2);
assert.ok(Math.abs(grainsPerPound(70, 50) - 54.7) < 0.6);
assert.ok(grainsPerPound(70, 50, pDenver) > 64);
assert.ok(Math.abs(dewPointF(70, 50) - 50.5) < 0.5);
assert.ok(Math.abs(dewPointF(70, 100) - 70) < 0.01); // saturated air: dew point = temperature
The same room reading is 54.5 gr/lb at sea level and 66.3 gr/lb at Denver's altitude, a difference of about 12 grains. On a drying goal measured in single grains, that gap is large enough to matter.
A drying log
Two derived numbers carry most of the information on a daily log. Grain depression is the room GPP minus the GPP of the air leaving the dehumidifier: if it is positive, the unit is pulling water out of the air. Outside GPP tells you whether opening a window would bring drier or wetter air into the house.
The log below is a made-up three-day example, not a real job:
const log = [
{ day: 1, room: [72, 65], dehuOut: [88, 28], outside: [45, 60] },
{ day: 2, room: [74, 48], dehuOut: [90, 22], outside: [50, 55] },
{ day: 3, room: [74, 38], dehuOut: [91, 18], outside: [48, 62] },
];
function summarize(entry, pressure) {
const gpp = ([t, rh]) => grainsPerPound(t, rh, pressure);
const room = gpp(entry.room);
const out = gpp(entry.dehuOut);
return {
day: entry.day,
roomGpp: Math.round(room),
grainDepression: Math.round(room - out),
outsideGpp: Math.round(gpp(entry.outside)),
};
}
console.table(log.map((e) => summarize(e, pDenver)));
┌─────────┬─────┬─────────┬─────────────────┬────────────┐
│ (index) │ day │ roomGpp │ grainDepression │ outsideGpp │
├─────────┼─────┼─────────┼─────────────────┼────────────┤
│ 0 │ 1 │ 93 │ 26 │ 32 │
│ 1 │ 2 │ 73 │ 17 │ 36 │
│ 2 │ 3 │ 58 │ 10 │ 37 │
└─────────┴─────┴─────────┴─────────────────┴────────────┘
Room GPP falls from 93 to 58 over three days, so the structure is drying. Grain depression shrinks as the room air gets drier, which is normal: a dehumidifier removes less water per pass from drier air. Outside air at 32 to 37 gr/lb is drier than the room on every day of this example.
Limits
pressureAtAltitude returns the standard atmosphere, not today's weather. Station pressure in Denver moves a few hectopascals with passing systems, which shifts GPP by well under one grain at room conditions, so the standard value is fine for a log. If your meter reports its own GPP, check which pressure it assumes before you compare its numbers with these. The Buck and Magnus formulas are fitted for ordinary indoor and outdoor temperatures. They are not meant for the inside of a furnace or a freezer.
All rights reserved