21 #ifndef FUB_EQUATINOS_PERFECT_GAS_MIX_CPOS_HPP
22 #define FUB_EQUATINOS_PERFECT_GAS_MIX_CPOS_HPP
26 template <
int Rank,
typename State>
29 using Depths =
typename State::Traits::template Depths<N>;
31 if constexpr (std::is_same_v<Depths, PerfectGasMixKineticStateShape>) {
32 depths.mole_fractions = eq.n_species + 1;
34 depths.species = eq.n_species;
45 if constexpr (std::is_same_v<double, Density>) {
48 return Array1d::Constant(eq.
gamma);
70 template <
typename Density,
typename Temperature,
typename MoleFractions>
81 const double cv = eq.Rspec * eq.gamma_minus_1_inv;
82 return cv * q.temperature;
89 q.density = kin.density;
90 q.momentum = q.density * u;
92 q.energy = q.density * (e + 0.5 * u.matrix().squaredNorm());
93 const double RT = eq.Rspec * kin.temperature;
94 q.pressure = RT * q.density;
95 q.speed_of_sound = std::sqrt(eq.gamma * RT);
96 const double sum = kin.mole_fractions.sum();
97 for (
int i = 0; i < eq.n_species; i++) {
98 q.species[i] = q.density * kin.mole_fractions[i] / sum;
105 kin.density = q.density;
108 for (
int i = 0; i < eq.n_species; ++i) {
109 kin.mole_fractions[i] = q.species[i] / q.density;
110 sum += kin.mole_fractions[i];
112 kin.mole_fractions[eq.n_species] = std::max(0.0, 1.0 - sum);
130 if constexpr (std::is_same_v<double, Density>) {
131 return q.momentum[d];
143 if constexpr (std::is_same_v<double, Density>) {
144 return q.momentum / q.density;
147 for (
int i = 0; i < N; ++i) {
148 v.row(i) = q.momentum.row(i) / q.density;
160 if constexpr (std::is_same_v<double, Density>) {
161 return q.momentum[d] / q.density;
163 return q.row(d) / q.density;
200 if constexpr (std::is_same_v<double, Density>) {
203 return q.species.row(d);
222 return q.speed_of_sound;
234 const double rho_new =
235 std::pow(p_new / q0.pressure, 1 / eq.gamma) * q0.density;
239 2.0 * std::sqrt(eq.gamma * q0.pressure / q0.density) *
240 eq.gamma_minus_1_inv -
241 2.0 * std::sqrt(eq.gamma * p_new / rho_new) * eq.gamma_minus_1_inv;
243 const double rhoE_new =
247 q.momentum = rhou_new;
249 q.species = q0.species;
251 q.speed_of_sound = std::sqrt(eq.gamma * p_new / rho_new);
constexpr struct fub::euler::InternalEnergyFn InternalEnergy
constexpr struct fub::euler::SpeedOfSoundFn SpeedOfSound
constexpr struct fub::euler::EnergyFn Energy
double KineticEnergy(double density, const Eigen::Array< double, Dim, 1 > &momentum) noexcept
Definition: EulerEquation.hpp:28
constexpr struct fub::euler::SpeciesFn Species
constexpr struct fub::euler::PressureFn Pressure
constexpr struct fub::euler::MomentumFn Momentum
constexpr struct fub::euler::DensityFn Density
constexpr struct fub::euler::VelocityFn Velocity
constexpr struct fub::euler::TemperatureFn Temperature
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
std::conditional_t< N==1||M==1, Eigen::Array< T, N, M >, Eigen::Array< T, N, M, Eigen::RowMajor > > Array
Definition: Eigen.hpp:50
constexpr struct fub::DepthsFn Depths
std::decay_t< decltype(T)> tag_t
Definition: type_traits.hpp:350
void tag_invoke(tag_t< euler::CompleteFromKineticState >, const PerfectGasMix< Rank > &eq, CompleteArray< PerfectGasMix< Rank >> &q, const KineticStateArray< PerfectGasMix< Rank >> &kin, const Array< double, Rank > &u) noexcept
Definition: PerfectGasMix.hpp:611
boost::mp11::mp_transform< ToConcreteDepth, Depths > ToConcreteDepths
Definition: State.hpp:122
This type has a constructor which takes an equation and might allocate any dynamically sized member v...
Definition: State.hpp:335
Definition: State.hpp:301
Definition: PerfectGasMix.hpp:174
This is a template class for constructing conservative states for the perfect gas equations.
Definition: PerfectGasMix.hpp:43
Definition: PerfectGasMix.hpp:111
Definition: PerfectGasMix.hpp:79
Definition: PerfectGasMix.hpp:208
double gamma
Definition: PerfectGasMix.hpp:269
Definition: State.hpp:162