modeling gas systems
intended applications
the gas library contains basic elements, such as orifices, chambers, and pneumatic-mechanical converters, as well as sensors and sources. use these blocks to model gas systems, for applications such as:
pneumatic actuation of mechanical systems
natural gas transport through pipe networks
gas turbines for power generation
air cooling of thermal components
you specify the gas properties in the connected loop by using the gas properties (g) block. this block lets you choose between three idealization levels: perfect gas, semiperfect gas, or real gas (see gas property models).
unless explicitly stated otherwise, all pressures and temperatures used in modeling gas systems are static pressure and static temperature.
network variables
the across variables are pressure and temperature, and the through variables are mass flow rate and energy flow rate. note that these choices result in a pseudo-bond graph, because the product of pressure and mass flow rate is not power.
gas property models
the gas library supports perfect gas, semiperfect gas, and real gas within the same gas domain in order to cover a wide range of modeling requirements. the three gas property models provide trade-offs between simulation speed and accuracy. they also enable the incremental workflow: you start with a simple model, which requires minimal information about the working gas, and then build upon the model when more detailed gas property data becomes available.
you select the gas property model by using the gas properties (g) block, which specifies the gas properties in the connected circuit.
the following table summarizes the different assumptions for each gas property model.
thermal equation of state indicates the relationship of density with temperature and pressure.
caloric equation of state indicates the relationship of specific heat capacity with temperature and pressure.
transport properties indicate the relationship between dynamic viscosity and thermal conductivity with temperature and pressure.
gas property model | thermal equation of state | caloric equation of state | transport properties |
---|---|---|---|
perfect | ideal gas law | constant | constant |
semiperfect | ideal gas law | 1-d table lookup by temperature | 1-d table lookup by temperature |
real | 2-d table lookup by temperature and pressure | 2-d table lookup by temperature and pressure | 2-d table lookup by temperature and pressure |
the ideal gas law is implemented in the simscape™ foundation gas library as
p = zρrt
where:
p is the pressure.
z is the compressibility factor.
r is the specific gas constant.
t is the temperature.
the compressibility factor, z, is typically a function of pressure and temperature. it accounts for the deviation from ideal gas behavior. the gas is ideal when z = 1. in the perfect and semiperfect gas property models, z must be constant but it does not have to be equal to 1. for example, if you are modeling a nonideal gas (z ≠ 1) but the temperature and pressure of the system do not vary significantly, you can use the perfect gas model and specify an appropriate value of z. the following table lists the compressibility factor z for various gases at 293.15 k and 0.101325 mpa:
gas | compressibility factor |
---|---|
dry air | 0.99962 |
carbon dioxide | 0.99467 |
oxygen | 0.99930 |
hydrogen | 1.00060 |
helium | 1.00049 |
methane | 0.99814 |
natural gas | 0.99797 |
ammonia | 0.98871 |
r-134a | 0.97814 |
using the perfect gas model, with the constant value of z adjusted based on the type of gas and the operating conditions, lets you avoid the additional complexity and computational cost of moving to the semiperfect or real gas property model.
the perfect gas property model is a good starting choice when modeling a gas network because it is simple, computationally efficient, and requires limited information about the working gas. it is correct for monatomic gases and, typically, it is sufficiently accurate for gases such as dry air, carbon dioxide, oxygen, hydrogen, helium, methane, natural gas, and so on, at standard conditions.
when the gas network is operating near the saturation boundary or is operating over a very wide temperature range, the working gas can exhibit mild nonideal behavior. in this case, after successfully simulating the gas network with the perfect gas property model, consider switching to the semiperfect gas property model.
finally, consider switching to the real gas property model if the working gas is expected to exhibit strongly nonideal behavior, such as heavy gases with large molecules. this model is the most expensive in terms of computational cost and requires detailed information about the working gas, because it uses 2-d interpolation for all properties.
blocks with gas volume
components in the gas domain are modeled using control volumes. the control volume encompasses the gas inside the component and separates it from the surrounding environment and other components. gas flows and heat flows across the control surface are represented by ports. the gas volume inside the component is represented using an internal node, which provides the gas pressure and temperature inside the component. this internal node is not visible, but you can access its parameters and variables using simscape data logging. for more information, see .
the following blocks in the gas library are modeled as components with a gas volume. in the case of controlled reservoir (g) and reservoir (g), the volume is assumed to be infinitely large.
block | gas volume |
---|---|
constant volume chamber (g) | finite |
pipe (g) | finite |
rotational mechanical converter (g) | finite |
translational mechanical converter (g) | finite |
reservoir (g) | infinite |
controlled reservoir (g) | infinite |
other components have relatively small gas volumes, so that gas 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, gas networks have different grounding rules.
blocks with a gas volume contain an internal node, which provides the gas pressure and temperature inside the component and therefore serves as a reference node for the gas network. each connected gas network must have at least one reference node. this means that each connected gas network must have at least one of the blocks listed in blocks with gas volume. in other words, a gas network that contains no gas volume is an invalid gas network.
the foundation gas library contains the absolute reference (g) block but, unlike other domains, you do not use it for grounding gas circuits. the purpose of the absolute reference (g) block is to provide a reference for the pressure & temperature sensor (g). however, starting in r2023a, the pressure & temperature sensor (g) block contains an implicit reference node, which makes using the absolute reference (g) block with the pressure & temperature sensor (g) block unnecessary. if you use the absolute reference (g) block elsewhere in a gas network, it will trigger a simulation assertion because gas pressure and temperature cannot be at absolute zero.
initial conditions for blocks with finite gas volume
this section discusses the specific initialization requirements for blocks modeled with finite gas volume. these blocks are listed in blocks with gas volume.
the state of the gas volume evolves dynamically based on interactions with connected blocks via mass and energy flows. the time constants depend on the compressibility and thermal capacity of the gas volume.
the state of the gas volume is represented by differential variables at the internal node of the block. as differential variables, they require initial conditions to be specified prior to the start of simulation. the dialog box of each block modeled with finite gas volume has an initial targets section, which lists three variables:
pressure of gas volume
temperature of gas volume
density of gas volume
by default, pressure of gas volume and temperature
of gas volume have high priority, with target values equal to the
standard condition (0.101325 mpa
and 293.15
k
). you can adjust the target values to represent the appropriate initial
state of the gas volume for the block. density of gas volume
has the default priority none
because only the initial conditions
of two of the three variables are needed to completely determine the initial state
of the gas volume. if desired, an alternative way to specify the initial conditions
is to change density of gas volume to high priority with an
appropriate target value, and then change either pressure of gas
volume or temperature of gas volume to a
priority of none.
it is important that only two of the three variables have their priorities set to
high
for each block with a finite gas volume. placing
high-priority constraints on all three variables results in over-specification, with
the solver unable to find an initialization solution that satisfies the desired
initial values. conversely, placing high-priority constraint only on one variable
makes the system under-specified, and the solver might resolve the variables with
arbitrary and unexpected initial values. for more information on variable
initialization and dealing with over-specification, see .
in blocks that are modeled with an infinitely large gas volume, the state of the gas volume is assumed quasisteady and there is no need to specify an initial condition.
choked flow
gas flow through local restriction (g), variable local restriction (g), or pipe (g) 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 gas increases. this can be achieved, for example, by increasing the pressure upstream of the point of choking. the effect of choking on a gas 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 (g)
block increases linearly from atmospheric pressure, starting at 10 s. the pressure
at port b is fixed at atmospheric pressure.
the following illustration shows the logged simulation data for the local restriction (g) block. the mach number at the restriction (mach_r) 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 (g) or a controlled mass flow rate source (g) connected downstream of the choked block. consider the model shown in the next illustration, which contains the controlled mass flow rate source (g) block instead of the controlled pressure source (g).
if the source commanded an increasing mass flow rate from left to right through the local restriction (g), the simulation would succeed even if the flow became choked because the controlled mass flow rate source (g) 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 (g) is downstream of the choked block. the pressure upstream of the local restriction (g) 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 simulation fails, use the simscape results explorer to inspect the mach number variables in all local restriction (g), variable local restriction (g), and pipe (g) 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.
the mach number variable for the restriction blocks is called mach_r. the pipe (g) block has two mach number variables, mach_a and mach_b, representing the mach number at port a and port b, respectively.
flow reversal
the flow of gas through the circuit carries energy from one gas volume to another gas volume. therefore, the energy flow rate between two connected blocks depends on the direction of flow. if the gas flows from block a to block b, then the energy flow rate between the two blocks is based on the specific total enthalpy of block a. conversely, if the gas flows from block b to block a, then the energy flow rate between the two blocks is based on the specific total enthalpy of block b. to smooth the transition for simulation robustness, the energy flow rate also includes a contribution based on the difference in the specific total enthalpies of the two blocks at low mass flow rates. the smoothing region is controlled by the gas properties (g) block parameter mach number threshold for flow reversal.
a consequence of this approach is that the temperature of a node between two connected blocks represents the temperature of the gas volume upstream of that node. if there are two or more upstream flow paths merging at the node, then the temperature at the node represents the weighted average temperature based on the ideal mixing of the merging gas flows.
simulation robustness can be challenging for models that exhibit quick flow reversals and large temperature differences between blocks. quick flow reversals may be a result of having low flow resistances (for example, short pipes) between large gas volumes. large temperature differences may be a result of the energy added by sources to maintain large pressure differences in a model with little heat dissipation. in these models, it may be necessary to increase the mach number threshold for flow reversal parameter value to avoid simulation failure.
cross-sectional area at block ports
many blocks in the gas domain let you specify the cross-sectional area at the inlet and outlet ports as a block parameter. it is recommended that you specify the same cross-sectional area for ports that are connected together. for example, if you have port a of a constant volume chamber (g) block connected to a pipe (g) block, set the cross-sectional area at port a parameter of the constant volume chamber (g) block to the same value as the cross-sectional area parameter of the pipe (g) block.
especially for high-speed flows, where mach number is close to 1, differences in the connected port areas can result in unexpected temperature differences. for more information, see .