26#ifndef DUMUX_ENERGY_VOLUME_VARIABLES_HH
27#define DUMUX_ENERGY_VOLUME_VARIABLES_HH
30#include <dune/common/std/type_traits.hh>
42template <
typename T,
typename ...Ts>
43using SolidHeatCapacityDetector =
decltype(std::declval<T>().solidHeatCapacity(std::declval<Ts>()...));
45template<
class T,
typename ...Args>
46static constexpr bool hasSolidHeatCapacity()
47{
return Dune::Std::is_detected<SolidHeatCapacityDetector, T, Args...>::value; }
49template <
typename T,
typename ...Ts>
50using SolidDensityDetector =
decltype(std::declval<T>().solidDensity(std::declval<Ts>()...));
52template<
class T,
typename ...Args>
53static constexpr bool hasSolidDensity()
54{
return Dune::Std::is_detected<SolidDensityDetector, T, Args...>::value; }
56template <
typename T,
typename ...Ts>
57using SolidThermalConductivityDetector =
decltype(std::declval<T>().solidThermalConductivity(std::declval<Ts>()...));
59template<
class T,
typename ...Args>
60static constexpr bool hasSolidThermalConductivity()
61{
return Dune::Std::is_detected<SolidThermalConductivityDetector, T, Args...>::value; }
63template<
class Sol
idSystem>
64struct isInertSolidPhase :
public std::false_type {};
66template<
class Scalar,
class Component>
67struct isInertSolidPhase<SolidSystems::
InertSolidPhase<Scalar, Component>> :
public std::true_type {};
74template <
class IsothermalTraits,
class Impl,
bool enableEnergyBalance>
84template<
class IsothermalTraits,
class Impl>
91template<
class IsothermalTraits,
class Impl>
94 using Scalar =
typename IsothermalTraits::PrimaryVariables::value_type;
97 using FluidState =
typename IsothermalTraits::FluidState;
98 using SolidState =
typename IsothermalTraits::SolidState;
102 template<
class ElemSol,
class Problem,
class Element,
class Scv>
104 const Problem& problem,
105 const Element& element,
111 Scalar T = problem.spatialParams().temperature(element, scv, elemSol);
112 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
114 fluidState.setTemperature(phaseIdx, T);
116 solidState.setTemperature(T);
119 template<
class ElemSol,
class Problem,
class Element,
class Scv>
121 const Problem& problem,
122 const Element &element,
129 template<
class Flu
idState,
class ParameterCache>
131 const ParameterCache& paramCache,
144template<
class Traits,
class Impl>
147 using Scalar =
typename Traits::PrimaryVariables::value_type;
148 using Idx =
typename Traits::ModelTraits::Indices;
150 using EffCondModel =
typename Traits::EffectiveThermalConductivityModel;
152 static constexpr int temperatureIdx = Idx::temperatureIdx;
153 static constexpr int numEnergyEq = Traits::ModelTraits::numEnergyEq();
155 static constexpr bool fullThermalEquilibrium = (numEnergyEq == 1);
156 static constexpr bool fluidThermalEquilibrium = (numEnergyEq == 2);
171 template<
class ElemSol,
class Problem,
class Element,
class Scv>
173 const Problem& problem,
174 const Element& element,
179 if constexpr (fullThermalEquilibrium)
182 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
183 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
185 fluidState.setTemperature(phaseIdx, T);
187 solidState.setTemperature(T);
193 if constexpr (fluidThermalEquilibrium)
195 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
196 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
198 fluidState.setTemperature(phaseIdx, T);
204 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
207 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx + phaseIdx];
208 fluidState.setTemperature(phaseIdx, T);
211 const Scalar
solidTemperature = elemSol[scv.localDofIndex()][temperatureIdx+numEnergyEq-1];
216 template<
class ElemSol,
class Problem,
class Element,
class Scv>
218 const Problem& problem,
219 const Element &element,
223 Scalar cs = solidHeatCapacity_(elemSol, problem, element, scv, solidState);
224 solidState.setHeatCapacity(cs);
226 Scalar rhos = solidDensity_(elemSol, problem, element, scv, solidState);
227 solidState.setDensity(rhos);
229 Scalar lambdas = solidThermalConductivity_(elemSol, problem, element, scv, solidState);
230 solidState.setThermalConductivity(lambdas);
236 if constexpr (fullThermalEquilibrium)
239 lambdaEff_[0] = EffCondModel::effectiveThermalConductivity(asImp_());
241 else if constexpr (fluidThermalEquilibrium)
244 Scalar fluidLambda = 0.0;
245 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
246 fluidLambda += fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
248 lambdaEff_[0] = fluidLambda;
249 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
254 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
255 lambdaEff_[phaseIdx] = fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
256 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
267 {
return asImp_().fluidState().internalEnergy(phaseIdx); }
276 {
return asImp_().fluidState().enthalpy(phaseIdx); }
283 {
return asImp_().solidState().temperature(); }
292 {
return asImp_().fluidState().temperature(phaseIdx); }
299 {
return asImp_().solidState().heatCapacity(); }
306 {
return asImp_().solidState().density(); }
313 {
return asImp_().solidState().thermalConductivity(); }
320 {
return FluidSystem::thermalConductivity(asImp_().fluidState(), phaseIdx); }
326 template<
bool enable = fullThermalEquilibrium,
327 std::enable_if_t<enable, int> = 0>
329 {
return lambdaEff_[0]; }
335 template<
bool enable = fluidThermalEquilibrium,
336 std::enable_if_t<enable, int> = 0>
338 {
return lambdaEff_[0]; }
345 template<
bool enable = fluidThermalEquilibrium,
346 std::enable_if_t<enable, int> = 0>
348 {
return lambdaEff_[numEnergyEq-1]; }
355 template<
bool enable = (!fullThermalEquilibrium && !fluidThermalEquilibrium),
356 std::enable_if_t<enable, int> = 0>
358 {
return lambdaEff_[phaseIdx]; }
362 template<
class ParameterCache>
364 const ParameterCache& paramCache,
367 return FluidSystem::enthalpy(fluidState, paramCache, phaseIdx);
371 const Impl &asImp_()
const {
return *
static_cast<const Impl*
>(
this); }
372 Impl &asImp_() {
return *
static_cast<Impl*
>(
this); }
400 template<
class ElemSol,
class Problem,
class Element,
class Scv,
401 std::enable_if_t<!Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
402 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
403 const Problem& problem,
404 const Element& element,
406 const SolidState& solidState)
408 return SolidSystem::heatCapacity(solidState);
421 template<
class ElemSol,
class Problem,
class Element,
class Scv,
422 std::enable_if_t<!Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
423 Scalar solidDensity_(
const ElemSol& elemSol,
424 const Problem& problem,
425 const Element& element,
427 const SolidState& solidState)
442 template<
class ElemSol,
class Problem,
class Element,
class Scv,
443 std::enable_if_t<!Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
444 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
445 const Problem& problem,
446 const Element& element,
448 const SolidState& solidState)
450 return SolidSystem::thermalConductivity(solidState);
472 template<
class ElemSol,
class Problem,
class Element,
class Scv,
473 std::enable_if_t<Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
474 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
475 const Problem& problem,
476 const Element& element,
478 const SolidState& solidState)
480 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
481 "solidHeatCapacity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
482 "If you select a proper solid system, the solid heat capacity will be computed as stated in the solid system!");
483 return problem.spatialParams().solidHeatCapacity(element, scv, elemSol, solidState);
497 template<
class ElemSol,
class Problem,
class Element,
class Scv,
498 std::enable_if_t<Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
499 Scalar solidDensity_(
const ElemSol& elemSol,
500 const Problem& problem,
501 const Element& element,
503 const SolidState& solidState)
505 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
506 "solidDensity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
507 "If you select a proper solid system, the solid density will be computed as stated in the solid system!");
508 return problem.spatialParams().solidDensity(element, scv, elemSol, solidState);
522 template<
class ElemSol,
class Problem,
class Element,
class Scv,
523 std::enable_if_t<Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
524 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
525 const Problem& problem,
526 const Element& element,
528 const SolidState& solidState)
530 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
531 "solidThermalConductivity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
532 "If you select a proper solid system, the solid thermal conductivity will be computed as stated in the solid system!");
533 return problem.spatialParams().solidThermalConductivity(element, scv, elemSol, solidState);
536 std::array<Scalar, numEnergyEq> lambdaEff_;
The simplest solid phase consisting of a single solid component.
OneCSolid< Scalar, ComponentT, true > InertSolidPhase
A solid phase consisting of a single inert solid component.
Definition: 1csolid.hh:137
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
std::string solidTemperature() noexcept
I/O name of solid temperature for non-equilibrium models.
Definition: name.hh:60
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Definition: porousmediumflow/nonisothermal/volumevariables.hh:75
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:120
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:130
typename IsothermalTraits::FluidSystem FluidSystem
Definition: porousmediumflow/nonisothermal/volumevariables.hh:99
typename IsothermalTraits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:98
typename IsothermalTraits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:97
void updateEffectiveThermalConductivity()
The effective thermal conductivity is zero for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:138
void updateTemperature(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
The temperature is obtained from the problem as a constant for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:103
Scalar temperatureFluid(const int phaseIdx) const
Returns the temperature of a fluid phase assuming thermal nonequilibrium the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:291
typename Traits::FluidSystem FluidSystem
export the underlying fluid system
Definition: porousmediumflow/nonisothermal/volumevariables.hh:162
Scalar solidDensity() const
Returns the mass density of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:305
Scalar enthalpy(const int phaseIdx) const
Returns the total enthalpy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:275
Scalar effectivePhaseThermalConductivity(const int phaseIdx) const
Returns the effective thermal conductivity per fluid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:357
Scalar fluidThermalConductivity(const int phaseIdx) const
Returns the thermal conductivity of a fluid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:319
Scalar temperatureSolid() const
Returns the temperature in fluid / solid phase(s) the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:282
Scalar internalEnergy(const int phaseIdx) const
Returns the total internal energy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:266
void updateEffectiveThermalConductivity()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:234
typename Traits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:160
Scalar solidHeatCapacity() const
Returns the total heat capacity of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:298
void updateTemperature(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, FluidState &fluidState, SolidState &solidState)
The temperature is obtained from the problem as a constant for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:172
Scalar effectiveSolidThermalConductivity() const
Returns the effective thermal conductivity of the solid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:347
Idx Indices
Export the indices.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:164
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:363
typename Traits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:166
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:217
Scalar effectiveThermalConductivity() const
Returns the effective thermal conductivity in the sub-control volume. Specific to equilibirum models...
Definition: porousmediumflow/nonisothermal/volumevariables.hh:328
Scalar solidThermalConductivity() const
Returns the thermal conductivity of the solid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:312
Scalar effectiveFluidThermalConductivity() const
Returns the effective thermal conductivity of the fluids in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:337
typename Traits::SolidSystem SolidSystem
export the underlying solid system
Definition: porousmediumflow/nonisothermal/volumevariables.hh:168
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:40
Base class for the model specific class which provides access to all volume averaged quantities.