Humid air can be modeled as a mixture of air and water vapor. In the simplest analysis, water and air are treated as ideal gases but in principle there is interaction between the air and water molecules that must be included through the use of interaction parameters.
Because humid air is a mixture of dry air (treated as a pseudo-pure gas) and water vapor (treated as a real gas), three variables are required to fix the state by the state postulate.
In the analysis that follows, the three parameters that are ultimately needed to calculate everything else are the dry bulb temperature $T$, the total pressure $p$, and the molar fraction of water $\psi_w$. The molar fraction of air is simply $\psi_a=1-\psi_w$.
Of course, it is not so straightforward to measure the mole fraction of water vapor molecules, so other measures are used. There are three different variables that can be used to obtain the mole fraction of water vapor without resorting to iterative methods.
The humidity ratio $W$ is the ratio of the mass of water vapor to the mass of air in the mixture. Thus the mole fraction of water can be obtained from
$$\psi_w=\frac{n_w}{n}=\frac{n_w}{n_a+n_w}=\frac{m_w/M_w}{m_a/M_a+m_w/M_w}=\frac{m_w}{(M_w/M_a)m_a+m_w}=\frac{1}{(M_w/M_a)/W+1}=\frac{W}{(M_w/M_a)+W}$$or
$$\psi_w=\frac{W}{\varepsilon+W}$$where the ratio of mole masses $\varepsilon$ is given by $\varepsilon=M_w/M_a$
The relative humidity $\varphi$ is defined as the ratio of the mole fraction of water in the humid air to the saturation mole fraction of water. Because of the presence of air with the water, the pure water saturated vapor pressure $p_{w,s}$ must be multiplied by an enhancement factor $f$ that is very close to one near atmospheric conditions.
Mathematically, the result is
$$\varphi=\frac{\psi_w}{\psi_{w,s}}$$where
$$\psi_{w,s}=\frac{fp_{w,s}}{p}$$The product $p_s$ is defined by $p_s=fp_{w,s}$, and $p_{w,s}$ is the saturation pressure of pure water (or ice) at temperature $T$. This yields the result for $\psi_w$ of
$$\varphi=\frac{\psi_w}{p_s/p}$$$$\psi_w=\frac{\varphi p_s}{p}$$The dewpoint temperature is defined as the temperature at which the actual vapor pressure of water is equal to the saturation vapor pressure. At the given dewpoint, the vapor pressure of water is given by
$$p_w=f(p,T_{dp})p_{w,s}(T_{dp})$$and the mole fraction of water vapor is obtained from
$$ \psi_w=\frac{p_w}{p}$$Once the state has been fixed by a set of $T,p,\psi_w$, any parameter of interest can be calculated
The bracketed term on the right hand side is the compressibility Z factor, equal to 1 for ideal gas, and is a measure of non-ideality of the air. The virial terms are given by
$$B_m=(1-\psi_w)^2B_{aa}+2(1-\psi_w)\psi_wB_{aw}+\psi_w^2B_{ww}$$$$C_m=(1-\psi_w)^3C_{aaa}+3(1-\psi_w)^2\psi_wC_{aaw}+3(1-\psi_w)\psi_w^2C_{aww}+\psi_w^3C_{www}$$where the virial coefficients are described in ASRAE RP-1485 and their values are provided in :ref:HA-Validation
. All virial terms are functions only of temperature.
Usually the temperature is known, the water mole fraction is calculated, and $\bar v$ is found using iterative methods, in HAProps, using a secant solver and the first guess that the compressibility factor is 1.0.
The molar enthalpy of humid air is obtained from
$$\bar h=(1-\psi_w)\bar h_a^o+\psi_w\bar h_w^o+\bar R T \left[(B_m-T\frac{dB_m}{dT})\frac{1}{\bar v}+\left(C_m-\frac{T}{2}\frac{dC_m}{dT}\right) \frac{1}{\bar v^2}\right]$$with $\bar h$ in kJ/kmol. For both air and water, the full EOS is used to evaluate the enthalpy
$$\bar h_a^o=\bar h_0+\bar RT\left[ 1+\tau\left( \frac{\partial \alpha^o}{\partial \tau}\right)_{\delta}\right]$$which is in kJ/kmol, using the mixture $\bar v$ to define the parameter $\delta=1/(\bar v \bar \rho_c)$ for each fluid, and using the critical molar density for the fluid obtained from $\bar \rho_c=1000\rho_c/M$ to give units of mol/m$^3$ . The offset enthalpies for air and water are given by
$$\bar h_{0,a}=-7,914.149298\mbox{ kJ/kmol}$$$$\bar h_{0,w}=-0.01102303806\mbox{ kJ/kmol}$$respectively. The enthalpy per kg of dry air is given by
$$h=\bar h\frac{1+W}{M_{ha}}$$The enhancement factor is a parameter that includes the impact of the air on the saturation pressure of water vapor. It is only a function of temperature and pressure, but it must be iteratively obtained due to the nature of the expression for the enhancement factor.
$\psi_{w,s}$ is given by $\psi_{w,s}=fp_{w,s}/p$, where $f$ can be obtained from
$$\ln(f)=\left[ \begin{array}{l}\left [ \dfrac{(1+k_Tp_{w,s})(p-p_{w,s})-k_T\dfrac{(p^2-p_{w,s}^2)}{2}}{\overline {R} T}\right] \bar v_{w,s}+\ln[1-\beta_H(1-\psi_{w,s})p]\\ +\left[\dfrac{(1-\psi_{w,s})^2p}{\bar R T}\right] B_{aa}-2\left[\dfrac{(1-\psi_{w,s})^2p}{\bar R T}\right]B_{aw}-\left[\dfrac{(p-p_{w,s}-(1-\psi_{w,s})^2p)}{\bar R T}\right]B_{ww} \\ +\left[\dfrac{(1-\psi_{w,s})^3 p^2}{(\bar R T)^2}\right] C_{aaa}+\left[\dfrac{3(1-\psi_{w,s})^2[1-2(1-\psi_{w,s})]p^2}{2(\bar R T)^2}\right]C_{aaw}\\ -\left[\dfrac{3(1-\psi_{w,s})^2\psi_{w,s}p^2}{(\bar R T)^2}\right]C_{aww}-\left[\dfrac{(3-2\psi_{w,s})\psi_{w,s}^2p^2-p_{w,s}^2}{2(\bar R T)^2}\right]C_{www}\\ -\left[\dfrac{(1-\psi_{w,s})^2(-2+3\psi_{w,s})\psi_{w,s}p^2}{(\bar R T)^2}\right]B_{aa}B_{ww}\\ -\left[\dfrac{2(1-\psi_{w,s})^3(-1+3\psi_{w,s})p^2}{(\bar R T)^2}\right]B_{aa}B_{aw}\\ +\left[\dfrac{6(1-\psi_{w,s})^2\psi_{w,s}^2p^2}{(\bar R T)^2}\right]B_{ww}B_{aw}-\left[\dfrac{3(1-\psi_{w,s})^4p^2}{2(\bar R T)^2}\right]B_{aa}^2\\ -\left[\dfrac{2(1-\psi_{w,s})^2\psi_{w,s}(-2+3\psi_{w,s})p^2}{(\bar R T)^2}\right]B_{aw}^2-\left[\dfrac{p_{w,s}^2-(4-3\psi_{w,s})(\psi_{w,s})^3p^2}{2(\bar R T)^2}\right]B_{ww}^2 \end{array}\right]$$For water, the isothermal compressibility [in 1/Pa] is evaluated from
$$k_T=\frac{1}{\rho\frac{\partial p}{\partial \rho}}\frac{1\mbox{ kPa}}{1000\mbox{ Pa}}$$with $$\frac{\partial p}{\partial \rho}=RT\left[1+2\delta\left(\frac{\partial \alpha^r}{\partial \delta}\right)_{\tau}+\delta^2\left(\frac{\partial^2 \alpha^r}{\partial \delta^2}\right)_{\tau}\right]$$
in kPa/(kg/m$^3$). And for ice,
$$k_T=\left( \frac{\partial^2 g}{\partial p^2}\right) \left( \frac{\partial g}{\partial p}\right)_T^{-1}\frac{1\mbox{ kPa}}{1000\mbox{ Pa}}$$
In [1]:
#import the things you need
from CoolProp.HumidAirProp import HAProps, HAProps_Aux
In [2]:
# Enthalpy (kJ per kg dry air) as a function of temperature, pressure,
# and relative humidity at dry bulb temperature T of 25C, pressure
# P of one atmosphere, relative humidity R of 50%
h = HAProps('H','T',298.15,'P',101.325,'R',0.5); print h
In [3]:
# Temperature of saturated air at the previous enthalpy
T = HAProps('T','P',101.325,'H',h,'R',1.0); print T
In [4]:
# Temperature of saturated air - order of inputs doesn't matter
T = HAProps('T','H',h,'R',1.0,'P',101.325); print T
In [5]:
execfile('Validation/HAValidation.py')
In [5]: