.Modelica.Media.UsersGuide.MediumUsage.TwoPhase

Information

Models for media which can exist in one-phase or two-phase conditions inherit from Modelica.Media.Interfaces.PartialTwoPhaseMedium (which inherits from PartialMedium). The basic usage of these media models is the same as described in the previous sections. However, additional functionalities are provided, which apply only to potentially two-phase media.

The following additional medium constants are provided:

Type Name Description
Boolean smoothModel If this flag is false (default value), then events are triggered whenever the saturation boundary is crossed; otherwise, no events are generated.
Boolean onePhase If this flag is true, then the medium model assumes it will be never called in the two-phase region. This can be useful to speed up the computations in a two-phase medium, when the user is sure it will always work in the one-phase region. Default value: false.

The setState_ph(), setState_ps(), setState_dT() and setState_pT() functions have one extra input, named phase. If the phase input is not specified, or if it is given a value of zero, then the setState function will determine the phase, based on the other input values. An input phase = 1 will force the setState function to return a state vector corresponding to a one-phase state, while phase = 2 will force the setState value to return a state vector corresponding to a two-phase state, as shown in the following example;

  replaceable package Medium = Modelica.Media.Interfaces.PartialTwoPhaseMedium;
  Medium.ThermodynamicState state, state1, state2;
equation
  // Set the state, given the pressure and the specific enthalpy
  // the phase is determined by the (p, h) values, and can be retrieved
  // from the state record
  state = Medium.setState_ph(p, h);
  phase = state1.phase;

  // Force the computation of the state with one-phase
  // equations of state, irrespective of the (p, h) values
  state1 = Medium.setState_ph(p, h, 1);

  // Force the computation of the state with 2-phase
  // equations of state, irrespective of the (p, h) values
  state2 = Medium.setState_ph(p, h, 2);

This feature can be used for the following purposes:

Many additional optional functions are defined to compute properties of saturated media, either liquid (bubble point) or vapour (dew point). The argument to such functions is a SaturationProperties record, which can be set starting from either the saturation pressure or the saturation temperature, as shown in the following example.

  replaceable package Medium = Modelica.Media.Interfaces.PartialTwoPhaseMedium;
  Medium.SaturationProperties sat_p;
  Medium.SaturationProperties sat_T;
equation
  // Set sat_p to saturation properties at pressure p
  sat_p = Medium.setSat_p(p);

  // Compute saturation properties at pressure p
  saturationTemperature_p = Medium.saturationTemperature_sat(sat_p);
  bubble_density_p =        Medium.bubbleDensity(sat_p);
  dew_enthalpy_p   =        Medium.dewEnthalpy(sat_p);

  // Set sat_T to saturation properties at temperature T
  sat_T = Medium.setSat_T(T);

  // Compute saturation properties at temperature T
  saturationTemperature_T = Medium.saturationPressure_sat(sat_T);
  bubble_density_T =        Medium.bubbleDensity(sat_T);
  dew_enthalpy_T =          Medium.dewEnthalpy(sat_T);

With reference to a model defining a pressure p, a temperature T, and a SaturationProperties record sat, the following functions are provided:

Function call Unit Description
Medium.saturationPressure(T) Pa Saturation pressure at temperature T
Medium.saturationTemperature(p) K Saturation temperature at pressure p
Medium.saturationTemperature_derp(p) K/Pa Derivative of saturation temperature with respect to pressure
Medium.saturationTemperature_sat(sat) K Saturation temperature
Medium.saturationPressure_sat(sat) Pa Saturation pressure
Medium.bubbleEnthalpy(sat) J/kg Specific enthalpy at bubble point
Medium.dewEnthalpy(sat) J/kg Specific enthalpy at dew point
Medium.bubbleEntropy(sat) J/(kg.K) Specific entropy at bubble point
Medium.dewEntropy(sat) J/(kg.K) Specific entropy at dew point
Medium.bubbleDensity(sat) kg/m3 Density at bubble point
Medium.dewDensity(sat) kg/m3 Density at dew point
Medium.saturationTemperature_derp_sat(sat) K/Pa Derivative of saturation temperature with respect to pressure
Medium.dBubbleDensity_dPressure(sat) kg/(m3.Pa) Derivative of density at bubble point with respect to pressure
Medium.dDewDensity_dPressure(sat) kg/(m3.Pa) Derivative of density at dew point with respect to pressure
Medium.dBubbleEnthalpy_dPressure(sat) J/(kg.Pa) Derivative of specific enthalpy at bubble point with respect to pressure
Medium.dDewEnthalpy_dPressure(sat) J/(kg.Pa) Derivative of specific enthalpy at dew point with respect to pressure
Medium.surfaceTension(sat) N/m Surface tension between liquid and vapour phase

Sometimes it can be necessary to compute fluid properties in the thermodynamic plane, just inside or outside the saturation dome. In this case, it is possible to obtain an instance of a ThermodynamicState state vector, and then use it to call the additional functions already defined for one-phase media.

Function call Description
Medium.setBubbleState(sat, phase) Obtain the thermodynamic state vector corresponding to the bubble point. If phase==1 (default), the state is on the one-phase side; if phase==2, the state is on the two-phase side
Medium.setDewState(sat, phase) Obtain the thermodynamic state vector corresponding to the dew point. If phase==1 (default), the state is on the one-phase side; if phase==2, the state is on the two-phase side

Here are some examples:

  replaceable package Medium = Modelica.Media.Interfaces.PartialTwoPhaseMedium;
  Medium.SaturationProperties sat;
  Medium.ThermodynamicState   dew_1;    // dew point, one-phase side
  Medium.ThermodynamicState   bubble_2; // bubble point, two phase side
equation
  // Set sat to saturation properties at pressure p
  sat = setSat_p(p);

  // Compute dew point properties, (default) one-phase side
  dew_1 = setDewState(sat);
  cpDew = Medium.specificHeatCapacityCp(dew_1);
  drho_dp_h_1 = Medium.density_derp_h(dew_1);

  // Compute bubble point properties, two-phase side
  bubble_2    = setBubbleState(sat, 2);
  drho_dp_h_2 = Medium.density_derp_h(bubble_2);

Generated at 2024-11-26T19:26:15Z by OpenModelicaOpenModelica 1.24.2 using GenerateDoc.mos