www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
PorousFlowFluidStateMultiComponentBase Class Referenceabstract

Compositional flash routines for miscible multiphase flow classes with multiple fluid components. More...

#include <PorousFlowFluidStateMultiComponentBase.h>

Inheritance diagram for PorousFlowFluidStateMultiComponentBase:
[legend]

Public Member Functions

 PorousFlowFluidStateMultiComponentBase (const InputParameters &parameters)
 
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...
 
virtual void thermophysicalProperties (Real pressure, Real temperature, Real Xnacl, Real Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const =0
 Determines the complete thermophysical state of the system for a given set of primary variables. More...
 
virtual Real totalMassFraction (Real pressure, Real temperature, Real Xnacl, Real saturation, unsigned int qp) const =0
 Total mass fraction of fluid component summed over all phases in the two-phase state for a specified gas saturation. More...
 
unsigned int getPressureIndex () const
 
unsigned int getTemperatureIndex () const
 
unsigned int getZIndex () const
 
unsigned int getXIndex () const
 
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...
 
DualReal vaporMassFraction (const DualReal &Z0, const DualReal &K0, const DualReal &K1) const
 
Real vaporMassFraction (std::vector< Real > &Zi, std::vector< Real > &Ki) const
 
void initialize () final
 
void execute () final
 
void finalize () final
 
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...
 
virtual std::string fluidStateName () const =0
 Name of FluidState. More...
 
void clearFluidStateProperties (std::vector< FluidStateProperties > &fsp) const
 Clears the contents of the FluidStateProperties data structure. More...
 

Protected Attributes

const unsigned int _pidx
 Index of derivative wrt pressure. More...
 
const unsigned int _Zidx
 Index of derivative wrt total mass fraction Z. More...
 
const unsigned int _Tidx
 Index of derivative wrt temperature. More...
 
const unsigned int _Xidx
 Index of derivative wrt salt mass fraction X. More...
 
const Real _nr_max_its
 Maximum number of iterations for the Newton-Raphson routine. More...
 
const Real _nr_tol
 Tolerance for Newton-Raphson iterations. 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 PorousFlowCapillaryPressure_pc
 Capillary pressure UserObject. More...
 
FluidStateProperties _empty_fsp
 Empty FluidStateProperties object. More...
 

Detailed Description

Compositional flash routines for miscible multiphase flow classes with multiple fluid components.

Definition at line 23 of file PorousFlowFluidStateMultiComponentBase.h.

Constructor & Destructor Documentation

◆ PorousFlowFluidStateMultiComponentBase()

PorousFlowFluidStateMultiComponentBase::PorousFlowFluidStateMultiComponentBase ( const InputParameters &  parameters)

Definition at line 21 of file PorousFlowFluidStateMultiComponentBase.C.

23  : PorousFlowFluidStateFlash(parameters), _pidx(0), _Zidx(1), _Tidx(2), _Xidx(3)
24 {
25 }

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 92 of file PorousFlowFluidStateBase.h.

92 { return _aqueous_fluid_component; };

◆ aqueousPhaseIndex()

unsigned int PorousFlowFluidStateBase::aqueousPhaseIndex ( ) const
inlineinherited

The index of the aqueous phase.

Returns
aqueous phase number

Definition at line 80 of file PorousFlowFluidStateBase.h.

80 { return _aqueous_phase_number; };

◆ 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 39 of file PorousFlowFluidStateBase.C.

40 {
41  std::fill(fsp.begin(), fsp.end(), _empty_fsp);
42 }

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

◆ execute()

void PorousFlowFluidStateBase::execute ( )
inlinefinalinherited

Definition at line 61 of file PorousFlowFluidStateBase.h.

61 {};

◆ finalize()

void PorousFlowFluidStateBase::finalize ( )
inlinefinalinherited

Definition at line 62 of file PorousFlowFluidStateBase.h.

62 {};

◆ fluidStateName()

virtual std::string PorousFlowFluidStateBase::fluidStateName ( ) const
pure virtualinherited

Name of FluidState.

Implemented in PorousFlowBrineCO2, PorousFlowWaterNCG, and PorousFlowWaterVapor.

◆ gasComponentIndex()

unsigned int PorousFlowFluidStateBase::gasComponentIndex ( ) const
inlineinherited

The index of the gas fluid component.

Returns
gas fluid component number

Definition at line 98 of file PorousFlowFluidStateBase.h.

98 { return _gas_fluid_component; };

◆ gasPhaseIndex()

unsigned int PorousFlowFluidStateBase::gasPhaseIndex ( ) const
inlineinherited

The index of the gas phase.

Returns
gas phase number

Definition at line 86 of file PorousFlowFluidStateBase.h.

86 { return _gas_phase_number; };

◆ getPressureIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getPressureIndex ( ) const
inline

Definition at line 70 of file PorousFlowFluidStateMultiComponentBase.h.

70 { return _pidx; };

◆ getTemperatureIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getTemperatureIndex ( ) const
inline

Definition at line 71 of file PorousFlowFluidStateMultiComponentBase.h.

71 { return _Tidx; };

◆ getXIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getXIndex ( ) const
inline

Definition at line 73 of file PorousFlowFluidStateMultiComponentBase.h.

73 { return _Xidx; };

◆ getZIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getZIndex ( ) const
inline

Definition at line 72 of file PorousFlowFluidStateMultiComponentBase.h.

72 { return _Zidx; };

◆ initialize()

void PorousFlowFluidStateBase::initialize ( )
inlinefinalinherited

Definition at line 60 of file PorousFlowFluidStateBase.h.

60 {};

◆ numComponents()

unsigned int PorousFlowFluidStateBase::numComponents ( ) const
inlineinherited

The maximum number of components in this model.

Returns
number of components

Definition at line 74 of file PorousFlowFluidStateBase.h.

74 { return _num_components; };

◆ numPhases()

unsigned int PorousFlowFluidStateBase::numPhases ( ) const
inlineinherited

The maximum number of phases in this model.

Returns
number of phases

Definition at line 68 of file PorousFlowFluidStateBase.h.

68 { return _num_phases; };

Referenced by PorousFlowFluidState::PorousFlowFluidState(), and PorousFlowFluidStateSingleComponent::PorousFlowFluidStateSingleComponent().

◆ phaseState()

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

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 28 of file PorousFlowFluidStateMultiComponentBase.C.

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

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

◆ 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 27 of file PorousFlowFluidStateFlash.C.

30 {
31  const std::size_t num_z = Zi.size();
32  // Check that the sizes of the mass fractions and equilibrium constant vectors are correct
33  if (Ki.size() != num_z + 1)
34  mooseError("The number of mass fractions or equilibrium components passed to rachfordRice is "
35  "not correct");
36 
37  Real f = 0.0;
38  Real Z_total = 0.0;
39 
40  for (std::size_t i = 0; i < num_z; ++i)
41  {
42  f += Zi[i] * (Ki[i] - 1.0) / (1.0 + x * (Ki[i] - 1.0));
43  Z_total += Zi[i];
44  }
45 
46  // Add the last component (with total mass fraction = 1 - z_total)
47  f += (1.0 - Z_total) * (Ki[num_z] - 1.0) / (1.0 + x * (Ki[num_z] - 1.0));
48 
49  return f;
50 }

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

◆ 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 53 of file PorousFlowFluidStateFlash.C.

56 {
57  const std::size_t num_Z = Zi.size();
58  // Check that the sizes of the mass fractions and equilibrium constant vectors are correct
59  if (Ki.size() != num_Z + 1)
60  mooseError("The number of mass fractions or equilibrium components passed to rachfordRice is "
61  "not correct");
62 
63  Real df = 0.0;
64  Real Z_total = 0.0;
65 
66  for (std::size_t i = 0; i < num_Z; ++i)
67  {
68  df -= Zi[i] * (Ki[i] - 1.0) * (Ki[i] - 1.0) / (1.0 + x * (Ki[i] - 1.0)) /
69  (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  df -= (1.0 - Z_total) * (Ki[num_Z] - 1.0) * (Ki[num_Z] - 1.0) / (1.0 + x * (Ki[num_Z] - 1.0)) /
75  (1.0 + x * (Ki[num_Z] - 1.0));
76 
77  return df;
78 }

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

◆ saltComponentIndex()

unsigned int PorousFlowFluidStateBase::saltComponentIndex ( ) const
inlineinherited

The index of the salt component.

Returns
salt component number

Definition at line 104 of file PorousFlowFluidStateBase.h.

104 { return _salt_component; };

◆ thermophysicalProperties()

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

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

Implemented in PorousFlowBrineCO2, and PorousFlowWaterNCG.

Referenced by PorousFlowFluidState::thermophysicalProperties().

◆ totalMassFraction()

virtual Real PorousFlowFluidStateMultiComponentBase::totalMassFraction ( Real  pressure,
Real  temperature,
Real  Xnacl,
Real  saturation,
unsigned int  qp 
) const
pure virtual

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 (-)

Implemented in PorousFlowBrineCO2, and PorousFlowWaterNCG.

Referenced by PorousFlowFluidStateIC::value().

◆ vaporMassFraction() [1/3]

DualReal PorousFlowFluidStateFlash::vaporMassFraction ( const DualReal &  Z0,
const DualReal &  K0,
const DualReal &  K1 
) const
inherited

Definition at line 87 of file PorousFlowFluidStateFlash.C.

90 {
91  return (Z0 * (K1 - K0) - (K1 - 1.0)) / ((K0 - 1.0) * (K1 - 1.0));
92 }

◆ vaporMassFraction() [2/3]

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 81 of file PorousFlowFluidStateFlash.C.

82 {
83  return (Z0 * (K1 - K0) - (K1 - 1.0)) / ((K0 - 1.0) * (K1 - 1.0));
84 }

Referenced by PorousFlowWaterNCG::saturation(), PorousFlowBrineCO2::saturation(), and PorousFlowFluidStateFlash::vaporMassFraction().

◆ vaporMassFraction() [3/3]

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

Definition at line 95 of file PorousFlowFluidStateFlash.C.

96 {
97  // Check that the sizes of the mass fractions and equilibrium constant vectors are correct
98  if (Ki.size() != Zi.size() + 1)
99  mooseError("The number of mass fractions or equilibrium components passed to rachfordRice is "
100  "not correct");
101  Real v;
102 
103  // If there are only two components, an analytical solution is possible
104  if (Ki.size() == 2)
105  v = vaporMassFraction(Zi[0], Ki[0], Ki[1]);
106  else
107  {
108  // More than two components - solve the Rachford-Rice equation using
109  // Newton-Raphson method
110  // Initial guess for vapor mass fraction
111  Real v0 = 0.5;
112  unsigned int iter = 0;
113 
114  while (std::abs(rachfordRice(v0, Zi, Ki)) > _nr_tol)
115  {
116  v0 = v0 - rachfordRice(v0, Zi, Ki) / rachfordRiceDeriv(v0, Zi, Ki);
117  iter++;
118 
119  if (iter > _nr_max_its)
120  break;
121  }
122  v = v0;
123  }
124  return v;
125 }

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

◆ _empty_fsp

FluidStateProperties PorousFlowFluidStateBase::_empty_fsp
protectedinherited

◆ _gas_fluid_component

unsigned int PorousFlowFluidStateBase::_gas_fluid_component
protectedinherited

◆ _gas_phase_number

unsigned int PorousFlowFluidStateBase::_gas_phase_number
protectedinherited

◆ _nr_max_its

const Real PorousFlowFluidStateFlash::_nr_max_its
protectedinherited

Maximum number of iterations for the Newton-Raphson routine.

Definition at line 80 of file PorousFlowFluidStateFlash.h.

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

◆ _nr_tol

const Real PorousFlowFluidStateFlash::_nr_tol
protectedinherited

Tolerance for Newton-Raphson iterations.

Definition at line 82 of file PorousFlowFluidStateFlash.h.

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

◆ _num_components

unsigned int PorousFlowFluidStateBase::_num_components
protectedinherited

◆ _num_phases

unsigned int PorousFlowFluidStateBase::_num_phases
protectedinherited

◆ _pc

const PorousFlowCapillaryPressure& PorousFlowFluidStateBase::_pc
protectedinherited

◆ _pidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_pidx
protected

◆ _R

const Real PorousFlowFluidStateBase::_R
protectedinherited

Universal gas constant (J/mol/K)

Definition at line 133 of file PorousFlowFluidStateBase.h.

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

◆ _salt_component

const unsigned int PorousFlowFluidStateBase::_salt_component
protectedinherited

Salt component index.

Definition at line 131 of file PorousFlowFluidStateBase.h.

Referenced by PorousFlowFluidStateBase::saltComponentIndex().

◆ _T_c2k

const Real PorousFlowFluidStateBase::_T_c2k
protectedinherited

◆ _Tidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Tidx
protected

◆ _Xidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Xidx
protected

◆ _Zidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Zidx
protected

The documentation for this class was generated from the following files:
PorousFlowFluidStateBase::_empty_fsp
FluidStateProperties _empty_fsp
Empty FluidStateProperties object.
Definition: PorousFlowFluidStateBase.h:139
PorousFlowFluidStateBase::_gas_phase_number
unsigned int _gas_phase_number
Phase number of the gas phase.
Definition: PorousFlowFluidStateBase.h:125
PorousFlowFluidStateFlash::rachfordRiceDeriv
Real rachfordRiceDeriv(Real vf, std::vector< Real > &Zi, std::vector< Real > &Ki) const
Derivative of Rachford-Rice equation wrt vapor fraction.
Definition: PorousFlowFluidStateFlash.C:53
PorousFlowFluidStateMultiComponentBase::_Xidx
const unsigned int _Xidx
Index of derivative wrt salt mass fraction X.
Definition: PorousFlowFluidStateMultiComponentBase.h:83
PorousFlowFluidStateMultiComponentBase::_Tidx
const unsigned int _Tidx
Index of derivative wrt temperature.
Definition: PorousFlowFluidStateMultiComponentBase.h:81
PorousFlowFluidStateFlash::vaporMassFraction
Real vaporMassFraction(Real Z0, Real K0, Real K1) const
Solves Rachford-Rice equation to provide vapor mass fraction.
Definition: PorousFlowFluidStateFlash.C:81
PorousFlowFluidStateBase::_gas_fluid_component
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
Definition: PorousFlowFluidStateBase.h:129
FluidStatePhaseEnum::LIQUID
PorousFlowFluidStateMultiComponentBase::_Zidx
const unsigned int _Zidx
Index of derivative wrt total mass fraction Z.
Definition: PorousFlowFluidStateMultiComponentBase.h:79
PorousFlowFluidStateFlash::_nr_max_its
const Real _nr_max_its
Maximum number of iterations for the Newton-Raphson routine.
Definition: PorousFlowFluidStateFlash.h:80
PorousFlowFluidStateFlash::_nr_tol
const Real _nr_tol
Tolerance for Newton-Raphson iterations.
Definition: PorousFlowFluidStateFlash.h:82
PorousFlowFluidStateBase::_salt_component
const unsigned int _salt_component
Salt component index.
Definition: PorousFlowFluidStateBase.h:131
PorousFlowFluidStateBase::_aqueous_phase_number
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
Definition: PorousFlowFluidStateBase.h:123
PorousFlowFluidStateBase::_num_phases
unsigned int _num_phases
Number of phases.
Definition: PorousFlowFluidStateBase.h:119
PorousFlowFluidStateBase::_num_components
unsigned int _num_components
Number of components.
Definition: PorousFlowFluidStateBase.h:121
FluidStatePhaseEnum::TWOPHASE
FluidStatePhaseEnum::GAS
PorousFlowFluidStateBase::_aqueous_fluid_component
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
Definition: PorousFlowFluidStateBase.h:127
PorousFlowFluidStateFlash::PorousFlowFluidStateFlash
PorousFlowFluidStateFlash(const InputParameters &parameters)
Definition: PorousFlowFluidStateFlash.C:21
PorousFlowFluidStateMultiComponentBase::_pidx
const unsigned int _pidx
Index of derivative wrt pressure.
Definition: PorousFlowFluidStateMultiComponentBase.h:73
PorousFlowFluidStateFlash::rachfordRice
Real rachfordRice(Real vf, std::vector< Real > &Zi, std::vector< Real > &Ki) const
Rachford-Rice equation for vapor fraction.
Definition: PorousFlowFluidStateFlash.C:27