44 template <
typename Scalar>
45 int tester(
const std::string& testname)
51 std::vector<std::string> species_str_list;
52 const unsigned int n_species = 4;
53 species_str_list.reserve(n_species);
54 species_str_list.push_back(
"N2" );
55 species_str_list.push_back(
"O" );
56 species_str_list.push_back(
"NO" );
57 species_str_list.push_back(
"N" );
63 const std::string equation(
"N2 + O [=] NO + N");
64 const Scalar
A = 5.7e+9L;
65 const Scalar b = 0.42L;
66 const Scalar
E = 85269.6L;
69 const bool reversible(
true);
71 const Scalar T = 1500.0L;
72 const Scalar P = 1.0e5L;
75 const Scalar P0_RT(1.0e5/Antioch::Constants::R_universal<Scalar>()/T);
76 std::vector<Scalar> h_RT_minus_s_R(n_species);
81 std::vector<Scalar> molar_densities(n_species , P/Antioch::Constants::R_universal<Scalar>()/T/Scalar(n_species));
83 Scalar k = A * Antioch::ant_pow(T,b) * Antioch::ant_exp(-E/(1.9858775L*T));
84 Scalar Keq = Antioch::ant_exp(h_RT_minus_s_R[0] + h_RT_minus_s_R[1] - h_RT_minus_s_R[2] - h_RT_minus_s_R[3]);
86 Scalar rate_fwd = k * molar_densities[0] * molar_densities[1];
87 Scalar rate_back = kback * molar_densities[2] * molar_densities[3];
88 Scalar net_rate = rate_fwd - rate_back;
91 Antioch::Reaction<Scalar>* my_rxn = Antioch::build_reaction<Scalar>(n_species, equation,reversible,typeReaction,kineticsModel);
92 std::vector<Scalar> data;
97 data.push_back(1.9858775L);
116 const Scalar tol = std::numeric_limits<Scalar>::epsilon() * 100;
118 if( abs( (rate_reversible - net_rate)/net_rate) > tol )
120 std::cout <<
"Error: Mismatch in " << testname <<
" rate reversibility." << std::endl
121 << std::setprecision(25)
122 <<
"net_rate_antioch(T) = " << rate_reversible << std::endl
123 <<
"net_rate_theory = " << net_rate << std::endl
124 <<
"relative error: " << abs( (rate_reversible - net_rate)/net_rate) << std::endl
125 <<
"tolerance: " << tol << std::endl;
130 if( abs( (rate_irreversible - rate_fwd)/rate_fwd) > tol )
132 std::cout <<
"Error: Mismatch in " << testname <<
" rate reversibility." << std::endl
133 << std::setprecision(25)
134 <<
"irr_rate_antioch(T) = " << rate_reversible << std::endl
135 <<
"irr_rate_theory = " << rate_fwd << std::endl
136 <<
"relative error: " << abs( (rate_irreversible - rate_fwd)/rate_fwd) << std::endl
137 <<
"tolerance: " << tol << std::endl;
142 if( abs( (abs(rate_reversible - rate_irreversible) - rate_back)/rate_back) > tol )
144 std::cout <<
"Error: Mismatch in " << testname <<
" rate reversibility." << std::endl
145 << std::setprecision(25)
146 <<
"irrev_rate_antioch(T) - rev_rate_antioch(T) = " << rate_irreversible - rate_reversible << std::endl
147 <<
"back_rate_theory = " << rate_back << std::endl
148 <<
"relative error: " << abs( ((rate_reversible - rate_irreversible) - rate_back)/rate_back) << std::endl
149 <<
"tolerance: " << tol << std::endl;
161 return (tester<double>(
"double") ||
162 tester<long double>(
"long double") ||
163 tester<float>(
"float"));
void add_reactant(const std::string &name, const unsigned int r_id, const unsigned int stoichiometric_coeff, const CoeffType partial_order=std::numeric_limits< CoeffType >::infinity())
A single reaction mechanism.
void initialize(unsigned int index=0)
Computes derived quantities.
base class for kinetics models
int tester(const std::string &testname)
Antioch::enable_if_c< Antioch::is_valarray< T >::value, typename Antioch::state_type< T >::type >::type pow(const T &in, const T2 &n)
void set_reversibility(const bool reversible)
Set the reversibility of reaction.
const std::map< std::string, Species > & species_name_map() const
StateType compute_rate_of_progress(const VectorStateType &molar_densities, const KineticsConditions< StateType, VectorStateType > &conditions, const StateType &P0_RT, const VectorStateType &h_RT_minus_s_R) const
void add_forward_rate(KineticsType< CoeffType, VectorCoeffType > *rate)
Add a forward rate object.
void add_product(const std::string &name, const unsigned int p_id, const unsigned int stoichiometric_coeff, const CoeffType partial_order=std::numeric_limits< CoeffType >::infinity())
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.
void print(std::ostream &os=std::cout) const
Formatted print, by default to std::cout.
This class contains the conditions of the chemistry.