37 #include "antioch_config.h"
55 #ifdef ANTIOCH_HAVE_GSL
76 template <
typename Scalar>
77 int test_val(
const Scalar val,
const Scalar val_exact,
const Scalar tol,
const std::string& val_name )
83 const Scalar rel_error = abs( (val - val_exact)/val_exact);
87 std::cerr << std::setprecision(20) << std::scientific
88 <<
"Error: Mismatch in " << val_name << std::endl
89 << val_name <<
" = " << val << std::endl
90 << val_name+
"_exact = " << val_exact << std::endl
91 <<
"rel_error = " << rel_error << std::endl
92 <<
"tol = " << tol << std::endl;
99 template <
typename Scalar>
104 std::vector<std::string> species_str_list;
105 const unsigned int n_species = 5;
106 species_str_list.reserve(n_species);
107 species_str_list.push_back(
"N2" );
108 species_str_list.push_back(
"O2" );
109 species_str_list.push_back(
"N" );
110 species_str_list.push_back(
"O" );
111 species_str_list.push_back(
"NO" );
131 Antioch::build_eucken_thermal_conductivity<MicroThermo,Scalar>(k,thermo_stat);
139 #ifdef ANTIOCH_HAVE_GSL
142 Antioch::build_kinetics_theory_viscosity<Scalar,Antioch::GSLSpliner>(ps_mu);
145 bimol_D( tran_mixture );
150 ps_k( tran_mixture );
152 Antioch::build_kinetics_theory_thermal_conductivity<MicroThermo,Scalar>(ps_k,thermo_stat);
159 const Scalar Le = 1.4;
160 Antioch::build_constant_lewis_diffusivity<Scalar>(
D, Le);
169 wilke( wilke_mixture, D, mu, k );
173 #ifdef ANTIOCH_HAVE_GSL
176 Antioch::KineticsTheoryViscosity<Scalar,Antioch::GSLSpliner>,
179 wilke_ps_evaluator(wilke_mixture,bimol_D,ps_mu,ps_k);
185 Antioch::EuckenThermalConductivity<MicroThermo> k_eucken(thermo_stat);
188 Antioch::EuckenThermalConductivity<MicroThermo>,
189 Scalar> wilke_eval_dep( wilke_mix_dep, mu, k_eucken );
193 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 5;
198 std::vector<Scalar> mu( 5 );
205 std::vector<Scalar> chi( 5 );
212 Scalar phi_N_exact = 0.0L;
213 unsigned int N_index = 2;
214 Scalar M_N = chem_mixture.
M(N_index);
216 for(
unsigned int r = 0; r < 5; r++ )
218 Scalar M_r = chem_mixture.
M(r);
219 Scalar dummy = 1.0L + std::sqrt(mu[N_index]/mu[r])*
pow( M_r/M_N, Scalar(0.25L) );
220 phi_N_exact += chi[r]*dummy*dummy/std::sqrt(8.0L*( 1.0L + M_N/M_r ) );
224 std::vector<std::vector<Scalar> > mu_mu_sqrt(mu.size());
229 phi_N = wilke.
compute_phi( mu_mu_sqrt, chi, N_index );
231 return_flag =
test_val( phi_N, phi_N_exact, tol, std::string(
"phi") );
234 const Scalar P = 1e5;
235 std::vector<Scalar> mass_fractions( 5, 0.2L);
236 const Scalar T = 1000.0L;
239 const Scalar R_mix = chem_mixture.
R(mass_fractions);
240 const Scalar rho = P/(R_mix*T);
241 const Scalar
cp = thermo_mix.
cp( T_cache, mass_fractions );
243 const Scalar wilke_mu_long_double = 4.51233094078102111066e-05L;
244 const Scalar wilke_k_long_double = 8.01027375195322618301e-02L;
246 Scalar wilke_mu = wilke.
mu(T, mass_fractions );
247 Scalar wilke_k = wilke.
k(T, mass_fractions );
249 return_flag =
test_val( wilke_mu, wilke_mu_long_double, tol,
"wilke mixture viscosity") || return_flag;
250 return_flag =
test_val( wilke_k, wilke_k_long_double, tol,
"wilke mixture thermal conduction") || return_flag;
252 std::vector<Scalar> lewis_D(5,0);
254 wilke.
mu_and_k(T,mass_fractions,wilke_mu,wilke_k);
256 return_flag =
test_val( wilke_mu, wilke_mu_long_double, tol,
"wilke mixture viscosity") || return_flag;
257 return_flag =
test_val( wilke_k, wilke_k_long_double, tol,
"wilke mixture thermal conduction") || return_flag;
259 wilke.
mu_and_k_and_D( T, rho, cp, mass_fractions, wilke_mu, wilke_k, lewis_D );
261 Scalar D_lewis_exact = wilke_k/(rho*cp*Le);
263 for(
unsigned int s = 0; s < lewis_D.size(); s++)
264 return_flag =
test_val( lewis_D[s], D_lewis_exact, tol,
"constant Lewis diffusion for species " + species_str_list[s]) || return_flag;
278 const Scalar mu_kt_long_double = 4.49877527305932602332e-05L;
279 const Scalar k_kt_long_double = 8.22050332419571328635e-02L;
281 std::vector<Scalar> D_kt_long_double(5,0);
282 D_kt_long_double[0] = 1.95418749838889089562e-04L;
283 D_kt_long_double[1] = 1.92376915629762328034e-04L;
284 D_kt_long_double[2] = 2.98006144849143296987e-04L;
285 D_kt_long_double[3] = 3.08179434829991685679e-04L;
286 D_kt_long_double[4] = 1.90508644119203653519e-04L;
288 std::vector<Scalar> D_kt(5,0);
289 wilke_ps_evaluator.
mu_and_k_and_D( T, rho, cp, mass_fractions, mu_kt, k_kt, D_kt );
292 return_flag =
test_val( mu_kt, mu_kt_long_double, tol,
"kinetics theory viscosity") || return_flag;
293 return_flag =
test_val( k_kt, k_kt_long_double, tol,
"kinetics theory thermal conduction") || return_flag;
294 for(
unsigned int s = 0; s < D_kt.size(); s++)
295 return_flag =
test_val( D_kt[s], D_kt_long_double[s], tol,
"kinetics theory diffusion for species " + species_str_list[s]) || return_flag;
297 std::vector<Scalar> D_kt_2(5,0);
298 wilke_ps_evaluator.
D(rho, T, mass_fractions, D_kt_2 );
300 for(
unsigned int s = 0; s < D_kt.size(); s++)
301 return_flag =
test_val( D_kt_2[s], D_kt_long_double[s], tol,
"kinetics theory diffusion for species " + species_str_list[s]) || return_flag;
306 Antioch::KineticsTheoryViscosity<Scalar,Antioch::GSLSpliner>,
307 Antioch::KineticsTheoryThermalConductivity<MicroThermo,Scalar>,
308 Scalar>::DiffusivityType
310 Antioch::KineticsTheoryViscosity<Scalar,Antioch::GSLSpliner>,
311 Antioch::KineticsTheoryThermalConductivity<MicroThermo,Scalar>,
312 Scalar>::MASS_FLUX_MASS_FRACTION;
314 std::vector<Scalar> D_kt_mass_mass_long_double(5);
315 D_kt_mass_mass_long_double[0] = 2.049224418207810845348e-04L;
316 D_kt_mass_mass_long_double[1] = 2.065920312318615510015e-04L;
317 D_kt_mass_mass_long_double[2] = 2.550809908204135170620e-04L;
318 D_kt_mass_mass_long_double[3] = 2.790464132548291530901e-04L;
319 D_kt_mass_mass_long_double[4] = 2.024029424511201457822e-04L;
321 std::vector<Scalar> D_kt_mass_mass(5,0);
322 wilke_ps_evaluator.
D(rho, T, mass_fractions, D_kt_mass_mass, diff_type );
324 for(
unsigned int s = 0; s < D_kt.size(); s++)
325 return_flag =
test_val( D_kt_mass_mass[s], D_kt_mass_mass_long_double[s], tol,
"kinetics theory diffusion (mass flux, mass fraction) for species " + species_str_list[s]) || return_flag;
332 Antioch::KineticsTheoryViscosity<Scalar,Antioch::GSLSpliner>,
333 Antioch::KineticsTheoryThermalConductivity<MicroThermo,Scalar>,
334 Scalar>::DiffusivityType
336 Antioch::KineticsTheoryViscosity<Scalar,Antioch::GSLSpliner>,
337 Antioch::KineticsTheoryThermalConductivity<MicroThermo,Scalar>,
338 Scalar>::MOLE_FLUX_MOLE_FRACTION;
340 std::vector<Scalar> D_kt_mole_mole_long_double(5);
341 D_kt_mole_mole_long_double[0] = 2.070373009368896292617e-04L;
342 D_kt_mole_mole_long_double[1] = 2.083783534307470249142e-04L;
343 D_kt_mole_mole_long_double[2] = 2.589403037715613871414e-04L;
344 D_kt_mole_mole_long_double[3] = 2.824017881144487186270e-04L;
345 D_kt_mole_mole_long_double[4] = 2.042449798230576410557e-04L;
347 std::vector<Scalar> D_kt_mole_mole(5,0);
348 wilke_ps_evaluator.
D(rho, T, mass_fractions, D_kt_mole_mole, diff_type );
350 for(
unsigned int s = 0; s < D_kt.size(); s++)
351 return_flag =
test_val( D_kt_mole_mole[s], D_kt_mole_mole_long_double[s], tol,
"kinetics theory diffusion (mass flux, mass fraction) for species " + species_str_list[s]) || return_flag;
364 return ( tester<double>() ||
365 tester<long double>() ||
void compute_mu_mu_sqrt(const VectorStateType &mu, typename rebind< VectorStateType, VectorStateType >::type &mu_mu_sqrt) const
Helper function to reduce code duplication.
Deprecated. Use MixtureAveragedTransportEvaluator instead.
Container class for species viscosities.
CoeffType R(const unsigned int s) const
Gas constant for species s in [J/kg-K].
value_type< VectorStateType >::type k(const StateType &T, const VectorStateType &mass_fractions) const
Mixture conducivity, in [W/m-K].
value_type< VectorStateType >::type compute_phi(typename rebind< VectorStateType, VectorStateType >::type &mu_mu_sqrt, const VectorStateType &chi, const unsigned int s) const
Helper function to reduce code duplication.
Compute transport properties using ``mixture averaged" model.
CoeffType M(const unsigned int s) const
Molecular weight (molar mass) for species s in kg/mol.
void mu_and_k_and_D(const StateType &T, const StateType &rho, const StateType &cp, const VectorStateType &mass_fractions, StateType &mu, StateType &k, VectorStateType &D_vec, DiffusivityType diff_type=DiffusivityType::MASS_FLUX_MOLE_FRACTION) const
Mixture viscosity, thermal conductivity, and diffusivities in [Pa-s], [W/m-K], [m^2/s] respectively...
Container class for species binary diffusion models.
Scalar cp(Scalar T, Scalar a0, Scalar a1, Scalar a2, Scalar a3, Scalar a4, Scalar a5, Scalar a6)
Conductivity based on kinetic theory of mixtures approximations.
int test_val(const Scalar val, const Scalar val_exact, const Scalar tol, const std::string &val_name)
void read_nasa_mixture_data(NASAThermoMixture< NumericType, CurveType > &thermo, const std::string &filename=DefaultSourceFilename::thermo_data(), ParsingType=ASCII, bool verbose=true)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
Species conductivity based on Eucken relation.
value_type< VectorStateType >::type mu(const StateType &T, const VectorStateType &mass_fractions) const
Mixture viscosity, in [Pa-s].
Class storing chemical mixture properties.
void D(const StateType &rho, const StateType &T, const VectorStateType &mass_fractions, VectorStateType &D_vec, DiffusivityType diff_type=DiffusivityType::MASS_FLUX_MOLE_FRACTION) const
Mixture diffusivities for each species, in [m^2/s].
static const std::string & thermo_data()
static const std::string & blottner_data()
void set_zero(_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &a)
Container class for species thermal conductivities.
Class storing chemical mixture properties.
void init_constant(Vector &output, const Scalar &example)
void read_blottner_data_ascii(MixtureViscosity< BlottnerViscosity< NumericType >, NumericType > &mu, const std::string &filename)
StateType cp(const TempCache< StateType > &cache, unsigned int species) const
We currently need different specializations for scalar vs vector inputs here.
Mixture object for MixtureAveragedTransport model.
void mu_and_k(const StateType &T, const VectorStateType &mass_fractions, StateType &mu, StateType &k) const
Mixture viscosity and thermal conductivity, in [Pa-s], [W/m-K] respectively.