32 #include "antioch_config.h"
34 #ifdef ANTIOCH_HAVE_EIGEN
35 #include "Eigen/Dense"
38 #ifdef ANTIOCH_HAVE_METAPHYSICL
39 #include "metaphysicl/numberarray.h"
42 #ifdef ANTIOCH_HAVE_VEXCL
43 #include "vexcl/vexcl.hpp"
83 #ifdef ANTIOCH_HAVE_GRVY
86 GRVY::GRVY_Timer_Class gt;
93 template <
typename Scalar,
typename PairScalars>
94 int test_val(
const PairScalars val,
const PairScalars val_exact,
95 const Scalar tol,
const std::string& val_name )
101 const PairScalars rel_error = (val - val_exact)/val_exact;
102 const PairScalars abs_rel_error = abs(rel_error);
106 std::cerr <<
"Error: Mismatch in " << val_name << std::endl
107 << val_name <<
" = " << val << std::endl
108 << val_name+
"_exact = " << val_exact << std::endl
109 <<
"abs_rel_error = " << abs_rel_error << std::endl
110 <<
"tol = " << tol << std::endl;
117 template <
typename PairScalars>
118 int tester(
const PairScalars& example,
const std::string& testname)
125 std::vector<std::string> species_str_list;
126 const unsigned int n_species = 5;
127 species_str_list.reserve(n_species);
128 species_str_list.push_back(
"N2" );
129 species_str_list.push_back(
"O2" );
130 species_str_list.push_back(
"N" );
131 species_str_list.push_back(
"O" );
132 species_str_list.push_back(
"NO" );
156 Antioch::build_constant_lewis_diffusivity<Scalar>(
D, 1.4);
165 wilke( wilke_mixture, D, mu, k );
169 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 2;
174 std::vector<PairScalars> mu(5, example);
175 std::vector<PairScalars> chi(5, example);
177 for (
unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
179 mu[0][2*tuple ] = 0.1L;
180 mu[1][2*tuple ] = 0.2L;
181 mu[2][2*tuple ] = 0.3L;
182 mu[3][2*tuple ] = 0.15L;
183 mu[4][2*tuple ] = 0.25L;
184 mu[0][2*tuple+1] = 0.25L;
185 mu[1][2*tuple+1] = 0.15L;
186 mu[2][2*tuple+1] = 0.3L;
187 mu[3][2*tuple+1] = 0.2L;
188 mu[4][2*tuple+1] = 0.1L;
190 chi[0][2*tuple ] = 0.1L;
191 chi[1][2*tuple ] = 0.2L;
192 chi[2][2*tuple ] = 0.3L;
193 chi[3][2*tuple ] = 0.15L;
194 chi[4][2*tuple ] = 0.25L;
195 chi[0][2*tuple+1] = 0.25L;
196 chi[1][2*tuple+1] = 0.15L;
197 chi[2][2*tuple+1] = 0.3L;
198 chi[3][2*tuple+1] = 0.2L;
199 chi[4][2*tuple+1] = 0.1L;
203 unsigned int N_index = 2;
204 const Scalar M_N = chem_mixture.
M(N_index);
206 for(
unsigned int r = 0; r < 5; r++ )
208 Scalar M_r = chem_mixture.
M(r);
209 PairScalars dummy = Scalar(1) + sqrt(mu[N_index]/mu[r])*
pow( M_r/M_N, Scalar(0.25L) );
210 phi_N_exact += chi[r]*dummy*dummy/sqrt(Scalar(8)*( Scalar(1) + M_N/M_r ) );
213 #ifdef ANTIOCH_HAVE_GRVY
214 gt.BeginTimer(testname);
217 std::vector<std::vector<PairScalars> > mu_mu_sqrt(mu.size());
222 const PairScalars phi_N = wilke.
compute_phi( mu_mu_sqrt, chi, N_index );
224 #ifdef ANTIOCH_HAVE_GRVY
225 gt.EndTimer(testname);
228 std::cout <<
"mu = " << mu << std::endl;
229 std::cout <<
"chi = " << chi << std::endl;
230 std::cout <<
"phi_N = " << phi_N << std::endl;
232 return_flag =
test_val( phi_N, phi_N_exact, tol, std::string(
"phi") );
253 int return_flag_temp = 0;
255 if( return_flag_temp != 0 ) return_flag = 1;
264 returnval = returnval ||
265 tester (std::valarray<float>(2*ANTIOCH_N_TUPLES),
"valarray<float>");
266 returnval = returnval ||
267 tester (std::valarray<double>(2*ANTIOCH_N_TUPLES),
"valarray<double>");
268 returnval = returnval ||
269 tester (std::valarray<long double>(2*ANTIOCH_N_TUPLES),
"valarray<ld>");
270 #ifdef ANTIOCH_HAVE_EIGEN
271 returnval = returnval ||
272 tester (Eigen::Array<float, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXf");
273 returnval = returnval ||
274 tester (Eigen::Array<double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXd");
275 returnval = returnval ||
276 tester (Eigen::Array<long double, 2*ANTIOCH_N_TUPLES, 1>(),
"Eigen::ArrayXld");
278 #ifdef ANTIOCH_HAVE_METAPHYSICL
279 returnval = returnval ||
280 tester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, float> (0),
"NumberArray<float>");
281 returnval = returnval ||
282 tester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, double> (0),
"NumberArray<double>");
283 returnval = returnval ||
284 tester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, long double> (0),
"NumberArray<ld>");
286 #ifdef ANTIOCH_HAVE_VEXCL
287 vex::Context ctx_f (vex::Filter::All);
289 returnval = returnval ||
290 tester (vex::vector<float> (ctx_f, 2*ANTIOCH_N_TUPLES),
"vex::vector<float>");
292 vex::Context ctx_d (vex::Filter::DoublePrecision);
294 returnval = returnval ||
295 tester (vex::vector<double> (ctx_d, 2*ANTIOCH_N_TUPLES),
"vex::vector<double>");
298 #ifdef ANTIOCH_HAVE_GRVY
Antioch::enable_if_c< is_eigen< T >::value, typename value_type< T >::type >::type max(const T &in)
void compute_mu_mu_sqrt(const VectorStateType &mu, typename rebind< VectorStateType, VectorStateType >::type &mu_mu_sqrt) const
Helper function to reduce code duplication.
Container class for species viscosities.
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.
int tester(const PairScalars &example, const std::string &testname)
Compute transport properties using ``mixture averaged" model.
CoeffType M(const unsigned int s) const
Molecular weight (molar mass) for species s in kg/mol.
Container class for species binary diffusion models.
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.
Class storing chemical mixture properties.
static const std::string & thermo_data()
static const std::string & blottner_data()
int test_val(const PairScalars val, const PairScalars val_exact, const Scalar tol, const std::string &val_name)
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)
_Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > zero_clone(const _Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > &ex)
Mixture object for MixtureAveragedTransport model.