OGS
ClausiusClapeyron.cpp
Go to the documentation of this file.
1
15
18
19namespace MaterialPropertyLib
20{
22 const double triple_temperature,
23 const double triple_pressure,
24 const double critical_temperature,
25 const double critical_pressure,
26 const double ref_temperature,
27 const double ref_pressure)
28 : T_triple_(triple_temperature),
29 p_triple_(triple_pressure),
30 T_critical_(critical_temperature),
31 p_critical_(critical_pressure),
32 T_ref_(ref_temperature),
33 p_ref_(ref_pressure)
34{
35 name_ = std::move(name);
36}
37
39{
40 if (!(std::holds_alternative<Phase*>(scale_) ||
41 std::holds_alternative<Component*>(scale_)))
42 {
44 "The property 'ClausiusClapeyron' is implemented on 'phase' and "
45 "'component' scales only.");
46 }
47}
48
50 std::variant<Medium*, Phase*, Component*> const scale,
51 VariableArray const& variable_array,
52 ParameterLib::SpatialPosition const& pos, double const t,
53 double const dt) const
54{
55 return std::visit(
56 [&variable_array, &pos, t, dt](auto&& s) -> double
57 {
58 return s->property(PropertyType::molar_mass)
59 .template value<double>(variable_array, pos, t, dt);
60 },
61 scale);
62}
63
65 VariableArray const& variable_array,
66 ParameterLib::SpatialPosition const& pos, double const t,
67 double const dt) const
68{
69 const double T = variable_array.temperature;
70
71 const double M = molarMass(scale_, variable_array, pos, t, dt);
72
73 if (T >= T_critical_)
74 {
75 return p_critical_;
76 }
77 if (T <= T_triple_)
78 {
79 return p_triple_;
80 }
81
82 const double dh = variable_array.enthalpy_of_evaporation;
84
85 return p_ref_ * std::exp((1. / T_ref_ - 1. / T) * M * dh / R);
86}
87
89 VariableArray const& variable_array, Variable const variable,
90 ParameterLib::SpatialPosition const& pos, double const t,
91 double const dt) const
92{
93 const double T = variable_array.temperature;
94 const double M = molarMass(scale_, variable_array, pos, t, dt);
95
96 if (T > T_critical_)
97 {
98 return 0.;
99 }
100 if (T < T_triple_)
101 {
102 return 0.;
103 }
104 if (variable == Variable::gas_phase_pressure)
105 {
106 return 0.;
107 }
108
110 const double dh = variable_array.enthalpy_of_evaporation;
111 const double p_vap = std::get<double>(value(variable_array, pos, t, dt));
112
113 if (variable == Variable::temperature)
114 {
115 return p_vap * M * dh / (R * T * T);
116 }
117 OGS_FATAL(
118 "ClausiusClapeyron::dValue is implemented for derivatives with respect "
119 "to phase pressure and temperature only.");
120}
121
123 VariableArray const& /*variable_array*/, Variable const /*variable1*/,
124 Variable const /*variable2*/, ParameterLib::SpatialPosition const& /*pos*/,
125 double const /*t*/, double const /*dt*/) const
126{
127 OGS_FATAL("ClausiusClapeyron::d2Value is not implemented.");
128}
129
130} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
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)
PropertyDataType d2Value(VariableArray const &variable_array, Variable const variable1, Variable const variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
Default implementation: 2nd derivative of any constant property is zero.
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:76
std::variant< Medium *, Phase *, Component * > scale_
Definition Property.h:297
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