13#ifndef CHEMISTRY_THERMO_H
14#define CHEMISTRY_THERMO_H
21#include <Kokkos_Core.hpp>
42template <
typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
45 Kokkos::View<double *, MemorySpace>
inv_W;
49 Kokkos::View<double *[9], Kokkos::LayoutRight, MemorySpace>
coeffs;
60 const double inv_T = 1.0 / T;
61 return {T, inv_T, inv_T * inv_T, Kokkos::log(T)};
109 const double T = p.
T;
116 template <
typename F_Y>
124 template <
typename F_Y>
133 template <
typename F_Y>
142 template <
typename F_Y>
147 const double n = y(k) *
inv_W(k);
160 template <
typename F_Y>
164 for (
int it = 0;
it < 200;
it++) {
167 const double f =
e_T -
e;
173 double T_new = T - f / cv;
175 if (Kokkos::fabs(
T_new - T) <= 1
e-10 * T)
return T_new;
183template <
typename MemorySpace = Kokkos::DefaultExecutionSpace::memory_space>
191 table.
inv_W = Kokkos::View<double *, MemorySpace>(
"thermo_inv_W", n);
192 table.
range_offset = Kokkos::View<uint32_t *, MemorySpace>(
"thermo_range_offset", n + 1);
194 table.
upper_closed = Kokkos::View<uint8_t *, MemorySpace>(
"thermo_upper_closed", n);
195 table.
coeffs = Kokkos::View<double *[9], Kokkos::LayoutRight, MemorySpace>(
"thermo_coeffs",
n_ranges);
203 double T_min = 0.0,
T_max = std::numeric_limits<double>::infinity();
210 for (
size_t i = 0;
i <
sp.thermo.coeffs.size();
i++,
r++) {
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
Gas-phase mechanisms read from Cantera YAML files.
constexpr double GAS_CONSTANT
Definition mechanism.h:26
ThermoTable< MemorySpace > make_thermo_table(const Mechanism &mechanism)
Copy a mechanism's species thermodynamics to MemorySpace.
Definition thermo.h:184
Mass fractions held in a contiguous array.
Definition thermo.h:28
KOKKOS_INLINE_FUNCTION double operator()(const uint32_t k) const
Definition thermo.h:30
const double * Y
Definition thermo.h:29
One ideal-gas phase of a Cantera YAML file: its elements, species and reactions.
Definition mechanism.h:145
std::vector< Species > species
Definition mechanism.h:149
uint32_t n_species() const
Definition mechanism.h:152
Definition mechanism.h:87
Powers of T shared by all species.
Definition thermo.h:54
double inv_T
Definition thermo.h:55
double inv_T2
Definition thermo.h:55
double log_T
Definition thermo.h:55
double T
Definition thermo.h:55
Species thermodynamics of a mechanism on the device, in double precision in every build: per species ...
Definition thermo.h:43
KOKKOS_INLINE_FUNCTION double gas_constant(const F_Y &y) const
Mixture gas constant R_u sum_k Y_k / W_k [J/(kg K)].
Definition thermo.h:117
KOKKOS_INLINE_FUNCTION double cp_mass(const double T, const F_Y &y) const
Mixture cp [J/(kg K)].
Definition thermo.h:125
KOKKOS_INLINE_FUNCTION uint32_t range(const uint32_t k, const double T) const
Definition thermo.h:65
KOKKOS_INLINE_FUNCTION double h_RT(const uint32_t k, const Powers &p) const
h_k / (R T), molar enthalpy including the formation enthalpy.
Definition thermo.h:96
Kokkos::View< uint32_t *, MemorySpace > range_offset
Definition thermo.h:46
double T_high
Definition thermo.h:51
KOKKOS_INLINE_FUNCTION void e_cv(const double T, const F_Y &y, double &e, double &cv) const
Mixture internal energy e [J/kg] and cv [J/(kg K)] at T.
Definition thermo.h:143
double T_low
Definition thermo.h:50
Kokkos::View< double *, MemorySpace > inv_W
Definition thermo.h:45
KOKKOS_INLINE_FUNCTION double h_mass(const double T, const F_Y &y) const
Mixture enthalpy [J/kg].
Definition thermo.h:134
Kokkos::View< double *, MemorySpace > range_upper
Definition thermo.h:47
Kokkos::View< uint8_t *, MemorySpace > upper_closed
Definition thermo.h:48
KOKKOS_INLINE_FUNCTION double cp_R(const uint32_t k, const Powers &p) const
cp_k / R.
Definition thermo.h:78
Kokkos::View< double *[9], Kokkos::LayoutRight, MemorySpace > coeffs
Definition thermo.h:49
static KOKKOS_INLINE_FUNCTION Powers powers(const double T)
Definition thermo.h:59
KOKKOS_INLINE_FUNCTION double dcp_R_dT(const uint32_t k, const Powers &p) const
d(cp_k / R) / dT.
Definition thermo.h:87
KOKKOS_INLINE_FUNCTION double T_from_e(const double e, const F_Y &y, const double T_guess) const
Temperature at which the mixture has internal energy e: Newton from T_guess (300 K if outside the bra...
Definition thermo.h:161
KOKKOS_INLINE_FUNCTION double s_R(const uint32_t k, const Powers &p) const
s_k / R at the standard pressure.
Definition thermo.h:107
uint32_t n_species
Definition thermo.h:44
uint8_t r
Definition teno_setup.cpp:687