14#ifndef DUMUX_ENERGY_VOLUME_VARIABLES_HH
15#define DUMUX_ENERGY_VOLUME_VARIABLES_HH
18#include <dune/common/std/type_traits.hh>
30template <
typename T,
typename ...Ts>
31using SolidHeatCapacityDetector =
decltype(std::declval<T>().solidHeatCapacity(std::declval<Ts>()...));
33template<
class T,
typename ...Args>
34static constexpr bool hasSolidHeatCapacity()
35{
return Dune::Std::is_detected<SolidHeatCapacityDetector, T, Args...>::value; }
37template <
typename T,
typename ...Ts>
38using SolidDensityDetector =
decltype(std::declval<T>().solidDensity(std::declval<Ts>()...));
40template<
class T,
typename ...Args>
41static constexpr bool hasSolidDensity()
42{
return Dune::Std::is_detected<SolidDensityDetector, T, Args...>::value; }
44template <
typename T,
typename ...Ts>
45using SolidThermalConductivityDetector =
decltype(std::declval<T>().solidThermalConductivity(std::declval<Ts>()...));
47template<
class T,
typename ...Args>
48static constexpr bool hasSolidThermalConductivity()
49{
return Dune::Std::is_detected<SolidThermalConductivityDetector, T, Args...>::value; }
51template<
class Sol
idSystem>
52struct isInertSolidPhase :
public std::false_type {};
54template<
class Scalar,
class Component>
55struct isInertSolidPhase<SolidSystems::
InertSolidPhase<Scalar, Component>> :
public std::true_type {};
62template <
class IsothermalTraits,
class Impl,
bool enableEnergyBalance>
72template<
class IsothermalTraits,
class Impl>
79template<
class IsothermalTraits,
class Impl>
82 using Scalar =
typename IsothermalTraits::PrimaryVariables::value_type;
85 using FluidState =
typename IsothermalTraits::FluidState;
86 using SolidState =
typename IsothermalTraits::SolidState;
90 template<
class ElemSol,
class Problem,
class Element,
class Scv>
92 const Problem& problem,
93 const Element& element,
99 Scalar T = problem.spatialParams().temperature(element, scv, elemSol);
100 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
102 fluidState.setTemperature(phaseIdx, T);
104 solidState.setTemperature(T);
107 template<
class ElemSol,
class Problem,
class Element,
class Scv>
109 const Problem& problem,
110 const Element &element,
117 template<
class Flu
idState,
class ParameterCache>
119 const ParameterCache& paramCache,
132template<
class Traits,
class Impl>
135 using Scalar =
typename Traits::PrimaryVariables::value_type;
136 using Idx =
typename Traits::ModelTraits::Indices;
138 using EffCondModel =
typename Traits::EffectiveThermalConductivityModel;
140 static constexpr int temperatureIdx = Idx::temperatureIdx;
141 static constexpr int numEnergyEq = Traits::ModelTraits::numEnergyEq();
143 static constexpr bool fullThermalEquilibrium = (numEnergyEq == 1);
144 static constexpr bool fluidThermalEquilibrium = (numEnergyEq == 2);
159 template<
class ElemSol,
class Problem,
class Element,
class Scv>
161 const Problem& problem,
162 const Element& element,
167 if constexpr (fullThermalEquilibrium)
170 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
171 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
173 fluidState.setTemperature(phaseIdx, T);
175 solidState.setTemperature(T);
181 if constexpr (fluidThermalEquilibrium)
183 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx];
184 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
186 fluidState.setTemperature(phaseIdx, T);
192 for(
int phaseIdx=0; phaseIdx < FluidSystem::numPhases; ++phaseIdx)
195 const Scalar T = elemSol[scv.localDofIndex()][temperatureIdx + phaseIdx];
196 fluidState.setTemperature(phaseIdx, T);
199 const Scalar
solidTemperature = elemSol[scv.localDofIndex()][temperatureIdx+numEnergyEq-1];
204 template<
class ElemSol,
class Problem,
class Element,
class Scv>
206 const Problem& problem,
207 const Element &element,
211 Scalar cs = solidHeatCapacity_(elemSol, problem, element, scv, solidState);
212 solidState.setHeatCapacity(cs);
214 Scalar rhos = solidDensity_(elemSol, problem, element, scv, solidState);
215 solidState.setDensity(rhos);
217 Scalar lambdas = solidThermalConductivity_(elemSol, problem, element, scv, solidState);
218 solidState.setThermalConductivity(lambdas);
224 if constexpr (fullThermalEquilibrium)
227 lambdaEff_[0] = EffCondModel::effectiveThermalConductivity(asImp_());
229 else if constexpr (fluidThermalEquilibrium)
232 Scalar fluidLambda = 0.0;
233 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
234 fluidLambda += fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
236 lambdaEff_[0] = fluidLambda;
237 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
242 for (
int phaseIdx = 0; phaseIdx < FluidSystem::numPhases; phaseIdx++)
243 lambdaEff_[phaseIdx] = fluidThermalConductivity(phaseIdx) * asImp_().saturation(phaseIdx) * asImp_().porosity();
244 lambdaEff_[numEnergyEq-1] = solidThermalConductivity() * (1.0 - asImp_().porosity());
255 {
return asImp_().fluidState().internalEnergy(phaseIdx); }
264 {
return asImp_().fluidState().enthalpy(phaseIdx); }
271 {
return asImp_().solidState().temperature(); }
280 {
return asImp_().fluidState().temperature(phaseIdx); }
287 {
return asImp_().solidState().heatCapacity(); }
294 {
return asImp_().solidState().density(); }
301 {
return asImp_().solidState().thermalConductivity(); }
308 {
return FluidSystem::thermalConductivity(asImp_().fluidState(), phaseIdx); }
314 template<
bool enable = fullThermalEquilibrium,
315 std::enable_if_t<enable, int> = 0>
317 {
return lambdaEff_[0]; }
323 template<
bool enable = fluidThermalEquilibrium,
324 std::enable_if_t<enable, int> = 0>
326 {
return lambdaEff_[0]; }
333 template<
bool enable = fluidThermalEquilibrium,
334 std::enable_if_t<enable, int> = 0>
336 {
return lambdaEff_[numEnergyEq-1]; }
343 template<
bool enable = (!fullThermalEquilibrium && !fluidThermalEquilibrium),
344 std::enable_if_t<enable, int> = 0>
346 {
return lambdaEff_[phaseIdx]; }
350 template<
class ParameterCache>
352 const ParameterCache& paramCache,
355 return FluidSystem::enthalpy(fluidState, paramCache, phaseIdx);
359 const Impl &
asImp_()
const {
return *
static_cast<const Impl*
>(
this); }
360 Impl &
asImp_() {
return *
static_cast<Impl*
>(
this); }
388 template<
class ElemSol,
class Problem,
class Element,
class Scv,
389 std::enable_if_t<!Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
390 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
391 const Problem& problem,
392 const Element& element,
394 const SolidState& solidState)
396 return SolidSystem::heatCapacity(solidState);
409 template<
class ElemSol,
class Problem,
class Element,
class Scv,
410 std::enable_if_t<!Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
411 Scalar solidDensity_(
const ElemSol& elemSol,
412 const Problem& problem,
413 const Element& element,
415 const SolidState& solidState)
430 template<
class ElemSol,
class Problem,
class Element,
class Scv,
431 std::enable_if_t<!Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
432 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
433 const Problem& problem,
434 const Element& element,
436 const SolidState& solidState)
438 return SolidSystem::thermalConductivity(solidState);
460 template<
class ElemSol,
class Problem,
class Element,
class Scv,
461 std::enable_if_t<Detail::hasSolidHeatCapacity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
462 Scalar solidHeatCapacity_(
const ElemSol& elemSol,
463 const Problem& problem,
464 const Element& element,
466 const SolidState& solidState)
468 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
469 "solidHeatCapacity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
470 "If you select a proper solid system, the solid heat capacity will be computed as stated in the solid system!");
471 return problem.spatialParams().solidHeatCapacity(element, scv, elemSol, solidState);
485 template<
class ElemSol,
class Problem,
class Element,
class Scv,
486 std::enable_if_t<Detail::hasSolidDensity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
487 Scalar solidDensity_(
const ElemSol& elemSol,
488 const Problem& problem,
489 const Element& element,
491 const SolidState& solidState)
493 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
494 "solidDensity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
495 "If you select a proper solid system, the solid density will be computed as stated in the solid system!");
496 return problem.spatialParams().solidDensity(element, scv, elemSol, solidState);
510 template<
class ElemSol,
class Problem,
class Element,
class Scv,
511 std::enable_if_t<Detail::hasSolidThermalConductivity<typename Problem::SpatialParams, Element, Scv, ElemSol, SolidState>(),
int> = 0>
512 Scalar solidThermalConductivity_(
const ElemSol& elemSol,
513 const Problem& problem,
514 const Element& element,
516 const SolidState& solidState)
518 static_assert(Detail::isInertSolidPhase<SolidSystem>::value,
519 "solidThermalConductivity can only be overwritten in the spatial params when the solid system is a simple InertSolidPhase\n"
520 "If you select a proper solid system, the solid thermal conductivity will be computed as stated in the solid system!");
521 return problem.spatialParams().solidThermalConductivity(element, scv, elemSol, solidState);
524 std::array<Scalar, numEnergyEq> lambdaEff_;
The simplest solid phase consisting of a single solid component.
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:108
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:118
typename IsothermalTraits::FluidSystem FluidSystem
Definition: porousmediumflow/nonisothermal/volumevariables.hh:87
typename IsothermalTraits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:86
typename IsothermalTraits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:85
void updateEffectiveThermalConductivity()
The effective thermal conductivity is zero for isothermal models.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:126
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:91
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:279
typename Traits::FluidSystem FluidSystem
export the underlying fluid system
Definition: porousmediumflow/nonisothermal/volumevariables.hh:150
Scalar solidDensity() const
Returns the mass density of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:293
const Impl & asImp_() const
Definition: porousmediumflow/nonisothermal/volumevariables.hh:359
Scalar enthalpy(const int phaseIdx) const
Returns the total enthalpy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:263
Scalar effectivePhaseThermalConductivity(const int phaseIdx) const
Returns the effective thermal conductivity per fluid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:345
Scalar fluidThermalConductivity(const int phaseIdx) const
Returns the thermal conductivity of a fluid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:307
Scalar temperatureSolid() const
Returns the temperature in fluid / solid phase(s) the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:270
Scalar internalEnergy(const int phaseIdx) const
Returns the total internal energy of a phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:254
void updateEffectiveThermalConductivity()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:222
typename Traits::FluidState FluidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:148
Scalar solidHeatCapacity() const
Returns the total heat capacity of the rock matrix in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:286
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:160
Scalar effectiveSolidThermalConductivity() const
Returns the effective thermal conductivity of the solid phase in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:335
Idx Indices
Export the indices.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:152
static Scalar enthalpy(const FluidState &fluidState, const ParameterCache ¶mCache, const int phaseIdx)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:351
typename Traits::SolidState SolidState
Definition: porousmediumflow/nonisothermal/volumevariables.hh:154
void updateSolidEnergyParams(const ElemSol &elemSol, const Problem &problem, const Element &element, const Scv &scv, SolidState &solidState)
Definition: porousmediumflow/nonisothermal/volumevariables.hh:205
Scalar effectiveThermalConductivity() const
Returns the effective thermal conductivity in the sub-control volume. Specific to equilibirum models...
Definition: porousmediumflow/nonisothermal/volumevariables.hh:316
Scalar solidThermalConductivity() const
Returns the thermal conductivity of the solid phase in the sub-control volume.
Definition: porousmediumflow/nonisothermal/volumevariables.hh:300
Scalar effectiveFluidThermalConductivity() const
Returns the effective thermal conductivity of the fluids in the sub-control volume....
Definition: porousmediumflow/nonisothermal/volumevariables.hh:325
Impl & asImp_()
Definition: porousmediumflow/nonisothermal/volumevariables.hh:360
typename Traits::SolidSystem SolidSystem
export the underlying solid system
Definition: porousmediumflow/nonisothermal/volumevariables.hh:156
Definition: porousmediumflow/nonisothermal/volumevariables.hh:63
The isothermal base class.
Definition: porousmediumflow/volumevariables.hh:28
OneCSolid< Scalar, ComponentT, true > InertSolidPhase
A solid phase consisting of a single inert solid component.
Definition: 1csolid.hh:125
std::string solidTemperature() noexcept
I/O name of solid temperature for non-equilibrium models.
Definition: name.hh:48
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Base class for the model specific class which provides access to all volume averaged quantities.