3.6-git
DUNE for Multi-{Phase, Component, Scale, Physics, ...} flow and transport in porous media
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 * See the file COPYING for full copying permissions. *
5 * *
6 * This program is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation, either version 3 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 *****************************************************************************/
28#ifndef DUMUX_TABULATED_COMPONENT_HH
29#define DUMUX_TABULATED_COMPONENT_HH
30
31#include <cmath>
32#include <limits>
33#include <cassert>
34#include <vector>
35#include <iostream>
36#include <iomanip>
37#include <algorithm>
38
39#include <dune/common/std/type_traits.hh>
40
46
47namespace Dumux::Components {
48// forward declaration
49template<class RawComponent, bool useVaporPressure>
50class TabulatedComponent;
51} // end namespace Dumux::Components
52
53namespace Dumux {
54
56template<class RawComponent, bool useVaporPressure>
57struct ComponentTraits<Components::TabulatedComponent<RawComponent, useVaporPressure>>
58{
59 using Scalar = typename RawComponent::Scalar;
60
62 static constexpr bool hasSolidState = std::is_base_of<Components::Solid<Scalar, RawComponent>, RawComponent>::value;
63
65 static constexpr bool hasLiquidState = std::is_base_of<Components::Liquid<Scalar, RawComponent>, RawComponent>::value;
66
68 static constexpr bool hasGasState = std::is_base_of<Components::Gas<Scalar, RawComponent>, RawComponent>::value;
69};
70} // end namespace Dumux
71
74} // end namespace Dumux::Components::Detail
75
76namespace Dumux {
77template<> struct AlwaysFalse<Components::Detail::DisableStaticAssert> : public std::true_type {};
78}// end namespace Dumux
79
81
82template<class C> using CompHasNoLiquidEnthalpy = decltype(C::template liquidEnthalpy<DisableStaticAssert>(0.0, 0.0));
83template<class C> using CompHasNoLiquidDensity = decltype(C::template liquidDensity<DisableStaticAssert>(0.0, 0.0));
84template<class C> using CompHasNoLiquidThermalCond = decltype(C::template liquidThermalConductivity<DisableStaticAssert>(0.0, 0.0));
85template<class C> using CompHasNoLiquidHeatCapacity = decltype(C::template liquidHeatCapacity<DisableStaticAssert>(0.0, 0.0));
86template<class C> using CompHasNoLiquidViscosity = decltype(C::template liquidViscosity<DisableStaticAssert>(0.0, 0.0));
87template<class C> using CompHasLiquidPressure = decltype(C::liquidPressure(0.0, 0.0));
88
89template<class C> using CompHasNoGasEnthalpy = decltype(C::template gasEnthalpy<DisableStaticAssert>(0.0, 0.0));
90template<class C> using CompHasNoGasDensity = decltype(C::template gasDensity<DisableStaticAssert>(0.0, 0.0));
91template<class C> using CompHasNoGasThermalCond = decltype(C::template gasThermalConductivity<DisableStaticAssert>(0.0, 0.0));
92template<class C> using CompHasNoGasHeatCapacity = decltype(C::template gasHeatCapacity<DisableStaticAssert>(0.0, 0.0));
93template<class C> using CompHasNoGasViscosity = decltype(C::template gasViscosity<DisableStaticAssert>(0.0, 0.0));
94template<class C> using CompHasGasPressure = decltype(C::gasPressure(0.0, 0.0));
95
96template<class C> constexpr inline bool hasLiquidEnthalpy()
97{ return !Dune::Std::is_detected<CompHasNoLiquidEnthalpy, C>::value && ComponentTraits<C>::hasLiquidState; }
98template<class C> constexpr inline bool hasLiquidDensity()
99{ return !Dune::Std::is_detected<CompHasNoLiquidDensity, C>::value && ComponentTraits<C>::hasLiquidState; }
100template<class C> constexpr inline bool hasLiquidThermalConductivity()
101{ return !Dune::Std::is_detected<CompHasNoLiquidThermalCond, C>::value && ComponentTraits<C>::hasLiquidState; }
102template<class C> constexpr inline bool hasLiquidHeatCapacity()
103{ return !Dune::Std::is_detected<CompHasNoLiquidHeatCapacity, C>::value && ComponentTraits<C>::hasLiquidState; }
104template<class C> constexpr inline bool hasLiquidViscosity()
105{ return !Dune::Std::is_detected<CompHasNoLiquidViscosity, C>::value && ComponentTraits<C>::hasLiquidState; }
106template<class C> constexpr inline bool hasLiquidPressure()
107{ return Dune::Std::is_detected<CompHasLiquidPressure, C>::value && ComponentTraits<C>::hasLiquidState; }
108
109template<class C> constexpr inline bool hasGasEnthalpy()
110{ return !Dune::Std::is_detected<CompHasNoGasEnthalpy, C>::value && ComponentTraits<C>::hasGasState; }
111template<class C> constexpr inline bool hasGasDensity()
112{ return !Dune::Std::is_detected<CompHasNoGasDensity, C>::value && ComponentTraits<C>::hasGasState; }
113template<class C> constexpr inline bool hasGasThermalConductivity()
114{ return !Dune::Std::is_detected<CompHasNoGasThermalCond, C>::value && ComponentTraits<C>::hasGasState; }
115template<class C> constexpr inline bool hasGasHeatCapacity()
116{ return !Dune::Std::is_detected<CompHasNoGasHeatCapacity, C>::value && ComponentTraits<C>::hasGasState; }
117template<class C> constexpr inline bool hasGasViscosity()
118{ return !Dune::Std::is_detected<CompHasNoGasViscosity, C>::value && ComponentTraits<C>::hasGasState; }
119template<class C> constexpr inline bool hasGasPressure()
120{ return Dune::Std::is_detected<CompHasGasPressure, C>::value && ComponentTraits<C>::hasGasState; }
121
122template<class RawComponent, bool useVaporPressure = true>
124{
125 using Scalar = typename RawComponent::Scalar;
126 friend class TabulatedComponent<RawComponent, useVaporPressure>;
127
128 struct GasPolicy
129 {
130 Scalar minP(std::size_t iT) const { return table.minGasPressure(iT); }
131 Scalar maxP(std::size_t iT) const { return table.maxGasPressure(iT); }
133 };
134
135 struct LiquidPolicy
136 {
137 Scalar minP(std::size_t iT) const { return table.minLiquidPressure(iT); }
138 Scalar maxP(std::size_t iT) const { return table.maxLiquidPressure(iT); }
140 };
141public:
142 void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp,
143 Scalar pressMin, Scalar pressMax, std::size_t nPress)
144 {
145 tempMin_ = tempMin;
146 tempMax_ = tempMax;
147 nTemp_ = nTemp;
148 pressMin_ = pressMin;
149 pressMax_ = pressMax;
150 nPress_ = nPress;
151 nDensity_ = nPress;
152
153 // resize & initialize the arrays with NaN
154 assert(std::numeric_limits<Scalar>::has_quiet_NaN);
155 const auto NaN = std::numeric_limits<Scalar>::quiet_NaN();
156
157 // initialize vapor pressure array depending on useVaporPressure
158 vaporPressure_.resize(nTemp_, NaN);
159 tabularizeVaporPressure_();
160
162 {
163 minGasDensity_.resize(nTemp_, NaN);
164 maxGasDensity_.resize(nTemp_, NaN);
165 const std::size_t numEntriesTp = nTemp_*nPress_;
166 gasEnthalpy_.resize(numEntriesTp, NaN);
167 gasHeatCapacity_.resize(numEntriesTp, NaN);
168 gasDensity_.resize(numEntriesTp, NaN);
169 gasViscosity_.resize(numEntriesTp, NaN);
170 gasThermalConductivity_.resize(numEntriesTp, NaN);
171
172 if constexpr (RawComponent::gasIsCompressible())
173 gasPressure_.resize(numEntriesTp, NaN);
174
175 minMaxGasDensityInitialized_ = tabularizeMinMaxGasDensity_();
176 gasPressureInitialized_ = tabularizeGasPressure_();
177 gasEnthalpyInitialized_ = tabularizeGasEnthalpy_();
178 gasHeatCapacityInitialized_ = tabularizeGasHeatCapacity_();
179 gasDensityInitialized_ = tabularizeGasDensity_();
180 gasViscosityInitialized_ = tabularizeGasViscosity_();
181 gasThermalConductivityInitialized_ = tabularizeGasThermalConductivity_();
182 }
183
185 {
186 minLiquidDensity_.resize(nTemp_, NaN);
187 maxLiquidDensity_.resize(nTemp_, NaN);
188
189 const std::size_t numEntriesTp = nTemp_*nPress_;
190 liquidEnthalpy_.resize(numEntriesTp, NaN);
191 liquidHeatCapacity_.resize(numEntriesTp, NaN);
192 liquidDensity_.resize(numEntriesTp, NaN);
193 liquidViscosity_.resize(numEntriesTp, NaN);
194 liquidThermalConductivity_.resize(numEntriesTp, NaN);
195
196 if constexpr (RawComponent::liquidIsCompressible())
197 liquidPressure_.resize(numEntriesTp, NaN);
198
199 minMaxLiquidDensityInitialized_ = tabularizeMinMaxLiquidDensity_();
200 liquidPressureInitialized_ = tabularizeLiquidPressure_();
201 liquidEnthalpyInitialized_ = tabularizeLiquidEnthalpy_();
202 liquidHeatCapacityInitialized_ = tabularizeLiquidHeatCapacity_();
203 liquidDensityInitialized_ = tabularizeLiquidDensity_();
204 liquidViscosityInitialized_ = tabularizeLiquidViscosity_();
205 liquidThermalConductivityInitialized_ = tabularizeLiquidThermalConductivity_();
206 }
207 }
208
210 inline Scalar tempIdx(Scalar temperature) const
211 {
212 return (nTemp_ - 1)*(temperature - tempMin_)/(tempMax_ - tempMin_);
213 }
214
216 inline Scalar pressLiquidIdx(Scalar pressure, std::size_t tempIdx) const
217 {
218 const Scalar plMin = minLiquidPressure(tempIdx);
219 const Scalar plMax = maxLiquidPressure(tempIdx);
220 return (nPress_ - 1)*(pressure - plMin)/(plMax - plMin);
221 }
222
224 inline Scalar pressGasIdx(Scalar pressure, std::size_t tempIdx) const
225 {
226 const Scalar pgMin = minGasPressure(tempIdx);
227 const Scalar pgMax = maxGasPressure(tempIdx);
228 return (nPress_ - 1)*(pressure - pgMin)/(pgMax - pgMin);
229 }
230
232 inline Scalar densityLiquidIdx(Scalar density, std::size_t tempIdx) const
233 {
234 const Scalar densityMin = minLiquidDensity_[tempIdx];
235 const Scalar densityMax = maxLiquidDensity_[tempIdx];
236 return (nDensity_ - 1) * (density - densityMin)/(densityMax - densityMin);
237 }
238
240 inline Scalar densityGasIdx(Scalar density, std::size_t tempIdx) const
241 {
242 const Scalar densityMin = minGasDensity_[tempIdx];
243 const Scalar densityMax = maxGasDensity_[tempIdx];
244 return (nDensity_ - 1) * (density - densityMin)/(densityMax - densityMin);
245 }
246
248 inline Scalar minLiquidPressure(int tempIdx) const
249 {
250 using std::max;
251 if (!useVaporPressure)
252 return pressMin_;
253 else
254 return max(pressMin_, vaporPressure_[tempIdx] / 1.1);
255 }
256
258 inline Scalar maxLiquidPressure(int tempIdx) const
259 {
260 using std::max;
261 if (!useVaporPressure)
262 return pressMax_;
263 else
264 return max(pressMax_, vaporPressure_[tempIdx] * 1.1);
265 }
266
268 inline Scalar minGasPressure(int tempIdx) const
269 {
270 using std::min;
271 if (!useVaporPressure)
272 return pressMin_;
273 else
274 return min(pressMin_, vaporPressure_[tempIdx] / 1.1 );
275 }
276
278 inline Scalar maxGasPressure(int tempIdx) const
279 {
280 using std::min;
281 if (!useVaporPressure)
282 return pressMax_;
283 else
284 return min(pressMax_, vaporPressure_[tempIdx] * 1.1);
285 }
286
288 inline Scalar minLiquidDensity(int tempIdx) const
289 { return minLiquidDensity_[tempIdx]; }
290
292 inline Scalar maxLiquidDensity(int tempIdx) const
293 { return maxLiquidDensity_[tempIdx]; }
294
296 inline Scalar minGasDensity(int tempIdx) const
297 { return minGasDensity_[tempIdx]; }
298
300 inline Scalar maxGasDensity(int tempIdx) const
301 { return maxGasDensity_[tempIdx]; }
302
303 inline std::size_t nTemp() const { return nTemp_; }
304 inline std::size_t nPress() const { return nPress_; }
305 inline std::size_t nDensity() const { return nDensity_; }
306
307 inline Scalar tempMax() const { return tempMax_; }
308 inline Scalar tempMin() const { return tempMin_; }
309
310private:
311
313 template< bool useVP = useVaporPressure, std::enable_if_t<useVP, int> = 0 >
314 void tabularizeVaporPressure_()
315 {
316 // fill the temperature-pressure arrays
317 Dumux::parallelFor(nTemp_, [=](std::size_t iT)
318 {
319 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
320 vaporPressure_[iT] = RawComponent::vaporPressure(temperature);
321 });
322 }
323
325 template< bool useVP = useVaporPressure, std::enable_if_t<!useVP, int> = 0 >
326 void tabularizeVaporPressure_() {}
327
342 template<class PropFunc, class Policy>
343 void tabularizeTPArray_(const PropFunc& f, Policy policy, std::vector<typename RawComponent::Scalar>& values) const
344 {
345 Dumux::parallelFor(nTemp_, [=,&values](std::size_t iT)
346 {
347 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
348
349 Scalar pMax = policy.maxP(iT);
350 Scalar pMin = policy.minP(iT);
351 for (std::size_t iP = 0; iP < nPress_; ++ iP)
352 {
353 Scalar pressure = iP * (pMax - pMin)/(nPress_ - 1) + pMin;
354 values[iT + iP*nTemp_] = f(temperature, pressure);
355 }
356 });
357 }
358
374 template<class RhoFunc, class Policy>
375 void tabularizeMinMaxRhoArray_(const RhoFunc& rho, Policy policy,
376 std::vector<typename RawComponent::Scalar>& rhoMin,
377 std::vector<typename RawComponent::Scalar>& rhoMax) const
378 {
379 Dumux::parallelFor(nTemp_, [=,&rhoMin,&rhoMax](std::size_t iT)
380 {
381 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
382
383 using std::min;
384 rhoMin[iT] = rho(temperature, policy.minP(iT));
385 rhoMax[iT] = rho(temperature, policy.maxP(min(iT + 1, nTemp_ - 1)));
386 });
387 }
388
399 template<class PFunc>
400 void tabularizePressureArray_(std::vector<typename RawComponent::Scalar>& pressure,
401 const PFunc& p,
402 const std::vector<typename RawComponent::Scalar>& rhoMin,
403 const std::vector<typename RawComponent::Scalar>& rhoMax) const
404 {
405 Dumux::parallelFor(nTemp_, [=,&pressure,&rhoMin,&rhoMax](std::size_t iT)
406 {
407 Scalar temperature = iT * (tempMax_ - tempMin_)/(nTemp_ - 1) + tempMin_;
408
409 for (std::size_t iRho = 0; iRho < nDensity_; ++ iRho)
410 {
411 Scalar density = Scalar(iRho)/(nDensity_ - 1)
412 * (rhoMax[iT] - rhoMin[iT])
413 + rhoMin[iT];
414 pressure[iT + iRho*nTemp_] = p(temperature, density);
415 }
416 });
417 }
418
419 template<class RC = RawComponent>
420 bool tabularizeGasEnthalpy_()
421 {
422 if constexpr (Detail::hasGasEnthalpy<RC>())
423 {
424 const auto gasEnth = [] (auto T, auto p) { return RC::gasEnthalpy(T, p); };
425 tabularizeTPArray_(gasEnth, GasPolicy{ *this }, gasEnthalpy_);
426 return true;
427 }
428
429 return false;
430 }
431
432 template<class RC = RawComponent>
433 bool tabularizeLiquidEnthalpy_()
434 {
435 if constexpr (Detail::hasLiquidEnthalpy<RC>())
436 {
437 const auto liqEnth = [] (auto T, auto p) { return RC::liquidEnthalpy(T, p); };
438 tabularizeTPArray_(liqEnth, LiquidPolicy{ *this }, liquidEnthalpy_);
439 return true;
440 }
441
442 return false;
443 }
444
445 template<class RC = RawComponent>
446 bool tabularizeGasHeatCapacity_()
447 {
448 if constexpr (Detail::hasGasHeatCapacity<RC>())
449 {
450 const auto gasHC = [] (auto T, auto p) { return RC::gasHeatCapacity(T, p); };
451 tabularizeTPArray_(gasHC, GasPolicy{ *this }, gasHeatCapacity_);
452 return true;
453 }
454
455 return false;
456 }
457
458 template<class RC = RawComponent>
459 bool tabularizeLiquidHeatCapacity_()
460 {
461 if constexpr (Detail::hasLiquidHeatCapacity<RC>())
462 {
463 const auto liqHC = [] (auto T, auto p) { return RC::liquidHeatCapacity(T, p); };
464 tabularizeTPArray_(liqHC, LiquidPolicy{ *this }, liquidHeatCapacity_);
465 return true;
466 }
467
468 return false;
469 }
470
471 template<class RC = RawComponent>
472 bool tabularizeMinMaxGasDensity_()
473 {
474 if constexpr (Detail::hasGasDensity<RC>())
475 {
476 const auto gasRho = [] (auto T, auto p) { return RC::gasDensity(T, p); };
477 tabularizeMinMaxRhoArray_(gasRho, GasPolicy{ *this }, minGasDensity_, maxGasDensity_);
478 return true;
479 }
480
481 return false;
482 }
483
484 template<class RC = RawComponent>
485 bool tabularizeMinMaxLiquidDensity_()
486 {
487 if constexpr (Detail::hasGasEnthalpy<RC>())
488 {
489 const auto liqRho = [] (auto T, auto p) { return RC::liquidDensity(T, p); };
490 tabularizeMinMaxRhoArray_(liqRho, LiquidPolicy{ *this }, minLiquidDensity_, maxLiquidDensity_);
491 return true;
492 }
493
494 return false;
495 }
496
497 template<class RC = RawComponent>
498 bool tabularizeGasPressure_()
499 {
500 // pressure is only defined if the gas is compressible (this is usually the case)
501 if constexpr (Detail::hasGasPressure<RC>() && RC::gasIsCompressible())
502 {
503 const auto gasPFunc = [] (auto T, auto rho) { return RC::gasPressure(T, rho); };
504 tabularizePressureArray_(gasPressure_, gasPFunc, minGasDensity_, maxGasDensity_);
505 return true;
506 }
507
508 return false;
509 }
510
511 template<class RC = RawComponent>
512 bool tabularizeLiquidPressure_()
513 {
514 // pressure is only defined if the liquid is compressible (this is often not the case)
515 if constexpr (Detail::hasLiquidPressure<RC>() && RC::liquidIsCompressible())
516 {
517 const auto liqPFunc = [] (auto T, auto rho) { return RC::liquidPressure(T, rho); };
518 tabularizePressureArray_(liquidPressure_, liqPFunc, minLiquidDensity_, maxLiquidDensity_);
519 return true;
520 }
521
522 return false;
523 }
524
525 template<class RC = RawComponent>
526 bool tabularizeGasDensity_()
527 {
528 if constexpr (Detail::hasGasDensity<RC>())
529 {
530 const auto gasRho = [] (auto T, auto p) { return RC::gasDensity(T, p); };
531 tabularizeTPArray_(gasRho, GasPolicy{ *this }, gasDensity_);
532 return true;
533 }
534
535 return false;
536 }
537
538 template<class RC = RawComponent>
539 bool tabularizeLiquidDensity_()
540 {
541 if constexpr (Detail::hasLiquidDensity<RC>())
542 {
543 // TODO: we could get rid of the lambdas and pass the functor directly. But,
544 // currently Brine is a component (and not a fluid system) expecting a
545 // third argument with a default, which cannot be wrapped in a function pointer.
546 // For this reason we have to wrap this into a lambda here.
547 const auto liqRho = [] (auto T, auto p) { return RC::liquidDensity(T, p); };
548 tabularizeTPArray_(liqRho, LiquidPolicy{ *this }, liquidDensity_);
549 return true;
550 }
551
552 return false;
553 }
554
555 template<class RC = RawComponent>
556 bool tabularizeGasViscosity_()
557 {
558 if constexpr (Detail::hasGasViscosity<RC>())
559 {
560 const auto gasVisc = [] (auto T, auto p) { return RC::gasViscosity(T, p); };
561 tabularizeTPArray_(gasVisc, GasPolicy{ *this }, gasViscosity_);
562 return true;
563 }
564
565 return false;
566 }
567
568 template<class RC = RawComponent>
569 bool tabularizeLiquidViscosity_()
570 {
571 if constexpr (Detail::hasLiquidViscosity<RC>())
572 {
573 const auto liqVisc = [] (auto T, auto p) { return RC::liquidViscosity(T, p); };
574 tabularizeTPArray_(liqVisc, LiquidPolicy{ *this }, liquidViscosity_);
575 return true;
576 }
577
578 return false;
579 }
580
581 template<class RC = RawComponent>
582 bool tabularizeGasThermalConductivity_()
583 {
584 if constexpr (Detail::hasGasThermalConductivity<RC>())
585 {
586 const auto gasTC = [] (auto T, auto p) { return RC::gasThermalConductivity(T, p); };
587 tabularizeTPArray_(gasTC, GasPolicy{ *this }, gasThermalConductivity_);
588 return true;
589 }
590
591 return false;
592 }
593
594 template<class RC = RawComponent>
595 bool tabularizeLiquidThermalConductivity_()
596 {
597 if constexpr (Detail::hasLiquidThermalConductivity<RC>())
598 {
599 const auto liqTC = [] (auto T, auto p) { return RC::liquidThermalConductivity(T, p); };
600 tabularizeTPArray_(liqTC, LiquidPolicy{ *this }, liquidThermalConductivity_);
601 return true;
602 }
603
604 return false;
605 }
606
607private:
608 // 1D fields with the temperature as degree of freedom
609 std::vector<Scalar> vaporPressure_;
610
611 std::vector<Scalar> minLiquidDensity_;
612 std::vector<Scalar> maxLiquidDensity_;
613 bool minMaxLiquidDensityInitialized_;
614
615 std::vector<Scalar> minGasDensity_;
616 std::vector<Scalar> maxGasDensity_;
617 bool minMaxGasDensityInitialized_;
618
619 // 2D fields with the temperature and pressure as degrees of freedom
620 std::vector<Scalar> gasEnthalpy_;
621 std::vector<Scalar> liquidEnthalpy_;
622 bool gasEnthalpyInitialized_;
623 bool liquidEnthalpyInitialized_;
624
625 std::vector<Scalar> gasHeatCapacity_;
626 std::vector<Scalar> liquidHeatCapacity_;
627 bool gasHeatCapacityInitialized_;
628 bool liquidHeatCapacityInitialized_;
629
630 std::vector<Scalar> gasDensity_;
631 std::vector<Scalar> liquidDensity_;
632 bool gasDensityInitialized_;
633 bool liquidDensityInitialized_;
634
635 std::vector<Scalar> gasViscosity_;
636 std::vector<Scalar> liquidViscosity_;
637 bool gasViscosityInitialized_;
638 bool liquidViscosityInitialized_;
639
640 std::vector<Scalar> gasThermalConductivity_;
641 std::vector<Scalar> liquidThermalConductivity_;
642 bool gasThermalConductivityInitialized_;
643 bool liquidThermalConductivityInitialized_;
644
645 // 2D fields with the temperature and density as degrees of freedom
646 std::vector<Scalar> gasPressure_;
647 std::vector<Scalar> liquidPressure_;
648 bool gasPressureInitialized_;
649 bool liquidPressureInitialized_;
650
651 // temperature, pressure and density ranges
652 Scalar tempMin_;
653 Scalar tempMax_;
654 std::size_t nTemp_;
655
656 Scalar pressMin_;
657 Scalar pressMax_;
658 std::size_t nPress_;
659
660 Scalar densityMin_;
661 Scalar densityMax_;
662 std::size_t nDensity_;
663};
664
665} // end namespace Dumux::Components::Detail
666
667namespace Dumux::Components {
668
682template <class RawComponent, bool useVaporPressure=true>
684{
687
688 struct InterpolatePolicy
689 {
690 using Scalar = typename RawComponent::Scalar;
691
692 const Table& table;
693
694 Scalar tempIdx(Scalar T) const { return table.tempIdx(T); }
695 Scalar tempMin() const { return table.tempMin(); }
696 Scalar tempMax() const { return table.tempMax(); }
697 std::size_t nTemp() const { return table.nTemp(); }
698 std::size_t nPress() const { return table.nPress(); }
699 std::size_t nDensity() const { return table.nDensity(); }
700 };
701
702 struct InterpolateGasPolicy : public InterpolatePolicy
703 {
704 using Scalar = typename RawComponent::Scalar;
705 Scalar pressIdx(Scalar p, std::size_t tempIdx) const { return this->table.pressGasIdx(p, tempIdx); }
706 Scalar rhoIdx(Scalar rho, std::size_t tempIdx) const { return this->table.densityGasIdx(rho, tempIdx); }
707 Scalar minP(int tempIdx) const { return this->table.minGasPressure(tempIdx); }
708 Scalar maxP(int tempIdx) const { return this->table.maxGasPressure(tempIdx); }
709 Scalar minRho(int tempIdx) const { return this->table.minGasDensity(tempIdx); }
710 Scalar maxRho(int tempIdx) const { return this->table.maxGasDensity(tempIdx); }
711 };
712
713 struct InterpolateLiquidPolicy : public InterpolatePolicy
714 {
715 using Scalar = typename RawComponent::Scalar;
716 Scalar pressIdx(Scalar p, std::size_t tempIdx) const { return this->table.pressLiquidIdx(p, tempIdx); }
717 Scalar rhoIdx(Scalar rho, std::size_t tempIdx) const { return this->table.densityLiquidIdx(rho, tempIdx); }
718 Scalar minP(int tempIdx) const { return this->table.minLiquidPressure(tempIdx); }
719 Scalar maxP(int tempIdx) const { return this->table.maxLiquidPressure(tempIdx); }
720 Scalar minRho(int tempIdx) const { return this->table.minLiquidDensity(tempIdx); }
721 Scalar maxRho(int tempIdx) const { return this->table.maxLiquidDensity(tempIdx); }
722 };
723public:
725 using Scalar = typename RawComponent::Scalar;
726
728 static constexpr bool isTabulated = true;
729
740 static void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp,
741 Scalar pressMin, Scalar pressMax, std::size_t nPress)
742 {
743#ifndef NDEBUG
744 warningPrinted_ = false;
745#endif
746 std::cout << "-------------------------------------------------------------------------\n"
747 << "Initializing tables for the " << RawComponent::name()
748 << " fluid properties (" << nTemp*nPress << " entries).\n"
749 << "Temperature -> min: " << std::scientific << std::setprecision(3)
750 << tempMin << ", max: " << tempMax << ", n: " << nTemp << '\n'
751 << "Pressure -> min: " << std::scientific << std::setprecision(3)
752 << pressMin << ", max: " << pressMax << ", n: " << nPress << '\n'
753 << "-------------------------------------------------------------------------" << std::endl;
754
755 table().init(tempMin, tempMax, nTemp, pressMin, pressMax, nPress);
756
757 initialized_ = true;
758 }
759
763 static std::string name()
764 { return RawComponent::name(); }
765
769 static constexpr Scalar molarMass()
770 { return RawComponent::molarMass(); }
771
776 { return RawComponent::criticalTemperature(); }
777
782 { return RawComponent::criticalPressure(); }
783
788 { return RawComponent::tripleTemperature(); }
789
794 { return RawComponent::triplePressure(); }
795
803 {
804 using std::isnan;
805 Scalar result = interpolateT_(table().vaporPressure_, T, InterpolatePolicy{{ table() }});
806 if (isnan(result))
807 return RawComponent::vaporPressure(T);
808 return result;
809 }
810
819 {
820 return RawComponent::vaporTemperature(pressure);
821 }
822
830 {
831 Scalar result = interpolateTP_(table().gasEnthalpy_, temperature, pressure, InterpolateGasPolicy{{ table() }});
832 using std::isnan;
833 if (isnan(result))
834 {
835 printWarningTP_("gasEnthalpy", temperature, pressure, InterpolateGasPolicy{{ table() }});
836 return RawComponent::gasEnthalpy(temperature, pressure);
837 }
838 return result;
839 }
840
848 {
849 Scalar result = interpolateTP_(table().liquidEnthalpy_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
850 using std::isnan;
851 if (isnan(result))
852 {
853 printWarningTP_("liquidEnthalpy", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
854 return RawComponent::liquidEnthalpy(temperature, pressure);
855 }
856 return result;
857 }
858
866 {
867 Scalar result = interpolateTP_(table().gasHeatCapacity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
868 using std::isnan;
869 if (isnan(result))
870 {
871 printWarningTP_("gasHeatCapacity", temperature, pressure, InterpolateGasPolicy{{ table() }});
872 return RawComponent::gasHeatCapacity(temperature, pressure);
873 }
874 return result;
875 }
876
884 {
885 Scalar result = interpolateTP_(table().liquidHeatCapacity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
886 using std::isnan;
887 if (isnan(result))
888 {
889 printWarningTP_("liquidHeatCapacity", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
890 return RawComponent::liquidHeatCapacity(temperature, pressure);
891 }
892 return result;
893 }
894
902 {
904 }
905
913 {
915 }
916
924 {
925 Scalar result = interpolateTRho_(table().gasPressure_, temperature, density, InterpolateGasPolicy{{ table() }});
926 using std::isnan;
927 if (isnan(result))
928 {
929 printWarningTRho_("gasPressure", temperature, density, InterpolateGasPolicy{{ table() }});
930 return RawComponent::gasPressure(temperature, density);
931 }
932 return result;
933 }
934
942 {
943 Scalar result = interpolateTRho_(table().liquidPressure_, temperature, density, InterpolateLiquidPolicy{{ table() }});
944 using std::isnan;
945 if (isnan(result))
946 {
947 printWarningTRho_("liquidPressure", temperature, density, InterpolateLiquidPolicy{{ table() }});
948 return RawComponent::liquidPressure(temperature, density);
949 }
950 return result;
951 }
952
956 static constexpr bool gasIsCompressible()
957 { return RawComponent::gasIsCompressible(); }
958
962 static constexpr bool liquidIsCompressible()
963 { return RawComponent::liquidIsCompressible(); }
964
968 static constexpr bool gasIsIdeal()
969 { return RawComponent::gasIsIdeal(); }
970
971
980 {
981 Scalar result = interpolateTP_(table().gasDensity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
982 using std::isnan;
983 if (isnan(result))
984 {
985 printWarningTP_("gasDensity", temperature, pressure, InterpolateGasPolicy{{ table() }});
986 return RawComponent::gasDensity(temperature, pressure);
987 }
988 return result;
989 }
990
1001
1010 {
1011 Scalar result = interpolateTP_(table().liquidDensity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1012 using std::isnan;
1013 if (isnan(result))
1014 {
1015 printWarningTP_("liquidDensity", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1016 return RawComponent::liquidDensity(temperature, pressure);
1017 }
1018
1019 return result;
1020 }
1021
1032
1040 {
1041 Scalar result = interpolateTP_(table().gasViscosity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
1042 using std::isnan;
1043 if (isnan(result))
1044 {
1045 printWarningTP_("gasViscosity", temperature, pressure, InterpolateGasPolicy{{ table() }});
1046 return RawComponent::gasViscosity(temperature, pressure);
1047 }
1048 return result;
1049 }
1050
1058 {
1059 Scalar result = interpolateTP_(table().liquidViscosity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1060 using std::isnan;
1061 if (isnan(result))
1062 {
1063 printWarningTP_("liquidViscosity",temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1064 return RawComponent::liquidViscosity(temperature, pressure);
1065 }
1066 return result;
1067 }
1068
1076 {
1077 Scalar result = interpolateTP_(table().gasThermalConductivity_, temperature, pressure, InterpolateGasPolicy{{ table() }});
1078 using std::isnan;
1079 if (isnan(result))
1080 {
1081 printWarningTP_("gasThermalConductivity", temperature, pressure, InterpolateGasPolicy{{ table() }});
1082 return RawComponent::gasThermalConductivity(temperature, pressure);
1083 }
1084 return result;
1085 }
1086
1094 {
1095 Scalar result = interpolateTP_(table().liquidThermalConductivity_, temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1096 using std::isnan;
1097 if (isnan(result))
1098 {
1099 printWarningTP_("liquidThermalConductivity", temperature, pressure, InterpolateLiquidPolicy{{ table() }});
1100 return RawComponent::liquidThermalConductivity(temperature, pressure);
1101 }
1102 return result;
1103 }
1104
1105
1106private:
1108 template<class Policy>
1109 static void printWarningTP_(const std::string& quantity, Scalar T, Scalar p, Policy policy)
1110 {
1111#ifndef NDEBUG
1112 if (warningPrinted_)
1113 return;
1114
1115 if (!initialized_)
1116 std::cerr << "Warning: tabulated component '" << name()
1117 << "' has not been initialized. "
1118 << "Call FluidSystem::init() to use the tabulation in order to reduce runtime. \n";
1119 else
1120 std::cerr << "Warning: "<<quantity<<"(T="<<T<<", p="<<p<<") of component '"<<name()
1121 << "' is outside tabulation range: ("<< policy.tempMin() <<"<=T<="<< policy.tempMax() <<"), ("
1122 << policy.minP(0) <<"<=p<=" << policy.maxP(policy.nTemp()-1) <<"). "
1123 << "Forwarded to FluidSystem for direct evaluation of "<<quantity<<". \n";
1124 warningPrinted_ = true;
1125#endif
1126 }
1127
1129 template<class Policy>
1130 static void printWarningTRho_(const std::string& quantity, Scalar T, Scalar rho, Policy policy)
1131 {
1132#ifndef NDEBUG
1133 if (warningPrinted_)
1134 return;
1135
1136 if (!initialized_)
1137 std::cerr << "Warning: tabulated component '" << name()
1138 << "' has not been initialized. "
1139 << "Call FluidSystem::init() to use the tabulation in order to reduce runtime. \n";
1140 else
1141 {
1142 const auto [densityMin, densityMax] = [&]
1143 {
1144 const Scalar alphaT = policy.tempIdx(T);
1145 using std::clamp;
1146 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, policy.nTemp() - 2);
1147 return std::make_pair( policy.minRho(iT), policy.maxRho(iT) );
1148 }();
1149
1150 std::cerr << "Warning: "<<quantity<<"(T="<<T<<", density="<<rho<<") of component '"<<name()
1151 << "' is outside tabulation range: ("<< policy.tempMin() <<"<=T<="<< policy.tempMax() <<"), ("
1152 << densityMin <<"<=density<=" << densityMax <<"). "
1153 << "Forwarded to FluidSystem for direct evaluation of "<<quantity<<". \n";
1154 }
1155 warningPrinted_ = true;
1156#endif
1157 }
1158
1160 template<class Policy>
1161 static Scalar interpolateT_(const std::vector<Scalar>& values, Scalar T, Policy policy)
1162 {
1163 Scalar alphaT = policy.tempIdx(T);
1164 const auto nTemp = policy.nTemp();
1165 if (alphaT < 0 - 1e-7*nTemp || alphaT >= nTemp - 1 + 1e-7*nTemp)
1166 return std::numeric_limits<Scalar>::quiet_NaN();
1167
1168 using std::clamp;
1169 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, nTemp - 2);
1170 alphaT -= iT;
1171
1172 return values[iT ]*(1 - alphaT) +
1173 values[iT + 1]*( alphaT);
1174 }
1175
1177 template<class Policy>
1178 static Scalar interpolateTP_(const std::vector<Scalar>& values, const Scalar T, const Scalar p, Policy policy)
1179 {
1180 const auto nTemp = policy.nTemp();
1181 const auto nPress = policy.nPress();
1182
1183 Scalar alphaT = policy.tempIdx(T);
1184 if (alphaT < 0 - 1e-7*nTemp || alphaT >= nTemp - 1 + 1e-7*nTemp)
1185 return std::numeric_limits<Scalar>::quiet_NaN();
1186
1187 using std::clamp;
1188 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, nTemp - 2);
1189 alphaT -= iT;
1190
1191 Scalar alphaP1 = policy.pressIdx(p, iT);
1192 Scalar alphaP2 = policy.pressIdx(p, iT + 1);
1193
1194 const auto iP1 = clamp<int>(static_cast<int>(alphaP1), 0, nPress - 2);
1195 const auto iP2 = clamp<int>(static_cast<int>(alphaP2), 0, nPress - 2);
1196 alphaP1 -= iP1;
1197 alphaP2 -= iP2;
1198
1199#if 0 && !defined NDEBUG
1200 const auto tempMin = policy.tempMin();
1201 const auto tempMin = policy.tempMax();
1202 if(!(0 <= alphaT && alphaT <= 1.0))
1203 DUNE_THROW(NumericalProblem, "Temperature out of range: "
1204 << "T=" << T << " range: [" << tempMin_ << ", " << tempMax_ << "]");
1205 if(!(0 <= alphaP1 && alphaP1 <= 1.0))
1206 DUNE_THROW(NumericalProblem, "First pressure out of range: "
1207 << "p=" << p << " range: [" << policy.minP(policy.tempIdx(T)) << ", " << policy.maxP(policy.tempIdx(T)) << "]");
1208 if(!(0 <= alphaP2 && alphaP2 <= 1.0))
1209 DUNE_THROW(NumericalProblem, "Second pressure out of range: "
1210 << "p=" << p << " range: [" << policy.minP(policy.tempIdx(T) + 1) << ", " << policy.maxP(policy.tempIdx(T) + 1) << "]");
1211#endif
1212 return values[(iT ) + (iP1 )*nTemp]*(1 - alphaT)*(1 - alphaP1) +
1213 values[(iT ) + (iP1 + 1)*nTemp]*(1 - alphaT)*( alphaP1) +
1214 values[(iT + 1) + (iP2 )*nTemp]*( alphaT)*(1 - alphaP2) +
1215 values[(iT + 1) + (iP2 + 1)*nTemp]*( alphaT)*( alphaP2);
1216 }
1217
1219 template<class Policy>
1220 static Scalar interpolateTRho_(const std::vector<Scalar>& values, const Scalar T, const Scalar rho, Policy policy)
1221 {
1222 const auto nTemp = policy.nTemp();
1223 const auto nDensity = policy.nDensity();
1224
1225 using std::clamp;
1226 Scalar alphaT = policy.tempIdx(T);
1227 if (alphaT < 0 - 1e-7*nTemp || alphaT >= nTemp - 1 + 1e-7*nTemp)
1228 return std::numeric_limits<Scalar>::quiet_NaN();
1229
1230 const auto iT = clamp<int>(static_cast<int>(alphaT), 0, nTemp - 2);
1231 alphaT -= iT;
1232
1233 Scalar alphaP1 = policy.rhoIdx(rho, iT);
1234 Scalar alphaP2 = policy.rhoIdx(rho, iT + 1);
1235 const auto iP1 = clamp<int>(static_cast<int>(alphaP1), 0, nDensity - 2);
1236 const auto iP2 = clamp<int>(static_cast<int>(alphaP2), 0, nDensity - 2);
1237 alphaP1 -= iP1;
1238 alphaP2 -= iP2;
1239
1240 return values[(iT ) + (iP1 )*nTemp]*(1 - alphaT)*(1 - alphaP1) +
1241 values[(iT ) + (iP1 + 1)*nTemp]*(1 - alphaT)*( alphaP1) +
1242 values[(iT + 1) + (iP2 )*nTemp]*( alphaT)*(1 - alphaP2) +
1243 values[(iT + 1) + (iP2 + 1)*nTemp]*( alphaT)*( alphaP2);
1244 }
1245
1246 // specifies whether the table was initialized
1247 static bool initialized_;
1248
1249#ifndef NDEBUG
1250 // specifies whether some warning was printed
1251 static bool warningPrinted_;
1252#endif
1253
1254 static Table& table()
1255 {
1256 static Table t;
1257 return t;
1258 }
1259};
1260
1261template <class RawComponent, bool useVaporPressure>
1262bool TabulatedComponent<RawComponent, useVaporPressure>::initialized_ = false;
1263
1264#ifndef NDEBUG
1265template <class RawComponent, bool useVaporPressure>
1266bool TabulatedComponent<RawComponent, useVaporPressure>::warningPrinted_ = false;
1267#endif
1268
1269// forward declaration
1270template <class Component>
1271struct IsAqueous;
1272
1273// we are aqueous if the raw compont is so
1274template <class RawComponent, bool useVaporPressure>
1275struct IsAqueous<TabulatedComponent<RawComponent, useVaporPressure>> : public IsAqueous<RawComponent> {};
1276
1277} // end namespace Dumux::Components
1278
1279#endif
Parallel for loop (multithreading)
Multithreading in Dumux.
Some exceptions thrown in DuMux
Type traits.
Component traits, i.e. information extracted from components.
void parallelFor(const std::size_t count, const FunctorType &functor)
A parallel for loop (multithreading)
Definition: parallel_for.hh:172
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
std::string temperature() noexcept
I/O name of temperature for equilibrium models.
Definition: name.hh:51
std::string pressure(int phaseIdx) noexcept
I/O name of pressure for multiphase systems.
Definition: name.hh:34
std::string density(int phaseIdx) noexcept
I/O name of density for multiphase systems.
Definition: name.hh:65
Definition: air.hh:35
Definition: tabulatedcomponent.hh:72
decltype(C::template gasThermalConductivity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasThermalCond
Definition: tabulatedcomponent.hh:91
constexpr bool hasGasEnthalpy()
Definition: tabulatedcomponent.hh:109
constexpr bool hasGasHeatCapacity()
Definition: tabulatedcomponent.hh:115
decltype(C::template liquidEnthalpy< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidEnthalpy
Definition: tabulatedcomponent.hh:82
decltype(C::template gasViscosity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasViscosity
Definition: tabulatedcomponent.hh:93
decltype(C::template gasDensity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasDensity
Definition: tabulatedcomponent.hh:90
decltype(C::template liquidHeatCapacity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidHeatCapacity
Definition: tabulatedcomponent.hh:85
decltype(C::gasPressure(0.0, 0.0)) CompHasGasPressure
Definition: tabulatedcomponent.hh:94
constexpr bool hasLiquidThermalConductivity()
Definition: tabulatedcomponent.hh:100
constexpr bool hasGasViscosity()
Definition: tabulatedcomponent.hh:117
constexpr bool hasLiquidPressure()
Definition: tabulatedcomponent.hh:106
constexpr bool hasLiquidEnthalpy()
Definition: tabulatedcomponent.hh:96
decltype(C::template gasEnthalpy< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasEnthalpy
Definition: tabulatedcomponent.hh:89
constexpr bool hasGasDensity()
Definition: tabulatedcomponent.hh:111
decltype(C::liquidPressure(0.0, 0.0)) CompHasLiquidPressure
Definition: tabulatedcomponent.hh:87
constexpr bool hasGasThermalConductivity()
Definition: tabulatedcomponent.hh:113
constexpr bool hasLiquidViscosity()
Definition: tabulatedcomponent.hh:104
constexpr bool hasGasPressure()
Definition: tabulatedcomponent.hh:119
decltype(C::template liquidThermalConductivity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidThermalCond
Definition: tabulatedcomponent.hh:84
constexpr bool hasLiquidHeatCapacity()
Definition: tabulatedcomponent.hh:102
constexpr bool hasLiquidDensity()
Definition: tabulatedcomponent.hh:98
decltype(C::template gasHeatCapacity< DisableStaticAssert >(0.0, 0.0)) CompHasNoGasHeatCapacity
Definition: tabulatedcomponent.hh:92
decltype(C::template liquidDensity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidDensity
Definition: tabulatedcomponent.hh:83
decltype(C::template liquidViscosity< DisableStaticAssert >(0.0, 0.0)) CompHasNoLiquidViscosity
Definition: tabulatedcomponent.hh:86
Template which always yields a false value.
Definition: typetraits.hh:35
IsAqueous struct.
Definition: components/base.hh:47
Component traits, i.e. information extracted from components.
Definition: componenttraits.hh:43
static constexpr bool hasLiquidState
if the component implements a liquid state
Definition: componenttraits.hh:50
static constexpr bool hasSolidState
if the component implements a solid state
Definition: componenttraits.hh:47
static constexpr bool hasGasState
if the component implements a gaseous state
Definition: componenttraits.hh:53
Tabulates all thermodynamic properties of a given component.
Definition: tabulatedcomponent.hh:684
static const Scalar gasEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the gas .
Definition: tabulatedcomponent.hh:829
static Scalar gasPressure(Scalar temperature, Scalar density)
The pressure of gas in at a given density and temperature.
Definition: tabulatedcomponent.hh:923
static Scalar criticalTemperature()
Returns the critical temperature in of the component.
Definition: tabulatedcomponent.hh:775
static Scalar liquidPressure(Scalar temperature, Scalar density)
The pressure of liquid in at a given density and temperature.
Definition: tabulatedcomponent.hh:941
static const Scalar gasHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the gas .
Definition: tabulatedcomponent.hh:865
static std::string name()
A human readable name for the component.
Definition: tabulatedcomponent.hh:763
static Scalar vaporTemperature(Scalar pressure)
The vapor pressure in of the component at a given temperature.
Definition: tabulatedcomponent.hh:818
static Scalar liquidThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of liquid water .
Definition: tabulatedcomponent.hh:1093
static Scalar gasDensity(Scalar temperature, Scalar pressure)
The density of gas at a given pressure and temperature .
Definition: tabulatedcomponent.hh:979
static const Scalar liquidEnthalpy(Scalar temperature, Scalar pressure)
Specific enthalpy of the liquid .
Definition: tabulatedcomponent.hh:847
static Scalar triplePressure()
Returns the pressure in at the component's triple point.
Definition: tabulatedcomponent.hh:793
static Scalar criticalPressure()
Returns the critical pressure in of the component.
Definition: tabulatedcomponent.hh:781
static const Scalar gasInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the gas .
Definition: tabulatedcomponent.hh:901
static Scalar liquidMolarDensity(Scalar temperature, Scalar pressure)
The molar density of liquid in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:1030
static constexpr Scalar molarMass()
The molar mass in of the component.
Definition: tabulatedcomponent.hh:769
static Scalar liquidViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of liquid.
Definition: tabulatedcomponent.hh:1057
static Scalar gasViscosity(Scalar temperature, Scalar pressure)
The dynamic viscosity of gas.
Definition: tabulatedcomponent.hh:1039
static Scalar tripleTemperature()
Returns the temperature in at the component's triple point.
Definition: tabulatedcomponent.hh:787
static constexpr bool liquidIsCompressible()
Returns true if the liquid phase is assumed to be compressible.
Definition: tabulatedcomponent.hh:962
static Scalar liquidDensity(Scalar temperature, Scalar pressure)
The density of liquid at a given pressure and temperature .
Definition: tabulatedcomponent.hh:1009
static Scalar gasThermalConductivity(Scalar temperature, Scalar pressure)
The thermal conductivity of gaseous water .
Definition: tabulatedcomponent.hh:1075
static Scalar gasMolarDensity(Scalar temperature, Scalar pressure)
The molar density of gas in at a given pressure and temperature.
Definition: tabulatedcomponent.hh:999
static constexpr bool isTabulated
state that we are tabulated
Definition: tabulatedcomponent.hh:728
static const Scalar liquidInternalEnergy(Scalar temperature, Scalar pressure)
Specific internal energy of the liquid .
Definition: tabulatedcomponent.hh:912
static Scalar vaporPressure(Scalar T)
The vapor pressure in of the component at a given temperature.
Definition: tabulatedcomponent.hh:802
static constexpr bool gasIsCompressible()
Returns true if the gas phase is assumed to be compressible.
Definition: tabulatedcomponent.hh:956
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:740
static constexpr bool gasIsIdeal()
Returns true if the gas phase is assumed to be ideal.
Definition: tabulatedcomponent.hh:968
static const Scalar liquidHeatCapacity(Scalar temperature, Scalar pressure)
Specific isobaric heat capacity of the liquid .
Definition: tabulatedcomponent.hh:883
typename RawComponent::Scalar Scalar
export scalar type
Definition: tabulatedcomponent.hh:725
typename RawComponent::Scalar Scalar
Definition: tabulatedcomponent.hh:59
Definition: tabulatedcomponent.hh:73
Definition: tabulatedcomponent.hh:124
std::size_t nPress() const
Definition: tabulatedcomponent.hh:304
Scalar tempIdx(Scalar temperature) const
returns the index of an entry in a temperature field
Definition: tabulatedcomponent.hh:210
Scalar densityLiquidIdx(Scalar density, std::size_t tempIdx) const
returns the index of an entry in a density field
Definition: tabulatedcomponent.hh:232
void init(Scalar tempMin, Scalar tempMax, std::size_t nTemp, Scalar pressMin, Scalar pressMax, std::size_t nPress)
Definition: tabulatedcomponent.hh:142
Scalar pressGasIdx(Scalar pressure, std::size_t tempIdx) const
returns the index of an entry in a temperature field
Definition: tabulatedcomponent.hh:224
Scalar minLiquidPressure(int tempIdx) const
returns the minimum tabularized liquid pressure at a given temperature index
Definition: tabulatedcomponent.hh:248
Scalar densityGasIdx(Scalar density, std::size_t tempIdx) const
returns the index of an entry in a density field
Definition: tabulatedcomponent.hh:240
Scalar maxGasPressure(int tempIdx) const
returns the maximum tabularized gas pressure at a given temperature index
Definition: tabulatedcomponent.hh:278
Scalar minGasDensity(int tempIdx) const
returns the minimum tabularized gas density at a given temperature index
Definition: tabulatedcomponent.hh:296
Scalar maxLiquidDensity(int tempIdx) const
returns the maximum tabularized liquid density at a given temperature index
Definition: tabulatedcomponent.hh:292
Scalar maxGasDensity(int tempIdx) const
returns the maximum tabularized gas density at a given temperature index
Definition: tabulatedcomponent.hh:300
Scalar tempMin() const
Definition: tabulatedcomponent.hh:308
Scalar maxLiquidPressure(int tempIdx) const
returns the maximum tabularized liquid pressure at a given temperature index
Definition: tabulatedcomponent.hh:258
Scalar pressLiquidIdx(Scalar pressure, std::size_t tempIdx) const
returns the index of an entry in a pressure field
Definition: tabulatedcomponent.hh:216
Scalar tempMax() const
Definition: tabulatedcomponent.hh:307
std::size_t nDensity() const
Definition: tabulatedcomponent.hh:305
Scalar minLiquidDensity(int tempIdx) const
returns the minimum tabularized liquid density at a given temperature index
Definition: tabulatedcomponent.hh:288
std::size_t nTemp() const
Definition: tabulatedcomponent.hh:303
Scalar minGasPressure(int tempIdx) const
returns the minimum tabularized gas pressure at a given temperature index
Definition: tabulatedcomponent.hh:268