51 static_assert(intervals == -1 || intervals > 0,
"Number of intervals must be -1 (dynamic) or greater than 0 (static).");
55 using Temperatures = std::conditional_t<intervals == -1, std::vector<Scalar>, std::array<Scalar, std::size_t(intervals+1)>>;
56 using Coefficients = std::conditional_t<intervals == -1, std::vector<CoefficientSet>, std::array<
CoefficientSet, std::size_t(intervals)>>;
64 : temperatures_(temperatures)
75 Scalar
enthalpy(
const Scalar temperature)
const
77 const auto& p = paramsAtTemperature_(temperature);
78 const Scalar t = temperature/1000.0;
79 const Scalar standardEnthalpyDiff = p.A*t + p.B*t*t/2.0 + p.C*t*t*t/3.0 + p.D*t*t*t*t/4.0 - p.E/t + p.F - p.H;
80 return standardEnthalpyDiff;
90 const auto& p = paramsAtTemperature_(temperature);
91 const Scalar t = temperature/1000.0;
92 const Scalar
heatCapacity = p.A + p.B*t + p.C*t*t + p.D*t*t*t + p.E/(t*t);
100 if (T < temperatures_.front() || T > temperatures_.back())
102 if (!warningPrinted_)
104 std::cout <<
"Temperature "<< T <<
" [K] is out of range. Enthalpy values are extrapolated." << std::endl;
105 warningPrinted_ =
true;
110 const auto index = std::min<std::size_t>(
113 temperatures_.begin(),
114 std::lower_bound(temperatures_.begin(), temperatures_.end(), T)
118 return coeffs_[index];
121 void checkInput_()
const
123 if constexpr (intervals == -1)
125 if (temperatures_.size() < 2)
126 DUNE_THROW(Dune::InvalidStateException,
"Temperature range must have at least two entries.");
128 for (
size_t i = 0; i < temperatures_.size()-1; i++)
129 if (temperatures_[i] >= temperatures_[i+1])
130 DUNE_THROW(Dune::InvalidStateException,
"Temperature range must be strictly increasing.");
132 if (temperatures_.size()-1 != coeffs_.size())
133 DUNE_THROW(Dune::InvalidStateException,
"If temperature vector is size n+1, there must be n coefficient sets.");
139 static bool warningPrinted_;