36 #include "antioch/ideal_gas_internal_thermo.h"
43 template <
typename Scalar>
54 template <
typename Scalar>
55 int test_relative(
const Scalar val,
const Scalar truth,
const Scalar tol,
const std::string & words)
59 bool test = (
test_zero(truth,tol))?!
test_zero(val,tol):(abs( (val-truth)/truth ) > tol );
60 Scalar diff = (
test_zero(truth,tol))?val:abs( (val-truth)/truth );
63 std::cerr << std::scientific << std::setprecision(20);
64 std::cerr <<
"Error: Mismatch in " << words
65 <<
"\n Expected = " << truth
66 <<
"\n Computed = " << val
67 <<
"\n Relative diff = " << diff
68 <<
"\n Tolerance = " << tol
77 template <
typename Scalar>
78 int test_molecule(
unsigned int spec,
const Scalar & n_tr_dofs,
const Scalar & R_spec,
79 const Scalar & cv_over_R,
const Scalar & T,
83 const std::string & name)
85 const Scalar tol = (std::numeric_limits<Scalar>::epsilon() * 2 < 5e-17L)?5e-17L:
86 std::numeric_limits<Scalar>::epsilon() * 2;
95 Scalar cv_rot = (n_tr_dofs > Scalar(1.5))?n_tr_dofs - Scalar(1.5):Scalar(0.);
96 Scalar cv_vib = (n_tr_dofs < 2.)?0.L:cv_over_R - n_tr_dofs;
98 return_flag =
test_relative(thermo.cv_tr_over_R(spec), n_tr_dofs, tol,
"cv_tr_over_R of " + name) || return_flag;
99 return_flag =
test_relative(thermo.cv_tr(spec), R_spec * n_tr_dofs, tol,
"cv_tr of " + name) || return_flag;
100 return_flag =
test_relative(thermo.cv_trans_over_R(spec), Scalar(1.5), tol,
"cv_trans_over_R of " + name) || return_flag;
101 return_flag =
test_relative(thermo.cv_trans(spec), R_spec * Scalar(1.5), tol,
"cv_trans of " + name) || return_flag;
102 return_flag =
test_relative(thermo.cv_rot_over_R(spec), cv_rot, tol,
"cv_rot_over_R of " + name) || return_flag;
103 return_flag =
test_relative(thermo.cv_rot(spec), R_spec * cv_rot, tol,
"cv_rot of " + name) || return_flag;
105 return_flag =
test_relative(thermo.cv_vib_over_R(spec,T), cv_vib, Scalar(200.L) * tol,
"cv_vib_over_R of " + name) || return_flag;
106 return_flag =
test_relative(thermo.cv_vib(spec,T), R_spec * cv_vib, Scalar(200.L) * tol,
"cv_vib of " + name) || return_flag;
110 template <
typename Scalar>
113 const Scalar Mm_N = 14.008e-3;
114 const Scalar Mm_O = 16e-3;
115 const Scalar Mm_N2 = 2.L * Mm_N;
116 const Scalar Mm_O2 = 2.L * Mm_O;
117 const Scalar Mm_NO = Mm_O + Mm_N;
119 std::vector<std::string> species_str_list;
120 const unsigned int n_species = 5;
121 species_str_list.reserve(n_species);
122 species_str_list.push_back(
"N2" );
123 species_str_list.push_back(
"O2" );
124 species_str_list.push_back(
"N" );
125 species_str_list.push_back(
"O" );
126 species_str_list.push_back(
"NO" );
135 Antioch::IdealGasInternalThermo< Antioch::NASAEvaluator<Scalar, Antioch::CEACurveFit<Scalar> >,
136 Scalar > id_thermo( nasa_thermo, chem_mixture );
139 std::vector<Scalar> mass_fractions( 5, 0.2 );
140 mass_fractions[0] = 0.5;
141 mass_fractions[1] = 0.2;
142 mass_fractions[2] = 0.1;
143 mass_fractions[3] = 0.1;
144 mass_fractions[4] = 0.1;
146 const Scalar R_N2 = Antioch::Constants::R_universal<Scalar>() / Mm_N2;
147 const Scalar R_O2 = Antioch::Constants::R_universal<Scalar>() / Mm_O2;
148 const Scalar R_N = Antioch::Constants::R_universal<Scalar>() / Mm_N;
149 const Scalar R_O = Antioch::Constants::R_universal<Scalar>() / Mm_O;
150 const Scalar R_NO = Antioch::Constants::R_universal<Scalar>() / Mm_NO;
171 int ierr = (tester<double>() ||
172 tester<long double>() ||
bool test_zero(const Scalar val, const Scalar tol)
void read_nasa_mixture_data(NASAThermoMixture< NumericType, CurveType > &thermo, const std::string &filename=DefaultSourceFilename::thermo_data(), ParsingType=ASCII, bool verbose=true)
This class only differs from NASA9CurveFit in the construction.
int test_relative(const Scalar val, const Scalar truth, const Scalar tol, const std::string &words)
static const std::string & thermo_data()
StateType cv_over_R(const TempCache< StateType > &cache, unsigned int species) const
Cv over R, from ideal gas,.
Class storing chemical mixture properties.
int test_molecule(unsigned int spec, const Scalar &n_tr_dofs, const Scalar &R_spec, const Scalar &cv_over_R, const Scalar &T, const Antioch::IdealGasInternalThermo< Antioch::NASAEvaluator< Scalar, Antioch::CEACurveFit< Scalar > >, Scalar > &thermo, const std::string &name)