version 3.8
tabulatedcomponent.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3//
4// SPDX-FileCopyrightInfo: Copyright © DuMux Project contributors, see AUTHORS.md in root folder
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
16#ifndef DUMUX_TABULATED_COMPONENT_HH
17#define DUMUX_TABULATED_COMPONENT_HH
18
19#include <cmath>
20#include <limits>
21#include <cassert>
22#include <vector>
23#include <iostream>
24#include <iomanip>
25#include <algorithm>
26
27#include <dune/common/std/type_traits.hh>
28
34
35namespace Dumux::Components {
36// forward declaration
37template<class RawComponent, bool useVaporPressure>
38class TabulatedComponent;
39} // end namespace Dumux::Components
40
41namespace Dumux {
42
44template<class RawComponent, bool useVaporPressure>
45struct ComponentTraits<Components::TabulatedComponent<RawComponent, useVaporPressure>>
46{
47 using Scalar = typename RawComponent::Scalar;
48
50 static constexpr bool hasSolidState = std::is_base_of<Components::Solid<Scalar, RawComponent>, RawComponent>::value;
51
53 static constexpr bool hasLiquidState = std::is_base_of<Components::Liquid<Scalar, RawComponent>, RawComponent>::value;
54
56 static constexpr bool hasGasState = std::is_base_of<Components::Gas<Scalar, RawComponent>, RawComponent>::value;
57};
58} // end namespace Dumux
59
62} // end namespace Dumux::Components::Detail
63
64namespace Dumux {
65template<> struct AlwaysFalse<Components::Detail::DisableStaticAssert> : public std::true_type {};
66}// end namespace Dumux
67
69
70template<class C> using CompHasNoLiquidEnthalpy = decltype(C::template liquidEnthalpy<DisableStaticAssert>(0.0, 0.0));
71template<class C> using CompHasNoLiquidDensity = decltype(C::template liquidDensity<DisableStaticAssert>(0.0, 0.0));
72template<class C> using CompHasNoLiquidThermalCond = decltype(C::template liquidThermalConductivity<DisableStaticAssert>(0.0, 0.0));
73template<class C> using CompHasNoLiquidHeatCapacity = decltype(C::template liquidHeatCapacity<DisableStaticAssert>(0.0, 0.0));
74template<class C> using CompHasNoLiquidViscosity = decltype(C::template liquidViscosity<DisableStaticAssert>(0.0, 0.0));
75template<class C> using CompHasLiquidPressure = decltype(C::liquidPressure(0.0, 0.0));
76
77template<class C> using CompHasNoGasEnthalpy = decltype(C::template gasEnthalpy<DisableStaticAssert>(0.0, 0.0));
78template<class C> using CompHasNoGasDensity = decltype(C::template gasDensity<DisableStaticAssert>(0.0, 0.0));
79template<class C> using CompHasNoGasThermalCond = decltype(C::template gasThermalConductivity<DisableStaticAssert>(0.0, 0.0));
80template<class C> using CompHasNoGasHeatCapacity = decltype(C::template gasHeatCapacity<DisableStaticAssert>(0.0, 0.0));
81template<class C> using CompHasNoGasViscosity = decltype(C::template gasViscosity<DisableStaticAssert>(0.0, 0.0));
82template<class C> using CompHasGasPressure = decltype(C::gasPressure(0.0, 0.0));
83
84template<class C> constexpr inline bool hasLiquidEnthalpy()
85{ return !Dune::Std::is_detected<CompHasNoLiquidEnthalpy, C>::value && ComponentTraits<C>::hasLiquidState; }
86template<class C> constexpr inline bool hasLiquidDensity()
87{ return !Dune::Std::is_detected<CompHasNoLiquidDensity, C>::value && ComponentTraits<C>::hasLiquidState; }
88template<class C> constexpr inline bool hasLiquidThermalConductivity()
89{ return !Dune::Std::is_detected<CompHasNoLiquidThermalCond, C>::value && ComponentTraits<C>::hasLiquidState; }
90template<class C> constexpr inline bool hasLiquidHeatCapacity()
91{ return !Dune::Std::is_detected<CompHasNoLiquidHeatCapacity, C>::value && ComponentTraits<C>::hasLiquidState; }
92template<class C> constexpr inline bool hasLiquidViscosity()
93{ return !Dune::Std::is_detected<CompHasNoLiquidViscosity, C>::value && ComponentTraits<C>::hasLiquidState; }
94template<class C> constexpr inline bool hasLiquidPressure()
95{ return Dune::Std::is_detected<CompHasLiquidPressure, C>::value && ComponentTraits<C>::hasLiquidState; }
96
97template<class C> constexpr inline bool hasGasEnthalpy()
98{ return !Dune::Std::is_detected<CompHasNoGasEnthalpy, C>::value && ComponentTraits<C>::hasGasState; }
99template<class C> constexpr inline bool hasGasDensity()
100{ return !Dune::Std::is_detected<CompHasNoGasDensity, C>::value && ComponentTraits<C>::hasGasState; }
101template<class C> constexpr inline bool hasGasThermalConductivity()
102{ return !Dune::Std::is_detected<CompHasNoGasThermalCond, C>::value && ComponentTraits<C>::hasGasState; }
103template<class C> constexpr inline bool hasGasHeatCapacity()
104{ return !Dune::Std::is_detected<CompHasNoGasHeatCapacity, C>::value && ComponentTraits<C>::hasGasState; }
105template<class C> constexpr inline bool hasGasViscosity()
106{ return !Dune::Std::is_detected<CompHasNoGasViscosity, C>::value && ComponentTraits<C>::hasGasState; }
107template<class C> constexpr inline bool hasGasPressure()
108{ return Dune::Std::is_detected<CompHasGasPressure, C>::value && ComponentTraits<C>::hasGasState; }
109
110template<class RawComponent, bool useVaporPressure = true>
112{
113 using Scalar = typename RawComponent::Scalar;
114 friend class TabulatedComponent<RawComponent, useVaporPressure>;
115
116 struct GasPolicy
117 {
118 Scalar minP(std::size_t iT) const { return table.minGasPressure(iT); }
119 Scalar maxP(std::size_t iT) const { return table.maxGasPressure(iT); }
121 };
122
123 struct LiquidPolicy
124 {
125 Scalar minP(std::size_t iT) const { return table.minLiquidPressure(iT); }
126 Scalar maxP(std::size_t iT) const { return table.maxLiquidPressure(iT); }
128 };
129public:
130 void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp,
131 Scalar pressMin, Scalar pressMax, std::size_t nPress)
132 {
133 tempMin_ = tempMin;
134 tempMax_ = tempMax;
135 nTemp_ = nTemp;
136 pressMin_ = pressMin;
137 pressMax_ = pressMax;
138 nPress_ = nPress;
139 nDensity_ = nPress;
140
141 // resize & initialize the arrays with NaN
142 assert(std::numeric_limits<Scalar>::has_quiet_NaN);
143 const auto NaN = std::numeric_limits<Scalar>::quiet_NaN();
144
145 // initialize vapor pressure array depending on useVaporPressure
146 vaporPressure_.resize(nTemp_, NaN);
147 tabularizeVaporPressure_();
148
150 {
151 minGasDensity_.resize(nTemp_, NaN);
152 maxGasDensity_.resize(nTemp_, NaN);
153 const std::size_t numEntriesTp = nTemp_*nPress_;
154 gasEnthalpy_.resize(numEntriesTp, NaN);
155 gasHeatCapacity_.resize(numEntriesTp, NaN);
156 gasDensity_.resize(numEntriesTp, NaN);
157 gasViscosity_.resize(numEntriesTp, NaN);
158 gasThermalConductivity_.resize(numEntriesTp, NaN);
159
160 if constexpr (RawComponent::gasIsCompressible())
161 gasPressure_.resize(numEntriesTp, NaN);
162
163 minMaxGasDensityInitialized_ = tabularizeMinMaxGasDensity_();
164 gasPressureInitialized_ = tabularizeGasPressure_();
165 gasEnthalpyInitialized_ = tabularizeGasEnthalpy_();
166 gasHeatCapacityInitialized_ = tabularizeGasHeatCapacity_();
167 gasDensityInitialized_ = tabularizeGasDensity_();
168 gasViscosityInitialized_ = tabularizeGasViscosity_();
169 gasThermalConductivityInitialized_ = tabularizeGasThermalConductivity_();
170 }
171
173 {
174 minLiquidDensity_.resize(nTemp_, NaN);
175 maxLiquidDensity_.resize(nTemp_, NaN);
176
177 const std::size_t numEntriesTp = nTemp_*nPress_;
178 liquidEnthalpy_.resize(numEntriesTp, NaN);
179 liquidHeatCapacity_.resize(numEntriesTp, NaN);
180 liquidDensity_.resize(numEntriesTp, NaN);
181 liquidViscosity_.resize(numEntriesTp, NaN);
182 liquidThermalConductivity_.resize(numEntriesTp, NaN);
183
184 if constexpr (RawComponent::liquidIsCompressible())
185 liquidPressure_.resize(numEntriesTp, NaN);
186
187 minMaxLiquidDensityInitialized_ = tabularizeMinMaxLiquidDensity_();
188 liquidPressureInitialized_ = tabularizeLiquidPressure_();
189 liquidEnthalpyInitialized_ = tabularizeLiquidEnthalpy_();
190 liquidHeatCapacityInitialized_ = tabularizeLiquidHeatCapacity_();
191 liquidDensityInitialized_ = tabularizeLiquidDensity_();
192 liquidViscosityInitialized_ = tabularizeLiquidViscosity_();
193 liquidThermalConductivityInitialized_ = tabularizeLiquidThermalConductivity_();
194 }
195 }
196
198 inline Scalar tempIdx(Scalar temperature) const
199 {
200 return (nTemp_ - 1)*(temperature - tempMin_)/(tempMax_ - tempMin_);
201 }
202
204 inline Scalar pressLiquidIdx(Scalar pressure, std::size_t tempIdx) const
205 {
206 const Scalar plMin = minLiquidPressure(tempIdx);
207 const Scalar plMax = maxLiquidPressure(tempIdx);
208 return (nPress_ - 1)*(pressure - plMin)/(plMax - plMin);
209 }
210
212 inline Scalar pressGasIdx(Scalar pressure, std::size_t tempIdx) const
213 {
214 const Scalar pgMin = minGasPressure(tempIdx);
215 const Scalar pgMax = maxGasPressure(tempIdx);
216 return (nPress_ - 1)*(pressure - pgMin)/(pgMax - pgMin);
217 }
218
220 inline Scalar densityLiquidIdx(Scalar density, std::size_t tempIdx) const
221 {
222 const Scalar densityMin = minLiquidDensity_[tempIdx];
223 const Scalar densityMax = maxLiquidDensity_[tempIdx];
224 return (nDensity_ - 1) * (density - densityMin)/(densityMax - densityMin);
225 }
226
228 inline Scalar densityGasIdx(Scalar density, std::size_t tempIdx) const
229 {
230 const Scalar densityMin = minGasDensity_[tempIdx];
231 const Scalar densityMax = maxGasDensity_[tempIdx];
232 return (nDensity_ - 1) * (density - densityMin)/(densityMax - densityMin);
233 }
234
236 inline Scalar minLiquidPressure(int tempIdx) const
237 {
238 using std::max;
239 if (!useVaporPressure)
240 return pressMin_;
241 else
242 return max(pressMin_, vaporPressure_[tempIdx] / 1.1);
243 }
244
246 inline Scalar maxLiquidPressure(int tempIdx) const
247 {
248 using std::max;
249 if (!useVaporPressure)
250 return pressMax_;
251 else
252 return max(pressMax_, vaporPressure_[tempIdx] * 1.1);
253 }
254
256 inline Scalar minGasPressure(int tempIdx) const
257 {
258 using std::min;
259 if (!useVaporPressure)
260 return pressMin_;
261 else
262 return min(pressMin_, vaporPressure_[tempIdx] / 1.1 );
263 }
264
266 inline Scalar maxGasPressure(int tempIdx) const
267 {
268 using std::min;
269 if (!useVaporPressure)
270 return pressMax_;
271 else
272 return min(pressMax_, vaporPressure_[tempIdx] * 1.1);
273 }
274
276 inline Scalar minLiquidDensity(int tempIdx) const
277 { return minLiquidDensity_[tempIdx]; }
278
280 inline Scalar maxLiquidDensity(int tempIdx) const
281 { return maxLiquidDensity_[tempIdx]; }
282
284 inline Scalar minGasDensity(int tempIdx) const
285 { return minGasDensity_[tempIdx]; }
286
288 inline Scalar maxGasDensity(int tempIdx) const
289 { return maxGasDensity_[tempIdx]; }
290
291 inline std::size_t nTemp() const { return nTemp_; }
292 inline std::size_t nPress() const { return nPress_; }
293 inline std::size_t nDensity() const { return nDensity_; }
294
295 inline Scalar tempMax() const { return tempMax_; }
296 inline Scalar tempMin() const { return tempMin_; }
297
298private:
299
301 template< bool useVP = useVaporPressure, std::enable_if_t<useVP, int> = 0 >
302 void tabularizeVaporPressure_()
303 {
304 // fill the temperature-pressure arrays
305 Dumux::parallelFor(nTemp_, [=](std::size_t iT)
306 {
307 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
308 vaporPressure_[iT] = RawComponent::vaporPressure(temperature);
309 });
310 }
311
313 template< bool useVP = useVaporPressure, std::enable_if_t<!useVP, int> = 0 >
314 void tabularizeVaporPressure_() {}
315
330 template<class PropFunc, class Policy>
331 void tabularizeTPArray_(const PropFunc& f, Policy policy, std::vector<typename RawComponent::Scalar>& values) const
332 {
333 Dumux::parallelFor(nTemp_, [=,&values](std::size_t iT)
334 {
335 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
336
337 Scalar pMax = policy.maxP(iT);
338 Scalar pMin = policy.minP(iT);
339 for (std::size_t iP = 0; iP < nPress_; ++ iP)
340 {
341 Scalar pressure = iP * (pMax - pMin)/(nPress_ - 1) + pMin;
342 values[iT + iP*nTemp_] = f(temperature, pressure);
343 }
344 });
345 }
346
362 template<class RhoFunc, class Policy>
363 void tabularizeMinMaxRhoArray_(const RhoFunc& rho, Policy policy,
364 std::vector<typename RawComponent::Scalar>& rhoMin,
365 std::vector<typename RawComponent::Scalar>& rhoMax) const
366 {
367 Dumux::parallelFor(nTemp_, [=,&rhoMin,&rhoMax](std::size_t iT)
368 {
369 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
370
371 using std::min;
372 rhoMin[iT] = rho(temperature, policy.minP(iT));
373 rhoMax[iT] = rho(temperature, policy.maxP(min(iT + 1, nTemp_ - 1)));
374 });
375 }
376
387 template<class PFunc>
388 void tabularizePressureArray_(std::vector<typename RawComponent::Scalar>& pressure,
389 const PFunc& p,
390 const std::vector<typename RawComponent::Scalar>& rhoMin,
391 const std::vector<typename RawComponent::Scalar>& rhoMax) const
392 {
393 Dumux::parallelFor(nTemp_, [=,&pressure,&rhoMin,&rhoMax](std::size_t iT)
394 {
395 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
396
397 for (std::size_t iRho = 0; iRho < nDensity_; ++ iRho)
398 {
399 Scalar density = Scalar(iRho)/(nDensity_ - 1)
400 * (rhoMax[iT] - rhoMin[iT])
401 + rhoMin[iT];
402 pressure[iT + iRho*nTemp_] = p(temperature, density);
403 }
404 });
405 }
406
407 template<class RC = RawComponent>
408 bool tabularizeGasEnthalpy_()
409 {
410 if constexpr (Detail::hasGasEnthalpy<RC>())
411 {
412 const auto gasEnth = [] (auto T, auto p) { return RC::gasEnthalpy(T, p); };
413 tabularizeTPArray_(gasEnth, GasPolicy{ *this }, gasEnthalpy_);
414 return true;
415 }
416
417 return false;
418 }
419
420 template<class RC = RawComponent>
421 bool tabularizeLiquidEnthalpy_()
422 {
423 if constexpr (Detail::hasLiquidEnthalpy<RC>())
424 {
425 const auto liqEnth = [] (auto T, auto p) { return RC::liquidEnthalpy(T, p); };
426 tabularizeTPArray_(liqEnth, LiquidPolicy{ *this }, liquidEnthalpy_);
427 return true;
428 }
429
430 return false;
431 }
432
433 template<class RC = RawComponent>
434 bool tabularizeGasHeatCapacity_()
435 {
436 if constexpr (Detail::hasGasHeatCapacity<RC>())
437 {
438 const auto gasHC = [] (auto T, auto p) { return RC::gasHeatCapacity(T, p); };
439 tabularizeTPArray_(gasHC, GasPolicy{ *this }, gasHeatCapacity_);
440 return true;
441 }
442
443 return false;
444 }
445
446 template<class RC = RawComponent>
447 bool tabularizeLiquidHeatCapacity_()
448 {
449 if constexpr (Detail::hasLiquidHeatCapacity<RC>())
450 {
451 const auto liqHC = [] (auto T, auto p) { return RC::liquidHeatCapacity(T, p); };
452 tabularizeTPArray_(liqHC, LiquidPolicy{ *this }, liquidHeatCapacity_);
453 return true;
454 }
455
456 return false;
457 }
458
459 template<class RC = RawComponent>
460 bool tabularizeMinMaxGasDensity_()
461 {
462 if constexpr (Detail::hasGasDensity<RC>())
463 {
464 const auto gasRho = [] (auto T, auto p) { return RC::gasDensity(T, p); };
465 tabularizeMinMaxRhoArray_(gasRho, GasPolicy{ *this }, minGasDensity_, maxGasDensity_);
466 return true;
467 }
468
469 return false;
470 }
471
472 template<class RC = RawComponent>
473 bool tabularizeMinMaxLiquidDensity_()
474 {
475 if constexpr (Detail::hasGasEnthalpy<RC>())
476 {
477 const auto liqRho = [] (auto T, auto p) { return RC::liquidDensity(T, p); };
478 tabularizeMinMaxRhoArray_(liqRho, LiquidPolicy{ *this }, minLiquidDensity_, maxLiquidDensity_);
479 return true;
480 }
481
482 return false;
483 }
484
485 template<class RC = RawComponent>
486 bool tabularizeGasPressure_()
487 {
488 // pressure is only defined if the gas is compressible (this is usually the case)
489 if constexpr (Detail::hasGasPressure<RC>() && RC::gasIsCompressible())
490 {
491 const auto gasPFunc = [] (auto T, auto rho) { return RC::gasPressure(T, rho); };
492 tabularizePressureArray_(gasPressure_, gasPFunc, minGasDensity_, maxGasDensity_);
493 return true;
494 }
495
496 return false;
497 }
498
499 template<class RC = RawComponent>
500 bool tabularizeLiquidPressure_()
501 {
502 // pressure is only defined if the liquid is compressible (this is often not the case)
503 if constexpr (Detail::hasLiquidPressure<RC>() && RC::liquidIsCompressible())
504 {
505 const auto liqPFunc = [] (auto T, auto rho) { return RC::liquidPressure(T, rho); };
506 tabularizePressureArray_(liquidPressure_, liqPFunc, minLiquidDensity_, maxLiquidDensity_);
507 return true;
508 }
509
510 return false;
511 }
512
513 template<class RC = RawComponent>
514 bool tabularizeGasDensity_()
515 {
516 if constexpr (Detail::hasGasDensity<RC>())
517 {
518 const auto gasRho = [] (auto T, auto p) { return RC::gasDensity(T, p); };
519 tabularizeTPArray_(gasRho, GasPolicy{ *this }, gasDensity_);
520 return true;
521 }
522
523 return false;
524 }
525
526 template<class RC = RawComponent>
527 bool tabularizeLiquidDensity_()
528 {
529 if constexpr (Detail::hasLiquidDensity<RC>())
530 {
531 // TODO: we could get rid of the lambdas and pass the functor directly. But,
532 // currently Brine is a component (and not a fluid system) expecting a
533 // third argument with a default, which cannot be wrapped in a function pointer.
534 // For this reason we have to wrap this into a lambda here.
535 const auto liqRho = [] (auto T, auto p) { return RC::liquidDensity(T, p); };
536 tabularizeTPArray_(liqRho, LiquidPolicy{ *this }, liquidDensity_);
537 return true;
538 }
539
540 return false;
541 }
542
543 template<class RC = RawComponent>
544 bool tabularizeGasViscosity_()
545 {
546 if constexpr (Detail::hasGasViscosity<RC>())
547 {
548 const auto gasVisc = [] (auto T, auto p) { return RC::gasViscosity(T, p); };
549 tabularizeTPArray_(gasVisc, GasPolicy{ *this }, gasViscosity_);
550 return true;
551 }
552
553 return false;
554 }
555
556 template<class RC = RawComponent>
557 bool tabularizeLiquidViscosity_()
558 {
559 if constexpr (Detail::hasLiquidViscosity<RC>())
560 {
561 const auto liqVisc = [] (auto T, auto p) { return RC::liquidViscosity(T, p); };
562 tabularizeTPArray_(liqVisc, LiquidPolicy{ *this }, liquidViscosity_);
563 return true;
564 }
565
566 return false;
567 }
568
569 template<class RC = RawComponent>
570 bool tabularizeGasThermalConductivity_()
571 {
572 if constexpr (Detail::hasGasThermalConductivity<RC>())
573 {
574 const auto gasTC = [] (auto T, auto p) { return RC::gasThermalConductivity(T, p); };
575 tabularizeTPArray_(gasTC, GasPolicy{ *this }, gasThermalConductivity_);
576 return true;
577 }
578
579 return false;
580 }
581
582 template<class RC = RawComponent>
583 bool tabularizeLiquidThermalConductivity_()
584 {
585 if constexpr (Detail::hasLiquidThermalConductivity<RC>())
586 {
587 const auto liqTC = [] (auto T, auto p) { return RC::liquidThermalConductivity(T, p); };
588 tabularizeTPArray_(liqTC, LiquidPolicy{ *this }, liquidThermalConductivity_);
589 return true;
590 }
591
592 return false;
593 }
594
595private:
596 // 1D fields with the temperature as degree of freedom
597 std::vector<Scalar> vaporPressure_;
598
599 std::vector<Scalar> minLiquidDensity_;
600 std::vector<Scalar> maxLiquidDensity_;
601 bool minMaxLiquidDensityInitialized_;
602
603 std::vector<Scalar> minGasDensity_;
604 std::vector<Scalar> maxGasDensity_;
605 bool minMaxGasDensityInitialized_;
606
607 // 2D fields with the temperature and pressure as degrees of freedom
608 std::vector<Scalar> gasEnthalpy_;
609 std::vector<Scalar> liquidEnthalpy_;
610 bool gasEnthalpyInitialized_;
611 bool liquidEnthalpyInitialized_;
612
613 std::vector<Scalar> gasHeatCapacity_;
614 std::vector<Scalar> liquidHeatCapacity_;
615 bool gasHeatCapacityInitialized_;
616 bool liquidHeatCapacityInitialized_;
617
618 std::vector<Scalar> gasDensity_;
619 std::vector<Scalar> liquidDensity_;
620 bool gasDensityInitialized_;
621 bool liquidDensityInitialized_;
622
623 std::vector<Scalar> gasViscosity_;
624 std::vector<Scalar> liquidViscosity_;
625 bool gasViscosityInitialized_;
626 bool liquidViscosityInitialized_;
627
628 std::vector<Scalar> gasThermalConductivity_;
629 std::vector<Scalar> liquidThermalConductivity_;
630 bool gasThermalConductivityInitialized_;
631 bool liquidThermalConductivityInitialized_;
632
633 // 2D fields with the temperature and density as degrees of freedom
634 std::vector<Scalar> gasPressure_;
635 std::vector<Scalar> liquidPressure_;
636 bool gasPressureInitialized_;
637 bool liquidPressureInitialized_;
638
639 // temperature, pressure and density ranges
640 Scalar tempMin_;
641 Scalar tempMax_;
642 std::size_t nTemp_;
643
644 Scalar pressMin_;
645 Scalar pressMax_;
646 std::size_t nPress_;
647
648 Scalar densityMin_;
649 Scalar densityMax_;
650 std::size_t nDensity_;
651};
652
653} // end namespace Dumux::Components::Detail
654
655namespace Dumux::Components {
656
670template <class RawComponent, bool useVaporPressure=true>
672{
675
676 struct InterpolatePolicy
677 {
678 using Scalar = typename RawComponent::Scalar;
679
680 const Table& table;
681
682 Scalar tempIdx(Scalar T) const { return table.tempIdx(T); }
683 Scalar tempMin() const { return table.tempMin(); }
684 Scalar tempMax() const { return table.tempMax(); }
685 std::size_t nTemp() const { return table.nTemp(); }
686 std::size_t nPress() const { return table.nPress(); }
687 std::size_t nDensity() const { return table.nDensity(); }
688 };
689
690 struct InterpolateGasPolicy : public InterpolatePolicy
691 {
692 using Scalar = typename RawComponent::Scalar;
693 Scalar pressIdx(Scalar p, std::size_t tempIdx) const { return this->table.pressGasIdx(p, tempIdx); }
694 Scalar rhoIdx(Scalar rho, std::size_t tempIdx) const { return this->table.densityGasIdx(rho, tempIdx); }
695 Scalar minP(int tempIdx) const { return this->table.minGasPressure(tempIdx); }
696 Scalar maxP(int tempIdx) const { return this->table.maxGasPressure(tempIdx); }
697 Scalar minRho(int tempIdx) const { return this->table.minGasDensity(tempIdx); }
698 Scalar maxRho(int tempIdx) const { return this->table.maxGasDensity(tempIdx); }
699 };
700
701 struct InterpolateLiquidPolicy : public InterpolatePolicy
702 {
703 using Scalar = typename RawComponent::Scalar;
704 Scalar pressIdx(Scalar p, std::size_t tempIdx) const { return this->table.pressLiquidIdx(p, tempIdx); }
705 Scalar rhoIdx(Scalar rho, std::size_t tempIdx) const { return this->table.densityLiquidIdx(rho, tempIdx); }
706 Scalar minP(int tempIdx) const { return this->table.minLiquidPressure(tempIdx); }
707 Scalar maxP(int tempIdx) const { return this->table.maxLiquidPressure(tempIdx); }
708 Scalar minRho(int tempIdx) const { return this->table.minLiquidDensity(tempIdx); }
709 Scalar maxRho(int tempIdx) const { return this->table.maxLiquidDensity(tempIdx); }
710 };
711public:
713 using Scalar = typename RawComponent::Scalar;
714
716 static constexpr bool isTabulated = true;
717
728 static void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp,
729 Scalar pressMin, Scalar pressMax, std::size_t nPress)
730 {
731#ifndef NDEBUG
732 warningPrinted_ = false;
733#endif
734 std::cout << "-------------------------------------------------------------------------\n"
735 << "Initializing tables for the " << RawComponent::name()
736 << " fluid properties (" << nTemp*nPress << " entries).\n"
737 << "Temperature -> min: " << std::scientific << std::setprecision(3)
738 << tempMin << ", max: " << tempMax << ", n: " << nTemp << '\n'
739 << "Pressure -> min: " << std::scientific << std::setprecision(3)
740 << pressMin << ", max: " << pressMax << ", n: " << nPress << '\n'
741 << "-------------------------------------------------------------------------" << std::endl;
742
743 table().init(tempMin, tempMax, nTemp, pressMin, pressMax, nPress);
744
745 initialized_ = true;
746 }
747
751 static std::string name()
752 { return RawComponent::name(); }
753
757 static constexpr Scalar molarMass()
758 { return RawComponent::molarMass(); }
759
764 { return RawComponent::criticalTemperature(); }
765
770 { return RawComponent::criticalPressure(); }
771
776 { return RawComponent::tripleTemperature(); }
777
782 { return RawComponent::triplePressure(); }
783
791 {
792 using std::isnan;
793 Scalar result = interpolateT_(table().vaporPressure_, T, InterpolatePolicy{{ table() }});
794 if (isnan(result))
795 return RawComponent::vaporPressure(T);
796 return result;
797 }
798
807 {
808 return RawComponent::vaporTemperature(pressure);
809 }
810
818 {
819 Scalar result = interpolateTP_(table().gasEnthalpy_, temperature, pressure, InterpolateGasPolicy{{ table() }});
820 using std::isnan;
821 if (isnan(result))
822 {
823 printWarningTP_("gasEnthalpy", temperature, pressure, InterpolateGasPolicy{{ table() }});
824 return RawComponent::gasEnthalpy(temperature, pressure);
825 }
826 return result;
827 }
828
836 {
837 Scalar result = interpolateTP_(table().liquidEnthalpy_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
838 using std::isnan;
839 if (isnan(result))
840 {
841 printWarningTP_("liquidEnthalpy", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
842 return RawComponent::liquidEnthalpy(temperature, pressure);
843 }
844 return result;
845 }
846
854 {
855 Scalar result = interpolateTP_(table().gasHeatCapacity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
856 using std::isnan;
857 if (isnan(result))
858 {
859 printWarningTP_("gasHeatCapacity", temperature, pressure, InterpolateGasPolicy{{ table() }});
860 return RawComponent::gasHeatCapacity(temperature, pressure);
861 }
862 return result;
863 }
864
872 {
873 Scalar result = interpolateTP_(table().liquidHeatCapacity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
874 using std::isnan;
875 if (isnan(result))
876 {
877 printWarningTP_("liquidHeatCapacity", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
878 return RawComponent::liquidHeatCapacity(temperature, pressure);
879 }
880 return result;
881 }
882
890 {
892 }
893
901 {
903 }
904
912 {
913 Scalar result = interpolateTRho_(table().gasPressure_, temperature, density, InterpolateGasPolicy{{ table() }});
914 using std::isnan;
915 if (isnan(result))
916 {
917 printWarningTRho_("gasPressure", temperature, density, InterpolateGasPolicy{{ table() }});
918 return RawComponent::gasPressure(temperature, density);
919 }
920 return result;
921 }
922
930 {
931 Scalar result = interpolateTRho_(table().liquidPressure_, temperature, density, InterpolateLiquidPolicy{{ table() }});
932 using std::isnan;
933 if (isnan(result))
934 {
935 printWarningTRho_("liquidPressure", temperature, density, InterpolateLiquidPolicy{{ table() }});
936 return RawComponent::liquidPressure(temperature, density);
937 }
938 return result;
939 }
940
944 static constexpr bool gasIsCompressible()
945 { return RawComponent::gasIsCompressible(); }
946
950 static constexpr bool liquidIsCompressible()
951 { return RawComponent::liquidIsCompressible(); }
952
956 static constexpr bool gasIsIdeal()
957 { return RawComponent::gasIsIdeal(); }
958
959
968 {
969 Scalar result = interpolateTP_(table().gasDensity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
970 using std::isnan;
971 if (isnan(result))
972 {
973 printWarningTP_("gasDensity", temperature, pressure, InterpolateGasPolicy{{ table() }});
974 return RawComponent::gasDensity(temperature, pressure);
975 }
976 return result;
977 }
978
989
998 {
999 Scalar result = interpolateTP_(table().liquidDensity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1000 using std::isnan;
1001 if (isnan(result))
1002 {
1003 printWarningTP_("liquidDensity", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1004 return RawComponent::liquidDensity(temperature, pressure);
1005 }
1006
1007 return result;
1008 }
1009
1020
1028 {
1029 Scalar result = interpolateTP_(table().gasViscosity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
1030 using std::isnan;
1031 if (isnan(result))
1032 {
1033 printWarningTP_("gasViscosity", temperature, pressure, InterpolateGasPolicy{{ table() }});
1034 return RawComponent::gasViscosity(temperature, pressure);
1035 }
1036 return result;
1037 }
1038
1046 {
1047 Scalar result = interpolateTP_(table().liquidViscosity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1048 using std::isnan;
1049 if (isnan(result))
1050 {
1051 printWarningTP_("liquidViscosity",temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1052 return RawComponent::liquidViscosity(temperature, pressure);
1053 }
1054 return result;
1055 }
1056
1064 {
1065 Scalar result = interpolateTP_(table().gasThermalConductivity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
1066 using std::isnan;
1067 if (isnan(result))
1068 {
1069 printWarningTP_("gasThermalConductivity", temperature, pressure, InterpolateGasPolicy{{ table() }});
1070 return RawComponent::gasThermalConductivity(temperature, pressure);
1071 }
1072 return result;
1073 }
1074
1082 {
1083 Scalar result = interpolateTP_(table().liquidThermalConductivity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1084 using std::isnan;
1085 if (isnan(result))
1086 {
1087 printWarningTP_("liquidThermalConductivity", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1088 return RawComponent::liquidThermalConductivity(temperature, pressure);
1089 }
1090 return result;
1091 }
1092
1093
1094private:
1096 template<class Policy>
1097 static void printWarningTP_(const std::string& quantity, Scalar T, Scalar p, Policy policy)
1098 {
1099#ifndef NDEBUG
1100 if (warningPrinted_)
1101 return;
1102
1103 if (!initialized_)
1104 std::cerr << "Warning: tabulated component '" << name()
1105 << "' has not been initialized. "
1106 << "Call FluidSystem::init() to use the tabulation in order to reduce runtime. \n";
1107 else
1108 std::cerr << "Warning: "<<quantity<<"(T="<<T<<", p="<<p<<") of component '"<<name()
1109 << "' is outside tabulation range: ("<< policy.tempMin() <<"<=T<="<< policy.tempMax() <<"), ("
1110 << policy.minP(0) <<"<=p<=" << policy.maxP(policy.nTemp()-1) <<"). "
1111 << "Forwarded to FluidSystem for direct evaluation of "<<quantity<<". \n";
1112 warningPrinted_ = true;
1113#endif
1114 }
1115
1117 template<class Policy>
1118 static void printWarningTRho_(const std::string& quantity, Scalar T, Scalar rho, Policy policy)
1119 {
1120#ifndef NDEBUG
1121 if (warningPrinted_)
1122 return;
1123
1124 if (!initialized_)
1125 std::cerr << "Warning: tabulated component '" << name()
1126 << "' has not been initialized. "
1127 << "Call FluidSystem::init() to use the tabulation in order to reduce runtime. \n";
1128 else
1129 {
1130 const auto [densityMin, densityMax] = [&]
1131 {
1132 const Scalar alphaT = policy.tempIdx(T);
1133 using std::clamp;
1134 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, policy.nTemp() - 2);
1135 return std::make_pair( policy.minRho(iT), policy.maxRho(iT) );
1136 }();
1137
1138 std::cerr << "Warning: "<<quantity<<"(T="<<T<<", density="<<rho<<") of component '"<<name()
1139 << "' is outside tabulation range: ("<< policy.tempMin() <<"<=T<="<< policy.tempMax() <<"), ("
1140 << densityMin <<"<=density<=" << densityMax <<"). "
1141 << "Forwarded to FluidSystem for direct evaluation of "<<quantity<<". \n";
1142 }
1143 warningPrinted_ = true;
1144#endif
1145 }
1146
1148 template<class Policy>
1149 static Scalar interpolateT_(const std::vector<Scalar>& values, Scalar T, Policy policy)
1150 {
1151 Scalar alphaT = policy.tempIdx(T);
1152 const auto nTemp = policy.nTemp();
1153 if (alphaT < 0 - 1e-7*nTemp || alphaT >= nTemp - 1 + 1e-7*nTemp)
1154 return std::numeric_limits<Scalar>::quiet_NaN();
1155
1156 using std::clamp;
1157 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, nTemp - 2);
1158 alphaT -= iT;
1159
1160 return values[iT ]*(1 - alphaT) +
1161 values[iT + 1]*( alphaT);
1162 }
1163
1165 template<class Policy>
1166 static Scalar interpolateTP_(const std::vector<Scalar>& values, const Scalar T, const Scalar p, Policy policy)
1167 {
1168 const auto nTemp = policy.nTemp();
1169 const auto nPress = policy.nPress();
1170
1171 Scalar alphaT = policy.tempIdx(T);
1172 if (alphaT < 0 - 1e-7*nTemp || alphaT >= nTemp - 1 + 1e-7*nTemp)
1173 return std::numeric_limits<Scalar>::quiet_NaN();
1174
1175 using std::clamp;
1176 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, nTemp - 2);
1177 alphaT -= iT;
1178
1179 Scalar alphaP1 = policy.pressIdx(p, iT);
1180 Scalar alphaP2 = policy.pressIdx(p, iT + 1);
1181
1182 const auto iP1 = clamp<int>(static_cast<int>(alphaP1), 0, nPress - 2);
1183 const auto iP2 = clamp<int>(static_cast<int>(alphaP2), 0, nPress - 2);
1184 alphaP1 -= iP1;
1185 alphaP2 -= iP2;
1186
1187#if 0 && !defined NDEBUG
1188 const auto tempMin = policy.tempMin();
1189 const auto tempMin = policy.tempMax();
1190 if(!(0 <= alphaT && alphaT <= 1.0))
1191 DUNE_THROW(NumericalProblem, "Temperature out of range: "
1192 << "T=" << T << " range: [" << tempMin_ << ", " << tempMax_ << "]");
1193 if(!(0 <= alphaP1 && alphaP1 <= 1.0))
1194 DUNE_THROW(NumericalProblem, "First pressure out of range: "
1195 << "p=" << p << " range: [" << policy.minP(policy.tempIdx(T)) << ", " << policy.maxP(policy.tempIdx(T)) << "]");
1196 if(!(0 <= alphaP2 && alphaP2 <= 1.0))
1197 DUNE_THROW(NumericalProblem, "Second pressure out of range: "
1198 << "p=" << p << " range: [" << policy.minP(policy.tempIdx(T) + 1) << ", " << policy.maxP(policy.tempIdx(T) + 1) << "]");
1199#endif
1200 return values[(iT ) + (iP1 )*nTemp]*(1 - alphaT)*(1 - alphaP1) +
1201 values[(iT ) + (iP1 + 1)*nTemp]*(1 - alphaT)*( alphaP1) +
1202 values[(iT + 1) + (iP2 )*nTemp]*( alphaT)*(1 - alphaP2) +
1203 values[(iT + 1) + (iP2 + 1)*nTemp]*( alphaT)*( alphaP2);
1204 }
1205
1207 template<class Policy>
1208 static Scalar interpolateTRho_(const std::vector<Scalar>& values, const Scalar T, const Scalar rho, Policy policy)
1209 {
1210 const auto nTemp = policy.nTemp();
1211 const auto nDensity = policy.nDensity();
1212
1213 using std::clamp;
1214 Scalar alphaT = policy.tempIdx(T);
1215 if (alphaT < 0 - 1e-7*nTemp || alphaT >= nTemp - 1 + 1e-7*nTemp)
1216 return std::numeric_limits<Scalar>::quiet_NaN();
1217
1218 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, nTemp - 2);
1219 alphaT -= iT;
1220
1221 Scalar alphaP1 = policy.rhoIdx(rho, iT);
1222 Scalar alphaP2 = policy.rhoIdx(rho, iT + 1);
1223 const auto iP1 = clamp<int>(static_cast<int>(alphaP1), 0, nDensity - 2);
1224 const auto iP2 = clamp<int>(static_cast<int>(alphaP2), 0, nDensity - 2);
1225 alphaP1 -= iP1;
1226 alphaP2 -= iP2;
1227
1228 return values[(iT ) + (iP1 )*nTemp]*(1 - alphaT)*(1 - alphaP1) +
1229 values[(iT ) + (iP1 + 1)*nTemp]*(1 - alphaT)*( alphaP1) +
1230 values[(iT + 1) + (iP2 )*nTemp]*( alphaT)*(1 - alphaP2) +
1231 values[(iT + 1) + (iP2 + 1)*nTemp]*( alphaT)*( alphaP2);
1232 }
1233
1234 // specifies whether the table was initialized
1235 static bool initialized_;
1236
1237#ifndef NDEBUG
1238 // specifies whether some warning was printed
1239 static bool warningPrinted_;
1240#endif
1241
1242 static Table& table()
1243 {
1244 static Table t;
1245 return t;
1246 }
1247};
1248
1249template <class RawComponent, bool useVaporPressure>
1250bool TabulatedComponent<RawComponent, useVaporPressure>::initialized_ = false;
1251
1252#ifndef NDEBUG
1253template <class RawComponent, bool useVaporPressure>
1254bool TabulatedComponent<RawComponent, useVaporPressure>::warningPrinted_ = false;
1255#endif
1256
1257// forward declaration
1258template <class Component>
1259struct IsAqueous;
1260
1261// we are aqueous if the raw compont is so
1262template <class RawComponent, bool useVaporPressure>
1263struct IsAqueous<TabulatedComponent<RawComponent, useVaporPressure>> : public IsAqueous<RawComponent> {};
1264
1265} // end namespace Dumux::Components
1266
1267#endif
Definition: tabulatedcomponent.hh:112
std::size_t nPress() const
Definition: tabulatedcomponent.hh:292
Scalar tempIdx(Scalar temperature) const
returns the index of an entry in a temperature field
Definition: tabulatedcomponent.hh:198
Scalar densityLiquidIdx(Scalar density, std::size_t tempIdx) const
returns the index of an entry in a density field
Definition: tabulatedcomponent.hh:220
void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp, Scalar pressMin, Scalar pressMax, std::size_t nPress)
Definition: tabulatedcomponent.hh:130
Scalar pressGasIdx(Scalar pressure, std::size_t tempIdx) const
returns the index of an entry in a temperature field
Definition: tabulatedcomponent.hh:212
Scalar minLiquidPressure(int tempIdx) const
returns the minimum tabularized liquid pressure at a given temperature index
Definition: tabulatedcomponent.hh:236
Scalar densityGasIdx(Scalar density, std::size_t tempIdx) const
returns the index of an entry in a density field
Definition: tabulatedcomponent.hh:228
Scalar maxGasPressure(int tempIdx) const
returns the maximum tabularized gas pressure at a given temperature index
Definition: tabulatedcomponent.hh:266
Scalar minGasDensity(int tempIdx) const
returns the minimum tabularized gas density at a given temperature index
Definition: tabulatedcomponent.hh:284
Scalar maxLiquidDensity(int tempIdx) const
returns the maximum tabularized liquid density at a given temperature index
Definition: tabulatedcomponent.hh:280
Scalar maxGasDensity(int tempIdx) const
returns the maximum tabularized gas density at a given temperature index
Definition: tabulatedcomponent.hh:288
Scalar tempMin() const
Definition: tabulatedcomponent.hh:296
Scalar maxLiquidPressure(int tempIdx) const
returns the maximum tabularized liquid pressure at a given temperature index
Definition: tabulatedcomponent.hh:246
Scalar pressLiquidIdx(Scalar pressure, std::size_t tempIdx) const
returns the index of an entry in a pressure field
Definition: tabulatedcomponent.hh:204
Scalar tempMax() const
Definition: tabulatedcomponent.hh:295
std::size_t nDensity() const
Definition: tabulatedcomponent.hh:293
Scalar minLiquidDensity(int tempIdx) const
returns the minimum tabularized liquid density at a given temperature index
Definition: tabulatedcomponent.hh:276
std::size_t nTemp() const
Definition: tabulatedcomponent.hh:291
Scalar minGasPressure(int tempIdx) const
returns the minimum tabularized gas pressure at a given temperature index
Definition: tabulatedcomponent.hh:256
Tabulates all thermodynamic properties of a given component.
Definition: tabulatedcomponent.hh:672
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the gas .
Definition: tabulatedcomponent.hh:817
static Scalar gasPressure(Scalar temperature, Scalar density)
The pressure of gas in at a given density and temperature.
Definition: tabulatedcomponent.hh:911
static Scalar criticalTemperature()
Returns the critical temperature in of the component.
Definition: tabulatedcomponent.hh:763
static Scalar liquidPressure(Scalar temperature, Scalar density)
The pressure of liquid in at a given density and temperature.
Definition: tabulatedcomponent.hh:929
static const Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the gas .
Definition: tabulatedcomponent.hh:853
static std::string name()
A human readable name for the component.
Definition: tabulatedcomponent.hh:751
static Scalar vaporTemperature(Scalar pressure)
The vapor pressure in of the component at a given temperature.
Definition: tabulatedcomponent.hh:806
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of liquid water .
Definition: tabulatedcomponent.hh:1081
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of gas at a given pressure and temperature .
Definition: tabulatedcomponent.hh:967
static const Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the liquid .
Definition: tabulatedcomponent.hh:835
static Scalar triplePressure()
Returns the pressure in at the component's triple point.
Definition: tabulatedcomponent.hh:781
static Scalar criticalPressure()
Returns the critical pressure in of the component.
Definition: tabulatedcomponent.hh:769
static const Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the gas .
Definition: tabulatedcomponent.hh:889
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density of liquid in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:1018
static constexpr Scalar molarMass()
The molar mass in of the component.
Definition: tabulatedcomponent.hh:757
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of liquid.
Definition: tabulatedcomponent.hh:1045
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of gas.
Definition: tabulatedcomponent.hh:1027
static Scalar tripleTemperature()
Returns the temperature in at the component's triple point.
Definition: tabulatedcomponent.hh:775
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition: tabulatedcomponent.hh:950
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
The density of liquid at a given pressure and temperature .
Definition: tabulatedcomponent.hh:997
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of gaseous water .
Definition: tabulatedcomponent.hh:1063
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of gas in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:987
static constexpr bool isTabulated
state that we are tabulated
Definition: tabulatedcomponent.hh:716
static const Scalar liquidInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the liquid .
Definition: tabulatedcomponent.hh:900
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the component at a given temperature.
Definition: tabulatedcomponent.hh:790
static constexpr bool gasIsCompressible()
Returns true if the gas phase is assumed to be compressible.
Definition: tabulatedcomponent.hh:944
static void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp, Scalar pressMin, Scalar pressMax, std::size_t nPress)
Initialize the tables.
Definition: tabulatedcomponent.hh:728
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: tabulatedcomponent.hh:956
static const Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the liquid .
Definition: tabulatedcomponent.hh:871
typename RawComponent::Scalar Scalar
export scalar type
Definition: tabulatedcomponent.hh:713
Type traits.
Component traits, i.e. information extracted from components.
Some exceptions thrown in DuMux
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:160
Multithreading in Dumux.
Definition: tabulatedcomponent.hh:60
decltype(C::template gasThermalConductivity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasThermalCond
Definition: tabulatedcomponent.hh:79
constexpr bool hasGasEnthalpy()
Definition: tabulatedcomponent.hh:97
constexpr bool hasGasHeatCapacity()
Definition: tabulatedcomponent.hh:103
decltype(C::template liquidEnthalpy< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidEnthalpy
Definition: tabulatedcomponent.hh:70
decltype(C::template gasViscosity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasViscosity
Definition: tabulatedcomponent.hh:81
decltype(C::template gasDensity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasDensity
Definition: tabulatedcomponent.hh:78
decltype(C::template liquidHeatCapacity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidHeatCapacity
Definition: tabulatedcomponent.hh:73
decltype(C::gasPressure(0.0, 0.0)) CompHasGasPressure
Definition: tabulatedcomponent.hh:82
constexpr bool hasLiquidThermalConductivity()
Definition: tabulatedcomponent.hh:88
constexpr bool hasGasViscosity()
Definition: tabulatedcomponent.hh:105
constexpr bool hasLiquidPressure()
Definition: tabulatedcomponent.hh:94
constexpr bool hasLiquidEnthalpy()
Definition: tabulatedcomponent.hh:84
decltype(C::template gasEnthalpy< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasEnthalpy
Definition: tabulatedcomponent.hh:77
constexpr bool hasGasDensity()
Definition: tabulatedcomponent.hh:99
decltype(C::liquidPressure(0.0, 0.0)) CompHasLiquidPressure
Definition: tabulatedcomponent.hh:75
constexpr bool hasGasThermalConductivity()
Definition: tabulatedcomponent.hh:101
constexpr bool hasLiquidViscosity()
Definition: tabulatedcomponent.hh:92
constexpr bool hasGasPressure()
Definition: tabulatedcomponent.hh:107
decltype(C::template liquidThermalConductivity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidThermalCond
Definition: tabulatedcomponent.hh:72
constexpr bool hasLiquidHeatCapacity()
Definition: tabulatedcomponent.hh:90
constexpr bool hasLiquidDensity()
Definition: tabulatedcomponent.hh:86
decltype(C::template gasHeatCapacity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasHeatCapacity
Definition: tabulatedcomponent.hh:80
decltype(C::template liquidDensity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidDensity
Definition: tabulatedcomponent.hh:71
decltype(C::template liquidViscosity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidViscosity
Definition: tabulatedcomponent.hh:74
Definition: air.hh:23
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:39
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:22
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:53
Definition: adapt.hh:17
Parallel for loop (multithreading)
Template which always yields a false value.
Definition: common/typetraits/typetraits.hh:24
typename RawComponent::Scalar Scalar
Definition: tabulatedcomponent.hh:47
Component traits, i.e. information extracted from components.
Definition: componenttraits.hh:31
static constexpr bool hasLiquidState
if the component implements a liquid state
Definition: componenttraits.hh:38
static constexpr bool hasSolidState
if the component implements a solid state
Definition: componenttraits.hh:35
static constexpr bool hasGasState
if the component implements a gaseous state
Definition: componenttraits.hh:41
Definition: tabulatedcomponent.hh:61
IsAqueous struct.
Definition: components/base.hh:35