Change Flow Direction
In the Simple Gas Model tutorial, you created a simple open-loop gas model, which
you then modified in the Change Flow Boundary Conditions tutorial. This
example shows how to further modify this model, to investigate how the change in the gas
flow direction affects the upstream temperature. To open the completed model, in the
MATLAB® Command Window, type
To investigate the change in the flow direction on the upstream temperature:
Replace the Mass Flow Rate Source (G) block with a Controlled Mass Flow Rate Source (G) block, with the Power added parameter also set to
Add a PS Sine Wave block and connect it to the input port of the Controlled Mass Flow Rate Source (G) block.
Set the Amplitude parameter of the PS Sine Wave block to
0.15 kg/sand Frequency specification to
Simulate the model. The mass flow rate through the restriction is now a sinusoidal wave with an amplitude of 0.15 kg/s.
Because the pressure on the right side of the restriction is fixed at atmospheric (as specified by the Downstream Reservoir block), the left side pressure (measured by the sensor) goes up and down, in order to produce the sinusoidal mass flow rate.
The temperature measured by the sensor switches between 400 K and 293 K. This is because the sensor measures the temperature of the gas just upstream of the measured node. Therefore, when the mass flow rate is positive, the upstream temperature is 400 K (as specified by the Upstream Reservoir block). When the mass flow rate is negative, the upstream temperature is 293 K (as specified by the Downstream Reservoir block), because even though the local restriction does change the temperature of the gas flowing through it, in this model the change is minimal.
As you can see, the switching between 400 K and 293 K is smoothed. This improves the simulation speed and robustness for flow reversal, that is, when the flow changes direction. The smoothing is controlled by the Mach number threshold for flow reversal parameter in the Gas Properties (G) block. Change this parameter value from
0.001and rerun the simulation.
The temperature now switches between 400 K and 293 K more sharply. Reducing the value of the Mach number threshold for flow reversal parameter can improve accuracy of the results, but may cause difficulties for the solver in a larger model, with large temperature variations and fast flow reversals.
Change the Mach number threshold for flow reversal parameter back to the default value of
0.01, which provides sufficient accuracy for this model.
Because the temperature at a node represents the temperature of the gas just upstream of that node, other thermodynamic properties that depend on temperature also represent the gas just upstream of the node. For example, if you use the Thermodynamic Properties Sensor (G) block to measure gas density, the density value also goes up and down as the flow reverses, similar to the temperature plot.