Loading [MathJax]/extensions/tex2jax.js
OGS
MaterialPropertyLib::ClausiusClapeyron Class Referencefinal

Detailed Description

Vapour pressure as function of temperature based on Clausius-Clapeyron equation. This property must be either a phase or a component property, it computes the saturation vapour pressure of a substance

Definition at line 29 of file ClausiusClapeyron.h.

#include <ClausiusClapeyron.h>

Inheritance diagram for MaterialPropertyLib::ClausiusClapeyron:
[legend]
Collaboration diagram for MaterialPropertyLib::ClausiusClapeyron:
[legend]

Public Member Functions

 ClausiusClapeyron (std::string name, const double triple_temperature, const double triple_pressure, const double critical_temperature, const double critical_pressure, const double ref_temperature, const double ref_pressure)
 
void checkScale () const override
 
PropertyDataType value (VariableArray const &variable_array, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
 
PropertyDataType dValue (VariableArray const &variable_array, Variable const primary_variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
 
PropertyDataType d2Value (VariableArray const &variable_array, Variable const primary_variable1, Variable const primary_variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
 Default implementation: 2nd derivative of any constant property is zero. More...
 
- Public Member Functions inherited from MaterialPropertyLib::Property
virtual ~Property ()
 
virtual PropertyDataType initialValue (ParameterLib::SpatialPosition const &pos, double const t) const
 
virtual PropertyDataType value () const
 
virtual PropertyDataType value (VariableArray const &variable_array, VariableArray const &variable_array_prev, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 
virtual PropertyDataType dValue (VariableArray const &variable_array, VariableArray const &variable_array_prev, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 
void setScale (std::variant< Medium *, Phase *, Component * > scale)
 
template<typename T >
initialValue (ParameterLib::SpatialPosition const &pos, double const t) const
 
template<typename T >
value () const
 
template<typename T >
value (VariableArray const &variable_array, VariableArray const &variable_array_prev, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 
template<typename T >
value (VariableArray const &variable_array, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 
template<typename T >
dValue (VariableArray const &variable_array, VariableArray const &variable_array_prev, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 
template<typename T >
dValue (VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 
template<typename T >
d2Value (VariableArray const &variable_array, Variable const &variable1, Variable const &variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 

Private Member Functions

double molarMass (std::variant< Medium *, Phase *, Component * > const scale, VariableArray const &variable_array, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 
double dMolarMass (std::variant< Medium *, Phase *, Component * > const scale, VariableArray const &variable_array, Variable const primary_variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
 

Private Attributes

double T_triple_
 
double p_triple_
 
double T_critical_
 
double p_critical_
 
double T_ref_
 
double p_ref_
 

Additional Inherited Members

- Protected Attributes inherited from MaterialPropertyLib::Property
std::string name_
 
PropertyDataType value_
 The single value of a property. More...
 
PropertyDataType dvalue_
 
std::variant< Medium *, Phase *, Component * > scale_
 

Constructor & Destructor Documentation

◆ ClausiusClapeyron()

MaterialPropertyLib::ClausiusClapeyron::ClausiusClapeyron ( std::string  name,
const double  triple_temperature,
const double  triple_pressure,
const double  critical_temperature,
const double  critical_pressure,
const double  ref_temperature,
const double  ref_pressure 
)
explicit

Member Function Documentation

◆ checkScale()

void MaterialPropertyLib::ClausiusClapeyron::checkScale ( ) const
overridevirtual

Reimplemented from MaterialPropertyLib::Property.

Definition at line 40 of file ClausiusClapeyron.cpp.

41 {
42  if (!(std::holds_alternative<Phase*>(scale_) ||
43  std::holds_alternative<Component*>(scale_)))
44  {
45  OGS_FATAL(
46  "The property 'ClausiusClapeyron' is implemented on 'phase' and "
47  "'component' scales only.");
48  }
49 }
#define OGS_FATAL(...)
Definition: Error.h:26
std::variant< Medium *, Phase *, Component * > scale_
Definition: Property.h:287

References OGS_FATAL, and MaterialPropertyLib::Property::scale_.

◆ d2Value()

PropertyDataType MaterialPropertyLib::ClausiusClapeyron::d2Value ( VariableArray const &  variable_array,
Variable const  variable1,
Variable const  variable2,
ParameterLib::SpatialPosition const &  pos,
double const  t,
double const  dt 
) const
overridevirtual

Default implementation: 2nd derivative of any constant property is zero.

This virtual method will compute the second derivative of a property with respect to the given variables pv1 and pv2.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 147 of file ClausiusClapeyron.cpp.

152 {
153  OGS_FATAL("ClausiusClapeyron::d2Value is not implemented.");
154 }

References OGS_FATAL.

◆ dMolarMass()

double MaterialPropertyLib::ClausiusClapeyron::dMolarMass ( std::variant< Medium *, Phase *, Component * > const  scale,
VariableArray const &  variable_array,
Variable const  primary_variable,
ParameterLib::SpatialPosition const &  pos,
double const  t,
double const  dt 
) const
private

Definition at line 66 of file ClausiusClapeyron.cpp.

71 {
72  return std::visit(
73  [&variable_array, &primary_variable, &pos, t, dt](auto&& s) -> double
74  {
75  return s->property(PropertyType::molar_mass)
76  .template dValue<double>(variable_array, primary_variable, pos,
77  t, dt);
78  },
79  scale);
80 }
void scale(PETScVector &x, double const a)
Definition: LinAlg.cpp:44

References MaterialPropertyLib::molar_mass, and MathLib::LinAlg::scale().

Referenced by dValue().

◆ dValue()

PropertyDataType MaterialPropertyLib::ClausiusClapeyron::dValue ( VariableArray const &  variable_array,
Variable const  variable,
ParameterLib::SpatialPosition const &  pos,
double const  t,
double const  dt 
) const
overridevirtual

This virtual method will compute the property derivative value based on the variables that are passed as arguments with the default implementation using empty variables array for the previous time step.

The default implementation of this method only returns the property value derivative without altering it.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 108 of file ClausiusClapeyron.cpp.

112 {
113  const double T = std::get<double>(
114  variable_array[static_cast<int>(Variable::temperature)]);
115 
116  const double M = molarMass(scale_, variable_array, pos, t, dt);
117  const double dM =
118  dMolarMass(scale_, variable_array, primary_variable, pos, t, dt);
119 
120  if (T > T_critical_)
121  {
122  return 0.;
123  }
124  if (T < T_triple_)
125  {
126  return 0.;
127  }
128 
130  const double dh = std::get<double>(
131  variable_array[static_cast<int>(Variable::enthalpy_of_evaporation)]);
132  const double p_vap = std::get<double>(value(variable_array, pos, t, dt));
133 
134  if (primary_variable == Variable::temperature)
135  {
136  return p_vap * dh / R * ((1. / T_ref_ - 1. / T) * dM + M / (T * T));
137  }
138  if (primary_variable == Variable::phase_pressure)
139  {
140  return p_vap * dh / R * (1. / T_ref_ - 1. / T) * dM;
141  }
142  OGS_FATAL(
143  "ClausiusClapeyron::dValue is implemented for derivatives with respect "
144  "to phase pressure or temperature only.");
145 }
double dMolarMass(std::variant< Medium *, Phase *, Component * > const scale, VariableArray const &variable_array, Variable const primary_variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
double molarMass(std::variant< Medium *, Phase *, Component * > const scale, VariableArray const &variable_array, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
virtual PropertyDataType value() const
Definition: Property.cpp:72

References dMolarMass(), MaterialPropertyLib::enthalpy_of_evaporation, MaterialLib::PhysicalConstant::IdealGasConstant, molarMass(), OGS_FATAL, MaterialPropertyLib::phase_pressure, MaterialPropertyLib::Property::scale_, T_critical_, T_ref_, T_triple_, MaterialPropertyLib::temperature, and MaterialPropertyLib::Property::value().

◆ molarMass()

double MaterialPropertyLib::ClausiusClapeyron::molarMass ( std::variant< Medium *, Phase *, Component * > const  scale,
VariableArray const &  variable_array,
ParameterLib::SpatialPosition const &  pos,
double const  t,
double const  dt 
) const
private

Definition at line 51 of file ClausiusClapeyron.cpp.

56 {
57  return std::visit(
58  [&variable_array, &pos, t, dt](auto&& s) -> double
59  {
60  return s->property(PropertyType::molar_mass)
61  .template value<double>(variable_array, pos, t, dt);
62  },
63  scale);
64 }

References MaterialPropertyLib::molar_mass, and MathLib::LinAlg::scale().

Referenced by dValue(), and value().

◆ value()

PropertyDataType MaterialPropertyLib::ClausiusClapeyron::value ( VariableArray const &  variable_array,
ParameterLib::SpatialPosition const &  pos,
double const  t,
double const  dt 
) const
overridevirtual

This virtual method will compute the property value based on the variables that are passed as arguments with the default implementation using empty variables array for the previous time step.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 82 of file ClausiusClapeyron.cpp.

86 {
87  const double T = std::get<double>(
88  variable_array[static_cast<int>(Variable::temperature)]);
89 
90  const double M = molarMass(scale_, variable_array, pos, t, dt);
91 
92  if (T >= T_critical_)
93  {
94  return p_critical_;
95  }
96  if (T <= T_triple_)
97  {
98  return p_triple_;
99  }
100 
101  const double dh = std::get<double>(
102  variable_array[static_cast<int>(Variable::enthalpy_of_evaporation)]);
104 
105  return p_ref_ * std::exp((1. / T_ref_ - 1. / T) * M * dh / R);
106 }

References MaterialPropertyLib::enthalpy_of_evaporation, MaterialLib::PhysicalConstant::IdealGasConstant, molarMass(), p_critical_, p_ref_, p_triple_, MaterialPropertyLib::Property::scale_, T_critical_, T_ref_, T_triple_, and MaterialPropertyLib::temperature.

Member Data Documentation

◆ p_critical_

double MaterialPropertyLib::ClausiusClapeyron::p_critical_
private

Definition at line 62 of file ClausiusClapeyron.h.

Referenced by value().

◆ p_ref_

double MaterialPropertyLib::ClausiusClapeyron::p_ref_
private

Definition at line 64 of file ClausiusClapeyron.h.

Referenced by value().

◆ p_triple_

double MaterialPropertyLib::ClausiusClapeyron::p_triple_
private

Definition at line 60 of file ClausiusClapeyron.h.

Referenced by value().

◆ T_critical_

double MaterialPropertyLib::ClausiusClapeyron::T_critical_
private

Definition at line 61 of file ClausiusClapeyron.h.

Referenced by dValue(), and value().

◆ T_ref_

double MaterialPropertyLib::ClausiusClapeyron::T_ref_
private

Definition at line 63 of file ClausiusClapeyron.h.

Referenced by dValue(), and value().

◆ T_triple_

double MaterialPropertyLib::ClausiusClapeyron::T_triple_
private

Definition at line 59 of file ClausiusClapeyron.h.

Referenced by dValue(), and value().


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