www.mooseframework.org
PorousFlowWaterVapor.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "PorousFlowWaterVapor.h"
12 #include "Conversion.h"
13 #include "MooseUtils.h"
14 
16 
17 template <>
18 InputParameters
20 {
22  params.addRequiredParam<UserObjectName>("water_fp", "The name of the user object for water");
23  params.addClassDescription("Fluid state class for water and vapor");
24  return params;
25 }
26 
27 PorousFlowWaterVapor::PorousFlowWaterVapor(const InputParameters & parameters)
29  _water_fp(getUserObject<SinglePhaseFluidProperties>("water_fp")),
30  _Mh2o(_water_fp.molarMass()),
31  _p_triple(_water_fp.triplePointPressure()),
32  _p_critical(_water_fp.criticalPressure()),
33  _T_triple(_water_fp.triplePointTemperature()),
34  _T_critical(_water_fp.criticalTemperature())
35 {
36  // Check that the correct FluidProperties UserObjects have been provided
37  if (_water_fp.fluidName() != "water")
38  paramError("water_fp", "A valid water FluidProperties UserObject must be provided in water_fp");
39 
40  // Set the number of phases and components, and their indexes
41  _num_phases = 2;
42  _num_components = 1;
45 
46  // Check that _aqueous_phase_number is <= total number of phases
48  paramError("liquid_phase_number",
49  "This value is larger than the possible number of phases ",
50  _num_phases);
51 
52  // Check that _aqueous_fluid_component is <= total number of fluid components
54  paramError("liquid_fluid_component",
55  "This value is larger than the possible number of fluid components",
57 
59 }
60 
61 std::string
63 {
64  return "water-vapor";
65 }
66 
67 void
69  Real enthalpy,
70  unsigned int qp,
71  FluidStatePhaseEnum & phase_state,
72  std::vector<FluidStateProperties> & fsp) const
73 {
76 
77  // AD versions of primary variables
78  DualReal p = pressure;
79  Moose::derivInsert(p.derivatives(), _pidx, 1.0);
80  DualReal h = enthalpy;
81  Moose::derivInsert(h.derivatives(), _hidx, 1.0);
82 
83  DualReal Tsat = 0.0;
84  DualReal hl = 0.0;
85  DualReal hv = 0.0;
86 
87  // Determine the phase state of the system
88  if (p.value() >= _p_triple && p.value() <= _p_critical)
89  {
90  // Saturation temperature at the given pressure
91  Tsat = _water_fp.vaporTemperature(p);
92 
93  // Enthalpy of saturated liquid and saturated vapor
94  hl = _water_fp.h_from_p_T(p, Tsat - dT);
95  hv = _water_fp.h_from_p_T(p, Tsat + dT);
96 
97  if (h.value() < hl)
98  phase_state = FluidStatePhaseEnum::LIQUID;
99 
100  else if (h.value() >= hl && h.value() <= hv)
101  phase_state = FluidStatePhaseEnum::TWOPHASE;
102 
103  else // h > hv
104  phase_state = FluidStatePhaseEnum::GAS;
105  }
106  else // p.value() > _p_critical
107  {
108  // Check whether the phase point is in the liquid or vapor state
109  const DualReal T = _water_fp.T_from_p_h(p, h);
110 
111  if (T.value() <= _T_critical)
112  phase_state = FluidStatePhaseEnum::LIQUID;
113  else
114  {
115  // The supercritical state is treated as a gas
116  phase_state = FluidStatePhaseEnum::GAS;
117  }
118  }
119 
120  // Calculate the properties for each phase as required
121  switch (phase_state)
122  {
124  {
125  gas.pressure = p + _pc.capillaryPressure(0.0, qp);
126  gas.saturation = 1.0;
127 
128  const DualReal T = _water_fp.T_from_p_h(gas.pressure, h);
129 
130  gas.temperature = T;
131  liquid.temperature = T;
132 
133  gas.density = _water_fp.rho_from_p_T(gas.pressure, T);
134  gas.viscosity = _water_fp.mu_from_p_T(gas.pressure, T);
135  gas.enthalpy = h;
136  gas.internal_energy = _water_fp.e_from_p_T(gas.pressure, T);
137 
138  break;
139  }
140 
142  {
143  const DualReal T = _water_fp.T_from_p_h(p, h);
144 
145  liquid.pressure = p;
146  liquid.temperature = T;
147  liquid.density = _water_fp.rho_from_p_T(p, T);
148  liquid.viscosity = _water_fp.mu_from_p_T(p, T);
149  liquid.enthalpy = h;
150  liquid.internal_energy = _water_fp.e_from_p_T(p, T);
151  liquid.saturation = 1.0;
152 
153  break;
154  }
155 
157  {
158  // Latent heat of vaporization
159  const DualReal hvl = hv - hl;
160 
161  // Vapor quality
162  const DualReal X = (h - hl) / hvl;
163 
164  // Perturbed saturation temperature to ensure that the correct
165  // phase properties are calculated
166  const DualReal Tsatl = Tsat - dT;
167  const DualReal Tsatv = Tsat + dT;
168 
169  // Density
170  const DualReal rhol = _water_fp.rho_from_p_T(p, Tsatl);
171  const DualReal rhov = _water_fp.rho_from_p_T(p, Tsatv);
172 
173  // Vapor (gas) saturation
174  const DualReal satv = X * rhol / (rhov + X * (rhol - rhov));
175 
176  gas.temperature = Tsat;
177  gas.density = rhov;
178  gas.viscosity = _water_fp.mu_from_p_T(p, Tsatv);
179  gas.enthalpy = hv;
180  gas.internal_energy = _water_fp.e_from_p_T(p, Tsatv);
181  gas.saturation = satv;
182 
183  liquid.temperature = Tsat;
184  liquid.density = rhol;
185  liquid.viscosity = _water_fp.mu_from_p_T(p, Tsatl);
186  liquid.enthalpy = hl;
187  liquid.internal_energy = _water_fp.e_from_p_T(p, Tsatl);
188  liquid.saturation = 1.0 - satv;
189 
190  liquid.pressure = p;
191  gas.pressure = p + _pc.capillaryPressure(liquid.saturation, qp);
192 
193  break;
194  }
195  }
196 }
PorousFlowFluidStateBase::_empty_fsp
FluidStateProperties _empty_fsp
Empty FluidStateProperties object.
Definition: PorousFlowFluidStateBase.h:139
PorousFlowFluidStateBase::_gas_phase_number
unsigned int _gas_phase_number
Phase number of the gas phase.
Definition: PorousFlowFluidStateBase.h:125
SinglePhaseFluidProperties
Common class for single phase fluid properties.
Definition: SinglePhaseFluidProperties.h:89
PorousFlowFluidStateBase::_pc
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
Definition: PorousFlowFluidStateBase.h:137
FluidStateProperties::density
DualReal density
Definition: PorousFlowFluidStateBase.h:42
FluidStateProperties::pressure
DualReal pressure
Definition: PorousFlowFluidStateBase.h:37
validParams< PorousFlowWaterVapor >
InputParameters validParams< PorousFlowWaterVapor >()
Definition: PorousFlowWaterVapor.C:19
SinglePhaseFluidProperties.h
FluidStatePhaseEnum
FluidStatePhaseEnum
Phase state enum.
Definition: PorousFlowFluidStateBase.h:18
PorousFlowWaterVapor::_p_critical
const Real _p_critical
Critical pressure of water (Pa)
Definition: PorousFlowWaterVapor.h:47
PorousFlowWaterVapor::PorousFlowWaterVapor
PorousFlowWaterVapor(const InputParameters &parameters)
Definition: PorousFlowWaterVapor.C:27
PorousFlowWaterVapor::thermophysicalProperties
void thermophysicalProperties(Real pressure, Real enthalpy, unsigned int qp, FluidStatePhaseEnum &phase_state, std::vector< FluidStateProperties > &fsp) const override
Determines the complete thermophysical state of the system for a given set of primary variables.
Definition: PorousFlowWaterVapor.C:68
FluidStateProperties::enthalpy
DualReal enthalpy
Definition: PorousFlowFluidStateBase.h:44
PorousFlowWaterVapor::_p_triple
const Real _p_triple
Triple point pressure of water (Pa)
Definition: PorousFlowWaterVapor.h:45
PorousFlowFluidStateSingleComponentBase
Base class for miscible multiphase flow classes with a single fluid component using a pressure and en...
Definition: PorousFlowFluidStateSingleComponentBase.h:23
PorousFlowWaterVapor::_T_critical
const Real _T_critical
Critical temperature of water (K)
Definition: PorousFlowWaterVapor.h:51
PorousFlowFluidStateBase::_gas_fluid_component
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
Definition: PorousFlowFluidStateBase.h:129
FluidStatePhaseEnum::LIQUID
PorousFlowWaterVapor
Specialized class for water and vapor mixture using pressure and enthalpy.
Definition: PorousFlowWaterVapor.h:26
NS::enthalpy
const std::string enthalpy
Definition: NS.h:27
PorousFlowWaterVapor::_water_fp
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
Definition: PorousFlowWaterVapor.h:41
FluidStateProperties
AD data structure to pass calculated thermophysical properties.
Definition: PorousFlowFluidStateBase.h:26
PorousFlowCapillaryPressure::capillaryPressure
virtual Real capillaryPressure(Real saturation, unsigned qp=0) const
Capillary pressure is calculated as a function of true saturation.
Definition: PorousFlowCapillaryPressure.C:64
PorousFlowFluidStateBase::_aqueous_phase_number
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
Definition: PorousFlowFluidStateBase.h:123
PorousFlowFluidStateBase::_num_phases
unsigned int _num_phases
Number of phases.
Definition: PorousFlowFluidStateBase.h:119
validParams< PorousFlowFluidStateSingleComponentBase >
InputParameters validParams< PorousFlowFluidStateSingleComponentBase >()
Definition: PorousFlowFluidStateSingleComponentBase.C:14
SinglePhaseFluidProperties::vaporTemperature
virtual Real vaporTemperature(Real p) const
Vapor temperature.
Definition: SinglePhaseFluidProperties.C:212
registerMooseObject
registerMooseObject("PorousFlowApp", PorousFlowWaterVapor)
PorousFlowFluidStateBase::_num_components
unsigned int _num_components
Number of components.
Definition: PorousFlowFluidStateBase.h:121
FluidStatePhaseEnum::TWOPHASE
FluidStateProperties::temperature
DualReal temperature
Definition: PorousFlowFluidStateBase.h:40
FluidStatePhaseEnum::GAS
FluidStateProperties::internal_energy
DualReal internal_energy
Definition: PorousFlowFluidStateBase.h:45
PorousFlowFluidStateBase::_aqueous_fluid_component
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
Definition: PorousFlowFluidStateBase.h:127
PorousFlowWaterVapor::fluidStateName
virtual std::string fluidStateName() const override
Name of FluidState.
Definition: PorousFlowWaterVapor.C:62
PorousFlowFluidStateSingleComponentBase::_hidx
const unsigned int _hidx
Index of derivative wrt enthalpy.
Definition: PorousFlowFluidStateSingleComponentBase.h:51
FluidStateProperties::viscosity
DualReal viscosity
Definition: PorousFlowFluidStateBase.h:43
PorousFlowFluidStateSingleComponentBase::dT
const Real dT
Perturbation applied to saturation temperature to move to gas/liquid phase.
Definition: PorousFlowFluidStateSingleComponentBase.h:53
FluidStateProperties::saturation
DualReal saturation
Definition: PorousFlowFluidStateBase.h:41
PorousFlowFluidStateSingleComponentBase::_pidx
const unsigned int _pidx
Index of derivative wrt pressure.
Definition: PorousFlowFluidStateSingleComponentBase.h:45
PorousFlowWaterVapor.h
NS::pressure
const std::string pressure
Definition: NS.h:25