www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PorousFlowFluidStateWaterNCG Class Reference

Fluid state class for water and a non-condensable gas. More...

#include <PorousFlowFluidStateWaterNCG.h>

Inheritance diagram for PorousFlowFluidStateWaterNCG:
[legend]

Public Member Functions

 PorousFlowFluidStateWaterNCG (const InputParameters &parameters)
 

Protected Member Functions

virtual void thermophysicalProperties () override
 Calculates all required thermophysical properties and derivatives for each phase and fluid component. More...
 
Real enthalpyOfDissolution (Real temperature, Real Kh, Real dKh_dT) const
 Enthalpy of dissolution of NCG in water calculated using Henry's constant From Himmelblau, Partial molal heats and entropies of solution for gases dissolved in water from the freezing to the near critical point, J. More...
 
Real moleFractionToMassFraction (Real xmol) const
 Convert mole fraction to mass fraction. More...
 
virtual void initQpStatefulProperties () override
 
virtual void computeQpProperties () override
 
void setMaterialVectorSize () const
 Size material property vectors and initialise with zeros. More...
 
Real rachfordRice (Real x, std::vector< Real > &Ki) const
 Rachford-Rice equation for vapor fraction. More...
 
Real rachfordRiceDeriv (Real x, std::vector< Real > &Ki) const
 Derivative of Rachford-Rice equation wrt vapor fraction. More...
 
Real vaporMassFraction (std::vector< Real > &Ki) const
 Solves Rachford-Rice equation to provide vapor mass fraction. More...
 

Protected Attributes

const Water97FluidProperties_water_fp
 Fluid properties UserObject for water. More...
 
const SinglePhaseFluidPropertiesPT_ncg_fp
 Fluid properties UserObject for the NCG. More...
 
const Real _Mh2o
 Molar mass of water (kg/mol) More...
 
const Real _Mncg
 Molar mass of non-condensable gas (kg/mol) More...
 
const Real _water_triple_temperature
 Triple point temperature of water (K) More...
 
const Real _water_critical_temperature
 Critical temperature of water (K) More...
 
const VariableValue & _gas_porepressure
 Porepressure. More...
 
const VariableGradient & _gas_gradp_qp
 Gradient of porepressure (only defined at the qps) More...
 
const unsigned int _gas_porepressure_varnum
 Moose variable number of the gas porepressure. More...
 
const unsigned int _pvar
 PorousFlow variable number of the gas porepressure. More...
 
std::vector< const VariableValue * > _z
 Total mass fraction(s) of the gas component(s) summed over all phases. More...
 
std::vector< const VariableGradient * > _gradz_qp
 Gradient(s) of total mass fraction(s) of the gas component(s) (only defined at the qps) More...
 
std::vector< unsigned int > _z_varnum
 Moose variable number of z. More...
 
std::vector< unsigned int > _zvar
 PorousFlow variable number of z. More...
 
const unsigned int _num_z_vars
 Number of coupled total mass fractions. Should be _num_phases - 1. More...
 
const unsigned int _aqueous_phase_number
 Phase number of the aqueous phase. More...
 
const unsigned int _gas_phase_number
 Phase number of the gas phase. More...
 
const unsigned int _aqueous_fluid_component
 Fluid component number of the aqueous component. More...
 
const unsigned int _gas_fluid_component
 Fluid component number of the gas phase. More...
 
const MaterialProperty< Real > & _temperature
 Temperature. More...
 
const MaterialProperty< RealGradient > & _gradT_qp
 Gradient of temperature (only defined at the qps) More...
 
const MaterialProperty< std::vector< Real > > & _dtemperature_dvar
 Derivative of temperature wrt PorousFlow variables. More...
 
MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
 Mass fraction matrix. More...
 
MaterialProperty< std::vector< std::vector< RealGradient > > > * _grad_mass_frac_qp
 Gradient of the mass fraction matrix (only defined at the qps) More...
 
MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
 Derivative of the mass fraction matrix with respect to the Porous Flow variables. More...
 
const MaterialProperty< std::vector< Real > > & _saturation_old
 Old value of saturation. More...
 
MaterialProperty< std::vector< Real > > & _fluid_density
 Fluid density of each phase. More...
 
MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
 Derivative of the fluid density for each phase wrt PorousFlow variables. More...
 
MaterialProperty< std::vector< Real > > & _fluid_viscosity
 Viscosity of each phase. More...
 
MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_viscosity_dvar
 Derivative of the fluid viscosity for each phase wrt PorousFlow variables. More...
 
const Real _T_c2k
 Conversion from degrees Celsius to degrees Kelvin. More...
 
const Real _R
 Universal gas constant (J/mol/K) More...
 
const Real _nr_max_its
 Maximum number of iterations for the Newton-Raphson iterations. More...
 
const Real _nr_tol
 Tolerance for Newton-Raphson iterations. More...
 
bool _is_initqp
 Flag to indicate whether to calculate stateful properties. More...
 
std::vector< FluidStateProperties_fsp
 FluidStateProperties data structure. More...
 
const PorousFlowCapillaryPressure_pc_uo
 Capillary pressure UserObject. More...
 
const unsigned int _num_phases
 Number of phases. More...
 
const unsigned int _num_components
 Number of components. More...
 
const unsigned int _num_pf_vars
 Number of PorousFlow variables. More...
 
MaterialProperty< std::vector< Real > > & _porepressure
 Computed nodal or quadpoint values of porepressure of the phases. More...
 
MaterialProperty< std::vector< std::vector< Real > > > & _dporepressure_dvar
 d(porepressure)/d(PorousFlow variable) More...
 
MaterialProperty< std::vector< RealGradient > > *const _gradp_qp
 Grad(p) at the quadpoints. More...
 
MaterialProperty< std::vector< std::vector< Real > > > *const _dgradp_qp_dgradv
 d(grad porepressure)/d(grad PorousFlow variable) at the quadpoints More...
 
MaterialProperty< std::vector< std::vector< RealGradient > > > *const _dgradp_qp_dv
 d(grad porepressure)/d(PorousFlow variable) at the quadpoints More...
 
MaterialProperty< std::vector< Real > > & _saturation
 Computed nodal or qp saturation of the phases. More...
 
MaterialProperty< std::vector< std::vector< Real > > > & _dsaturation_dvar
 d(saturation)/d(PorousFlow variable) More...
 
MaterialProperty< std::vector< RealGradient > > *const _grads_qp
 Grad(s) at the quadpoints. More...
 
MaterialProperty< std::vector< std::vector< Real > > > *const _dgrads_qp_dgradv
 d(grad saturation)/d(grad PorousFlow variable) at the quadpoints More...
 
MaterialProperty< std::vector< std::vector< RealGradient > > > *const _dgrads_qp_dv
 d(grad saturation)/d(PorousFlow variable) at the quadpoints More...
 

Detailed Description

Fluid state class for water and a non-condensable gas.

Calculates the solubility of the gas phase in the water using Henry's law, and provides density, viscosity and mass fractions for use in Kernels.

Definition at line 24 of file PorousFlowFluidStateWaterNCG.h.

Constructor & Destructor Documentation

PorousFlowFluidStateWaterNCG::PorousFlowFluidStateWaterNCG ( const InputParameters &  parameters)

Definition at line 23 of file PorousFlowFluidStateWaterNCG.C.

24  : PorousFlowFluidStateFlashBase(parameters),
25 
26  _water_fp(getUserObject<Water97FluidProperties>("water_fp")),
27  _ncg_fp(getUserObject<SinglePhaseFluidPropertiesPT>("gas_fp")),
32 {
33  // Check that the correct FluidProperties UserObjects have been provided
34  if (_water_fp.fluidName() != "water")
35  mooseError("Only a valid water FluidProperties UserObject can be provided in water_fp");
36 }
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)
const Water97FluidProperties & _water_fp
Fluid properties UserObject for water.
const SinglePhaseFluidPropertiesPT & _ncg_fp
Fluid properties UserObject for the NCG.
PorousFlowFluidStateFlashBase(const InputParameters &parameters)
virtual std::string fluidName() const override
Fluid name.
const Real _water_critical_temperature
Critical temperature of water (K)
const Real _Mh2o
Molar mass of water (kg/mol)
const Real _water_triple_temperature
Triple point temperature of water (K)
virtual Real molarMass() const =0
Molar mass.
virtual Real molarMass() const override
Water molar mass.
virtual Real triplePointTemperature() const
Water triple point temperature.
virtual Real criticalTemperature() const
Water critical temperature.

Member Function Documentation

void PorousFlowFluidStateFlashBase::computeQpProperties ( )
overrideprotectedvirtualinherited

Reimplemented from PorousFlowVariableBase.

Definition at line 161 of file PorousFlowFluidStateFlashBase.C.

162 {
163  _is_initqp = false;
164  // Prepare the derivative vectors
166 
167  // Set the size of all other vectors
169 
170  // Calculate all required thermophysical properties
172 
173  for (unsigned int ph = 0; ph < _num_phases; ++ph)
174  {
175  _saturation[_qp][ph] = _fsp[ph].saturation;
176  _porepressure[_qp][ph] = _fsp[ph].pressure;
177  _fluid_density[_qp][ph] = _fsp[ph].fluid_density;
178  _fluid_viscosity[_qp][ph] = _fsp[ph].fluid_viscosity;
179  _mass_frac[_qp][ph] = _fsp[ph].mass_fraction;
180  }
181 
182  // Derivative of saturation wrt variables
183  for (unsigned int ph = 0; ph < _num_phases; ++ph)
184  {
185  _dsaturation_dvar[_qp][ph][_zvar[0]] = _fsp[ph].dsaturation_dz;
186  _dsaturation_dvar[_qp][ph][_pvar] = _fsp[ph].dsaturation_dp;
187  }
188  // Derivative of capillary pressure
190 
191  // Derivative of porepressure wrt variables
192  if (_dictator.isPorousFlowVariable(_gas_porepressure_varnum))
193  {
194  for (unsigned int ph = 0; ph < _num_phases; ++ph)
195  {
196  _dporepressure_dvar[_qp][ph][_pvar] = 1.0;
197  if (!_nodal_material)
198  (*_dgradp_qp_dgradv)[_qp][ph][_pvar] = 1.0;
199  }
200 
201  if (!_nodal_material)
202  (*_dgradp_qp_dgradv)[_qp][_aqueous_phase_number][_zvar[0]] =
203  -dpc * _fsp[_aqueous_phase_number].dsaturation_dp -
204  dpc * _fsp[_aqueous_phase_number].dsaturation_dz;
205 
206  // The aqueous phase porepressure is also a function of liquid saturation,
207  // which depends on both gas porepressure and z
211  -dpc * _dsaturation_dvar[_qp][_aqueous_phase_number][_zvar[0]];
212  }
213 
214  // Calculate derivatives of material properties wrt primary variables
215  // Derivative of z wrt variables
216  std::vector<Real> dz_dvar;
217  dz_dvar.assign(_num_pf_vars, 0.0);
218  if (_dictator.isPorousFlowVariable(_z_varnum[0]))
219  dz_dvar[_zvar[0]] = 1.0;
220 
221  // Derivatives of properties wrt primary variables
222  for (unsigned int v = 0; v < _num_pf_vars; ++v)
223  {
224  for (unsigned int ph = 0; ph < _num_phases; ++ph)
225  {
226  // Derivative of density in each phase
227  _dfluid_density_dvar[_qp][ph][v] =
228  _fsp[ph].dfluid_density_dp * _dporepressure_dvar[_qp][ph][v];
229  _dfluid_density_dvar[_qp][ph][v] += _fsp[ph].dfluid_density_dT * _dtemperature_dvar[_qp][v];
230  _dfluid_density_dvar[_qp][ph][v] += _fsp[ph].dfluid_density_dz * dz_dvar[v];
231 
232  // Derivative of viscosity in each phase
233  _dfluid_viscosity_dvar[_qp][ph][v] =
234  _fsp[ph].dfluid_viscosity_dp * _dporepressure_dvar[_qp][ph][v];
235  _dfluid_viscosity_dvar[_qp][ph][v] +=
236  _fsp[ph].dfluid_viscosity_dT * _dtemperature_dvar[_qp][v];
237  _dfluid_viscosity_dvar[_qp][ph][v] += _fsp[ph].dfluid_viscosity_dz * dz_dvar[v];
238 
239  // The derivative of the mass fractions for each fluid component in each phase
240  for (unsigned int comp = 0; comp < _num_components; ++comp)
241  {
242  _dmass_frac_dvar[_qp][ph][comp][v] =
243  _fsp[ph].dmass_fraction_dp[comp] * _dporepressure_dvar[_qp][ph][v];
244  _dmass_frac_dvar[_qp][ph][comp][v] +=
245  _fsp[ph].dmass_fraction_dT[comp] * _dtemperature_dvar[_qp][v];
246  _dmass_frac_dvar[_qp][ph][comp][v] += _fsp[ph].dmass_fraction_dz[comp] * dz_dvar[v];
247  }
248  }
249  }
250 
251  // If the material properties are being evaluated at the qps, calculate the
252  // gradients as well. Note: only nodal properties are evaluated in
253  // initQpStatefulProperties(), so no need to check _is_initqp flag for qp
254  // properties
255  if (!_nodal_material)
256  {
257  // Second derivative of capillary pressure
258  Real d2pc = _pc_uo.d2CapillaryPressure(_fsp[_aqueous_phase_number].saturation);
259 
260  (*_grads_qp)[_qp][_gas_phase_number] =
262  _dsaturation_dvar[_qp][_gas_phase_number][_zvar[0]] * (*_gradz_qp[0])[_qp];
263  (*_grads_qp)[_qp][_aqueous_phase_number] = -(*_grads_qp)[_qp][_gas_phase_number];
264 
265  (*_gradp_qp)[_qp][_gas_phase_number] = _gas_gradp_qp[_qp];
266  (*_gradp_qp)[_qp][_aqueous_phase_number] =
267  _gas_gradp_qp[_qp] - dpc * (*_grads_qp)[_qp][_aqueous_phase_number];
268 
269  (*_dgradp_qp_dv)[_qp][_aqueous_phase_number][_zvar[0]] =
270  -d2pc * (*_grads_qp)[_qp][_aqueous_phase_number];
271 
272  (*_grad_mass_frac_qp)[_qp][_aqueous_phase_number][_aqueous_fluid_component] =
274  _gas_gradp_qp[_qp] +
276  (*_gradz_qp[0])[_qp];
277  (*_grad_mass_frac_qp)[_qp][_aqueous_phase_number][_gas_fluid_component] =
278  -(*_grad_mass_frac_qp)[_qp][_aqueous_phase_number][_aqueous_fluid_component];
279  (*_grad_mass_frac_qp)[_qp][_gas_phase_number][_aqueous_fluid_component] =
280  _fsp[_gas_phase_number].dmass_fraction_dp[_aqueous_fluid_component] * _gas_gradp_qp[_qp] +
281  _fsp[_gas_phase_number].dmass_fraction_dz[_aqueous_fluid_component] * (*_gradz_qp[0])[_qp];
282  (*_grad_mass_frac_qp)[_qp][_gas_phase_number][_gas_fluid_component] =
283  -(*_grad_mass_frac_qp)[_qp][_gas_phase_number][_aqueous_fluid_component];
284  }
285 }
std::vector< const VariableGradient * > _gradz_qp
Gradient(s) of total mass fraction(s) of the gas component(s) (only defined at the qps) ...
void setMaterialVectorSize() const
Size material property vectors and initialise with zeros.
MaterialProperty< std::vector< std::vector< Real > > > & _dporepressure_dvar
d(porepressure)/d(PorousFlow variable)
const MaterialProperty< std::vector< Real > > & _dtemperature_dvar
Derivative of temperature wrt PorousFlow variables.
const VariableGradient & _gas_gradp_qp
Gradient of porepressure (only defined at the qps)
MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_viscosity_dvar
Derivative of the fluid viscosity for each phase wrt PorousFlow variables.
const unsigned int _num_pf_vars
Number of PorousFlow variables.
const unsigned int _gas_porepressure_varnum
Moose variable number of the gas porepressure.
std::vector< unsigned int > _z_varnum
Moose variable number of z.
const unsigned int _pvar
PorousFlow variable number of the gas porepressure.
MaterialProperty< std::vector< Real > > & _saturation
Computed nodal or qp saturation of the phases.
MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
Derivative of the fluid density for each phase wrt PorousFlow variables.
MaterialProperty< std::vector< std::vector< Real > > > & _dsaturation_dvar
d(saturation)/d(PorousFlow variable)
virtual Real dCapillaryPressure(Real saturation) const
Derivative of capillary pressure wrt true saturation.
MaterialProperty< std::vector< Real > > & _fluid_density
Fluid density of each phase.
virtual Real d2CapillaryPressure(Real saturation) const
Second derivative of capillary pressure wrt true saturation.
MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
Mass fraction matrix.
const unsigned int _gas_fluid_component
Fluid component number of the gas phase.
const PorousFlowCapillaryPressure & _pc_uo
Capillary pressure UserObject.
std::vector< FluidStateProperties > _fsp
FluidStateProperties data structure.
std::vector< unsigned int > _zvar
PorousFlow variable number of z.
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
virtual void computeQpProperties() override
const unsigned int _gas_phase_number
Phase number of the gas phase.
bool _is_initqp
Flag to indicate whether to calculate stateful properties.
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
const unsigned int _num_components
Number of components.
const unsigned int _num_phases
Number of phases.
void FORTRAN_CALL() saturation(double &P, double &T, int &N, int &nerr)
MaterialProperty< std::vector< Real > > & _porepressure
Computed nodal or quadpoint values of porepressure of the phases.
MaterialProperty< std::vector< Real > > & _fluid_viscosity
Viscosity of each phase.
MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
Derivative of the mass fraction matrix with respect to the Porous Flow variables. ...
virtual void thermophysicalProperties()=0
Calculates all required thermophysical properties and derivatives for each phase and fluid component...
Real PorousFlowFluidStateWaterNCG::enthalpyOfDissolution ( Real  temperature,
Real  Kh,
Real  dKh_dT 
) const
protected

Enthalpy of dissolution of NCG in water calculated using Henry's constant From Himmelblau, Partial molal heats and entropies of solution for gases dissolved in water from the freezing to the near critical point, J.

Phys. Chem. 63 (1959)

Parameters
temperaturefluid temperature (K)
KhHenry's constant (Pa)
dKh_dTderivative of Henry's constant wrt temperature
Returns
enthalpy of dissolution (kJ/kg)

Definition at line 350 of file PorousFlowFluidStateWaterNCG.C.

351 {
352  return -_R * temperature * temperature * _Mncg * dKh_dT / Kh;
353 }
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)
const std::string temperature
Definition: NS.h:25
const Real _R
Universal gas constant (J/mol/K)
void PorousFlowFluidStateFlashBase::initQpStatefulProperties ( )
overrideprotectedvirtualinherited

Reimplemented from PorousFlowVariableBase.

Definition at line 134 of file PorousFlowFluidStateFlashBase.C.

135 {
136  _is_initqp = true;
137  // Set the size of pressure and saturation vectors
139 
140  // Set the size of all other vectors
142 
143  // Set the initial values of the properties at the nodes.
144  // Note: not required for qp materials as no old values at the qps are requested
145  if (_nodal_material)
146  {
148 
149  for (unsigned int ph = 0; ph < _num_phases; ++ph)
150  {
151  _saturation[_qp][ph] = _fsp[ph].saturation;
152  _porepressure[_qp][ph] = _fsp[ph].pressure;
153  _fluid_density[_qp][ph] = _fsp[ph].fluid_density;
154  _fluid_viscosity[_qp][ph] = _fsp[ph].fluid_viscosity;
155  _mass_frac[_qp][ph] = _fsp[ph].mass_fraction;
156  }
157  }
158 }
void setMaterialVectorSize() const
Size material property vectors and initialise with zeros.
MaterialProperty< std::vector< Real > > & _saturation
Computed nodal or qp saturation of the phases.
MaterialProperty< std::vector< Real > > & _fluid_density
Fluid density of each phase.
MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
Mass fraction matrix.
virtual void initQpStatefulProperties() override
std::vector< FluidStateProperties > _fsp
FluidStateProperties data structure.
bool _is_initqp
Flag to indicate whether to calculate stateful properties.
const unsigned int _num_phases
Number of phases.
MaterialProperty< std::vector< Real > > & _porepressure
Computed nodal or quadpoint values of porepressure of the phases.
MaterialProperty< std::vector< Real > > & _fluid_viscosity
Viscosity of each phase.
virtual void thermophysicalProperties()=0
Calculates all required thermophysical properties and derivatives for each phase and fluid component...
Real PorousFlowFluidStateWaterNCG::moleFractionToMassFraction ( Real  xmol) const
protected

Convert mole fraction to mass fraction.

Parameters
xmolmole fraction
Returns
mass fraction

Definition at line 356 of file PorousFlowFluidStateWaterNCG.C.

Referenced by thermophysicalProperties().

357 {
358  return xmol * _Mncg / (xmol * _Mncg + (1.0 - xmol) * _Mh2o);
359 }
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)
const Real _Mh2o
Molar mass of water (kg/mol)
Real PorousFlowFluidStateFlashBase::rachfordRice ( Real  x,
std::vector< Real > &  Ki 
) const
protectedinherited

Rachford-Rice equation for vapor fraction.

Can be solved analytically for two components in two phases, but must be solved iteratively using a root finding algorithm for more components. This equation has the nice property that it is monotonic in the interval [0,1], so that only a small number of iterations are typically required to find the root.

The Rachford-Rice equation can also be used to check whether the phase state is two phase, single phase gas, or single phase liquid. Evaluate f(v), the Rachford-Rice equation evaluated at the vapor mass fraction.

If f(0) < 0, then the mixture is below the bubble point, and only a single phase liquid can exist

If f(1) > 0, then the mixture is above the dew point, and only a single phase gas exists.

If f(0) >= 0 and f(1) <= 0, the mixture is between the bubble and dew points, and both gas and liquid phases exist.

Parameters
xvapor fraction
Kiequilibrium constants
Returns
f(x)

Definition at line 320 of file PorousFlowFluidStateFlashBase.C.

Referenced by PorousFlowFluidStateFlashBase::vaporMassFraction().

321 {
322  // Check that the size of the equilibrium constant vector is correct
323  if (Ki.size() != _num_components)
324  mooseError("The number of equilibrium components passed to rachfordRice is not correct");
325 
326  Real f = 0.0;
327  Real z_total = 0.0;
328 
329  for (unsigned int i = 0; i < _num_z_vars; ++i)
330  {
331  f += (*_z[i])[_qp] * (Ki[i] - 1.0) / (1.0 + x * (Ki[i] - 1.0));
332  z_total += (*_z[i])[_qp];
333  }
334 
335  // Add the last component (with total mass fraction = 1 - z_total)
336  f += (1.0 - z_total) * (Ki[_num_z_vars] - 1.0) / (1.0 + x * (Ki[_num_z_vars] - 1.0));
337 
338  return f;
339 }
const unsigned int _num_z_vars
Number of coupled total mass fractions. Should be _num_phases - 1.
const unsigned int _num_components
Number of components.
std::vector< const VariableValue * > _z
Total mass fraction(s) of the gas component(s) summed over all phases.
Real PorousFlowFluidStateFlashBase::rachfordRiceDeriv ( Real  x,
std::vector< Real > &  Ki 
) const
protectedinherited

Derivative of Rachford-Rice equation wrt vapor fraction.

Has the nice property that it is strictly negative in the interval [0,1]

Parameters
xvapor fraction
Kiequilibrium constants
Returns
f'(x)

Definition at line 342 of file PorousFlowFluidStateFlashBase.C.

Referenced by PorousFlowFluidStateFlashBase::vaporMassFraction().

343 {
344  // Check that the size of the equilibrium constant vector is correct
345  if (Ki.size() != _num_components)
346  mooseError("The number of equilibrium components passed to rachfordRiceDeriv is not correct");
347 
348  Real df = 0.0;
349  Real z_total = 0.0;
350 
351  for (unsigned int i = 0; i < _num_z_vars; ++i)
352  {
353  df -= (*_z[i])[_qp] * (Ki[i] - 1.0) * (Ki[i] - 1.0) / (1.0 + x * (Ki[i] - 1.0)) /
354  (1.0 + x * (Ki[i] - 1.0));
355  z_total += (*_z[i])[_qp];
356  }
357 
358  // Add the last component (with total mass fraction = 1 - z_total)
359  df -= (1.0 - z_total) * (Ki[_num_z_vars] - 1.0) * (Ki[_num_z_vars] - 1.0) /
360  (1.0 + x * (Ki[_num_z_vars] - 1.0)) / (1.0 + x * (Ki[_num_z_vars] - 1.0));
361 
362  return df;
363 }
const unsigned int _num_z_vars
Number of coupled total mass fractions. Should be _num_phases - 1.
const unsigned int _num_components
Number of components.
std::vector< const VariableValue * > _z
Total mass fraction(s) of the gas component(s) summed over all phases.
void PorousFlowFluidStateFlashBase::setMaterialVectorSize ( ) const
protectedinherited

Size material property vectors and initialise with zeros.

Definition at line 288 of file PorousFlowFluidStateFlashBase.C.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties(), and PorousFlowFluidStateFlashBase::initQpStatefulProperties().

289 {
290  _fluid_density[_qp].assign(_num_phases, 0.0);
291  _fluid_viscosity[_qp].assign(_num_phases, 0.0);
292  _mass_frac[_qp].resize(_num_phases);
293 
294  // Derivatives and gradients are not required in initQpStatefulProperties
295  if (!_is_initqp)
296  {
297  _dfluid_density_dvar[_qp].resize(_num_phases);
298  _dfluid_viscosity_dvar[_qp].resize(_num_phases);
299  _dmass_frac_dvar[_qp].resize(_num_phases);
300 
301  if (!_nodal_material)
302  (*_grad_mass_frac_qp)[_qp].resize(_num_phases);
303 
304  for (unsigned int ph = 0; ph < _num_phases; ++ph)
305  {
306  _dfluid_density_dvar[_qp][ph].assign(_num_pf_vars, 0.0);
307  _dfluid_viscosity_dvar[_qp][ph].assign(_num_pf_vars, 0.0);
308  _dmass_frac_dvar[_qp][ph].resize(_num_components);
309 
310  for (unsigned int comp = 0; comp < _num_components; ++comp)
311  _dmass_frac_dvar[_qp][ph][comp].assign(_num_pf_vars, 0.0);
312 
313  if (!_nodal_material)
314  (*_grad_mass_frac_qp)[_qp][ph].assign(_num_components, RealGradient());
315  }
316  }
317 }
MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_viscosity_dvar
Derivative of the fluid viscosity for each phase wrt PorousFlow variables.
const unsigned int _num_pf_vars
Number of PorousFlow variables.
MaterialProperty< std::vector< std::vector< Real > > > & _dfluid_density_dvar
Derivative of the fluid density for each phase wrt PorousFlow variables.
MaterialProperty< std::vector< Real > > & _fluid_density
Fluid density of each phase.
MaterialProperty< std::vector< std::vector< Real > > > & _mass_frac
Mass fraction matrix.
bool _is_initqp
Flag to indicate whether to calculate stateful properties.
const unsigned int _num_components
Number of components.
const unsigned int _num_phases
Number of phases.
MaterialProperty< std::vector< Real > > & _fluid_viscosity
Viscosity of each phase.
MaterialProperty< std::vector< std::vector< std::vector< Real > > > > & _dmass_frac_dvar
Derivative of the mass fraction matrix with respect to the Porous Flow variables. ...
void PorousFlowFluidStateWaterNCG::thermophysicalProperties ( )
overrideprotectedvirtual

Calculates all required thermophysical properties and derivatives for each phase and fluid component.

Must override in all derived classes.

Implements PorousFlowFluidStateFlashBase.

Definition at line 39 of file PorousFlowFluidStateWaterNCG.C.

40 {
41  // The FluidProperty objects use temperature in K
42  Real Tk = _temperature[_qp] + _T_c2k;
43 
44  // Check whether the input temperature is within the region of validity of this equation
45  // of state (T_triple <= T <= T_critical)
46  if (Tk < _water_triple_temperature || Tk > _water_critical_temperature)
47  mooseError("PorousFlowFluidStateWaterNCG: Temperature is outside range 273.16 K <= T "
48  "<= 647.096 K");
49 
50  // Equilibrium constants for each component (Henry's law for the NCG
51  // component, and Raoult's law for water).
52  // Note: these are in terms of mole fraction
53  Real psat, dpsat_dT;
54  _water_fp.vaporPressure_dT(Tk, psat, dpsat_dT);
55  Real K0 = _ncg_fp.henryConstant(Tk) / _gas_porepressure[_qp];
56  Real K1 = psat / _gas_porepressure[_qp];
57 
58  // The mole fractions for the NCG component in the two component
59  // case can be expressed in terms of the equilibrium constants only
60  Real x0 = (1.0 - K1) / (K0 - K1);
61  Real y0 = K0 * x0;
62 
63  // Convert mole fractions to mass fractions
64  Real X0 = moleFractionToMassFraction(x0);
65  Real Y0 = moleFractionToMassFraction(y0);
66 
67  // Determine which phases are present based on the value of z
68  bool is_liquid = false;
69  bool is_gas = false;
70  bool is_twophase = false;
71 
72  if ((*_z[0])[_qp] <= X0)
73  {
74  // In this case, there is not enough NCG to form a gas phase,
75  // so only a liquid phase is present
76  is_liquid = true;
77  }
78  else if ((*_z[0])[_qp] > X0 && (*_z[0])[_qp] < Y0)
79  {
80  // Two phases are present
81  is_twophase = true;
82  }
83  else // ((*_z[0])[_qp] >= Y0)
84  {
85  // In this case, there is not enough water to form a liquid
86  // phase, so only a gas phase is present
87  is_gas = true;
88  }
89 
90  // Material must provide the following properties
91  Real vapor_mass_fraction = 0.0;
92  Real gas_saturation, liquid_saturation;
93  Real gas_density, liquid_density;
94  Real gas_viscosity, liquid_viscosity;
95 
96  // And the following derivatives
97  Real dX0_dp = 0.0, dX0_dT = 0.0, dX0_dz = 0.0;
98  Real dY0_dp = 0.0, dY0_dT = 0.0, dY0_dz = 0.0;
99  Real dgas_density_dp = 0.0, dgas_density_dT = 0.0, dgas_density_dz = 0.0;
100  Real dliquid_density_dp = 0.0, dliquid_density_dT = 0.0, dliquid_density_dz = 0.0;
101  Real dgas_viscosity_dp = 0.0, dgas_viscosity_dT = 0.0, dgas_viscosity_dz = 0.0;
102  Real dliquid_viscosity_dp = 0.0, dliquid_viscosity_dT = 0.0, dliquid_viscosity_dz = 0.0;
103 
104  if (is_liquid)
105  {
106  X0 = (*_z[0])[_qp];
107  Y0 = 0.0;
108  gas_saturation = 0.0;
109  dX0_dz = 1.0;
110  gas_density = 0.0;
111  gas_viscosity = 1.0; // To guard against division by 0
112  }
113  else if (is_twophase)
114  {
115  // Two phase are present. Set mass equilibrium constants used in the
116  // calculation of vapor mass fraction
117  std::vector<Real> Ki(_num_components);
118  Ki[0] = Y0 / X0;
119  Ki[1] = (1.0 - Y0) / (1.0 - X0);
120  vapor_mass_fraction = vaporMassFraction(Ki);
121 
122  // Derivatives of mass fractions wrt PorousFlow variables
123  Real Kh, dKh_dT;
124  _ncg_fp.henryConstant_dT(Tk, Kh, dKh_dT);
125  Real dK0_dp = -Kh / _gas_porepressure[_qp] / _gas_porepressure[_qp];
126  Real dK0_dT = dKh_dT / _gas_porepressure[_qp];
127 
128  Real dK1_dp = -psat / _gas_porepressure[_qp] / _gas_porepressure[_qp];
129  Real dK1_dT = dpsat_dT / _gas_porepressure[_qp];
130 
131  Real dx0_dp = ((K1 - 1.0) * dK0_dp + (1 - K0) * dK1_dp) / (K0 - K1) / (K0 - K1);
132  Real dy0_dp = x0 * dK0_dp + K0 * dx0_dp;
133  Real dx0_dT = ((K1 - 1.0) * dK0_dT + (1 - K0) * dK1_dT) / (K0 - K1) / (K0 - K1);
134  Real dy0_dT = x0 * dK0_dT + K0 * dx0_dT;
135 
136  Real dX0_dx0 =
137  _Mncg * _Mh2o / (x0 * _Mncg + (1.0 - x0) * _Mh2o) / (x0 * _Mncg + (1.0 - x0) * _Mh2o);
138  Real dY0_dy0 =
139  _Mncg * _Mh2o / (y0 * _Mncg + (1.0 - y0) * _Mh2o) / (y0 * _Mncg + (1.0 - y0) * _Mh2o);
140 
141  dX0_dp = dX0_dx0 * dx0_dp;
142  dX0_dT = dX0_dx0 * dx0_dT;
143  dY0_dp = dY0_dy0 * dy0_dp;
144  dY0_dT = dY0_dy0 * dy0_dT;
145  }
146  else // if (is_gas)
147  {
148  X0 = 0.0;
149  Y0 = (*_z[0])[_qp];
150  vapor_mass_fraction = 1.0;
151  gas_saturation = 1.0;
152  dY0_dz = 1.0;
153  liquid_density = 0.0;
154  liquid_viscosity = 1.0; // To guard against division by 0
155  }
156 
157  // Calculate the gas density and viscosity in the single phase gas or two
158  // phase region
159  if (is_gas || is_twophase)
160  {
161  Real ncg_density, dncg_density_dp, dncg_density_dT;
162  Real vapor_density, dvapor_density_dp, dvapor_density_dT;
163  // NCG density calculated using partial pressure Y0 * gas_poreressure (Dalton's law)
164  _ncg_fp.rho_dpT(Y0 * _gas_porepressure[_qp], Tk, ncg_density, dncg_density_dp, dncg_density_dT);
165  // Vapor density calculated using partial pressure X1 * psat (Raoult's law)
166  _water_fp.rho_dpT((1.0 - X0) * psat, Tk, vapor_density, dvapor_density_dp, dvapor_density_dT);
167 
168  // The derivatives wrt pressure above must be multiplied by the derivative of the pressure
169  // variable using the chain rule
170  gas_density = ncg_density + vapor_density;
171  dgas_density_dp = (Y0 + dY0_dp * _gas_porepressure[_qp]) * dncg_density_dp -
172  dX0_dp * psat * dvapor_density_dp;
173  dgas_density_dT = dncg_density_dT + dvapor_density_dT;
174 
175  Real ncg_viscosity, dncg_viscosity_drho, dncg_viscosity_dT;
176  Real vapor_viscosity, dvapor_viscosity_drho, dvapor_viscosity_dT;
178  ncg_density, Tk, dncg_density_dT, ncg_viscosity, dncg_viscosity_drho, dncg_viscosity_dT);
179  _water_fp.mu_drhoT_from_rho_T(vapor_density,
180  Tk,
181  dvapor_density_dT,
182  vapor_viscosity,
183  dvapor_viscosity_drho,
184  dvapor_viscosity_dT);
185 
186  // Assume that the viscosity of the gas phase is a weighted sum of the
187  // individual viscosities
188  gas_viscosity = Y0 * ncg_viscosity + (1.0 - Y0) * vapor_viscosity;
189  dgas_viscosity_dp =
190  dY0_dp * (ncg_viscosity - vapor_viscosity) +
191  Y0 * (Y0 + dY0_dp * _gas_porepressure[_qp]) * dncg_viscosity_drho * dncg_density_dp -
192  dX0_dp * psat * (1.0 - Y0) * dvapor_viscosity_drho * dvapor_density_dp;
193  dgas_viscosity_dT = dY0_dT * (ncg_viscosity - vapor_viscosity) + Y0 * dncg_viscosity_dT +
194  (1.0 - Y0) * dvapor_density_dT;
195 
196  // Also calculate derivatives wrt z in the gas phase (these are 0 in the two phase region)
197  if (is_gas)
198  {
199  dgas_density_dz =
200  dY0_dz * _gas_porepressure[_qp] * dncg_density_dp - dX0_dz * psat * dvapor_density_dp;
201 
202  dgas_viscosity_dz =
203  dY0_dz * (ncg_viscosity - vapor_viscosity) +
204  Y0 * dncg_viscosity_drho * dncg_density_dp * dY0_dz * _gas_porepressure[_qp] -
205  dX0_dz * psat * (1.0 - Y0) * dvapor_viscosity_drho * dvapor_density_dp;
206  }
207  }
208 
209  // Calculate the saturation in the two phase case using the vapor mass fraction
210  if (is_twophase)
211  {
212  // Liquid density is approximated by the water density.
213  // Use old value of gas saturation to estimate liquid saturation
214  Real liqsat = 1.0;
215  if (!_is_initqp)
216  liqsat -= _saturation_old[_qp][_gas_phase_number];
217  liquid_density = _water_fp.rho(_gas_porepressure[_qp] + _pc_uo.capillaryPressure(liqsat), Tk);
218 
219  // The gas saturation in the two phase case
220  gas_saturation = vapor_mass_fraction * liquid_density /
221  (gas_density + vapor_mass_fraction * (liquid_density - gas_density));
222  }
223 
224  // Calculate the saturations and pressures for each phase
225  liquid_saturation = 1.0 - gas_saturation;
226  Real liquid_porepressure = _gas_porepressure[_qp] - _pc_uo.capillaryPressure(liquid_saturation);
227 
228  // Calculate liquid density and viscosity if in the two phase or single phase
229  // liquid region, assuming they are not affected by the presence of dissolved
230  // NCG. Note: the (small) contribution due to derivative of capillary pressure
231  // wrt pressure (using the chain rule) is not implemented.
232  if (is_liquid || is_twophase)
233  {
234  Real dliquid_viscosity_drho;
236  liquid_porepressure, Tk, liquid_density, dliquid_density_dp, dliquid_density_dT);
237  _water_fp.mu_drhoT_from_rho_T(liquid_density,
238  Tk,
239  dliquid_density_dT,
240  liquid_viscosity,
241  dliquid_viscosity_drho,
242  dliquid_viscosity_dT);
243 
244  // The derivative of viscosity wrt pressure is given by the chain rule
245  dliquid_viscosity_dp = dliquid_viscosity_drho * dliquid_density_dp;
246  }
247 
248  // Save properties in FluidStateProperties vector
249  auto & liquid = _fsp[_aqueous_phase_number];
250  auto & gas = _fsp[_gas_phase_number];
251 
252  liquid.saturation = liquid_saturation;
253  gas.saturation = gas_saturation;
254  liquid.pressure = liquid_porepressure;
255  gas.pressure = _gas_porepressure[_qp];
256 
257  liquid.mass_fraction[_aqueous_fluid_component] = 1.0 - X0;
258  liquid.mass_fraction[_gas_fluid_component] = X0;
259  gas.mass_fraction[_aqueous_fluid_component] = 1.0 - Y0;
260  gas.mass_fraction[_gas_fluid_component] = Y0;
261 
262  liquid.fluid_density = liquid_density;
263  gas.fluid_density = gas_density;
264  liquid.fluid_viscosity = liquid_viscosity;
265  gas.fluid_viscosity = gas_viscosity;
266 
267  // Derivatives wrt PorousFlow variables are required by the kernels
268  // Note: these don't need to be stateful so don't calculate them in
269  // initQpStatefulProperties
270  if (!_is_initqp)
271  {
272  // Derivative of gas saturation wrt variables
273  Real ds_dp = 0.0, ds_dT = 0.0, ds_dz = 0.0;
274  if (is_twophase)
275  {
276  K0 = Y0 / X0;
277  K1 = (1.0 - Y0) / (1.0 - X0);
278  Real dv_dz = (K1 - K0) / ((K0 - 1.0) * (K1 - 1.0));
279  ds_dz = gas_density * liquid_density * dv_dz +
280  vapor_mass_fraction * (1.0 - vapor_mass_fraction) *
281  (gas_density * dliquid_density_dz - dgas_density_dz * liquid_density);
282  ds_dz /= (gas_density + vapor_mass_fraction * (liquid_density - gas_density)) *
283  (gas_density + vapor_mass_fraction * (liquid_density - gas_density));
284 
285  Real Kh, dKh_dT;
286  _ncg_fp.henryConstant_dT(Tk, Kh, dKh_dT);
287  Real dK0_dp = -Kh / _gas_porepressure[_qp] / _gas_porepressure[_qp];
288  Real dK0_dT = dKh_dT / _gas_porepressure[_qp];
289 
290  Real dK1_dp = -psat / _gas_porepressure[_qp] / _gas_porepressure[_qp];
291  Real dK1_dT = dpsat_dT / _gas_porepressure[_qp];
292 
293  Real dv_dp = (*_z[0])[_qp] * dK1_dp / (K1 - 1.0) / (K1 - 1.0) +
294  (1.0 - (*_z[0])[_qp]) * dK0_dp / (K0 - 1.0) / (K0 - 1.0);
295  ds_dp = gas_density * liquid_density * dv_dp +
296  vapor_mass_fraction * (1.0 - vapor_mass_fraction) *
297  (gas_density * dliquid_density_dp - dgas_density_dp * liquid_density);
298 
299  ds_dp /= (gas_density + vapor_mass_fraction * (liquid_density - gas_density)) *
300  (gas_density + vapor_mass_fraction * (liquid_density - gas_density));
301 
302  Real dv_dT = (*_z[0])[_qp] * dK1_dT / (K1 - 1.0) / (K1 - 1.0) +
303  (1.0 - (*_z[0])[_qp]) * dK0_dT / (K0 - 1.0) / (K0 - 1.0);
304  ds_dT = gas_density * liquid_density * dv_dT +
305  vapor_mass_fraction * (1.0 - vapor_mass_fraction) *
306  (gas_density * dliquid_density_dT - dgas_density_dT * liquid_density);
307 
308  ds_dT /= (gas_density + vapor_mass_fraction * (liquid_density - gas_density)) *
309  (gas_density + vapor_mass_fraction * (liquid_density - gas_density));
310  }
311 
312  liquid.dsaturation_dp = -ds_dp;
313  liquid.dsaturation_dT = -ds_dT;
314  liquid.dsaturation_dz = -ds_dz;
315  gas.dsaturation_dp = ds_dp;
316  gas.dsaturation_dT = ds_dT;
317  gas.dsaturation_dz = ds_dz;
318 
319  liquid.dmass_fraction_dp[_aqueous_fluid_component] = -dX0_dp;
320  liquid.dmass_fraction_dp[_gas_fluid_component] = dX0_dp;
321  liquid.dmass_fraction_dT[_aqueous_fluid_component] = -dX0_dT;
322  liquid.dmass_fraction_dT[_gas_fluid_component] = dX0_dT;
323  liquid.dmass_fraction_dz[_aqueous_fluid_component] = -dX0_dz;
324  liquid.dmass_fraction_dz[_gas_fluid_component] = dX0_dz;
325 
326  gas.dmass_fraction_dp[_aqueous_fluid_component] = -dY0_dp;
327  gas.dmass_fraction_dp[_gas_fluid_component] = dY0_dp;
328  gas.dmass_fraction_dT[_aqueous_fluid_component] = -dY0_dT;
329  gas.dmass_fraction_dT[_gas_fluid_component] = dY0_dT;
330  gas.dmass_fraction_dz[_aqueous_fluid_component] = -dY0_dz;
331  gas.dmass_fraction_dz[_gas_fluid_component] = dY0_dz;
332 
333  liquid.dfluid_density_dp = dliquid_density_dp;
334  liquid.dfluid_density_dT = dliquid_density_dT;
335  liquid.dfluid_density_dz = dliquid_density_dz;
336  gas.dfluid_density_dp = dgas_density_dp;
337  gas.dfluid_density_dT = dgas_density_dT;
338  gas.dfluid_density_dz = dgas_density_dz;
339 
340  liquid.dfluid_viscosity_dp = dliquid_viscosity_dp;
341  liquid.dfluid_viscosity_dT = dliquid_viscosity_dT;
342  liquid.dfluid_viscosity_dz = dliquid_viscosity_dz;
343  gas.dfluid_viscosity_dp = dgas_viscosity_dp;
344  gas.dfluid_viscosity_dT = dgas_viscosity_dT;
345  gas.dfluid_viscosity_dz = dgas_viscosity_dz;
346  }
347 }
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)
const Water97FluidProperties & _water_fp
Fluid properties UserObject for water.
const SinglePhaseFluidPropertiesPT & _ncg_fp
Fluid properties UserObject for the NCG.
const MaterialProperty< Real > & _temperature
Temperature.
const Real _water_critical_temperature
Critical temperature of water (K)
void vaporPressure_dT(Real temperature, Real &psat, Real &dpsat_dT) const
Saturation pressure as a function of temperature and derivative wrt temperature.
virtual void rho_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT) const =0
Density and its derivatives wrt pressure and temperature.
const Real _Mh2o
Molar mass of water (kg/mol)
Real moleFractionToMassFraction(Real xmol) const
Convert mole fraction to mass fraction.
const VariableValue & _gas_porepressure
Porepressure.
virtual Real rho(Real pressure, Real temperature) const override
Density.
const MaterialProperty< std::vector< Real > > & _saturation_old
Old value of saturation.
virtual Real henryConstant(Real temperature) const =0
Henry&#39;s law constant for dissolution in water.
virtual void henryConstant_dT(Real temperature, Real &Kh, Real &dKh_dT) const =0
Henry&#39;s law constant for dissolution in water and derivative wrt temperature.
virtual Real capillaryPressure(Real saturation) const
Capillary pressure is calculated as a function of true saturation.
const unsigned int _gas_fluid_component
Fluid component number of the gas phase.
const PorousFlowCapillaryPressure & _pc_uo
Capillary pressure UserObject.
virtual void mu_drhoT_from_rho_T(Real density, Real temperature, Real ddensity_dT, Real &mu, Real &dmu_drho, Real &dmu_dT) const override
Dynamic viscosity and its derivatives wrt density and temperature.
std::vector< FluidStateProperties > _fsp
FluidStateProperties data structure.
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
virtual void mu_drhoT_from_rho_T(Real density, Real temperature, Real ddensity_dT, Real &mu, Real &dmu_drho, Real &dmu_dT) const =0
Dynamic viscosity and its derivatives wrt density and temperature.
const unsigned int _gas_phase_number
Phase number of the gas phase.
bool _is_initqp
Flag to indicate whether to calculate stateful properties.
virtual void rho_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT) const override
Density and its derivatives wrt pressure and temperature.
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
const Real _T_c2k
Conversion from degrees Celsius to degrees Kelvin.
const unsigned int _num_components
Number of components.
std::vector< const VariableValue * > _z
Total mass fraction(s) of the gas component(s) summed over all phases.
Real vaporMassFraction(std::vector< Real > &Ki) const
Solves Rachford-Rice equation to provide vapor mass fraction.
Real PorousFlowFluidStateFlashBase::vaporMassFraction ( std::vector< Real > &  Ki) const
protectedinherited

Solves Rachford-Rice equation to provide vapor mass fraction.

For two components, the analytical solution is used, while for cases with more than two components, a Newton-Raphson iterative solution is calculated.

Parameters
Kiequilibrium constants
Returns
vapor mass fraction

Definition at line 366 of file PorousFlowFluidStateFlashBase.C.

Referenced by thermophysicalProperties(), and PorousFlowFluidStateBrineCO2::thermophysicalProperties().

367 {
368  // Check that the size of the equilibrium constant vector is correct
369  if (Ki.size() != _num_components)
370  mooseError("The number of equilibrium components passed to vaporMassFraction is not correct");
371 
372  Real v;
373 
374  // If there are only two components, an analytical solution is possible
375  if (_num_components == 2)
376  v = ((*_z[0])[_qp] * (Ki[1] - Ki[0]) - (Ki[1] - 1.0)) / ((Ki[0] - 1.0) * (Ki[1] - 1.0));
377  else
378  {
379  // More than two components - solve the Rachford-Rice equation using
380  // Newton-Raphson method.
381  // Initial guess for vapor mass fraction
382  Real v0 = 0.5;
383  unsigned int iter = 0;
384 
385  while (std::abs(rachfordRice(v0, Ki)) > _nr_tol)
386  {
387  v0 = v0 - rachfordRice(v0, Ki) / rachfordRiceDeriv(v0, Ki);
388  iter++;
389 
390  if (iter > _nr_max_its)
391  break;
392  }
393  v = v0;
394  }
395  return v;
396 }
Real rachfordRiceDeriv(Real x, std::vector< Real > &Ki) const
Derivative of Rachford-Rice equation wrt vapor fraction.
const Real _nr_tol
Tolerance for Newton-Raphson iterations.
Real rachfordRice(Real x, std::vector< Real > &Ki) const
Rachford-Rice equation for vapor fraction.
const unsigned int _num_components
Number of components.
const Real _nr_max_its
Maximum number of iterations for the Newton-Raphson iterations.
std::vector< const VariableValue * > _z
Total mass fraction(s) of the gas component(s) summed over all phases.

Member Data Documentation

const unsigned int PorousFlowFluidStateFlashBase::_aqueous_fluid_component
protectedinherited
const unsigned int PorousFlowFluidStateFlashBase::_aqueous_phase_number
protectedinherited
MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowFluidStateFlashBase::_dfluid_density_dvar
protectedinherited

Derivative of the fluid density for each phase wrt PorousFlow variables.

Definition at line 177 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties(), and PorousFlowFluidStateFlashBase::setMaterialVectorSize().

MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowFluidStateFlashBase::_dfluid_viscosity_dvar
protectedinherited

Derivative of the fluid viscosity for each phase wrt PorousFlow variables.

Definition at line 181 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties(), and PorousFlowFluidStateFlashBase::setMaterialVectorSize().

MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowVariableBase::_dgradp_qp_dgradv
protectedinherited

d(grad porepressure)/d(grad PorousFlow variable) at the quadpoints

Definition at line 52 of file PorousFlowVariableBase.h.

MaterialProperty<std::vector<std::vector<RealGradient> > >* const PorousFlowVariableBase::_dgradp_qp_dv
protectedinherited

d(grad porepressure)/d(PorousFlow variable) at the quadpoints

Definition at line 55 of file PorousFlowVariableBase.h.

MaterialProperty<std::vector<std::vector<Real> > >* const PorousFlowVariableBase::_dgrads_qp_dgradv
protectedinherited

d(grad saturation)/d(grad PorousFlow variable) at the quadpoints

Definition at line 67 of file PorousFlowVariableBase.h.

MaterialProperty<std::vector<std::vector<RealGradient> > >* const PorousFlowVariableBase::_dgrads_qp_dv
protectedinherited

d(grad saturation)/d(PorousFlow variable) at the quadpoints

Definition at line 70 of file PorousFlowVariableBase.h.

MaterialProperty<std::vector<std::vector<std::vector<Real> > > >& PorousFlowFluidStateFlashBase::_dmass_frac_dvar
protectedinherited

Derivative of the mass fraction matrix with respect to the Porous Flow variables.

Definition at line 170 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties(), and PorousFlowFluidStateFlashBase::setMaterialVectorSize().

MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowVariableBase::_dporepressure_dvar
protectedinherited
MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowVariableBase::_dsaturation_dvar
protectedinherited
const MaterialProperty<std::vector<Real> >& PorousFlowFluidStateFlashBase::_dtemperature_dvar
protectedinherited

Derivative of temperature wrt PorousFlow variables.

Definition at line 164 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties().

MaterialProperty<std::vector<Real> >& PorousFlowFluidStateFlashBase::_fluid_density
protectedinherited
MaterialProperty<std::vector<Real> >& PorousFlowFluidStateFlashBase::_fluid_viscosity
protectedinherited
std::vector<FluidStateProperties> PorousFlowFluidStateFlashBase::_fsp
protectedinherited
const unsigned int PorousFlowFluidStateFlashBase::_gas_fluid_component
protectedinherited
const VariableGradient& PorousFlowFluidStateFlashBase::_gas_gradp_qp
protectedinherited

Gradient of porepressure (only defined at the qps)

Definition at line 136 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties().

const unsigned int PorousFlowFluidStateFlashBase::_gas_phase_number
protectedinherited
const VariableValue& PorousFlowFluidStateFlashBase::_gas_porepressure
protectedinherited
const unsigned int PorousFlowFluidStateFlashBase::_gas_porepressure_varnum
protectedinherited

Moose variable number of the gas porepressure.

Definition at line 138 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties().

MaterialProperty<std::vector<std::vector<RealGradient> > >* PorousFlowFluidStateFlashBase::_grad_mass_frac_qp
protectedinherited

Gradient of the mass fraction matrix (only defined at the qps)

Definition at line 168 of file PorousFlowFluidStateFlashBase.h.

MaterialProperty<std::vector<RealGradient> >* const PorousFlowVariableBase::_gradp_qp
protectedinherited

Grad(p) at the quadpoints.

Definition at line 49 of file PorousFlowVariableBase.h.

MaterialProperty<std::vector<RealGradient> >* const PorousFlowVariableBase::_grads_qp
protectedinherited

Grad(s) at the quadpoints.

Definition at line 64 of file PorousFlowVariableBase.h.

const MaterialProperty<RealGradient>& PorousFlowFluidStateFlashBase::_gradT_qp
protectedinherited

Gradient of temperature (only defined at the qps)

Definition at line 162 of file PorousFlowFluidStateFlashBase.h.

std::vector<const VariableGradient *> PorousFlowFluidStateFlashBase::_gradz_qp
protectedinherited

Gradient(s) of total mass fraction(s) of the gas component(s) (only defined at the qps)

Definition at line 144 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties(), and PorousFlowFluidStateFlashBase::PorousFlowFluidStateFlashBase().

bool PorousFlowFluidStateFlashBase::_is_initqp
protectedinherited
MaterialProperty<std::vector<std::vector<Real> > >& PorousFlowFluidStateFlashBase::_mass_frac
protectedinherited
const Real PorousFlowFluidStateWaterNCG::_Mh2o
protected

Molar mass of water (kg/mol)

Definition at line 57 of file PorousFlowFluidStateWaterNCG.h.

Referenced by moleFractionToMassFraction(), and thermophysicalProperties().

const Real PorousFlowFluidStateWaterNCG::_Mncg
protected

Molar mass of non-condensable gas (kg/mol)

Definition at line 59 of file PorousFlowFluidStateWaterNCG.h.

Referenced by enthalpyOfDissolution(), moleFractionToMassFraction(), and thermophysicalProperties().

const SinglePhaseFluidPropertiesPT& PorousFlowFluidStateWaterNCG::_ncg_fp
protected

Fluid properties UserObject for the NCG.

Definition at line 55 of file PorousFlowFluidStateWaterNCG.h.

Referenced by thermophysicalProperties().

const Real PorousFlowFluidStateFlashBase::_nr_max_its
protectedinherited

Maximum number of iterations for the Newton-Raphson iterations.

Definition at line 188 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::vaporMassFraction().

const Real PorousFlowFluidStateFlashBase::_nr_tol
protectedinherited

Tolerance for Newton-Raphson iterations.

Definition at line 190 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::vaporMassFraction().

const unsigned int PorousFlowVariableBase::_num_components
protectedinherited
const unsigned int PorousFlowVariableBase::_num_pf_vars
protectedinherited
const unsigned int PorousFlowVariableBase::_num_phases
protectedinherited
const unsigned int PorousFlowFluidStateFlashBase::_num_z_vars
protectedinherited
const PorousFlowCapillaryPressure& PorousFlowFluidStateFlashBase::_pc_uo
protectedinherited
MaterialProperty<std::vector<Real> >& PorousFlowVariableBase::_porepressure
protectedinherited
const unsigned int PorousFlowFluidStateFlashBase::_pvar
protectedinherited

PorousFlow variable number of the gas porepressure.

Definition at line 140 of file PorousFlowFluidStateFlashBase.h.

Referenced by PorousFlowFluidStateFlashBase::computeQpProperties().

const Real PorousFlowFluidStateFlashBase::_R
protectedinherited

Universal gas constant (J/mol/K)

Definition at line 186 of file PorousFlowFluidStateFlashBase.h.

Referenced by enthalpyOfDissolution().

MaterialProperty<std::vector<Real> >& PorousFlowVariableBase::_saturation
protectedinherited
const MaterialProperty<std::vector<Real> >& PorousFlowFluidStateFlashBase::_saturation_old
protectedinherited

Old value of saturation.

Definition at line 172 of file PorousFlowFluidStateFlashBase.h.

Referenced by thermophysicalProperties(), and PorousFlowFluidStateBrineCO2::thermophysicalProperties().

const Real PorousFlowFluidStateFlashBase::_T_c2k
protectedinherited
const MaterialProperty<Real>& PorousFlowFluidStateFlashBase::_temperature
protectedinherited
const Real PorousFlowFluidStateWaterNCG::_water_critical_temperature
protected

Critical temperature of water (K)

Definition at line 63 of file PorousFlowFluidStateWaterNCG.h.

Referenced by thermophysicalProperties().

const Water97FluidProperties& PorousFlowFluidStateWaterNCG::_water_fp
protected

Fluid properties UserObject for water.

Definition at line 53 of file PorousFlowFluidStateWaterNCG.h.

Referenced by PorousFlowFluidStateWaterNCG(), and thermophysicalProperties().

const Real PorousFlowFluidStateWaterNCG::_water_triple_temperature
protected

Triple point temperature of water (K)

Definition at line 61 of file PorousFlowFluidStateWaterNCG.h.

std::vector<const VariableValue *> PorousFlowFluidStateFlashBase::_z
protectedinherited
std::vector<unsigned int> PorousFlowFluidStateFlashBase::_z_varnum
protectedinherited
std::vector<unsigned int> PorousFlowFluidStateFlashBase::_zvar
protectedinherited

The documentation for this class was generated from the following files: