OGS
IdealGasLaw.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
5
8
10{
12{
13 name_ = std::move(name);
14}
15
17 VariableArray const& variable_array,
18 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
19 double const /*dt*/) const
20{
21 const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
22 const double pressure = variable_array.gas_phase_pressure;
23 const double temperature = variable_array.temperature;
24 const double molar_mass = variable_array.molar_mass;
25
26 const double density = pressure * molar_mass / gas_constant / temperature;
27
28 return density;
29}
30
32 VariableArray const& variable_array, Variable const variable,
33 ParameterLib::SpatialPosition const& /*pos*/, double const /*t*/,
34 double const /*dt*/) const
35{
36 const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
37 const double pressure = variable_array.gas_phase_pressure;
38 const double temperature = variable_array.temperature;
39 const double molar_mass = variable_array.molar_mass;
40 // todo: add molar mass derivatives
41
42 if (variable == Variable::temperature)
43 {
44 // extend to take temperature-dependent molar mass into account
45 return -pressure * molar_mass / gas_constant / temperature /
47 }
48
49 if (variable == Variable::gas_phase_pressure)
50 {
51 // extend to take pressure-dependent molar mass into account
52 return molar_mass / gas_constant / temperature;
53 }
54
56 "IdealGasLaw::dValue is implemented for derivatives with respect to "
57 "phase pressure or temperature only.");
58
59 return 0.;
60}
61
63 VariableArray const& variable_array, Variable const variable1,
64 Variable const variable2, ParameterLib::SpatialPosition const& /*pos*/,
65 double const /*t*/, double const /*dt*/) const
66{
67 const double gas_constant = MaterialLib::PhysicalConstant::IdealGasConstant;
68 const double pressure = variable_array.gas_phase_pressure;
69 const double temperature = variable_array.temperature;
70 const double molar_mass = variable_array.molar_mass;
71 // todo: add molar mass derivatives
72
73 if ((variable1 == Variable::gas_phase_pressure) &&
74 (variable2 == Variable::gas_phase_pressure))
75 {
76 // d2rho_dp2
77 // extend to take pressure-dependent molar mass into account
78 return 0.;
79 }
80 if ((variable1 == Variable::temperature) &&
81 (variable2 == Variable::temperature))
82 {
83 // d2rho_dT2
84 // extend to take temperature-dependent molar mass into account
85 return 2. * molar_mass * pressure / gas_constant / temperature /
87 }
88 if (((variable1 == Variable::gas_phase_pressure) &&
89 (variable2 == Variable::temperature)) ||
90 ((variable1 == Variable::temperature) &&
91 (variable2 == Variable::gas_phase_pressure)))
92 {
93 // d2rho_dpdT or d2rho_dTdp
94 // extend to take pressure-temperature-dependent molar mass into account
95 return -molar_mass / gas_constant / temperature / temperature;
96 }
97
99 "IdealGasLaw::d2Value is implemented for derivatives with respect to "
100 "phase pressure and temperature only.");
101
102 return 0.;
103}
104
105} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:19
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
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