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 29 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.
 
- 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
 
virtual void setProperties (std::vector< std::unique_ptr< Phase > > const &phases)
 Default implementation:
 
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.
 
PropertyDataType dvalue_
 
std::variant< Medium *, Phase *, Component * > scale_
 

Constructor & Destructor Documentation

◆ IdealGasLaw()

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

Definition at line 21 of file IdealGasLaw.cpp.

22{
23 name_ = std::move(name);
24}

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

Member Function Documentation

◆ checkScale()

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

Reimplemented from MaterialPropertyLib::Property.

Definition at line 34 of file IdealGasLaw.h.

35 {
36 if (!(std::holds_alternative<Phase*>(scale_) ||
37 std::holds_alternative<Component*>(scale_)))
38 {
40 "The property 'IdealGasLaw' is implemented on the "
41 "'phase' and 'component' scales only.");
42 }
43 }
#define OGS_FATAL(...)
Definition Error.h:26
std::variant< Medium *, Phase *, Component * > scale_
Definition Property.h:297

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 72 of file IdealGasLaw.cpp.

76{
77 const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
78 const double pressure = variable_array.gas_phase_pressure;
79 const double temperature = variable_array.temperature;
80 const double molar_mass = variable_array.molar_mass;
81 // todo: add molar mass derivatives
82
83 if ((variable1 == Variable::gas_phase_pressure) &&
84 (variable2 == Variable::gas_phase_pressure))
85 {
86 // d2rho_dp2
87 // extend to take pressure-dependent molar mass into account
88 return 0.;
89 }
90 if ((variable1 == Variable::temperature) &&
91 (variable2 == Variable::temperature))
92 {
93 // d2rho_dT2
94 // extend to take temperature-dependent molar mass into account
95 return 2. * molar_mass * pressure / gas_constant / temperature /
97 }
98 if (((variable1 == Variable::gas_phase_pressure) &&
99 (variable2 == Variable::temperature)) ||
100 ((variable1 == Variable::temperature) &&
101 (variable2 == Variable::gas_phase_pressure)))
102 {
103 // d2rho_dpdT or d2rho_dTdp
104 // extend to take pressure-temperature-dependent molar mass into account
105 return -molar_mass / gas_constant / temperature / temperature;
106 }
107
108 OGS_FATAL(
109 "IdealGasLaw::d2Value is implemented for derivatives with respect to "
110 "phase pressure and temperature only.");
111
112 return 0.;
113}

References MaterialPropertyLib::gas_phase_pressure, MaterialPropertyLib::VariableArray::gas_phase_pressure, MaterialLib::PhysicalConstant::IdealGasConstant, MaterialPropertyLib::molar_mass, MaterialPropertyLib::VariableArray::molar_mass, OGS_FATAL, MaterialPropertyLib::temperature, and MaterialPropertyLib::VariableArray::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 41 of file IdealGasLaw.cpp.

45{
46 const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
47 const double pressure = variable_array.gas_phase_pressure;
48 const double temperature = variable_array.temperature;
49 const double molar_mass = variable_array.molar_mass;
50 // todo: add molar mass derivatives
51
52 if (variable == Variable::temperature)
53 {
54 // extend to take temperature-dependent molar mass into account
55 return -pressure * molar_mass / gas_constant / temperature /
57 }
58
59 if (variable == Variable::gas_phase_pressure)
60 {
61 // extend to take pressure-dependent molar mass into account
62 return molar_mass / gas_constant / temperature;
63 }
64
66 "IdealGasLaw::dValue is implemented for derivatives with respect to "
67 "phase pressure or temperature only.");
68
69 return 0.;
70}

References MaterialPropertyLib::gas_phase_pressure, MaterialPropertyLib::VariableArray::gas_phase_pressure, MaterialLib::PhysicalConstant::IdealGasConstant, MaterialPropertyLib::molar_mass, MaterialPropertyLib::VariableArray::molar_mass, OGS_FATAL, MaterialPropertyLib::temperature, and MaterialPropertyLib::VariableArray::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 26 of file IdealGasLaw.cpp.

30{
31 const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
32 const double pressure = variable_array.gas_phase_pressure;
33 const double temperature = variable_array.temperature;
34 const double molar_mass = variable_array.molar_mass;
35
36 const double density = pressure * molar_mass / gas_constant / temperature;
37
38 return density;
39}

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


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