/*
This file is a library containing functions for calculating properties
of water vapor in air (e.g. absolute humidity, relative humidity,
partial vapor pressure of water.)
There are a lot of equations that could be used. See the survey:
http://faculty.eas.ualberta.ca/jdwilson/EAS372_13/Vomel_CIRES_satvpformulae.html
Most of the equations in this library are taken from the reversible
equations cited in:
Buck, A. L. (1981), "New equations for computing vapor pressure and enhancement factor", J. Appl. Meteorol. 20: 1527–1532
http://ams.allenpress.com/perlserv/?request=get-pdf&doi=10.1175%2F1520-0450%281981%29020%3C1527%3ANEFCVP%3E2.0.CO%3B2
This is further corrected in
Buck (1996), Buck Research CR-1A User's Manual, Appendix 1.
http://www.hygrometers.com/wp-content/uploads/CR-1A-users-manual-2009-12.pdf
The equations in this library are for water vapor pressure over water (there
are similar equations for over ice) and represent the corrected Buck
equations (1996).
*/
/*
Returns *saturation* vapor pressure of water at the specified temperature.
This is the maximum vapor pressure of water at the specified temperature
over water.
*/
saturationVaporPressure[temp is temperature] :=
{
t = C[temp]
return 6.1121 hPa exp[(18.678 - t/234.5) t / (257.14 + t)]
}
// Calculate the vapor pressure given temperature, pressure,
// and relative humidity (a number between 0 and 1, or, say, "30 percent")
vaporPressure[temp is temperature, p is pressure, relativeHumidity is dimensionless] :=
{
return relativeHumidity * buckF1[temp, p]
}
// Returns absolute humidity as a mass density (e.g. g/m^3)
// T is the temperature,
// relativeHumidity is a number between 0 and 1, or "30 percent"
absoluteHumidity[temp is temperature, p is pressure, relativeHumidity is dimensionless] :=
{
e = vaporPressure[temp, p, relativeHumidity] / millibars
return 216.7 g/m^3 * e / (temp/K)
}
/*
Returns absolute humidity as a mass density (e.g. g/m^3) for water vapor
over water. (As opposed to over ice, which has different equations.)
T is the temperature,
vaporPressure is the partial pressure of water vapor
It's much more likely that you'll use the function above, though, which
calculates the partial vapor pressure of water for you, which is nonlinear
and hard to measure directly.
*/
absoluteHumidity[temp is temperature, vaporPressure is pressure] :=
{
return 216.7 g/m^3 (vaporPressure/millibar)/(temp/K)
}
////////////////////////////////////////////////////////////////////
//
// You probably don't want to call functions below here directly,
// but use the friendlier functions above.
//
////////////////////////////////////////////////////////////////////
/* Calculates equation F1 from Buck (1996) for partial vapor pressure over
water (there are other equations for water over ice.)
Results are the partial vapor pressure of water.
temp is the temperature.
p is the total atmospheric pressure.
*/
buckF1[temp is temperature, p is pressure] :=
{
T = C[temp]
return EFw[temp, p] * 6.1121 * exp[(18.678 - T/234.5) * T/(T+257.14)] millibars
}
/* Calculates the "enhancement factor" due to water vapor not behaving
like an ideal gas in air. See Buck (1996).
This is for water vapor over water. There is a different equation for
water vapor over ice.
Result is a dimensionless number.
*/
EFw[temp is temperature, p is pressure] :=
{
P = p / millibars
T = C[temp]
return (1 + 10^-4 (7.2 + P (0.0320 + 5.9e-6 T^2)))
}