OGS
IdealGasLaw.cpp
Go to the documentation of this file.
1
15
18
19namespace MaterialPropertyLib
20{
22{
23 name_ = std::move(name);
24}
25
27 VariableArray const& variable_array,
28 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
29 double const /*dt*/) const
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}
40
42 VariableArray const& variable_array, Variable const variable,
43 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
44 double const /*dt*/) const
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}
71
73 VariableArray const& variable_array, Variable const variable1,
74 Variable const variable2, ParameterLib::SpatialPosition const& /*pos*/,
75 double const /*t*/, double const /*dt*/) const
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}
114
115} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
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.
virtual PropertyDataType value() const
Definition Property.cpp:76
std::variant< double, Eigen::Matrix< double, 2, 1 >, Eigen::Matrix< double, 3, 1 >, Eigen::Matrix< double, 2, 2 >, Eigen::Matrix< double, 3, 3 >, Eigen::Matrix< double, 4, 1 >, Eigen::Matrix< double, 6, 1 >, Eigen::MatrixXd > PropertyDataType
Definition Property.h:31