https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
PorousFlowBrineCO2 Class Reference

Specialized class for brine and CO2 including calculation of mutual solubility of the two fluids using a high-accuracy fugacity-based formulation. More...

#include <PorousFlowBrineCO2.h>

Inheritance diagram for PorousFlowBrineCO2:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 PorousFlowBrineCO2 (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 thermophysicalProperties (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const override
 
void equilibriumMoleFractions (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, ADReal &xco2, ADReal &yh2o) const
 Mole fractions of CO2 in brine and water vapor in CO2 at equilibrium. More...
 
void equilibriumMassFractions (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, ADReal &Xco2, ADReal &Yh2o) const
 Mass fractions of CO2 in brine and water vapor in CO2 at equilibrium. More...
 
void massFractions (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, FluidStatePhaseEnum &phase_state, std::vector< FluidStateProperties > &fsp) const
 Mass fractions of CO2 and H2O in both phases, as well as derivatives wrt PorousFlow variables. More...
 
void gasProperties (const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
 Thermophysical properties of the gaseous state. More...
 
void liquidProperties (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, std::vector< FluidStateProperties > &fsp) const
 Thermophysical properties of the liquid state. More...
 
ADReal saturation (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, std::vector< FluidStateProperties > &fsp) const
 Gas saturation in the two-phase region. More...
 
void twoPhaseProperties (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const
 Gas and liquid properties in the two-phase region. More...
 
void fugacityCoefficientsLowTemp (const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, ADReal &fco2, ADReal &fh2o) const
 Fugacity coefficients for H2O and CO2 for T <= 100C Eq. More...
 
ADReal activityCoefficientH2O (const ADReal &temperature, const ADReal &xco2) const
 Activity coefficient of H2O Eq. More...
 
ADReal activityCoefficientCO2 (const ADReal &temperature, const ADReal &xco2) const
 Activity coefficient of CO2 Eq. More...
 
ADReal activityCoefficient (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl) const
 Activity coefficient for CO2 in brine. More...
 
ADReal activityCoefficientHighTemp (const ADReal &temperature, const ADReal &Xnacl) const
 Activity coefficient for CO2 in brine used in the elevated temperature formulation. More...
 
ADReal equilibriumConstantH2O (const ADReal &temperature) const
 Equilibrium constant for H2O For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2003) For temperatures 109C <= T <= 300C, uses Spycher and Pruess (2010) For temperatures 99C < T < 109C, the value is calculated by smoothly interpolating the two formulations. More...
 
ADReal equilibriumConstantCO2 (const ADReal &temperature) const
 Equilibrium constant for CO2 For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2003) For temperatures 109C <= T <= 300C, uses Spycher and Pruess (2010) For temperatures 99C < T < 109C, the value is calculated by smoothly interpolating the two formulations. More...
 
ADReal partialDensityCO2 (const ADReal &temperature) const
 Partial density of dissolved CO2 From Garcia, Density of aqueous solutions of CO2, LBNL-49023 (2001) 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 saltComponentIndex () const
 The index of the salt component. More...
 
ADReal henryConstant (const ADReal &temperature, const ADReal &Xnacl) const
 Henry's constant of dissolution of gas phase CO2 in brine. More...
 
ADReal enthalpyOfDissolutionGas (const ADReal &temperature, const ADReal &Xnacl) const
 Enthalpy of dissolution of gas phase CO2 in brine 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...
 
ADReal enthalpyOfDissolution (const ADReal &temperature) const
 Enthalpy of dissolution of CO2 in brine calculated using linear fit to model of Duan and Sun, An improved model calculating CO2 solubility in pure water and aqueous NaCl solutions from 273 to 533 K and from 0 to 2000 bar, Chemical geology, 193, 257–271 (2003). More...
 
void equilibriumMoleFractionsLowTemp (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, ADReal &xco2, ADReal &yh2o) const
 Mole fractions of CO2 in brine and water vapor in CO2 at equilibrium in the low temperature regime (T <= 99C). More...
 
void solveEquilibriumMoleFractionHighTemp (Real pressure, Real temperature, Real Xnacl, Real co2_density, Real &xco2, Real &yh2o) const
 Function to solve for yh2o and xco2 iteratively in the elevated temperature regime (T > 100C) 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...
 
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...
 
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...
 
ADReal vaporMassFraction (const ADReal &Z0, const ADReal &K0, const ADReal &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...
 
void clearFluidStateProperties (std::vector< FluidStateProperties > &fsp) const
 Clears the contents of the FluidStateProperties data structure. More...
 
SubProblemgetSubProblem () const
 
bool shouldDuplicateInitialExecution () const
 
virtual Real spatialValue (const Point &) const
 
virtual const std::vector< Point > spatialPoints () const
 
void gatherSum (T &value)
 
void gatherMax (T &value)
 
void gatherMin (T &value)
 
void gatherProxyValueMax (T1 &proxy, T2 &value)
 
void gatherProxyValueMin (T1 &proxy, T2 &value)
 
void setPrimaryThreadCopy (UserObject *primary)
 
UserObjectprimaryThreadCopy ()
 
std::set< UserObjectName > getDependObjects () const
 
virtual bool needThreadedCopy () const
 
const std::set< std::string > & getRequestedItems () override
 
const std::set< std::string > & getSuppliedItems () override
 
unsigned int systemNumber () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
bool isKokkosObject (IsKokkosObjectKey &&) const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParametersparameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnumgetExecuteOnEnum () const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const T & getUserObject (const std::string &param_name, bool is_dependency=true) const
 
const T & getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const std::vector< MooseVariableScalar *> & getCoupledMooseScalarVars ()
 
const std::set< TagID > & getScalarVariableCoupleableVectorTags () const
 
const std::set< TagID > & getScalarVariableCoupleableMatrixTags () const
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialProperty (const std::string &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, MaterialData &material_data, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialProperty (const std::string &name, const unsigned int state=0)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name, MaterialData &material_data)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > & getADMaterialProperty (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOld (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name)
 
const MaterialProperty< T > & getMaterialPropertyOlder (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const GenericMaterialProperty< T, is_ad > & getGenericMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const MaterialProperty< T > & getMaterialPropertyByName (const MaterialPropertyName &name, const unsigned int state=0)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name)
 
const ADMaterialProperty< T > & getADMaterialPropertyByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOldByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name, MaterialData &material_data)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name)
 
const MaterialProperty< T > & getMaterialPropertyOlderByName (const MaterialPropertyName &name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyByName (const std::string &prop_name_in)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOldByName (const std::string &prop_name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOlderByName (const std::string &prop_name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialProperty (const std::string &name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOld (const std::string &name)
 
Moose::Kokkos::MaterialProperty< T, dimension > getKokkosMaterialPropertyOlder (const std::string &name)
 
std::pair< const MaterialProperty< T > *, std::set< SubdomainID > > getBlockMaterialProperty (const MaterialPropertyName &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialProperty ()
 
const GenericMaterialProperty< T, is_ad > & getGenericZeroMaterialPropertyByName (const std::string &prop_name)
 
const MaterialProperty< T > & getZeroMaterialProperty (Ts... args)
 
std::set< SubdomainIDgetMaterialPropertyBlocks (const std::string &name)
 
std::vector< SubdomainName > getMaterialPropertyBlockNames (const std::string &name)
 
std::set< BoundaryIDgetMaterialPropertyBoundaryIDs (const std::string &name)
 
std::vector< BoundaryName > getMaterialPropertyBoundaryNames (const std::string &name)
 
void checkBlockAndBoundaryCompatibility (std::shared_ptr< MaterialBase > discrete)
 
std::unordered_map< SubdomainID, std::vector< MaterialBase *> > buildRequiredMaterials (bool allow_stateful=true)
 
void statefulPropertiesAllowed (bool)
 
virtual bool getMaterialPropertyCalled () const
 
virtual const std::unordered_set< unsigned int > & getMatPropDependencies () const
 
virtual void resolveOptionalProperties ()
 
const GenericMaterialProperty< T, is_ad > & getPossiblyConstantGenericMaterialPropertyByName (const MaterialPropertyName &prop_name, MaterialData &material_data, const unsigned int state)
 
bool isImplicit ()
 
Moose::StateArg determineState () const
 
virtual void threadJoin (const UserObject &) override
 
virtual void threadJoin (const UserObject &) override
 
virtual void subdomainSetup () override
 
virtual void subdomainSetup () override
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
const GenericOptionalMaterialProperty< T, is_ad > & getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const GenericOptionalMaterialProperty< T, is_ad > & getGenericOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalMaterialProperty< T > & getOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalMaterialProperty< T > & getOptionalMaterialProperty (const std::string &name, const unsigned int state=0)
 
const OptionalADMaterialProperty< T > & getOptionalADMaterialProperty (const std::string &name)
 
const OptionalADMaterialProperty< T > & getOptionalADMaterialProperty (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOld (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOld (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOlder (const std::string &name)
 
const OptionalMaterialProperty< T > & getOptionalMaterialPropertyOlder (const std::string &name)
 
MaterialBasegetMaterial (const std::string &name)
 
MaterialBasegetMaterial (const std::string &name)
 
MaterialBasegetMaterialByName (const std::string &name, bool no_warn=false)
 
MaterialBasegetMaterialByName (const std::string &name, bool no_warn=false)
 
bool hasMaterialProperty (const std::string &name)
 
bool hasMaterialProperty (const std::string &name)
 
bool hasMaterialPropertyByName (const std::string &name)
 
bool hasMaterialPropertyByName (const std::string &name)
 
bool hasADMaterialProperty (const std::string &name)
 
bool hasADMaterialProperty (const std::string &name)
 
bool hasADMaterialPropertyByName (const std::string &name)
 
bool hasADMaterialPropertyByName (const std::string &name)
 
bool hasKokkosMaterialProperty (const std::string &name)
 
bool hasKokkosMaterialProperty (const std::string &name)
 
bool hasKokkosMaterialPropertyByName (const std::string &name)
 
bool hasKokkosMaterialPropertyByName (const std::string &name)
 
bool hasGenericMaterialProperty (const std::string &name)
 
bool hasGenericMaterialProperty (const std::string &name)
 
bool hasGenericMaterialPropertyByName (const std::string &name)
 
bool hasGenericMaterialPropertyByName (const std::string &name)
 
const FunctiongetFunction (const std::string &name) const
 
const FunctiongetFunctionByName (const FunctionName &name) const
 
bool hasFunction (const std::string &param_name) const
 
bool hasFunctionByName (const FunctionName &name) const
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValuegetVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValuegetScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name) const
 
const VectorPostprocessorName & getVectorPostprocessorName (const std::string &param_name) const
 
T & getSampler (const std::string &name)
 
SamplergetSampler (const std::string &name)
 
T & getSamplerByName (const SamplerName &name)
 
SamplergetSamplerByName (const SamplerName &name)
 
virtual void meshChanged ()
 
virtual void meshDisplaced ()
 
PerfGraphperfGraph ()
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistribution (const std::string &name) const
 
const T & getDistribution (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const DistributiongetDistributionByName (const DistributionName &name) const
 
const T & getDistributionByName (const std::string &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 
void fugacityCoefficientsHighTemp (const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, const ADReal &xco2, const ADReal &yh2o, ADReal &fco2, ADReal &fh2o) const
 Fugacity coefficients for H2O and CO2 at elevated temperatures (100C < T <= 300C). More...
 
ADReal fugacityCoefficientH2OHighTemp (const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, const ADReal &xco2, const ADReal &yh2o) const
 
ADReal fugacityCoefficientCO2HighTemp (const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, const ADReal &xco2, const ADReal &yh2o) const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node)
 
static void sort (typename std::vector< T > &vector)
 
static void sortDFS (typename std::vector< T > &vector)
 
static void cyclicDependencyError (CyclicDependencyException< T2 > &e, const std::string &header)
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 
static constexpr PropertyValue::id_type default_property_id
 
static constexpr PropertyValue::id_type zero_property_id
 
static constexpr auto SYSTEM
 
static constexpr auto NAME
 

Protected Member Functions

virtual void checkVariables (Real pressure, Real temperature) const
 Check the input variables. More...
 
void smoothCubicInterpolation (Real temperature, Real f0, Real df0, Real f1, Real df1, Real &value, Real &deriv) const
 Cubic function to smoothly interpolate between the low temperature and elevated temperature models for 99C < T < 109C. More...
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &name) const override
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &name) const override
 
virtual void addUserObjectDependencyHelper (const UserObject &uo) const override
 
void addReporterDependencyHelper (const ReporterName &reporter_name) override
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
const ReporterContextBasegetReporterContextBaseByName (const ReporterName &reporter_name) const
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
const T & getMeshProperty (const std::string &data_name, const std::string &prefix)
 
const T & getMeshProperty (const std::string &data_name)
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name, const std::string &prefix) const
 
bool hasMeshProperty (const std::string &data_name) const
 
bool hasMeshProperty (const std::string &data_name) const
 
std::string meshPropertyName (const std::string &data_name) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
bool isCoupledScalar (const std::string &var_name, unsigned int i=0) const
 
unsigned int coupledScalarComponents (const std::string &var_name) const
 
unsigned int coupledScalar (const std::string &var_name, unsigned int comp=0) const
 
libMesh::Order coupledScalarOrder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< is_ad > & coupledGenericScalarValue (const std::string &var_name, unsigned int comp=0) const
 
const GenericVariableValue< false > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const GenericVariableValue< true > & coupledGenericScalarValue (const std::string &var_name, const unsigned int comp) const
 
const VariableValuecoupledVectorTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledMatrixTagScalarValue (const std::string &var_name, TagID tag, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarValueOlder (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const ADVariableValueadCoupledScalarDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDot (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotOld (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDu (const std::string &var_name, unsigned int comp=0) const
 
const VariableValuecoupledScalarDotDotDu (const std::string &var_name, unsigned int comp=0) const
 
const MooseVariableScalargetScalarVar (const std::string &var_name, unsigned int comp) const
 
virtual void checkMaterialProperty (const std::string &name, const unsigned int state)
 
virtual void getKokkosMaterialPropertyHook (const std::string &, const unsigned int)
 
void markMatPropRequested (const std::string &)
 
MaterialPropertyName getMaterialPropertyName (const std::string &name) const
 
void checkExecutionStage ()
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
const GenericMaterialProperty< T, is_ad > * defaultGenericMaterialProperty (const std::string &name)
 
const GenericMaterialProperty< T, is_ad > * defaultGenericMaterialProperty (const std::string &name)
 
const MaterialProperty< T > * defaultMaterialProperty (const std::string &name)
 
const MaterialProperty< T > * defaultMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > * defaultADMaterialProperty (const std::string &name)
 
const ADMaterialProperty< T > * defaultADMaterialProperty (const std::string &name)
 
void funcABHighTemp (Real pressure, Real temperature, Real Xnacl, Real co2_density, Real xco2, Real yh2o, Real &A, Real &B) const
 The function A (Eq. More...
 
void funcABHighTemp (Real pressure, Real temperature, Real Xnacl, Real co2_density, Real xco2, Real yh2o, Real &A, Real &dA_dp, Real &dA_dT, Real &B, Real &dB_dp, Real &dB_dT, Real &dB_dX) const
 
void funcABLowTemp (const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, ADReal &A, ADReal &B) const
 

Static Protected Member Functions

static std::string meshPropertyName (const std::string &data_name, const std::string &prefix)
 

Protected Attributes

const unsigned int _salt_component
 Salt component index. More...
 
const BrineFluidProperties_brine_fp
 Fluid properties UserObject for water. More...
 
const SinglePhaseFluidProperties_co2_fp
 Fluid properties UserObject for the CO2. More...
 
const Real _Mh2o
 Molar mass of water (kg/mol) More...
 
const Real _invMh2o
 Inverse of molar mass of H2O (mol/kg) More...
 
const Real _Mco2
 Molar mass of CO2 (kg/mol) More...
 
const Real _Mnacl
 Molar mass of NaCL. More...
 
const Real _Rbar
 Molar gas constant in bar cm^3 /(K mol) More...
 
const Real _Tlower
 Temperature below which the Spycher, Pruess & Ennis-King (2003) model is used (K) More...
 
const Real _Tupper
 Temperature above which the Spycher & Pruess (2010) model is used (K) More...
 
const Real _Zmin
 Minimum Z - below this value all CO2 will be dissolved. More...
 
const std::vector< Real_co2_henry
 Henry's coefficeients for CO2. 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 _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 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...
 
SubProblem_subproblem
 
FEProblemBase_fe_problem
 
SystemBase_sys
 
const THREAD_ID _tid
 
Assembly_assembly
 
const Moose::CoordinateSystemType_coord_sys
 
const bool _duplicate_initial_execution
 
std::set< std::string > _depend_uo
 
const bool & _enabled
 
MooseApp_app
 
Factory_factory
 
ActionFactory_action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters_pars
 
const ExecFlagEnum_execute_enum
 
const ExecFlagType_current_execute_flag
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
FEProblemBase_mci_feproblem
 
FEProblemBase_mdi_feproblem
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
FEProblemBase_sc_fe_problem
 
const THREAD_ID _sc_tid
 
const Real_real_zero
 
const VariableValue_scalar_zero
 
const Point & _point_zero
 
const InputParameters_mi_params
 
const std::string _mi_name
 
const MooseObjectName _mi_moose_object_name
 
FEProblemBase_mi_feproblem
 
SubProblem_mi_subproblem
 
const THREAD_ID _mi_tid
 
const bool _is_kokkos_object
 
const Moose::MaterialDataType _material_data_type
 
MaterialData_material_data
 
bool _stateful_allowed
 
bool _get_material_property_called
 
std::vector< std::unique_ptr< PropertyValue > > _default_properties
 
std::unordered_set< unsigned int_material_property_dependencies
 
const MaterialPropertyName _get_suffix
 
const bool _use_interpolated_state
 
const InputParameters_ti_params
 
FEProblemBase_ti_feproblem
 
bool _is_implicit
 
Real_t
 
const Real_t_old
 
int_t_step
 
Real_dt
 
Real_dt_old
 
bool _is_transient
 
const Parallel::Communicator & _communicator
 

Static Protected Attributes

static const std::string _interpolated_old
 
static const std::string _interpolated_older
 

Detailed Description

Specialized class for brine and CO2 including calculation of mutual solubility of the two fluids using a high-accuracy fugacity-based formulation.

For temperatures 12C <= T <= 99C, the formulation is based on Spycher, Pruess and Ennis-King, CO2-H2O mixtures in the geological sequestration of CO2. I. Assessment and calculation of mutual solubilities from 12 to 100C and up to 600 bar, Geochimica et Cosmochimica Acta, 67, 3015-3031 (2003), and Spycher and Pruess, CO2-H2O mixtures in the geological sequestration of CO2. II. Partitioning in chloride brine at 12-100C and up to 600 bar, Geochimica et Cosmochimica Acta, 69, 3309-3320 (2005).

For temperatures 109C <= T <= 300C, the formulation is based on Spycher and Pruess, A Phase-Partitioning Model for CO2-Brine Mixtures at Elevated Temperatures and Pressures: Application to CO2-Enhanced Geothermal Systems, Transport in Porous Media, 82, 173-196 (2010)

As the two formulations do not coincide at temperatures near 100C, a cubic polynomial is used in the intermediate temperature range 99C < T < 109C to provide a smooth transition from the two formulations in this region.

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 47 of file PorousFlowBrineCO2.h.

Constructor & Destructor Documentation

◆ PorousFlowBrineCO2()

PorousFlowBrineCO2::PorousFlowBrineCO2 ( const InputParameters parameters)

Definition at line 29 of file PorousFlowBrineCO2.C.

31  _salt_component(getParam<unsigned int>("salt_component")),
32  _brine_fp(getUserObject<BrineFluidProperties>("brine_fp")),
33  _co2_fp(getUserObject<SinglePhaseFluidProperties>("co2_fp")),
35  _invMh2o(1.0 / _Mh2o),
38  _Rbar(_R * 10.0),
39  _Tlower(372.15),
40  _Tupper(382.15),
41  _Zmin(1.0e-4),
43 {
44  // Check that the correct FluidProperties UserObjects have been provided
45  if (_co2_fp.fluidName() != "co2")
46  paramError("co2_fp", "A valid CO2 FluidProperties UserObject must be provided");
47 
48  if (_brine_fp.fluidName() != "brine")
49  paramError("brine_fp", "A valid Brine FluidProperties UserObject must be provided");
50 
51  // Set the number of phases and components, and their indexes
52  _num_phases = 2;
53  _num_components = 3;
56 
57  // Check that _aqueous_phase_number is <= total number of phases
59  paramError("liquid_phase_number",
60  "This value is larger than the possible number of phases ",
61  _num_phases);
62 
63  // Check that _aqueous_fluid_component is <= total number of fluid components
65  paramError("liquid_fluid_component",
66  "This value is larger than the possible number of fluid components",
68 
69  // Check that the salt component index is not identical to the liquid fluid component
71  paramError(
72  "salt_component",
73  "The value provided must be different from the value entered in liquid_fluid_component");
74 
75  // Check that _salt_component is <= total number of fluid components
77  paramError("salt_component",
78  "The value provided is larger than the possible number of fluid components",
80 
82 }
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
const Real _Tlower
Temperature below which the Spycher, Pruess & Ennis-King (2003) model is used (K) ...
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
unsigned int _num_phases
Number of phases.
const unsigned int _salt_component
Salt component index.
const Real _Mh2o
Molar mass of water (kg/mol)
void paramError(const std::string &param, Args... args) const
const Real _Mnacl
Molar mass of NaCL.
const Real _invMh2o
Inverse of molar mass of H2O (mol/kg)
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
virtual std::string fluidName() const override
Fluid name.
const InputParameters & parameters() const
const std::vector< Real > _co2_henry
Henry&#39;s coefficeients for CO2.
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 Real _Mco2
Molar mass of CO2 (kg/mol)
virtual std::vector< Real > henryCoefficients() const
Henry&#39;s law coefficients for dissolution in water.
Real molarMassH2O() const
H2O molar mass.
const BrineFluidProperties & _brine_fp
Fluid properties UserObject for water.
PorousFlowFluidStateMultiComponentBase(const InputParameters &parameters)
const SinglePhaseFluidProperties & _co2_fp
Fluid properties UserObject for the CO2.
Real molarMassNaCl() const
NaCl molar mass.
const Real _R
Universal gas constant (J/mol/K)
AD data structure to pass calculated thermophysical properties.
const Real _Rbar
Molar gas constant in bar cm^3 /(K mol)
e e e e s T T T T T rho v v T e p T T virtual T std::string fluidName() const
Fluid name.
FluidStateProperties _empty_fsp
Empty FluidStateProperties object.
const Real _Zmin
Minimum Z - below this value all CO2 will be dissolved.
const Real _Tupper
Temperature above which the Spycher & Pruess (2010) model is used (K)

Member Function Documentation

◆ activityCoefficient()

ADReal PorousFlowBrineCO2::activityCoefficient ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl 
) const

Activity coefficient for CO2 in brine.

From Duan and Sun, An improved model calculating CO2 solubility in pure water and aqueous NaCl solutions from 257 to 533 K and from 0 to 2000 bar, Chem. Geol., 193, 257-271 (2003)

Note: this is not a 'true' activity coefficient, and is instead related to the molality of CO2 in water and brine. Nevertheless, Spycher and Pruess (2005) refer to it as an activity coefficient, so this notation is followed here.

Parameters
pressurephase pressure (Pa)
temperaturephase temperature (K)
Xnaclsalt mass fraction (kg/kg)
Returns
activity coefficient for CO2 in brine

Definition at line 588 of file PorousFlowBrineCO2.C.

Referenced by equilibriumMoleFractionsLowTemp().

591 {
592  using std::log, std::exp;
593 
594  // Need pressure in bar
595  const ADReal pbar = pressure * 1.0e-5;
596  // Need NaCl molality (mol/kg)
597  const ADReal mnacl = Xnacl / (1.0 - Xnacl) / _Mnacl;
598 
599  const ADReal lambda = -0.411370585 + 6.07632013e-4 * temperature + 97.5347708 / temperature -
600  0.0237622469 * pbar / temperature +
601  0.0170656236 * pbar / (630.0 - temperature) +
602  1.41335834e-5 * temperature * log(pbar);
603 
604  const ADReal xi = 3.36389723e-4 - 1.9829898e-5 * temperature +
605  2.12220830e-3 * pbar / temperature -
606  5.24873303e-3 * pbar / (630.0 - temperature);
607 
608  return exp(2.0 * lambda * mnacl + xi * mnacl * mnacl);
609 }
auto exp(const T &)
const Real _Mnacl
Molar mass of NaCL.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
auto log(const T &)
static const std::string pressure
Definition: NS.h:56

◆ activityCoefficientCO2()

ADReal PorousFlowBrineCO2::activityCoefficientCO2 ( const ADReal temperature,
const ADReal xco2 
) const

Activity coefficient of CO2 Eq.

(13) from Spycher & Pruess (2010)

Parameters
temperaturetemperature (K)
xco2mole fraction of CO2 in liquid phase (-)
Returns
activity coefficient

Definition at line 571 of file PorousFlowBrineCO2.C.

Referenced by funcABHighTemp().

572 {
573  using std::exp;
574 
575  if (temperature.value() <= 373.15)
576  return 1.0;
577  else
578  {
579  const ADReal Tref = temperature - 373.15;
580  const ADReal xh2o = 1.0 - xco2;
581  const ADReal Am = -3.084e-2 * Tref + 1.927e-5 * Tref * Tref;
582 
583  return exp(2.0 * Am * xco2 * xh2o * xh2o);
584  }
585 }
auto exp(const T &)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal

◆ activityCoefficientH2O()

ADReal PorousFlowBrineCO2::activityCoefficientH2O ( const ADReal temperature,
const ADReal xco2 
) const

Activity coefficient of H2O Eq.

(12) from Spycher & Pruess (2010)

Parameters
temperaturetemperature (K)
xco2mole fraction of CO2 in liquid phase (-)
Returns
activity coefficient

Definition at line 554 of file PorousFlowBrineCO2.C.

Referenced by funcABHighTemp().

555 {
556  using std::exp;
557 
558  if (temperature.value() <= 373.15)
559  return 1.0;
560  else
561  {
562  const ADReal Tref = temperature - 373.15;
563  const ADReal xh2o = 1.0 - xco2;
564  const ADReal Am = -3.084e-2 * Tref + 1.927e-5 * Tref * Tref;
565 
566  return exp((Am - 2.0 * Am * xh2o) * xco2 * xco2);
567  }
568 }
auto exp(const T &)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal

◆ activityCoefficientHighTemp()

ADReal PorousFlowBrineCO2::activityCoefficientHighTemp ( const ADReal temperature,
const ADReal Xnacl 
) const

Activity coefficient for CO2 in brine used in the elevated temperature formulation.

Eq. (18) from Spycher and Pruess (2010).

Note: unlike activityCoefficient(), no pressure dependence is included in this formulation

Parameters
temperaturephase temperature (K)
Xnaclsalt mass fraction (kg/kg)
Returns
activity coefficient for CO2 in brine

Definition at line 612 of file PorousFlowBrineCO2.C.

Referenced by funcABHighTemp().

614 {
615  using std::exp;
616 
617  // Need NaCl molality (mol/kg)
618  const ADReal mnacl = Xnacl / (1.0 - Xnacl) / _Mnacl;
619 
620  const ADReal T2 = temperature * temperature;
621  const ADReal T3 = temperature * T2;
622 
623  const ADReal lambda = 2.217e-4 * temperature + 1.074 / temperature + 2648.0 / T2;
624  const ADReal xi = 1.3e-5 * temperature - 20.12 / temperature + 5259.0 / T2;
625 
626  return (1.0 - mnacl / _invMh2o) * exp(2.0 * lambda * mnacl + xi * mnacl * mnacl);
627 }
auto exp(const T &)
const Real _Mnacl
Molar mass of NaCL.
const Real _invMh2o
Inverse of molar mass of H2O (mol/kg)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal

◆ aqueousComponentIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::aqueousComponentIndex ( ) const
inlineinherited

The index of the aqueous fluid component.

Returns
aqueous fluid component number

Definition at line 29 of file PorousFlowFluidStateMultiComponentBase.h.

29 { 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 77 of file PorousFlowFluidStateBase.h.

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

◆ checkVariables()

void PorousFlowBrineCO2::checkVariables ( Real  pressure,
Real  temperature 
) const
protectedvirtual

Check the input variables.

Definition at line 1181 of file PorousFlowBrineCO2.C.

Referenced by thermophysicalProperties(), and totalMassFraction().

1182 {
1183  // The calculation of mass fractions is valid from 12C <= T <= 300C, and
1184  // pressure less than 60 MPa
1185  if (temperature < 285.15 || temperature > 573.15)
1186  mooseException(name() + ": temperature " + Moose::stringify(temperature) +
1187  " is outside range 285.15 K <= T <= 573.15 K");
1188 
1189  if (pressure > 6.0e7)
1190  mooseException(name() + ": pressure " + Moose::stringify(pressure) +
1191  " must be less than 60 MPa");
1192 }
static const std::string temperature
Definition: NS.h:59
const std::string & name() const
std::string stringify(const T &t)
static const std::string pressure
Definition: NS.h:56

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

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

34 {
35  std::fill(fsp.begin(), fsp.end(), _empty_fsp);
36 }
FluidStateProperties _empty_fsp
Empty FluidStateProperties object.

◆ enthalpyOfDissolution()

ADReal PorousFlowBrineCO2::enthalpyOfDissolution ( const ADReal temperature) const

Enthalpy of dissolution of CO2 in brine calculated using linear fit to model of Duan and Sun, An improved model calculating CO2 solubility in pure water and aqueous NaCl solutions from 273 to 533 K and from 0 to 2000 bar, Chemical geology, 193, 257–271 (2003).

In the region of interest, the more complicated model given in Eq. (8) of Duan and Sun is well approximated by a simple linear fit (R^2 = 0.9997).

Note: as the effect of salt mass fraction is small, it is not included in this function.

Parameters
temperaturefluid temperature (K)
Returns
enthalpy of dissolution (J/kg)

Definition at line 1152 of file PorousFlowBrineCO2.C.

Referenced by liquidProperties().

1153 {
1154  // Linear fit to model of Duan and Sun (2003) (in kJ/mol)
1155  const ADReal delta_h = -58.3533 + 0.134519 * temperature;
1156 
1157  // Convert to J/kg
1158  return delta_h * 1000.0 / _Mco2;
1159 }
const Real _Mco2
Molar mass of CO2 (kg/mol)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal

◆ enthalpyOfDissolutionGas()

ADReal PorousFlowBrineCO2::enthalpyOfDissolutionGas ( const ADReal temperature,
const ADReal Xnacl 
) const

Enthalpy of dissolution of gas phase CO2 in brine 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). Correction due to salinity from Battistelli et al, A fluid property module for the TOUGH2 simulator for saline brines with non-condensible gas, Proc. Eighteenth Workshop on Geothermal Reservoir Engineering (1993).

Parameters
temperaturefluid temperature (K)
XnaclNaCl mass fraction (kg/kg)
Returns
enthalpy of dissolution (J/kg)

Definition at line 1122 of file PorousFlowBrineCO2.C.

1123 {
1124  // Henry's constant
1125  const ADReal Kh = henryConstant(temperature, Xnacl);
1126 
1127  ADReal hdis = -_R * temperature * temperature * Kh.derivatives()[_Tidx] / Kh / _Mco2;
1128 
1129  // Derivative of enthalpy of dissolution wrt temperature and xnacl requires the second
1130  // derivatives of Henry's constant. For simplicity, approximate these numerically
1131  const Real dT = temperature.value() * 1.0e-8;
1132  const ADReal T2 = temperature + dT;
1133  const ADReal Kh2 = henryConstant(T2, Xnacl);
1134 
1135  const Real dhdis_dT =
1136  (-_R * T2 * T2 * Kh2.derivatives()[_Tidx] / Kh2 / _Mco2 - hdis).value() / dT;
1137 
1138  const Real dX = Xnacl.value() * 1.0e-8;
1139  const ADReal X2 = Xnacl + dX;
1140  const ADReal Kh3 = henryConstant(temperature, X2);
1141 
1142  const Real dhdis_dX =
1143  (-_R * temperature * temperature * Kh3.derivatives()[_Tidx] / Kh3 / _Mco2 - hdis).value() /
1144  dX;
1145 
1146  hdis.derivatives() = temperature.derivatives() * dhdis_dT + Xnacl.derivatives() * dhdis_dX;
1147 
1148  return hdis;
1149 }
const unsigned int _Tidx
Index of derivative wrt temperature.
const Real _Mco2
Molar mass of CO2 (kg/mol)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
const Real _R
Universal gas constant (J/mol/K)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
ADReal henryConstant(const ADReal &temperature, const ADReal &Xnacl) const
Henry&#39;s constant of dissolution of gas phase CO2 in brine.

◆ equilibriumConstantCO2()

ADReal PorousFlowBrineCO2::equilibriumConstantCO2 ( const ADReal temperature) const

Equilibrium constant for CO2 For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2003) For temperatures 109C <= T <= 300C, uses Spycher and Pruess (2010) For temperatures 99C < T < 109C, the value is calculated by smoothly interpolating the two formulations.

Parameters
temperaturetemperature (K)
Returns
equilibrium constant for CO2

Definition at line 659 of file PorousFlowBrineCO2.C.

Referenced by funcABHighTemp(), and funcABLowTemp().

660 {
661  using std::pow;
662 
663  // Uses temperature in Celsius
664  const ADReal Tc = temperature - _T_c2k;
665  const ADReal Tc2 = Tc * Tc;
666  const ADReal Tc3 = Tc2 * Tc;
667 
668  ADReal logK0CO2;
669 
670  if (Tc <= 99.0)
671  logK0CO2 = 1.189 + 1.304e-2 * Tc - 5.446e-5 * Tc2;
672 
673  else if (Tc > 99.0 && Tc < 109.0)
674  {
675  const ADReal Tint = (Tc - 99.0) / 10.0;
676  const ADReal Tint2 = Tint * Tint;
677  logK0CO2 = 1.9462 + 2.25692e-2 * Tint - 9.49577e-3 * Tint2 - 6.77721e-3 * Tint * Tint2;
678  }
679 
680  else // 109 <= Tc <= 300
681  logK0CO2 = 1.668 + 3.992e-3 * Tc - 1.156e-5 * Tc2 + 1.593e-9 * Tc3;
682 
683  return pow(10.0, logK0CO2);
684 }
const Real _T_c2k
Conversion from C to K.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
MooseUnits pow(const MooseUnits &, int)

◆ equilibriumConstantH2O()

ADReal PorousFlowBrineCO2::equilibriumConstantH2O ( const ADReal temperature) const

Equilibrium constant for H2O For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2003) For temperatures 109C <= T <= 300C, uses Spycher and Pruess (2010) For temperatures 99C < T < 109C, the value is calculated by smoothly interpolating the two formulations.

Parameters
temperaturetemperature (K)
Returns
equilibrium constant for H2O

Definition at line 630 of file PorousFlowBrineCO2.C.

Referenced by funcABHighTemp(), and funcABLowTemp().

631 {
632  using std::pow;
633 
634  // Uses temperature in Celsius
635  const ADReal Tc = temperature - _T_c2k;
636  const ADReal Tc2 = Tc * Tc;
637  const ADReal Tc3 = Tc2 * Tc;
638  const ADReal Tc4 = Tc3 * Tc;
639 
640  ADReal logK0H2O;
641 
642  if (Tc <= 99.0)
643  logK0H2O = -2.209 + 3.097e-2 * Tc - 1.098e-4 * Tc2 + 2.048e-7 * Tc3;
644 
645  else if (Tc > 99.0 && Tc < 109.0)
646  {
647  const ADReal Tint = (Tc - 99.0) / 10.0;
648  const ADReal Tint2 = Tint * Tint;
649  logK0H2O = -0.0204026 + 0.0152513 * Tint + 0.417565 * Tint2 - 0.278636 * Tint * Tint2;
650  }
651 
652  else // 109 <= Tc <= 300
653  logK0H2O = -2.1077 + 2.8127e-2 * Tc - 8.4298e-5 * Tc2 + 1.4969e-7 * Tc3 - 1.1812e-10 * Tc4;
654 
655  return pow(10.0, logK0H2O);
656 }
const Real _T_c2k
Conversion from C to K.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
MooseUnits pow(const MooseUnits &, int)

◆ equilibriumMassFractions()

void PorousFlowBrineCO2::equilibriumMassFractions ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl,
ADReal Xco2,
ADReal Yh2o 
) const

Mass fractions of CO2 in brine and water vapor in CO2 at equilibrium.

Parameters
pressurephase pressure (Pa)
temperaturephase temperature (K)
XnaclNaCl mass fraction (kg/kg)
[out]Xco2mass fraction of CO2 in liquid (kg/kg)
[out]Yh2omass fraction of H2O in gas (kg/kg)

Definition at line 372 of file PorousFlowBrineCO2.C.

Referenced by massFractions(), and totalMassFraction().

377 {
378  // Mole fractions at equilibrium
379  ADReal xco2, yh2o;
380  equilibriumMoleFractions(pressure, temperature, Xnacl, xco2, yh2o);
381 
382  // The mass fraction of H2O in gas (assume no salt in gas phase) and derivatives
383  // wrt p, T, and X
384  Yh2o = yh2o * _Mh2o / (yh2o * _Mh2o + (1.0 - yh2o) * _Mco2);
385 
386  // NaCl molality (mol/kg)
387  const ADReal mnacl = Xnacl / (1.0 - Xnacl) / _Mnacl;
388 
389  // The molality of CO2 in 1kg of H2O
390  const ADReal mco2 = xco2 * (2.0 * mnacl + _invMh2o) / (1.0 - xco2);
391  // The mass fraction of CO2 in brine is then
392  const ADReal denominator = (1.0 + mnacl * _Mnacl + mco2 * _Mco2);
393  Xco2 = mco2 * _Mco2 / denominator;
394 }
const Real _Mh2o
Molar mass of water (kg/mol)
const Real _Mnacl
Molar mass of NaCL.
const Real _invMh2o
Inverse of molar mass of H2O (mol/kg)
const Real _Mco2
Molar mass of CO2 (kg/mol)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
void equilibriumMoleFractions(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, ADReal &xco2, ADReal &yh2o) const
Mole fractions of CO2 in brine and water vapor in CO2 at equilibrium.
static const std::string pressure
Definition: NS.h:56

◆ equilibriumMoleFractions()

void PorousFlowBrineCO2::equilibriumMoleFractions ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl,
ADReal xco2,
ADReal yh2o 
) const

Mole fractions of CO2 in brine and water vapor in CO2 at equilibrium.

In the low temperature regime (T <= 99C), the mole fractions are calculated directly, while in the elevated temperature regime (T >= 109C), they are calculated iteratively. In the intermediate regime (99C < T < 109C), a cubic polynomial is used to smoothly connect the low and elevated temperature regimes.

Parameters
pressurephase pressure (Pa)
temperaturephase temperature (K)
XnaclNaCl mass fraction (kg/kg)
[out]xco2mole fraction of CO2 in liquid
[out]yh2omole fraction of H2O in gas

Definition at line 687 of file PorousFlowBrineCO2.C.

Referenced by equilibriumMassFractions().

692 {
693  if (temperature.value() <= _Tlower)
694  {
696  }
697  else if (temperature.value() > _Tlower && temperature.value() < _Tupper)
698  {
699  // Cubic polynomial in this regime
700  const Real Tint = (temperature.value() - _Tlower) / 10.0;
701 
702  // Equilibrium mole fractions and derivatives at the lower temperature
703  ADReal Tlower = _Tlower;
704  Moose::derivInsert(Tlower.derivatives(), _Tidx, 1.0);
705 
706  ADReal xco2_lower, yh2o_lower;
707  equilibriumMoleFractionsLowTemp(pressure, Tlower, Xnacl, xco2_lower, yh2o_lower);
708 
709  const Real dxco2_dT_lower = xco2_lower.derivatives()[_Tidx];
710  const Real dyh2o_dT_lower = yh2o_lower.derivatives()[_Tidx];
711 
712  // Equilibrium mole fractions and derivatives at the upper temperature
713  Real xco2_upper, yh2o_upper;
714  Real co2_density_upper = _co2_fp.rho_from_p_T(pressure.value(), _Tupper);
715 
717  pressure.value(), _Tupper, Xnacl.value(), co2_density_upper, xco2_upper, yh2o_upper);
718 
719  Real A, dA_dp, dA_dT, B, dB_dp, dB_dT, dB_dX;
720  funcABHighTemp(pressure.value(),
721  _Tupper,
722  Xnacl.value(),
723  co2_density_upper,
724  xco2_upper,
725  yh2o_upper,
726  A,
727  dA_dp,
728  dA_dT,
729  B,
730  dB_dp,
731  dB_dT,
732  dB_dX);
733 
734  const Real dyh2o_dT_upper =
735  ((1.0 - B) * dA_dT + (A - 1.0) * A * dB_dT) / (1.0 - A * B) / (1.0 - A * B);
736  const Real dxco2_dT_upper = dB_dT * (1.0 - yh2o_upper) - B * dyh2o_dT_upper;
737 
738  // The mole fractions in this regime are then found by interpolation
739  Real xco2r, yh2or, dxco2_dT, dyh2o_dT;
741  Tint, xco2_lower.value(), dxco2_dT_lower, xco2_upper, dxco2_dT_upper, xco2r, dxco2_dT);
743  Tint, yh2o_lower.value(), dyh2o_dT_lower, yh2o_upper, dyh2o_dT_upper, yh2or, dyh2o_dT);
744 
745  xco2 = xco2r;
746  Moose::derivInsert(xco2.derivatives(), _pidx, xco2_lower.derivatives()[_pidx]);
747  Moose::derivInsert(xco2.derivatives(), _Tidx, dxco2_dT);
748  Moose::derivInsert(xco2.derivatives(), _Xidx, xco2_lower.derivatives()[_Xidx]);
749 
750  yh2o = yh2or;
751  Moose::derivInsert(yh2o.derivatives(), _pidx, yh2o_lower.derivatives()[_pidx]);
752  Moose::derivInsert(yh2o.derivatives(), _Tidx, dyh2o_dT);
753  Moose::derivInsert(yh2o.derivatives(), _Xidx, yh2o_lower.derivatives()[_Xidx]);
754  }
755  else
756  {
757  // CO2 density and derivatives wrt pressure and temperature
758  const Real co2_density = _co2_fp.rho_from_p_T(pressure.value(), temperature.value());
759 
760  // Equilibrium mole fractions solved using iteration in this regime
761  Real xco2r, yh2or;
763  pressure.value(), temperature.value(), Xnacl.value(), co2_density, xco2r, yh2or);
764 
765  // Can use these in funcABHighTemp() to get derivatives analytically rather than by iteration
766  Real A, dA_dp, dA_dT, B, dB_dp, dB_dT, dB_dX;
767  funcABHighTemp(pressure.value(),
768  temperature.value(),
769  Xnacl.value(),
770  co2_density,
771  xco2r,
772  yh2or,
773  A,
774  dA_dp,
775  dA_dT,
776  B,
777  dB_dp,
778  dB_dT,
779  dB_dX);
780 
781  const Real dyh2o_dp =
782  ((1.0 - B) * dA_dp + (A - 1.0) * A * dB_dp) / (1.0 - A * B) / (1.0 - A * B);
783  const Real dxco2_dp = dB_dp * (1.0 - yh2or) - B * dyh2o_dp;
784 
785  const Real dyh2o_dT =
786  ((1.0 - B) * dA_dT + (A - 1.0) * A * dB_dT) / (1.0 - A * B) / (1.0 - A * B);
787  const Real dxco2_dT = dB_dT * (1.0 - yh2or) - B * dyh2o_dT;
788 
789  const Real dyh2o_dX = ((A - 1.0) * A * dB_dX) / (1.0 - A * B) / (1.0 - A * B);
790  const Real dxco2_dX = dB_dX * (1.0 - yh2or) - B * dyh2o_dX;
791 
792  xco2 = xco2r;
793  Moose::derivInsert(xco2.derivatives(), _pidx, dxco2_dp);
794  Moose::derivInsert(xco2.derivatives(), _Tidx, dxco2_dT);
795  Moose::derivInsert(xco2.derivatives(), _Xidx, dxco2_dX);
796 
797  yh2o = yh2or;
798  Moose::derivInsert(yh2o.derivatives(), _pidx, dyh2o_dp);
799  Moose::derivInsert(yh2o.derivatives(), _Tidx, dyh2o_dT);
800  Moose::derivInsert(yh2o.derivatives(), _Xidx, dyh2o_dX);
801  }
802 }
const Real _Tlower
Temperature below which the Spycher, Pruess & Ennis-King (2003) model is used (K) ...
const unsigned int _Tidx
Index of derivative wrt temperature.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
void solveEquilibriumMoleFractionHighTemp(Real pressure, Real temperature, Real Xnacl, Real co2_density, Real &xco2, Real &yh2o) const
Function to solve for yh2o and xco2 iteratively in the elevated temperature regime (T > 100C) ...
const SinglePhaseFluidProperties & _co2_fp
Fluid properties UserObject for the CO2.
const unsigned int _pidx
Index of derivative wrt pressure.
void funcABHighTemp(Real pressure, Real temperature, Real Xnacl, Real co2_density, Real xco2, Real yh2o, Real &A, Real &B) const
The function A (Eq.
void equilibriumMoleFractionsLowTemp(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, ADReal &xco2, ADReal &yh2o) const
Mole fractions of CO2 in brine and water vapor in CO2 at equilibrium in the low temperature regime (T...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)
const unsigned int _Xidx
Index of derivative wrt salt mass fraction X.
void smoothCubicInterpolation(Real temperature, Real f0, Real df0, Real f1, Real df1, Real &value, Real &deriv) const
Cubic function to smoothly interpolate between the low temperature and elevated temperature models fo...
const Real _Tupper
Temperature above which the Spycher & Pruess (2010) model is used (K)

◆ equilibriumMoleFractionsLowTemp()

void PorousFlowBrineCO2::equilibriumMoleFractionsLowTemp ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl,
ADReal xco2,
ADReal yh2o 
) const

Mole fractions of CO2 in brine and water vapor in CO2 at equilibrium in the low temperature regime (T <= 99C).

Parameters
pressurephase pressure (Pa)
temperaturephase temperature (K)
XnaclNaCl mass fraction (kg/kg)
[out]xco2mole fraction of CO2 in liquid
[out]yh2omass fraction of mole in gas

Definition at line 805 of file PorousFlowBrineCO2.C.

Referenced by equilibriumMoleFractions().

810 {
811  if (temperature.value() > 373.15)
812  mooseError(name(),
813  ": equilibriumMoleFractionsLowTemp() is not valid for T > 373.15K. Use "
814  "equilibriumMoleFractions() instead");
815 
816  // CO2 density and derivatives wrt pressure and temperature
817  const ADReal co2_density = _co2_fp.rho_from_p_T(pressure, temperature);
818 
819  // Assume infinite dilution (yh20 = 0 and xco2 = 0) in low temperature regime
820  ADReal A, B;
821  funcABLowTemp(pressure, temperature, co2_density, A, B);
822 
823  // As the activity coefficient for CO2 in brine used in this regime isn't a 'true'
824  // activity coefficient, we instead calculate the molality of CO2 in water, then
825  // correct it for brine, and then calculate the mole fractions.
826  // The mole fraction in pure water is
827  const ADReal yh2ow = (1.0 - B) / (1.0 / A - B);
828  const ADReal xco2w = B * (1.0 - yh2ow);
829 
830  // Molality of CO2 in pure water
831  const ADReal mco2w = xco2w * _invMh2o / (1.0 - xco2w);
832  // Molality of CO2 in brine is then calculated using gamma
833  const ADReal gamma = activityCoefficient(pressure, temperature, Xnacl);
834  const ADReal mco2 = mco2w / gamma;
835 
836  // Need NaCl molality (mol/kg)
837  const ADReal mnacl = Xnacl / (1.0 - Xnacl) / _Mnacl;
838 
839  // Mole fractions of CO2 and H2O in liquid and gas phases
840  const ADReal total_moles = 2.0 * mnacl + _invMh2o + mco2;
841  xco2 = mco2 / total_moles;
842  yh2o = A * (1.0 - xco2 - 2.0 * mnacl / total_moles);
843 }
ADReal activityCoefficient(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl) const
Activity coefficient for CO2 in brine.
const Real _Mnacl
Molar mass of NaCL.
const Real _invMh2o
Inverse of molar mass of H2O (mol/kg)
void funcABLowTemp(const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, ADReal &A, ADReal &B) const
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const SinglePhaseFluidProperties & _co2_fp
Fluid properties UserObject for the CO2.
const std::string & name() const
static const std::string pressure
Definition: NS.h:56
void mooseError(Args &&... args) const

◆ execute()

void PorousFlowFluidStateBase::execute ( )
inlinefinalvirtualinherited

Implements GeneralUserObject.

Definition at line 58 of file PorousFlowFluidStateBase.h.

58 {};

◆ finalize()

void PorousFlowFluidStateBase::finalize ( )
inlinefinalvirtualinherited

Implements GeneralUserObject.

Definition at line 59 of file PorousFlowFluidStateBase.h.

59 {};

◆ fluidStateName()

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

Name of FluidState.

Implements PorousFlowFluidStateBase.

Definition at line 85 of file PorousFlowBrineCO2.C.

86 {
87  return "brine-co2";
88 }

◆ fugacityCoefficientCO2HighTemp()

ADReal PorousFlowBrineCO2::fugacityCoefficientCO2HighTemp ( const ADReal pressure,
const ADReal temperature,
const ADReal co2_density,
const ADReal xco2,
const ADReal yh2o 
) const

Definition at line 506 of file PorousFlowBrineCO2.C.

Referenced by fugacityCoefficientsHighTemp().

511 {
512  using std::sqrt, std::pow, std::log, std::exp;
513 
514  // Need pressure in bar
515  const ADReal pbar = pressure * 1.0e-5;
516  // Molar volume in cm^3/mol
517  const ADReal V = _Mco2 / co2_density * 1.0e6;
518 
519  // Redlich-Kwong parameters
520  const ADReal yco2 = 1.0 - yh2o;
521  const ADReal xh2o = 1.0 - xco2;
522 
523  const ADReal aCO2 = 8.008e7 - 4.984e4 * temperature;
524  const ADReal aH2O = 1.337e8 - 1.4e4 * temperature;
525  const Real bCO2 = 28.25;
526  const Real bH2O = 15.7;
527  const ADReal KH2OCO2 = 1.427e-2 - 4.037e-4 * temperature;
528  const ADReal KCO2H2O = 0.4228 - 7.422e-4 * temperature;
529  const ADReal kH2OCO2 = KH2OCO2 * yh2o + KCO2H2O * yco2;
530  const ADReal kCO2H2O = KCO2H2O * yh2o + KH2OCO2 * yco2;
531 
532  const ADReal aH2OCO2 = sqrt(aCO2 * aH2O) * (1.0 - kH2OCO2);
533  const ADReal aCO2H2O = sqrt(aCO2 * aH2O) * (1.0 - kCO2H2O);
534 
535  const ADReal amix = yh2o * yh2o * aH2O + yh2o * yco2 * (aH2OCO2 + aCO2H2O) + yco2 * yco2 * aCO2;
536  const ADReal bmix = yh2o * bH2O + yco2 * bCO2;
537 
538  const ADReal t15 = pow(temperature, 1.5);
539 
540  ADReal lnPhiCO2 = bCO2 / bmix * (pbar * V / (_Rbar * temperature) - 1.0) -
541  log(pbar * (V - bmix) / (_Rbar * temperature));
542 
543  ADReal term3 = (2.0 * yco2 * aCO2 + yh2o * (aH2OCO2 + aCO2H2O) -
544  yh2o * yco2 * sqrt(aH2O * aCO2) * (kH2OCO2 - kCO2H2O) * (yh2o - yco2) +
545  xh2o * xco2 * sqrt(aH2O * aCO2) * (kCO2H2O - kH2OCO2)) /
546  amix;
547 
548  lnPhiCO2 += (term3 - bCO2 / bmix) * amix / (bmix * _Rbar * t15) * log(V / (V + bmix));
549 
550  return exp(lnPhiCO2);
551 }
auto exp(const T &)
const Real _Mco2
Molar mass of CO2 (kg/mol)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
auto log(const T &)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _Rbar
Molar gas constant in bar cm^3 /(K mol)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
static const std::string pressure
Definition: NS.h:56
MooseUnits pow(const MooseUnits &, int)

◆ fugacityCoefficientH2OHighTemp()

ADReal PorousFlowBrineCO2::fugacityCoefficientH2OHighTemp ( const ADReal pressure,
const ADReal temperature,
const ADReal co2_density,
const ADReal xco2,
const ADReal yh2o 
) const

Definition at line 458 of file PorousFlowBrineCO2.C.

Referenced by fugacityCoefficientsHighTemp().

463 {
464  using std::sqrt, std::pow, std::log, std::exp;
465 
466  // Need pressure in bar
467  const ADReal pbar = pressure * 1.0e-5;
468  // Molar volume in cm^3/mol
469  const ADReal V = _Mco2 / co2_density * 1.0e6;
470 
471  // Redlich-Kwong parameters
472  const ADReal yco2 = 1.0 - yh2o;
473  const ADReal xh2o = 1.0 - xco2;
474 
475  const ADReal aCO2 = 8.008e7 - 4.984e4 * temperature;
476  const ADReal aH2O = 1.337e8 - 1.4e4 * temperature;
477  const Real bCO2 = 28.25;
478  const Real bH2O = 15.7;
479  const ADReal KH2OCO2 = 1.427e-2 - 4.037e-4 * temperature;
480  const ADReal KCO2H2O = 0.4228 - 7.422e-4 * temperature;
481  const ADReal kH2OCO2 = KH2OCO2 * yh2o + KCO2H2O * yco2;
482  const ADReal kCO2H2O = KCO2H2O * yh2o + KH2OCO2 * yco2;
483 
484  const ADReal aH2OCO2 = sqrt(aCO2 * aH2O) * (1.0 - kH2OCO2);
485  const ADReal aCO2H2O = sqrt(aCO2 * aH2O) * (1.0 - kCO2H2O);
486 
487  const ADReal amix = yh2o * yh2o * aH2O + yh2o * yco2 * (aH2OCO2 + aCO2H2O) + yco2 * yco2 * aCO2;
488  const ADReal bmix = yh2o * bH2O + yco2 * bCO2;
489 
490  const ADReal t15 = pow(temperature, 1.5);
491 
492  ADReal lnPhiH2O = bH2O / bmix * (pbar * V / (_Rbar * temperature) - 1.0) -
493  log(pbar * (V - bmix) / (_Rbar * temperature));
494  ADReal term3 = (2.0 * yh2o * aH2O + yco2 * (aH2OCO2 + aCO2H2O) -
495  yh2o * yco2 * sqrt(aH2O * aCO2) * (kH2OCO2 - kCO2H2O) * (yh2o - yco2) +
496  xh2o * xco2 * sqrt(aH2O * aCO2) * (kH2OCO2 - kCO2H2O)) /
497  amix;
498  term3 -= bH2O / bmix;
499  term3 *= amix / (bmix * _Rbar * t15) * log(V / (V + bmix));
500  lnPhiH2O += term3;
501 
502  return exp(lnPhiH2O);
503 }
auto exp(const T &)
const Real _Mco2
Molar mass of CO2 (kg/mol)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
auto log(const T &)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _Rbar
Molar gas constant in bar cm^3 /(K mol)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
static const std::string pressure
Definition: NS.h:56
MooseUnits pow(const MooseUnits &, int)

◆ fugacityCoefficientsHighTemp()

void PorousFlowBrineCO2::fugacityCoefficientsHighTemp ( const ADReal pressure,
const ADReal temperature,
const ADReal co2_density,
const ADReal xco2,
const ADReal yh2o,
ADReal fco2,
ADReal fh2o 
) const

Fugacity coefficients for H2O and CO2 at elevated temperatures (100C < T <= 300C).

Eq. (A8) from Spycher & Pruess (2010)

Parameters
pressuregas pressure (Pa)
temperaturetemperature (K)
co2_densityCO2 density (kg/m^3)
xco2mole fraction of CO2 in liquid phase (-)
yh2omole fraction of H2O in gas phase (-)
[out]fco2fugacity coefficient for CO2
[out]fh2ofugacity coefficient for H2O

Definition at line 440 of file PorousFlowBrineCO2.C.

Referenced by funcABHighTemp().

447 {
448  if (temperature.value() <= 373.15)
449  mooseError(name(),
450  ": fugacityCoefficientsHighTemp() is not valid for T <= 373.15K. Use "
451  "fugacityCoefficientsLowTemp() instead");
452 
453  fh2o = fugacityCoefficientH2OHighTemp(pressure, temperature, co2_density, xco2, yh2o);
454  fco2 = fugacityCoefficientCO2HighTemp(pressure, temperature, co2_density, xco2, yh2o);
455 }
ADReal fugacityCoefficientH2OHighTemp(const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, const ADReal &xco2, const ADReal &yh2o) const
static const std::string temperature
Definition: NS.h:59
const std::string & name() const
ADReal fugacityCoefficientCO2HighTemp(const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, const ADReal &xco2, const ADReal &yh2o) const
static const std::string pressure
Definition: NS.h:56
void mooseError(Args &&... args) const

◆ fugacityCoefficientsLowTemp()

void PorousFlowBrineCO2::fugacityCoefficientsLowTemp ( const ADReal pressure,
const ADReal temperature,
const ADReal co2_density,
ADReal fco2,
ADReal fh2o 
) const

Fugacity coefficients for H2O and CO2 for T <= 100C Eq.

(B7) from Spycher, Pruess and Ennis-King (2003)

Parameters
pressuregas pressure (Pa)
temperaturetemperature (K)
co2_densityCO2 density (kg/m^3)
[out]fco2fugacity coefficient for CO2
[out]fh2ofugacity coefficient for H2O

Definition at line 397 of file PorousFlowBrineCO2.C.

Referenced by funcABLowTemp().

402 {
403  using std::log, std::exp, std::pow;
404 
405  if (temperature.value() > 373.15)
406  mooseError(name(),
407  ": fugacityCoefficientsLowTemp() is not valid for T > 373.15K. Use "
408  "fugacityCoefficientsHighTemp() instead");
409 
410  // Need pressure in bar
411  const ADReal pbar = pressure * 1.0e-5;
412 
413  // Molar volume in cm^3/mol
414  const ADReal V = _Mco2 / co2_density * 1.0e6;
415 
416  // Redlich-Kwong parameters
417  const ADReal aCO2 = 7.54e7 - 4.13e4 * temperature;
418  const Real bCO2 = 27.8;
419  const Real aCO2H2O = 7.89e7;
420  const Real bH2O = 18.18;
421 
422  const ADReal t15 = pow(temperature, 1.5);
423 
424  // The fugacity coefficients for H2O and CO2
425  auto lnPhi = [V, aCO2, bCO2, t15, this](ADReal a, ADReal b)
426  {
427  return log(V / (V - bCO2)) + b / (V - bCO2) -
428  2.0 * a / (_Rbar * t15 * bCO2) * log((V + bCO2) / V) +
429  aCO2 * b / (_Rbar * t15 * bCO2 * bCO2) * (log((V + bCO2) / V) - bCO2 / (V + bCO2));
430  };
431 
432  const ADReal lnPhiH2O = lnPhi(aCO2H2O, bH2O) - log(pbar * V / (_Rbar * temperature));
433  const ADReal lnPhiCO2 = lnPhi(aCO2, bCO2) - log(pbar * V / (_Rbar * temperature));
434 
435  fh2o = exp(lnPhiH2O);
436  fco2 = exp(lnPhiCO2);
437 }
auto exp(const T &)
const Real _Mco2
Molar mass of CO2 (kg/mol)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const std::string & name() const
auto log(const T &)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const Real _Rbar
Molar gas constant in bar cm^3 /(K mol)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56
void mooseError(Args &&... args) const
MooseUnits pow(const MooseUnits &, int)

◆ funcABHighTemp() [1/2]

void PorousFlowBrineCO2::funcABHighTemp ( Real  pressure,
Real  temperature,
Real  Xnacl,
Real  co2_density,
Real  xco2,
Real  yh2o,
Real A,
Real B 
) const
protected

The function A (Eq.

(11) of Spycher, Pruess and Ennis-King (2003) for T <= 100C, and Eqs. (10) and (17) of Spycher and Pruess (2010) for T > 100C)

Parameters
pressuregas pressure (Pa)
temperaturefluid temperature (K)
XnaclNaCl mass fraction (kg/kg)
co2_densityCO2 density (kg/m^3)
xco2mole fraction of CO2 in liquid phase (-)
yh2omole fraction of H2O in gas phase (-)
[out]Athe function A
[out]Bthe function B

Definition at line 882 of file PorousFlowBrineCO2.C.

Referenced by equilibriumMoleFractions(), funcABHighTemp(), and solveEquilibriumMoleFractionHighTemp().

890 {
891  using std::exp;
892 
893  if (temperature <= 373.15)
894  mooseError(name(),
895  ": funcABHighTemp() is not valid for T <= 373.15K. Use funcABLowTemp() instead");
896 
897  // Pressure in bar
898  const Real pbar = pressure * 1.0e-5;
899  // Temperature in C
900  const Real Tc = temperature - _T_c2k;
901 
902  // Reference pressure and partial molar volumes
903  const Real pref = -1.9906e-1 + 2.0471e-3 * Tc + 1.0152e-4 * Tc * Tc - 1.4234e-6 * Tc * Tc * Tc +
904  1.4168e-8 * Tc * Tc * Tc * Tc;
905  const Real vCO2 = 32.6 + 3.413e-2 * (Tc - 100.0);
906  const Real vH2O = 18.1 + 3.137e-2 * (Tc - 100.0);
907 
908  const Real delta_pbar = pbar - pref;
909  const Real Rt = _Rbar * temperature;
910 
911  // Equilibrium constants
912  // Use dummy ADReal temperature as derivatives aren't required
913  const ADReal T = temperature;
914  Real K0H2O = equilibriumConstantH2O(T).value();
915  Real K0CO2 = equilibriumConstantCO2(T).value();
916 
917  // Fugacity coefficients
918  // Use dummy ADReal variables as derivatives aren't required
919  const ADReal p = pressure;
920  const ADReal rhoco2 = co2_density;
921  const ADReal x = xco2;
922  const ADReal y = yh2o;
923 
924  ADReal phiH2O, phiCO2;
925  fugacityCoefficientsHighTemp(p, T, rhoco2, x, y, phiCO2, phiH2O);
926 
927  // Activity coefficients
928  const Real gammaH2O = activityCoefficientH2O(T, x).value();
929  const Real gammaCO2 = activityCoefficientCO2(T, x).value();
930 
931  // Activity coefficient for CO2 in brine
932  // Use dummy ADReal Xnacl as derivatives aren't required
933  const ADReal X = Xnacl;
934  const Real gamma = activityCoefficientHighTemp(T, X).value();
935 
936  A = K0H2O * gammaH2O / (phiH2O.value() * pbar) * exp(delta_pbar * vH2O / Rt);
937  B = phiCO2.value() * pbar / (_invMh2o * K0CO2 * gamma * gammaCO2) * exp(-delta_pbar * vCO2 / Rt);
938 }
const Real _T_c2k
Conversion from C to K.
auto exp(const T &)
ADReal activityCoefficientHighTemp(const ADReal &temperature, const ADReal &Xnacl) const
Activity coefficient for CO2 in brine used in the elevated temperature formulation.
ADReal equilibriumConstantH2O(const ADReal &temperature) const
Equilibrium constant for H2O For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2...
const Real _invMh2o
Inverse of molar mass of H2O (mol/kg)
void fugacityCoefficientsHighTemp(const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, const ADReal &xco2, const ADReal &yh2o, ADReal &fco2, ADReal &fh2o) const
Fugacity coefficients for H2O and CO2 at elevated temperatures (100C < T <= 300C).
const std::vector< double > y
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const std::string & name() const
const std::vector< double > x
ADReal activityCoefficientH2O(const ADReal &temperature, const ADReal &xco2) const
Activity coefficient of H2O Eq.
ADReal activityCoefficientCO2(const ADReal &temperature, const ADReal &xco2) const
Activity coefficient of CO2 Eq.
const Real _Rbar
Molar gas constant in bar cm^3 /(K mol)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56
void mooseError(Args &&... args) const
ADReal equilibriumConstantCO2(const ADReal &temperature) const
Equilibrium constant for CO2 For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2...

◆ funcABHighTemp() [2/2]

void PorousFlowBrineCO2::funcABHighTemp ( Real  pressure,
Real  temperature,
Real  Xnacl,
Real  co2_density,
Real  xco2,
Real  yh2o,
Real A,
Real dA_dp,
Real dA_dT,
Real B,
Real dB_dp,
Real dB_dT,
Real dB_dX 
) const
protected

Definition at line 941 of file PorousFlowBrineCO2.C.

954 {
955  funcABHighTemp(pressure, temperature, Xnacl, co2_density, xco2, yh2o, A, B);
956 
957  // Use finite differences for derivatives in the high temperature regime
958  const Real dp = 1.0e-2;
959  const Real dT = 1.0e-6;
960  const Real dX = 1.0e-8;
961 
962  Real A2, B2;
963  funcABHighTemp(pressure + dp, temperature, Xnacl, co2_density, xco2, yh2o, A2, B2);
964  dA_dp = (A2 - A) / dp;
965  dB_dp = (B2 - B) / dp;
966 
967  funcABHighTemp(pressure, temperature + dT, Xnacl, co2_density, xco2, yh2o, A2, B2);
968  dA_dT = (A2 - A) / dT;
969  dB_dT = (B2 - B) / dT;
970 
971  funcABHighTemp(pressure, temperature, Xnacl + dX, co2_density, xco2, yh2o, A2, B2);
972  dB_dX = (B2 - B) / dX;
973 }
static const std::string temperature
Definition: NS.h:59
void funcABHighTemp(Real pressure, Real temperature, Real Xnacl, Real co2_density, Real xco2, Real yh2o, Real &A, Real &B) const
The function A (Eq.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56

◆ funcABLowTemp()

void PorousFlowBrineCO2::funcABLowTemp ( const ADReal pressure,
const ADReal temperature,
const ADReal co2_density,
ADReal A,
ADReal B 
) const
protected

Definition at line 846 of file PorousFlowBrineCO2.C.

Referenced by equilibriumMoleFractionsLowTemp().

851 {
852  using std::exp;
853 
854  if (temperature.value() > 373.15)
855  mooseError(name(),
856  ": funcABLowTemp() is not valid for T > 373.15K. Use funcABHighTemp() instead");
857 
858  // Pressure in bar
859  const ADReal pbar = pressure * 1.0e-5;
860 
861  // Reference pressure and partial molar volumes
862  const Real pref = 1.0;
863  const Real vCO2 = 32.6;
864  const Real vH2O = 18.1;
865 
866  const ADReal delta_pbar = pbar - pref;
867  const ADReal Rt = _Rbar * temperature;
868 
869  // Equilibrium constants
872 
873  // Fugacity coefficients
874  ADReal phiH2O, phiCO2;
875  fugacityCoefficientsLowTemp(pressure, temperature, co2_density, phiCO2, phiH2O);
876 
877  A = K0H2O / (phiH2O * pbar) * exp(delta_pbar * vH2O / Rt);
878  B = phiCO2 * pbar / (_invMh2o * K0CO2) * exp(-delta_pbar * vCO2 / Rt);
879 }
auto exp(const T &)
ADReal equilibriumConstantH2O(const ADReal &temperature) const
Equilibrium constant for H2O For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2...
const Real _invMh2o
Inverse of molar mass of H2O (mol/kg)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const std::string & name() const
void fugacityCoefficientsLowTemp(const ADReal &pressure, const ADReal &temperature, const ADReal &co2_density, ADReal &fco2, ADReal &fh2o) const
Fugacity coefficients for H2O and CO2 for T <= 100C Eq.
const Real _Rbar
Molar gas constant in bar cm^3 /(K mol)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56
void mooseError(Args &&... args) const
ADReal equilibriumConstantCO2(const ADReal &temperature) const
Equilibrium constant for CO2 For temperatures 12C <= T <= 99C, uses Spycher, Pruess and Ennis-King (2...

◆ gasComponentIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::gasComponentIndex ( ) const
inlineinherited

The index of the gas fluid component.

Returns
gas fluid component number

Definition at line 35 of file PorousFlowFluidStateMultiComponentBase.h.

35 { 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 83 of file PorousFlowFluidStateBase.h.

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

◆ gasProperties()

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

Thermophysical properties of the gaseous state.

Parameters
pressuregas pressure (Pa)
temperaturetemperature (K)
[out]FluidStatePropertiesdata structure

Definition at line 242 of file PorousFlowBrineCO2.C.

Referenced by thermophysicalProperties(), totalMassFraction(), and twoPhaseProperties().

245 {
247 
248  // Gas density, viscosity and enthalpy are approximated with pure CO2 - no correction due
249  // to the small amount of water vapor is made
250  ADReal co2_density, co2_viscosity;
251  _co2_fp.rho_mu_from_p_T(pressure, temperature, co2_density, co2_viscosity);
252 
253  ADReal co2_enthalpy = _co2_fp.h_from_p_T(pressure, temperature);
254 
255  // Save the values to the FluidStateProperties object. Note that derivatives wrt z are 0
256  gas.density = co2_density;
257  gas.viscosity = co2_viscosity;
258  gas.enthalpy = co2_enthalpy;
259 
260  mooseAssert(gas.density.value() > 0.0, "Gas density must be greater than zero");
261  gas.internal_energy = gas.enthalpy - pressure / gas.density;
262 }
unsigned int _gas_phase_number
Phase number of the gas phase.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const SinglePhaseFluidProperties & _co2_fp
Fluid properties UserObject for the CO2.
AD data structure to pass calculated thermophysical properties.
virtual void rho_mu_from_p_T(Real p, Real T, Real &rho, Real &mu) const
Combined methods.
static const std::string pressure
Definition: NS.h:56

◆ getPressureIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getPressureIndex ( ) const
inlineinherited

◆ getTemperatureIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getTemperatureIndex ( ) const
inlineinherited

Definition at line 93 of file PorousFlowFluidStateMultiComponentBase.h.

Referenced by PorousFlowWaterNCGTest::buildObjects(), and PorousFlowBrineCO2Test::buildObjects().

93 { return _Tidx; };
const unsigned int _Tidx
Index of derivative wrt temperature.

◆ getXIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getXIndex ( ) const
inlineinherited

Definition at line 95 of file PorousFlowFluidStateMultiComponentBase.h.

Referenced by PorousFlowBrineCO2Test::buildObjects().

95 { return _Xidx; };
const unsigned int _Xidx
Index of derivative wrt salt mass fraction X.

◆ getZIndex()

unsigned int PorousFlowFluidStateMultiComponentBase::getZIndex ( ) const
inlineinherited

Definition at line 94 of file PorousFlowFluidStateMultiComponentBase.h.

Referenced by PorousFlowWaterNCGTest::buildObjects(), and PorousFlowBrineCO2Test::buildObjects().

94 { return _Zidx; };
const unsigned int _Zidx
Index of derivative wrt total mass fraction Z.

◆ henryConstant()

ADReal PorousFlowBrineCO2::henryConstant ( const ADReal temperature,
const ADReal Xnacl 
) const

Henry's constant of dissolution of gas phase CO2 in brine.

From Battistelli et al, A fluid property module for the TOUGH2 simulator for saline brines with non-condensible gas, Proc. Eighteenth Workshop on Geothermal Reservoir Engineering (1993)

Parameters
temperaturefluid temperature (K)
XnaclNaCl mass fraction (kg/kg)
Returns
Henry's constant (Pa)

Definition at line 1097 of file PorousFlowBrineCO2.C.

Referenced by enthalpyOfDissolutionGas().

1098 {
1099  using std::pow;
1100 
1101  // Henry's constant for dissolution in water
1103 
1104  // The correction to salt is obtained through the salting out coefficient
1105  const std::vector<Real> b{1.19784e-1, -7.17823e-4, 4.93854e-6, -1.03826e-8, 1.08233e-11};
1106 
1107  // Need temperature in Celsius
1108  const ADReal Tc = temperature - _T_c2k;
1109 
1110  ADReal kb = 0.0;
1111  for (unsigned int i = 0; i < b.size(); ++i)
1112  kb += b[i] * pow(Tc, i);
1113 
1114  // Need salt mass fraction in molality
1115  const ADReal xmol = Xnacl / (1.0 - Xnacl) / _Mnacl;
1116 
1117  // Henry's constant and its derivative wrt temperature and salt mass fraction
1118  return Kh_h2o * pow(10.0, xmol * kb);
1119 }
const Real _T_c2k
Conversion from C to K.
const Real _Mnacl
Molar mass of NaCL.
const std::vector< Real > _co2_henry
Henry&#39;s coefficeients for CO2.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const BrineFluidProperties & _brine_fp
Fluid properties UserObject for water.
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
Real henryConstant(Real temperature, const std::vector< Real > &coeffs) const
IAPWS formulation of Henry&#39;s law constant for dissolution in water (implemented in water FluidPropert...
MooseUnits pow(const MooseUnits &, int)

◆ initialize()

void PorousFlowFluidStateBase::initialize ( )
inlinefinalvirtualinherited

Implements GeneralUserObject.

Definition at line 57 of file PorousFlowFluidStateBase.h.

57 {};

◆ liquidProperties()

void PorousFlowBrineCO2::liquidProperties ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl,
std::vector< FluidStateProperties > &  fsp 
) const

Thermophysical properties of the liquid state.

Parameters
pressureliquid pressure (Pa)
temperaturetemperature (K)
XnaclNaCl mass fraction (kg/kg)
[out]FluidStatePropertiesdata structure

Definition at line 265 of file PorousFlowBrineCO2.C.

Referenced by thermophysicalProperties(), totalMassFraction(), and twoPhaseProperties().

269 {
271 
272  // The liquid density includes the density increase due to dissolved CO2
273  const ADReal brine_density = _brine_fp.rho_from_p_T_X(pressure, temperature, Xnacl);
274 
275  // Mass fraction of CO2 in liquid phase
276  const ADReal Xco2 = liquid.mass_fraction[_gas_fluid_component];
277 
278  // The liquid density
279  const ADReal co2_partial_density = partialDensityCO2(temperature);
280 
281  const ADReal liquid_density = 1.0 / (Xco2 / co2_partial_density + (1.0 - Xco2) / brine_density);
282 
283  // Assume that liquid viscosity is just the brine viscosity
284  const ADReal liquid_viscosity = _brine_fp.mu_from_p_T_X(pressure, temperature, Xnacl);
285 
286  // Liquid enthalpy (including contribution due to the enthalpy of dissolution)
287  const ADReal brine_enthalpy = _brine_fp.h_from_p_T_X(pressure, temperature, Xnacl);
288 
289  // Enthalpy of CO2
290  const ADReal co2_enthalpy = _co2_fp.h_from_p_T(pressure, temperature);
291 
292  // Enthalpy of dissolution
294 
295  const ADReal liquid_enthalpy = (1.0 - Xco2) * brine_enthalpy + Xco2 * (co2_enthalpy + hdis);
296 
297  // Save the values to the FluidStateProperties object
298  liquid.density = liquid_density;
299  liquid.viscosity = liquid_viscosity;
300  liquid.enthalpy = liquid_enthalpy;
301 
302  mooseAssert(liquid.density.value() > 0.0, "Liquid density must be greater than zero");
303  liquid.internal_energy = liquid.enthalpy - pressure / liquid.density;
304 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
FPADReal h_from_p_T_X(const FPADReal &pressure, const FPADReal &temperature, const FPADReal &xnacl) const
virtual Real rho_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
static const std::string temperature
Definition: NS.h:59
virtual Real mu_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override
DualNumber< Real, DNDerivativeType, true > ADReal
const BrineFluidProperties & _brine_fp
Fluid properties UserObject for water.
const SinglePhaseFluidProperties & _co2_fp
Fluid properties UserObject for the CO2.
ADReal partialDensityCO2(const ADReal &temperature) const
Partial density of dissolved CO2 From Garcia, Density of aqueous solutions of CO2, LBNL-49023 (2001)
ADReal enthalpyOfDissolution(const ADReal &temperature) const
Enthalpy of dissolution of CO2 in brine calculated using linear fit to model of Duan and Sun...
AD data structure to pass calculated thermophysical properties.
static const std::string pressure
Definition: NS.h:56
std::vector< ADReal > mass_fraction

◆ massFractions()

void PorousFlowBrineCO2::massFractions ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl,
const ADReal Z,
FluidStatePhaseEnum phase_state,
std::vector< FluidStateProperties > &  fsp 
) const

Mass fractions of CO2 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 (K)
XnaclNaCl mass fraction (kg/kg)
Ztotal mass fraction of CO2 component
[out]PhaseStateEnumcurrent phase state
[out]FluidStatePropertiesdata structure

Definition at line 171 of file PorousFlowBrineCO2.C.

Referenced by thermophysicalProperties().

177 {
180 
181  ADReal Xco2 = 0.0;
182  ADReal Yh2o = 0.0;
183  ADReal Yco2 = 0.0;
184 
185  // If the amount of CO2 is less than the smallest solubility, then all CO2 will
186  // be dissolved, and the equilibrium mass fractions do not need to be computed
187  if (Z.value() < _Zmin)
188  phase_state = FluidStatePhaseEnum::LIQUID;
189 
190  else
191  {
192  // Equilibrium mass fraction of CO2 in liquid and H2O in gas phases
193  equilibriumMassFractions(pressure, temperature, Xnacl, Xco2, Yh2o);
194 
195  Yco2 = 1.0 - Yh2o;
196 
197  // Determine which phases are present based on the value of z
198  phaseState(Z.value(), Xco2.value(), Yco2.value(), phase_state);
199  }
200 
201  // The equilibrium mass fractions calculated above are only correct in the two phase
202  // state. If only liquid or gas phases are present, the mass fractions are given by
203  // the total mass fraction z
204  ADReal Xh2o = 0.0;
205 
206  switch (phase_state)
207  {
209  {
210  Xco2 = Z;
211  Yco2 = 0.0;
212  Xh2o = 1.0 - Z;
213  Yh2o = 0.0;
214  break;
215  }
216 
218  {
219  Xco2 = 0.0;
220  Yco2 = Z;
221  Yh2o = 1.0 - Z;
222  break;
223  }
224 
226  {
227  // Keep equilibrium mass fractions
228  Xh2o = 1.0 - Xco2;
229  break;
230  }
231  }
232 
233  // Save the mass fractions in the FluidStateProperties object
235  liquid.mass_fraction[_gas_fluid_component] = Xco2;
236  liquid.mass_fraction[_salt_component] = Xnacl;
239 }
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
const unsigned int _salt_component
Salt component index.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
unsigned int _gas_phase_number
Phase number of the gas phase.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
void equilibriumMassFractions(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, ADReal &Xco2, ADReal &Yh2o) const
Mass fractions of CO2 in brine and water vapor in CO2 at equilibrium.
AD data structure to pass calculated thermophysical properties.
static const std::string Z
Definition: NS.h:169
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.
static const std::string pressure
Definition: NS.h:56
const Real _Zmin
Minimum Z - below this value all CO2 will be dissolved.
std::vector< ADReal > mass_fraction

◆ numComponents()

unsigned int PorousFlowFluidStateBase::numComponents ( ) const
inlineinherited

The maximum number of components in this model.

Returns
number of components

Definition at line 71 of file PorousFlowFluidStateBase.h.

71 { 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 65 of file PorousFlowFluidStateBase.h.

Referenced by PorousFlowFluidStateSingleComponentTempl< is_ad >::PorousFlowFluidStateSingleComponentTempl(), and PorousFlowFluidStateTempl< is_ad >::PorousFlowFluidStateTempl().

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

◆ partialDensityCO2()

ADReal PorousFlowBrineCO2::partialDensityCO2 ( const ADReal temperature) const

Partial density of dissolved CO2 From Garcia, Density of aqueous solutions of CO2, LBNL-49023 (2001)

Parameters
temperaturefluid temperature (K)
Returns
partial molar density (kg/m^3)

Definition at line 1043 of file PorousFlowBrineCO2.C.

Referenced by liquidProperties(), and saturation().

1044 {
1045  // This correlation uses temperature in C
1046  const ADReal Tc = temperature - _T_c2k;
1047  // The parial molar volume
1048  const ADReal V = 37.51 - 9.585e-2 * Tc + 8.74e-4 * Tc * Tc - 5.044e-7 * Tc * Tc * Tc;
1049 
1050  return 1.0e6 * _Mco2 / V;
1051 }
const Real _T_c2k
Conversion from C to K.
const Real _Mco2
Molar mass of CO2 (kg/mol)
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal

◆ phaseState()

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

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

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

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

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

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

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

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

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

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

◆ saltComponentIndex()

unsigned int PorousFlowBrineCO2::saltComponentIndex ( ) const
inline

The index of the salt component.

Returns
salt component number

Definition at line 321 of file PorousFlowBrineCO2.h.

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

◆ saturation()

ADReal PorousFlowBrineCO2::saturation ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl,
const ADReal Z,
std::vector< FluidStateProperties > &  fsp 
) const

Gas saturation in the two-phase region.

Parameters
pressuregas pressure (Pa)
temperaturephase temperature (K)
XnaclNaCl mass fraction (kg/kg)
Ztotal mass fraction of CO2 component
FluidStatePropertiesdata structure
Returns
gas saturation (-)

Definition at line 307 of file PorousFlowBrineCO2.C.

Referenced by totalMassFraction(), and twoPhaseProperties().

312 {
313  auto & gas = fsp[_gas_phase_number];
314  auto & liquid = fsp[_aqueous_fluid_component];
315 
316  // Approximate liquid density as saturation isn't known yet, by using the gas
317  // pressure rather than the liquid pressure. This does result in a small error
318  // in the calculated saturation, but this is below the error associated with
319  // the correlations. A more accurate saturation could be found iteraviely,
320  // at the cost of increased computational expense
321 
322  // Gas density
323  const ADReal gas_density = _co2_fp.rho_from_p_T(pressure, temperature);
324 
325  // Approximate liquid density as saturation isn't known yet
326  const ADReal brine_density = _brine_fp.rho_from_p_T_X(pressure, temperature, Xnacl);
327 
328  // Mass fraction of CO2 in liquid phase
329  const ADReal Xco2 = liquid.mass_fraction[_gas_fluid_component];
330 
331  // The liquid density
332  const ADReal co2_partial_density = partialDensityCO2(temperature);
333 
334  const ADReal liquid_density = 1.0 / (Xco2 / co2_partial_density + (1.0 - Xco2) / brine_density);
335 
336  const ADReal Yco2 = gas.mass_fraction[_gas_fluid_component];
337 
338  // Set mass equilibrium constants used in the calculation of vapor mass fraction
339  const ADReal K0 = Yco2 / Xco2;
340  const ADReal K1 = (1.0 - Yco2) / (1.0 - Xco2);
341  const ADReal vapor_mass_fraction = vaporMassFraction(Z, K0, K1);
342 
343  // The gas saturation in the two phase case
344  const ADReal saturation = vapor_mass_fraction * liquid_density /
345  (gas_density + vapor_mass_fraction * (liquid_density - gas_density));
346 
347  return saturation;
348 }
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
virtual Real rho_from_p_T_X(Real pressure, Real temperature, Real xnacl) const override
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
unsigned int _gas_phase_number
Phase number of the gas phase.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const BrineFluidProperties & _brine_fp
Fluid properties UserObject for water.
const SinglePhaseFluidProperties & _co2_fp
Fluid properties UserObject for the CO2.
ADReal partialDensityCO2(const ADReal &temperature) const
Partial density of dissolved CO2 From Garcia, Density of aqueous solutions of CO2, LBNL-49023 (2001)
static const std::string Z
Definition: NS.h:169
Real vaporMassFraction(Real Z0, Real K0, Real K1) const
Solves Rachford-Rice equation to provide vapor mass fraction.
static const std::string pressure
Definition: NS.h:56
ADReal saturation(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, std::vector< FluidStateProperties > &fsp) const
Gas saturation in the two-phase region.

◆ smoothCubicInterpolation()

void PorousFlowBrineCO2::smoothCubicInterpolation ( Real  temperature,
Real  f0,
Real  df0,
Real  f1,
Real  df1,
Real value,
Real deriv 
) const
protected

Cubic function to smoothly interpolate between the low temperature and elevated temperature models for 99C < T < 109C.

Parameters
temperaturetemperature (K)
f0function value at T = 372K (99C)
df0derivative of function at T = 372K (99C)
f1function value at T = 382K (109C)
df1derivative of function at T = 382K (109C)
[out]valuevalue at the given temperature
[out]derivderivative at the given temperature

Definition at line 1162 of file PorousFlowBrineCO2.C.

Referenced by equilibriumMoleFractions().

1164 {
1165  // Coefficients of cubic polynomial
1166  const Real dT = _Tupper - _Tlower;
1167 
1168  const Real a = f0;
1169  const Real b = df0 * dT;
1170  const Real c = 3.0 * (f1 - f0) - (2.0 * df0 + df1) * dT;
1171  const Real d = 2.0 * (f0 - f1) + (df0 + df1) * dT;
1172 
1173  const Real t2 = temperature * temperature;
1174  const Real t3 = temperature * t2;
1175 
1176  value = a + b * temperature + c * t2 + d * t3;
1177  deriv = b + 2.0 * c * temperature + 3.0 * d * t2;
1178 }
const Real _Tlower
Temperature below which the Spycher, Pruess & Ennis-King (2003) model is used (K) ...
static const std::string temperature
Definition: NS.h:59
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
Real deriv(unsigned n, unsigned alpha, unsigned beta, Real x)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const Real _Tupper
Temperature above which the Spycher & Pruess (2010) model is used (K)

◆ solveEquilibriumMoleFractionHighTemp()

void PorousFlowBrineCO2::solveEquilibriumMoleFractionHighTemp ( Real  pressure,
Real  temperature,
Real  Xnacl,
Real  co2_density,
Real xco2,
Real yh2o 
) const

Function to solve for yh2o and xco2 iteratively in the elevated temperature regime (T > 100C)

Parameters
pressuregas pressure (Pa)
temperaturefluid temperature (K)
XnaclNaCl mass fraction (kg/kg)
co2_densityCO2 density (kg/m^3)
[out]xco2mole fraction of CO2 in liquid phase (-)
[out]yh2omole fraction of H2O in gas phase (-)

Definition at line 976 of file PorousFlowBrineCO2.C.

Referenced by equilibriumMoleFractions().

978 {
979  // Initial guess for yh2o and xco2 (from Spycher and Pruess (2010))
981  Real x = 0.009;
982 
983  // Need salt mass fraction in molality
984  const Real mnacl = Xnacl / (1.0 - Xnacl) / _Mnacl;
985 
986  // If y > 1, then just use y = 1, x = 0 (only a gas phase)
987  if (y >= 1.0)
988  {
989  y = 1.0;
990  x = 0.0;
991  }
992  else
993  {
994  // Residual function for Newton-Raphson
995  auto fy = [mnacl, this](Real y, Real A, Real B) {
996  return y -
997  (1.0 - B) * _invMh2o / ((1.0 / A - B) * (2.0 * mnacl + _invMh2o) + 2.0 * mnacl * B);
998  };
999 
1000  // Derivative of fy wrt y
1001  auto dfy = [mnacl, this](Real A, Real B, Real dA, Real dB)
1002  {
1003  const Real denominator = (1.0 / A - B) * (2.0 * mnacl + _invMh2o) + 2.0 * mnacl * B;
1004  return 1.0 + _invMh2o * dB / denominator +
1005  (1.0 - B) * _invMh2o *
1006  (2.0 * mnacl * dB - (2.0 * mnacl + _invMh2o) * (dB + dA / A / A)) / denominator /
1007  denominator;
1008  };
1009 
1010  Real A, B;
1011  Real dA, dB;
1012  const Real dy = 1.0e-8;
1013 
1014  // Solve for yh2o using Newton-Raphson method
1015  unsigned int iter = 0;
1016  const Real tol = 1.0e-12;
1017  const unsigned int max_its = 10;
1018  funcABHighTemp(pressure, temperature, Xnacl, co2_density, x, y, A, B);
1019 
1020  while (std::abs(fy(y, A, B)) > tol)
1021  {
1022  funcABHighTemp(pressure, temperature, Xnacl, co2_density, x, y, A, B);
1023  // Finite difference derivatives of A and B wrt y
1024  funcABHighTemp(pressure, temperature, Xnacl, co2_density, x, y + dy, dA, dB);
1025  dA = (dA - A) / dy;
1026  dB = (dB - B) / dy;
1027 
1028  y = y - fy(y, A, B) / dfy(A, B, dA, dB);
1029 
1030  x = B * (1.0 - y);
1031 
1032  // Break if not converged and just use the value
1033  if (iter > max_its)
1034  break;
1035  }
1036  }
1037 
1038  yh2o = y;
1039  xco2 = x;
1040 }
const Real _Mnacl
Molar mass of NaCL.
const Real _invMh2o
Inverse of molar mass of H2O (mol/kg)
const double tol
const std::vector< double > y
static const std::string temperature
Definition: NS.h:59
const BrineFluidProperties & _brine_fp
Fluid properties UserObject for water.
Real vaporPressure(Real temperature, Real xnacl) const
Brine vapour pressure From Haas, Physical properties of the coexisting phases and thermochemical prop...
void funcABHighTemp(Real pressure, Real temperature, Real Xnacl, Real co2_density, Real xco2, Real yh2o, Real &A, Real &B) const
The function A (Eq.
const std::vector< double > x
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string pressure
Definition: NS.h:56

◆ thermophysicalProperties() [1/2]

void PorousFlowBrineCO2::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 PorousFlowFluidStateMultiComponentBase.

Definition at line 91 of file PorousFlowBrineCO2.C.

97 {
98  // Make AD versions of primary variables then call AD thermophysicalProperties()
99  ADReal p = pressure;
100  Moose::derivInsert(p.derivatives(), _pidx, 1.0);
101  ADReal T = temperature;
102  Moose::derivInsert(T.derivatives(), _Tidx, 1.0);
103  ADReal Zco2 = Z;
104  Moose::derivInsert(Zco2.derivatives(), _Zidx, 1.0);
105  ADReal X = Xnacl;
106  Moose::derivInsert(X.derivatives(), _Xidx, 1.0);
107 
108  thermophysicalProperties(p, T, X, Zco2, qp, fsp);
109 }
const unsigned int _Tidx
Index of derivative wrt temperature.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const unsigned int _pidx
Index of derivative wrt pressure.
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...
static const std::string Z
Definition: NS.h:169
static const std::string pressure
Definition: NS.h:56
const unsigned int _Zidx
Index of derivative wrt total mass fraction Z.
void derivInsert(SemiDynamicSparseNumberArray< Real, libMesh::dof_id_type, NWrapper< N >> &derivs, libMesh::dof_id_type index, Real value)
const unsigned int _Xidx
Index of derivative wrt salt mass fraction X.

◆ thermophysicalProperties() [2/2]

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

Implements PorousFlowFluidStateMultiComponentBase.

Definition at line 112 of file PorousFlowBrineCO2.C.

118 {
121 
122  // Check whether the input temperature is within the region of validity
123  checkVariables(pressure.value(), temperature.value());
124 
125  // Clear all of the FluidStateProperties data
127 
128  FluidStatePhaseEnum phase_state;
129  massFractions(pressure, temperature, Xnacl, Z, phase_state, fsp);
130 
131  switch (phase_state)
132  {
134  {
135  // Set the gas saturations
136  gas.saturation = 1.0;
137 
138  // Calculate gas properties
140 
141  break;
142  }
143 
145  {
146  // Calculate the liquid properties
147  const ADReal liquid_pressure = pressure - _pc.capillaryPressure(1.0, qp);
148  liquidProperties(liquid_pressure, temperature, Xnacl, fsp);
149 
150  break;
151  }
152 
154  {
155  // Calculate the gas and liquid properties in the two phase region
156  twoPhaseProperties(pressure, temperature, Xnacl, Z, qp, fsp);
157 
158  break;
159  }
160  }
161 
162  // Liquid saturations can now be set
163  liquid.saturation = 1.0 - gas.saturation;
164 
165  // Save pressures to FluidStateProperties object
166  gas.pressure = pressure;
167  liquid.pressure = pressure - _pc.capillaryPressure(liquid.saturation, qp);
168 }
void liquidProperties(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, std::vector< FluidStateProperties > &fsp) const
Thermophysical properties of the liquid state.
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
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.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
virtual Real capillaryPressure(Real saturation, unsigned qp=0) const
Capillary pressure is calculated as a function of true saturation.
AD data structure to pass calculated thermophysical properties.
FluidStatePhaseEnum
Phase state enum.
void twoPhaseProperties(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const
Gas and liquid properties in the two-phase region.
static const std::string Z
Definition: NS.h:169
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
void massFractions(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, FluidStatePhaseEnum &phase_state, std::vector< FluidStateProperties > &fsp) const
Mass fractions of CO2 and H2O in both phases, as well as derivatives wrt PorousFlow variables...
void gasProperties(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Thermophysical properties of the gaseous state.
static const std::string pressure
Definition: NS.h:56
virtual void checkVariables(Real pressure, Real temperature) const
Check the input variables.

◆ totalMassFraction()

Real PorousFlowBrineCO2::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 PorousFlowFluidStateMultiComponentBase.

Definition at line 1054 of file PorousFlowBrineCO2.C.

1056 {
1057  // Check whether the input pressure and temperature are within the region of validity
1059 
1060  // As we do not require derivatives, we can simply ignore their initialisation
1061  const ADReal p = pressure;
1062  const ADReal T = temperature;
1063  const ADReal X = Xnacl;
1064 
1065  // FluidStateProperties data structure
1066  std::vector<FluidStateProperties> fsp(_num_phases, FluidStateProperties(_num_components));
1069 
1070  // Calculate equilibrium mass fractions in the two-phase state
1071  ADReal Xco2, Yh2o;
1072  equilibriumMassFractions(p, T, X, Xco2, Yh2o);
1073 
1074  // Save the mass fractions in the FluidStateMassFractions object
1075  const ADReal Yco2 = 1.0 - Yh2o;
1076  liquid.mass_fraction[_aqueous_fluid_component] = 1.0 - Xco2;
1077  liquid.mass_fraction[_gas_fluid_component] = Xco2;
1079  gas.mass_fraction[_gas_fluid_component] = Yco2;
1080 
1081  // Gas properties
1083 
1084  // Liquid properties
1085  const ADReal liquid_saturation = 1.0 - saturation;
1086  const ADReal liquid_pressure = p - _pc.capillaryPressure(liquid_saturation, qp);
1087  liquidProperties(liquid_pressure, T, X, fsp);
1088 
1089  // The total mass fraction of ncg (z) can now be calculated
1090  const ADReal Z = (saturation * gas.density * Yco2 + liquid_saturation * liquid.density * Xco2) /
1091  (saturation * gas.density + liquid_saturation * liquid.density);
1092 
1093  return Z.value();
1094 }
void liquidProperties(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, std::vector< FluidStateProperties > &fsp) const
Thermophysical properties of the liquid state.
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
unsigned int _num_phases
Number of phases.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
unsigned int _gas_phase_number
Phase number of the gas phase.
unsigned int _num_components
Number of components.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
virtual Real capillaryPressure(Real saturation, unsigned qp=0) const
Capillary pressure is calculated as a function of true saturation.
void equilibriumMassFractions(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, ADReal &Xco2, ADReal &Yh2o) const
Mass fractions of CO2 in brine and water vapor in CO2 at equilibrium.
AD data structure to pass calculated thermophysical properties.
static const std::string Z
Definition: NS.h:169
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
void gasProperties(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Thermophysical properties of the gaseous state.
static const std::string pressure
Definition: NS.h:56
virtual void checkVariables(Real pressure, Real temperature) const
Check the input variables.
std::vector< ADReal > mass_fraction
ADReal saturation(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, std::vector< FluidStateProperties > &fsp) const
Gas saturation in the two-phase region.

◆ twoPhaseProperties()

void PorousFlowBrineCO2::twoPhaseProperties ( const ADReal pressure,
const ADReal temperature,
const ADReal Xnacl,
const ADReal Z,
unsigned int  qp,
std::vector< FluidStateProperties > &  fsp 
) const

Gas and liquid properties in the two-phase region.

Parameters
pressuregas pressure (Pa)
temperaturephase temperature (K)
XnaclNaCl mass fraction (kg/kg)
Ztotal mass fraction of NCG component
qpquadpoint for capillary presssure
[out]FluidStatePropertiesdata structure

Definition at line 351 of file PorousFlowBrineCO2.C.

Referenced by thermophysicalProperties().

357 {
358  auto & gas = fsp[_gas_phase_number];
359 
360  // Calculate all of the gas phase properties, as these don't depend on saturation
362 
363  // The gas saturation in the two phase case
364  gas.saturation = saturation(pressure, temperature, Xnacl, Z, fsp);
365 
366  // The liquid pressure and properties can now be calculated
367  const ADReal liquid_pressure = pressure - _pc.capillaryPressure(1.0 - gas.saturation, qp);
368  liquidProperties(liquid_pressure, temperature, Xnacl, fsp);
369 }
void liquidProperties(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, std::vector< FluidStateProperties > &fsp) const
Thermophysical properties of the liquid state.
unsigned int _gas_phase_number
Phase number of the gas phase.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
virtual Real capillaryPressure(Real saturation, unsigned qp=0) const
Capillary pressure is calculated as a function of true saturation.
static const std::string Z
Definition: NS.h:169
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
void gasProperties(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Thermophysical properties of the gaseous state.
static const std::string pressure
Definition: NS.h:56
ADReal saturation(const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, std::vector< FluidStateProperties > &fsp) const
Gas saturation in the two-phase region.

◆ validParams()

InputParameters PorousFlowBrineCO2::validParams ( )
static

Definition at line 19 of file PorousFlowBrineCO2.C.

20 {
22  params.addRequiredParam<UserObjectName>("brine_fp", "The name of the user object for brine");
23  params.addRequiredParam<UserObjectName>("co2_fp", "The name of the user object for CO2");
24  params.addParam<unsigned int>("salt_component", 2, "The component number of salt");
25  params.addClassDescription("Fluid state class for brine and CO2");
26  return params;
27 }
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)

◆ vaporMassFraction() [1/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 80 of file PorousFlowFluidStateFlash.C.

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

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

◆ vaporMassFraction() [2/3]

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

Definition at line 86 of file PorousFlowFluidStateFlash.C.

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

◆ vaporMassFraction() [3/3]

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

Definition at line 94 of file PorousFlowFluidStateFlash.C.

95 {
96  // Check that the sizes of the mass fractions and equilibrium constant vectors are correct
97  if (Ki.size() != Zi.size() + 1)
98  mooseError("The number of mass fractions or equilibrium components passed to rachfordRice is "
99  "not correct");
100  Real v;
101 
102  // If there are only two components, an analytical solution is possible
103  if (Ki.size() == 2)
104  v = vaporMassFraction(Zi[0], Ki[0], Ki[1]);
105  else
106  {
107  // More than two components - solve the Rachford-Rice equation using
108  // Newton-Raphson method
109  // Initial guess for vapor mass fraction
110  Real v0 = 0.5;
111  unsigned int iter = 0;
112 
113  while (std::abs(rachfordRice(v0, Zi, Ki)) > _nr_tol)
114  {
115  v0 = v0 - rachfordRice(v0, Zi, Ki) / rachfordRiceDeriv(v0, Zi, Ki);
116  iter++;
117 
118  if (iter > _nr_max_its)
119  break;
120  }
121  v = v0;
122  }
123  return v;
124 }
Real rachfordRice(Real vf, std::vector< Real > &Zi, std::vector< Real > &Ki) const
Rachford-Rice equation for vapor fraction.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string v
Definition: NS.h:84
Real vaporMassFraction(Real Z0, Real K0, Real K1) const
Solves Rachford-Rice equation to provide vapor mass fraction.
void mooseError(Args &&... args) const
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 PorousFlowFluidStateMultiComponentBase::_aqueous_fluid_component
protectedinherited

◆ _aqueous_phase_number

const unsigned int PorousFlowFluidStateBase::_aqueous_phase_number
protectedinherited

◆ _brine_fp

const BrineFluidProperties& PorousFlowBrineCO2::_brine_fp
protected

◆ _co2_fp

const SinglePhaseFluidProperties& PorousFlowBrineCO2::_co2_fp
protected

◆ _co2_henry

const std::vector<Real> PorousFlowBrineCO2::_co2_henry
protected

Henry's coefficeients for CO2.

Definition at line 483 of file PorousFlowBrineCO2.h.

Referenced by henryConstant().

◆ _empty_fsp

FluidStateProperties PorousFlowFluidStateBase::_empty_fsp
protectedinherited

◆ _gas_fluid_component

unsigned int PorousFlowFluidStateMultiComponentBase::_gas_fluid_component
protectedinherited

◆ _gas_phase_number

unsigned int PorousFlowFluidStateBase::_gas_phase_number
protectedinherited

◆ _invMh2o

const Real PorousFlowBrineCO2::_invMh2o
protected

◆ _Mco2

const Real PorousFlowBrineCO2::_Mco2
protected

◆ _Mh2o

const Real PorousFlowBrineCO2::_Mh2o
protected

Molar mass of water (kg/mol)

Definition at line 466 of file PorousFlowBrineCO2.h.

Referenced by equilibriumMassFractions().

◆ _Mnacl

const Real PorousFlowBrineCO2::_Mnacl
protected

◆ _nr_max_its

const Real PorousFlowFluidStateFlash::_nr_max_its
protectedinherited

Maximum number of iterations for the Newton-Raphson routine.

Definition at line 77 of file PorousFlowFluidStateFlash.h.

Referenced by PorousFlowFluidStateFlash::vaporMassFraction().

◆ _nr_tol

const Real PorousFlowFluidStateFlash::_nr_tol
protectedinherited

Tolerance for Newton-Raphson iterations.

Definition at line 79 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
protectedinherited

◆ _R

const Real PorousFlowFluidStateBase::_R
protectedinherited

Universal gas constant (J/mol/K)

Definition at line 106 of file PorousFlowFluidStateBase.h.

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

◆ _Rbar

const Real PorousFlowBrineCO2::_Rbar
protected

Molar gas constant in bar cm^3 /(K mol)

Definition at line 474 of file PorousFlowBrineCO2.h.

Referenced by fugacityCoefficientCO2HighTemp(), fugacityCoefficientH2OHighTemp(), fugacityCoefficientsLowTemp(), funcABHighTemp(), and funcABLowTemp().

◆ _salt_component

const unsigned int PorousFlowBrineCO2::_salt_component
protected

Salt component index.

Definition at line 460 of file PorousFlowBrineCO2.h.

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

◆ _T_c2k

const Real PorousFlowFluidStateBase::_T_c2k
protectedinherited

◆ _Tidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Tidx
protectedinherited

◆ _Tlower

const Real PorousFlowBrineCO2::_Tlower
protected

Temperature below which the Spycher, Pruess & Ennis-King (2003) model is used (K)

Definition at line 476 of file PorousFlowBrineCO2.h.

Referenced by equilibriumMoleFractions(), and smoothCubicInterpolation().

◆ _Tupper

const Real PorousFlowBrineCO2::_Tupper
protected

Temperature above which the Spycher & Pruess (2010) model is used (K)

Definition at line 478 of file PorousFlowBrineCO2.h.

Referenced by equilibriumMoleFractions(), and smoothCubicInterpolation().

◆ _Xidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Xidx
protectedinherited

◆ _Zidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Zidx
protectedinherited

◆ _Zmin

const Real PorousFlowBrineCO2::_Zmin
protected

Minimum Z - below this value all CO2 will be dissolved.

This reduces the computational burden when small values of Z are present

Definition at line 481 of file PorousFlowBrineCO2.h.

Referenced by massFractions().


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