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
PorousFlowWaterNCG Class Reference

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

#include <PorousFlowWaterNCG.h>

Inheritance diagram for PorousFlowWaterNCG:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 PorousFlowWaterNCG (const InputParameters &parameters)
 
virtual std::string fluidStateName () const override
 Name of FluidState. More...
 
void thermophysicalProperties (Real pressure, Real temperature, Real Xnacl, Real Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const override
 Determines the complete thermophysical state of the system for a given set of primary variables. More...
 
void thermophysicalProperties (const ADReal &pressure, const ADReal &temperature, const ADReal &Xnacl, const ADReal &Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const override
 
void equilibriumMassFractions (const ADReal &pressure, const ADReal &temperature, ADReal &Xncg, ADReal &Yh2o) const
 Mass fractions of NCG in liquid phase and H2O in gas phase at thermodynamic equilibrium. More...
 
void massFractions (const ADReal &pressure, const ADReal &temperature, const ADReal &Z, FluidStatePhaseEnum &phase_state, std::vector< FluidStateProperties > &fsp) const
 Mass fractions of NCG and H2O in both phases, as well as derivatives wrt PorousFlow variables. More...
 
void gasProperties (const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
 Gas properties - density, viscosity and enthalpy. More...
 
void liquidProperties (const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
 Liquid properties - density, viscosity and enthalpy Note: The pressure here is the liquid pressure. More...
 
ADReal liquidDensity (const ADReal &pressure, const ADReal &temperature) const
 Density of the liquid phase Note: The pressure here is the gas pressure. More...
 
ADReal gasDensity (const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
 Density of the gas phase. More...
 
ADReal saturation (const ADReal &pressure, const ADReal &temperature, 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 &Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const
 Gas and liquid properties in the two-phase region. More...
 
ADReal enthalpyOfDissolution (const ADReal &temperature) const
 Enthalpy of dissolution of NCG in water calculated using Henry's constant From Himmelblau, Partial molal heats and entropies of solution for gases dissolved in water from the freezing to the near critical point, J. More...
 
virtual Real totalMassFraction (Real pressure, Real temperature, Real Xnacl, Real saturation, unsigned int qp) const override
 Total mass fraction of fluid component summed over all phases in the two-phase state for a specified gas saturation. More...
 
unsigned int aqueousComponentIndex () const
 The index of the aqueous fluid component. More...
 
unsigned int gasComponentIndex () const
 The index of the gas fluid component. More...
 
unsigned int saltComponentIndex () const
 The index of the salt component. More...
 
void 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
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () 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 &nm) const
 
void paramError (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
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) 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)
 
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)
 
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 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
 

Static Public Member Functions

static InputParameters validParams ()
 
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

const ConsoleStream _console
 

Static Public Attributes

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

ADReal moleFractionToMassFraction (const ADReal &xmol) const
 Convert mole fraction to mass fraction. More...
 
void checkVariables (Real temperature) const
 Check that the temperature is between the triple and critical values. More...
 
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
 
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)
 
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)
 

Static Protected Member Functions

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

Protected Attributes

const SinglePhaseFluidProperties_water_fp
 Fluid properties UserObject for water. More...
 
const Water97FluidProperties_water97_fp
 Fluid properties UserObject for water (used to access Henry's law) More...
 
const SinglePhaseFluidProperties_ncg_fp
 Fluid properties UserObject for the NCG. More...
 
const Real _Mh2o
 Molar mass of water (kg/mol) More...
 
const Real _Mncg
 Molar mass of non-condensable gas (kg/mol) More...
 
const Real _water_triple_temperature
 Triple point temperature of water (K) More...
 
const Real _water_critical_temperature
 Critical temperature of water (K) More...
 
const std::vector< Real_ncg_henry
 Henry's coefficients for the NCG. More...
 
const unsigned int _aqueous_fluid_component
 Fluid component number of the aqueous component. More...
 
unsigned int _gas_fluid_component
 Fluid component number of the gas phase. More...
 
const unsigned int _salt_component
 Salt component index. More...
 
const 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
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
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 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 water and a non-condensable gas (NCG) Includes dissolution of gas in liquid water phase using Henry's law.

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

Definition at line 29 of file PorousFlowWaterNCG.h.

Constructor & Destructor Documentation

◆ PorousFlowWaterNCG()

PorousFlowWaterNCG::PorousFlowWaterNCG ( const InputParameters parameters)

Definition at line 28 of file PorousFlowWaterNCG.C.

30  _water_fp(getUserObject<SinglePhaseFluidProperties>("water_fp")),
31  _water97_fp(getUserObject<Water97FluidProperties>("water_fp")),
32  _ncg_fp(getUserObject<SinglePhaseFluidProperties>("gas_fp")),
38 {
39  // Check that the correct FluidProperties UserObjects have been provided
40  if (_water_fp.fluidName() != "water")
41  paramError("water_fp", "A valid water FluidProperties UserObject must be provided in water_fp");
42 
43  // Set the number of phases and components, and their indexes
44  _num_phases = 2;
45  _num_components = 2;
48 
49  // Check that _aqueous_phase_number is <= total number of phases
51  paramError("liquid_phase_number",
52  "This value is larger than the possible number of phases ",
53  _num_phases);
54 
55  // Check that _aqueous_fluid_component is <= total number of fluid components
57  paramError("liquid_fluid_component",
58  "This value is larger than the possible number of fluid components",
60 
62 }
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.
virtual Real triplePointTemperature() const
Triple point temperature.
const std::vector< Real > _ncg_henry
Henry&#39;s coefficients for the NCG.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
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.
virtual std::vector< Real > henryCoefficients() const
Henry&#39;s law coefficients for dissolution in water.
PorousFlowFluidStateMultiComponentBase(const InputParameters &parameters)
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
virtual Real criticalTemperature() const
Critical temperature.
const Water97FluidProperties & _water97_fp
Fluid properties UserObject for water (used to access Henry&#39;s law)
AD data structure to pass calculated thermophysical properties.
void paramError(const std::string &param, Args... args) const
const Real _Mh2o
Molar mass of water (kg/mol)
const Real _water_triple_temperature
Triple point temperature of water (K)
const Real _water_critical_temperature
Critical temperature of water (K)
const Real _Mncg
Molar mass of non-condensable gas (kg/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.
const InputParameters & parameters() const
FluidStateProperties _empty_fsp
Empty FluidStateProperties object.
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

Member Function Documentation

◆ 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 PorousFlowWaterNCG::checkVariables ( Real  temperature) const
protected

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

Parameters
temperaturefluid temperature (K)

Definition at line 391 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties(), and totalMassFraction().

392 {
393  // Check whether the input temperature is within the region of validity of this equation
394  // of state (T_triple <= T <= T_critical)
395  if (temperature < _water_triple_temperature || temperature > _water_critical_temperature)
396  mooseException(name() + ": temperature " + Moose::stringify(temperature) +
397  " is outside range 273.16 K <= T <= 647.096 K");
398 }
static const std::string temperature
Definition: NS.h:59
virtual const std::string & name() const
std::string stringify(const T &t)
const Real _water_critical_temperature
Critical temperature of water (K)

◆ clearFluidStateProperties()

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

Clears the contents of the FluidStateProperties data structure.

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

Definition at line 33 of file PorousFlowFluidStateBase.C.

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

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

◆ enthalpyOfDissolution()

ADReal PorousFlowWaterNCG::enthalpyOfDissolution ( const ADReal temperature) const

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

Phys. Chem. 63 (1959)

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

Definition at line 401 of file PorousFlowWaterNCG.C.

Referenced by liquidProperties().

402 {
403  // Henry's constant
405 
406  ADReal hdis = -_R * temperature * temperature * Kh.derivatives()[_Tidx] / Kh / _Mncg;
407 
408  // Derivative of enthalpy of dissolution wrt temperature requires the second derivative of
409  // Henry's constant wrt temperature. For simplicity, approximate this numerically
410  const Real dT = temperature.value() * 1.0e-8;
411  const ADReal t2 = temperature + dT;
412  const ADReal Kh2 = _water97_fp.henryConstant(t2, _ncg_henry);
413 
414  const Real dhdis_dT =
415  (-_R * t2 * t2 * Kh2.derivatives()[_Tidx] / Kh2 / _Mncg - hdis).value() / dT;
416 
417  hdis.derivatives() = temperature.derivatives() * dhdis_dT;
418 
419  return hdis;
420 }
const std::vector< Real > _ncg_henry
Henry&#39;s coefficients for the NCG.
const unsigned int _Tidx
Index of derivative wrt temperature.
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)
const Water97FluidProperties & _water97_fp
Fluid properties UserObject for water (used to access Henry&#39;s law)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real henryConstant(Real temperature, const std::vector< Real > &coeffs) const
IAPWS formulation of Henry&#39;s law constant for dissolution in water From Guidelines on the Henry&#39;s con...
const Real _Mncg
Molar mass of non-condensable gas (kg/mol)

◆ equilibriumMassFractions()

void PorousFlowWaterNCG::equilibriumMassFractions ( const ADReal pressure,
const ADReal temperature,
ADReal Xncg,
ADReal Yh2o 
) const

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

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

Parameters
pressurephase pressure (Pa)
temperaturephase temperature (K)
[out]Xncgmass fraction of NCG in liquid (kg/kg)
[out]Yh2omass fraction of H2O in gas (kg/kg)

Definition at line 361 of file PorousFlowWaterNCG.C.

Referenced by massFractions(), and totalMassFraction().

365 {
366  // Equilibrium constants for each component (Henry's law for the NCG
367  // component, and Raoult's law for water).
370 
371  const ADReal Kncg = Kh / pressure;
372  const ADReal Kh2o = psat / pressure;
373 
374  // The mole fractions for the NCG component in the two component
375  // case can be expressed in terms of the equilibrium constants only
376  const ADReal xncg = (1.0 - Kh2o) / (Kncg - Kh2o);
377  const ADReal yncg = Kncg * xncg;
378 
379  // Convert mole fractions to mass fractions
380  Xncg = moleFractionToMassFraction(xncg);
381  Yh2o = 1.0 - moleFractionToMassFraction(yncg);
382 }
const std::vector< Real > _ncg_henry
Henry&#39;s coefficients for the NCG.
ADReal moleFractionToMassFraction(const ADReal &xmol) const
Convert mole fraction to mass fraction.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
const Water97FluidProperties & _water97_fp
Fluid properties UserObject for water (used to access Henry&#39;s law)
static const std::string pressure
Definition: NS.h:56
Real henryConstant(Real temperature, const std::vector< Real > &coeffs) const
IAPWS formulation of Henry&#39;s law constant for dissolution in water From Guidelines on the Henry&#39;s con...
virtual Real vaporPressure(Real T) const
Vapor pressure.

◆ 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 PorousFlowWaterNCG::fluidStateName ( ) const
overridevirtual

Name of FluidState.

Implements PorousFlowFluidStateBase.

Definition at line 65 of file PorousFlowWaterNCG.C.

66 {
67  return "water-ncg";
68 }

◆ 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.

◆ gasDensity()

ADReal PorousFlowWaterNCG::gasDensity ( const ADReal pressure,
const ADReal temperature,
std::vector< FluidStateProperties > &  fsp 
) const

Density of the gas phase.

Parameters
pressurepressure (Pa)
temperaturetemperature (K)
Returns
gas density (kg/m^3)

Definition at line 287 of file PorousFlowWaterNCG.C.

Referenced by saturation(), and totalMassFraction().

290 {
291  auto & liquid = fsp[_aqueous_phase_number];
292  auto & gas = fsp[_gas_phase_number];
293 
295 
296  const ADReal Yncg = gas.mass_fraction[_gas_fluid_component];
297  const ADReal Xncg = liquid.mass_fraction[_gas_fluid_component];
298 
299  ADReal ncg_density = _ncg_fp.rho_from_p_T(Yncg * pressure, temperature);
300  ADReal vapor_density = _water_fp.rho_from_p_T((1.0 - Xncg) * psat, temperature);
301 
302  // Density is just the sum of individual component densities
303  return ncg_density + vapor_density;
304 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
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 SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
static const std::string pressure
Definition: NS.h:56
virtual Real vaporPressure(Real T) const
Vapor pressure.
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

◆ 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 PorousFlowWaterNCG::gasProperties ( const ADReal pressure,
const ADReal temperature,
std::vector< FluidStateProperties > &  fsp 
) const

Gas properties - density, viscosity and enthalpy.

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

Definition at line 210 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties(), and twoPhaseProperties().

213 {
216 
218 
219  const ADReal Yncg = gas.mass_fraction[_gas_fluid_component];
220  const ADReal Xncg = liquid.mass_fraction[_gas_fluid_component];
221 
222  // NCG density, viscosity and enthalpy calculated using partial pressure
223  // Yncg * gas_poreressure (Dalton's law)
224  ADReal ncg_density, ncg_viscosity;
225  _ncg_fp.rho_mu_from_p_T(Yncg * pressure, temperature, ncg_density, ncg_viscosity);
226  ADReal ncg_enthalpy = _ncg_fp.h_from_p_T(Yncg * pressure, temperature);
227 
228  // Vapor density, viscosity and enthalpy calculated using partial pressure
229  // X1 * psat (Raoult's law)
230  ADReal vapor_density, vapor_viscosity;
231 
232  _water_fp.rho_mu_from_p_T((1.0 - Xncg) * psat, temperature, vapor_density, vapor_viscosity);
233  ADReal vapor_enthalpy = _water_fp.h_from_p_T((1.0 - Xncg) * psat, temperature);
234 
235  // Density is just the sum of individual component densities
236  gas.density = ncg_density + vapor_density;
237 
238  // Viscosity of the gas phase is a weighted sum of the individual viscosities
239  gas.viscosity = Yncg * ncg_viscosity + (1.0 - Yncg) * vapor_viscosity;
240 
241  // Enthalpy of the gas phase is a weighted sum of the individual enthalpies
242  gas.enthalpy = Yncg * ncg_enthalpy + (1.0 - Yncg) * vapor_enthalpy;
243 
244  // Internal energy of the gas phase (e = h - pv)
245  mooseAssert(gas.density.value() > 0.0, "Gas density must be greater than zero");
246  gas.internal_energy = gas.enthalpy - pressure / gas.density;
247 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
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 SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
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
virtual Real vaporPressure(Real T) const
Vapor pressure.
std::vector< ADReal > mass_fraction
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

◆ 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.

◆ initialize()

void PorousFlowFluidStateBase::initialize ( )
inlinefinalvirtualinherited

Implements GeneralUserObject.

Definition at line 57 of file PorousFlowFluidStateBase.h.

57 {};

◆ liquidDensity()

ADReal PorousFlowWaterNCG::liquidDensity ( const ADReal pressure,
const ADReal temperature 
) const

Density of the liquid phase Note: The pressure here is the gas pressure.

As a result, the liquid pressure can include a dependence on saturation due to the capillary pressure, so this method should be called after the saturation is calculated for the two phase case ie: after calling saturation(). For the single phase liquid case, it is ok to call this method by itself, as gas saturation is initialized to zero.

Parameters
pressuregas pressure (Pa)
temperaturetemperature (K)
Returns
liquid density (kg/m^3)

Definition at line 281 of file PorousFlowWaterNCG.C.

Referenced by saturation(), and totalMassFraction().

282 {
283  return _water_fp.rho_from_p_T(pressure, temperature);
284 }
static const std::string temperature
Definition: NS.h:59
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
static const std::string pressure
Definition: NS.h:56

◆ liquidProperties()

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

Liquid properties - density, viscosity and enthalpy Note: The pressure here is the liquid pressure.

In this class, enthalpy includes a contribution due to the enthalpy of dissolution of the NCG into the liquid phase. As a result, the derivatives can include a dependence on the capillary pressure, so this method should be called after the saturation is calculated for the two phase case ie: after calling saturation(). For the single phase liquid case, it is ok to call this method by itself, as gas saturation is initialized to zero.

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

Definition at line 250 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties(), and twoPhaseProperties().

253 {
255 
256  // Calculate liquid density and viscosity if in the two phase or single phase
257  // liquid region, assuming they are not affected by the presence of dissolved
258  // NCG. Note: the (small) contribution due to derivative of capillary pressure
259  // wrt pressure (using the chain rule) is not implemented.
260  ADReal liquid_density, liquid_viscosity;
261  _water_fp.rho_mu_from_p_T(pressure, temperature, liquid_density, liquid_viscosity);
262 
263  liquid.density = liquid_density;
264  liquid.viscosity = liquid_viscosity;
265 
266  // Enthalpy does include a contribution due to the enthalpy of dissolution
268 
269  const ADReal water_enthalpy = _water_fp.h_from_p_T(pressure, temperature);
270  const ADReal ncg_enthalpy = _ncg_fp.h_from_p_T(pressure, temperature);
271 
272  const ADReal Xncg = liquid.mass_fraction[_gas_fluid_component];
273  liquid.enthalpy = (1.0 - Xncg) * water_enthalpy + Xncg * (ncg_enthalpy + hdis);
274 
275  // Internal energy of the liquid phase (e = h - pv)
276  mooseAssert(liquid.density.value() > 0.0, "Liquid density must be greater than zero");
277  liquid.internal_energy = liquid.enthalpy - pressure / liquid.density;
278 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
static const std::string temperature
Definition: NS.h:59
DualNumber< Real, DNDerivativeType, true > ADReal
const SinglePhaseFluidProperties & _water_fp
Fluid properties UserObject for water.
AD data structure to pass calculated thermophysical properties.
ADReal enthalpyOfDissolution(const ADReal &temperature) const
Enthalpy of dissolution of NCG in water calculated using Henry&#39;s constant From Himmelblau, Partial molal heats and entropies of solution for gases dissolved in water from the freezing to the near critical point, J.
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
std::vector< ADReal > mass_fraction
const SinglePhaseFluidProperties & _ncg_fp
Fluid properties UserObject for the NCG.

◆ massFractions()

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

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

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

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

Definition at line 152 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties().

157 {
160 
161  // Equilibrium mass fraction of NCG in liquid and H2O in gas phases
162  ADReal Xncg, Yh2o;
164 
165  ADReal Yncg = 1.0 - Yh2o;
166 
167  // Determine which phases are present based on the value of Z
168  phaseState(Z.value(), Xncg.value(), Yncg.value(), phase_state);
169 
170  // The equilibrium mass fractions calculated above are only correct in the two phase
171  // state. If only liquid or gas phases are present, the mass fractions are given by
172  // the total mass fraction Z.
173  ADReal Xh2o = 0.0;
174 
175  switch (phase_state)
176  {
178  {
179  Xncg = Z;
180  Yncg = 0.0;
181  Xh2o = 1.0 - Z;
182  Yh2o = 0.0;
183  break;
184  }
185 
187  {
188  Xncg = 0.0;
189  Yncg = Z;
190  Yh2o = 1.0 - Z;
191  break;
192  }
193 
195  {
196  // Keep equilibrium mass fractions
197  Xh2o = 1.0 - Xncg;
198  break;
199  }
200  }
201 
202  // Save the mass fractions in the FluidStateMassFractions object
204  liquid.mass_fraction[_gas_fluid_component] = Xncg;
207 }
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.
void equilibriumMassFractions(const ADReal &pressure, const ADReal &temperature, ADReal &Xncg, ADReal &Yh2o) const
Mass fractions of NCG in liquid phase and H2O in gas phase at thermodynamic equilibrium.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
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
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
std::vector< ADReal > mass_fraction

◆ moleFractionToMassFraction()

ADReal PorousFlowWaterNCG::moleFractionToMassFraction ( const ADReal xmol) const
protected

Convert mole fraction to mass fraction.

Parameters
xmolmole fraction
Returns
mass fraction

Definition at line 385 of file PorousFlowWaterNCG.C.

Referenced by equilibriumMassFractions().

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

◆ numComponents()

unsigned int PorousFlowFluidStateBase::numComponents ( ) const
inlineinherited

The maximum number of components in this model.

Returns
number of components

Definition at line 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.

◆ 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 massFractions(), and PorousFlowBrineCO2::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 PorousFlowFluidStateMultiComponentBase::saltComponentIndex ( ) const
inlineinherited

The index of the salt component.

Returns
salt component number

Definition at line 41 of file PorousFlowFluidStateMultiComponentBase.h.

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

◆ saturation()

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

Gas saturation in the two-phase region.

Parameters
pressuregas pressure (Pa)
temperaturephase temperature (K)
Ztotal mass fraction of NCG component
[out]FluidStatePropertiesdata structure
Returns
gas saturation (-)

Definition at line 307 of file PorousFlowWaterNCG.C.

Referenced by totalMassFraction(), and twoPhaseProperties().

311 {
312  auto & gas = fsp[_gas_phase_number];
313  auto & liquid = fsp[_aqueous_fluid_component];
314 
315  // Approximate liquid density as saturation isn't known yet, by using the gas
316  // pressure rather than the liquid pressure. This does result in a small error
317  // in the calculated saturation, but this is below the error associated with
318  // the correlations. A more accurate saturation could be found iteraviely,
319  // at the cost of increased computational expense
320 
321  // The gas and liquid densities
322  const ADReal gas_density = gasDensity(pressure, temperature, fsp);
323  const ADReal liquid_density = liquidDensity(pressure, temperature);
324 
325  // Set mass equilibrium constants used in the calculation of vapor mass fraction
326  const ADReal Xncg = liquid.mass_fraction[_gas_fluid_component];
327  const ADReal Yncg = gas.mass_fraction[_gas_fluid_component];
328 
329  const ADReal K0 = Yncg / Xncg;
330  const ADReal K1 = (1.0 - Yncg) / (1.0 - Xncg);
331  const ADReal vapor_mass_fraction = vaporMassFraction(Z, K0, K1);
332 
333  // The gas saturation in the two phase case
334  const ADReal saturation = vapor_mass_fraction * liquid_density /
335  (gas_density + vapor_mass_fraction * (liquid_density - gas_density));
336 
337  return saturation;
338 }
const unsigned int _aqueous_fluid_component
Fluid component number of the aqueous component.
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
ADReal saturation(const ADReal &pressure, const ADReal &temperature, const ADReal &Z, std::vector< FluidStateProperties > &fsp) const
Gas saturation in the two-phase region.
ADReal gasDensity(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Density of the gas phase.
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 liquidDensity(const ADReal &pressure, const ADReal &temperature) const
Density of the liquid phase Note: The pressure here is the gas pressure.

◆ thermophysicalProperties() [1/2]

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

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

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

Implements PorousFlowFluidStateMultiComponentBase.

Definition at line 71 of file PorousFlowWaterNCG.C.

77 {
78  // Make AD versions of primary variables then call AD thermophysicalProperties()
79  ADReal p = pressure;
80  Moose::derivInsert(p.derivatives(), _pidx, 1.0);
81  ADReal T = temperature;
82  Moose::derivInsert(T.derivatives(), _Tidx, 1.0);
83  ADReal Zncg = Z;
84  Moose::derivInsert(Zncg.derivatives(), _Zidx, 1.0);
85  // X is not used, but needed for consistency with PorousFlowFluidState interface
86  ADReal X = Xnacl;
87  Moose::derivInsert(X.derivatives(), _Xidx, 1.0);
88 
89  thermophysicalProperties(p, T, X, Zncg, qp, fsp);
90 }
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 PorousFlowWaterNCG::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 93 of file PorousFlowWaterNCG.C.

99 {
102 
103  // Check whether the input temperature is within the region of validity
104  checkVariables(temperature.value());
105 
106  // Clear all of the FluidStateProperties data
108 
109  FluidStatePhaseEnum phase_state;
110  massFractions(pressure, temperature, Z, phase_state, fsp);
111 
112  switch (phase_state)
113  {
115  {
116  // Set the gas saturations
117  gas.saturation = 1.0;
118 
119  // Calculate gas properties
121 
122  break;
123  }
124 
126  {
127  // Calculate the liquid properties
128  const ADReal liquid_pressure = pressure - _pc.capillaryPressure(1.0, qp);
129  liquidProperties(liquid_pressure, temperature, fsp);
130 
131  break;
132  }
133 
135  {
136  // Calculate the gas and liquid properties in the two phase region
138 
139  break;
140  }
141  }
142 
143  // Liquid saturations can now be set
144  liquid.saturation = 1.0 - gas.saturation;
145 
146  // Save pressures to FluidStateProperties object
147  gas.pressure = pressure;
148  liquid.pressure = pressure - _pc.capillaryPressure(liquid.saturation, qp);
149 }
const unsigned int _aqueous_phase_number
Phase number of the aqueous phase.
void massFractions(const ADReal &pressure, const ADReal &temperature, const ADReal &Z, FluidStatePhaseEnum &phase_state, std::vector< FluidStateProperties > &fsp) const
Mass fractions of NCG and H2O in both phases, as well as derivatives wrt PorousFlow variables...
void liquidProperties(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Liquid properties - density, viscosity and enthalpy Note: The pressure here is the liquid pressure...
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
void twoPhaseProperties(const ADReal &pressure, const ADReal &temperature, const ADReal &Z, unsigned int qp, std::vector< FluidStateProperties > &fsp) const
Gas and liquid properties in the two-phase region.
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.
static const std::string Z
Definition: NS.h:169
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
void checkVariables(Real temperature) const
Check that the temperature is between the triple and critical values.
static const std::string pressure
Definition: NS.h:56
void gasProperties(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Gas properties - density, viscosity and enthalpy.

◆ totalMassFraction()

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

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

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

Implements PorousFlowFluidStateMultiComponentBase.

Definition at line 423 of file PorousFlowWaterNCG.C.

425 {
426  // Check whether the input temperature is within the region of validity
428 
429  // As we do not require derivatives, we can simply ignore their initialisation
430  const ADReal p = pressure;
431  const ADReal T = temperature;
432 
433  // FluidStateProperties data structure
434  std::vector<FluidStateProperties> fsp(_num_phases, FluidStateProperties(_num_components));
435  auto & liquid = fsp[_aqueous_phase_number];
436  auto & gas = fsp[_gas_phase_number];
437 
438  // Calculate equilibrium mass fractions in the two-phase state
439  ADReal Xncg, Yh2o;
440  equilibriumMassFractions(p, T, Xncg, Yh2o);
441 
442  // Save the mass fractions in the FluidStateMassFractions object to calculate gas density
443  const ADReal Yncg = 1.0 - Yh2o;
444  liquid.mass_fraction[_aqueous_fluid_component] = 1.0 - Xncg;
445  liquid.mass_fraction[_gas_fluid_component] = Xncg;
446  gas.mass_fraction[_aqueous_fluid_component] = Yh2o;
447  gas.mass_fraction[_gas_fluid_component] = Yncg;
448 
449  // Gas density
450  const Real gas_density = gasDensity(p, T, fsp).value();
451 
452  // Liquid density
453  const ADReal liquid_pressure = p - _pc.capillaryPressure(1.0 - saturation, qp);
454  const Real liquid_density = liquidDensity(liquid_pressure, T).value();
455 
456  // The total mass fraction of ncg (Z) can now be calculated
457  const Real Z = (saturation * gas_density * Yncg.value() +
458  (1.0 - saturation) * liquid_density * Xncg.value()) /
459  (saturation * gas_density + (1.0 - saturation) * liquid_density);
460 
461  return Z;
462 }
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.
void equilibriumMassFractions(const ADReal &pressure, const ADReal &temperature, ADReal &Xncg, ADReal &Yh2o) const
Mass fractions of NCG in liquid phase and H2O in gas phase at thermodynamic equilibrium.
unsigned int _gas_fluid_component
Fluid component number of the gas phase.
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.
ADReal saturation(const ADReal &pressure, const ADReal &temperature, const ADReal &Z, std::vector< FluidStateProperties > &fsp) const
Gas saturation in the two-phase region.
AD data structure to pass calculated thermophysical properties.
ADReal gasDensity(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Density of the gas phase.
static const std::string Z
Definition: NS.h:169
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
void checkVariables(Real temperature) const
Check that the temperature is between the triple and critical values.
static const std::string pressure
Definition: NS.h:56
ADReal liquidDensity(const ADReal &pressure, const ADReal &temperature) const
Density of the liquid phase Note: The pressure here is the gas pressure.

◆ twoPhaseProperties()

void PorousFlowWaterNCG::twoPhaseProperties ( const ADReal pressure,
const ADReal temperature,
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)
Ztotal mass fraction of NCG component
qpquadpoint for capillary pressure
[out]FluidStatePropertiesdata structure

Definition at line 341 of file PorousFlowWaterNCG.C.

Referenced by thermophysicalProperties().

346 {
347  auto & gas = fsp[_gas_phase_number];
348 
349  // Calculate all of the gas phase properties, as these don't depend on saturation
351 
352  // The gas saturation in the two phase case
353  gas.saturation = saturation(pressure, temperature, Z, fsp);
354 
355  // The liquid pressure and properties can now be calculated
356  const ADReal liquid_pressure = pressure - _pc.capillaryPressure(1.0 - gas.saturation, qp);
357  liquidProperties(liquid_pressure, temperature, fsp);
358 }
void liquidProperties(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Liquid properties - density, viscosity and enthalpy Note: The pressure here is the liquid pressure...
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.
ADReal saturation(const ADReal &pressure, const ADReal &temperature, const ADReal &Z, std::vector< FluidStateProperties > &fsp) const
Gas saturation in the two-phase region.
static const std::string Z
Definition: NS.h:169
const PorousFlowCapillaryPressure & _pc
Capillary pressure UserObject.
static const std::string pressure
Definition: NS.h:56
void gasProperties(const ADReal &pressure, const ADReal &temperature, std::vector< FluidStateProperties > &fsp) const
Gas properties - density, viscosity and enthalpy.

◆ validParams()

InputParameters PorousFlowWaterNCG::validParams ( )
static

Definition at line 18 of file PorousFlowWaterNCG.C.

19 {
21  params.addRequiredParam<UserObjectName>("water_fp", "The name of the user object for water");
22  params.addRequiredParam<UserObjectName>(
23  "gas_fp", "The name of the user object for the non-condensable gas");
24  params.addClassDescription("Fluid state class for water and non-condensable gas");
25  return params;
26 }
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 saturation(), PorousFlowBrineCO2::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

◆ _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

◆ _Mh2o

const Real PorousFlowWaterNCG::_Mh2o
protected

Molar mass of water (kg/mol)

Definition at line 197 of file PorousFlowWaterNCG.h.

Referenced by moleFractionToMassFraction().

◆ _Mncg

const Real PorousFlowWaterNCG::_Mncg
protected

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

Definition at line 199 of file PorousFlowWaterNCG.h.

Referenced by enthalpyOfDissolution(), and moleFractionToMassFraction().

◆ _ncg_fp

const SinglePhaseFluidProperties& PorousFlowWaterNCG::_ncg_fp
protected

Fluid properties UserObject for the NCG.

Definition at line 195 of file PorousFlowWaterNCG.h.

Referenced by gasDensity(), gasProperties(), and liquidProperties().

◆ _ncg_henry

const std::vector<Real> PorousFlowWaterNCG::_ncg_henry
protected

Henry's coefficients for the NCG.

Definition at line 205 of file PorousFlowWaterNCG.h.

Referenced by enthalpyOfDissolution(), and equilibriumMassFractions().

◆ _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 enthalpyOfDissolution(), and PorousFlowBrineCO2::enthalpyOfDissolutionGas().

◆ _salt_component

const unsigned int PorousFlowFluidStateMultiComponentBase::_salt_component
protectedinherited

Salt component index.

Definition at line 103 of file PorousFlowFluidStateMultiComponentBase.h.

Referenced by PorousFlowFluidStateMultiComponentBase::saltComponentIndex().

◆ _T_c2k

const Real PorousFlowFluidStateBase::_T_c2k
protectedinherited

◆ _Tidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Tidx
protectedinherited

◆ _water97_fp

const Water97FluidProperties& PorousFlowWaterNCG::_water97_fp
protected

Fluid properties UserObject for water (used to access Henry's law)

Definition at line 193 of file PorousFlowWaterNCG.h.

Referenced by enthalpyOfDissolution(), and equilibriumMassFractions().

◆ _water_critical_temperature

const Real PorousFlowWaterNCG::_water_critical_temperature
protected

Critical temperature of water (K)

Definition at line 203 of file PorousFlowWaterNCG.h.

Referenced by checkVariables().

◆ _water_fp

const SinglePhaseFluidProperties& PorousFlowWaterNCG::_water_fp
protected

◆ _water_triple_temperature

const Real PorousFlowWaterNCG::_water_triple_temperature
protected

Triple point temperature of water (K)

Definition at line 201 of file PorousFlowWaterNCG.h.

◆ _Xidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Xidx
protectedinherited

◆ _Zidx

const unsigned int PorousFlowFluidStateMultiComponentBase::_Zidx
protectedinherited

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