## Modeling Moist Air Systems

### Intended Applications

The Moist Air library contains basic elements, such as reservoirs, chambers, and pneumatic-mechanical converters, as well as sensors and sources. Use these blocks to model HVAC systems, environmental control systems, and other similar applications.

Relevant industries include automotive, aerospace, building. The key aspect of these applications is the need to keep track of humidity levels in different parts of the model over time. The moist air domain is a two-species gas domain, where the species are air and water vapor. Furthermore, the water vapor can condense out of the system. This effect is important to HVAC applications because latent heat of water condensation affects the thermodynamics of the fluid flow.

The moist air mixture is composed of dry air and water vapor. Trace gas is an optional third species in the moist air mixture. Example of the trace gas usage is to track carbon dioxide and pollutants such as nitrogen oxides (NOx). You specify the moist air properties in the connected loop by using the Moist Air Properties (MA) block. This block also gives you several options for modeling trace gas properties. You increase and decrease levels of moisture and trace gas in the air mixture by using the blocks in the Moisture & Trace Gas Sources library (see Modeling Moisture and Trace Gas Levels).

All gas species in the mixture are assumed to be semiperfect gas. This means that pressure, temperature, and density obey the ideal gas law. Other properties―specific enthalpy, specific heat, dynamic viscosity, and thermal conductivity―are functions of temperature only.

Unless explicitly stated otherwise, all pressures and temperatures used in modeling moist air systems are static pressure and static temperature.

Use the Moist Air domain and library to perform the following tasks:

• Develop requirements of an HVAC system for an environment, such as a building, automobile, or aircraft

• Ensure acceptable temperature, pressure, humidity, and condensation within the environment

• Determine capacity of an HVAC system to match heating, cooling, and dehumidification requirements

• Analyze HVAC system performance, efficiency, and cost

• Validate HVAC system model against test data

• Design and simulate HVAC components and tune component models to test rig data

• Simulate models including an HVAC system, environment model, and controller

• Design controllers for valves, fans, and compressors to ensure safe and optimal operation

• Perform HIL testing

### Network Variables for Moist Air Domain

The Across variables are pressure, temperature, specific humidity (water vapor mass fraction), and trace gas mass fraction. The Through variables are mixture mass flow rate, mixture energy flow rate, water vapor mass flow rate, and trace gas mass flow rate. Note that these choices result in a pseudo-bond graph, because the product of Across and Through variables is not power.

There is a separate domain for modeling moisture and trace gas levels in moist air systems. For more information, see Moist Air Source Domain.

### Moist Air Properties

The default fluid properties for the moist air library correspond to dry air, water vapor, and carbon dioxide (the optional trace gas). However, you can modify the fluid properties in the Moist Air Properties (MA) block to model mixtures of other gases and vapors. You can replace dry air and carbon dioxide with other gas species. You can also change water vapor to another condensing vapor (or even to another noncondensing gas species, by supplying large enough values for the saturation pressure, so that it would never reach saturation during simulation). In this way, you can model any three-species gas mixture.

All gas species in the mixture are assumed to be semiperfect gas. This means that pressure p, temperature T, and density ρ of the constituents obey the ideal gas law:

`$\begin{array}{l}{p}_{a}={\rho }_{a}{R}_{a}T,\\ {p}_{w}={\rho }_{w}{R}_{w}T,\\ {p}_{g}={\rho }_{g}{R}_{g}T,\end{array}$`

where R is the specific gas constant. Subscripts a, w, and g indicate dry air, water vapor, and trace gas, respectively.

Dalton’s law applies to ideal gases:

`$p={p}_{a}+{p}_{w}+{p}_{g}.$`

Therefore, the mixture also obeys the ideal gas law:

`$p=\rho RT,$`

where:

`$\begin{array}{l}\rho ={\rho }_{a}+{\rho }_{w}+{\rho }_{g},\\ R={x}_{a}{R}_{a}+{x}_{w}{R}_{w}+{x}_{g}{R}_{g}.\end{array}$`

xa, xw, and xg are mass fractions of dry air, water vapor, and trace gas, respectively.

Other properties of each constituent are assumed to be functions of temperature only:

• ha(T), hw(T), hg(T) ― Specific enthalpy of dry air, water vapor, and trace gas, respectively.

• μa(T), μw(T), μg(T) ― Dynamic viscosity of dry air, water vapor, and trace gas, respectively.

• ka(T), kw(T), kg(T) ― Thermal conductivity of dry air, water vapor, and trace gas, respectively.

For ideal gases, the enthalpy of mixing is zero. Therefore, the mixture specific enthalpy is a combination of the constituent specific enthalpy based on their mass fractions:

`$h={x}_{a}{h}_{a}\left(T\right)+{x}_{w}{h}_{w}\left(T\right)+{x}_{g}{h}_{g}\left(T\right).$`

You can compute the entropy of mixing from the mole fractions:

`$\Delta {s}^{mix}=-{x}_{a}{R}_{a}\mathrm{ln}\left({y}_{a}\right)+{x}_{w}{R}_{w}\mathrm{ln}\left({y}_{w}\right)+{x}_{g}{R}_{g}\mathrm{ln}\left({y}_{g}\right),$`

where ya, yw, and yg are mole fractions of dry air, water vapor, and trace gas, respectively.

Therefore, the mixture specific entropy is

`$s={x}_{a}{s}_{a}+{x}_{w}{s}_{w}+{x}_{g}{s}_{g}+\Delta {s}^{mix}.$`

### Humidity and Trace Gas Property Definitions

The equations describing humidity and trace gas properties use these symbols and property definitions. Subscripts `a`, `w`, and `g` indicate the properties of dry air, water vapor, and trace gas, respectively. Subscript `ws` indicates water vapor at saturation.

SymbolPropertyDefinition
pPressurePressure of the moist air mixture (as opposed to the partial pressure of water vapor or partial pressure of trace gas).
TTemperatureThe dry-bulb temperature, which is the temperature in the common thermodynamic sense. (The wet-bulb temperature is a different quantity, which measures the moisture level.)
RSpecific gas constant

Universal gas constant divided by the molar mass of the species. Specific gas constant of the mixture is

`$R={x}_{a}{R}_{a}+{x}_{w}{R}_{w}+{x}_{g}{R}_{g}.$`
φwRelative humidity

Moles of water vapor as a fraction of the moles of water vapor needed to saturate at the same temperature. Water vapor saturation pressure is a property of water and is a function of temperature only, pws(T). The ideal gas law (due to the assumed semiperfect gas) means that mole fraction is equivalent to partial pressure fraction. The mole fraction yw cannot be greater than 1. Therefore, at high temperature or low pressure, it may not be possible to achieve relative humidity of 1.

`${\phi }_{w}={\frac{{y}_{w}}{{y}_{ws}}|}_{T}=\frac{{y}_{w}p}{{p}_{ws}\left(T\right)}$`
xwSpecific humidity

Mass of water vapor as a fraction of the total mass of the moist air mixture. It is another term for water vapor mass fraction. It may not be possible to achieve specific humidity of 1 due to saturation.

`${x}_{w}=\frac{{M}_{w}}{M}=\frac{{\stackrel{˙}{m}}_{w}}{\stackrel{˙}{m}}$`
ywWater vapor mole fraction

Moles of water vapor as a fraction of the total moles of the moist air mixture. It may not be possible to achieve water vapor mole fraction of 1 due to saturation.

`${y}_{w}=\frac{{N}_{w}}{N}=\frac{{p}_{w}}{p}$`
rwHumidity ratio

Ratio of mass of water vapor to mass of dry air and trace gas. For conditions in typical HVAC applications, it is close to the specific humidity.

`${r}_{w}=\frac{{M}_{w}}{{M}_{a}+{M}_{g}}$`
ρwAbsolute humidity

Mass of water vapor over the volume of the moist air mixture. It is another term for water vapor density.

`${\rho }_{w}=\frac{{M}_{w}}{V}$`
xgTrace gas mass fraction

Mass of trace gas as a fraction of the total mass of the moist air mixture.

`${x}_{g}=\frac{{M}_{g}}{M}=\frac{{\stackrel{˙}{m}}_{g}}{\stackrel{˙}{m}}$`
ygTrace gas mole fraction

Moles of trace gas as a fraction of the total moles of the moist air mixture.

`${y}_{g}=\frac{{N}_{g}}{N}=\frac{{p}_{g}}{p}$`

Water vapor mole fraction is related to specific humidity (that is, to mass fraction) as follows:

`${y}_{w}=\frac{{R}_{w}}{R}{x}_{w}.$`

Trace gas mole fraction is related to trace gas mass fraction as follows:

`${y}_{g}=\frac{{R}_{g}}{R}{x}_{g}.$`

### Blocks with Moist Air Volume

Components in the moist air domain are modeled using control volumes. A control volume encompasses the moist air inside the component and separates it from the surrounding environment and other components. Air flows and heat flows across the control surface are represented by ports. The moist air volume inside the component is represented using an internal node. This internal node is not visible, but you can access its parameters and variables using Simscape™ data logging. For more information, see About Simulation Data Logging.

For a moist air volume, you must specify the pressure, temperature, moisture level, and trace gas level. For more information, see Initial Conditions for Blocks with Finite Moist Air Volume.

The following blocks in the Moist Air library are modeled as components with a moist air volume. In the case of Controlled Reservoir (MA) and Reservoir (MA) blocks, the volume is assumed to be infinitely large.

BlockGas Volume
Constant Volume Chamber (MA)Finite
Pipe (MA)Finite
Rotational Mechanical Converter (MA)Finite
Translational Mechanical Converter (MA)Finite
Reservoir (MA)Infinite
Controlled Reservoir (MA)Infinite

Other components have relatively small moist air volumes, so that the air mixture entering the component spends negligible time inside the component before exiting. These components are considered quasi-steady-state and they do not have an internal node.

### Reference Node and Grounding Rules

Unlike mechanical and electrical domains, where each topologically distinct circuit within a domain must contain at least one reference block, moist air networks have different grounding rules.

Blocks with a moist air volume contain an internal node, which provides the pressure, temperature, moisture level, and trace gas level inside the component and therefore serves as a reference node for the moist air network. Each connected moist air network must have at least one reference node. This means that each connected moist air network must have at least one of the blocks listed in Blocks with Moist Air Volume. In other words, a moist air network that contains no air volume is an invalid network.

The Foundation Moist Air library contains the Absolute Reference (MA) block but, unlike other domains, you do not use it for grounding moist air circuits. The purpose of the Absolute Reference (MA) block is to provide a reference for the Pressure & Temperature Sensor (MA) block. If you use the Absolute Reference (MA) block elsewhere in a moist air network, it triggers a simulation assertion because air mixture pressure and temperature cannot be at absolute zero.

### Initial Conditions for Blocks with Finite Moist Air Volume

This section discusses the specific initialization requirements for blocks modeled with finite moist air volume. These blocks are listed in Blocks with Moist Air Volume.

The fluid states of a moist air volume are pressure, temperature, moisture level, and trace gas level. These fluid states evolve dynamically based on the mixture mass conservation, water vapor mass conservation, trace gas mass conservation, and mixture energy conservation. Therefore, it is necessary to specify initial conditions for these blocks, to define the initial fluid states. The dialog box of each block modeled with finite moist air volume has an Initial Targets section, which lets you specify the initial conditions. To ensure consistent initial conditions, specify high priority targets for four variables:

• Pressure of moist air volume

• Temperature of moist air volume

• One of the variables representing the moisture level:

• Relative humidity of moist air volume

• Specific humidity of moist air volume

• Water vapor mole fraction of moist air volume

• Humidity ratio of moist air volume

• One of the variables representing the trace gas level:

• Trace gas mass fraction of moist air volume

• Trace gas mole fraction of moist air volume

It is important that only four variables, as described, have their priorities set to `High` for each block with a finite moist air volume. Placing high-priority constraints on additional variables results in overspecification, with the solver being unable to find an initialization solution that satisfies the desired initial values. Set the priority of remaining variables to `None`. You can use the equations in Humidity and Trace Gas Property Definitions and Trace Gas Modeling Options to convert values from one moisture or trace gas measure to another. For more information on variable initialization and dealing with overspecification, see Initialize Variables for a Mass-Spring-Damper System.

The fluid states of moist air volume in these blocks are reported by the physical signal output port F. Connect port F to the Measurement Selector (MA) block to extract the measurements of pressure, temperature, moisture level, and trace gas level during simulation.

In blocks that are modeled with an infinitely large moist air volume, the state of the volume is assumed quasisteady and there is no need to specify an initial condition. Instead, these blocks represent boundary conditions for the moist air network.

### Saturation and Condensation

Blocks with finite moist air volume (listed in Blocks with Moist Air Volume) can become saturated when the relative humidity φw reaches the relative humidity at saturation φws. The saturated state represents the maximum amount of moisture that the moist air volume can hold at that pressure and temperature. Any additional moisture condenses into liquid water.

By definition, the relative humidity at saturation is 1. However, you can specify a different value for φws to model some empirical effect or other phenomenon. When φws > 1, water vapor partial pressure can become greater than the water vapor saturation pressure. When φws < 1, moisture can condense before the water vapor partial pressure reaches the water vapor saturation pressure.

Condensation does not occur instantaneously. Consequently, it is possible for φw to be slightly greater than φws. The condensation time constant represents the characteristic time it takes to condense out enough moisture to bring φw back to φws. A larger value of the time constant causes φw to exceed φws to a greater degree, but is more numerically robust.

Moisture that condenses is considered to have left the moist air network, therefore, the mass and energy of condensed liquid water is subtracted from the moist air volume. The rate of condensation is reported by the physical signal output port W. If you want to model the flow of the condensed liquid water, you can use the rate of condensation as an input for another fluid network (hydraulic, thermal liquid, two-phase fluid, or another moist air network). The following example shows how to use the thermal liquid network to model the condensate that drains from a Constant Volume Chamber (MA) through a pipe.

If you have a Simscape Fluids™ license, you can also use the Tank (TL) block to model a condensation collection tray. The liquid level in the tank represents the amount of condensation collected but not yet drained from the tank.

### Choked Flow

Moist air flow through Local Restriction (MA), Variable Local Restriction (MA), or Pipe (MA) blocks can become choked. Choking occurs when the flow velocity reaches the local speed of sound. When the flow is choked, the velocity at the point of choking cannot increase any further. However, the mass flow rate can still increase if the density of the air mixture increases. This can be achieved, for example, by increasing the pressure upstream of the point of choking. The effect of choking on a moist air network is that the mass flow rate through the branch containing the choked block depends completely on the upstream pressure and temperature. As long as the choking condition is maintained, this choked mass flow rate is independent of any changes occurring in the pressure downstream.

The following model illustrates the choked flow. In this model, the Ramp block has a slope of 0.005 and the start time of 10. The Simulink-PS Converter block has Input signal unit set to `MPa`. All other blocks have default parameter values. Simulation time is 50 s. When you simulate the model, the pressure at port A of the Local Restriction (MA) block increases linearly from atmospheric pressure, starting at 10 s. The pressure at port B is fixed at atmospheric pressure.

The following two plots show the logged simulation data for the Local Restriction (MA) block. The Mach number at the restriction (Mach) reaches 1 at around 20 s, indicating that the flow is choked. The mass flow rate (mdot_A) before the flow is choked follows the typical quadratic behavior with respect to an increasing pressure difference. However, the mass flow rate after the flow is choked becomes linear because the choked mass flow rate depends only on the upstream pressure and temperature, and the upstream pressure is increasing linearly.

The fact that the choked mass flow rate depends only on the upstream conditions can cause an incompatibility with a Mass Flow Rate Source (MA) or a Controlled Mass Flow Rate Source (MA) block connected downstream of the choked block. Consider this model, which contains the Controlled Mass Flow Rate Source (MA) block instead of the Controlled Pressure Source (MA) block.

If the source commanded an increasing mass flow rate from left to right through the Local Restriction (MA) block, the simulation would succeed even if the flow became choked because the Controlled Mass Flow Rate Source (MA) block would be upstream of the choked block. However, in this model, the Gain block reverses the flow direction, so that the Controlled Mass Flow Rate Source (MA) block is downstream of the choked block. The pressure upstream of the Local Restriction (MA) block is fixed at atmospheric pressure. Therefore, the choked mass flow rate in this situation is constant. As the commanded mass flow rate increases, eventually it will become greater than this constant value of choked mass flow rate. At this point, the commanded mass flow rate and the choked mass flow rate cannot be reconciled and the simulation fails. Viewing the logged simulation data in the Simscape Results Explorer shows that simulation fails just at the point when the Mach number reaches 1 and the flow becomes choked.

In general, if a model is likely to choke, use pressure sources rather than mass flow rate sources. If a model contains mass flow rate source blocks and the simulation fails, use the Simscape Results Explorer to inspect the Mach number variables in all Local Restriction (MA), Variable Local Restriction (MA), and Pipe (MA) blocks connected along the same branch as the mass flow rate source. If the simulation failure occurs when the Mach number reaches 1, it is likely that there is a downstream mass flow rate source trying to command a mass flow rate greater than the possible choked mass flow rate.