## Two-Phase Fluid Domain

To view the complete domain source file, at the MATLAB® Command prompt, type:

`open([matlabroot '/toolbox/physmod/simscape/library/m/+foundation/+two_phase_fluid/two_phase_fluid.ssc'])`

Abbreviated two-phase fluid domain declaration is shown below, with intermediate lookup table values omitted for readability.

```domain two_phase_fluid % Two-Phase Fluid Domain % Copyright 2013-2018 The MathWorks, Inc. parameters p_min = {1e-3, 'MPa' }; % Minimum valid pressure p_max = {95, 'MPa' }; % Maximum valid pressure u_min = {0, 'kJ/kg'}; % Minimum valid specific internal energy u_max = {4000, 'kJ/kg'}; % Maximum valid specific internal energy p_crit = {22.0640, 'MPa' }; % Critical pressure p_atm = {0.101325, 'MPa' }; % Atmospheric pressure properties_range_check = simscape.enum.assert.action.error; % Pressure and specific internal energy outside valid range % 0 - none % 1 - warn % 2 - error q_rev = {0.01, 'Pa' }; % Dynamic pressure threshold for flow reversal transition_range = {0.1, '1'}; % Range in vapor quality for smoothing of density partial derivatives % Default fluid property tables for water % Rows of the tables correspond to the normalized internal energy vector % Columns of the tables correspond to the pressure vector unorm_TLU = {[ -1 -0.958333333333333 ... 1.95833333333333 2 ], '1'}; % Normalized internal energy vector unorm_liq_TLU = {[ -1 -0.958333333333333 ... -0.0416666666666666 0 ], '1'}; % Normalized liquid internal energy vector unorm_vap_TLU = {[ 1 1.04166666666667 ... 1.95833333333333 2 ], '1'}; % Normalized vapor internal energy vector unorm_mix_TLU = {[ 0 0.0204081632653061 ... 0.979591836734694 1 ], '1'}; % Normalized mixture internal energy vector p_TLU = {[ 0.00100000000000000 ... 95.0000000000000 ], 'MPa' }; % Pressure vector v_TLU = {[ 0.00100020732544948 ... 0.00646806895821810 ], 'm^3/kg'}; % Specific volume table s_TLU = {[ -7.05045840376749e-13 ... 6.81117017439253 ], 'kJ/kg/K'}; % Specific entropy table T_TLU = {[ 273.159998291077 ... 1348.81511704704 ], 'K'}; % Temperature table nu_TLU = {[ 1.79172848157620 ... 0.361552941837863 ], 'mm^2/s'}; % Kinematic viscosity table k_TLU = {[ 0.555598831086800 ... 0.250538481070411 ], 'W/(m*K)'}; % Thermal conductivity table Pr_TLU = {[ 13.6057970740934 ... 0.671580102714643 ], '1' }; % Prandtl number table DrhoDp_liq_TLU = {[ 0.509755264394891 ... 1.80807388692342 ], 'kg/m^3/MPa'}; % Partial derivative of liquid density with pressure % at constant specific internal energy table DrhoDp_vap_TLU = {[ 7.36831747174794 ... 1.45923555583730 ], 'kg/m^3/MPa'}; % Partial derivative of vapor density with pressure % at constant specific internal energy table DrhoDp_mix_TLU = {[ 1350.39031864440 ... 1.80807388692342 ], 'kg/m^3/MPa'}; % Partial derivative of mixture density with pressure % at constant specific internal energy table DrhoDu_liq_TLU = {[ 0.0160937306771423 ... -0.350392782066966 ], 'kg^2/m^3/kJ'}; % Partial derivative of liquid density with specific internal energy % at constant pressure table DrhoDu_vap_TLU = {[ -1.79894990819782e-05 ... -0.0610611856834271 ], 'kg^2/m^3/kJ'}; % Partial derivative of vapor density with specific internal energy % at constant pressure table DrhoDu_mix_TLU = {[ -0.0137995431136761 ... -0.350392782066966 ], 'kg^2/m^3/kJ'}; % Partial derivative of mixture density with specific internal energy % at constant pressure table u_sat_liq_TLU = {[ 29.2976389515495 ... 2242.74587564859 ], 'kJ/kg'}; % Saturated liquid specific internal energy vector u_sat_vap_TLU = {[ 2384.48887142334 ... 2242.74587564859 ], 'kJ/kg'}; % Saturated vapor specific internal energy vector end variables p = { 0.1, 'MPa' }; % Pressure u = { 1500, 'kJ/kg' }; % Specific internal energy end variables(Balancing = true) mdot = { 0, 'kg/s' }; % Mass flow rate Phi = { 0, 'kW' }; % Energy flow rate end end ```

The domain declaration contains the following variables and parameters:

• Across variable p (absolute pressure), in MPa

• Through variable mdot (mass flow rate), in kg/s

• Across variable u (specific internal energy), in kJ/kg

• Through variable Phi (energy flow rate), in kW

• Parameter p_min, defining the minimum allowable pressure

• Parameter p_max, defining the maximum allowable pressure

• Parameter u_min, defining the minimum allowable specific internal energy

• Parameter u_max, defining the maximum allowable specific internal energy

• Parameter p_crit, defining the critical pressure

• Parameter p_atm, defining the atmospheric pressure

• Parameter q_rev, defining the dynamic pressure threshold for flow reversal

It also contains lookup table data, declared as domain parameters, for the following fluid properties:

• Normalized internal energy vector

• Normalized liquid internal energy vector

• Normalized vapor internal energy vector

• Normalized mixture internal energy vector

• Pressure vector

• Specific volume table

• Specific entropy table

• Temperature table

• Kinematic viscosity table

• Thermal conductivity table

• Prandtl number table

• Partial derivative of liquid density with pressure at constant specific internal energy table

• Partial derivative of vapor density with pressure at constant specific internal energy table

• Partial derivative of mixture density with pressure at constant specific internal energy table

• Partial derivative of liquid density with specific internal energy at constant pressure table

• Partial derivative of vapor density with specific internal energy at constant pressure table

• Partial derivative of mixture density with specific internal energy at constant pressure table

• Saturated liquid specific internal energy vector

• Saturated vapor specific internal energy vector

These parameter declarations propagate to the components connected to the Two-Phase Fluid domain, and therefore you can use them in the `tablelookup` function in the component equations. In particular, the two-phase fluid blocks in the Foundation library use these lookup tables for interpolation purposes.

To refer to this domain in your custom component declarations, use the following syntax:

`foundation.two_phase_fluid.two_phase_fluid `