OGS
SpecificHeatCapacityWithLatentHeat.cpp
Go to the documentation of this file.
1
13
15
16namespace MaterialPropertyLib
17{
19 std::string name, double const l)
20 : l_(l)
21{
22 name_ = std::move(name);
23}
24
26{
27 if (!std::holds_alternative<Medium*>(scale_))
28 {
30 "The property 'SpecificHeatCapacityWithLatentHeat' is "
31 "implemented on the 'medium' scale only.");
32 }
33}
34
36 std::vector<std::unique_ptr<Phase>> const& phases)
37{
38 // run over phases, identify them and get properties
39 for (auto const& phase : phases)
40 {
41 if (phase == nullptr)
42 {
44 "One of the required phases (AqueousLiquid/FrozenLiquid/Solid) "
45 "does not exist!");
46 }
47 std::string const& phase_name = phase->name;
48
49 auto const& density_property =
51 auto const& specific_heat_capacity_property = phase->property(
53
54 if (phase_name == "AqueousLiquid")
55 {
56 densities_.liquid = &density_property;
57 spec_heat_capacities_.liquid = &specific_heat_capacity_property;
58 }
59 else if (phase_name == "FrozenLiquid")
60 {
61 densities_.frozen = &density_property;
62 spec_heat_capacities_.frozen = &specific_heat_capacity_property;
63 }
64 else if (phase_name == "Solid")
65 {
66 densities_.porous = &density_property;
67 spec_heat_capacities_.porous = &specific_heat_capacity_property;
68 }
69 }
70}
71
73 VariableArray const& variable_array,
74 ParameterLib::SpatialPosition const& pos, double const t,
75 double const dt) const
76{
77 auto const& medium = *std::get<Medium*>(scale_);
78 auto const& porosity_property = medium[PropertyType::porosity];
79 auto const& frozen_fraction_property =
81
82 auto const phi =
83 std::get<double>(porosity_property.value(variable_array, pos, t, dt));
84 auto const phi_fr = std::get<double>(
85 frozen_fraction_property.value(variable_array, pos, t, dt));
86 auto const phi_li = phi - phi_fr;
87 auto const phi_po = 1 - phi;
88
89 auto const rho_li =
90 std::get<double>(densities_.liquid->value(variable_array, pos, t, dt));
91 auto const rho_fr =
92 std::get<double>(densities_.frozen->value(variable_array, pos, t, dt));
93 auto const rho_po =
94 std::get<double>(densities_.porous->value(variable_array, pos, t, dt));
95
96 auto const c_li = std::get<double>(
97 spec_heat_capacities_.liquid->value(variable_array, pos, t, dt));
98 auto const c_fr = std::get<double>(
99 spec_heat_capacities_.frozen->value(variable_array, pos, t, dt));
100 auto const c_po = std::get<double>(
101 spec_heat_capacities_.porous->value(variable_array, pos, t, dt));
102
103 // rule of mixtures for resulting volumetric heat capacity
104 // (mass fraction average of specific heat capacities!)
105 return phi_li * rho_li * c_li + phi_fr * rho_fr * c_fr +
106 phi_po * rho_po * c_po;
107}
108
110 VariableArray const& variable_array,
111 ParameterLib::SpatialPosition const& pos, double const t,
112 double const dt) const
113{
114 auto const& medium = *std::get<Medium*>(scale_);
115 auto const& effective_density_property = medium[PropertyType::density];
116 auto const& frozen_fraction_property =
118
119 auto const rho_eff = effective_density_property.template value<double>(
120 variable_array, pos, t, dt);
121 auto const rho_fr =
122 std::get<double>(densities_.frozen->value(variable_array, pos, t, dt));
123 auto const dphi_fr_dT = frozen_fraction_property.template dValue<double>(
124 variable_array, Variable::temperature, pos, t, dt);
125
126 auto const Cvol =
127 effectiveVolumetricHeatCapacity(variable_array, pos, t, dt);
128 auto const Lvol = l_ * rho_fr;
129 auto const Cvol_app = Cvol - Lvol * dphi_fr_dT;
130 // divide volumetric quantity by density in order to obtain specific value
131 return Cvol_app / rho_eff;
132}
133
135 VariableArray const& variable_array, Variable const variable,
136 ParameterLib::SpatialPosition const& pos, double const t,
137 double const dt) const
138{
139 (void)variable;
140 assert((variable == Variable::temperature) &&
141 "SpecificHeatCapacityWithLatentHeat::dvalue is implemented for "
142 "derivatives with respect to temperature only.");
143
144 auto const& medium = *std::get<Medium*>(scale_);
145 auto const& effective_density_property = medium[PropertyType::density];
146 auto const& frozen_fraction_property =
148
149 auto const rho_eff = effective_density_property.template value<double>(
150 variable_array, pos, t, dt);
151 auto const rho_li =
152 std::get<double>(densities_.liquid->value(variable_array, pos, t, dt));
153 auto const rho_fr =
154 std::get<double>(densities_.frozen->value(variable_array, pos, t, dt));
155 auto const c_li = std::get<double>(
156 spec_heat_capacities_.liquid->value(variable_array, pos, t, dt));
157 auto const c_fr = std::get<double>(
158 spec_heat_capacities_.frozen->value(variable_array, pos, t, dt));
159 auto const drho_dT = effective_density_property.template dValue<double>(
160 variable_array, Variable::temperature, pos, t, dt);
161 auto const dphi_fr_dT = frozen_fraction_property.template dValue<double>(
162 variable_array, Variable::temperature, pos, t, dt);
163 auto const d2phi_fr_dT2 = frozen_fraction_property.template d2Value<double>(
164 variable_array, Variable::temperature, Variable::temperature, pos, t,
165 dt);
166 auto const Cvol =
167 effectiveVolumetricHeatCapacity(variable_array, pos, t, dt);
168 // TODO: avoid duplicate code, call value()?
169 auto const C_app = (Cvol - l_ * rho_eff * dphi_fr_dT) / rho_eff;
170 auto const dCvol_dphi_fr = rho_fr * c_fr - rho_li * c_li;
171 auto const dCvol_app_dT =
172 dCvol_dphi_fr * dphi_fr_dT - l_ * rho_eff * d2phi_fr_dT2;
173
174 return (dCvol_app_dT - drho_dT / rho_eff * C_app) / rho_eff;
175}
176} // namespace MaterialPropertyLib
#define OGS_FATAL(...)
Definition Error.h:26
virtual PropertyDataType d2Value(VariableArray const &variable_array, Variable const variable1, Variable const variable2, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const
Default implementation: 2nd derivative of any constant property is zero.
Definition Property.cpp:131
virtual PropertyDataType value() const
Definition Property.cpp:76
std::variant< Medium *, Phase *, Component * > scale_
Definition Property.h:297
void setProperties(std::vector< std::unique_ptr< Phase > > const &phases) override
Default implementation:
PhaseProperties spec_heat_capacities_
Pointers to the properties in each phase.
PhaseProperties densities_
Pointers to the properties in each phase.
PropertyDataType dValue(VariableArray const &variable_array, Variable const variable, ParameterLib::SpatialPosition const &pos, double const t, double const dt) const override
double effectiveVolumetricHeatCapacity(VariableArray const &variable_array, ParameterLib::SpatialPosition const &pos, double const t, double const dt) 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
Definition Property.h:31