OGS
MaterialPropertyLib::IdealGasLaw Class Referencefinal

Detailed Description

Density function for ideal gases.

This property must be either a phase or a component property, it computes the density of an ideal gas as function of phase pressure and temperature.

Definition at line 31 of file IdealGasLaw.h.

#include <IdealGasLaw.h>

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

Public Member Functions

 IdealGasLaw (std::string name)
 
void checkScale () const override
 
PropertyDataType value (VariableArray const &variable_array, ParameterLib::SpatialPosition const &, double const, double const) const override
 
PropertyDataType dValue (VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &, double const, double const) const override
 
PropertyDataType d2Value (VariableArray const &variable_array, Variable const variable1, Variable const variable2, ParameterLib::SpatialPosition const &, double const, double const) 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
 

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

◆ IdealGasLaw()

MaterialPropertyLib::IdealGasLaw::IdealGasLaw ( std::string  name)
explicit

Definition at line 23 of file IdealGasLaw.cpp.

24 {
25  name_ = std::move(name);
26 }

References MaterialPropertyLib::name, and MaterialPropertyLib::Property::name_.

Member Function Documentation

◆ checkScale()

void MaterialPropertyLib::IdealGasLaw::checkScale ( ) const
inlineoverridevirtual

Reimplemented from MaterialPropertyLib::Property.

Definition at line 36 of file IdealGasLaw.h.

37  {
38  if (!(std::holds_alternative<Phase*>(scale_) ||
39  std::holds_alternative<Component*>(scale_)))
40  {
41  OGS_FATAL(
42  "The property 'IdealGasLaw' is implemented on the "
43  "'phase' and 'component' scales only.");
44  }
45  }
#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::IdealGasLaw::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 80 of file IdealGasLaw.cpp.

85 {
86  const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
87  const double pressure = std::get<double>(
88  variable_array[static_cast<int>(Variable::phase_pressure)]);
89  const double temperature = std::get<double>(
90  variable_array[static_cast<int>(Variable::temperature)]);
91  const double molar_mass = std::get<double>(
92  variable_array[static_cast<int>(Variable::molar_mass)]);
93  // todo: add molar mass derivatives
94 
95  if ((primary_variable1 == Variable::phase_pressure) &&
96  (primary_variable2 == Variable::phase_pressure))
97  {
98  // d2rho_dp2
99  // extend to take pressure-dependent molar mass into account
100  return 0.;
101  }
102  if ((primary_variable1 == Variable::temperature) &&
103  (primary_variable2 == Variable::temperature))
104  {
105  // d2rho_dT2
106  // extend to take temperature-dependent molar mass into account
107  return 2. * molar_mass * pressure / gas_constant / temperature /
109  }
110  if (((primary_variable1 == Variable::phase_pressure) &&
111  (primary_variable2 == Variable::temperature)) ||
112  ((primary_variable1 == Variable::temperature) &&
113  (primary_variable2 == Variable::phase_pressure)))
114  {
115  // d2rho_dpdT or d2rho_dTdp
116  // extend to take pressure-temperature-dependent molar mass into account
117  return -molar_mass / gas_constant / temperature / temperature;
118  }
119 
120  OGS_FATAL(
121  "IdealGasLaw::d2Value is implemented for derivatives with respect to "
122  "phase pressure and temperature only.");
123 
124  return 0.;
125 }

References MaterialLib::PhysicalConstant::IdealGasConstant, MaterialPropertyLib::molar_mass, OGS_FATAL, MaterialPropertyLib::phase_pressure, and MaterialPropertyLib::temperature.

◆ dValue()

PropertyDataType MaterialPropertyLib::IdealGasLaw::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 46 of file IdealGasLaw.cpp.

50 {
51  const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
52  const double pressure = std::get<double>(
53  variable_array[static_cast<int>(Variable::phase_pressure)]);
54  const double temperature = std::get<double>(
55  variable_array[static_cast<int>(Variable::temperature)]);
56  const double molar_mass = std::get<double>(
57  variable_array[static_cast<int>(Variable::molar_mass)]);
58  // todo: add molar mass derivatives
59 
60  if (primary_variable == Variable::temperature)
61  {
62  // extend to take temperature-dependent molar mass into account
63  return -pressure * molar_mass / gas_constant / temperature /
65  }
66 
67  if (primary_variable == Variable::phase_pressure)
68  {
69  // extend to take pressure-dependent molar mass into account
70  return molar_mass / gas_constant / temperature;
71  }
72 
73  OGS_FATAL(
74  "IdealGasLaw::dValue is implemented for derivatives with respect to "
75  "phase pressure or temperature only.");
76 
77  return 0.;
78 }

References MaterialLib::PhysicalConstant::IdealGasConstant, MaterialPropertyLib::molar_mass, OGS_FATAL, MaterialPropertyLib::phase_pressure, and MaterialPropertyLib::temperature.

◆ value()

PropertyDataType MaterialPropertyLib::IdealGasLaw::value ( VariableArray const &  variable_array,
ParameterLib::SpatialPosition const &  ,
double const  ,
double const   
) const
overridevirtual

Those methods override the base class implementations and actually compute and set the property values_ and dValues_.

Reimplemented from MaterialPropertyLib::Property.

Definition at line 28 of file IdealGasLaw.cpp.

32 {
33  const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
34  const double pressure = std::get<double>(
35  variable_array[static_cast<int>(Variable::phase_pressure)]);
36  const double temperature = std::get<double>(
37  variable_array[static_cast<int>(Variable::temperature)]);
38  const double molar_mass = std::get<double>(
39  variable_array[static_cast<int>(Variable::molar_mass)]);
40 
41  const double density = pressure * molar_mass / gas_constant / temperature;
42 
43  return density;
44 }

References MaterialPropertyLib::density, MaterialLib::PhysicalConstant::IdealGasConstant, MaterialPropertyLib::molar_mass, MaterialPropertyLib::phase_pressure, and MaterialPropertyLib::temperature.


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