15#include "libmesh/utility.h"
24#define define_mass_specific_prop_from_p_T(prop) \
25 Real IdealGasMixtureFluidProperties::prop##_from_p_T( \
26 Real p, Real T, const std::vector<Real> & x_secondary) const \
28 const auto x = secondaryToAllMassFractions(x_secondary); \
29 mooseAssert(x.size() == _n_components, "Size mismatch"); \
32 for (const auto i : make_range(_n_components)) \
33 z += x[i] * _component_fps[i]->prop##_from_p_T(p, T); \
37 ADReal IdealGasMixtureFluidProperties::prop##_from_p_T( \
38 const ADReal & p, const ADReal & T, const std::vector<ADReal> & x_secondary) const \
40 const auto x = secondaryToAllMassFractions(x_secondary); \
41 mooseAssert(x.size() == _n_components, "Size mismatch"); \
44 for (const auto i : make_range(_n_components)) \
45 z += x[i] * _component_fps[i]->prop##_from_p_T(p, T); \
56#undef define_mass_specific_prop_from_p_T
67 "component_fluid_properties",
68 "Name of component fluid properties user objects. The first entry should be the primary "
71 MooseEnum transport_mixing_rule(
"mole_fraction_average wilke",
"mole_fraction_average");
72 transport_mixing_rule.addDocumentation(
"mole_fraction_average",
73 "Uses the average weighted by molar fraction");
74 transport_mixing_rule.addDocumentation(
"wilke",
75 "Uses the rule of Wilke for the viscosity and that of "
76 "Mason and Saxena for the thermal conductivity");
78 "transport_mixing_rule",
79 transport_mixing_rule,
80 "Rule that combines the viscosities and thermal conductivities of the components");
88 _component_fp_names(getParam<
std::vector<UserObjectName>>(
"component_fluid_properties")),
89 _n_components(_component_fp_names.size()),
90 _n_secondary_components(_n_components - 1),
91 _constant_specific_heats(true),
92 _T_newton_start(
std::numeric_limits<Real>::max()),
93 _transport_mixing_rule(
97 mooseError(
"There must be at least one entry in 'component_fluid_properties'.");
105 const auto & single_phase_fp =
109 mooseError(
"Each entry in 'component_fluid_properties' must be an ideal gas that implements "
110 "IdealGasMixtureInterface, such as 'IdealGasFluidProperties' or "
111 "'NASA7IdealGasFluidProperties'.");
112 if (!ideal_gas_fp->hasConstantSpecificHeats())
145 mooseAssert(i < getNumberOfSecondaryVapors(),
"Requested secondary index too high.");
149template <
typename CppType>
152 const std::vector<CppType> & x_secondary)
const
158 sum += x_secondary[i];
160 const CppType x_primary = 1.0 - sum;
162 std::vector<CppType>
x;
163 x.push_back(x_primary);
164 x.insert(
x.end(), x_secondary.begin(), x_secondary.end());
171 const std::vector<ADReal> & x_secondary)
const
178 const std::vector<Real> & x_secondary)
const
183template <
typename CppType>
208template <
typename CppType>
212 const std::vector<CppType> &
x)
const
216 CppType cp_mix = 0, cv_mix = 0;
223 return cp_mix / cv_mix;
229 const std::vector<ADReal> &
x)
const
237 const std::vector<Real> &
x)
const
242template <
typename CppType>
246 mooseDoOnce(
mooseDeprecated(
"mixtureSpecificHeatRatio(x) is deprecated; use "
247 "mixtureSpecificHeatRatio(p, T, x) instead."));
249 mooseError(
"mixtureSpecificHeatRatio(x) requires components with constant specific heats; use "
250 "mixtureSpecificHeatRatio(p, T, x) instead.");
268template <
typename CppType>
271 const std::vector<CppType> &
x)
const
295template <
typename CppType>
297IdealGasMixtureFluidProperties::s_from_p_T_templ(
const CppType &
p,
299 const std::vector<CppType> & x_secondary)
const
316IdealGasMixtureFluidProperties::s_from_p_T(
const ADReal &
p,
318 const std::vector<ADReal> & x_secondary)
const
320 return s_from_p_T_templ(
p,
T, x_secondary);
324IdealGasMixtureFluidProperties::s_from_p_T(Real
p,
326 const std::vector<Real> & x_secondary)
const
328 return s_from_p_T_templ(
p,
T, x_secondary);
332IdealGasMixtureFluidProperties::rho_from_p_T(
const ADReal &
p,
334 const std::vector<ADReal> & x_secondary)
const
336 return 1.0 / v_from_p_T(
p,
T, x_secondary);
340IdealGasMixtureFluidProperties::rho_from_p_T(Real
p,
342 const std::vector<Real> & x_secondary)
const
344 return 1.0 / v_from_p_T(
p,
T, x_secondary);
347template <
typename CppType>
349IdealGasMixtureFluidProperties::e_from_p_rho_templ(
const CppType &
p,
351 const std::vector<CppType> & x_secondary)
const
355 return e_from_p_T(
p,
T, x_secondary);
359IdealGasMixtureFluidProperties::e_from_p_rho(
const ADReal &
p,
361 const std::vector<ADReal> & x_secondary)
const
363 return e_from_p_rho_templ(
p,
rho, x_secondary);
367IdealGasMixtureFluidProperties::e_from_p_rho(Real
p,
369 const std::vector<Real> & x_secondary)
const
371 return e_from_p_rho_templ(
p,
rho, x_secondary);
374template <
typename CppType>
376IdealGasMixtureFluidProperties::p_from_v_e_templ(
const CppType &
v,
378 const std::vector<CppType> & x_secondary)
const
383 return _R * T_from_v_e(
v, e, x_secondary) / (
M *
v);
387IdealGasMixtureFluidProperties::p_from_v_e(
const ADReal &
v,
389 const std::vector<ADReal> & x_secondary)
const
391 return p_from_v_e_templ(
v, e, x_secondary);
395IdealGasMixtureFluidProperties::p_from_v_e(Real
v,
397 const std::vector<Real> & x_secondary)
const
399 return p_from_v_e_templ(
v, e, x_secondary);
402template <
typename CppType>
404IdealGasMixtureFluidProperties::T_from_v_e_templ(
const CppType & ,
406 const std::vector<CppType> & x_secondary)
const
424 return (e - e0_sum) / cv_sum;
428 const auto e_cv_from_T = [
this, &
x](
const CppType &
T, CppType & e_T, CppType & cv_T)
447 e_cv_from_T(CppType(T0), e0, cv0);
450 const auto shifted_e = [&e_cv_from_T, shift](
const CppType & ,
456 e_cv_from_T(
T, e_T, de_T_dT);
464 const Real tolerance = 1e-8;
465 const CppType target = e + shift;
467 e, target, T0, tolerance, shifted_e,
name() +
"::T_from_v_e")
472IdealGasMixtureFluidProperties::T_from_v_e(
const ADReal &
v,
474 const std::vector<ADReal> & x_secondary)
const
476 return T_from_v_e_templ(
v, e, x_secondary);
480IdealGasMixtureFluidProperties::T_from_v_e(Real
v,
482 const std::vector<Real> & x_secondary)
const
484 return T_from_v_e_templ(
v, e, x_secondary);
487template <
typename CppType>
489IdealGasMixtureFluidProperties::c_from_p_T_templ(
const CppType &
p,
491 const std::vector<CppType> & x_secondary)
const
503IdealGasMixtureFluidProperties::c_from_p_T(
const ADReal &
p,
505 const std::vector<ADReal> & x_secondary)
const
507 return c_from_p_T_templ(
p,
T, x_secondary);
511IdealGasMixtureFluidProperties::c_from_p_T(Real
p,
513 const std::vector<Real> & x_secondary)
const
515 return c_from_p_T_templ(
p,
T, x_secondary);
518template <
typename CppType>
521 const std::vector<CppType> &
y,
522 const std::vector<CppType> &
mu)
const
530 y_mix += psi[i] *
y[i];
543 CppType denominator = 0;
546 const CppType phi_ij =
549 denominator += psi[j] * phi_ij;
551 y_mix += psi[i] *
y[i] / denominator;
556template <
typename CppType>
558IdealGasMixtureFluidProperties::mu_from_p_T_templ(
const CppType &
p,
560 const std::vector<CppType> & x_secondary)
const
570IdealGasMixtureFluidProperties::mu_from_p_T(
const ADReal &
p,
572 const std::vector<ADReal> & x_secondary)
const
574 return mu_from_p_T_templ(
p,
T, x_secondary);
578IdealGasMixtureFluidProperties::mu_from_p_T(Real
p,
580 const std::vector<Real> & x_secondary)
const
582 return mu_from_p_T_templ(
p,
T, x_secondary);
585template <
typename CppType>
587IdealGasMixtureFluidProperties::k_from_p_T_templ(
const CppType &
p,
589 const std::vector<CppType> & x_secondary)
const
597 std::vector<CppType>
mu;
608IdealGasMixtureFluidProperties::k_from_p_T(
const ADReal &
p,
610 const std::vector<ADReal> & x_secondary)
const
612 return k_from_p_T_templ(
p,
T, x_secondary);
616IdealGasMixtureFluidProperties::k_from_p_T(Real
p,
618 const std::vector<Real> & x_secondary)
const
620 return k_from_p_T_templ(
p,
T, x_secondary);
623template <
typename CppType>
627 const unsigned int i,
628 const unsigned int j)
const
632 mooseError(
"Binary diffusion coefficients require components with Lennard-Jones parameters, "
633 "such as 'NASA7IdealGasFluidProperties'.");
646 unsigned int j)
const
655 unsigned int j)
const
DualNumber< Real, DNDerivativeType, true > ADReal
const std::vector< double > y
const std::vector< double > x
define_mass_specific_prop_from_p_T(v)
registerMooseObject("FluidPropertiesApp", IdealGasMixtureFluidProperties)
static const Real _R
Universal gas constant (J/mol/K)
Class for fluid properties of an ideal gas mixture.
std::vector< ADReal > secondaryToAllMassFractions(const std::vector< ADReal > &x_secondary) const
std::vector< CppType > molarFractionsFromMassFractions_templ(const std::vector< CppType > &x) const
Computes molar fractions.
CppType mixtureMolarMass_templ(const std::vector< CppType > &x) const
Computes the mixture molar mass.
CppType mixtureSpecificHeatRatio_templ(const CppType &p, const CppType &T, const std::vector< CppType > &x) const
Computes the mixture specific heat ratio.
virtual const SinglePhaseFluidProperties & getPrimaryFluidProperties() const override
Gets the primary component single-phase fluid properties.
ADReal mixtureMolarMass(const std::vector< ADReal > &x) const
IdealGasMixtureFluidProperties(const InputParameters ¶meters)
std::vector< const GasTransportUtils::LennardJonesParameters * > _lennard_jones
Lennard-Jones parameters of the components, or nullptr for components without them.
const TransportMixingRule _transport_mixing_rule
Rule that combines the viscosities and thermal conductivities of the components.
std::vector< CppType > secondaryToAllMassFractions_templ(const std::vector< CppType > &x_secondary) const
Computes all mass fractions.
std::vector< const SinglePhaseFluidProperties * > _component_fps
Component fluid properties objects.
CppType mixTransportProperty(const std::vector< CppType > &psi, const std::vector< CppType > &y, const std::vector< CppType > &mu) const
Combines a transport property of the components with the transport mixing rule.
const unsigned int _n_secondary_components
Number of secondary components.
CppType binaryDiffusionCoefficient_templ(const CppType &p, const CppType &T, unsigned int i, unsigned int j) const
Implements binaryDiffusionCoefficient for Real and AD arguments.
virtual Real binaryDiffusionCoefficient(Real p, Real T, unsigned int i, unsigned int j) const override
Computes the Chapman-Enskog binary diffusion coefficient of a pair of components, which must both hav...
bool _constant_specific_heats
Whether all components have constant specific heats, so that the internal energy is linear in tempera...
std::vector< std::vector< Real > > _wilke_molar_mass_factor
std::vector< std::vector< Real > > _wilke_normalization
TransportMixingRule
Rules that combine the viscosities and thermal conductivities of the components.
Real _T_newton_start
Temperature at which Newton's method starts to compute the temperature from the internal energy when ...
std::vector< ADReal > molarFractionsFromMassFractions(const std::vector< ADReal > &x) const
const std::vector< UserObjectName > _component_fp_names
Names of component fluid properties.
ADReal mixtureSpecificHeatRatio(const ADReal &p, const ADReal &T, const std::vector< ADReal > &x) const
static InputParameters validParams()
virtual const SinglePhaseFluidProperties & getSecondaryFluidProperties(unsigned int i=0) const override
Gets a secondary component single-phase fluid properties.
const unsigned int _n_components
Number of components.
CppType constantSpecificHeatRatio(const std::vector< CppType > &x) const
Implements the deprecated mixtureSpecificHeatRatio(x)
Interface of the fluid properties of ideal gases that can be components of IdealGasMixtureFluidProper...
void mooseDeprecated(Args &&... args) const
const std::string & name() const
void mooseError(Args &&... args) const
Interface class for producing errors, warnings, or just quiet NaNs.
static InputParameters validParams()
Common class for single phase fluid properties.
Base class for fluid properties of vapor mixtures.
static InputParameters validParams()
CTSub CT_OPERATOR_BINARY CTMul CTCompareLess CTCompareGreater CTCompareEqual _arg template * sqrt(_arg)) *_arg.template D< dtag >()) CT_SIMPLE_UNARY_FUNCTION(tanh
std::pair< T, T > NewtonSolve(const T &x, const T &y, const Real z_initial_guess, const Real tolerance, const Functor &y_from_x_z, const std::string &caller_name, const unsigned int max_its=100, const bool verbose=false)
NewtonSolve does a 1D Newton Solve to solve the equation y = f(x, z) for variable z.
CppType binaryDiffusionCoefficient(const CppType &p, const CppType &T, const Real molar_mass_i, const Real molar_mass_j, const LennardJonesParameters &lj_i, const LennardJonesParameters &lj_j)
Chapman-Enskog binary diffusion coefficient of a dilute gas pair [m^2/s], with the Lorentz-Berthelot ...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
IntRange< T > make_range(T beg, T end)