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

Specialized class for water and a non-condensable gas (NCG) Includes dissolution of gas in liquid water phase using Henry's law. More...

#include <PorousFlowWaterNCG.h>

Inheritance diagram for PorousFlowWaterNCG:
[legend]

Public Member Functions

 PorousFlowWaterNCG (const InputParameters &parameters)
 
virtual std::string fluidStateName () const override
 Name of FluidState. More...
 
void thermophysicalProperties (Real pressure, Real temperature, Real Xnacl, Real Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const override
 Determines the complete thermophysical state of the system for a given set of primary variables. More...
 
void equilibriumMassFractions (Real pressure, Real temperature, Real &Xncg, Real &dXncg_dp, Real &dXncg_dT, Real &Yh2o, Real &dYh2o_dp, Real &dYh2o_dT) const
 Mass fractions of NCG in liquid phase and H2O in gas phase at thermodynamic equilibrium. More...
 
void massFractions (Real pressure, Real temperature, Real Z, FluidStatePhaseEnum &phase_state, std::vector< FluidStateProperties > &fsp) const
 Mass fractions of NCG and H2O in both phases, as well as derivatives wrt PorousFlow variables. More...
 
void gasProperties (Real pressure, Real temperature, std::vector< FluidStateProperties > &fsp) const
 Gas density. More...
 
void liquidProperties (Real pressure, Real temperature, std::vector< FluidStateProperties > &fsp) const
 Liquid density. More...
 
void saturationTwoPhase (Real pressure, Real temperature, Real Z, std::vector< FluidStateProperties > &fsp) const
 Gas and liquid saturation in the two-phase region. More...
 
void enthalpyOfDissolution (Real temperature, Real &hdis, Real &dhdis_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...
 
virtual Real totalMassFraction (Real pressure, Real temperature, Real Xnacl, Real saturation, unsigned int qp) const override
 Total mass fraction of fluid component summed over all phases in the two-phase state for a specified gas saturation. More...
 
unsigned int numPhases () const
 The maximum number of phases in this model. More...
 
unsigned int numComponents () const
 The maximum number of components in this model. More...
 
unsigned int aqueousPhaseIndex () const
 The index of the aqueous phase. More...
 
unsigned int gasPhaseIndex () const
 The index of the gas phase. More...
 
unsigned int aqueousComponentIndex () const
 The index of the aqueous fluid component. More...
 
unsigned int gasComponentIndex () const
 The index of the gas fluid component. More...
 
unsigned int saltComponentIndex () const
 The index of the salt component. More...
 
void clearFluidStateProperties (std::vector< FluidStateProperties > &fsp) const
 Clears the contents of the FluidStateProperties data structure. More...
 
void initialize () final
 
void execute () final
 
void finalize () final
 
Real rachfordRice (Real vf, std::vector< Real > &Zi, std::vector< Real > &Ki) const
 Rachford-Rice equation for vapor fraction. More...
 
Real rachfordRiceDeriv (Real vf, std::vector< Real > &Zi, std::vector< Real > &Ki) const
 Derivative of Rachford-Rice equation wrt vapor fraction. More...
 
Real vaporMassFraction (Real Z0, Real K0, Real K1) const
 Solves Rachford-Rice equation to provide vapor mass fraction. More...
 
Real vaporMassFraction (std::vector< Real > &Zi, std::vector< Real > &Ki) const
 

Protected Member Functions

Real moleFractionToMassFraction (Real xmol) const
 Convert mole fraction to mass fraction. More...
 
void checkVariables (Real temperature) const
 Check that the temperature is between the triple and critical values. More...
 
void phaseState (Real Zi, Real Xi, Real Yi, FluidStatePhaseEnum &phase_state) const
 Determines the phase state gven the total mass fraction and equilibrium mass fractions. More...
 

Protected Attributes

const SinglePhaseFluidProperties_water_fp
 Fluid properties UserObject for water. More...
 
const SinglePhaseFluidProperties_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...
 
unsigned int _num_phases
 Number of phases. More...
 
unsigned int _num_components
 Number of components. More...
 
const unsigned int _aqueous_phase_number
 Phase number of the aqueous phase. More...
 
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...
 
unsigned int _gas_fluid_component
 Fluid component number of the gas phase. More...
 
const unsigned int _salt_component
 Salt component index. More...
 
const Real _R
 Universal gas constant (J/mol/K) More...
 
const Real _T_c2k
 Conversion from C to 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...
 
const PorousFlowCapillaryPressure_pc
 Capillary pressure UserObject. More...
 

Detailed Description

Specialized class for water and a non-condensable gas (NCG) Includes dissolution of gas in liquid water phase using Henry's law.

Notation convention Throughout this class, both mole fractions and mass fractions will be used. The following notation will be used: yk: mole fraction of component k in the gas phase xk: mole fraction of component k in the liquid phase Yk: mass fraction of component k in the gas phase Xk: mass fraction of component k in the liquid phase

Definition at line 33 of file PorousFlowWaterNCG.h.

Constructor & Destructor Documentation

◆ PorousFlowWaterNCG()

PorousFlowWaterNCG::PorousFlowWaterNCG ( const InputParameters &  parameters)

Definition at line 28 of file PorousFlowWaterNCG.C.

29  : PorousFlowFluidStateBase(parameters),
30  _water_fp(getUserObject<SinglePhaseFluidProperties>("water_fp")),
31  _ncg_fp(getUserObject<SinglePhaseFluidProperties>("gas_fp")),
36 {
37  // Check that the correct FluidProperties UserObjects have been provided
38  if (_water_fp.fluidName() != "water")
39  paramError("water_fp", "A valid water FluidProperties UserObject must be provided in water_fp");
40 
41  // Set the number of phases and components, and their indexes
42  _num_phases = 2;
43  _num_components = 2;
46 
47  // Check that _aqueous_phase_number is <= total number of phases
49  paramError("liquid_phase_number",
50  "This value is larger than the possible number of phases ",
51  _num_phases);
52 
53  // Check that _aqueous_fluid_component is <= total number of fluid components
55  paramError("liquid_fluid_component",
56  "This value is larger than the possible number of fluid components",
58 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
unsigned int _num_phases
Number of phases.
virtual Real triplePointTemperature() const
Triple point temperature.
virtual Real molarMass() const
Molar mass [kg/mol].
unsigned int _gas_phase_number
Phase number of the gas phase.
unsigned int _num_components
Number of components.
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
virtual Real criticalTemperature() const
Critical temperature.
const Real _Mh2o
Molar mass of water (kg/mol)
const Real _water_triple_temperature
Triple point temperature of water (K)
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
const Real _water_critical_temperature
Critical temperature of water (K)
PorousFlowFluidStateBase(const InputParameters &parameters)
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)
virtual std::string fluidName() const
Fluid name.
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

Member Function Documentation

◆ aqueousComponentIndex()

unsigned int PorousFlowFluidStateBase::aqueousComponentIndex ( ) const
inlineinherited

The index of the aqueous fluid component.

Returns
aqueous fluid component number

Definition at line 117 of file PorousFlowFluidStateBase.h.

117 { return _aqueous_fluid_component; };
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.

◆ aqueousPhaseIndex()

unsigned int PorousFlowFluidStateBase::aqueousPhaseIndex ( ) const
inlineinherited

The index of the aqueous phase.

Returns
aqueous phase number

Definition at line 105 of file PorousFlowFluidStateBase.h.

105 { return _aqueous_phase_number; };
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.

◆ checkVariables()

void PorousFlowWaterNCG::checkVariables ( Real  temperature) const
protected

Check that the temperature is between the triple and critical values.

Parameters
temperaturefluid temperature (K)

Definition at line 517 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties(), and totalMassFraction().

518 {
519  // Check whether the input temperature is within the region of validity of this equation
520  // of state (T_triple <= T <= T_critical)
521  if (temperature < _water_triple_temperature || temperature > _water_critical_temperature)
522  mooseException(name() + ": temperature " + Moose::stringify(temperature) +
523  " is outside range 273.16 K <= T <= 647.096 K");
524 }
const std::string temperature
Definition: NS.h:27
const std::string name
Definition: Setup.h:22
const Real _water_critical_temperature
Critical temperature of water (K)

◆ clearFluidStateProperties()

void PorousFlowFluidStateBase::clearFluidStateProperties ( std::vector< FluidStateProperties > &  fsp) const
inherited

Clears the contents of the FluidStateProperties data structure.

Parameters
[out]fspFluidStateProperties data structure with all data initialized to 0

Definition at line 41 of file PorousFlowFluidStateBase.C.

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

42 {
43  std::fill(fsp.begin(), fsp.end(), FluidStateProperties(_num_components));
44 }
unsigned int _num_components
Number of components.
Data structure to pass calculated thermophysical properties.

◆ enthalpyOfDissolution()

void PorousFlowWaterNCG::enthalpyOfDissolution ( Real  temperature,
Real &  hdis,
Real &  dhdis_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.

Phys. Chem. 63 (1959)

Parameters
temperaturefluid temperature (K)
[out]hdisenthalpy of dissolution (J/kg)
[out]dhdis_dTderivative of enthalpy of dissolution wrt temperature

Definition at line 527 of file PorousFlowWaterNCG.C.

Referenced by liquidProperties().

528 {
529  // Henry's constant
530  Real Kh, dKh_dT;
531  _ncg_fp.henryConstant_dT(temperature, Kh, dKh_dT);
532 
533  hdis = -_R * temperature * temperature * dKh_dT / Kh / _Mncg;
534 
535  // Derivative of enthalpy of dissolution wrt temperature requires the second derivative of
536  // Henry's constant wrt temperature. For simplicity, approximate this numerically
537  const Real dT = temperature * 1.0e-8;
538  const Real t2 = temperature + dT;
539  _ncg_fp.henryConstant_dT(t2, Kh, dKh_dT);
540 
541  dhdis_dT = (-_R * t2 * t2 * dKh_dT / Kh / _Mncg - hdis) / dT;
542 }
virtual void henryConstant_dT(Real temperature, Real &Kh, Real &dKh_dT) const
Henry&#39;s law constant for dissolution in water and derivative wrt temperature.
const std::string temperature
Definition: NS.h:27
const Real _R
Universal gas constant (J/mol/K)
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

◆ equilibriumMassFractions()

void PorousFlowWaterNCG::equilibriumMassFractions ( Real  pressure,
Real  temperature,
Real &  Xncg,
Real &  dXncg_dp,
Real &  dXncg_dT,
Real &  Yh2o,
Real &  dYh2o_dp,
Real &  dYh2o_dT 
) const

Mass fractions of NCG in liquid phase and H2O in gas phase at thermodynamic equilibrium.

Calculated using Henry's law (for NCG component), and Raoult's law (for water).

Parameters
pressurephase pressure (Pa)
temperaturephase temperature (C)
[out]Xncgmass fraction of NCG in liquid (kg/kg)
[out]dXncg_dpderivative of mass fraction of NCG in liquid wrt pressure
[out]dXncg_dTderivative of mass fraction of NCG in liqiud wrt temperature
[out]Yh2omass fraction of H2O in gas (kg/kg)
[out]dYh2o_dpderivative of mass fraction of NCG in gas wrt pressure
[out]dYh2o_dTderivative of mass fraction of NCG in gas wrt temperature

Definition at line 461 of file PorousFlowWaterNCG.C.

Referenced by massFractions(), and totalMassFraction().

469 {
470  // Equilibrium constants for each component (Henry's law for the NCG
471  // component, and Raoult's law for water).
472  Real Kh, dKh_dT, psat, dpsat_dT;
473  _ncg_fp.henryConstant_dT(temperature, Kh, dKh_dT);
474  _water_fp.vaporPressure_dT(temperature, psat, dpsat_dT);
475  const Real Kncg = Kh / pressure;
476  const Real Kh2o = psat / pressure;
477 
478  // The mole fractions for the NCG component in the two component
479  // case can be expressed in terms of the equilibrium constants only
480  const Real xncg = (1.0 - Kh2o) / (Kncg - Kh2o);
481  const Real yncg = Kncg * xncg;
482 
483  // Convert mole fractions to mass fractions
484  Xncg = moleFractionToMassFraction(xncg);
485  Yh2o = 1.0 - moleFractionToMassFraction(yncg);
486 
487  // Derivatives of mass fractions wrt PorousFlow variables
488  const Real dKncg_dp = -Kh / pressure / pressure;
489  const Real dKncg_dT = dKh_dT / pressure;
490 
491  const Real dKh2o_dp = -psat / pressure / pressure;
492  const Real dKh2o_dT = dpsat_dT / pressure;
493 
494  Real dxncg_dp = ((Kh2o - 1.0) * dKncg_dp + (1 - Kncg) * dKh2o_dp) / (Kncg - Kh2o) / (Kncg - Kh2o);
495  Real dyncg_dp = xncg * dKncg_dp + Kncg * dxncg_dp;
496  Real dxncg_dT = ((Kh2o - 1.0) * dKncg_dT + (1 - Kncg) * dKh2o_dT) / (Kncg - Kh2o) / (Kncg - Kh2o);
497  Real dyncg_dT = xncg * dKncg_dT + Kncg * dxncg_dT;
498 
499  Real dXncg_dxncg =
500  _Mncg * _Mh2o / (xncg * _Mncg + (1.0 - xncg) * _Mh2o) / (xncg * _Mncg + (1.0 - xncg) * _Mh2o);
501  Real dYncg_dyncg =
502  _Mncg * _Mh2o / (yncg * _Mncg + (1.0 - yncg) * _Mh2o) / (yncg * _Mncg + (1.0 - yncg) * _Mh2o);
503 
504  dXncg_dp = dXncg_dxncg * dxncg_dp;
505  dXncg_dT = dXncg_dxncg * dxncg_dT;
506  dYh2o_dp = -dYncg_dyncg * dyncg_dp;
507  dYh2o_dT = -dYncg_dyncg * dyncg_dT;
508 }
virtual void henryConstant_dT(Real temperature, Real &Kh, Real &dKh_dT) const
Henry&#39;s law constant for dissolution in water and derivative wrt temperature.
const std::string temperature
Definition: NS.h:27
virtual void vaporPressure_dT(Real temperature, Real &psat, Real &dpsat_dT) const
Vapor pressure.
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
const Real _Mh2o
Molar mass of water (kg/mol)
Real moleFractionToMassFraction(Real xmol) const
Convert mole fraction to mass fraction.
const std::string pressure
Definition: NS.h:26
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

◆ execute()

void PorousFlowFluidStateFlash::execute ( )
inlinefinalinherited

Definition at line 37 of file PorousFlowFluidStateFlash.h.

37 {};

◆ finalize()

void PorousFlowFluidStateFlash::finalize ( )
inlinefinalinherited

Definition at line 38 of file PorousFlowFluidStateFlash.h.

38 {};

◆ fluidStateName()

std::string PorousFlowWaterNCG::fluidStateName ( ) const
overridevirtual

Name of FluidState.

Implements PorousFlowFluidStateBase.

Definition at line 61 of file PorousFlowWaterNCG.C.

62 {
63  return "water-ncg";
64 }

◆ gasComponentIndex()

unsigned int PorousFlowFluidStateBase::gasComponentIndex ( ) const
inlineinherited

The index of the gas fluid component.

Returns
gas fluid component number

Definition at line 123 of file PorousFlowFluidStateBase.h.

123 { return _gas_fluid_component; };
unsigned int _gas_fluid_component
Fluid component number of the gas phase.

◆ gasPhaseIndex()

unsigned int PorousFlowFluidStateBase::gasPhaseIndex ( ) const
inlineinherited

The index of the gas phase.

Returns
gas phase number

Definition at line 111 of file PorousFlowFluidStateBase.h.

111 { return _gas_phase_number; };
unsigned int _gas_phase_number
Phase number of the gas phase.

◆ gasProperties()

void PorousFlowWaterNCG::gasProperties ( Real  pressure,
Real  temperature,
std::vector< FluidStateProperties > &  fsp 
) const

Gas density.

Parameters
pressuregas pressure (Pa)
temperaturetemperature (C)
[out]FluidStateDensitydata structure

Definition at line 223 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties(), and totalMassFraction().

226 {
229 
230  Real psat, dpsat_dT;
231  _water_fp.vaporPressure_dT(temperature, psat, dpsat_dT);
232 
233  const Real Yncg = gas.mass_fraction[_gas_fluid_component];
234  const Real dYncg_dp = gas.dmass_fraction_dp[_gas_fluid_component];
235  const Real dYncg_dT = gas.dmass_fraction_dT[_gas_fluid_component];
236  const Real dYncg_dZ = gas.dmass_fraction_dZ[_gas_fluid_component];
237 
238  const Real Xncg = liquid.mass_fraction[_gas_fluid_component];
239  const Real dXncg_dp = liquid.dmass_fraction_dp[_gas_fluid_component];
240  const Real dXncg_dT = liquid.dmass_fraction_dT[_gas_fluid_component];
241  const Real dXncg_dZ = liquid.dmass_fraction_dZ[_gas_fluid_component];
242 
243  // Note: take derivative wrt (Yncg * p) etc, hence the dp0
244  Real ncg_density, dncg_density_dp0, dncg_density_dT;
245  Real ncg_viscosity, dncg_viscosity_dp0, dncg_viscosity_dT;
246  Real ncg_enthalpy, dncg_enthalpy_dp0, dncg_enthalpy_dT;
247  Real vapor_density, dvapor_density_dp0, dvapor_density_dT;
248  Real vapor_viscosity, dvapor_viscosity_dp0, dvapor_viscosity_dT;
249  Real vapor_enthalpy, dvapor_enthalpy_dp0, dvapor_enthalpy_dT;
250 
251  // NCG density, viscosity and enthalpy calculated using partial pressure
252  // Yncg * gas_poreressure (Dalton's law)
253  _ncg_fp.rho_mu_dpT(Yncg * pressure,
254  temperature,
255  ncg_density,
256  dncg_density_dp0,
257  dncg_density_dT,
258  ncg_viscosity,
259  dncg_viscosity_dp0,
260  dncg_viscosity_dT);
261 
263  Yncg * pressure, temperature, ncg_enthalpy, dncg_enthalpy_dp0, dncg_enthalpy_dT);
264 
265  // Vapor density, viscosity and enthalpy calculated using partial pressure
266  // X1 * psat (Raoult's law)
267  _water_fp.rho_mu_dpT((1.0 - Xncg) * psat,
268  temperature,
269  vapor_density,
270  dvapor_density_dp0,
271  dvapor_density_dT,
272  vapor_viscosity,
273  dvapor_viscosity_dp0,
274  dvapor_viscosity_dT);
275 
277  (1.0 - Xncg) * psat, temperature, vapor_enthalpy, dvapor_enthalpy_dp0, dvapor_enthalpy_dT);
278 
279  // Derivative wrt Z by the chain rule
280  Real dncg_density_dZ = dYncg_dZ * pressure * dncg_density_dp0;
281  Real dvapor_density_dZ = -dXncg_dZ * psat * dvapor_density_dp0;
282  Real dncg_viscosity_dZ = dYncg_dZ * pressure * dncg_viscosity_dp0;
283  Real dvapor_viscosity_dZ = -dXncg_dZ * psat * dvapor_viscosity_dp0;
284  Real dncg_enthalpy_dZ = dYncg_dZ * pressure * dncg_enthalpy_dp0;
285  Real dvapor_enthalpy_dZ = -dXncg_dZ * psat * dvapor_enthalpy_dp0;
286 
287  // The derivatives wrt pressure and temperature above also depend on the derivative
288  // of the pressure variable using the chain rule
289  Real dncg_density_dp = (Yncg + dYncg_dp * pressure) * dncg_density_dp0;
290  dncg_density_dT += dYncg_dT * pressure * dncg_density_dp0;
291 
292  Real dvapor_density_dp = -dXncg_dp * psat * dvapor_density_dp0;
293  dvapor_density_dT += ((1.0 - Xncg) * dpsat_dT - dXncg_dT * psat) * dvapor_density_dp0;
294 
295  Real dncg_viscosity_dp = (Yncg + dYncg_dp * pressure) * dncg_viscosity_dp0;
296  dncg_viscosity_dT += dYncg_dT * pressure * dncg_viscosity_dp0;
297 
298  Real dvapor_viscosity_dp = -dXncg_dp * psat * dvapor_viscosity_dp0;
299  dvapor_viscosity_dT += ((1.0 - Xncg) * dpsat_dT - dXncg_dT * psat) * dvapor_viscosity_dp0;
300 
301  Real dncg_enthalpy_dp = (Yncg + dYncg_dp * pressure) * dncg_enthalpy_dp0;
302  dncg_enthalpy_dT += dYncg_dT * pressure * dncg_enthalpy_dp0;
303 
304  Real dvapor_enthalpy_dp = -dXncg_dp * psat * dvapor_enthalpy_dp0;
305  dvapor_enthalpy_dT += ((1.0 - Xncg) * dpsat_dT - dXncg_dT * psat) * dvapor_enthalpy_dp0;
306 
307  // Density is just the sum of individual component densities
308  gas.density = ncg_density + vapor_density;
309  gas.ddensity_dp = dncg_density_dp + dvapor_density_dp;
310  gas.ddensity_dT = dncg_density_dT + dvapor_density_dT;
311  gas.ddensity_dZ = dncg_density_dZ + dvapor_density_dZ;
312 
313  // Viscosity of the gas phase is a weighted sum of the individual viscosities
314  gas.viscosity = Yncg * ncg_viscosity + (1.0 - Yncg) * vapor_viscosity;
315  gas.dviscosity_dp = dYncg_dp * (ncg_viscosity - vapor_viscosity) + Yncg * dncg_viscosity_dp +
316  (1.0 - Yncg) * dvapor_viscosity_dp;
317  gas.dviscosity_dT = dYncg_dT * (ncg_viscosity - vapor_viscosity) + Yncg * dncg_viscosity_dT +
318  (1.0 - Yncg) * dvapor_viscosity_dT;
319  gas.dviscosity_dZ = dYncg_dZ * (ncg_viscosity - vapor_viscosity) + Yncg * dncg_viscosity_dZ +
320  (1.0 - Yncg) * dvapor_viscosity_dZ;
321 
322  // Enthalpy of the gas phase is a weighted sum of the individual enthalpies
323  gas.enthalpy = Yncg * ncg_enthalpy + (1.0 - Yncg) * vapor_enthalpy;
324  gas.denthalpy_dp = dYncg_dp * (ncg_enthalpy - vapor_enthalpy) + Yncg * dncg_enthalpy_dp +
325  (1.0 - Yncg) * dvapor_enthalpy_dp;
326  gas.denthalpy_dT = dYncg_dT * (ncg_enthalpy - vapor_enthalpy) + Yncg * dncg_enthalpy_dT +
327  (1.0 - Yncg) * dvapor_enthalpy_dT;
328  gas.denthalpy_dZ = dYncg_dZ * (ncg_enthalpy - vapor_enthalpy) + Yncg * dncg_enthalpy_dZ +
329  (1.0 - Yncg) * dvapor_enthalpy_dZ;
330 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
virtual void rho_mu_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT, Real &mu, Real &dmu_dp, Real &dmu_dT) const
Density and viscosity and their derivatives wrt pressure and temperature.
unsigned int _gas_phase_number
Phase number of the gas phase.
const std::string temperature
Definition: NS.h:27
std::vector< Real > dmass_fraction_dT
virtual void vaporPressure_dT(Real temperature, Real &psat, Real &dpsat_dT) const
Vapor pressure.
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
std::vector< Real > mass_fraction
Data structure to pass calculated thermophysical properties.
std::vector< Real > dmass_fraction_dZ
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
std::vector< Real > dmass_fraction_dp
const std::string pressure
Definition: NS.h:26
virtual Real h_from_p_T(Real p, Real T) const
Specific enthalpy from pressure and temperature.
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

◆ initialize()

void PorousFlowFluidStateFlash::initialize ( )
inlinefinalinherited

Definition at line 36 of file PorousFlowFluidStateFlash.h.

36 {};

◆ liquidProperties()

void PorousFlowWaterNCG::liquidProperties ( Real  pressure,
Real  temperature,
std::vector< FluidStateProperties > &  fsp 
) const

Liquid density.

Parameters
pressureliquid pressure (Pa)
temperaturetemperature (C)
[out]FluidStateDensitydata structure

Definition at line 333 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties(), and totalMassFraction().

336 {
338 
339  // Calculate liquid density and viscosity if in the two phase or single phase
340  // liquid region, assuming they are not affected by the presence of dissolved
341  // NCG. Note: the (small) contribution due to derivative of capillary pressure
342  // wrt pressure (using the chain rule) is not implemented.
343  Real liquid_density, dliquid_density_dp, dliquid_density_dT;
344  Real liquid_viscosity, dliquid_viscosity_dp, dliquid_viscosity_dT;
346  temperature,
347  liquid_density,
348  dliquid_density_dp,
349  dliquid_density_dT,
350  liquid_viscosity,
351  dliquid_viscosity_dp,
352  dliquid_viscosity_dT);
353 
354  liquid.density = liquid_density;
355  liquid.ddensity_dp = dliquid_density_dp;
356  liquid.ddensity_dT = dliquid_density_dT;
357  liquid.ddensity_dZ = 0.0;
358 
359  liquid.viscosity = liquid_viscosity;
360  liquid.dviscosity_dp = dliquid_viscosity_dp;
361  liquid.dviscosity_dT = dliquid_viscosity_dT;
362  liquid.dviscosity_dZ = 0.0;
363 
364  // Enthalpy does include a contribution due to the enthalpy of dissolution
365  Real hdis, dhdis_dT;
366  enthalpyOfDissolution(temperature, hdis, dhdis_dT);
367 
368  Real water_enthalpy, dwater_enthalpy_dp, dwater_enthalpy_dT;
370  pressure, temperature, water_enthalpy, dwater_enthalpy_dp, dwater_enthalpy_dT);
371 
372  // Enthalpy of gaseous CO2
373  Real ncg_enthalpy, dncg_enthalpy_dp, dncg_enthalpy_dT;
374  _ncg_fp.h_from_p_T(pressure, temperature, ncg_enthalpy, dncg_enthalpy_dp, dncg_enthalpy_dT);
375 
376  const Real Xncg = liquid.mass_fraction[_gas_fluid_component];
377  const Real dXncg_dp = liquid.dmass_fraction_dp[_gas_fluid_component];
378  const Real dXncg_dT = liquid.dmass_fraction_dT[_gas_fluid_component];
379  const Real dXncg_dZ = liquid.dmass_fraction_dZ[_gas_fluid_component];
380 
381  liquid.enthalpy = (1.0 - Xncg) * water_enthalpy + Xncg * (ncg_enthalpy + hdis);
382  liquid.denthalpy_dp = (1.0 - Xncg) * dwater_enthalpy_dp - dXncg_dp * water_enthalpy +
383  Xncg * dncg_enthalpy_dp + dXncg_dp * (ncg_enthalpy + hdis);
384  liquid.denthalpy_dT = (1.0 - Xncg) * dwater_enthalpy_dT - dXncg_dT * water_enthalpy +
385  Xncg * dncg_enthalpy_dT + dXncg_dT * (ncg_enthalpy + hdis) +
386  Xncg * dhdis_dT;
387  liquid.denthalpy_dZ = dXncg_dZ * (ncg_enthalpy + hdis - water_enthalpy);
388 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
virtual void rho_mu_dpT(Real pressure, Real temperature, Real &rho, Real &drho_dp, Real &drho_dT, Real &mu, Real &dmu_dp, Real &dmu_dT) const
Density and viscosity and their derivatives wrt pressure and temperature.
const std::string temperature
Definition: NS.h:27
std::vector< Real > dmass_fraction_dT
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
std::vector< Real > mass_fraction
Data structure to pass calculated thermophysical properties.
std::vector< Real > dmass_fraction_dZ
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
std::vector< Real > dmass_fraction_dp
const std::string pressure
Definition: NS.h:26
virtual Real h_from_p_T(Real p, Real T) const
Specific enthalpy from pressure and temperature.
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.
void enthalpyOfDissolution(Real temperature, Real &hdis, Real &dhdis_dT) const
Enthalpy of dissolution of NCG in water calculated using Henry&#39;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.

◆ massFractions()

void PorousFlowWaterNCG::massFractions ( Real  pressure,
Real  temperature,
Real  Z,
FluidStatePhaseEnum phase_state,
std::vector< FluidStateProperties > &  fsp 
) const

Mass fractions of NCG and H2O in both phases, as well as derivatives wrt PorousFlow variables.

Values depend on the phase state (liquid, gas or two phase)

Parameters
pressurephase pressure (Pa)
temperaturephase temperature (C)
Ztotal mass fraction of NCG component
[out]PhaseStateEnumcurrent phase state
[out]FluidStateMassFractionsdata structure

Definition at line 136 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties().

141 {
144 
145  // Equilibrium mass fraction of NCG in liquid and H2O in gas phases
146  Real Xncg, dXncg_dp, dXncg_dT, Yh2o, dYh2o_dp, dYh2o_dT;
148  pressure, temperature, Xncg, dXncg_dp, dXncg_dT, Yh2o, dYh2o_dp, dYh2o_dT);
149 
150  Real Yncg = 1.0 - Yh2o;
151  Real dYncg_dp = -dYh2o_dp;
152  Real dYncg_dT = -dYh2o_dT;
153 
154  // Determine which phases are present based on the value of Z
155  phaseState(Z, Xncg, Yncg, phase_state);
156 
157  // The equilibrium mass fractions calculated above are only correct in the two phase
158  // state. If only liquid or gas phases are present, the mass fractions are given by
159  // the total mass fraction Z.
160  Real Xh2o = 0.0;
161  Real dXncg_dZ = 0.0, dYncg_dZ = 0.0;
162 
163  switch (phase_state)
164  {
166  {
167  Xncg = Z;
168  Yncg = 0.0;
169  Xh2o = 1.0 - Z;
170  Yh2o = 0.0;
171  dXncg_dp = 0.0;
172  dXncg_dT = 0.0;
173  dXncg_dZ = 1.0;
174  dYncg_dp = 0.0;
175  dYncg_dT = 0.0;
176  break;
177  }
178 
180  {
181  Xncg = 0.0;
182  Yncg = Z;
183  Yh2o = 1.0 - Z;
184  dXncg_dp = 0.0;
185  dXncg_dT = 0.0;
186  dYncg_dZ = 1.0;
187  dYncg_dp = 0.0;
188  dYncg_dT = 0.0;
189  break;
190  }
191 
193  {
194  // Keep equilibrium mass fractions
195  Xh2o = 1.0 - Xncg;
196  break;
197  }
198  }
199 
200  // Save the mass fractions in the FluidStateMassFractions object
202  liquid.mass_fraction[_gas_fluid_component] = Xncg;
205 
206  // Save the derivatives wrt PorousFlow variables
207  liquid.dmass_fraction_dp[_aqueous_fluid_component] = -dXncg_dp;
208  liquid.dmass_fraction_dp[_gas_fluid_component] = dXncg_dp;
209  liquid.dmass_fraction_dT[_aqueous_fluid_component] = -dXncg_dT;
210  liquid.dmass_fraction_dT[_gas_fluid_component] = dXncg_dT;
211  liquid.dmass_fraction_dZ[_aqueous_fluid_component] = -dXncg_dZ;
212  liquid.dmass_fraction_dZ[_gas_fluid_component] = dXncg_dZ;
213 
215  gas.dmass_fraction_dp[_gas_fluid_component] = dYncg_dp;
217  gas.dmass_fraction_dT[_gas_fluid_component] = dYncg_dT;
219  gas.dmass_fraction_dZ[_gas_fluid_component] = dYncg_dZ;
220 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
unsigned int _gas_phase_number
Phase number of the gas phase.
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
void phaseState(Real Zi, Real Xi, Real Yi, FluidStatePhaseEnum &phase_state) const
Determines the phase state gven the total mass fraction and equilibrium mass fractions.
const std::string temperature
Definition: NS.h:27
std::vector< Real > dmass_fraction_dT
std::vector< Real > mass_fraction
Data structure to pass calculated thermophysical properties.
std::vector< Real > dmass_fraction_dZ
void equilibriumMassFractions(Real pressure, Real temperature, Real &Xncg, Real &dXncg_dp, Real &dXncg_dT, Real &Yh2o, Real &dYh2o_dp, Real &dYh2o_dT) const
Mass fractions of NCG in liquid phase and H2O in gas phase at thermodynamic equilibrium.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
std::vector< Real > dmass_fraction_dp
const std::string pressure
Definition: NS.h:26

◆ moleFractionToMassFraction()

Real PorousFlowWaterNCG::moleFractionToMassFraction ( Real  xmol) const
protected

Convert mole fraction to mass fraction.

Parameters
xmolmole fraction
Returns
mass fraction

Definition at line 511 of file PorousFlowWaterNCG.C.

Referenced by equilibriumMassFractions().

512 {
513  return xmol * _Mncg / (xmol * _Mncg + (1.0 - xmol) * _Mh2o);
514 }
const Real _Mh2o
Molar mass of water (kg/mol)
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)

◆ numComponents()

unsigned int PorousFlowFluidStateBase::numComponents ( ) const
inlineinherited

The maximum number of components in this model.

Returns
number of components

Definition at line 99 of file PorousFlowFluidStateBase.h.

99 { return _num_components; };
unsigned int _num_components
Number of components.

◆ numPhases()

unsigned int PorousFlowFluidStateBase::numPhases ( ) const
inlineinherited

The maximum number of phases in this model.

Returns
number of phases

Definition at line 93 of file PorousFlowFluidStateBase.h.

Referenced by PorousFlowFluidState::PorousFlowFluidState().

93 { return _num_phases; };
unsigned int _num_phases
Number of phases.

◆ phaseState()

void PorousFlowFluidStateFlash::phaseState ( Real  Zi,
Real  Xi,
Real  Yi,
FluidStatePhaseEnum phase_state 
) const
protectedinherited

Determines the phase state gven the total mass fraction and equilibrium mass fractions.

Parameters
Zitotal mass fraction
Xiequilibrium mass fraction in liquid
Yiequilibrium mass fraction in gas
[out]phase_statethe phase state (gas, liquid, two phase)

Definition at line 29 of file PorousFlowFluidStateFlash.C.

Referenced by massFractions(), and PorousFlowBrineCO2::massFractions().

33 {
34  if (Zi <= Xi)
35  {
36  // In this case, there is not enough component i to form a gas phase,
37  // so only a liquid phase is present
38  phase_state = FluidStatePhaseEnum::LIQUID;
39  }
40  else if (Zi > Xi && Zi < Yi)
41  {
42  // Two phases are present
43  phase_state = FluidStatePhaseEnum::TWOPHASE;
44  }
45  else // (Zi >= Yi)
46  {
47  // In this case, there is not enough water to form a liquid
48  // phase, so only a gas phase is present
49  phase_state = FluidStatePhaseEnum::GAS;
50  }
51 }

◆ rachfordRice()

Real PorousFlowFluidStateFlash::rachfordRice ( Real  vf,
std::vector< Real > &  Zi,
std::vector< Real > &  Ki 
) const
inherited

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
vfvapor fraction
Zimass fractions
Kiequilibrium constants
Returns
f(x)

Definition at line 54 of file PorousFlowFluidStateFlash.C.

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

57 {
58  const std::size_t num_z = Zi.size();
59  // Check that the sizes of the mass fractions and equilibrium constant vectors are correct
60  if (Ki.size() != num_z + 1)
61  mooseError("The number of mass fractions or equilibrium components passed to rachfordRice is "
62  "not correct");
63 
64  Real f = 0.0;
65  Real Z_total = 0.0;
66 
67  for (std::size_t i = 0; i < num_z; ++i)
68  {
69  f += Zi[i] * (Ki[i] - 1.0) / (1.0 + x * (Ki[i] - 1.0));
70  Z_total += Zi[i];
71  }
72 
73  // Add the last component (with total mass fraction = 1 - z_total)
74  f += (1.0 - Z_total) * (Ki[num_z] - 1.0) / (1.0 + x * (Ki[num_z] - 1.0));
75 
76  return f;
77 }

◆ rachfordRiceDeriv()

Real PorousFlowFluidStateFlash::rachfordRiceDeriv ( Real  vf,
std::vector< Real > &  Zi,
std::vector< Real > &  Ki 
) const
inherited

Derivative of Rachford-Rice equation wrt vapor fraction.

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

Parameters
vfvapor fraction
Zimass fractions
Kiequilibrium constants
Returns
f'(x)

Definition at line 80 of file PorousFlowFluidStateFlash.C.

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

83 {
84  const std::size_t num_Z = Zi.size();
85  // Check that the sizes of the mass fractions and equilibrium constant vectors are correct
86  if (Ki.size() != num_Z + 1)
87  mooseError("The number of mass fractions or equilibrium components passed to rachfordRice is "
88  "not correct");
89 
90  Real df = 0.0;
91  Real Z_total = 0.0;
92 
93  for (std::size_t i = 0; i < num_Z; ++i)
94  {
95  df -= Zi[i] * (Ki[i] - 1.0) * (Ki[i] - 1.0) / (1.0 + x * (Ki[i] - 1.0)) /
96  (1.0 + x * (Ki[i] - 1.0));
97  Z_total += Zi[i];
98  }
99 
100  // Add the last component (with total mass fraction = 1 - z_total)
101  df -= (1.0 - Z_total) * (Ki[num_Z] - 1.0) * (Ki[num_Z] - 1.0) / (1.0 + x * (Ki[num_Z] - 1.0)) /
102  (1.0 + x * (Ki[num_Z] - 1.0));
103 
104  return df;
105 }

◆ saltComponentIndex()

unsigned int PorousFlowFluidStateBase::saltComponentIndex ( ) const
inlineinherited

The index of the salt component.

Returns
salt component number

Definition at line 129 of file PorousFlowFluidStateBase.h.

129 { return _salt_component; };
const unsigned int _salt_component
Salt component index.

◆ saturationTwoPhase()

void PorousFlowWaterNCG::saturationTwoPhase ( Real  pressure,
Real  temperature,
Real  Z,
std::vector< FluidStateProperties > &  fsp 
) const

Gas and liquid saturation in the two-phase region.

Parameters
pressuregas pressure (Pa)
temperaturephase temperature (C)
Ztotal mass fraction of NCG component
[out]FluidStateSaturationdata structure

Definition at line 391 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties().

395 {
398 
399  // Mass fractions
400  const Real Xncg = liquid.mass_fraction[_gas_fluid_component];
401  const Real dXncg_dp = liquid.dmass_fraction_dp[_gas_fluid_component];
402  const Real dXncg_dT = liquid.dmass_fraction_dT[_gas_fluid_component];
403 
404  const Real Yncg = gas.mass_fraction[_gas_fluid_component];
405  const Real dYncg_dp = gas.dmass_fraction_dp[_gas_fluid_component];
406  const Real dYncg_dT = gas.dmass_fraction_dT[_gas_fluid_component];
407 
408  // Calculate the vapor mass fraction
409  const Real K0 = Yncg / Xncg;
410  const Real K1 = (1.0 - Yncg) / (1.0 - Xncg);
411  const Real vapor_mass_fraction = vaporMassFraction(Z, K0, K1);
412 
413  // Liquid density is a function of gas saturation through the capillary pressure
414  // curve, so approximate liquid pressure as gas pressure
415  const Real liquid_pressure = pressure;
416 
417  Real liquid_density, liquid_ddensity_dp, liquid_ddensity_dT;
419  liquid_pressure, temperature, liquid_density, liquid_ddensity_dp, liquid_ddensity_dT);
420 
421  // The gas saturation in the two phase case
422  gas.saturation = vapor_mass_fraction * liquid_density /
423  (gas.density + vapor_mass_fraction * (liquid_density - gas.density));
424 
425  const Real dv_dZ = (K1 - K0) / ((K0 - 1.0) * (K1 - 1.0));
426  const Real denominator = (gas.density + vapor_mass_fraction * (liquid_density - gas.density)) *
427  (gas.density + vapor_mass_fraction * (liquid_density - gas.density));
428 
429  const Real ds_dZ = gas.density * liquid_density * dv_dZ / denominator;
430 
431  const Real dK0_dp = (Xncg * dYncg_dp - Yncg * dXncg_dp) / Xncg / Xncg;
432  const Real dK0_dT = (Xncg * dYncg_dT - Yncg * dXncg_dT) / Xncg / Xncg;
433 
434  const Real dK1_dp =
435  ((1.0 - Yncg) * dXncg_dp - (1.0 - Xncg) * dYncg_dp) / (1.0 - Xncg) / (1.0 - Xncg);
436  const Real dK1_dT =
437  ((1.0 - Yncg) * dXncg_dT - (1.0 - Xncg) * dYncg_dT) / (1.0 - Xncg) / (1.0 - Xncg);
438 
439  const Real dv_dp =
440  Z * dK1_dp / (K1 - 1.0) / (K1 - 1.0) + (1.0 - Z) * dK0_dp / (K0 - 1.0) / (K0 - 1.0);
441 
442  Real ds_dp = gas.density * liquid_density * dv_dp +
443  vapor_mass_fraction * (1.0 - vapor_mass_fraction) *
444  (gas.density * liquid_ddensity_dp - gas.ddensity_dp * liquid_density);
445  ds_dp /= denominator;
446 
447  const Real dv_dT =
448  Z * dK1_dT / (K1 - 1.0) / (K1 - 1.0) + (1.0 - Z) * dK0_dT / (K0 - 1.0) / (K0 - 1.0);
449 
450  Real ds_dT = gas.density * liquid_density * dv_dT +
451  vapor_mass_fraction * (1.0 - vapor_mass_fraction) *
452  (gas.density * liquid_ddensity_dT - gas.ddensity_dT * liquid_density);
453  ds_dT /= denominator;
454 
455  gas.dsaturation_dp = ds_dp;
456  gas.dsaturation_dT = ds_dT;
457  gas.dsaturation_dZ = ds_dZ;
458 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
unsigned int _gas_phase_number
Phase number of the gas phase.
const std::string temperature
Definition: NS.h:27
std::vector< Real > dmass_fraction_dT
virtual Real rho_from_p_T(Real p, Real T) const
Density from pressure and temperature.
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
std::vector< Real > mass_fraction
Data structure to pass calculated thermophysical properties.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
std::vector< Real > dmass_fraction_dp
Real vaporMassFraction(Real Z0, Real K0, Real K1) const
Solves Rachford-Rice equation to provide vapor mass fraction.
const std::string pressure
Definition: NS.h:26

◆ thermophysicalProperties()

void PorousFlowWaterNCG::thermophysicalProperties ( Real  pressure,
Real  temperature,
Real  Xnacl,
Real  Z,
unsigned int  qp,
std::vector< FluidStateProperties > &  fsp 
) const
overridevirtual

Determines the complete thermophysical state of the system for a given set of primary variables.

Parameters
pressuregas phase pressure (Pa)
temperaturefluid temperature (K)
Xnaclmass fraction of NaCl
Ztotal mass fraction of fluid component
qpquadpoint index
[out]fspthe FluidStateProperties struct containing all properties

Implements PorousFlowFluidStateBase.

Definition at line 67 of file PorousFlowWaterNCG.C.

73 {
76 
77  // Check whether the input temperature is within the region of validity
79 
80  // Clear all of the FluidStateProperties data
82 
83  FluidStatePhaseEnum phase_state;
84  massFractions(pressure, temperature, Z, phase_state, fsp);
85 
86  switch (phase_state)
87  {
89  {
90  // Set the gas saturations
91  gas.saturation = 1.0;
92 
93  // Calculate gas properties
95 
96  break;
97  }
98 
100  {
101  // Calculate the liquid properties
102  Real liquid_pressure = pressure - _pc.capillaryPressure(1.0, qp);
103  liquidProperties(liquid_pressure, temperature, fsp);
104 
105  break;
106  }
107 
109  {
110  // Calculate the gas properties
112 
113  // Calculate the saturation
115 
116  // Calculate the liquid properties
117  Real liquid_pressure = pressure - _pc.capillaryPressure(1.0 - gas.saturation, qp);
118  liquidProperties(liquid_pressure, temperature, fsp);
119 
120  break;
121  }
122  }
123 
124  // Liquid saturations can now be set
125  liquid.saturation = 1.0 - gas.saturation;
126  liquid.dsaturation_dp = -gas.dsaturation_dp;
127  liquid.dsaturation_dT = -gas.dsaturation_dT;
128  liquid.dsaturation_dZ = -gas.dsaturation_dZ;
129 
130  // Save pressures to FluidStateProperties object
131  gas.pressure = pressure;
132  liquid.pressure = pressure - _pc.capillaryPressure(liquid.saturation, qp);
133 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
void gasProperties(Real pressure, Real temperature, std::vector< FluidStateProperties > &fsp) const
Gas density.
FluidStatePhaseEnum
Phase state enum.
void saturationTwoPhase(Real pressure, Real temperature, Real Z, std::vector< FluidStateProperties > &fsp) const
Gas and liquid saturation in the two-phase region.
unsigned int _gas_phase_number
Phase number of the gas phase.
void clearFluidStateProperties(std::vector< FluidStateProperties > &fsp) const
Clears the contents of the FluidStateProperties data structure.
const std::string temperature
Definition: NS.h:27
virtual Real capillaryPressure(Real saturation, unsigned qp=0) const
Capillary pressure is calculated as a function of true saturation.
void liquidProperties(Real pressure, Real temperature, std::vector< FluidStateProperties > &fsp) const
Liquid density.
Data structure to pass calculated thermophysical properties.
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
void checkVariables(Real temperature) const
Check that the temperature is between the triple and critical values.
const std::string pressure
Definition: NS.h:26
void massFractions(Real pressure, Real temperature, Real Z, FluidStatePhaseEnum &phase_state, std::vector< FluidStateProperties > &fsp) const
Mass fractions of NCG and H2O in both phases, as well as derivatives wrt PorousFlow variables...

◆ totalMassFraction()

Real PorousFlowWaterNCG::totalMassFraction ( Real  pressure,
Real  temperature,
Real  Xnacl,
Real  saturation,
unsigned int  qp 
) const
overridevirtual

Total mass fraction of fluid component summed over all phases in the two-phase state for a specified gas saturation.

Parameters
pressuregas pressure (Pa)
temperaturetemperature (K)
XnaclNaCl mass fraction (kg/kg)
saturationgas saturation (-)
qpquadpoint index
Returns
total mass fraction Z (-)

Implements PorousFlowFluidStateBase.

Definition at line 545 of file PorousFlowWaterNCG.C.

547 {
548  // Check whether the input temperature is within the region of validity
550 
551  // FluidStateProperties data structure
552  std::vector<FluidStateProperties> fsp(_num_phases, FluidStateProperties(_num_components));
555 
556  // Calculate equilibrium mass fractions in the two-phase state
557  Real Xncg, dXncg_dp, dXncg_dT, Yh2o, dYh2o_dp, dYh2o_dT;
559  pressure, temperature, Xncg, dXncg_dp, dXncg_dT, Yh2o, dYh2o_dp, dYh2o_dT);
560 
561  // Save the mass fractions in the FluidStateMassFractions object
562  const Real Yncg = 1.0 - Yh2o;
563  liquid.mass_fraction[_aqueous_fluid_component] = 1.0 - Xncg;
564  liquid.mass_fraction[_gas_fluid_component] = Xncg;
567 
568  // Gas properties
570 
571  // Liquid properties
572  const Real liquid_saturation = 1.0 - saturation;
573  const Real liquid_pressure = pressure - _pc.capillaryPressure(liquid_saturation, qp);
574  liquidProperties(liquid_pressure, temperature, fsp);
575 
576  // The total mass fraction of ncg (Z) can now be calculated
577  const Real Z = (saturation * gas.density * Yncg + liquid_saturation * liquid.density * Xncg) /
578  (saturation * gas.density + liquid_saturation * liquid.density);
579 
580  return Z;
581 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
unsigned int _num_phases
Number of phases.
void gasProperties(Real pressure, Real temperature, std::vector< FluidStateProperties > &fsp) const
Gas density.
unsigned int _gas_phase_number
Phase number of the gas phase.
unsigned int _num_components
Number of components.
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
const std::string temperature
Definition: NS.h:27
virtual Real capillaryPressure(Real saturation, unsigned qp=0) const
Capillary pressure is calculated as a function of true saturation.
std::vector< Real > mass_fraction
void liquidProperties(Real pressure, Real temperature, std::vector< FluidStateProperties > &fsp) const
Liquid density.
Data structure to pass calculated thermophysical properties.
void equilibriumMassFractions(Real pressure, Real temperature, Real &Xncg, Real &dXncg_dp, Real &dXncg_dT, Real &Yh2o, Real &dYh2o_dp, Real &dYh2o_dT) const
Mass fractions of NCG in liquid phase and H2O in gas phase at thermodynamic equilibrium.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
void checkVariables(Real temperature) const
Check that the temperature is between the triple and critical values.
const std::string pressure
Definition: NS.h:26

◆ vaporMassFraction() [1/2]

Real PorousFlowFluidStateFlash::vaporMassFraction ( Real  Z0,
Real  K0,
Real  K1 
) const
inherited

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
Zitotal mass fraction(s)
Kiequilibrium constant(s)
Returns
vapor mass fraction

Definition at line 108 of file PorousFlowFluidStateFlash.C.

Referenced by saturationTwoPhase(), PorousFlowBrineCO2::saturationTwoPhase(), and PorousFlowFluidStateFlash::vaporMassFraction().

109 {
110  return (Z0 * (K1 - K0) - (K1 - 1.0)) / ((K0 - 1.0) * (K1 - 1.0));
111 }

◆ vaporMassFraction() [2/2]

Real PorousFlowFluidStateFlash::vaporMassFraction ( std::vector< Real > &  Zi,
std::vector< Real > &  Ki 
) const
inherited

Definition at line 114 of file PorousFlowFluidStateFlash.C.

115 {
116  // Check that the sizes of the mass fractions and equilibrium constant vectors are correct
117  if (Ki.size() != Zi.size() + 1)
118  mooseError("The number of mass fractions or equilibrium components passed to rachfordRice is "
119  "not correct");
120  Real v;
121 
122  // If there are only two components, an analytical solution is possible
123  if (Ki.size() == 2)
124  v = vaporMassFraction(Zi[0], Ki[0], Ki[1]);
125  else
126  {
127  // More than two components - solve the Rachford-Rice equation using
128  // Newton-Raphson method
129  // Initial guess for vapor mass fraction
130  Real v0 = 0.5;
131  unsigned int iter = 0;
132 
133  while (std::abs(rachfordRice(v0, Zi, Ki)) > _nr_tol)
134  {
135  v0 = v0 - rachfordRice(v0, Zi, Ki) / rachfordRiceDeriv(v0, Zi, Ki);
136  iter++;
137 
138  if (iter > _nr_max_its)
139  break;
140  }
141  v = v0;
142  }
143  return v;
144 }
Real rachfordRice(Real vf, std::vector< Real > &Zi, std::vector< Real > &Ki) const
Rachford-Rice equation for vapor fraction.
Real vaporMassFraction(Real Z0, Real K0, Real K1) const
Solves Rachford-Rice equation to provide vapor mass fraction.
const Real _nr_tol
Tolerance for Newton-Raphson iterations.
Real rachfordRiceDeriv(Real vf, std::vector< Real > &Zi, std::vector< Real > &Ki) const
Derivative of Rachford-Rice equation wrt vapor fraction.
const Real _nr_max_its
Maximum number of iterations for the Newton-Raphson routine.

Member Data Documentation

◆ _aqueous_fluid_component

const unsigned int PorousFlowFluidStateBase::_aqueous_fluid_component
protectedinherited

◆ _aqueous_phase_number

const unsigned int PorousFlowFluidStateBase::_aqueous_phase_number
protectedinherited

◆ _gas_fluid_component

unsigned int PorousFlowFluidStateBase::_gas_fluid_component
protectedinherited

◆ _gas_phase_number

unsigned int PorousFlowFluidStateBase::_gas_phase_number
protectedinherited

◆ _Mh2o

const Real PorousFlowWaterNCG::_Mh2o
protected

Molar mass of water (kg/mol)

Definition at line 151 of file PorousFlowWaterNCG.h.

Referenced by equilibriumMassFractions(), and moleFractionToMassFraction().

◆ _Mncg

const Real PorousFlowWaterNCG::_Mncg
protected

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

Definition at line 153 of file PorousFlowWaterNCG.h.

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

◆ _ncg_fp

const SinglePhaseFluidProperties& PorousFlowWaterNCG::_ncg_fp
protected

Fluid properties UserObject for the NCG.

Definition at line 149 of file PorousFlowWaterNCG.h.

Referenced by enthalpyOfDissolution(), equilibriumMassFractions(), gasProperties(), and liquidProperties().

◆ _nr_max_its

const Real PorousFlowFluidStateBase::_nr_max_its
protectedinherited

Maximum number of iterations for the Newton-Raphson iterations.

Definition at line 194 of file PorousFlowFluidStateBase.h.

◆ _nr_tol

const Real PorousFlowFluidStateBase::_nr_tol
protectedinherited

Tolerance for Newton-Raphson iterations.

Definition at line 196 of file PorousFlowFluidStateBase.h.

◆ _num_components

unsigned int PorousFlowFluidStateBase::_num_components
protectedinherited

◆ _num_phases

unsigned int PorousFlowFluidStateBase::_num_phases
protectedinherited

◆ _pc

const PorousFlowCapillaryPressure& PorousFlowFluidStateBase::_pc
protectedinherited

◆ _R

const Real PorousFlowFluidStateBase::_R
protectedinherited

Universal gas constant (J/mol/K)

Definition at line 190 of file PorousFlowFluidStateBase.h.

Referenced by enthalpyOfDissolution(), and PorousFlowBrineCO2::enthalpyOfDissolutionGas().

◆ _salt_component

const unsigned int PorousFlowFluidStateBase::_salt_component
protectedinherited

Salt component index.

Definition at line 188 of file PorousFlowFluidStateBase.h.

Referenced by PorousFlowFluidStateBase::saltComponentIndex().

◆ _T_c2k

const Real PorousFlowFluidStateBase::_T_c2k
protectedinherited

◆ _water_critical_temperature

const Real PorousFlowWaterNCG::_water_critical_temperature
protected

Critical temperature of water (K)

Definition at line 157 of file PorousFlowWaterNCG.h.

Referenced by checkVariables().

◆ _water_fp

const SinglePhaseFluidProperties& PorousFlowWaterNCG::_water_fp
protected

Fluid properties UserObject for water.

Definition at line 147 of file PorousFlowWaterNCG.h.

Referenced by equilibriumMassFractions(), gasProperties(), liquidProperties(), PorousFlowWaterNCG(), and saturationTwoPhase().

◆ _water_triple_temperature

const Real PorousFlowWaterNCG::_water_triple_temperature
protected

Triple point temperature of water (K)

Definition at line 155 of file PorousFlowWaterNCG.h.


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