48 template <
typename Scalar>
53 std::vector<std::string> species_str_list;
54 const unsigned int n_species = 2;
55 species_str_list.reserve(n_species);
56 species_str_list.push_back(
"N2" );
57 species_str_list.push_back(
"N" );
63 Antioch::read_reaction_set_data_xml<Scalar>( input_name,
false, reaction_set );
66 std::vector<Scalar> omega_dot(n_species);
68 const Scalar P = 1.0e5;
71 std::vector<Scalar> Y(n_species,0.2);
73 const Scalar R_mix = chem_mixture.
R(Y);
75 const unsigned int n_T_samples = 10;
76 const Scalar T0 = 500;
77 const Scalar T_inc = 500;
79 std::vector<Scalar> molar_densities(n_species,0.0);
80 std::vector<Scalar> h_RT_minus_s_R(n_species);
84 for(
unsigned int i = 0; i < n_T_samples; i++ )
86 const Scalar T = T0 + T_inc*
static_cast<Scalar
>(i);
87 const Scalar rho = P/(R_mix*T);
97 std::vector<std::vector<Scalar> > loss_matrix;
98 std::vector<std::vector<Scalar> > prod_matrix;
99 std::vector<std::vector<Scalar> > net_matrix;
101 reaction_set.
print_chemical_scheme( std::cout, cond, molar_densities, h_RT_minus_s_R, loss_matrix, prod_matrix, net_matrix );
104 kinetics.compute_mass_sources( cond, molar_densities, h_RT_minus_s_R, omega_dot );
108 for(
unsigned int s = 0; s < n_species; s++ )
112 const Scalar sum_tol = std::numeric_limits<Scalar>::epsilon() * 1.0e6;
113 if( abs( sum ) > sum_tol )
116 std::cerr <<
"Error: omega_dot did not sum to 0.0." << std::endl
117 << std::scientific << std::setprecision(16)
118 <<
"T = " << T << std::endl
119 <<
"sum = " << sum <<
", sum_tol = " << sum_tol << std::endl;
120 for(
unsigned int s = 0; s < n_species; s++ )
122 std::cerr << std::scientific << std::setprecision(16)
124 << omega_dot[s] << std::endl;
126 std::cout << std::endl << std::endl;
134 template <
typename Scalar>
135 int tester(
const std::string& input_name)
139 std::vector<std::string> species_str_list;
140 const unsigned int n_species = 5;
141 species_str_list.reserve(n_species);
142 species_str_list.push_back(
"N2" );
143 species_str_list.push_back(
"O2" );
144 species_str_list.push_back(
"N" );
145 species_str_list.push_back(
"O" );
146 species_str_list.push_back(
"NO" );
152 Antioch::read_reaction_set_data_xml<Scalar>( input_name,
false, reaction_set );
155 std::vector<Scalar> omega_dot(n_species);
157 const Scalar P = 1.0e5;
160 std::vector<Scalar> Y(n_species,0.2);
162 const Scalar R_mix = chem_mixture.
R(Y);
164 const unsigned int n_T_samples = 10;
165 const Scalar T0 = 500;
166 const Scalar T_inc = 500;
168 std::vector<Scalar> molar_densities(n_species,0.0);
169 std::vector<Scalar> h_RT_minus_s_R(n_species);
173 for(
unsigned int i = 0; i < n_T_samples; i++ )
175 const Scalar T = T0 + T_inc*
static_cast<Scalar
>(i);
176 const Scalar rho = P/(R_mix*T);
184 kinetics.compute_mass_sources( cond, molar_densities, h_RT_minus_s_R, omega_dot );
188 for(
unsigned int s = 0; s < n_species; s++ )
193 const Scalar sum_tol = std::numeric_limits<Scalar>::epsilon() * 5.0e6;
194 if( abs( sum ) > sum_tol )
197 std::cerr <<
"Error: omega_dot did not sum to 0.0." << std::endl
198 << std::scientific << std::setprecision(16)
199 <<
"T = " << T << std::endl
200 <<
"sum = " << sum <<
", sum_tol = " << sum_tol << std::endl;
201 for(
unsigned int s = 0; s < n_species; s++ )
203 std::cerr << std::scientific << std::setprecision(16)
205 << omega_dot[s] << std::endl;
207 std::cout << std::endl << std::endl;
215 int main(
int argc,
char* argv[])
221 std::cerr <<
"Error: Must specify reaction set XML input file." << std::endl;
227 return_flag += (tester<double>(std::string(argv[1])) ||
228 tester<long double>(std::string(argv[1])) ||
229 tester<float>(std::string(argv[1])));
231 return_flag += (tester_N2N<double>(std::string(argv[1])) ||
232 tester_N2N<long double>(std::string(argv[1])) ||
233 tester_N2N<float>(std::string(argv[1])));
void print_chemical_scheme(std::ostream &output, const KineticsConditions< StateType, VectorStateType > &conditions, const VectorStateType &molar_densities, const VectorStateType &h_RT_minus_s_R, std::vector< VectorStateType > &lossMatrix, std::vector< VectorStateType > &prodMatrix, std::vector< VectorStateType > &netMatrix) const
This class encapsulates all the reaction mechanisms considered in a chemical nonequilibrium simulatio...
CoeffType R(const unsigned int s) const
Gas constant for species s in [J/kg-K].
int tester_N2N(const std::string &input_name)
Class to handle computing mass source terms for a given ReactionSet.
X(const unsigned int species, const StateType &M, const StateType &mass_fraction) const template< typename VectorStateType > void X(typename Antioch VectorStateType void molar_densities(const StateType &rho, const VectorStateType &mass_fractions, VectorStateType &molar_densities) const
int main(int argc, char *argv[])
Class storing chemical mixture properties.
StateType h_RT_minus_s_R(const Cache< StateType > &cache, unsigned int species) const
We currently need different specializations for scalar vs vector inputs here.
const std::vector< ChemicalSpecies< CoeffType > * > & chemical_species() const
int tester(const std::string &input_name)
This class contains the conditions of the chemistry.
We parse the file here, with an exhaustive unit management.